Viewer pages don't show as soon as I add another viewer code...

5 posts by 3 authors in: Forums > CMS Builder
Last Post: April 17, 2011   (RSS)

Re: [Izadorra] Viewer pages don't show as soon as I add another viewer code...

Hi Tzadorra,

You're probably better at coding then you think, you just need to get the hang of some basics, that's all.

First thing is, unless I don't understand what it is you're after, you shouldn't be calling the viewer_function and the records twice for the same featured_stories editor.

Try just using one of them, or event if you're actually trying to insert information from two different single record editors into the same web page, you still only have to load the viewer library once, so use something like:

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


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/nmcleanc/public_html/','','../','../../','../../../');
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 records for first editor
list($featured_storiesRecords, $featured_storiesMetaData) = getRecords(array(
'tableName' => 'featured_stories',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$featured_storiesRecord = @$featured_storiesRecords[0]; // get first record

// optionally load records for the second editor
list($fsecond_editorRecords, $second_editorMetaData) = getRecords(array(
'tableName' => 'second_editor',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$second_editorRecord = @$second_editorRecords[0]; // get first record
//end optional load records code for the second editor
?>


Then from the code generator, put the echo code for the required fields where ever you want a particular field to be displayed.

You really don't need the error code stuff if you're sure there are records saved for both viewers.

That should get you closer to where you need to go.

There's a really thorough tutorial on CMSB coding basics (including sample exercises)and a lot of other really helpful recipes in my CMSB Cookbook http://www.thecmsbcookbook.com

Hope that works for you,

Don't give up...

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] Viewer pages don't show as soon as I add another viewer code...

By Izadorra - April 15, 2011

Thank you! Works just the way I want it to.

Re: [Izadorra] Viewer pages don't show as soon as I add another viewer code...

By abincline - April 16, 2011

I also had trouble identifying which character is causing me the problem. I am not really good at programming but thanks to your post.

Re: [abincline] Viewer pages don't show as soon as I add another viewer code...

By Izadorra - April 17, 2011

I never got above a C in programming but I'm a great "copy & paster". I remember struggling with "hello world".

But my java professor gave me the best advice ever, he said "if it is a code that is needed then someone else has already written it." Go forth and find it. Hence, the beginning of my "copy & paste" career.

I went ahead and invested in the CMS Builders Cookbook that was mentioned by the very nice person that helped me. I had to justify it to my husband by telling him it was like trying to work on a car without the owners manual. I haven't received it yet but I'm hoping it will save me some time.