Post by Sakoulis » Tue Feb 21, 2017 7:20 am

Hello all.

I would like to show the category description only when the first page of the products' of any category is shown. When a user selects the 2nd page, the 3rd page and so on, the category description will not be shown.
Is there any easy way to do it?

Thanks in advance.

Newbie

Posts

Joined
Thu Jun 19, 2014 1:14 pm

Post by Sakoulis » Wed Feb 22, 2017 4:32 am

I tried myself and I made it. Here is the solution:

In file "catalog/view/theme/default/template/product/category.tpl"
SEARCH for the line

Code: Select all

<?php if ($thumb || $description) { ?>
and put BEFORE that line that line

Code: Select all

<?php if (($this->request->get['page']) == '1' || ($this->request->get['page']) == '') { ?>
and SEARCH for the line

Code: Select all

<?php if ($categories) { ?>
and put BEFORE that line that line

Code: Select all

<?php } ?>
In other words, SEARCH for the code

Code: Select all

  <?php if ($thumb || $description) { ?>
  <div class="category-info">
    <?php if ($thumb) { ?>
    <div class="image"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" /></div>
    <?php } ?>
    <?php if ($description) { ?>
    <?php echo MijoShop::get('base')->triggerContentPlg($description); ?>
    <?php } ?>
  </div>
  <?php } ?>
and REPLACE it with

Code: Select all

  <?php if (($this->request->get['page']) == '1' || ($this->request->get['page']) == '') { ?>
  <?php if ($thumb || $description) { ?>
  <div class="category-info">
    <?php if ($thumb) { ?>
    <div class="image"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" /></div>
    <?php } ?>
    <?php if ($description) { ?>
    <?php echo MijoShop::get('base')->triggerContentPlg($description); ?>
    <?php } ?>
  </div>
  <?php } ?>
  <?php } ?>

Newbie

Posts

Joined
Thu Jun 19, 2014 1:14 pm

Post by Sakoulis » Wed Feb 22, 2017 4:35 am

Here is an .xml file I made so you can avoid editing the source files by uploading the file to vqmod/xml folder.

Attachments


Newbie

Posts

Joined
Thu Jun 19, 2014 1:14 pm

Post by vesel@abv.bg » Wed Mar 15, 2017 1:46 pm

Which OC version is that?
Not working on 2.2.

Newbie

Posts

Joined
Fri May 27, 2016 5:29 am

Post by nobreak » Mon Mar 01, 2021 5:46 pm

Opencart 1.5.6.4 not working :(

New member

Posts

Joined
Wed Jul 02, 2014 3:23 pm

Post by nobreak » Mon Mar 01, 2021 7:17 pm

Is there a working solution to the problem?

New member

Posts

Joined
Wed Jul 02, 2014 3:23 pm

Post by danielmedia74 » Sun Apr 11, 2021 9:57 am

I bump this thread i'm facing the same issue in opencart 3.0.3.3 does anyone have a soulution for this problem?

Newbie

Posts

Joined
Thu Apr 08, 2021 9:21 pm

Post by straightlight » Sun Apr 11, 2021 10:22 am

Sakoulis wrote:
Wed Feb 22, 2017 4:32 am
I tried myself and I made it. Here is the solution:

In file "catalog/view/theme/default/template/product/category.tpl"
SEARCH for the line

Code: Select all

<?php if ($thumb || $description) { ?>
and put BEFORE that line that line

Code: Select all

<?php if (($this->request->get['page']) == '1' || ($this->request->get['page']) == '') { ?>
and SEARCH for the line

Code: Select all

<?php if ($categories) { ?>
and put BEFORE that line that line

Code: Select all

<?php } ?>
In other words, SEARCH for the code

Code: Select all

  <?php if ($thumb || $description) { ?>
  <div class="category-info">
    <?php if ($thumb) { ?>
    <div class="image"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" /></div>
    <?php } ?>
    <?php if ($description) { ?>
    <?php echo MijoShop::get('base')->triggerContentPlg($description); ?>
    <?php } ?>
  </div>
  <?php } ?>
and REPLACE it with

Code: Select all

  <?php if (($this->request->get['page']) == '1' || ($this->request->get['page']) == '') { ?>
  <?php if ($thumb || $description) { ?>
  <div class="category-info">
    <?php if ($thumb) { ?>
    <div class="image"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" /></div>
    <?php } ?>
    <?php if ($description) { ?>
    <?php echo MijoShop::get('base')->triggerContentPlg($description); ?>
    <?php } ?>
  </div>
  <?php } ?>
  <?php } ?>
Normally, for OC v2.2x and above, an event would need to be created. However, to convert the codes to OC v3.x releases, it is as followed.

In catalog/controller/product/category.php file, find:

Code: Select all

$data['breadcrumbs'] = array();
add above:

Code: Select all

$data['page'] = $page;
Then, in catalog/view/theme/<your_theme>/template/product/category.twig file, find:

Code: Select all

{% if thumb or description %}
add above:

Code: Select all

{% if page %}
Then, find:

Code: Select all

{% if categories %}
add above:

Code: Select all

{% endif %}
Then, follow this FAQ: viewtopic.php?f=134&t=215776#p718325 .

This should resolve the issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 113 guests