software does not match tutorials

3 posts by 3 authors in: Forums > CMS Builder
Last Post: December 6, 2010   (RSS)

Re: [sandisturm] software does not match tutorials

By Jason - December 6, 2010

Hi,

Yes, some of the tutorials use older versions of CMS Builder, but how the code generator works is still the same. The code generated is an entire .php page with HTML, but you don't need to copy and paste the whole thing. Basically, you just need the pieces that you find in between <?php ?> tags.

Here's an example for a list page created for a section called news. Here is the code you would need.

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


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('C:/wamp/www/sb/CMS Builder/','','../','../../','../../../');
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
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
));

?>


This is the code at the very top of the code. This needs to be pasted to the very top of your .php file. This code connects to CMS Builder and get's all of the records in the news section. These records are stored in a variable called $newsRecords. If you're comfortable with php, then this is all you need.

The example code that outputs these records is found a little further down where it says

<!-- STEP2: Display Records (Paste this where you want your records to be listed) -->

<?php foreach ($newsRecords as $record): ?>
Record Number: <?php echo $record['num'] ?><br/>
Title: <?php echo $record['title'] ?><br/>
Content: <?php echo $record['content'] ?><br/>
approved: <?php echo $record['approved'] ?><br/>
approve: <?php echo $record['approve'] ?><br/>
Multi_Category: <?php echo join(', ', getListLabels('news', 'multi_category', $record['multi_category'])); ?><br/>
_link : <a href="<?php echo $record['_link'] ?>"><?php echo $record['_link'] ?></a><br/>


<!-- STEP 2a: Display Uploads for field 'images' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->
<?php foreach ($record['images'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/>

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>
<!-- STEP2a: /Display Uploads -->


<hr/>
<?php endforeach ?>

<?php if (!$newsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->


By default, the code generator code outputs everything. You can paste this code anywhere into your current template and then remove any parts you don't want displayed.

Give this a try and let me know if you run into any problems.

Hope this helps.
---------------------------------------------------
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: [sandisturm] software does not match tutorials

Hi sandsturm,

welcome to CMS Builder.

You may find this Cookbook helpful.

http://www.thecmsbcookbook.com

In addition to many pretty advanced recipes, there's a step by step introduction into how CMS Builder works and how to create sections (tables) and viewers (web pages).


Hope that helps,

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