Multiple detail templates

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

By shawnpatoka - November 19, 2012

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

By Steve99 - November 19, 2012

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

By gkornbluth - November 19, 2012

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

By shawnpatoka - November 19, 2012

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

By Steve99 - November 19, 2012

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

By shawnpatoka - November 19, 2012

thank you! im trying it out right now

Re: [gkornbluth] Multiple detail templates

By shawnpatoka - November 20, 2012

kk, so i am screwing something up, lol.

If you go to www.seenstream.com/default2.php then type in a zip code, it brings you to list2.php with populated results.

There should be 3 listings with stars on them. One being a 'platinum' listing, one 'gold' and one 'silver'. And below the starred results, should be the generic listings, that should not be linked to anything.

My code currently...

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php require_once "cmsAdmin/lib/viewer_functions.php"; ?>
<?php if (!@$GLOBALS['GEOCODER_PLUGIN']) { die("You must activate the Geocoder plugin before you can access this page."); } ?>
<?php

$kmOrMiles = 'miles'; // can be 'miles' or 'km'

// set default values
if (!array_key_exists('fromAddress', $_REQUEST)) { $_REQUEST['fromAddress'] = '10001'; } // this is the default address/postalcode if none entered
if (!@$_REQUEST['maxDistance']) { $_REQUEST['maxDistance'] = '50000'; } // this will include all results

// get coordinates
list($myLat, $myLng) = geocodeAddress( @$_REQUEST['fromAddress'] );

// error checking
$errorsAndAlerts = '';
if (@$_REQUEST['search']) {
if (!@$_REQUEST['fromAddress']) { $errorsAndAlerts .= "No address entered!<br/>\n"; }
elseif (!$myLat || !$myLng) { $errorsAndAlerts .= "We couldn't determine your location, please try again!<br/>\n"; }
}

// get records
$addressRecords = array();
if ($myLat && $myLng) {
$maxDist = floatval(@$_REQUEST['maxDistance']);
list($trueAddressRecords, $trueAddressMetaData) = getRecords(array(
'tableName' => 'participating_bars',
'addSelectExpr' => geocoder_getSelectExprForDistance($myLat, $myLng, '_distance', $kmOrMiles), // adds '_distance' field to output records
'where' => geocoder_getWhereForDistanceWithin($myLat, $myLng, $maxDist, $kmOrMiles), // optimization: remove results outside of minimum bounding rectangle
'having' => "_distance <= " . $maxDist, // only show results within max distance
'orderBy' => 'ISNULL(_distance), _distance', // sort nearest records first -and- unknown or undefined distances last
'where' => "none = '0'",
));
}

// get records
$addressRecords = array();
if ($myLat && $myLng) {
$maxDist = floatval(@$_REQUEST['maxDistance']);
list($falseAddressRecords, $falseAddressMetaData) = getRecords(array(
'tableName' => 'participating_bars',
'addSelectExpr' => geocoder_getSelectExprForDistance($myLat, $myLng, '_distance', $kmOrMiles), // adds '_distance' field to output records
'where' => geocoder_getWhereForDistanceWithin($myLat, $myLng, $maxDist, $kmOrMiles), // optimization: remove results outside of minimum bounding rectangle
'having' => "_distance <= " . $maxDist, // only show results within max distance
'orderBy' => 'ISNULL(_distance), _distance', // sort nearest records first -and- unknown or undefined distances last
'where' => "none = '1'",
'perPage' => '5',
));
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SeenStream: Bar List</title>
<link href="ip_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var mapCanvasId = 'map_canvas';
var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP };
var map = new google.maps.Map(document.getElementById(mapCanvasId), mapOptions);
var bounds = new google.maps.LatLngBounds();
var infowindow = new google.maps.InfoWindow();
<?php
foreach ($trueAddressRecords as $record) {
if (!$record['latitude'] || !$record['longitude']) { continue; }
$jsFunctionArgs = "{$record['latitude']}, {$record['longitude']}, {$record['num']}, '" .escapeJs($record['_link']). "'";
print " _geocoder_addMarker($jsFunctionArgs);\n";
}

foreach ($falseAddressRecords as $record) {
if (!$record['latitude'] || !$record['longitude']) { continue; }
$jsFunctionArgs = "{$record['latitude']}, {$record['longitude']}, {$record['num']}, '" .escapeJs($record['_link']). "'";
print " _geocoder_addMarker($jsFunctionArgs);\n";
}
?>

//
function _geocoder_addMarker(latitude, longitude, recordNum, detailLink) {
var latLng = new google.maps.LatLng(latitude, longitude);
var infowindowEl = document.getElementById('marker_infowindow_' + recordNum);
var marker = new google.maps.Marker({ map: map, position: latLng });
google.maps.event.addListener(marker, 'click', function() {
if (infowindowEl) {
infowindow.setContent(infowindowEl.innerHTML);
infowindow.open(map, marker);
}
else {
window.location = detailLink;
}
});
bounds.extend(latLng);
}

//
map.fitBounds(bounds);
}

</script>
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-34997255-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
</head>

<body onload="initialize()">
<?php include('includes/navigation.php'); ?>
<div id="content-container">
<div class="h-adspace"><div class="ad"><a href="http://www.llsmiling.com/" target="_blank"><img class="border" src="i/lls_ad_728x90_10262012.jpg" border="0" /></a></div></div>


<div id="map-display"> <?php $hasAddresses = array_filter(array_pluck($trueAddressRecords, 'latitude')); ?>
<?php if ($hasAddresses): ?>
<div id="map_canvas" style="width: 960px; height: 225px; float: left; margin: 0px 0px;"></div>
<?php endif ?>

<?php if (!$hasAddresses): ?>
<div style="width: 299px; height: 299px; float: left; margin: 0px 15px; border: 1px solid #000;">
<div style="text-align: center; padding-top: 135px">
No map available!
</div>
</div>
<?php endif ?></div>

<div id="column-left">


<!-- 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'] ?>"/>
<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 endif ?>
<?php endforeach ?>
<?php endif ?>



<!-- Not participating -->
<?php if (@$_REQUEST['search'] && !$errorsAndAlerts): ?>
<?php foreach ($falseAddressRecords as $record): ?>
<!--<?php echo htmlspecialchars($record['title']); ?>,-->
<div class="listing-container"><img class="barlogo" src="i/barlogo_seenstream.jpg" /><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>
<?php endforeach ?>
<?php if (!$falseAddressRecords): ?>
No results found!
<?php endif ?>
<?php endif ?>




<?php if ($falseAddressMetaData['prevPage']): ?>
<a href="<?php echo $falseAddressMetaData['prevPageLink'] ?>"><div class="button">prev.</div></a>
<?php else: ?>
<div class="button">--</div>
<?php endif ?>

<div class="button">page <?php echo $falseAddressMetaData['page'] ?> of <?php echo $falseAddressMetaData['totalPages'] ?></div>

<?php if ($falseAddressMetaData['nextPage']): ?>
<a href="<?php echo $falseAddressMetaData['nextPageLink'] ?>"><div class="button">next</div></a>
<?php else: ?>
<div class="button">--</div>
<?php endif ?>

</div><!--column-left-->

<div id="column-right">
<div id="tellafriend"><h3>search</h3>
<form method="post" action="list.php">
<input type="hidden" name="search" value="1" />
<input class="tell" type="text" name="fromAddress" placeholder="Address, City, or Zip"/><input class="btn" name="Submit" type="button" label=" " value=" " />
<input type="hidden" value="Search" />
</form>
</div>
<a href="http://www.llsmiling.com/" target="_blank"><div class="adspace"></div></a>

</div><!--column-right-->

<br class="clear" />
</div><!-- content container-->

<?php include('includes/footer.php'); ?>

<div id="marker_details" style="display: none; ">
<?php foreach ($trueAddressRecords as $record): ?>

<?php // marker_infowindow_### is the content displayed in the info-window on click ?>
<div id="marker_infowindow_<?php echo $record['num']; ?>">
<p class="text" style="margin-top: -2px"><span style="color: #37c1f0; text-transform: uppercase"> <?php echo htmlspecialchars( @$record['title']); ?></span><br />
<?php echo htmlspecialchars( @$record['address']); ?><br /><?php echo htmlspecialchars( @$record['phone_number']); ?></p>
</div>

<?php endforeach ?>

<?php foreach ($falseAddressRecords as $record): ?>

<?php // marker_infowindow_### is the content displayed in the info-window on click ?>
<div id="marker_infowindow_<?php echo $record['num']; ?>">
<p class="text" style="margin-top: -2px"><span style="color: #37c1f0; text-transform: uppercase"> <?php echo htmlspecialchars( @$record['title']); ?></span><br />
<?php echo htmlspecialchars( @$record['address']); ?><br /><?php echo htmlspecialchars( @$record['phone_number']); ?></p>
</div>

<?php endforeach ?>
</div>
</body>
</html>

Re: [greg] Multiple detail templates

By shawnpatoka - November 20, 2012

excellent! thank you very much