I've done that, Glenn.
Thank you very much for helping me. I really appreciate it!
I've done that, Glenn.
Thank you very much for helping me. I really appreciate it!
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"': '';
} ?>
$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.
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.
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.
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.
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..
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/includes/templates/your_template/sideboxes/tpl_ezpages.phpPHP 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/templates/tpl_ezpages_bar_header.phpPHP 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>';
?>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.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 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.
As there are numerous tweaks from the previous version to this one, please test to make sure there are no typos or bugs introduced.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;}
Last edited by gjh42; 23 Aug 2010 at 11:13 PM.
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!
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.phpPHP 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;
}
?>
Bookmarks