I have searched for a way to customise the simple navigation functions provided by PHPWCMS to no avail. Primarily I wanted to be able to use the nice NAV_TABLE_COLUMN tag to create a context sensitive navigation menu (compare with NAV_LIST_CURRENT).
After going through the code I realised that the replacement tag comes with all information needed to make the appropriate adjustments with a minimum of new code and hazzle.
I have added three parameters (in your template or content you add the parameters by adding ":PARAMETER", as per usual):
CURRENT - This parameter limits the scope of the menu to only children of the current page.
PARENT - This parameter limits the scope of the menu to only children of the current page's parent.
CAT_PARENT - This parameter (probably the most useful one...) looks up the page's top parent closest to the root node of the site and displays only children of this page. This is used to create "section navigation".
By editing the file content.func.inc.php and searching for NAV_TABLE_COLUMN and adding the below lines, you make the replacement tag accept these three additional parameters to extend it's functionality.
To gain this extended functionality, replace the NAV_TABLE_COLUMN replacement section in your code with the following:
Code: Select all
// Left table based rollover navigation
// Replacement tag altered by Johan Strömquist, 2008-07-03
// Added:
// CURRENT - display only children of current page
// PARENT - display only children of the current page's parent
// CAT_PARENT - display only children of the top level parent of the active site section
if(strpos($content["all"],'{NAV_TABLE_COLUMN') !== false) {
$parent = $content["cat_id"];
while ($parent) {
$catParent = $parent;
$parent = $content["struct"][$parent]["acat_struct"];
}
$content["all"] = str_replace('{NAV_TABLE_COLUMN:CURRENT}', '{NAV_TABLE_COLUMN:' . $content["cat_id"] . '}', $content["all"]);
$content["all"] = str_replace('{NAV_TABLE_COLUMN:PARENT}', '{NAV_TABLE_COLUMN:' . $content["struct"][$content["cat_id"]]["acat_struct"] . '}', $content["all"]);
$content["all"] = str_replace('{NAV_TABLE_COLUMN:CAT_PARENT}', '{NAV_TABLE_COLUMN:' . $catParent . '}', $content["all"]);
$content["all"] = str_replace('{NAV_TABLE_COLUMN}', '{NAV_TABLE_COLUMN:0}', $content["all"]);
$replace = 'nav_table_struct($content["struct"], $content["cat_id"], "$1", $template_default["nav_table_struct"]);';
$content["all"] = preg_replace('/\{NAV_TABLE_COLUMN:(\d+)\}/e', $replace, $content["all"]);
}