问题
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.
回答1:
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; ?>
来源:https://stackoverflow.com/questions/14536473/opencart-hide-special-offers-title-if-no-special-offers-available