Jump to content
Killersites Community
Sign in to follow this  
rwaller

Php, Xml Products Post Horizontal On Website

Recommended Posts

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

Share this post


Link to post
Share on other sites

@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?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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>.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×