Jump to content

Add static page to category menu


Recommended Posts

We may need to have a better description.

There is a link for the Gift Certificates as a "Shop by Category" menu item already.

Are you wanting a sub-menu item below (aka 'child of') the GC menu item?

Or are you wanting to edit the actual GC page where the customer fills out the form when purchasing the GC?

Link to comment
Share on other sites

There will be two tasks: create a code snippet, and make an edit to the skin template.

There are two assumptions:
The sub-item of the Gift Cert menu item will only appear if the Gift Cert menu item is actually there. That is, if Gift Certs are switched off, so also will this sub-item. And,
The link is hard-coded and the page must actually exist. Otherwise, CubeCart will try to interpret /special-sub-item.html as a valid CubeCart page - which will not be found and CubeCart will send the index.php page as the default.

In admin, Manage Hooks, Code Snippets tab, click Add Snippet. A form will be presented below a list of existing snippets.

Enabled: checked
Unique ID: [email protected]+
Execution Order: 1
Description: Adds an item to the static URLs of Nav
Trigger: class.gui.display_navigation.pre_cache
PHP Code:
{php}
$url['subcert'] = "/subcert.html"; // Destined to be a sub-item of GC, page must actually exist
$GLOBALS['smarty']->assign('URL', $url);

Edit the skin template as follows:

In box.navigation.php, find:

<li class="li-nav"><a href="{$URL.certificates}" title="{$LANG.navigation.giftcerts}">{$LANG.navigation.giftcerts}</a></li>

Change to:

<li class="li-nav"><a href="{$URL.certificates}" title="{$LANG.navigation.giftcerts}">{$LANG.navigation.giftcerts}</a>{if $URL.subcert}<ul><li><a href="{$URL.subcert}">{$URL.subcert}</a></li></ul>{/if}</li>

You may need to have CubeCart clear its internal cache. In admin, Maintenance, Rebuild tab, check the Clear Cache box and then Submit.

Link to comment
Share on other sites

I would like to understand why creating the code snippet didn't work for you. Maybe we can explore that later. In the list of snippets, delete that snippet from the list and restore from the edit made to the skin template.

We will create this snippet instead:

Enabled: checked
Unique ID: [email protected]+
Execution Order: 1
Description: Adds a non-cat menu item to a parent cat
Trigger: class.gui.display_navigation.make_tree
Version: 1.0
Author: https://forums.cubecart.com/topic/54574-add-static-page-to-category-menu/
PHP Code:
{php}
if ($branch['cat_id'] == 4) { // You must use the cat_id of the parent cat
	$special = array(
		'name'=>$GLOBALS['language']->navigation['giftcerts'],
		'cat_level'=>$branch['cat_level']+1,
		'url'=>$GLOBALS['seo']->buildURL('certificates',false,'&',false)
	);
	$GLOBALS['smarty']->assign('BRANCH', $special);
	$special_out = $GLOBALS['smarty']->fetch('templates/element.navigation_tree.php');
	$branch['children'] = $special_out . $branch['children'];
	$GLOBALS['smarty']->assign('BRANCH', $branch);
}

Note that you must use the actual cat_id of the "Christmas Gifts Ideas" category.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...