re-directing a page with one item

3 posts by 2 authors in: Forums > CMS Builder
Last Post: May 7, 2009   (RSS)

By Carrie - April 26, 2009

Hi there,

We would like some help with the follownig please:

On this page: http://www.geniuscom.com.au/products-list.php in the content area are a list of sub-categories. These click through to a seondary list of products, and then to a detail page.

What we would like to be able to do is for any secondary lists that only have one item, to re-direct the user straight to the detail page to eliminate the extra click. For example, when you click on "Telelphone Systems", it goes to a list of three products. When you click on Hospitality Solutions, it only has one product. We would like this to go straight to this page: http://www.geniuscom.com.au/products-detail.php?Hospitality-Solutions-9

Can you help? Please consider that I am not a programmer, so you will need to be very specific!

Thanks,
Carrie
Carrie
WebGenesis
www.webgenesis.com.au

Re: [Carrie] re-directing a page with one item

By ross - May 7, 2009

Hi Carrie

I have an idea for you. It doesn't actually involve redirecting though. Basically, when you are on a list page, you can display any field you like so you can actually turn your list page into a full detail page if you like. The main difference is that it will display a full detail page for every single record it returns so you could end up with a single page that shows all the details about 10 different records.

With me so far?

My idea is to figure out how many records are going to be appearing on your list page. If it's just a single record, then you would display it as a full detail page. If there are more than one records, you display it as a list page.

The code to get that going will look something like this:

<?php foreach ($productsRecords as $record): ?>
<?php if (count($productsRecords) > 1): ?>
CODE FOR REGULAR LIST PAGE GOES HERE
<?php else: ?>
CODE FOR FULL DETAIL PAGE GOES HERE
<?php endif; ?>
<?php endforeach; ?>


You'll see where you need to put your detail page code and your list page code from there.

Does that make sense? To make it easier, I recommend starting by having just one field display. Summary in the first part and Content in the second.

Give it a shot and let me know how you make out :).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/