PDA

View Full Version : How to show subcategory items on home page?


ljtruba
04-03-2008, 12:45 AM
Hi guys,
I have managed to change category template, so that it shows subcategory articles.

I am trying to do the same on homepage.
Check http://www.kucnibioskop.com/index.php
Category is called "Testovi" and it is not showing subcategory articles.

I am trying to Edit: templates/xhtml/homepage/default.tpl

I beleive that problem is here somewhere,

<div class="box_body">
<vte:box module="box_article_list">
<vte:params>
<vte:param name="search_sort_by" value="created" />
<vte:param name="search_limit" value="{VIVVO_MODULES_MORE_NEWS_ARTICLE_NUMBER}" />
<vte:param name="search_cid" value="{category.id}" />
<vte:param name="add_to_printed" value="true" />
<vte:param name="exclude_printed" value="true" />
</vte:params>
<vte:template>
<vte:foreach item = "article" from = "{article_list}" start="1" loop="1">
<vte:include file="{VIVVO_TEMPLATE_DIR}summary/morenews_short.tpl" />
</vte:foreach>
<ul>
<vte:foreach item = "article" from = "{article_list}" start="2">
<li><a href="{article.get_href}"><vte:value select="{article.title}" /><vte:if test="{article.get_link}"> <img src="{VIVVO_THEME}img/external.png" alt="{LNG_VISIT_WEBSITE}"/></vte:if></a></li>
</vte:foreach>
</ul>
</vte:template>
</vte:box>
</div>

because i get empty HTML like this

<div class="box_body">
<ul>

</ul>

</div>

Micha
04-03-2008, 10:24 AM
You can use same param for this as you did for categories:

<vte:param name="search_cid" value="{CURRENT_CATEGORY.get_id},{CURRENT_CATEGORY .get_descendent_ids|implode:','}" />


Just place it inside params and it should work.

ljtruba
04-03-2008, 11:31 AM
I didn't get what I wanted
Look http://www.kucnibioskop.com/

Article from different category "DVD recenzije" went on left side.
Also it is not showing small images for articles in category "Testovi".

Micha
04-03-2008, 11:58 AM
Article from different category "DVD recenzije" went on left side.

Not sure what might be the problem.

Also it is not showing small images for articles in category "Testovi".

Remove this block of code:

<ul>
<vte:foreach item = "article" from = "{article_list}" start="2">
<li><a href="{article.get_href}"><vte:value select="{article.title}" /><vte:if test="{article.get_link}"> <img src="{VIVVO_THEME}img/external.png" alt="{LNG_VISIT_WEBSITE}"/></vte:if></a></li>
</vte:foreach>
</ul>

and edit this line:

<vte:foreach item = "article" from = "{article_list}" start="1" loop="1">
and remove start="1" loop="1".

ljtruba
04-03-2008, 12:52 PM
Thanks, but we still have first problem.

I have set in preferences->categories->page elements->categories for more news
"Testovi" and "DVD recenzije"

I have set to publish only 1 article, but they seem to to switch places.
It looks that I made a mistake in template, but i dont know where.


<vte:template>
<div id="category_news_box" >
<div class="main_news_box_holder">
<vte:for from="{categories}" step="2" key="category_index">
<div class="main_news_box_row">
<vte:foreach item = "category" from = "{categories}" loop="2" start="{category_index}">
<div id="box_more_category_list_{category.get_id}" class="main_news_category">
<div class="box_title">
<h4>
<a href="{category.get_href}"><vte:value select="{category.get_category_name}" /></a>
</h4>

</div>
<div class="box_body">
<vte:box module="box_article_list">
<vte:params>
<vte:param name="search_sort_by" value="created" />
<vte:param name="search_limit" value="{VIVVO_MODULES_MORE_NEWS_ARTICLE_NUMBER}" />
<vte:param name="search_cid" value="{CURRENT_CATEGORY.get_id},{CURRENT_CATEGORY .get_descendent_ids|implode:','}" /> <vte:param name="add_to_printed" value="true" />
<vte:param name="exclude_printed" value="true" />
</vte:params>
<vte:template>
<vte:foreach item = "article" from = "{article_list}">
<vte:include file="{VIVVO_TEMPLATE_DIR}summary/morenews_short.tpl" />
</vte:foreach>
</vte:template>
</vte:box>
</div>
</div>
</vte:foreach>
</div>
</vte:for>
</div>
</div>
</vte:template>

Micha
04-03-2008, 01:05 PM
Hmmm, try this:

on this line

<vte:param name="search_cid" value="{CURRENT_CATEGORY.get_id},{CURRENT_CATEGORY .get_descendent_ids|implode:','}" />

remove CURRENT_ from value so your this line would look something like this:

<vte:param name="search_cid" value="{CATEGORY.get_id},{CATEGORY .get_descendent_ids|implode:','}" />

ljtruba
04-03-2008, 11:40 PM
No, nothing happened.
I changed in preferences "Number of articles per category:" to 4 and all of them are on the left side.

ljtruba
04-03-2008, 11:42 PM
Look, I have set only one category to be shown and everything is still on the left side.
It looks like code is not recognizing which category article belongs.

ljtruba
04-04-2008, 12:38 AM
This is how it looks like, right now

<vte:box module="box_article_list">
<vte:params>
<vte:param name="search_sort_by" value="created" />
<vte:param name="search_limit" value="{VIVVO_MODULES_MORE_NEWS_ARTICLE_NUMBER}" />
<vte:param name="search_cid" value="{CATEGORY.get_id},{CATEGORY.get_descendent_ids|imp lode:','}" /> <vte:param name="add_to_printed" value="true" />
<vte:param name="exclude_printed" value="true" />
</vte:params>
<vte:template>
<vte:foreach item = "article" from = "{article_list}">
<vte:include file="{VIVVO_TEMPLATE_DIR}summary/morenews_short.tpl" />
</vte:foreach>
</vte:template>
</vte:box>

ljtruba
04-04-2008, 12:49 AM
I found a solution. CMS makes difference between caps.

CATEGORY is not the same as category

So this line should be
<vte:param name="search_cid" value="{category.get_id},{category.get_descendent_ids|imp lode:','}" />

You owe me a beer :)

Micha
04-04-2008, 11:58 AM
Sure thing man ;)