Page Elements section
2 posts by 2 authors in: Forums > CMS Builder
Last Post: April 9, 2010 (RSS)
By Thomas - April 9, 2010
Hi,
I am trying to set up a 'Page Elements' section that will include things like header, footer, menus, etc. so I have set up a single record editor with a field for each item.
I would now like to include these in my other pages that have the content so at the top of the page I have included (in addition to the page content code):
Then calling the element with :
This is all working great, but only on the first page.
As soon as I go to the next page I get 'Record not found!' I guess because there is no page 2 of the page elements.
Is there a way I can call the same page elements on all pages?
I am trying to set up a 'Page Elements' section that will include things like header, footer, menus, etc. so I have set up a single record editor with a field for each item.
I would now like to include these in my other pages that have the content so at the top of the page I have included (in addition to the page content code):
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
require_once "/lib/viewer_functions.php";
list($page_elementsRecords, $page_elementsMetaData) = getRecords(array(
'tableName' => 'page_elements',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$page_elementsRecord = @$page_elementsRecords[0]; // get first record
// show error message if no matching record is found
if (!$page_elementsRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}
?>
Then calling the element with :
<?php echo $page_elementsRecord['header'] ?><br/>
This is all working great, but only on the first page.
As soon as I go to the next page I get 'Record not found!' I guess because there is no page 2 of the page elements.
Is there a way I can call the same page elements on all pages?
Re: [Thomas] Page Elements section
By Jason - April 9, 2010
try removing this line:
'where' => whereRecordNumberInUrl(1),
and replace it with:
'allowSearch' => false,
Because there is only record and we always want to be able to access that record, we don't want anything that limits the records being returned.
Give that a try and let me know if it works.
'where' => whereRecordNumberInUrl(1),
and replace it with:
'allowSearch' => false,
Because there is only record and we always want to be able to access that record, we don't want anything that limits the records being returned.
Give that a try and let me know if it works.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/