Announcement

Collapse
No announcement yet.

Me + Actinic + php

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

    Me + Actinic + php

    Hi all,

    I'm currently building my site using V8 and am a regular reader of this forum - this is the first time I've not been able to find an answer to a question, so I'm starting my first thread...

    My site is going to have 10,000+ products when complete. Whilst making use of Actinic's upselling tools (also bought/related lists), I'd also like a 'random' list of products generated on each page.

    I found this which has been very helpful (thanks Norman!)

    http://community.actinic.com/showthread.php?t=45325

    It works great, but I want to see if it can be taken a step further:

    Home page - random list of all products (as per Norman's code)
    Section 1 - random list of products from Section 1
    Section 2 - random list of products from Section 2
    etc etc

    My knowledge of php is, shall we say, limited (!) but I do like pulling code apart and experimenting with Actinic's capabilities to try and use it to it's full potential! As I can see it, presumably you'd need to take 'allprods' (as in Norman's code), and then filter it by sectionID? Am I along the right lines? Anyone feel like having a bash at actually translating into php code?

    Simon
    Last edited by KB2; 22-Mar-2010, 01:52 PM. Reason: Updating kb links

    #2
    the below code from the KB does the following in the first three lines
    1. clear the variable $allproducts so we start with a clean slate
    2. start a loop through ALL sections in the site
    3. start a loop throug all products in the sections defined in the line above (ALL)

    So if you remove line 2 <actinic:block type="EntireSectionList"> and the corresponding end of block </actinic:block> in line 11 it will only loop through the products in the current section. That's the theory anyway - can't test it at the moment but if you start by doing that you should get near to what you want. It will depend whereabouts you put the code as to whether it will pick up onthe products in the section you want it to.
    (might be worth changing all occurrences of the variable $allproducts to $productsinthissection if you are going to also display $allproducts on some pages)

    Code:
    <actinic:block php="true">unset($allproducts);</actinic:block>
    <actinic:block type="EntireSectionList">
      <actinic:block type="ProductList" php="true">
        if ( <actinic:variable name="ProductType" /> == 0 )
         {
         $allproducts[] = <<<ENDOFCODE
    <actinic:variable name="BestSellerItem" value="Mini Best Seller Layout" encoding="perl" />
    ENDOFCODE;
         }
      </actinic:block>
    </actinic:block>
    
    <!-- Here we output 4 random products -->
    <actinic:block php="true">
      for ( $i=1; $i<=4; $i++ )
        {
        echo '<br clear="all" />'  . $allproducts[mt_rand(0, count($allproducts) - 1)];
        }
    </actinic:block>

    Comment


      #3
      Hi Dave

      I've tested that out, and got the following:

      Notice: Undefined variable: allproducts in main on line 4

      But you got me thinking, so I replaced <actinic:block type="EntireSectionList"> with:

      <actinic:block php="true" type="ChildSectionList" >

      And it seems to work! Thanks!

      Comment

      Working...
      X