Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2014-08-17 00:31:38

fwillette
Member
From: Brussels - Belgium
Registered: 2014-05-08
Posts: 135

Highlighting the current page’s navigation menu item ( Solved )

Hi Rod

Site:  http://martine-cheval.be

Maybe did you notice that I had implemented "Highlighting the current page’s navigation menu item" using yout Tip.
I really think this is a great "plus" to navigation, especially when entering a site from Full screen flip gallery. Thanks a lot for this tip.


Just for information: in the phplugins.php file, in CE4, the line  <link href="/phplugins/css/custom.css" rel="stylesheet" />
is sligntly different:" link href"  has been replaced by "link ref" and it is enouth for prevent the script for working. Just replaced ref by href and it works.

An other point is that Hightlighting doesn't work for the "Oeuvres récentes" page whitch is a Stage page.

Cordially

fredy

Last edited by fwillette (2014-08-20 18:50:32)

Offline

#2 2014-08-19 21:19:20

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Highlighting the current page’s navigation menu item ( Solved )

it's still <link  ... href ...  in the phplugins file generated by CE4

this is what I see:

<link rel="stylesheet" href="/phplugins/css/custom.css" />

Not sure why that particular page isn't being highlighted in  menu. The only real difference I see in your navigation for that item compared to the others is that it doesn't have a / at the end of the url. Try adding that. If that doesn't work, try /index.php


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#3 2014-08-20 00:23:42

fwillette
Member
From: Brussels - Belgium
Registered: 2014-05-08
Posts: 135

Re: Highlighting the current page’s navigation menu item ( Solved )

Hi Rod

Stage page "oeuvres récentes" is now hightlighted, I added a "/" at the end of the URL, seems that the syntax is different for pages ceated by TTG-Pages that are of type" /page.php" and supplementary pages ( like Search or Stage ) that are of type "/url/"

Concerning the code line ( 136 or 137 ) beneath which  code must be inserted to activate hightlighting, in your Tip, you mention this line:
<link href="/phplugins/css/custom.css" rel="stylesheet" />   and I think it was the case with CE3, but with CE4 this line is now:
<link rel="stylesheet" href="/phplugins/css/custom.css" />  In this case hightlighting is not active. To acitivate, must be changed in
<link hrel="stylesheet" href="/phplugins/css/custom.css" />  I just tested it now to confirm.

Thanks for all

Fredy

Offline

#4 2014-08-20 00:37:08

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Highlighting the current page’s navigation menu item ( Solved )

seems that the syntax is different for pages

I'm guessing it's rather how the code returns window.location.href. I still have a whole lot to learn....

hrel is not valid html

the code, as it appears in the tutorial is working fine in my CE test site: http://ce4.barbeephoto.com/

This is what I have in my phplugins file:

function ttg_head_end( $style, $path ) { 
    echo '
    <link rel="stylesheet" href="/phplugins/css/custom.css" />
    <script>
$(document).ready(function() {
    $("#navigation a").each(function() {
        if ($(this).prop("href") == window.location.href) {
            $(this).addClass("selected");
        }
    });
});
</script>
    ';  

Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#5 2014-08-20 00:47:29

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Highlighting the current page’s navigation menu item ( Solved )

Oh, and thanks for pointing out how this wasn't working on a couple of pages. I've updated the tutorial to point out that urls targeting a folder need to end in a forward slash.


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#6 2014-08-20 18:49:54

fwillette
Member
From: Brussels - Belgium
Registered: 2014-05-08
Posts: 135

Re: Highlighting the current page’s navigation menu item ( Solved )

Hi Rod

I pasted the code you gave  in post 4 above and it works.

This is the code I use:


function ttg_head_end( $style, $path ) {
    echo '
    <link href="/phplugins/css/custom.css" rel="stylesheet" />
   
    <script>
$(document).ready(function() {
$("#navigation a").each(function() {
if ($(this).prop("href") == window.location.href) {
$(this).addClass("selected");
}
});
});
</script>
    ';


and it works too.

I don't really remember what was the initial issue, but the most important is that it works.

Thanks

Fredy

Offline

#7 2014-08-20 22:08:04

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Highlighting the current page’s navigation menu item ( Solved )

probably just a simple syntax error: a missing ' or misplaced ;


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

Board footer

Powered by FluxBB