How to generate code for single record section?

5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 13, 2012   (RSS)

By Ridder7NO - October 12, 2012

Hi.

I'm having problems finding the way to generate the code necessarry for a single record section.

If I'm not wrong, this was earlier to find in earlier versions of CMS Builder. I'm currently using version 2.17, and I have problems finding it?

Thanks in advance :)

- Ridder7NO

Re: [Ridder7NO] How to generate code for single record section?

By gregThomas - October 12, 2012

Hi Ridder7NO,

Are you trying to create getRecords code for a single record? If you are then you can do this:

If you go to the code Generator in the cmsAdmin area then select Code Generator under the admin area. You should see a link called Detail Page for getting a single record from the database, click on this.

On the Code Generator Details page select your single record from the Select Section drop down. Under the which record area select Single record sections: Load first record in database

This should give you a getRecord function that looks something like this:

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('C:/wamp/www/','','../','../../','../../../');
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 'tableNametableName'
list($tableNameRecords, $tableNameMetaData) = getRecords(array(
'tableName' => 'tableName',
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$tableNameRecord = @$tableNameRecords[0]; // get first record
if (!$tableNameRecord) { dieWith404("Record not found!"); } // show error message if no record found


Thanks
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] How to generate code for single record section?

By Ridder7NO - October 12, 2012 - edited: October 12, 2012

Thank you so much for trying to help, greg, but what I meant was:

On my websites frontpage, I have things that repeat (multi), such as a News list etc. That's working perfectly.

But...

Also, I have content that I would like to be shown on each page, but it should not repeat (like news lists etc), like a general footer text, that should be the same on every page, but that I could change in CMS.

I'm talking about a single editor for a single place on the page, without needing ID in the URL.

The detail code wouldn't let me do that, as it required a specific ID in the URL to let the data to be shown.

Hope you understand.

Thank you in advance.

- Ridder7NO

Re: [greg] How to generate code for single record section?

By Ridder7NO - October 13, 2012

Thank you so much! :D

This is great! Thanks for helping me :)