close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

making navigation point 'active'

Thread began 1/25/2016 6:45 am by Jamie | Last modified 2/05/2016 11:21 am by Ray Borduin | 2078 views | 14 replies |

Jamie

making navigation point 'active'

Hey Ray

Just wondering if you would be able to steer me in the right direction.

Am wanting to create an 'on' or 'active' state for a navigation when you are on a certain page.

So, for example, if you are on the 'about' page, the navigation highlights it.

The navigation is on this page: http://clients.motley.site/motley/template.php

The navigation will be added to each page with an include and I have created an 'active' class for when it is needed but I dont know how to apply it to the page when that particular page is visited.

Cheers

Jamie

Sign in to reply to this post

Ray BorduinWebAssist

You can check the page name based on the value of: $_SERVER['PHP_SELF']

So you might use:

php:
<a href="about.php" class="<?php echo(($_SERVER['PHP_SELF']=="about.php")?"active":""); ?>">about us</a>



Write the value of: <?php echo($_SERVER['PHP_SELF']); ?> to each page to get the correct value for comparison (I'm not sure if it includes a slash or not in the front)

Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

that works great many thanks.

have got this set up to show the 'blog' as active if the visitor is on either blog.php or blogarchive.php

php:
<div class="container pulldown"> <a class="link-text first-level-button <?php echo(($_SERVER['PHP_SELF']=="/about.php" || $_SERVER['PHP_SELF']=="/blogarchive.php" || $_SERVER['PHP_SELF']=="/blogarticle.php")?"active":""); ?>" href="blog.php">blog</a> </div>



2 questions about this.

1) is there a more 'elegant' or efficient way to schieve the same result?

2) how would i get a blog article (the urls are being rewrittent for these) to also show the blog nav point as active?

Sign in to reply to this post

Ray BorduinWebAssist

I would think similar code just checking the url parameter for the blogID compared to the linked blog.

I think this is a perfectly elegant solution.

Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

thanks Ray.

Almost there.... on the services pages, which are each dynamic/rewritten not sure how to achieve the on state when on the relevant service page

Sign in to reply to this post

Ray BorduinWebAssist

<a class="<?php echo(($_SERVER['REQUEST_URI']=="/web/seo-search-engine-optimisation")?"active":""); ?>" href="/web/seo-search-engine-optimisation">search engine optimization</a>

Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

with that, would i need to have that for each navigation point? that being the case, if another naviagtion point were added, the underlying code would need to be changed manually?

Sign in to reply to this post

Ray BorduinWebAssist

Isn't it dynamically added? You would use the dynamic variable. If your navigation point is added dynamically, then the code could be built the same way.

Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

ahhhhhh gotcha, yes of course

what is the proper syntax for adding the echo

<?php echo(($_SERVER['PHP_SELF']=="/web/<?php echo($Services->getColumnVal("Permalink")); ?>

is clearly wrong....

Sign in to reply to this post

Ray BorduinWebAssist

<?php echo(($_SERVER['PHP_SELF']=="/web/".$Services->getColumnVal("Permalink"))?"active":""); ?>

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...