-
#categories li a.cat-selected-text but for EZPAGES
hello...
im just playing.. but is there a way to make the selected link for an EZpage link bold like how you can a selected category link.
for example, i use the following for category links
#categories li a.cat-selected-text {
color:#990000;
font-weight:bold;
padding-left: 0.5em;
}
can CSS be used to do the same for links in the EZpages top bar thing, so when a person is looking at that ezpage, the top bar link remains bold or a diff colour etc... if so, how, cos i havent worked it out... :(
Cheers
M
-
Re: #categories li a.cat-selected-text but for EZPAGES
I've been trying to do that for the EZ Page and other links (Information, etc.) by adapting the code from the Categories box, but have failed so far. It would be a very popular mod, I think.
-
Re: #categories li a.cat-selected-text but for EZPAGES
haha.. no wonder i couldnt get it to work then.. my PHP knowledge is less than my understanding of women... and i will never understand them!
We need a ZC rock n roll star who could create something and name it... oh... EZPage Dressing ;-)
LOL... Glenn Herbert, was that a good enough shamless hint?
-
Re: #categories li a.cat-selected-text but for EZPAGES
Sure, it would be possible. The $current_page_base and $_GET['id'] when on an ez-page will allow you to identify if one is active. This can be done in /includes/templates/your_template/templates/tpl_ezpages_bar_header.php, and the link can then be given an "active" classname to style as desired.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Here you go:
/includes/templates/your_template/templates/tpl_ezpages_bar_header.php
PHP Code:
<?php
/**
* Page Template
*
* Displays EZ-Pages Header-Bar content.<br />
*
* @package templateSystem
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_ezpages_bar_header.php 3377 2006-04-05 04:43:11Z ajeh $
* Modified for Ezpages Active Header by Glenn Herbert (gjh42) 2010-06-15
*/
/**
* require code to show EZ-Pages list
*/
include(DIR_WS_MODULES . zen_get_module_directory('ezpages_bar_header.php'));
?>
<?php if (sizeof($var_linksList) >= 1) { ?>
<div id="navEZPagesTop">
<?php for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) {
$active = ($current_page_base == 'page' and $_GET['id'] == $var_linksList[$i]['id'])? ' class="activeEZPage"': '';
?>
<a href="<?php echo $var_linksList[$i]['link']; ?>"<?php echo $active; ?>><?php echo $var_linksList[$i]['name']; ?></a><?php echo ($i < $n ? EZPAGES_SEPARATOR_HEADER : '') . "\n"; ?>
<?php } // end FOR loop ?>
</div>
<?php } ?>
Style .activeEZPage {} as desired.
Note: I haven't tested this yet, so please let me know if anything needs fixing.
I'll package it up into a proper mod after the festival I'm hosting in two weeks... I'm a bit busy right now:)
-
Re: #categories li a.cat-selected-text but for EZPAGES
-
Re: #categories li a.cat-selected-text but for EZPAGES
one tiny thing, if you have the time... how can i style internal links in the EZpage top bar? for example: index.php?main_page=reviews or index.php?main_page=index&cPath=1 etc
It works great for pages where the content is created in the EZpage editor bit... but no effect on pages that are internally linked... if you get me?
-
Re: #categories li a.cat-selected-text but for EZPAGES
Right - the ez-pages header can show links to non-ez-pages... that will take a bunch more identification coding... like ten times as much or so:)
I'll have to look into this when I have more time. There may be an elegant method of doing it, let's hope so anyway.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Hi Glenn, when ever you can fit it in is great. Im just pleased it can be done!
I was just playing about with CSS (killing time) and i had the thought of the ezpages effect like how category dressing can style selected links.
hope your festival goes well!! thanks for mod!
Quote:
Originally Posted by
gjh42
Right - the ez-pages header can show links to non-ez-pages... that will take a bunch more identification coding... like ten times as much or so:)
I'll have to look into this when I have more time. There may be an elegant method of doing it, let's hope so anyway.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Hello Glenn.
How was your festival ?
Did you ever get a chance to look over this idea?
Any joy? Or would it take far too much changing of loads and loads of files etc?
Cheers
M
-
Re: #categories li a.cat-selected-text but for EZPAGES
It would not require touching any additional files, just more code in the one. I think the Smart Backgrounds code would serve as a starter, with sub-tests... maybe need to include a specific line for each possible pagename, or maybe there is a universal way I can phrase it that will work with all names. I have this thread bookmarked now, and will look into it.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Hi Glenn,
Have you ever figured out how to style selected link in ezpages sidebox? I'd really love to know how to do that. Could you help?? This is quite urgent.. Thank you!
-
Re: #categories li a.cat-selected-text but for EZPAGES
I haven't worked on the "internal link" highlighting, but the code I gave above should already work for ez-page links.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Glenn,
The situation is I don't have any sidebox other than ezpage sidebox. I have home page, contact us page , etc. set up in ezpage sidebox, so the code you mentioned doesn't help..
Do you have any idea when you'll be able to look into it (internal links)?
Thank you in advance!
-
Re: #categories li a.cat-selected-text but for EZPAGES
OK, I see your predicament. I'll take a quick look at it now to really see what kind of a job it is. If it's simple enough, I'll post some code for you to test.
-
Re: #categories li a.cat-selected-text but for EZPAGES
It looks like I should have the ez-pages header version ready to test in a few minutes. If that works, it shouldn't be hard to translate into the sidebox.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Please test this to see how it works.
/includes/templates/your_template/templates/tpl_ezpages_bar_header.php
Style the classes
.activeEZPage {}
and
.activeILPage {}
in your stylesheet to see effects.
PHP Code:
<?php
/**
* Page Template
*
* Displays EZ-Pages Header-Bar content.<br />
*
* @package templateSystem
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_ezpages_bar_header.php 3377 2006-04-05 04:43:11Z ajeh $
*Modified for Ezpages Active Header by Glenn Herbert (gjh42) 2010-08-20
*/
/**
* require code to show EZ-Pages list
*/
include(DIR_WS_MODULES . zen_get_module_directory('ezpages_bar_header.php'));
?>
<?php if (sizeof($var_linksList) >= 1) { ?>
<div id="navEZPagesTop">
<?php for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) {
$active = '';
if($current_page_base == 'page') {
$active = ($_GET['id'] == $var_linksList[$i]['id'])? ' class="activeEZPage"': '';
}elseif ($var_linksList[$i]['altURL']) {//check for current page in alturl
$active = (strstr($var_linksList[$i]['altURL'],'main_page=' . $current_page_base))?' class="activeILPage"': '';
} ?>
<a href="<?php echo $var_linksList[$i]['link']; ?>"<?php echo $active; ?>><?php echo $var_linksList[$i]['name']; ?></a><?php echo ($i < $n ? EZPAGES_SEPARATOR_HEADER : '') . "\n"; ?>
<?php } // end FOR loop ?>
</div>
<?php } ?>
-
Re: #categories li a.cat-selected-text but for EZPAGES
Thank you very much for your help, Glenn.
It works for certain page but not all. Please see link below:
http://tinyurl.com/2c4jabc
"testimonials" works, but for "home" and "about us", it doesn't. Any clue why??
Thanks again for your effort. I really appreciate it!
-
Re: #categories li a.cat-selected-text but for EZPAGES
The home link is easy - that doesn't include a "main_page=" part, so is not being picked up. I can add a special check for that case.
The about us is puzzling, as it is an ez-page and essentially the same code apparently worked for Shane78. It would be helpful if you could add some debug code so we can see exactly what is happening there.
PHP Code:
<?php for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) {
$active = '';
if($current_page_base == 'page') {
$active = ($_GET['id'] == $var_linksList[$i]['id'])? ' class="activeEZPage"': '';
Change to
PHP Code:
<?php for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) {
echo ' $i='.$i.' current page='.$current_page_base;//debug
$active = '';
if($current_page_base == 'page') {
echo ' id='.$_GET['id'].' listid='.$var_linksList[$i]['id'];//debug
$active = ($_GET['id'] == $var_linksList[$i]['id'])? ' class="activeEZPage"': '';
This will output a line of text above the ez-page bar. Let me know when you have activated the debug code and I will look at it.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Change
PHP Code:
}elseif ($var_linksList[$i]['altURL']) {//check for current page in alturl
$active = (strstr($var_linksList[$i]['altURL'],'main_page=' . $current_page_base))?' class="activeILPage"': '';
} ?>
to
PHP Code:
}elseif ($var_linksList[$i]['altURL']) {//check for current page in alturl
$active = (strstr($var_linksList[$i]['altURL'],'main_page=' . $current_page_base) or ((strstr($var_linksList[$i]['altURL'],'/index.php') == '/index.php') and ($current_page_base == 'index')))?' class="activeILPage"': '';
} ?>
This may still be subject to false positives with certain kinds of custom page names, so I will work on tightening it up; meanwhile this should work for common pages.
-
Re: #categories li a.cat-selected-text but for EZPAGES
I've done that, Glenn.
Thank you very much for helping me. I really appreciate it!
-
Re: #categories li a.cat-selected-text but for EZPAGES
This should function for all internal links whether generic or specific, as well as for home links. Please test it and let me know how it works for you.
PHP Code:
}elseif ($var_linksList[$i]['altURL']) {//check for current page in alturl
$active = ((strstr($_GET['url'],$var_linksList[$i]['altURL']) and (strstr($var_linksList[$i]['altURL'],'/index.php') != '/index.php')) or ($_GET['url'] == $var_linksList[$i]['altURL']))?' class="activeILPage"': '';
} ?>
-
Re: #categories li a.cat-selected-text but for EZPAGES
$i=1 current page=page id=6 listid=3 About Us ::
This says (when on the About Us page) that the actual ez-page id is 6, while the link is pointing to ez-page id 3; thus they don't match and the link code doesn't think it is the current page. I don't know how this can be... if the link gets to the right ez-page, they should match.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Glenn,
Most links work now but one strange thing happened..
Now if you click on/go to "Home", the "products" turns red too.
And when click on "Products", it doesn't turn red. ("Products" is pointed to "index.php?main_page=product_info&cPath=1" on ezpage setting.)
How do I apply this to ezpage sidebox? Would you tell me how to do that for ezpage sidebox?
Thanks, Glenn.
PS. I've "fixed" the "about us". I noticed that "about us" header order was "3" and sidebox order was "6". I changed both to"6" and it works now.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Product or category listings are "index" pages, as is the home page, so the post #20 code's
strstr($var_linksList[$i]['altURL'],'main_page=' . $current_page_base)
will be positive when the link has main_page=index and you are on the home page.
This will probably be taken care of with the latest version of the test in post #22.
If that works correctly, I will proceed to transfer it into the sidebox.
-
Re: #categories li a.cat-selected-text but for EZPAGES
The "Products" link is not turning red on the product page because you have only one product in the category, and Zen Cart is following the default setting and going straight to the product info page in this case
main_page=product_info&cPath=1&products_id=1
while the link says
main_page=index&cPath=1
I think even the improved code wouldn't pick up on this; you would need to use the individual product as the link destination. The only practical way I could see this situation arising without writing the link by hand is if a category had two products when the link was made and then had one deleted. Copy/pasting the internal link destinations is a good way to be sure they are right.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Yes, it works!! (I pointed the "products" to "index.php?main_page=product_info" for the moment..)
Please go ahead and transfer it into ezpage sidebox. I'm so happy that this can be done. I cannot thank you enough..
-
Re: #categories li a.cat-selected-text but for EZPAGES
I transferred the testing code into a function, so only one line in both the header and sidebox tpl_ files needs to be altered, calling the function.
/includes/functions/extra_functions/ezpages_improved_menus_functions.php
PHP Code:
<?php
/**
*
* @copyright Copyright 2010 Glenn Herbert
* @copyright Portions Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.gnu.org/licenses/ GNU Public License V3.0
* @version $Id: /includes/functions/extra_functions/ezpages_improved_menus_functions.php
*Ezpages Improved Menus by Glenn Herbert (gjh42) 2010-08-23
*/
//call as activePageClass($var_linksList[$i]['id'],$var_linksList[$i]['altURL']);
function active_page_class($ezpid,$alturl) {
$active = '';
if($current_page_base == 'page') {
$active = ($_GET['id'] == $ezpid)? ' class="activeEZPage"': '';
}elseif($alturl) {//check for current page in alturl
$active = ((strstr($_GET['url'],$alturl) and (strstr($alturl,'/index.php') != '/index.php')) or ($_GET['url'] == $alturl))?' class="activeILPage"': '';
}
return $active;
}
?>
/includes/templates/your_template/sideboxes/tpl_ezpages.php
PHP Code:
<?php
/**
* Side Box Template
*
* @package templateSystem
* @copyright Copyright 2003-2005 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_ezpages.php 2982 2006-02-07 07:56:41Z birdbrain $
* /includes/templates/your_template/sideboxes/tpl_ezpages.php
*Modified for Ezpages Improved Menus by Glenn Herbert (gjh42) 2010-08-23
*/
$content = "";
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';
$content .= "\n" . '<ul>' . "\n";
for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) {
$content .= '<li><a href="' . $var_linksList[$i]['link'] . '"' . active_page_class($var_linksList[$i]['id'],$var_linksList[$i]['altURL']) . '>' . $var_linksList[$i]['name'] . '</a></li>' . "\n" ;
} // end FOR loop
$content .= '</ul>' . "\n";
$content .= '</div>';
?>
/includes/templates/your_template/templates/tpl_ezpages_bar_header.php
PHP Code:
<?php
/**
* Page Template
*
* Displays EZ-Pages Header-Bar content.<br />
*
* @package templateSystem
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_ezpages_bar_header.php 3377 2006-04-05 04:43:11Z ajeh $
* /includes/templates/your_template/templates/tpl_ezpages_bar_header.php
*Modified for Ezpages Improved Menus by Glenn Herbert (gjh42) 2010-08-23
*/
/**
* require code to show EZ-Pages list
*/
include(DIR_WS_MODULES . zen_get_module_directory('ezpages_bar_header.php'));
if (sizeof($var_linksList) >= 1) { ?>
<div id="navEZPagesTop">
<ul>
<?php for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) {
echo '<li class="link"><a href="' . $var_linksList[$i]['link'] . '"' . active_page_class($var_linksList[$i]['id'],$var_linksList[$i]['altURL']) . '>' . $var_linksList[$i]['name'] . '</a></li>' . ($i < $n ? '<li class="separator">' . EZPAGES_SEPARATOR_HEADER . '</li>' : '') . "\n";
} // end FOR loop ?>
</ul>
</div>
<?php } ?>
I did modify the header bar file a bit, for streamlined code and to make the list a <ul> for more flexible styling. This requires an addition to the stylesheet to keep the appearance the same as before.
I also pulled the inline styling out of the sidebox file, so it needs to go in the stylesheet as well, in addition to the new active class style rules.
Code:
#navEZPagesTop ul {margin: 0; padding: 0; list-style-type: none;}
#ezpagesContent ul {margin: 0; padding: 0; list-style-type: none;}
.activeEZPage {color: #ff0000;}
.activeILPage {color: #ff0000;}
As there are numerous tweaks from the previous version to this one, please test to make sure there are no typos or bugs introduced.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Glenn,
I created a PHP file:
/includes/functions/extra_functions/ezpages_improved_menus_functions.php
and made all the changes according to your instructions, but nothing seems to happen now..
I feel bad that you are doing all the work. Please have a look when you get a chance. Really appreciate it!
-
Re: #categories li a.cat-selected-text but for EZPAGES
Note: you also want to display the header items inline:
#navEZPagesTop ul li {display: inline;}
You are helping me test the mod, so don't feel bad. We will need to put some debug lines back into the files.
ezpages_improved_menus_functions.php
PHP Code:
function active_page_class($ezpid,$alturl) {
$active = '';
echo '<br /> current_page='.$current_page_base;//debug
if($current_page_base == 'page') {
echo ' id='.$_GET['id'].' listid='.$ezpid;//debug
$active = ($_GET['id'] == $ezpid)? ' class="activeEZPage"': '';
}elseif($alturl) {//check for current page in alturl
echo ' url='.$_GET['url'].' alturl='.$alturl.' index='.strstr($alturl,'/index.php');//debug
$active = ((strstr($_GET['url'],$alturl) and (strstr($alturl,'/index.php') != '/index.php')) or ($_GET['url'] == $alturl))?' class="activeILPage"': '';
}
return $active;
}
?>
-
Re: #categories li a.cat-selected-text but for EZPAGES
Wow. I just did what you asked me to..
Have a look. Thank you, Glenn.
-
Re: #categories li a.cat-selected-text but for EZPAGES
I'm not surprised that it couldn't read $current_page_base inside the function, but $_GET is a superglobal that should be readable anywhere. I have used it in other functions. Anyway, add the global line as shown and it should work as before.
PHP Code:
function active_page_class($ezpid,$alturl) {
global $current_page_base, $_GET;
$active = '';
-
Re: #categories li a.cat-selected-text but for EZPAGES
OK. I added the global line and the only link seems to work is "About us". All others still don't.
What should we do now?
-
Re: #categories li a.cat-selected-text but for EZPAGES
Decidedly strange. $_GET['id'] is working fine, but $_GET['url'] is not. It worked in the previous version of the code. Let's try passing its value in as a parameter:
PHP Code:
function active_page_class($ezpid,$cururl,$alturl) {
global $current_page_base;
$active = '';
echo '<br /> current_page='.$current_page_base;//debug
if($current_page_base == 'page') {
echo ' id='.$_GET['id'].' listid='.$ezpid;//debug
$active = ($_GET['id'] == $ezpid)? ' class="activeEZPage"': '';
}elseif($alturl) {//check for current page in alturl
echo ' url='.$cururl.' alturl='.$alturl.' index='.strstr($alturl,'/index.php');//debug
$active = ((strstr($cururl,$alturl) and (strstr($alturl,'/index.php') != '/index.php')) or ($cururl == $alturl))?' class="activeILPage"': '';
}
return $active;
}
?>
and calling it from the other two files this way:
PHP Code:
active_page_class($var_linksList[$i]['id'],$_GET['url'],$var_linksList[$i]['altURL'])
-
Re: #categories li a.cat-selected-text but for EZPAGES
Just a thought... the letter "l" and the numeral "1" are identical in the code box font. Maybe retype all instances of $_GET['url'] to make sure they are the correct character??? (Before doing the other file edits.)
A cut/paste without code tags to see what the original characters are:
function active_page_class($ezpid,$alturl) {
$active = '';
if($current_page_base == 'page') {
$active = ($_GET['id'] == $ezpid)? ' class="activeEZPage"': '';
}elseif($alturl) {//check for current page in alturl
$active = ((strstr($_GET['url'],$alturl) and (strstr($alturl,'/index.php') != '/index.php')) or ($_GET['url'] == $alturl))?' class="activeILPage"': '';
}
return $active;
}
Okay, they are all the correct characters. No need for doing that test.
-
Re: #categories li a.cat-selected-text but for EZPAGES
No.. It's the same. Only "About Us" works..
-
Re: #categories li a.cat-selected-text but for EZPAGES
Curiouser and curiouser. This code worked when it was in the header file:
PHP Code:
if ($var_linksList[$i]['altURL']) {//check for current page in alturl
$active = ((strstr($_GET['url'],$var_linksList[$i]['altURL']) and (strstr($var_linksList[$i]['altURL'],'/index.php') != '/index.php')) or ($_GET['url'] == $var_linksList[$i]['altURL']))?' class="activeILPage"': '';
}
so let's put it back in:
PHP Code:
/* /includes/templates/your_template/templates/tpl_ezpages_bar_header.php
*Modified for Ezpages Improved Menus by Glenn Herbert (gjh42) 2010-08-23
*/
//...
<?php for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) {
if ($var_linksList[$i]['altURL']) {//check for current page in alturl - debug test
$active = ((strstr($_GET['url'],$var_linksList[$i]['altURL']) and (strstr($var_linksList[$i]['altURL'],'/index.php') != '/index.php')) or ($_GET['url'] == $var_linksList[$i]['altURL']))?' class="activeILPage"': '';
echo ' url='.$_GET['url'];
} // /debug test
echo '<li class="link"><a href="' . $var_linksList[$i]['link'] . '"' . $active /*debug test*/ . active_page_class($var_linksList[$i]['id'],$_GET['url'],$var_linksList[$i]['altURL']) . '>' . $var_linksList[$i]['name'] . '</a></li>' . ($i < $n ? '<li class="separator">' . EZPAGES_SEPARATOR_HEADER . '</li>' : '') . "\n";
} // end FOR loop ?>
-
Re: #categories li a.cat-selected-text but for EZPAGES
I see that broke something on internal linked pages. I'll have to go back through the code and double check.
Un-broke. I guess you were in the middle of doing something.
-
Re: #categories li a.cat-selected-text but for EZPAGES
I'm afraid that I'm loosing tracks with all the copy and past..
OK. Here is what I have right now:
/includes/functions/extra_functions/ezpages_improved_menus_functions.php
PHP Code:
<?php
/**
*
* @copyright Copyright 2010 Glenn Herbert
* @copyright Portions Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.gnu.org/licenses/ GNU Public License V3.0
* @version $Id: /includes/functions/extra_functions/ezpages_improved_menus_functions.php
*Ezpages Improved Menus by Glenn Herbert (gjh42) 2010-08-23
*/
//call as activePageClass($var_linksList[$i]['id'],$var_linksList[$i]['altURL']);
function active_page_class($ezpid,$cururl,$alturl) {
global $current_page_base;
$active = '';
echo '<br /> current_page='.$current_page_base;//debug
if($current_page_base == 'page') {
echo ' id='.$_GET['id'].' listid='.$ezpid;//debug
$active = ($_GET['id'] == $ezpid)? ' class="activeEZPage"': '';
}elseif($alturl) {//check for current page in alturl
echo ' url='.$cururl.' alturl='.$alturl.' index='.strstr($alturl,'/index.php');//debug
$active = ((strstr($cururl,$alturl) and (strstr($alturl,'/index.php') != '/index.php')) or ($cururl == $alturl))?' class="activeILPage"': '';
}
return $active;
}
?>
/includes/templates/custom_template/templates/tpl_ezpages_bar_header.php
PHP Code:
<?php
/**
* Page Template
*
* Displays EZ-Pages Header-Bar content.<br />
*
* @package templateSystem
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_ezpages_bar_header.php 3377 2006-04-05 04:43:11Z ajeh $
* /includes/templates/your_template/templates/tpl_ezpages_bar_header.php
*Modified for Ezpages Improved Menus by Glenn Herbert (gjh42) 2010-08-23
*/
/**
* require code to show EZ-Pages list
*/
include(DIR_WS_MODULES . zen_get_module_directory('ezpages_bar_header.php'));
if (sizeof($var_linksList) >= 1) { ?>
<div id="navEZPagesTop">
<ul>
<?php for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) {
if ($var_linksList[$i]['altURL']) {//check for current page in alturl - debug test
$active = ((strstr($_GET['url'],$var_linksList[$i]['altURL']) and (strstr($var_linksList[$i]['altURL'],'/index.php') != '/index.php')) or ($_GET['url'] == $var_linksList[$i]['altURL']))?' class="activeILPage"': '';
echo ' url='.$_GET['url'];
} // /debug test
echo '<li class="link"><a href="' . $var_linksList[$i]['link'] . '"' . $active /*debug test*/ . active_page_class($var_linksList[$i]['id'],$_GET['url'],$var_linksList[$i]['altURL']) . '>' . $var_linksList[$i]['name'] . '</a></li>' . ($i < $n ? '<li class="separator">' . EZPAGES_SEPARATOR_HEADER . '</li>' : '') . "\n";
} // end FOR loop ?>
</ul>
</div>
<?php } ?>
/includes/templates/custom_template/sideboxes/tpl_ezpages.php
PHP Code:
<?php
/**
* Side Box Template
*
* @package templateSystem
* @copyright Copyright 2003-2005 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_ezpages.php 2982 2006-02-07 07:56:41Z birdbrain $
* /includes/templates/your_template/sideboxes/tpl_ezpages.php
*Modified for Ezpages Improved Menus by Glenn Herbert (gjh42) 2010-08-23
*/
$content = "";
$content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">';
$content .= "\n" . '<ul>' . "\n";
for ($i=1, $n=sizeof($var_linksList); $i<=$n; $i++) {
$content .= '<li><a href="' . $var_linksList[$i]['link'] . '"' . active_page_class($var_linksList[$i]['id'],$_GET['url'],$var_linksList[$i]['altURL']) . '>' . $var_linksList[$i]['name'] . '</a></li>' . "\n" ;
} // end FOR loop
$content .= '</ul>' . "\n";
$content .= '</div>';
?>
Do I have everything right?
-
Re: #categories li a.cat-selected-text but for EZPAGES
It all looks right. I've been researching $_GET and it seems that $_GET['url'] is not used anywhere in Zen Cart. Apparently whatever we thought we saw when I first added it to the code as a trial was mistaken... but it did work then for all the links, right? I haven't yet been able to locate the terminology for retrieving the complete URL from the page, and that is what is really necessary for a robust active link identifier. I'll keep looking...
-
Re: #categories li a.cat-selected-text but for EZPAGES
I posted a request and got a good lead from some members who know PHP better than I do.
$_SERVER['REQUEST_URI'] gives what we are looking for here. I knew I had seen something that did it, but was focused on $_GET.
So, going back to my original set of files in post #28 (and adding the global statement),
PHP Code:
function active_page_class($ezpid,$alturl) {
global $current_page_base;
$active = '';
if($current_page_base == 'page') {
$active = ($_GET['id'] == $ezpid)? ' class="activeEZPage"': '';
}elseif($alturl) {//check for current page in alturl
$active = ((strstr($_SERVER['REQUEST_URI'],$alturl) and (strstr($alturl,'/index.php') != '/index.php')) or ($_SERVER['REQUEST_URI'] == $alturl))?' class="activeILPage"': '';
}
return $active;
}
This is the only edit that should be needed to those files.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Hmmm.. Still the same.
(I use all the codes in post #28 except the "ezpages_improved_menus_functions.php" )
-
Re: #categories li a.cat-selected-text but for EZPAGES
Oh well, debug time again.
echo ' url='.$_SERVER['REQUEST_URI'],' alturl='.$alturl;//debug
PHP Code:
}elseif($alturl) {//check for current page in alturl
echo ' url='.$_SERVER['REQUEST_URI'],' alturl='.$alturl;//debug
$active = ((strstr($_SERVER['REQUEST_URI'],$alturl) and (strstr($alturl,'/index.php') != '/index.php')) or ($_SERVER['REQUEST_URI'] == $alturl))?' class="activeILPage"': '';
}
-
Re: #categories li a.cat-selected-text but for EZPAGES
Have a look. Thanks, Glenn.
-
Re: #categories li a.cat-selected-text but for EZPAGES
url=/index.php?main_page=index alturl=http://www.oligoskincare.com/index.php?main_page=index
The $_SERVER is giving everything *after* the shop base, so the $alturl will have to be tweaked to match that. Once that is done, I think it will actually work correctly.
-
Re: #categories li a.cat-selected-text but for EZPAGES
PHP Code:
}elseif($alturl) {//check for current page in alturl
$alturl = '/' . str_replace(HTTP_SERVER . DIR_WS_CATALOG,'',$alturl);//strip root info, put back initial / to match $_SERVER format
echo ' url='.$_SERVER['REQUEST_URI'],' alturl='.$alturl;//debug
$active = ((strstr($_SERVER['REQUEST_URI'],$alturl) and (strstr($alturl,'/index.php') != '/index.php')) or ($_SERVER['REQUEST_URI'] == $alturl))?' class="activeILPage"': '';
}
Now let's see what we get...
-
Re: #categories li a.cat-selected-text but for EZPAGES
YES!!! You did it!!
Thank you so much, Glenn!
-
Re: #categories li a.cat-selected-text but for EZPAGES
There's still a bit of finessing to do to make the homepage link highlighting more robust, as there are several ways it can show in the address bar, but overall I'm happy with it. The next stage is to extend it to the ez-pages footer menu, and possibly the footer columns mod that I developed locally.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Glenn,
I want to thank you again for all your help. I really appreciate it!
I understand that it is not perfect, but I'm satisfied with it over all. Some are really strange, such as:
when you list products by manufacturers:
http://tinyurl.com/2djx2u4
and the "Home" is highlighted (bold and in light blue color). This happens also when you go to a sub-category product list page.
But, I'm happy with what you have and could have done.
Thank you. Thank you. Thank you!
-
Re: #categories li a.cat-selected-text but for EZPAGES
I played with it some more after my last post, and I believe this solves the false positives for home page:
PHP Code:
<?php
/**
*
* @copyright Copyright 2010 Glenn Herbert
* @copyright Portions Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.gnu.org/licenses/ GNU Public License V3.0
* @version $Id: /includes/functions/extra_functions/ezpages_improved_menus_functions.php
*Ezpages Improved Menus by Glenn Herbert (gjh42) 2010-08-31
*/
//call as activePageClass($var_linksList[$i]['id'],$var_linksList[$i]['altURL']);
function active_page_class($ezpid,$alturl) {
global $this_is_home_page;
$active = '';
if($_GET['main_page'] == 'page') {
$active = ($_GET['id'] == $ezpid)? ' class="activeEZPage"': '';
}elseif($alturl) {
$alturl = str_replace(HTTP_SERVER . DIR_WS_CATALOG,'/',$alturl);
$active = ((strstr($_SERVER['REQUEST_URI'],$alturl) and !strstr('/index.php?main_page=index',$alturl)) or ($this_is_home_page and strstr('/index.php?main_page=index',$alturl)))?' class="activeILPage"': '';
}
return $active;
}
?>
-
Re: #categories li a.cat-selected-text but for EZPAGES
Hi, is this available in the downloads section? I have looked but i have failed to find it. Thanks.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Not yet. I have completed the footer version of the mod, but the header/sidebox version still needs final testing and documentation brushed up.
I will post a beta zip for now, so you can try it out.
-
Re: #categories li a.cat-selected-text but for EZPAGES
sorry for the lack of a reply. I have not had the time to test this for you and give feedback :(
I will hopefully have time to play after Xmas
Thanks
-
Re: #categories li a.cat-selected-text but for EZPAGES
I have actually fixed a few bugs in it since posting this zip. Let me know when you are ready and I will repost with the latest updates.
-
Re: #categories li a.cat-selected-text but for EZPAGES
Ezpages Improved Menus and Ezpages Footer Columns have been submitted to Free Addons. Until they are activated, you can get them at their support threads:
Ezpages Improved Menus support
Ezpages Footer Columns support