how to replace "opencart" word from back-end - opencart

i want to replace the "Opencart" word from my back-end by the name of my store. I mean the "Opencart" written before the "Administration" in back end and from its footer in Dashboard. Will please any one help me out?
Thank you..

I think "Opencart" not word but it's an image logo.
You can edit this line :
<div class="div2">
<img src="view/image/logo.png" title="<?php echo $heading_title; ?>" onclick="location = '<?php echo $home; ?>'" />
</div>
location file : admin/view/template/common/header.tpl

Related

Variables in expr regular expressions

I have a simple bash script. It reads a bunch of HTML from the file test.html and pulls out a substring, but right now it's not outputting anything.
grep yt-lockup-content test.html | while read -r line; do
datasession=`expr "$line" : ".*data-sessionlink=\"\(.*\)\" >.*"`;
users=`expr "$line" : ".*data-sessionlink=\"$datasession\" >\(.*\)</a>.*"`; echo ${users}
done
I've pinpointed the problem being that it doesn't work with the variable $datasession. If I replace it with the proper text from the first block of HTML it works fine.
grep yt-lockup-content test.html | while read -r line; do
datasession=`expr "$line" : ".*data-sessionlink=\"\(.*\)\" >.*"`;
users=`expr "$line" : ".*data-sessionlink=\"itct=CJgBEJQ1GAMiEwjOnsu1ou_RAhVJdaoKHVzWA1Eojh4\" >\(.*\)</a>.*"`; echo ${users}
done
Any suggestions on how to get my idea to work?
test.html:
</div><div class="yt-lockup-content"><h3 class="yt-lockup-title polymer-title">Ellen's Comments on the Travel Ban<span class="accessible-description" id="description-id-183985"> - Duration: 2:44.</span></h3><div class="yt-lockup-byline polymer-byline"><a href="/user/TheEllenShow" class="g-hovercard yt-uix-sessionlink spf-link " data-ytid="UCp0hYYBW6IMayGgR-WeoCvQ" data-sessionlink="itct=CJgBEJQ1GAMiEwjOnsu1ou_RAhVJdaoKHVzWA1Eojh4" >TheEllenShow</a> <span class="yt-uix-tooltip yt-channel-title-icon-verified yt-sprite" title="Verified"></span></div><div class="yt-lockup-meta polymer-metadata"><ul class="yt-lockup-meta-info"><li>855,335 views</li><li>1 day ago</li></ul></div></div></div></div></li><li class="yt-shelf-grid-item yt-uix-shelfslider-item"><div class="yt-lockup yt-lockup-grid yt-lockup-video vve-check clearfix" data-context-item-id="sAwFLtbc7_c" data-visibility-tracking="CJcBEJQ1GAQiEwjOnsu1ou_RAhVJdaoKHVzWA1Eojh5A99_ztu2lgYawAQ=="><div class="yt-lockup-dismissable"><div class="yt-lockup-thumbnail contains-addto polymer-thumbnail-padding"><a aria-hidden="true" href="/watch?v=sAwFLtbc7_c" class=" yt-uix-sessionlink spf-link " data-sessionlink="itct=CJcBEJQ1GAQiEwjOnsu1ou_RAhVJdaoKHVzWA1Eojh4yCmctaGlnaC10cnZaD0ZFd2hhdF90b193YXRjaA" ><div class="yt-thumb video-thumb"><span class="yt-thumb-simple">
<img width="196" data-ytimg="1" height="110" alt="" src="https://i.ytimg.com/vi/sAwFLtbc7_c/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=qC9IiuL6075XOXO7ipK_PmTwmx8" onload=";__ytRIL(this)" >
<span class="video-time" aria-hidden="true">5:24</span></span></div></a> <span class="thumb-menu dark-overflow-action-menu video-actions">
<button type="button" aria-expanded="false" class="yt-uix-button-reverse flip addto-watch-queue-menu spf-nolink hide-until-delayloaded yt-uix-button yt-uix-button-dark-overflow-action-menu yt-uix-button-size-default yt-uix-button-has-icon no-icon-markup yt-uix-button-empty" onclick=";return false;" aria-haspopup="true" ><span class="yt-uix-button-arrow yt-sprite"></span><ul class="watch-queue-thumb-menu yt-uix-button-menu yt-uix-button-menu-dark-overflow-action-menu hid"><li role="menuitem" class="overflow-menu-choice addto-watch-queue-menu-choice addto-watch-queue-play-next yt-uix-button-menu-item" data-action="play-next" onclick=";return false;" data-video-ids="sAwFLtbc7_c"><span class="addto-watch-queue-menu-text">Play next</span></li><li role="menuitem" class="overflow-menu-choice addto-watch-queue-menu-choice addto-watch-queue-play-now yt-uix-button-menu-item" data-action="play-now" onclick=";return false;" data-video-ids="sAwFLtbc7_c"><span class="addto-watch-queue-menu-text">Play now</span></li></ul></button>
</span>
The text I'm trying to pull out with grep and expr is the YouTube username: TheEllenShow
The solution I've come up with is as follows. Keep in mind that this is a "just barely works" solution and I'm only using it so i can complete my project and move on. As Chepener has said, expr is not a good tool for this job and i only used it because i was required to.
grep yt-lockup-content test.html | while read -r line; do
users=`expr "$line" : ".*[a-zA-Z0-9]\" >\(.*\)</a>[</div>? ?]*"`; echo ${users}
done

Change Image Size on Product Page in opencart 2.0.1.1

I have small problem with changing size of the product image only on product page.
I know that from admin I can change the size for all thumb pictures.
But how to make bigger images only on the product page and I am not talking about additional images section...
Can anyone explain to me where $thumb variable is defined as i made search in almost all php files but I cannot find $thumb declaration...????
In product.tpl
Code:
<div id="product">
<div class="a"><img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>"><br>
<?php echo $text_enlarge; ?></div>
Now in this bit taken from product.tpl I see that path for the image is taken from the variable called $thumb.
I want Opencart to:
Prepare for me medium sized image
Generate for it path that will be stored in $medium variable which I can call in this place and simply have the code like this:
Code:
<div id="product">
<div class="a"><img src="<?php echo $medium; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>"><br>
<?php echo $text_enlarge; ?></div>
Anyone please help...
Before you start work in opencart, You should have to understand the basic knowledge of opencart MVC-L (i.e. How opencart module works)
Here is the Tutorial
$thumb which is defined in product.tpl file is declared in its controller file ( catalog/product/product.php ) named $data['thumb'].
Maximum variables used in product.tpl file are defined in modules controller file.
To more information, Check the above shared tutorial.

Trying to validate one or more email extensions using regular expression

I'm getting a user to input their email address and trying to validate it using regular expressions and the preg match function. I'm unable to get the code to validate different email extensions (hotmail, gmail, blueyonder etc.) as I'm only able to get it to accept one and cannot use an OR function in the code. I'm not getting a specific error but as it is the user will have to be limted to just using the 'gmail.co.uk' extension. Any help?
Code:
<?php
$emailErr = "";
$email = "";
if(isset($_POST['submit'])){
if(empty($_POST["email"])) {
$emailErr = "Email is required";
}else{
$email = ($_POST["email"]);
if (!preg_match("/[a-zA-Z_-]+#[gmail]+.+[co]+.+[uk]/",$email)){
$emailErr = "Only letters and white space allowed";
}
}
}
?>
<html>
<head>
<title> symbol test</title>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<form name = "testform" method="POST">
<p>Email:<input type="text" name="email" style="width:20%"/>
<span class="error">*<?php echo $emailErr;?></span>
<p><br><input type="submit" name="submit" value="Submit"/></br></p>
</form>
<?php
echo $email;
?>
</body>
</html>
[gmail] is not the actual way to go. This matches g or m or a or i or l.
[a-zA-Z_-]+#gmail\.co\.\uk
Add anchors if necessary.
if (!preg_match("~^[a-zA-Z_-]+#gmail\.co\.uk$~",$email)){
If you are looking for a generic regex to match all kind of valid email-ID then you can try
^(?![\W_])((?:([\w-]{2,})\.?){1,})(?<![\W_])#(?![\W_])(?=[\w.-]{5,})(?=.+\..+)(?1)(?<![\W_])$
Look at the regex demo for detailed overview.

How to add a PHP if statement within an echo?

I would like to place an if statement within an echo and I am not quite sure how to do it. Here is the echo:
if(!$hideProduct) {
echo '
<div class="gearBorder">
<img title="Sold Out" alt="Sold Out" class="soldOut" src="soldout.png" />':"").'
<div class="gearInfo">
<h4>' . $productName . '</h4>
<p class="gearDesc">'. $productDescription .'</p>
<p class="cost">$' . $productPrice . '</div>
</div>
</div>
';}
On line 3, I would like to wrap the image in an if statement:
if($productStatus = '0') {
}
What would be the best way to wrap the image in that statement? Thanks!
You can actually end control flow blocks like if statements outside of the same PHP block they were opened in. For example, this should work:
<?php if (!$hideProduct) { ?>
<div class="gearBorder">
<?php if ($productStatus == '0') { ?>
<img title="Sold Out" ... />
<?php } ?>
...HTML...
</div>
<?php } ?>
If you don't like the curly braces, you can also replace them with a colon (:) and endif, respectively. See this link for more information.
Use an array to hold the CSS classes (with background-image) for each $productStatus
Fast and efficient. There is a performance hot when you toggle from HTML mode to PHP mode. This method eliminates the if elseif performance hit in the Intel micro code.
<style type="text/css">
.soldout{width:40px;height:40px;background-image: url('soldout.png');}
.backorder{width:40px;height:40px;background-image: url('backorder.png');}
.instock{width:40px;height:40px;background-image: url('instock.png');}
</style>
$icon = array(' class="soldout" ',' class="backorder" ',' class="instock" ');.
echo '<div class="gearBorder"><div ' . $icon[$productStatus] . '></div><div class="gearInfo"> ... ';
I would also use a 4-bit color GIF icon and convert it to Base64 MIME
Make sure page is served with gZip and there will be little to no penalty for the Base64.
If you want to stick with image files, make sure images are served with a large cache max-age value.
background-image: url('data:image/gif;base64,R0lGODlhKAAoAK...');

What is the proper way to add a custom dashboard "box" in the Magento backend without editing default templates?

I am working on creating what I hope one day will be a publicly available Magento extension (this part I mention because it's important to me that I do the "right thing" here). One of the things I would like to do is add a box in the default Magento dashboard, basically a new "box" exactly like "Top 5 Search Terms" except with my own content. I would like my new custom box to be the last box that is displayed (ideally).
The issue that I'm running into is that the template that is responsible for rendering the dashboard calls out specific blocks to be rendered, and these blocks are nested inside of html. In other words, where often there is an area where child blocks will be rendered into a nice reasonable HTML element, in this situation it appears that specific blocks are rendered. Here is the contents of /app/design/adminhtml/default/default/template/dashboard/index.phtml
<div class="dashboard-container">
<?php echo $this->getChildHtml('store_switcher') ?>
<table cellspacing="25" width="100%">
<tr>
<td><?php echo $this->getChildHtml('sales') ?>
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Last 5 Orders') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('lastOrders'); ?></fieldset>
</div>
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Last 5 Search Terms') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('lastSearches'); ?></fieldset>
</div>
<div class="entry-edit">
<div class="entry-edit-head"><h4><?php echo $this->__('Top 5 Search Terms') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('topSearches'); ?></fieldset>
</div>
</td>
<td>
<div class="entry-edit" style="border:1px solid #ccc;">
<?php echo $this->getChildHtml('diagrams') ?>
<?php if (is_array($this->getChild('diagrams')->getTabsIds())) : ?>
<div id="diagram_tab_content"></div>
<?php endif; ?>
<div style="margin:20px;">
<?php echo $this->getChildHtml('totals') ?>
</div>
<div style="margin:20px;">
<?php echo $this->getChildHtml('grids') ?>
<div id="grid_tab_content"></div>
</div>
</div>
</td>
</tr>
</table>
</div>
If I was doing this in my own store, I believe I could achieve this relatively easily by editing the base Magento dashboard template index.phtml above, add what I need to have my block render, something like:
<div class="entry-edit">
<div class="entry-edit-head">
<h4><?php echo $this->__('Top 5 Search Terms') ?></h4></div>
<fieldset class="np"><?php echo $this->getChildHtml('myDashboardBox'); ?></fieldset>
</div>
</div>
But, this isn't my own store, so this doesn't really seem like an option.
Now, after some thought my options seem to be as follows (note that most of these seem "bad" and not something I'd be super proud to have seen in the public):
0) Something obvious that I'm not seeing that you will tell me is the perfect/right solution
1) I might (maybe?) be able to add my custom block inside of one of these other blocks in this area ("topSearches", "sales", etc) and have my block rendered. This does not seem very "clean"
2) I might be able to have the block rendered somewhere else on the dashboard page, and then move it with javascript to the correct place. This would be fairly easy I'm guessing, but feels very "hacky" for obvious reasons.
Does anybody have any feedback on the way to do this, or IF there is a way? Keep in mind that again I would like to release this module publicly so my goal is to do a good job and do as little "hacking" as possible.
Thank you very much for reading!
There is no really clean option, as you said, the template is coded in a non-extendable way, so there will always be some degree of hackiness. This is my personal preferred way of doing it by using event observers. This way it at least doesn't conflict with other modules.
First, add an observer for the core_block_abstract_prepare_layout_after and core_block_abstract_to_html_after event.
<adminhtml>
<events>
<core_block_abstract_prepare_layout_after>
<observers>
<your_module>
<class>your_module/observer</class>
<method>coreBlockAbstractPrepareLayoutAfter</method>
</your_module>
</observers>
</core_block_abstract_prepare_layout_after>
<core_block_abstract_to_html_after>
<observers>
<your_module>
<class>your_module/observer</class>
<method>coreBlockAbstractToHtmlAfter</method>
</your_module>
</observers>
</core_block_abstract_to_html_after>
</events>
</adminhtml>
These two events are dispatched for every block that is instantiated and rendered in Mage_Core_Block_Abstract. In my experience it's not such an issue using them in the adminhtml interface, but on the frontend observers for these events add too much overhead.
Back to the task at hand, you need to create the observer class.
class Your_Module_Model_Observer
{
public function coreBlockAbstractPrepareLayoutAfter(Varien_Event_Observer $observer)
{
if (Mage::app()->getFrontController()->getAction()->getFullActionName() === 'adminhtml_dashboard_index')
{
$block = $observer->getBlock();
if ($block->getNameInLayout() === 'dashboard')
{
$block->getChild('topSearches')->setUseAsDashboardHook(true);
}
}
}
public function coreBlockAbstractToHtmlAfter(Varien_Event_Observer $observer)
{
if (Mage::app()->getFrontController()->getAction()->getFullActionName() === 'adminhtml_dashboard_index')
{
if ($observer->getBlock()->getUseAsDashboardHook())
{
$html = $observer->getTransport()->getHtml();
$myBlock = $observer->getBlock()->getLayout()
->createBlock('you_module/block')
->setTheValuesAndTemplateYouNeed('HA!');
$html .= $myBlock->toHtml();
$observer->getTransport()->setHtml($html);
}
}
}
}
Your template will need to accomodate for the fact that you are inserting a sibling <div> from inside the sibling, but otherwise you should be fine.
</fieldset></div>
<div class="entry-edit">
<div class="entry-edit-head"><h4>Your Module</h4></div>
<fieldset class="np">Your Content
Leave it at that, because the parent template will be closing the <fieldset> and the <div> for you (ugly as heck, I know).