Sub Category Description Shown in Category List

More
15 years 11 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
15 years 11 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
15 years 11 months 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
15 years 10 months 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
15 years 10 months 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
15 years 10 months 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.

More
15 years 10 months ago #5364 by werrabbit
I tried the same with image:
Code:
<?php if($sub->image) : ?> <div class="subcatImage"> <?php echo JHTML::_('image.site', $sub->image, 'images/stories/', NULL, NULL, $sub->title); ?> </div> <?php endif; ?>
and this works too!

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

More
15 years 6 months ago #8412 by simjoubert
Hello I try yours code (sorry Iam Freench)
but I have a probleme
The HTML code is visible. when I use the fonction striptagsandcut only the < and > are remoove.

this is my code :
Code:
<div class="subcategorieslist"> <?php echo JText::_( 'FLEXI_SUBCATEGORIES' ) . ' : '; foreach ($this->categories as $sub) : $subsubcount = count($sub->subcats); ?> [url=<?php echo JRoute::_( FlexicontentHelperRoute::getCategoryRoute($sub->slug) ); ?>]<?php echo $this->escape($sub->title); ?>[/url] <div><?php echo flexicontent_html::striptagsandcut($this->escape($sub->description),400);?></div> <?php if ($this->params->get('show_itemcount', 1)) echo ' (' . ($sub->assigneditems != null ? $sub->assigneditems.'/'.$subsubcount : '0/'.$subsubcount) . ')'; $i++; if ($i != $n) : echo ', '; endif; endforeach; ?> </div>
I have use
Code:
<?php echo flexicontent_html::striptagsandcut($this->escape($sub->description),400);?>

this is a view of my site

[img
[size=9:yothfkay]imagik.fr[/size] :?:
after i solved this problème i would like to view the image categorie
If your are french : vous pouvez me répondre dans la langue de MOLIERE!
Thank you

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

More
15 years 6 months ago #8418 by simjoubert
I find my problem
in the description the < was replace by the &lt;
i apply the php fonction htmlspecialchars_decode()
and after i apply the flexicontent_html::striptagsandcut
thank you
but i don't know why the < and the> was replace?

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

Moderators: vistamediajoomlacornerggppdk
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
Save