Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
CSS Current page

 

 


chassa2556
User

Jun 23, 2008, 2:47 AM

Post #1 of 21 (3271 views)
Shortcut
CSS Current page Can't Post

Is there a way of editing the active page tag in CSS so that the active page is highlighted in green.

http://www.straloch.com/newsite/indexpages.php?1&theCategory=The+Dower+House

Many thanks in advance


gkornbluth
Veteran

Jun 23, 2008, 9:34 AM

Post #2 of 21 (3261 views)
Shortcut
Re: [chassa2556] CSS Current page [In reply to] Can't Post

I'm not sure if I understand what you are asking for, but if I do, then this might help. You can apply the concept to any css style sheet or in any editor that you'd like. It doesn't rely on Dreamweaver or on Library items

Good luch

Download the free Dreamweaver Tutorial Video
The first CMS Builder reference book is now available on-line!
http://www.thecmsbcookbook.com


Dave
Staff / Moderator


Jun 23, 2008, 9:44 AM

Post #3 of 21 (3259 views)
Shortcut
Re: [chassa2556] CSS Current page [In reply to] Can't Post

Do you mean so that the currently selected menu item shows in green? Or something else?

Dave Edis - Senior Developer
interactivetools.com
 


chassa2556
User

Jun 23, 2008, 10:24 AM

Post #4 of 21 (3255 views)
Shortcut
Re: [Dave] CSS Current page [In reply to] Can't Post

yes I mean that the currently selected page shows in green. So people have an indication where they are...Sorry I wasn't very clear!


Dave
Staff / Moderator


Jun 23, 2008, 10:26 AM

Post #5 of 21 (3251 views)
Shortcut
Re: [chassa2556] CSS Current page [In reply to] Can't Post

Ok, and the category name is always in the url as theCategory=... is that right? Can you past the few lines of code that displays the category name? Or attach indexpages.php to this post so I can see it?

Dave Edis - Senior Developer
interactivetools.com
 


chassa2556
User

Jun 23, 2008, 10:41 AM

Post #6 of 21 (3250 views)
Shortcut
Re: [Dave] CSS Current page [In reply to] Can't Post

have included attachment for you to look at. thanks
Attachments: indexpages.php (5.41 KB)


Dave
Staff / Moderator


Jun 23, 2008, 12:54 PM

Post #7 of 21 (3243 views)
Shortcut
Re: [chassa2556] CSS Current page [In reply to] Can't Post

Thanks, It looks like it might be in secondarynav.php. Do you want to just send me FTP to dave@interactivetools.com and I can update it for you? (Email, don't post FTP details in forum). That way I can easily get to any other files I need. I'll post back what I changed here.

Let me know if that works for you.

Dave Edis - Senior Developer
interactivetools.com
 


Dave
Staff / Moderator


Jun 23, 2008, 4:21 PM

Post #8 of 21 (3234 views)
Shortcut
Re: [Dave] CSS Current page [In reply to] Can't Post

I've responded by email but here's how I did. It's a little hard because this site is a bit more complicated with it's structure but here they are:

You can see the green highlighting on the secondary menu for this page:
http://www.straloch.com/newsite/secondary.php?8&theCategory=Straloch+Estate

I edited secondarynav.php, added this code to get the current record number:
$num = getNumberFromEndOfUrl();

And this code to display the class in the foreach loop
<?php if ($num == $record['num']): ?>greenbuttons<?php endif; ?>

For headernav.php I added this code:
<?php if (@$_GET['theCategory'] == $pagesRecord['title']): ?>greenbuttons<?php endif; ?>

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com
 


IronVictory
User

Jun 25, 2008, 1:04 PM

Post #9 of 21 (3218 views)
Shortcut
Re: [Dave] CSS Current page [In reply to] Can't Post

Thought this might help others. This is what I do:
1) Set up a class named ".current" with the colours you want for the active link.
2) Use this code in the link:
<a href="page.php?category=something" <?php if ($category == "something") { echo "class=\"current\"";} ?> >link</a>

Peter


Djulia
User

Mar 11, 2009, 11:32 AM

Post #10 of 21 (2882 views)
Shortcut
Re: [Dave] CSS Current page [In reply to] Can't Post

Hi Dave,

I have a problem which I am not able to solve with the $num
condition.

<?php if ($num == $record['num']): ?>greenbuttons<?php endif; ?>

The value of $record['num']): is ever modified.
It always preserves the value of the first recording in the table.


But, my approach is perhaps not the good one...
I want to obtain the entries of the table to build a menu and to identify the recording to emphasize it with a style.

You have an idea ?

Thanks,

Djulia

Attachments: nav.php (0.98 KB)


Djulia
User

Mar 11, 2009, 11:54 AM

Post #11 of 21 (2876 views)
Shortcut
Re: [Djulia] CSS Current page [In reply to] Can't Post

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



Dave
Staff / Moderator


Mar 11, 2009, 12:12 PM

Post #12 of 21 (2872 views)
Shortcut
Re: [Djulia] CSS Current page [In reply to] Can't Post

Glad to hear you got it working! Let us know if you need anything else. :)

Dave Edis - Senior Developer
interactivetools.com
 


Perchpole
User

Mar 11, 2009, 5:20 PM

Post #13 of 21 (2855 views)
Shortcut
Re: [Dave] CSS Current page [In reply to] Can't Post

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


Djulia
User

Mar 12, 2009, 2:07 AM

Post #14 of 21 (2838 views)
Shortcut
Re: [Perchpole] CSS Current page [In reply to] Can't Post

Thanks Perchpole for your suggestion. Smile

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.

Code
 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



(This post was edited by Djulia on Mar 12, 2009, 2:41 AM)


Djulia
User

Mar 12, 2009, 2:59 AM

Post #15 of 21 (2831 views)
Shortcut
Re: [Dave] CSS Current page [In reply to] Can't Post

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



Dave
Staff / Moderator


Mar 12, 2009, 12:55 PM

Post #16 of 21 (2819 views)
Shortcut
Re: [Djulia] CSS Current page [In reply to] Can't Post

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
 


Djulia
User

Mar 14, 2009, 9:19 AM

Post #17 of 21 (2797 views)
Shortcut
Re: [Dave] CSS Current page [In reply to] Can't Post

Hi Dave,

In fact, we adapted the code on each page. That thus avoids applying the condition to the same recording (or $num) of section 1 and 2 on the page.

Here an example :

On page newsDetail_1.php.

For the section 1 (tableName1) :
<?php foreach ($listingRecords as $record):
if ($num == $record['num']) { continue; } ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></li>
<?php endforeach; ?>

For the section 2 (tableName2) :
<?php foreach ($listingtwoRecords as $record): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></li>
<?php endforeach; ?>

...and on page newsDetail_2.php

For the section 1 (tableName1) :
<?php foreach ($listingRecords as $record):
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></li>
<?php endforeach; ?>

For the section 2 (tableName2) :
<?php foreach ($listingtwoRecords as $record): ?>
if ($num == $record['num']) { continue; } ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></li>
<?php endforeach; ?>

Djulia


(This post was edited by Djulia on Mar 14, 2009, 10:20 AM)


ross
Staff / Moderator


Mar 16, 2009, 10:58 AM

Post #18 of 21 (2750 views)
Shortcut
Re: [Djulia] CSS Current page [In reply to] Can't Post

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 - Product Specialist
support@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/



Djulia
User

Mar 16, 2009, 1:28 PM

Post #19 of 21 (2742 views)
Shortcut
Re: [ross] CSS Current page [In reply to] Can't Post

Hi Ross,

I communicate it to you in private message.
Thanks for your comprehension.


Djulia


ross
Staff / Moderator


Mar 17, 2009, 6:49 AM

Post #20 of 21 (2722 views)
Shortcut
Re: [Djulia] CSS Current page [In reply to] Can't Post

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 - Product Specialist
support@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/



Djulia
User

Mar 18, 2009, 3:39 AM

Post #21 of 21 (2692 views)
Shortcut
Re: [ross] CSS Current page [In reply to] Can't Post

Hi Ross,

Thanks for your patience !

Here my code :

I removed useless tags HTML to facilitate the reading.

Djulia
Attachments: detailList.php (2.59 KB)