Jump to content
Sign in to follow this  
bzfvggigaietjghnkzdfaewrkv

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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Here's a shot of our menu - GC link is at the bottom, but what we're hoping to achieve is a drop-down arrow under 'CHRISTMAS GIFT IDEAS' at the top.

We want to duplicate the link to /gift-certificates.html at the top, as a temporary feature.

I tried the snippet as above but no success so far

Screen Shot 2018-12-04 at 11.46.43 am.png

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...