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.
You are not logged in.
Pages: 1
Hi the code I am using is below in the scripts plugin file but I keep getting an error when I implement; I think it is correct but my eyes could be deceiving me. I need a second pair of eyes to see what I am not seeing.
echo '
<style type="text/css">
.selected
{
background-color: red !important;
color: black !important;
}
</style>
<script>
$(function()
{
$("ul.menu a[href='" + window.location.pathname + "']")
.parentsUntil(".menu", "li")
.addClass("selected");
});
</script>
';
Here is the error I am getting when I run this:
Something went wrong
Unexpected error: syntax error, unexpected '" + window.location.pathname +' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in kp-plugins.php on line 371
Please report error at http://community.theturninggate.net
Also, I would like to add the effect to also be on the both the parent & children and I think this should work but let me know this as well.
$("ul.menu a[href='" + window.location.pathname + "']")
.parentsUntil(".menu", "li")
.addClass("selected").parents("li").children("a").addClass("selected");
Offline
it's the single quotes in that line.
If you use the sample script in the phplugins-pangolin-sample.php file you won't need to escape those single quotes.
It's this one:
function scripts() {
echo <<<SCRIPT
<script>
$("ul.menu a[href='" + window.location.pathname + "']")
.parentsUntil('.menu', 'li')
.addClass("current_page_item")
;
</script>
SCRIPT;
return false;
} // END /**/
otherwise, escape the single quotes:
<script>
$(function() {
$("ul.menu a[href=\'" + window.location.pathname + "\']")
.parentsUntil(".menu", "li")
.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
I tried the one in the sample script but it also gives me the same error. I will try the escape char. What about the item I have for the children and parent to both be highlighted? Will it work as well or did I miss something?
Offline
I don't know about the second item. I've not played around with that.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
I just tested the sample script provided. It worked for me without error.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Well it did not work for me until I used it on the sample script with the escape. Also, the children code that I posted I had works as well. But, it did not highlight everything I am looking at why some menu items did not get highlighted when selected. I think it is because of the window location pathname.
Last edited by mad (2019-03-12 03:01:56)
Offline
Pages: 1