Announcement

Collapse
No announcement yet.

Related products in sidebar - how can I test to use different content if empty

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Related products in sidebar - how can I test to use different content if empty

    Hi Everyone,

    I have used Normans code (drillpine) to put related products to the side bar of a product (clever man).

    The code work great but I would like to fill the box with alternative content if there aren't any related products displayed.

    I have tried using a block if around the code but it seams that if there aren't any related product, actinic do not produces any code that can be tested buy a block if.

    I'd be very grateful if anyone could suggest a solution.

    Code used :

    <actinic:block type="ProductList"> <actinic:block type="RelatedProductsList"> <actinic:variable name="ProductRelatedProductsItem" /> <br/> </actinic:block></actinic:block>

    Toby@happyharris.co.uk

    #2
    Look at the Related Product List you are using for the sidebar. Click the Click here to edit list layout settings. Put your code into Empty List:.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thank you for your reply Norman..

      Please excuse my lack of understanding, but I am struggling to find Click here to edit list layout settings for the ProductRelatedProductsItem variable that I am using to display all of the related products in a sidebar.

      Your original code above produces exactly what I need, but I need to supply alternate code when no related products exist on a page.

      I have tried using ProductRelatedProductsList instead, but although I can sort out the "is empty" problem through the layout settings, the related products do not display.

      Once again, please excuse my lack of understanding. Any advice would be a great help..

      Toby@happyharris.co.uk

      Comment


        #4
        Select the design tab, click on a related product, that will be the related product layout, then using the upward arrow keep pressing until you see the list layout with the link mentioned. The design tree on the right should also help, if you don't see that go with 'restore split view layout' from the window menu.

        Comment


          #5
          Hi Lee,

          Still no luck, I think the problem is that I am using the code in my main layout template.

          <actinic:block type="ProductList"> <actinic:block type="RelatedProductsList"> <actinic:variable name="ProductRelatedProductsItem" /> <br/> </actinic:block></actinic:block>

          Toby@happyharris.co.uk

          Comment


            #6
            Go straight to the layout in the design library, dont have to go via the design tab.

            Comment


              #7
              Sorry Only half the post above.....

              I think that the problem is because I am using <actinic:variable name="ProductRelatedProductsItem" /> rather than the usual <actinic:variable name="ProductRelatedProductsList" /> which is in the product layouts.

              The settings normally being controlled by the List object rather than the Item object leaves me unable to test for an "is empty" state.

              Or that could all be tosh and I'm just blind!!!!!

              Toby@happyharris.co.uk

              Comment


                #8
                Possible solution

                Just to recap, I am putting all of the related products that appear on a product page in a side bar box. The problem was that when using Norman very helpful code

                <actinic:block type="ProductList"> <actinic:block type="RelatedProductsList"> <actinic:variable name="ProductRelatedProductsItem" /> <br/> </actinic:block></actinic:block>

                an empty box appeared on on pages when there were no related products.

                As the code uses <actinic:variable name="ProductRelatedProductsItem" /> rather than the usual <actinic:variable name="ProductRelatedProductsList" /> I could not use the setting "is empty".

                Through trial and error I think I may have a solution using the following code:

                <!-- Create PHP Variable -->
                <actinic:block php="true">
                $RelatedProductQty = 9999;
                </actinic:block>

                <!-- Run through Related list to Set $RelatedProductQty is Code Runs -->
                <actinic:block type="ProductList">
                <actinic:block type="RelatedProductsList">
                <actinic:block php="true">
                $RelatedProductQty = <actinic:variable name="ListCount" />;
                </actinic:block>
                </actinic:block>
                </actinic:block>

                <!-- Test if $RelatedProductQty is still 9999 if not create Related Items list-->
                <actinic:block php="true"" >
                if($RelatedProductQty !== 9999){
                echo '<div class="RelatedProductBox" id="RelatedProductBox-list">';
                echo '<h2>Related Products</h2>';
                echo '<ul>';
                echo '<actinic:block type="ProductList"><actinic:block type="RelatedProductsList">';
                echo '<li>';
                echo '<a href="<actinic:variable name="SearchCGIURL" />?PRODREF=<actinic:variable Name="ProductID" />&amp;NOLOGIN=1';
                echo '<actinic:block if="%3cactinic%3avariable%20name%3d%22IsHostMode%22%20%2f%3e">&amp;SHOP=<actinic:variable name="ShopID" /></actinic:block>">';
                echo '<Actinic:Variable Name="ProductName"/>';
                echo '<br><actinic:variable name="PriceListRetail" selectable="false" encoding="perl"/>';
                echo '</a>';
                echo '</li>';
                echo '</actinic:block></actinic:block>';
                echo '</ul>';
                echo '</div>';
                }
                </actinic:block>

                The basic idea is:
                1. Set a variable to represent the number of Related Products (which will never be correct)
                2. Run the list code to set the correct number of Related Products (if the page hasn't got any related items this code does not run)
                3. If the variable is then something other than its original value, run the full code to produce the box and related products.

                I have set out the code to make it easier to understand and de-bug and so far I haven't found any problems.

                I would be very grateful for any comments or suggestions

                Anyway, hope this is helpful, maybe the basic principle can be adapted for other situations.

                Finally I would like to say thank you for the vast amount of information in this forum, which I have used extensively

                Toby@happyharris.co.uk

                Comment

                Working...
                X