Page 1 of 1

[solved]News: how to change the detailpage according to the category?

Posted: Sun May 25, 2008 1:10 pm
by firfelin
Hi,

I am currently working on a site with CMSMS 1.2.5 and the News Module 2.6.1

I use the News Module to display projects; I have 3 categories and one page "Projects" to show them all with:

Code: Select all

{news detailpage='details'}
Works well, but...

I would like to be able to stylise differently with CSS the different projects, according to the different categories. So my idea was to make one detailpage per category, with the same name and alias as the category, and then to call it with something like that:

Code: Select all

{news detailpage=$entry->category}
but it doesnt work...  :-\

Any smart idea to achieve something similar?

Thanks in advance for your help and your time.

Re: News: how to change the detailpage according to the category?

Posted: Sun May 25, 2008 1:27 pm
by sjmann
One possible, but very simplified way of doing it could be to add an 'if' statement below the foreach statement on the calender template. This will of course require the use of three templates.

Code: Select all

{foreach from=$items item=entry}
{if $entry->category == 'General'}
I hope this helps.

Re: News: how to change the detailpage according to the category?

Posted: Sun May 25, 2008 3:12 pm
by firfelin
I solved my problem, turning it otherway; I doesnt answer the initial question of having multiples detailpages, but it quite works for my purpose: instead of having several detailpages, I put in the detail template an extra div with a class according to the category:

My News detail template:

Code: Select all

<div class={$entry->category}>

<h2 id="projet_titre">
{$entry->title}
</h2>

<div id="projet_detail">
{$entry->content}
</div>

<div id="specifications">
{$entry->specifications}
</div>

<div id="exergue">
{$entry->exergue}
</div>

</div>
Thanks for the input sjmann  :D

Re: News: how to change the detailpage according to the category?

Posted: Mon May 26, 2008 9:09 am
by firfelin
almost... ;D

It seem that I have another related problem...: with one and only detailpage for all the projects and 3 categories, I cant make my menu active according to the categories.

My menu is organized as well:

Projects
  -projects category 1
  -projects category 2
  -projects category 3

Another Menu
  -another submenu
    etc

I would like to -for example- underlign "projects category 2" when the detailpage displays a news belonging to that category 2.
How can I say to the menu "the project actually displayed on the News detailpage belongs to category X" and style it according to this category.

Not so clear I guess with my poor english... sorry :-[. Is it possible to interact between the news and the menu and make something like this?

if news category == category 2, then menu active is #submenu node 2

Thanks again