Sub Category Description Shown in Category List

More
14 years 2 months ago #4130 by james_sgp
I thought I had this working previously, but it isn`t now.

I want to be able to see the sub-category description in the category list, like shown below:


[Main category]
[Main category description]

[Sub category 1]
[Sub category 1 Description]

[Sub category 2]
[Sub category 2 Description]

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

More
14 years 2 months ago #4134 by yopyop001
Hi,

You have to edit the file category_subcategories.php of your template.

In the loop:
Code:
foreach ($this->categories as $sub) : ... endforeach;

you can display the subcategory description using :
Code:
$sub->description

If you want to use the subcategory image you can use :
Code:
<?php echo JHTML::_('image.site', $sub->image, 'images/stories/', NULL, NULL, $sub->title); ?>

I hope it helps.

Rgds.

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

More
14 years 1 month ago #4194 by james_sgp
I had already tried that, but for some reason I`m just seeing the HMTL code of the item description...not the formatted version?

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

More
14 years 1 month ago #5347 by werrabbit
Hi yopyop001 !!

I tried this:

yopyop001 wrote: Hi,
you can display the subcategory description using :

Code:
$sub->description

changed:
Code:
[url=<?php echo JRoute::_( FlexicontentHelperRoute::getCategoryRoute($sub->slug) ); ?>]<?php echo $this->escape($sub->title); ?>[/url]
to:
Code:
<div class="subcatView"><div>[url=<?php echo JRoute::_( FlexicontentHelperRoute::getCategoryRoute($sub->slug) ); ?>]<?php echo '<h2 class="subcatTitle">'; echo $this->escape($sub->title);echo '</h2>';?>[/url]</div>
to add some styles to the title, and:
Code:
<div class="subcatDesc"><?php echo $this->escape($sub->description) ?></div>
to add the description and styles for it

and it really works for me!
I know nothing of php, could you write here the "if" condition to display the description if there is one, and leave the field empty if not.

for the rest (like images display) I'll try to look into categories_categories.php but I do not know what parameters to use.
( :cry: I know nothing of php, can just compare and copy :cry: )

thank you, will make sure get back and post if I do something nice =)
cheers

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

More
14 years 1 month ago #5355 by yopyop001
Hi,

You can try :
Code:
<?php if($sub->description) : ?> <div class="subcatDesc"><?php echo $this->escape($sub->description) ?></div> <?php endif; ?>

to avoid display
Code:
<div class="subcatDesc"></div>
when description is empty.

Regards

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

More
14 years 1 month ago #5363 by werrabbit
yes exactly fro this reason,
and it works as expected :) !!

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.416 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline