Jump to content

Caching Problem


Recommended Posts

I know I'm pushing my luck here with this one but it hopefully only hurts little to ask so here goes.

I have a unique homepage from the rest of the store. This page has a custom horizontal css/jQuery navigation bar on it. The rest of the site is using a super-fish vertical nav menu. When caching is enabled as soon as you go from the homepage to any other page and back again the horizontal nav bar disappears. I am using ($NAVIGATION_TREE} for both of these in two different files.

box.hnav.php

box.navigation.php

If I turn caching off it works fine. If I clear the cache I get one use, then it breaks again. Obviously it seems I have a conflict from using {$NAVIGATION_TREE} on the two different pages. Is there a way to fix this?

Also, an jQuery experts here? The css menu I am using has an error for jQuery is undefined but I have no idea what that means or how it should be defined. I have a message out to the person who setup the menu but have not heard back yet. Thought I'd ask here too just in case....

Link to comment
Share on other sites

Find the templates you believe are causing problems because of being cached (probably box.hnav.php and box.navigation.php).

I am of the opinion {$NAVIGATION_TREE} is not the culprit, as from what you say its the overall menu that's different between the custom homepage and the other pages. But I'll let you decide what's going on.

Anyway, use {nocache}....{/nocache} to wrap the part of the HTML/Smarty variables that you've decided should not be cached.

Is the javascript error message being generated on a storefront page? Is so, what's the address where this happens?

And there is something about a sidelogo.jpg not being found.

Link to comment
Share on other sites

Hi Dodgebill,

I like the theme you have chosen for your shop with the sliding header. Have a look at my home page. Mine is made in foundation 5.

I am not a programmer, but I see that the code you are using is not foundation based, but you have grafted the cubecart foundation code into your html . 

Would it be better to start afresh with a foundation orbit slider code, ala : http://foundation.zurb.com/docs/v/4.3.2/components/orbit.html

regards Duncan

Link to comment
Share on other sites

tried the {nocache} idea but it still does the same thing. I guess that rules out a caching problem at least. Now I'm stumped

I have this on two sites right now

http://cnkapparel.com/store (NSFW)

and

http://www.bill-cooke.com/ccskins (plain base CC 6.0.6 install)

I wanted to make sure it wasn't something else I had done that was causing it.

Link to comment
Share on other sites

When I leave the Homepage and come back, I still have:

<div class="cssmenu">
    <ul> </ul>
</div>

Which means that whatever is in between the <ul> tags is not getting processed. I'm going to guess it's box.navigation.php. for this statement in main.php: {include file='templates/box.navigation.php'}.

If you haven't tried:

{nocache}{include file='templates/box.navigation.php'}{/nocache}

in both <body> sections, please let us know if that makes a difference.

 

 

 

Link to comment
Share on other sites

Here is the code I am using for box.hnav.php

  {nocache}
   <div id="cssmenu">
 <ul> {$NAVIGATION_TREE}
                {if $CTRL_CERTIFICATES && !$CATALOGUE_MODE}
                <li><a href="{$URL.certificates}" title="{$LANG.navigation.giftcerts}"><span class="icon icon-gift"></span> {$LANG.navigation.giftcerts}</a></li>
                {/if}
                {if $CTRL_SALE}
                <li><a href="{$URL.saleitems}" title="{$LANG.navigation.saleitems}"><span class="icon icon-tag"></span> {$LANG.navigation.saleitems}</a></li>
                {/if}
        </ul> </div>
               {/nocache}

 

Link to comment
Share on other sites

I will assume you are using {$NAVIGATION_TREE} in both box.hnav.php and box.navigation.php.

{$NAVIGATION_TREE} is populated using the element.navigation_tree.php template. (I would have little expectation that adding {nocache} in this template would work as this template is called recursively. That is, CubeCart inserts that template into itself.)

Let me try to replicate the dual expression of this template and I'll check my skin cache files.

 

On the other hand, I know you have items for sale as I see the For Sale link in the horizontal menu on the Homepage. Yet, this is all I see:

<div class="cssmenu">
    <ul> </ul>
</div>

No sale items. Hmm...

Link to comment
Share on other sites

8afd2.html.Lingerie.menu.en-GB.cache is actually the file in the cache folder that is causing the problem. Delete that and you get one normal page load.

Here is the content of that file

-- CubeCart Cache Split --
<div id="navigation">
        <div id="box-title"> <h3 id="navigation-toggle">Shop by Category</h3> </div>
        <ul class="sf-menu sf-vertical sf-mobile">
                <li>
  <a href="http://www.bill-cooke.com/ccskins/test-category.html" title="Test Category">Test Category</a>
  </li>
                                                <li><a href="http://www.bill-cooke.com/ccskins/sale-items.html" title="Sale Items"><span class="icon icon-tag"></span> Sale Items</a></li>
                        </ul>
</div> 

Link to comment
Share on other sites

In your store, what populates box.hnav.php?

For example, in /classes/gui.class.php, line 960, _displayNavigation() populates box.navigation.php. Are you using a hook to populate box.hnav.php?

The file, 8afd2.html.Lingerie.menu.en-GB.cache, is CubeCart's cache file (same gui function), not Smarty's skin cache file, so {nocache} would be irrelevant in this case.

Link to comment
Share on other sites

I was trying to reuse $NAVIGATION_TREE and whatever makes that work (elements.navigation_tree.php) for both menus. I almost got away with it too! 'Til that meddling cache got in the way! (sorry scooby doo flashbacks).

I really wanted to be able to do this just as a skin without any big mods to the core code. That is looking less likely as this goes on.

Link to comment
Share on other sites

I'm sorry, I guess I do not understand what you are asking.

I have already posted to code in box.hnav.php and just explained what I was trying to do. It is populated by the same thing as box.navigation.php, whatever that is.

Link to comment
Share on other sites

Maybe there is a simpler solution to this and that is to just use the horizontal nav menu on all pages. That seems to work I think.

I hate giving up but I really hate to get stuck on one problem and stop all other progress. Maybe once I learn a bit more about hooks and such I can build a mod that will allow this but until then it's just too hard.

I REALLY miss CC4! and carburetors and land lines and..... Progress has it's downsides I guess.

Link to comment
Share on other sites

For example, look at the file /classes/gui.class.php, line 960, _displayNavigation() . The code in this function populates box.navigation.php. Let's look at this function.

It first checks to see if there is a cached file for the rendered HTML nav menu. If it was found in the cache, then use it for CATEGORIES. {$CATEGORIES} is found in the template box.navigation.php.

If not in the cache, then get all the data and build everything necessary using box.navigation.php as the template. Also, cache the final rendered HTML content. Then use it for CATEGORIES. Here is where I was asking, "What uses box.hnav.php to find and populate the needed variables for that template."

But notice that only if the cached file is not found, is everything built and also assigned to Smarty variables.

What I am not seeing in your box.navigation.php and box.hnav.php template files are the test for the presence of {$CATEGORIES}.

{if $CATEGORIES}
{$CATEGORIES}
{else}
// All the other variables
// Such as {$NAVIGATION_TREE} and
// {$CTRL_SALE}, among everything else.
{/if}

As I said, if the cached file exists, use it for CATEGORIES. The consequence being that the function does not go through the process of assigning data to NAVIGATION, et al. And if your templates does not have {$CATEGORIES} for the GUI function to assign the cached file to it, nothing is going to be displayed for that template file.

Link to comment
Share on other sites

I have been playing with gui.class.php with little luck so far. I see how it works but haven't hit the right code to give each menu it's own identity. If I comment out the caching functions I do get it to work. The problem with that is trying to make this skin so it can be easily installed by anyone and having to make changes to the base code like that.

So, what you described does put something in the box.hnav.php file to show after a page refresh but it is showing the contents of box.navigation.php, not the actual categories. It is caching the contents of box.navigation.php, not the actual list of categories. There needs to be a second cache event that takes the contents of box.hnav.php and stores those as something else.

If there was a way to make a plugin mod that would change the gui.class.php file automatically that would be ideal. A guy can dream, right?

Link to comment
Share on other sites

There is a hook in that function which will enable one to do whatever is necessary: delete the cached file, create/cache a separate file, whatever.

Or we can try to work out the HTML in the templates to give us what we need -- you said this is a distinct skin, right?

So, how is the menu contents, strictly from <ul> to </ul>, different between box.navigation.php vs box.hnav.php?

Link to comment
Share on other sites

So, how is the menu contents, strictly from <ul> to </ul>, different between box.navigation.php vs box.hnav.php?

That is the problem. They are identical. The only difference is the <ul class="">

I have tried to read the tutorial about mods and hooks but it's so basic it was no help in this case. Honestly I have no idea how they work or what to do with them. My specialty is graphics and layout. Coding is not my strong suit but I try. Sadly, it's like teaching violin to a monkey. You might get him to hold it and move the bow but he has no idea why... OK, I'm not that hopeless but I do get lost pretty quickly in the code.

Link to comment
Share on other sites

On the Homepage, I see:

<div id="navigation">
<div id="cssmenu">
<ul>
<li>

On a Category page, I see:

<div id="navigation">
<div id="box-title"> <h3 id="navigation-toggle">Shop by Category</h3> </div>
<ul class="sf-menu sf-vertical sf-mobile">
<li>

Assuming that, for your custom skin, we can put:

<div id="navigation">
<div id="cssmenu">

in the main.php template, in the <body> section that belongs to the Homepage, and put:

<div id="navigation">
<div id="box-title"> <h3 id="navigation-toggle">Shop by Category</h3> </div>

in the main.php template, in the <body> section that belongs to everything else, that just leaves:

<ul>
vs.
<ul class="sf-menu sf-vertical sf-mobile">

to deal with, depending which <body> section we are using.

There is no harm to having a class attribute where no class definitions or javascript actionality exists.

It may not be pretty, but put all the superfish CSS and JS files in a separate folder. Then, in the main.php places where CSS files are called (<head>) and javascript files are called (bottom of <body> -- the specific section), add code such as:

{if $SECTION_NAME != 'home'}
Get the super-fish CSS files and javascript files from the specific folder
{/if}

We put these files in a separate folder so that CubeCart will not automatically add them to the list of CSS and javascript files to fetch.

This then cancels the need to have a separate template file when box.navigation.php can contain only the common <ul> to </ul> code.

Link to comment
Share on other sites

I see what you are doing there. I'll give that a try and let you know how it works.

Alternatively, couldn't I just change the vertical navigation file from

<ul class="sf-menu sf-vertical sf-mobile">

to <div class="sf-menu sf-vertical sf-mobile"> and then just use the same <ul> for each menu just to pull the data?

Nope, just tried that. TOO easy... I'll try you're suggestion and see what happens. Let you know once I get it up and running, or not.

Link to comment
Share on other sites

Just tried it and still does not work once I turned the caching functions back on in gui.class.php. The problem isn't the css info I guess. It seems to be the cache file is for box.navigation.php only. When it tries to pull up box.hnav.php it sees nothing. There seems to be a need for a second cache file just for box.hnav.php.

I have tried to copy the original part of the gui.class.php code that creates that cache file and change the names but it does not work for me. Remember, monkey with a violin... Here is where I have commented out the cache functions and it works just fine.

/**
         * Display navigation box
         */
        private function _displayNavigation() {
                $cache_id = 'html.'.$this->_skin.'.menu.'.$GLOBALS['language']->current();
                $serialize = false;
           /*    if (($content = $GLOBALS['cache']->read($cache_id,$serialize)) == false) {   */
                        
                        //Get the navigation tree data
                        $tree_data = $GLOBALS['catalogue']->getCategoryTree();
                        //Make the navigation tree
                        $navigation_tree = $this->_makeTree($tree_data);
                        $GLOBALS['smarty']->assign('NAVIGATION_TREE', $navigation_tree);

                        //Check for sales
                        $GLOBALS['smarty']->assign('CTRL_SALE', $GLOBALS['config']->get('config', 'catalogue_sale_mode'));

                        //Check for gift certs
                        $gc_status = $GLOBALS['config']->get('gift_certs','status');
                        if ($gc_status=='1') {
                                $GLOBALS['smarty']->assign('CTRL_CERTIFICATES', true);
                        } else {
                                $GLOBALS['smarty']->assign('CTRL_CERTIFICATES', false);
                        }

                        $url = array (
                                'saleitems' => $GLOBALS['seo']->buildURL('saleitems'),
                                'certificates' => $GLOBALS['seo']->buildURL('certificates')
                        );
                        $GLOBALS['smarty']->assign('URL', $url);
                        //Fetch the navigation so we can cache it
                        foreach ($GLOBALS['hooks']->load('class.gui.display_navigation.pre_cache') as $hook) include $hook;
                        $content = $GLOBALS['smarty']->fetch('templates/box.navigation.php');


                        $content = str_replace('/index.php/', '/', $content);
                        
                      /*   $GLOBALS['cache']->write($content, $cache_id, '', $serialize);
               } */

                foreach ($GLOBALS['hooks']->load('class.gui.display_navigation') as $hook) include $hook;

                //Send it to the main template
                $GLOBALS['smarty']->assign('CATEGORIES', $content);
        }

 

Link to comment
Share on other sites

So close but the css info is getting all jumbled up.

Why does it not work to change

<ul class="sf-menu sf-vertical sf-menu">

to

<div class="sf-menu sf-vertical sf-menu"> <ul>

If that works for the other menu why not this one?

The homepage is still pulling up the superfish menu css info for some reason. I moved it all to a folder called 'new' in the template, not in a css or js folder. That works fine on every other page so I know it's finding it but it's also stepping on the menu on the home page.

Edited by Dodgebill
Link to comment
Share on other sites

"Why does it not work to change..."

I suppose the css/javascript is looking for rules/selectors specific to ul.sf-menu, not a general .sf-menu (which would include everything including div's). (I wonder why sf-menu is in the class list twice? Hm...)

But the site sems to be working for me, just fine.

I see that superfish.js is still getting loaded at the bottom of the <body> section for the Homepage.

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.

×
×
  • Create New...