[solved] show latest items of multiple categories in News Module

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
davidjon
Forum Members
Forum Members
Posts: 21
Joined: Thu Jul 09, 2009 7:56 pm

[solved] show latest items of multiple categories in News Module

Post by davidjon »

Hey Guys,

I was wondering. It's probably possible, but dont really now how. But is it possible (like in the browse cat template) show a listing of all the categories and 3 of their items. I would prefer to make a fully automatic. Thats alot easier for my client, i could ofcourse put all 12 summarytemplates of em in the page, but it would be easier if it automatically refills as soon as they add a new categorie.

tnx

david
Last edited by davidjon on Mon Nov 30, 2009 10:29 pm, edited 1 time in total.
davidjon
Forum Members
Forum Members
Posts: 21
Joined: Thu Jul 09, 2009 7:56 pm

Re: show latest items of multiple categories in News Module

Post by davidjon »

just to make it extra clear. Im talking about a block with the Categoryname as Title and then the newstitle links. For each categorie a new block so..
Peciura

Re: show latest items of multiple categories in News Module

Post by Peciura »

You need to create summary template that shows news title-links and and new browse category template that will show all root categories and up to 3 news for each category.

Code: Select all

{if $count > 0}
<ul class="list1">
{foreach from=$cats item=node}
{if $node.depth==1}
<li class="newscategory">
<span>

{$node.news_category_name}

{capture assign='temp'}{$node.news_category_name} | *{/capture}

{news number='3'  summarytemplate='simple_list' category=$temp }

</span>
</li>
{/if}
{/foreach}
</ul>
{/if}
Everything else depends on exact your needs.


EDIT: I named new browse category template  "test" and called news module in page as follows:

Code: Select all

{news action=browsecat browsecattemplate=test }
Last edited by Peciura on Thu Nov 19, 2009 10:22 pm, edited 1 time in total.
davidjon
Forum Members
Forum Members
Posts: 21
Joined: Thu Jul 09, 2009 7:56 pm

Re: show latest items of multiple categories in News Module

Post by davidjon »

wow! f** nice....thanks it works...i actually found a way accidentaly, but later on i changed something again and it didnt work anymore:( and could think of how i did it....

but i think this will work fine :)

tnx mate
davidjon
Forum Members
Forum Members
Posts: 21
Joined: Thu Jul 09, 2009 7:56 pm

Re: show latest items of multiple categories in News Module

Post by davidjon »

ooo, forgot one thing.

I know selected {news category="name | child*"} for the browsecat temp. The only problem is that it adds CHild to the list, and I only want to show the childeren of CHILD..is there a workaround for this?
Peciura

Re: show latest items of multiple categories in News Module

Post by Peciura »

These are 3 different meanings:
1. show node and it's children "*"

Code: Select all

{news category="name | child*"}
2. show children only  " | *"

Code: Select all

{news category="name | child | *"}
3. is "*" variable modifier  ???  "|*"

Code: Select all

{news category="name | child|*"}
davidjon
Forum Members
Forum Members
Posts: 21
Joined: Thu Jul 09, 2009 7:56 pm

Re: show latest items of multiple categories in News Module

Post by davidjon »

I've working on this site again...
thanks for the explanation. However im bumping in to an issue

The code for the first one is :

{news action="browsecat" browsecat="1" category="Activiteiten | Particulieren |*" sortby="random" detailpage="detail-bo"}

The code for the second one is :

{news action="browsecat" browsecat="1" category="Activiteiten | Basis Onderwijs | *" sortby="random" detailpage="detail-bo"}

Both of em have a child categorie named Sport.

And now they're Showing items in both categories....

i take it this shouldnt happen? can you help me fix this please?!
Peciura

Re: show latest items of multiple categories in News Module

Post by Peciura »

Post  page link , template you are using and category hierarchy list to forum. And i will look how i can help you.
davidjon
Forum Members
Forum Members
Posts: 21
Joined: Thu Jul 09, 2009 7:56 pm

Re: show latest items of multiple categories in News Module

Post by davidjon »

Thanks that you're willing to help..

Ok here it comes....

The link to my site (in Dutch),

http://da.stylique.nl

If you go to the page 'Onderwijs' (Education), you'll get submenu. I only made the first two with the category list. So if you click on these. You'll see all the blocks which should contain items in it. Not all of em tho, i havnt had time yet, and first want I  to sort out this problem.

If you look at the 2nd boxes for each page, you'll see that it contains the item 'Schilderen' (painting) twice. This is because I both added it to the category 'Activiteiten | Basis Onderwijs | Creatief ' & to 'Activiteiten | Jongeren | Creatief '. However when you click on the button 'Meer' (MORE) on the bottom of those blocks, you'll only see the orginal containing Item.

So this is the big main issue.

The structure of my News category is as following

Image

This is the browse category template

Code: Select all

{if $count > 0}
{foreach from=$cats item=node}
<div class="smallBlock">
                <div class="blockHeader"><h2>{$node.news_category_name}</h2></div>
                <div class="blockContent">
{if $node.count > 0}         
{capture assign='temp'}{$node.news_category_name}{/capture}

{news number='3'  action="default" summarytemplate="categorie_list" detailpage="detail-bo" category=$temp}

{/if}
              
                </div>
                <p class="blockFooter"><a href="bo/bo-{$node.news_category_name|replace:' ':'-'}">meer...</a></p>
            </div>


{/foreach}
{/if}
This is the corresponding summarytemplate

Code: Select all

{foreach from=$items item=entry}
 <div class="item" onclick="location.href='{$entry->moreurl}'"><div class="title">{$entry->title|cms_escape:htmlall}</div><img src="http://da.stylique.nl//uploads/images/small/{$entry->small_image}.jpg" /></div>
{/foreach}
These two templates make up the Main pages. and they get called by the tags

Code: Select all

{news action="browsecat" browsecat="1" category="Activiteiten | Basis Onderwijs | *" sortby="random"}

Code: Select all

{news action="browsecat" browsecat="1" category="Activiteiten | Jongeren | *" sortby="random"}

The code for the summary view once you click on MORE is :

Code: Select all

<div class="blockColumn">
{foreach from=$items item=entry}

<div class="smallBlock">
                <div class="blockHeader"><h2>{$entry->title|cms_escape}</h2></div>
                <div class="blockContent">
                <img src="uploads/images/small/{$entry->small_image}.jpg" />
                                     <p> {eval var=$entry->content|truncate:350}</p>
                </div>
                <div class="blockFooter"><a href="{$entry->moreurl}">meer...</a></div>
</div>

{/foreach}
</div>
and the Detailed template is :

Code: Select all

{* set a canonical variable that can be used in the head section if process_whole_template is false in the config.php *}
{if isset($entry->canonical)}
  {assign var='canonical' value=$entry->canonical}
{/if}
{assign var='detail_title'  value=$entry->title}

<div class="xLargeContent">
            <div class="xLargeBlock">
                <div class="blockHeader">
<ul>
<li><h1 class="cufon">{$entry->title}</h1></li>

<li class="crumbs"><a href="{$entry->category}">{$entry->category}</a></li>
</ul>
</div>
                <div class="blockContent">
                    <p>{$entry->content}</p>

                </div>
                <p class="blockFooter"></p>
            </div>
</div>


<div class="xLargeContent">
            <div class="xLargeBlock">
                <div class="blockHeader"><h2 class="cufon">Meer informatie aanvragen</h2></div>
                <div class="blockContent">
                    <p>{startExpandCollapse id="name" title="Vraag meer informatie aan"}{capture assign='defaultval'}{title}{/capture}{cms_module module='FormBuilder' form='contact' value_fld2='$defaultval'}{stopExpandCollapse} 
</p>

                </div>
                <p class="blockFooter"></p>
            </div>
</div>


I'm bumping in to another issue tho. As you can see, i made a page title in the Detail Template, with a 'breadcrumb to the category' next to it. I think i fix stuff with the smarty replace tag, but i was wondering if it's possible to replace multiple things in one tag. Since I have to replace the SPACE for a -, and sometimes i'll have to replace the ' & ' for a stripe. Do you know if this is possible, that would help me out alot, because I need to keep my category names like this, but they dont always match the page alias I want to link it to.

Well I hope this is enough info for ya,

Thanks alot for your time and effort, i hope this can be solved :)

tnx mate
DJ.
davidjon
Forum Members
Forum Members
Posts: 21
Joined: Thu Jul 09, 2009 7:56 pm

Re: show latest items of multiple categories in News Module

Post by davidjon »

Okay so I was a bit quick in asking the last question.
on the tag I just added |replace:' & ':'-'|replace:' ':'-'|lower and that works fine now.

I was thinking, i might know a workaround around the issue of multiple the items in different categories with the same name. It's very ugly i know. But what If i'd just name the second group of categories ......name-2 and then just simply add the smarty string thing, strip or replace to the header....i think it would work, its not the nices way however..

But ill wait on what you have to say. 

again thanks for your time.
Peciura

Re: show latest items of multiple categories in News Module

Post by Peciura »

I think you need to use
"{capture assign='temp'}{$node.long_name}{/capture}" instead of
"{capture assign='temp'}{$node.news_category_name}{/capture}" in browse category template.

This way it would assign category like "Activiteiten | Jongeren | Creatief" instead of "Creatief" only and it will not show sibling categories (though this is an handy category functionality ).

If you inspect variable {$node} in browse category template you will see some thing like this:

Code: Select all

array(9) {
  ["news_category_id"]=> string(2) "72"
  ["news_category_name"]=>  string(13) "International"
  ["hierarchy"]=>  string(17) "00070.00071.00072"
  ["long_name"]=>  string(45) "Activiteiten | Jongeren | Creatief"
  ["index"]=>  int(27)
  ["count"]=>  string(1) "1"
  ["prevdepth"]=>  int(2)
  ["depth"]=>  int(3)
  ["url"]=>  string(125) "http://www.blablablabl..."
}
davidjon
Forum Members
Forum Members
Posts: 21
Joined: Thu Jul 09, 2009 7:56 pm

Re: show latest items of multiple categories in News Module

Post by davidjon »

Wow!i'm dazzled....

thank you my friend...this seems to be it :) kinda logic thoo....

How do i mark this [solved]? Just put in the subject line of my first message? Is that all i need to do?
Peciura

Re: show latest items of multiple categories in News Module

Post by Peciura »

Yes edit title of initial post.
Post Reply

Return to “Modules/Add-Ons”