+ Reply to Thread
Results 1 to 13 of 13

Thread: Recently Viewed Navigation Block

  1. #1
    Client
    Join Date
    May 2011
    Location
    Venice, CA
    Posts
    4
    Squirrelcart version
    v3.3.5

    Recently Viewed Navigation Block

    How can I add a recently viewed products navigation block to my template? Is there a built in Squirrelcart block for this?

  2. #2
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    We do not have a feature for this. I wrote a custom one for you. It will be added to the next mid level release (v3.4.0). You can add this as follows to earlier versions:

    1. Click Settings > Themes > Navigation Blocks in the control panel

    2. Click Add New

    3. Enter a name, like Recently Viewed

    4. Enter the same value for the Header field

    5. Enter this for the Content field:
    PHP Code:
    <?php
    $show_limit 
    5;

    if (
    is_array($SC['products_viewed'])) {
        
    $prod_rns array_unique(array_reverse($SC['products_viewed']));
        
    $prod_rns_fixed = array();

        foreach(
    $prod_rns as $prod_rn) {
            if (
    $show_limit-- == 0) break;
            
    $prod_rns_fixed[] =  array('record_number' => $prod_rn);
        }
        
    $prod_info sc_products($prod_rns_fixed,'category_preview_box',1,5);
        
    $Product_Rows $prod_info['rows'];
        if (!
    $Product_Rows) return false;
            include 
    sc_tpl('category_preview_main');
    }

    if (
    $_GET['action'] == 'show_detail' && is_numeric($_GET['rn'])) {
        
    $SC['products_viewed'][] = $_GET['rn'];
    }
    ?>
    6. Double check that there are no blank lines or spaces before the code you pasted in the Content field, and that there are no blank lines or spaces after the code. A blank space before or after will cause the nav block to appear even when no products have been viewed.

    7. The value on the first line controls how many items will be shown:
    PHP Code:
    $show_limit 5
    If you want to show a different number, change that value.

    8. Click Save Changes

    9. Add the nav block to your storefront:
    http://www.squirrelcart.com/help/?Na...torefront.html

    It will show the last viewed items, up to the value you enter in $show_limit.

  3. #3
    Client
    Join Date
    May 2011
    Location
    Venice, CA
    Posts
    4
    Squirrelcart version
    v3.3.5

    Extremely Generous

    Jaime,

    That was extremely generous of you to provide the custom code for the module I needed. This is the first time I have actually had to use support for this product in the 4-5 years I have been using Squirrelcart and the response is a testament to how exceptional customer support can truly make a great product even better.

    Thanks for a great product!

    Scott

  4. #4
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    Hi Scott,

    You're welcome! Glad to finally have this feature.

  5. #5
    Client Beery_Asst's Avatar
    Join Date
    Feb 2006
    Location
    Houston, TX
    Posts
    189
    Squirrelcart version
    v3.4.0
    I quickly implemented this as well. Nice feature, thanks.

    Beery

  6. #6
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    Glad you like it!

  7. #7
    Client tgrant's Avatar
    Join Date
    Mar 2011
    Posts
    132
    Squirrelcart version
    v3.3.2
    Much appreciated! Very nice of you to do that!
    Regards,

    Tom

  8. #8
    Client
    Join Date
    Mar 2006
    Location
    Ontario, Canada
    Posts
    294
    Squirrelcart version
    v3.4.0

    Working But - Slight Error in Permissions

    Jamie,

    It is working, but I am getting an error code. Can you review the screen capture and let me know what permission I have not set up correctly.

    Thanks!

    P.S. - This is a very useful feature!
    Attached Images

  9. #9
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    That's a warning only. It is indicating the theme config file can't be saved because permissions aren't set to allow it. That file is only used to port your theme to another installation. It won't effect the way anything works.

  10. #10
    Client mNolan's Avatar
    Join Date
    Oct 2010
    Posts
    25
    Squirrelcart version
    v3.3.6
    Love it....

    Query - how can I change the code if i just want to output the link to the product without the picture? If there's existing code, can you please direct me there and i'll have a look into it?

    thanks heaps.

  11. #11
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    Quote Originally Posted by mNolan View Post
    Query - how can I change the code if i just want to output the link to the product without the picture? If there's existing code, can you please direct me there and i'll have a look into it?
    The code above is showing products via the already existing template files used for the Category Preview navigation block which shows products in the same category of a product being viewed in detail. You can make this show whatever you want by changing it to use custom template files.

    1. Create a new file recently_viewed_box.tpl.php in squirrelcart/themes/YOUR_CUSTOM_THEME/ with the following content:
    PHP Code:
    <?php /* This line prevents direct access to template. Don't remove it. */ if (!defined('SC_INCLUDE_OK')) die; ?>
    <!-- Template: <?php print basename(__FILE__?> -->

    <li class="tip" title="<?php print $Tooltip ?>"><a href="<?php print $URL ?>"><?php print $Name?></a></li>
    2. Create a new file recently_viewed_main.tpl.php in squirrelcart/themes/YOUR_CUSTOM_THEME/ with the following content:
    PHP Code:
    <?php /* This line prevents direct access to template. Don't remove it. */ if (!defined('SC_INCLUDE_OK')) die; ?>
    <!-- Template: <?php print basename(__FILE__?> -->

    <div class="recently_viewed nav_link_container">
        <ul class="nav_links">
            <?php foreach($Product_Rows as $Product_Row): $Product $Product_Row['products'][0]; ?>
                <?php print $Product['HTML'?>             
            <?php endforeach; ?>
        </ul>
    </div>
    3. Change the code that goes in the nav blocks Content field to:
    PHP Code:
    <?php
    $show_limit 
    5;

    if (
    is_array($SC['products_viewed'])) {
        
    $prod_rns array_unique(array_reverse($SC['products_viewed']));
        
    $prod_rns_fixed = array();

        foreach(
    $prod_rns as $prod_rn) {
            if (
    $show_limit-- == 0) break;
            
    $prod_rns_fixed[] =  array('record_number' => $prod_rn);
        }
        
    $prod_info sc_products($prod_rns_fixed,'recently_viewed_box',1,5);
        
    $Product_Rows $prod_info['rows'];
        if (!
    $Product_Rows) return false;
            include 
    sc_tpl('recently_viewed_main');
    }

    if (
    $_GET['action'] == 'show_detail' && is_numeric($_GET['rn'])) {
        
    $SC['products_viewed'][] = $_GET['rn'];
    }
    ?>
    That code is identical to what I originally posted, with the template names changed to your custom templates.

    That should show them in a list as links only, using the standard format we use for nav block links.

  12. #12
    Client mNolan's Avatar
    Join Date
    Oct 2010
    Posts
    25
    Squirrelcart version
    v3.3.6
    Much appreciated, works like a charm!

    Thanks again
    M

  13. #13
    Squirrelcart Staff Jamie's Avatar
    Join Date
    May 2002
    Posts
    6,829
    Squirrelcart version
    v3.3.7
    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts