Listings Manager with CMS - How to pull specific tables from database onto one page

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

By meg - April 27, 2010

I'm creating a listings manager for a website that also will be featuring "Last Minute Availability" and "Specials" pages.

There's a series of pages currently, such as entertainment, dining, hotel, etc that has listings that contain "specials" and "last minute availability" within each listing. What I need to do is make a page that contains all of the "specials" and another of all of the "last minute availability" from the other listings pages. How do I do that?

Re: [meg] Listings Manager with CMS - How to pull specific tables from database onto one page

By Donna - April 27, 2010

Hi Meg!

Is this for CMS Builder with the Listings Template, or our discontinued product "Listings Manager"?
Donna

--
support@interactivetools.com

Re: [meg] Listings Manager with CMS - How to pull specific tables from database onto one page

By ross - April 28, 2010

Hi there.

Thanks for clearing that up!

With the page that lists pieces of information from several sections, you'll definitely need to start by putting the viewer code for each section up at the top of the page.

Next, the easiest way would be to just start listing the content on your page where it should show up. It will basically just be a series of foreach loops.

It will make what looks like a single list but it's actually a bunch of different ones all strung together.

Does that make sense? The best place to start on this one is going to be with adding all your viewers to the top of the page. Once you get that done, feel free to post a copy of it (as an attachment) and I'll take a look :).

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Listings Manager with CMS - How to pull specific tables from database onto one page

By meg - April 28, 2010

Thanks for the tips...Here's what I have so far for the header...

Now for the listing part...I think... I'll have all the entry fields use
<?php echo $record['table-name'] ?> (for example)
but how do I call on all of the pages at the top? Do I use something like this before the entry?

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

And do I make a string of them for each database table that I want referenced?

I'm still a little confused...I attached two files...one is the last minute availability and the other is an example of one of the listings pages (apartments).

Thanks so much!

Re: [meg] Listings Manager with CMS - How to pull specific tables from database onto one page

By Jason - April 29, 2010

Hi,

For each of your tables that your accessing for "last minute availability", is there a field that would be set to indicate that it's a last minute availability (a checkbox maybe).

Let me know and we'll see what we can do.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Listings Manager with CMS - How to pull specific tables from database onto one page

By meg - April 29, 2010

In the backend, I have a WYSIWYG for inserting Last Minute Availability and Specials. Should I include a checkbox? I attached a screen grab of the CMS listings form for those sections.
Attachments:

lma.tiff 58K

Re: [meg] Listings Manager with CMS - How to pull specific tables from database onto one page

By gkornbluth - April 29, 2010 - edited: April 29, 2010

Hi Meg,

Here's an excerpt from my CMSB Cookbook http://www.thecmsbcookbook.com/ that might help a little:

DISPLAYING INFORMATION FROM MORE THAN ONE SECTION IN A SINGLE VIEWER

Setting up a page to display information from multiple sections is pretty easy once you get the hang of it. But it can be somewhat confusing at first.

Here’s the approach for displaying information on a home page from information that’‘s in a single record editor called “homepage” and other information from a multi record editor called “listings”.

First you’ll need to set up the top of your page with getRecords calls to the two sections. (You can copy the actual code from the code generated in the admin area of the CMSB interface)

<?php

require_once "/your path/cmsAdmin/lib/viewer_functions.php";

list($homepageRecords, $homepageMetaData) = getRecords(array(
'tableName' => 'homepage',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$homepageRecord = @$homepageRecords[0]; // get first record


list($yourlistingsRecords, $yourlistingsMetaData) = getRecords(array(
'tableName' => 'yourlistings',

));

?>


Then in the body where you want to display the home page information

<?php echo $homepageRecord['your_first_field'] ?><br/>
<?php echo $homepageRecord['your_secondt_field'] ?><br/>
<?php echo $homepageRecord['your_third_field'] ?>


and in the body where you want to display the listings records:

<?php foreach ($yourlistingsRecords as $record): ?>
<?php echo $record['your_first_field'] ?><br />
<?php echo $record['your_second_field'] ?><br />
<?php echo $record['your_third_field'] ?>
<?php endforeach; ?>


There’s no formatting in the above example, but it should get you started.

This concept can be expanded to display information pulled from any number of sections.

If you find you’re getting errors when you try to display items from a single record editor on multi record detail pages, you may need to remove the:

'where' => whereRecordNumberInUrl(1),

from the get records call so that you can display them.

There are situations where you may have to remove the:

'limit' => '1',

as well.

If you're going to pull from 2 multi-record editors, you would adjust the get records code accordingly list($yourlistingsRecords, $yourlistingsMetaData) = getRecords(array(
'tableName' => 'yourlistings',

list($your_other_listingsRecords, $your_other_listingsMetaData) = getRecords(array(
'tableName' => 'your_other_listings',

and use separate foreach loops.<?php foreach ($yourlistingsRecords as $record): ?>
<?php echo $record['your_first_field'] ?><br />
<?php echo $record['your_second_field'] ?><br />
<?php echo $record['your_third_field'] ?>
<?php endforeach; ?>

<?php foreach ($your_other_listingsRecords as $record): ?>
<?php echo $record['your_first_field'] ?><br />
<?php echo $record['your_second_field'] ?><br />
<?php echo $record['your_third_field'] ?>
<?php endforeach; ?>


Hope that clarifies things a bit.

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