Changing table from URL

5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 8, 2010   (RSS)

Here's my Header code:
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

require_once "\\\\frigga/home/users/web/b302/as.pequannock/admin/lib/viewer_functions.php";

list($district_sidebarRecords, $district_sidebarMetaData) = getRecords(array(
'tableName' => 'district_sidebar',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$district_sidebarRecord = @$district_sidebarRecords[0]; // get first record
?>

Here's the body code:
<h1><?php echo $district_sidebarRecord['title'] ?></h1>
<p><?php echo $district_sidebarRecord['content'] ?></p>

Here's my question:
I have 5 different sites using this page for different content.. but instead of creating 5 of these documents with different table names, I want to use the same document... can't I just put into the link in the URL what table I want it to use?

theres:
district_sidebar
pv_sidebar
pths_sidebar
hv_sidebar
sjg_sidebar

thanks
John Tedesco

Creative Director



JAM Graphics

Re: [jtedescojam] Changing table from URL

By Dave - February 8, 2010

Hi jtedescojam,

Yes, you could. Are these all single-record sections?

Let me know how you would like to have the urls look for each site and I'll see if I can write up some example code for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Changing table from URL

It's a multi section... Where there is a "list" field with a drop down to choose the category for each one... So each record us already set up with it's proper category location
John Tedesco

Creative Director



JAM Graphics

Re: [jtedescojam] Changing table from URL

By Dave - February 8, 2010

Ok, well there's a few ways you could do it already.

You could load a record by the category value (assuming your category field is called "category"):

yourviewer.php?category= hv_sidebar

Or you could load a record by the record number:

yourviewer.php?3

Would either of those work for you?
Dave Edis - Senior Developer
interactivetools.com