Using url variable to pull in correct page

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

By zaba - February 13, 2009

Okay, difficult to explain but, I have one php page (called functions) that pulls in a record based on a where clause, the where clause needs to select the record based on the menu item that is clicked. The trigger for this is a menu built from "navigation_title" a field in each record which uses the $record['_link'] to load the same page with the relevant record number at the end .
how do i define the where clause for this to happen?
for example:

require_once "/home/xxxxx/public_html/cms/lib/viewer_functions.php";


list($lk_funceventsRecords, $lk_funceventsMetaData) = getRecords(array(
'tableName' => 'lk_funcevents',
'allowSearch' => '0',
'where' => 'category="function" AND num="THIS NEEDS TO BE THE record number sent from end of the url in the sub menu"',
));

list($lk_funcmenuRecords, $lk_funceventsMetaData) = getRecords(array(
'tableName' => 'lk_funcevents',
'loadUploads' => '0',
'allowSearch' => '0',
));

?>
<html>
<head></head>
<body>
<!-- This is the submenu built from all records using the field navigation_title -->
<?php foreach ($lk_funcmenuRecords as $record): ?>
<li><a href="<?php echo $record['_link'] ?>"><?php echo $record['navigation_title'] ?></a></li>
<?php endforeach; ?>

<!-- when one of these is clicked I need to load the same page and bring in the contents of the record based on the record number which is sent with the url (and added to the where clause) -->

<!-- rest of page -->
<div id="page">
<div class="pagerule">
</div> <!--x pagerule -->
<?php foreach ($lk_funceventsRecords as $record): ?>
<h1><?php echo $record['page_title'] ?></h1>
<h2><?php echo $record['main_head_one'] ?></h2>
<?php foreach ($record['upload_one'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>"><img src="/lakeside/gfx/viewmenu2.gif" alt="<?php echo $upload['filename'] ?>" width="106" height="12" class="viewmenuimg" /></a>

<?php endif ?><?php endforeach ?>
<?php echo $record['main_text_one'] ?>
<?php if ($record['main_head_one']): ?>
<div class="clearthefloats">
</div><!--x clearthefloats -->
<div class="pagerule">
</div><!--x pagerule -->

<?php endif ?>


<h2><?php echo $record['sub_head_two'] ?></h2>
<?php foreach ($record['upload_two'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>"><img src="/lakeside/gfx/viewmenu2.gif" alt="<?php echo $upload['filename'] ?>" width="106" height="12" class="viewmenuimg" /></a>

<?php endif ?><?php endforeach ?>
<?php echo $record['sub_text_two'] ?>
<?php if ($record['sub_head_two']): ?>
<div class="clearthefloats">
</div><!--x clearthefloats -->
<div class="pagerule">
</div><!--x pagerule -->

<?php endif ?>
<?php endforeach ?>

Re: [zaba] Using url variable to pull in correct page

By zaba - February 13, 2009

Okay,
I have used my brain and figured out that I am homer, basically this is all i needed to do. doh.
Just in case barny or moe are having the same problem here it is.


list($lk_funceventsRecords, $lk_funceventsMetaData) = getRecords(array(
'tableName' => 'lk_funcevents',
'allowSearch' => '0',
'where' => whereRecordNumberInUrl(1),
));
list($lk_funcmenuRecords, $lk_funceventsMetaData) = getRecords(array(
'tableName' => 'lk_funcevents',
'loadUploads' => '0',
'allowSearch' => '0',
));