Post by hbuchel » Thu Feb 17, 2011 11:10 pm

I am just wondering, there are many parts of the template where a list of products is used. This includes the home modules, category page, search results, etc. Is there any downside to moving the loop of code that calls and lists the products to its own .php page, and just using an include on any template file that needs a product list?

I'm mostly asking because the same exact loop is used for all of those pages, however if you want to fix the presentation of how the list looks, you would have to edit EVERY one of those pages. Simply editing one page, for example product_list.php, would be a lot easier.

I'm not asking how to do it, as I've already done it to test it out and make sure it works. I'm more so asking if there is any reason not to, and if anyone more skilled in PHP could weigh in with their own opinion.

New member

Posts

Joined
Mon Aug 30, 2010 9:41 pm

Post by Qphoria » Thu Feb 17, 2011 11:45 pm

What you are describing is right.. we copy/paste too much of the same code over and over when we should use more common files across them all. I am looking into how we can make more things generic

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by hbuchel » Fri Feb 18, 2011 12:30 am

Excellent! But for now though, if I dump all of my product list code into product_list.php and just do a

Code: Select all

<?php include('product_list.php'); ?>
I should be good to go? I'm not sure if theres a wrong way to do it; but thought I'd get some advice first :S

New member

Posts

Joined
Mon Aug 30, 2010 9:41 pm

Post by Qphoria » Fri Feb 18, 2011 12:50 am

yea that could work.. try it and see

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 30 guests