Jump to content

Php, Xml Products Post Horizontal On Website


rwaller

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

Link to comment
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?

Link to comment
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?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...