• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: currentpage class for news items - SOLVED
PostPosted: Sat Mar 03, 2007 6:33 pm 
Offline
Forum Members
Forum Members

Joined: Tue Aug 22, 2006 2:32 pm
Posts: 20
Location: Philadelphia
Hello,
Im using:
CMS Made Simple 1.0.4
News Module 2.2

When you are on a news "detail" page (ie - you hit "more info" on a news item) on my site I have a menu of the other news item that are in the same category. What I would like to do is have the "currentpage" class passed to the tag of the link for the page you are currently on (like the MenuManager does).

The only way I could think to do this is to compare the address of the page (in the address bar) to the entry->link of the item.

This is what I have in my template for the menu of news items:
Code:
{php}
$currentdomain = $_SERVER['HTTP_HOST'];
$currenturl = "http://" . $currentdomain . $_SERVER['REQUEST_URI'];
#echo $currenturl;

function giveClass(){
if($entry->link == $currenturl)
{
   $theClass = "class=\"currentpage\"";
}
echo $theClass;
}
{/php}

<ul>
{foreach from=$items item=entry}
<li>{if $entry->link}<a href="{$entry->link}" {php}giveClass(){/php} >{$entry->title}</a>{/if}</li>
{/foreach}
</ul>


What it is doing is giving every link the "currentpage" class.
You can see an example here:
http://www.mantispirate.com/flash/jacques-ferber-intro-13/

What am I doing wrong?

Any assistance would be much appreciated.


Last edited by mantispirate on Mon Mar 05, 2007 5:46 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: currentpage class for news items
PostPosted: Sat Mar 03, 2007 8:42 pm 
Offline
Forum Members
Forum Members

Joined: Tue Aug 22, 2006 2:32 pm
Posts: 20
Location: Philadelphia
Im beginning to think I might be going about this all wrong. Not sure of any other way to do it though.
Can somebody let me know if Im even in the right ballpark on this?


Top
 Profile  
 
 Post subject: Re: currentpage class for news items - SOLVED
PostPosted: Mon Mar 05, 2007 4:54 am 
Offline
Forum Members
Forum Members

Joined: Tue Aug 22, 2006 2:32 pm
Posts: 20
Location: Philadelphia
Well it took me all weekend and a crash course in smarty but I now have sub menus in my "news" pages that correctly mark the page you are on. ;D

This is what my sub menu template now looks like
Code:
<ul>
{foreach from=$items item=entry}
<li><a href="{$entry->link}"
{php}
$currentdomain = $_SERVER['HTTP_HOST'];
$currenturl = "http://" . $currentdomain . $_SERVER['REQUEST_URI'];
$this->assign('theURL', $currenturl);
{/php}
{if $entry->link == $theURL}class="currentpage"{/if}>{$entry->title}</a></li>
{/foreach}
</ul>


I'm sure there is a cleaner way to do this, but it works for me.
And now it is time to sleep.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner