CSS Current page

21 posts by 7 authors in: Forums > CMS Builder
Last Post: March 18, 2009   (RSS)

By Djulia - March 11, 2009

Oops !

I found the origin of my problem.

The condition was not correctly positioned. [crazy]

<?php foreach ($secondaryRecords as $record): ?><a href="<?php echo $record['_link'] ?>"><?php if ($num == $record['num']): ?>1<?php endif; ?></a> - <?php print_r($record['num']); ?><br /><?php endforeach; ?>

Djulia

By Dave - March 11, 2009

Glad to hear you got it working! Let us know if you need anything else. :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] CSS Current page

By Perchpole - March 11, 2009

You can also create a similar effect using raw CSS. The trick is to assign a different css class to the <body> tag of each page - and also to each link of your navigation menu. Then all you need to do is create a style which only kicks-in if the <body> class and the corresponding link class appear on the same page.

It's delightfully simple.

:0)

Perchpole

Re: [Perchpole] CSS Current page

By Djulia - March 12, 2009 - edited: March 12, 2009

Thanks Perchpole for your suggestion. [:)]

In fact, I wanted to remove the link for the active page.
What complicates a little the use :

<?php foreach ($secondaryRecords as $record): ?>
<?php if ($num == $record['num']): ?>
Page (ID 1)
<?php else: ?>
<a href="...">Page (ID 2)</a>
<a href="...">Page (ID 3)</a>
...
<?php endif; ?>
<?php endforeach; ?>

The problem now, it is with the use of several sections on the same page.
If there is a recording of another section with the same value (ID) the condition is also applied.
MY MENU
Section 1

<?php foreach ($seconeRecords as $record): ?>
<?php if ($num == $record['num']): ?>
Page (ID 1)
<?php else: ?>
<a href="...">Page (ID 2)</a>
<a href="...">Page (ID 3)</a>
...
<?php endif; ?>
<?php endforeach; ?>

Section 2

<?php foreach ($sectwoRecords as $record): ?>
<?php if ($num == $record['num']): ?>
Page (ID 1)
<?php else: ?>
<a href="...">Page (ID 2)</a>
<a href="...">Page (ID 3)</a>
...
<?php endif; ?>
<?php endforeach; ?>

I think that it is necessary to add a condition (perhaps on _filename (?) ).

Djulia

Re: [Dave] CSS Current page

By Djulia - March 12, 2009

Hi Dave,

You think that there is a solution with the problem mentioned above ?

I forgot to add that this condition is used in a include (includes/nav.php) to optimize the use.

Thanks for your assistance.

Djulia

By Dave - March 12, 2009

Hi Djulia,

I'm not sure I follow. Can you provide a sample url that shows the page you're working on?

Thanks!
Dave Edis - Senior Developer
interactivetools.com

By ross - March 16, 2009

Hi Djulia

Thanks for the follow up. I am still having some trouble following along though. Could you post a link to your site so we can take a closer look at what's happening?

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] CSS Current page

By Djulia - March 16, 2009

Hi Ross,

[font "Verdana"]I communicate it to you in private message.
Thanks for your comprehension.


[font "Verdana"]Djulia

By ross - March 17, 2009

Hi Djulia

I'll be in touch as soon as I can. I'll have to read through your code to get a better idea of what's going on.

Thanks for getting me the details though :). That makes this a lot easier to troubleshoot.
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/