rwaller Posted May 24, 2013 Report Share Posted May 24, 2013 I have recently purchased the PHP Shopping cart using xml and php software. I have a website created and each time I add a product to the xml file, it displays horizontally on the webpage. It's ok when you only have three like the tutorial shows. But when I put more than that, it continues to go across the page without going to a new line. Can someone tell me the best way to set the templates.php, main.css, or xml file so that my products start a new line after a certain number is added to the page. Thanks, RWALLER Quote Link to comment Share on other sites More sharing options...
cygnet Posted May 24, 2013 Report Share Posted May 24, 2013 (edited) Set changes to main.css file. Edited May 24, 2013 by Andrea Quote Link to comment Share on other sites More sharing options...
falkencreative Posted May 24, 2013 Report Share Posted May 24, 2013 @cygnet - a CSS change won't fix it. @Rwaller - You'd need to modify the render_products() function within /functions/templates.php to add support for individual rows within the product table. Within the foreach loop that loops through each product, you'd need to add a counter that tracked which column the product belonged in. So, for example, the first product would be product 1, the second would be 2, etc. If the counter is 1, you know to start a new row and insert a "<tr>" tag. If it is 3 (assuming you want three products per row), after the product has been added to the output variable, you'd need to insert a closing "</tr>" and reset the value of the counter back to 1. Hope that makes sense? Quote Link to comment Share on other sites More sharing options...
rwaller Posted May 25, 2013 Author Report Share Posted May 25, 2013 Thanks @cygnet and Ben for your replies. I will give it a try and let you know what I come up with. Will I need to add the " $line_item_counter" variable to the render_products function, if so, I would I reset it to one once I have three products in a row? @cygnet - a CSS change won't fix it. @Rwaller - You'd need to modify the render_products() function within /functions/templates.php to add support for individual rows within the product table. Within the foreach loop that loops through each product, you'd need to add a counter that tracked which column the product belonged in. So, for example, the first product would be product 1, the second would be 2, etc. If the counter is 1, you know to start a new row and insert a "<tr>" tag. If it is 3 (assuming you want three products per row), after the product has been added to the output variable, you'd need to insert a closing "</tr>" and reset the value of the counter back to 1. Hope that makes sense? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted May 25, 2013 Report Share Posted May 25, 2013 Will I need to add the " $line_item_counter" variable to the render_products function, if so, I would I reset it to one once I have three products in a row? Correct. You'd need to reset it back to one after it hits three and you add the closing </tr>. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.