Jump to content

Linking to a Tool in Nav Menu ?


Nik Grey
 Share

Recommended Posts

Using the Mican skin.

 

I want to add a link in the navigation menu on the left hand side which points to this tool Here. but either I am using the wrong search terms or there is very little to give me any clues.

 

I have tried adding new categories/products etc but still no way of pointing a menu item to the page which contains my tool :(

 

I suppose we are going to be editing files ? how would I go about this hopefully simple task ?

Link to comment
Share on other sites

Would you like to use a snippet (a small piece of PHP that modifies the results of CubeCart core code and survives upgrades), or a hard edit on the skin?

 

If a hard edit on the skin, in the skin template file box.navigation.php, find:

    <li><a href="{$STORE_URL}/index.php" title="{$LANG.navigation.homepage}">{$LANG.navigation.homepage}</a></li>

    {$NAVIGATION_TREE}

    {if $CTRL_CERTIFICATES && !$CATALOGUE_MODE}

Between the second and third line shown, add:

    <li><a href="{$STORE_URL}/index.php?_a=letter" title="Lettering Tool">Lettering Tool</a></li>
Link to comment
Share on other sites

On the other hand, you can make a copy of the Mican skin, call it Mican_Nik (with two edits in the config.xml file), and this new skin won't be overwrote on an upgrade. But then you will need to make any upgrades to this new skin manually.

 

So, we will do a snippet. In admin, Manage Hooks, Code Snippets tab:

 

Enabled: green tick

Unique ID: [email protected]_Grey

Execution Order: 99

Description: Adds a link to my Lettering Tool page on the Shop by Category Navigation List.

Trigger: class.gui.display_navigation.pre_cache

Version: 1.0

Author: forums.cubecart.com/topic/48070-linking-to-a-tool-in-nav-menu/

PHP Code:

{php}
$lettering_tool_branch = array('url' => $GLOBALS['storeURL']."/index.php?_a=letter", 'name' => "Lettering Tool");
$GLOBALS['smarty']->assign('BRANCH', $lettering_tool_branch);
$navigation_tree .= $GLOBALS['smarty']->fetch('templates/element.navigation_tree.php');
$GLOBALS['smarty']->assign('NAVIGATION_TREE', $navigation_tree);
{/php}

In CubeCart admin, Maintenance, Rebuild tab, clear your cache because this navigation list is cached, and the current cached list does not have the link that this snippet adds.

Link to comment
Share on other sites

"There is no 'Homepage' link. Is there a way I can get rid of the boxes on the right?"

 

Apparently, some javascript is causing the sidebar_left column to disappear. The same could be done for the sidebar_right column.

 

In the file, /modules/external/lettering/js/front.js, after:

$("#sidebar_left").remove();

add:

$("#sidebar_right").remove();

 

The "Home" breadcrumb is still there.

 

Also, (but then, if it works for you...) the Tool page HTML is calling jQuery 1.8.2, and the core CubeCart calls jQuery 1.7.

 

I mention again, I have no knowledge as to the consequences of calling two versions of the jQuery code.

Link to comment
Share on other sites

Just got home, I present/represent Hospital Radio here in Norwich and had to go and accept a cheque from our local Amateur Radio club - it was a big occasion and took longer than expected.. as we are a charity I do a few things in the fundraising department.

 

I will try the code above Brian so thanks for that.

DB The Mobile Skin may have to be disabled as I think its going to be more trouble than its worth at the moment as there's no way the tools will work with it - the Upload Tool cropping wont work on touch screens and I hadnt even checked the Lettering tool.

 

I would be happy with Breadcrumbs but I cant even see them ! I can see them, was looking in the wrong place (I am used to Joomla)

 

I am using Firefox on OSX 10.9.1

 

ok, that worked - it removed the sidebar on the right but its just a blank space now as may as well have the sidebar back unless there is a way of making that tool bigger without too much messing about (I doubt it though).

 

Also I just noticed Brians 2nd comment.. will try now.

 

You see - if you follow instruction things do work :)

 

Outstanding: http://greyprint.co.uk/index.php?_a=letter

Link to comment
Share on other sites

Is there any way I can add some explanation text under this tool now ? I will need to explain how to use it and maybe link to some other pages - a 'Vinyl Application Guide' for example.

 

Really what I am saying is I would like to edit the page !

 

Oh no, its broken again, nothing is being added to the cart :(

Link to comment
Share on other sites

ok - sussed it :)

 

I must have a 'Lettering' category enabled for this to work - if I disable it then nothing is sent to the cart.

 

So... how can I hide this 'Lettering' category from the menu but still keep it active ?

 

Your a Legend Brian.

Link to comment
Share on other sites

How can I hide this 'Lettering' category from the menu but still keep it active?

 

I won't try to guess why having a 'Lettering' category is a requirement. But I see what appears to be tool submissions as products in the category. So the tool must first be creating a new inventory item, then assigning it to the 'Lettering' category. Then it adds the newly created inventory item to the shopping basket.

 

(It would be kind of neat to have a set of "products" in the 'Lettering' category already in inventory: famous quotes, taglines, etc.)

 

(Umm.. You are making vinyl signs/posters. So why would anyone want such a thing with a quote/tagline?)

 

Have you tried making the 'Lettering' category invisible (it will still be enabled -- status=1)? Admin, Categories, click to make the red x in the Visible column.

 

If that affects how the Lettering Tool functions, then we will need to find another solution.

 

 

Really what I am saying is I would like to edit the page!

 

You can issue a "change order" to the developers and require the project to include a method in admin to put custom content in the newly opened up area on the right third of the lettering tool screen.

 

You will say it's for more fuller explanatory text (maybe in several languages) that CSS tricks allow when hovering over the tool's selectors (instead of 'tooltips'). For example, you might create the text block that shows the color chart here instead of a separate page.

Link to comment
Share on other sites

Thanks Brian,

 

I have paid the developer for this now, I am just glad its over with them. it would probably take months to get the revisions I want and I am due for a less stressful time.

 

I tried the 'Status' option - turning it from the tick to the cross but then nothing is added to my cart from the tool, it took me a while to figure that out - I have been trying different stages of the instructions you gave above to see which bit was causing it to fail.. then in a last attempt tried enabling that category again.

 

If you go to the category I want to hide, there is sort of an explanation at the top "Separate Category to Maintain Products Created for Lettering Purpose from Front End." but of course there is no need to show what others have purchased - some may not like to see that made public at all as you can imagine.

 

I think I am going to have to find a way to put a page in between the link on the homepage and the tool so I can explain how it works - that's the only way I can see at the moment.

Link to comment
Share on other sites

When calling the add method in cart, it called catalogue -> getProductData, which does return false if the category is disabled, so yeah, as it currently stands, you can't order products if the category is turned off.

 

You could turn that off by editting classes/catalogue.class.php

 

Finding:

            if (!$category_status) {
                return false;
            }

And just changing to

            if (!$category_status) {
#                return false;
            }

Not sure if that's makeable as a snippet, still require the standard hooks don't they? Don't see any suitable on those locations that would get round it
 

Link to comment
Share on other sites

I have recently discovered that the Visible column in the admin list of categories is actually the Status. I find no code in CC525 that reads from or writes to the 'hide' column of the CC_category table.

 

So, there is no hiding a category.

 

I will add to the existing snippet that will look for the string of code that has the 'Lettering' category and remove it. I'll get to this shortly.

Link to comment
Share on other sites

Well, I was thinking I had done this successfully with categories, so I checked. I AM able to hide a category - as a test I was able to hide the Clearance category on plushcatalog. But, unlike a hidden document, I could NOT use the actual url for the clearance category to access it. So there is a difference between a hidden category, which is in effect disabled, and a hidden document, which is still accessible.

 

Documents have an extra field in the table called doc_url_openin that controls the hidden feature. It would seem logical that this is a bug in CC, as why otherwise hide a category when you have done the same thing as disable it?

Link to comment
Share on other sites

In the snippet, change the PHP code to this:

{php}
$lettering_tool_branch = array('url' => $GLOBALS['storeURL']."/index.php?_a=letter", 'name' => "Lettering Tool");
$GLOBALS['smarty']->assign('BRANCH', $lettering_tool_branch);
$navigation_tree .= $GLOBALS['smarty']->fetch('templates/element.navigation_tree.php');
$navigation_tree = preg_replace('#<li>.*title="Lettering".*</li>#s','',$navigation_tree);
$GLOBALS['smarty']->assign('NAVIGATION_TREE', $navigation_tree);
{/php}

The new line is a preg_replace that looks for a <li> tag, followed by anything but eventually must contain the title="Lettering" sequence, followed by anything, ending with a </li> tag. If found, the function will replace the match with nothing.

 

This only affects the Navigation List (Shop by Category). That is, a site map will still be listed, for example.

 

We also need to deal with these "products" showing up in the Featured Product and Popular Products boxes.

 

"Cart->add() calls Catalogue->getProductData(), which does return false if the category is disabled."

 

I stand corrected.

Link to comment
Share on other sites

Well, I was thinking I had done this successfully with categories, so I checked. I AM able to hide a category - as a test I was able to hide the Clearance category on plushcatalog. But, unlike a hidden document, I could NOT use the actual url for the clearance category to access it. So there is a difference between a hidden category, which is in effect disabled, and a hidden document, which is still accessible.

 

Documents have an extra field in the table called doc_url_openin that controls the hidden feature. It would seem logical that this is a bug in CC, as why otherwise hide a category when you have done the same thing as disable it?

Hidden category status is set to 0 - disabled. No other way to hide a category. When category is disabled it can't be accessed nor any product from such a category purchased.

 

Documents have the hide link feature category does not at this time. When a document is disabled it can't be even viewed this acts as the same as disabled category. However document link can be hidden using "Show link to document in storefront?" setting but document must be enabled to access its content via direct URL. Custom doc URL even doc_url_openin as you already mentioned has nothing common to hide doc link.

 

Well there is a category table column using name 'hide' but used almost nowhere apart from  searchCatalogue() method of catalogue class but seems as an early v5 development result only. May be a new feature as the same as document has to hide link to a category from Shop By Category box. This however also removes such a category subcategories from list.

Link to comment
Share on other sites

Sorry for the delay in my response, and trying the suggested edits. Thursdays is my Hospital Radio Show day so am not usually around much on that day as there is a lot of preparation to do (patients to visit).

 

Many thanks for your continued support - I only wish I had the money to throw at this in order to get it as I expected it to be :(

 

I tried both Brian's edit and then Jonathan's but unfortunately Brians removed my other products aswell. adding the hash to the file mentioned didnt seem to do anything. WI was clearing my Cache each time (got used to doing that when making any change).

Link to comment
Share on other sites

Hmm, that's weird.. my change should let it add a product despite the category being disabled, can't see any other error it would cause getting the product data.

 

It's not something else, like it missing a required option and throwing an error due to that perhaps? That's one of the few other checks it makes while trying to add something to the basket.

 

There's some code which checks if it's out of stock or such, but that should still add it, though it'll cause a redirect to the basket which will usually then remove it and give you a warning message (or allow it, if you've got your settings to allow out of stock purchases)

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

 Share

×
×
  • Create New...