Keyword

How to hide readmore on categories without items?

  • Henrik Holm Nielsen
  • Henrik Holm Nielsen's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 7 months ago #94392 by Henrik Holm Nielsen
How to hide readmore on categories without items? was created by Henrik Holm Nielsen
Hi all,

 

Being new to K2, I'm trying to implement some sort of automatic way, of not having the "Read more" displayed on Categories without items. As we have many categories, I would really like to avoid the manual way of doing this, by setting this on each category.

 

So - in the K2 template, I have modified the showing of the "subCategoryMore" class, and added the if-statement trying to determine if there is any items below the category.

 

<?php if(($subCategory->numOfItems) != 0): ?>     <a class="subCategoryMore" href="<?php echo $subCategory->link; ?>">      <?php echo JText::_('View items...'); ?>    </a><?php endif; ?>

 

However - this only works, if I have set the "Item counter (next to sub-category title)" to show in the category view options.

 

Does anybody have a suggestion on how to make this independant of showing the "Item counter" next to the category title?

 

edit: link removed... 

Cheers,Henrik ;)

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #94393 by william white
Replied by william white on topic How to hide readmore on categories without items?
Try wrapping your item counter code in your override with the same statement as you using for readmore

Please Log in or Create an account to join the conversation.

  • Henrik Holm Nielsen
  • Henrik Holm Nielsen's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 7 months ago #94394 by Henrik Holm Nielsen
Replied by Henrik Holm Nielsen on topic How to hide readmore on categories without items?
William,

 

You were right - that did it...

<?php if($this->params->get('subCatTitleItemCounter')): ?>     <?php if(($subCategory->numOfItems) > 0): ?>         <a class="subCategoryMore" href="<?php echo $subCategory->link; ?>">           <?php echo JText::_('View items...'); ?>        </a>

     <?php endif; ?>  <?php endif; ?>

And then I had to remove the showing of the itemcounter earlier in category.php - but thats OK for me in this override.

 

Thanx a million for the suggestion :)

 

Cheers,

Henrik;)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum