Multiple detail templates

10 posts by 4 authors in: Forums > CMS Builder
Last Post: November 20, 2012   (RSS)

So, I have my website, SeenStream.com.

Right now, if you type in a zipcode, it populates records into list.php.

In each record in CmsBuilder, I have a checkbox that specifies if that record is a participating bar or not. And if it is, it displays that record at the top of the list, and makes it link to its detail page.

example detail.php?Speakeasy-Ultra-Lounge-3

my question... how do i make it so I can have like 3 different detail pages? so some records link to detail-1.php some link to detail-2.php and some link to detail-3.php

thanks!

Re: [shawnpatoka] Multiple detail templates

Hi Shawn,

I would add a list field in your editor and have three options to choose from. Use that var for the page link in your foreach loop.

One|detail1.php
Two|detail2.php
Three|detail2.php

Does this sound like what you are looking for?

Hope this helps.

Steve

Re: [shawnpatoka] Multiple detail templates

Hi shawnpatoka,

If I'm understanding you correctly, instead of using: <a href="<?php echo $record['_link'] ?>">Link Text </a>
in your links, you can use:
<a href="http://www.your_domain.com/your_detail_page.php?num=<?php echo $record['num'] ?>">Link Text </a>

Depending on your requirements you may need to include if statements to determine which of your detail pages should be accessed.

So if you had a list field in your record that had a number of choices which determined which detail page should be shown, you could use something like:
<a href="http://www.your_domain.com/
<?php if($record['your_field'] == "choice_one") : ?>
your_detail_page_1.php?num=<?php echo $record['num'] ?>
<?php elseif ($record['your_field'] == "choice_two"): ?>
your_detail_page_2.php?num=<?php echo $record['num'] ?>
<?php elseif ($record['your_field'] == "choice_three") : ?>
your_detail_page_3.php?num=<?php echo $record['num'] ?>"/>Link Text </a>.
<?php endif ?>

Hope that helps,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Multiple detail templates

right now, i have some checkboxes in CmsBuilder for each record. they are Platinum, Gold, and Silver. Is that what you mean by a list field?

Re: [shawnpatoka] Multiple detail templates

By gkornbluth - November 19, 2012 - edited: November 19, 2012

Yes, That's what I meant.

Give it a try and post whether it works and the code you used if it doesn't.

For check boxes I think you'll need to change the code to if($record['platinum'] ==1) and elseif($record['gold'] ==1), etc.

Good luck,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [shawnpatoka] Multiple detail templates

Didn't realize you had check boxes with the three levels set up already. Since you have that set up you don't need to do what I said. Follow Jerry's updated instructions updated by his 2nd post for using your check boxes and you'll be good.

Re: [steve99] Multiple detail templates

thank you! im trying it out right now

Re: [shawnpatoka] Multiple detail templates

Hi Shawn,

I think I can see the problem, I've modifed that participation foreach statement:

<!-- Participating -->
<?php if (@$_REQUEST['search'] && !$errorsAndAlerts): ?>
<?php foreach ($trueAddressRecords as $record): ?>
<a href="http://www.seenstream.com/<?php if($record['platinum'] ==1): ?>
detail_1.php?num=<?php echo $record['num'] ?>
<?php elseif ($record['gold'] ==1): ?>
detail_2.php?num=<?php echo $record['num'] ?>
<?php elseif ($record['silver'] ==1): ?>
detail_3.php?num=<?php echo $record['num'] ?>
<?php endif ?>" />
<div class="listing-container"><?php foreach ($record['logo'] as $index => $upload): ?><img class="barlogo" src="<?php echo $upload['urlPath'] ?>" /><?php endforeach; ?>
<div class="listing-container-heading"><h2><?php echo $record['title']; ?></h2></div>
<p><?php echo $record['address']; ?><br /><?php echo $record['phone_number']; ?><br />(<?php echo floor($record['_distance'] * 10) / 10; ?> <?php echo $kmOrMiles ?> away)</p>
<div class="star"></div></div>
</a>
<?php endforeach ?>
<?php endif ?>


I think the problem is that the listing-containter divs are only being shown if the record is silver as the endif statement was in the wrong place. I've moved it up so that it's in the same format as the platinum and silver, and added a closing quotation mark and link tag to the end. Let me know if that helps at all.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Multiple detail templates

excellent! thank you very much