Header Text for List Page

8 posts by 3 authors in: Forums > CMS Builder
Last Post: March 17, 2010   (RSS)

By soulint - March 16, 2010

I have create a multi record editor but would like to have a field for generic text that gets displayed only on the list page not the record detail page. Is there anyway to do this?

Re: [soulint] Header Text for List Page

Hi Soulint,

My usual approach is to create one single record editor with fields for all kinds of "generic" information.

You can combine the contents of any number of section editors on one viewer.

Here's an example of how to do that from my CMSB Cookbook http://www.thecmsbcookbook.com

DISPLAY 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.


Hope that points you in the right direction.

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] Header Text for List Page

By soulint - March 16, 2010

Thanks for the quick response. One more question is there a way to control how many listings get displayed per row. Let say after 5 listing create a new table row, almost a grid style display?
Scott

Re: [soulint] Header Text for List Page

By soulint - March 16, 2010

Thanks again thats exactly what I was looking for!!!

Re: [gkornbluth] Header Text for List Page

By soulint - March 16, 2010

Is there any way to do this within the original editor instead of using 2 editors?

Re: [soulint] Header Text for List Page

By gkornbluth - March 16, 2010 - edited: March 16, 2010

I don't think there is because each record in a multi-record editor contains a unique set of data.

I use the common information to hold a whole host of things (metadata like keywords and descriptions, logos, special copyright notices, terms of service, etc.) so it works best for me.

Best,

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] Header Text for List Page

By Chris - March 17, 2010

Hi soulint,

Is there any way to do this within the original editor instead of using 2 editors?


Combining a Single Record section and a Multi Record section (which are related to managing content on the same page) is on my own personal feature request list. :)
All the best,
Chris