I want to make a relatively simple modification to OpenCart so that if there are no Special Offers available, or applicable, that the title Special Offers does not display.
If none are available or applicable, currently it will display the heading title on a coloured background which looks odd if there are no special offers to show.
I am guessing the modification needs to be made to /catalog/controller/module/special.php and would be something like.
If special offers > 0 then do this
else
Don't do anything
But I am not sure how to implement this.
I'd be grateful if someone could advise.
Not entirely sure what you are referring to here, but you would be best editing the template not the controller file and using
<?php if($products) { echo $heading_title; } ?>
in place of what is there currently - something like just <?php echo $heading_title; ?>
Also you may find the title is surrounded by <h1> or <h2> tags. If so, just do the same but around the tags, something like
<?php if($products): ?>
<h2><?php echo $heading_title; ?></h2>
<?php endif; ?>
Related
If I click on a product from my product overview on the left side, the shop does not load with the list.phtml. As soon as I swap view to grid or list, it swaps to the list.phtml file and everything is fine. But as I said, if I click on the products on the sidebar, it doesnt work (it's not even affected by list.phtml at all). I removed all the code inside it and it still showed (a bit different, that's why I want to change it) the products, but as soon as I swapped mode, everything disappeared -- as it should. Do you know where I can change that?
Thank you.
It should use list.phtml file. In that file it is defined for both list mode and grid mode.
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php $_iterator = 0; ?>
And
<?php else: ?>
<?php // Grid Mode ?>
<?php $_collectionSize = $_productCollection->count() ?>
You can see something like above code in your list.phtml file,one is for list mode and another for grid mode. This is the default case unless you haven't changed the layout or template code.
If you want to know the file location than you can always enable template path hint. If you don't know how to do that you can follow this.
After knowing from which file it is rendering you can fix it.
Hope this will help.
I've been trying to create simple script that swaps table data based on the active currency code. It's for a size chart (on product.tpl).
PREMISE:
IF "USD" is active then display table "A" (Inches), ELSE display table "B" (Centimeters).
I'm a total hack with php/js, but enough to find my way into trouble. :)
I followed this thread to bring the currency code variable into "product.tpl": How to get currency to show on product page in opencart?
Now I'm just banging my head, I can't find the right variable to create the swap... I've tried multiple variations of a simple If/Else script, basically like this:
<?php if ($currency['code'] == $currency_code) { ?>
<td>15.5"</td>
<td>25"</td>
<?php } else { ?>
<td >40cm</td>
<td >64cm</td>
<?php } ?>
Anyone have a clue what the script might look like?
Or am I totally barking at the wrong cat here?? Thx
Just use the session value for the currency code...
<?php if($this->session->data['currency'] == 'USD') : ?>
<td>15.5"</td>
<td>25"</td>
<?php else: ?>
<td>40cm</td>
<td>60cm</td>
<?php endif; ?>
I'd like to use my product tags as meta keywords on every product page. Can anyone help me with this code?
Thaks
Below are some tips and they are general but give a direction of the different approaches to do this. Step 4 is a bit obvious. I am sorry but this not a module request forum, your question I think is fair so this direction set should get you in the right direction.
1 - Open catalog/view/theme/default/product/product.tpl
And do a find and replace with the header echo:
<?php
$getKeysandReplace=$header;
$getKeysandReplace=str_replace("<meta name=", "");
?>
Understand? Or use a regex to delete the Meta Keyword and Meta Description from the $header string and replace them with your own on the product.tpl - just grab the tags echo in the below code.
<?php if ($tags) { ?>
<div class="tags"><b><?php echo $text_tags; ?></b>
<?php for ($i = 0; $i < count($tags); $i++) { ?>
<?php if ($i < (count($tags) - 1)) { ?>
<?php echo $tags[$i]['tag']; ?>,
<?php } else { ?>
<?php echo $tags[$i]['tag']; ?>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
2 - You can edit header.tpl and do a IF($GET or if page is product type page then display this Meta Tag or display the normal tags.
3 - You can do an SQL crob job that copies the product tags, and places them as product keywords in your database everyday.
4 - Make sure staff copy and paste the tags as keywords to in the admin panel - stating the obvious
I am beginning to use Opencart and I am making my own template by copying the default template.
When I was going through template/common/header.tpl, I see the following lines
<?php foreach ($styles as $style) { ?>
<link rel="<?php echo $style['rel']; ?>" type="text/css" href="<?php echo $style['href']; ?>" media="<?php echo $style['media']; ?>" />
<?php } ?>
I have been thinking for a while, how it is getting populated. Though I have changed the theme to be used as my new theme, it is still populated with old default stylesheets. I will be really thankful if anyone can point me to the direction I have missed. I am sorry if it is a naive question.
Styles get added to the array using $this->document->addStyle() by the various controller classes. The $this->document class is located in /system/library/document.php if you want to see the source code for the method
Hy,
I'm look for a way to do this on symfony:
I've to use a "box" a bit every where on my site... this box is resizable ... so the html/css is not simple... and i don't want to copy/paste it every where and the content of this box is not constant at all... so its not possible to make a partial template with a object variable... and pass all the content on a variable it's a bit annoying.
someyhing like this would be great:
<?PHP begin("mytemplate") ?>
"html content"
<?PHP end ?>
thanks for your help
Everywhere you need this "box" try this:
include_partial('mymodule/mypartial', array('variable1' => 'value1', 'variable2' => 'value2'));
and in your "mymodule/templates/_mypartial.php" use it like:
<div class="box"><?php echo $variable1 ?></div>
If you don't want to use partials you can use components and define each variable into the component action. Check Symfony's Components Slots (this is for v1.2 but works in v1.4).