My Sellerdeck Account | Free Trial

Sellerdeck Community & Knowledge Base

Old 22-Nov-2009, 05:18 PM
KB KB is offline
Join Date: Nov 2009
Posts: 1,012
Thanks: 0
Thanked 34 Times in 29 Posts
How can I generate a random product list on my home page?

We first store the HTML of the Mini Best Seller layout from all products into an array.

Then later display 4 at random.

<!-- Here we fill a PHP array with snippets of HTML from all products -->
<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" />

<!-- 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)];

You could put the first bit (or all of it) into a layout that's processed only once (like Brochure Home page). The second snippet could be on every page as the PHP array should be populated then.

Kindly provided by Norman Rouxel from Drillpine
Reply With Quote
Old 03-Aug-2017, 03:52 PM
graphicz's Avatar
graphicz graphicz is offline
Registered User
Join Date: May 2007
Full Name: Jonathan Chappell
Posts: 828
Thanks: 77
Thanked 135 Times in 101 Posts
This continues to work very well (v16 now) but with large sites can significantly lengthen the time to take snapshots and for uploading the site.

I have played around with the invariant property and this seems to work to speed upload and snapshot without hindering the generation process:

<actinic:block invariant="true" >
<!-- Here we fill a PHP array with snippets of HTML from all products -->
<actinic:block php="true">unset($allproducts);</actinic:block>
<actinic:block type="EntireSectionList" >
<actinic:block php="true" type="ProductList" >
if ( <actinic:variable name="ProductType" /> == 0 )
$allproducts[] = <<<ENDOFCODE
<actinic:variable encoding="perl" value="forMMII" name="BestSellerItem" />
An invariant block is wrapped around the whole expression.
Site in question had some 2000 products and without the invariant block upload was 30mins coming down to five minutes with the block.

Thanks to Norman
Jonathan Chappell
Website Designer
SellerDeck Website Designer
Actinic to SellerDeck upgrades
Graphicz Limited -
Reply With Quote
The Following User Says Thank You to graphicz For This Useful Post:
Duncan Rounding (04-Aug-2017)

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT. The time now is 05:36 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.