Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Get current page with a fixed menu structure?


Reply

6 Posts   2775 Views

Avatar
DonL

12 August 2008 at 8:15am Community Member, 9 Posts

I'm new to SS and working on converting an existing site for use with the CMS. The site design involves a graphical menu bar across the top which uses separate images for each menu item. For simplicity's sake I'm inclined to leave it this way (at least for now) and just change the links to point to the relevant SS top-level pages. However, I need to be able to figure out which menu item is the current page and display a different image in the menu bar. Currently this is done by simply having a different HTML file for each page and hard-coding the images, but obviously I don't want to do that.

The <% if LinkCurrent = current %> doesn't seem to work without the SS menu control structure, so is there some other way to do this?

Avatar
Fuzz10

12 August 2008 at 8:56am Community Member, 787 Posts

You can use $URLSegment, this returns the part of the url of the page you are on. You could also add a custom identification field to your pageclass and use that to identify the current page.

Avatar
Willr

12 August 2008 at 9:02am Forum Moderator, 5511 Posts

if I have to do a site with graphical navigation what I normally do is in the menu control (nice bits cut out for briefness)

<% control Menu(1) %>
<img src="{$URLSegment}nav.gif" alt="$Title" />
<% end_control %>

So if you have a Blog page with a URL of blog your blog image should be blognav.gif and blognavCurrent. Then what you could do if you want to swap the images on the current page is

<% control Menu(1) %>
<% if LinkOrSection = section %>
<img src="{$URLSegment}navCurrent.gif" alt="$Title" />
<% else %>
<img src="{$URLSegment}nav.gif" alt="$Title" />
<% end_control %>

Thats just one of the ways you could do it.

Avatar
mschiefmaker

12 November 2008 at 9:45am Community Member, 187 Posts

When I use

<% control Menu(1) %>
<% if LinkOrSection = section %>
<img src="themes/purplewine/images/menu/{$URLSegment}nav.gif" alt="$Title" />
<% else %>
<img src="themes/purplewine/images/menu/{$URLSegment}navCurrent.gif" alt="$Title" />
<% end_control %>

The website returns a blank screen. I can save in the CMS with no errrors.

<% control Menu(1) %>
<img src="themes/purplewine/images/menu/{$URLSegment}nav.gif" alt="$Title" />
<% end_control %>

Works fine.

The problem seems to be caused when I add <% if LinkOrSection = section %> but I can see nothing wrong with this syntax and I am getting no error messages. Am new to this so it might be something obvious. Would appreciate any suggestions

MM

Avatar
mschiefmaker

12 November 2008 at 10:15am Community Member, 187 Posts

Ignore this question ... must be a newbie error. All working fin now.

MM

Avatar
jamesg

12 November 2008 at 10:16am (Last edited: 12 November 2008 10:17am), Community Member, 8 Posts

You're missing an <% end_if %>

edit: but you beat me to it :P