USING THE MULTI-SELECT DROP DOWN LIST TO CREATE LINKS TO LISTINGS RELATED TO A MAIN CATEGORY - Dec 29th, 2018
|
Creating links from checked entries in a multi value list field
In a section called “salon_test”, I created a multi value list field (salons_presented_in), which gets it’s option values from the record number (num) field in the table I want to access (salon_eblasts), and it’s option labels from the title field in that table.
I’ve created a detail page for the “salon_test” section that gets its record number from the end of the URL.
On that detail page, I needed to create separate links to another detail page for each entry that’s checked in the multi value list field (salons_presented_in).
Building on some related products posts in the forum, I came up with this:
At the top of the viewer
// load viewer library $libraryPath = 'cmsAdmin/lib/viewer_functions.php'; $dirsToCheck = array('/path_to_your_server/','','../','../../','../../../'); foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }} if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
// load record from 'salon_test' list($salon_testRecords, $salon_testMetaData) = getRecords(array( 'tableName' => 'salon_test', 'where' => whereRecordNumberInUrl(0), 'loadUploads' => true, 'allowSearch' => false, 'limit' => '1', )); $salon_testRecord = @$salon_testRecords[0]; // get first record ?>
And in the body where I wanted to show the links:
<?php $relatedSalons = join(',', explode("\t", trim($salon_testRecord['salons_presented_in'], "\t"))); $valueFieldName = "num";
if (!$relatedSalons) { $relatedSalons = 0; }
// load records from 'salon_e_blasts' list($salon_e_blastsRecords, $salon_e_blastsMetaData) = getRecords(array( 'tableName' => 'salon_e_blasts', 'loadUploads' => true, 'allowSearch' => false, 'where' => "`$valueFieldName` IN ($relatedSalons)", )); ?> <?php foreach ($salon_e_blastsRecords as $record): ?> <a href="your_second_detail_page.php?<?php echo $record['num']?>"><?php echo $record['presentation_title'] ?></a> <?php endforeach; ?>
There’s also a long thread here, with lots of juicy information:
http://www.interactivetools.com/forum/gforum.cgi?post=63505
|
The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact
Interactive Tools for information on the downloading of the software or the purchasing of licenses.