Jump to content

Popular Products (box) - just on home page


disco_ii_disco

Recommended Posts

Hello,

I am working on a new skin for my store.

I want the "popular products" box just displayed on the home page, so have moved:

{include file='templates/box.popular.php'}    

on to the "content.homepage.php" template.

But it doesn't display now. I can't seem to find any reason, in the code, why it would not work. Any advice?

 

Link to comment
Share on other sites

That approach would then put the popular box at a spot inside the actual area showing the homepage content.

There is a variable we can test for:

In the main.php template, find:

{include file='templates/box.popular.php'}

Change to:

{if $SECTION_NAME eq "home"}{include file='templates/box.popular.php'}{/if}

The specific reason it dosn't show is because CubeCart processes the various pieces of the templates in two phases: the main content, then all the extra bits.

So, the Homepage, being the main content, gets all its data fetched from the database and prepared. All that is then given to Smarty, and then immediately asks Smarty to compile and render the final HTML. Done.

Then CubeCart starts working through all the various boxes.

Therefore, since content.homepage.php, the main content, having already been created, and with no data having been fetched and prepared for the box.popular.php template at that time, the Popular Products just won't show.

Link to comment
Share on other sites

Many thanks for that. That is a good tip which I'm sure I'll use. (e.g. to just show the breadcrumbs on product pages).

For this though, my homepage has a completely different layout to the other pages, so I need to include the popular products amongst the hompepage code. 

On my existing site, I have a code snippet that loads my own version of the bestselling products - so I'll continue with this method for my new site. I'll change the "Number of popular products to display" setting to 0, so it prevents the Cubecart list getting loaded.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...