SAMPLE RECIPES
FROM THE COOKBOOK


WHAT’S THE BEST WAY TO BEGIN USING CMSB?

The easiest way to begin using CMS Builder is to design your page using standard HTML and CSS first. Then list the areas that you’d like to allow CMSB to control, and those areas that you want hard coded into your design.

Once that’s done, you should look for similarities in the design. (A list of identical entries that all have a title, a description and an image associated with them, etc.)

HINT: If you know that you are going to show many items with a similar structure, you should enter at least enough of them to show the basic layout of your page, like the table structure, etc.

Once that’s done, you can start to think about the format that you can use to store and retrieve that information. Here are 2 examples that will illustrate the process. We’ll be designing an “About Us” page using a single record section editor and then create an “Events” page using a multi record section editor.

We suggest that you create your own pages for this exercise from scratch, using your favorite text or html editor.

IF YOU DOWNLOAD OUR SAMPLE PAGES,
you’ll be able to troubleshoot the process by comparing our results to yours.

DESIGNING YOUR FIRST CMSB PAGES

AN “ABOUT US” PAGE
This “About Us” page get it’s content through a single record section editor interface.

Our “About Us” page contains the company name, an address, a phone number, and a few paragraphs describing the company.

CREATING THE “ABOUT US” HTML PAGE
The first step is to design the “About Us” page using HTML and to make sure that it looks the way you want it to.

Then you’d make a list of all the areas (fields) that you want the user to be able modify. In our example we’ll want the user to be able to modify the company’s name, their current address, phone number, and a company description.

CREATING THE SINGLE RECORD SECTION EDITOR
Since this page will contain only one set of information, it uses a single record section editor.

Log on to your CMS Builder interface as administrator and click on the "Admin" tab on the menu. Then click on the "Section Editors" tab and again on the “Add New Editor” button. From there, click on the “Single Record” radio button. Then enter “About Us” in the “Menu Name” field and click on ”Create New Menu”.

On the next screen, which is a list of existing section editors, click on “modify” next to the “About Us” entry. That will bring you to a screen that will allow you to add new information fields to the section editor’s field menu.

We’ll keep things pretty simple to begin with, so for the menu of fields on your section editor, in addition to the “Title” and “Content” fields that are automatically created, you’ll be creating a text field called “Street Address”, a text field called “City” a text field called “State” a text field called “Zipcode”, a text field called “Phone” and a text box called “Description”.

You’ll add these fields by clicking on the “Add Field” button at the bottom of the field list.

For the first field, type “Street Address” in the “Field Label” box.

You’ll notice that your entry is reflected in the Field Name” box, but there are only lower case letters and numbers, and that any spaces or special characters are replaced by underscores. After you’ve created a field, you can modify your “Field Label” to say anything that you want to, but the “Field Name”, which is the actual name of your field in your MySQL database, is restricted to those types of characters.

From the “Field Type” pull down select “text field”.

Click on the Show All link next to “Input Validation” and check the box that says “Required” so that the user can not leave this field blank.

You’ll be creating a number of text fields, so instead of clicking on “Save”, click on “Save & Copy”. You’ll notice that the Field Label now says “Copy of Street Address” and all the other parameters (like the “Required” checkbox) are the same as they...


ELIMINATE BLANK LINES OR HEADINGS WHEN THERE’S NO INFORMATION IN A FIELD
One of the easiest ways is to start by surrounding fields with the PHP “if” tag.

<?PHP if ($yourRecord['title']): ?>
Title: <?PHP echo $yourRecord['title'] ?><br>
<?PHP endif; ?>

Here’s an example that was used in an event listing multi record editor to eliminate the word “through” if there was no “end date” for the event and to eliminate the heading, "Reception” if that field was blank:

<?PHP foreach ($exhibitionsRecords as $record): ?>
<tr valign="top" align="center">
<td >
<span class="heading-text-bold"><?PHP echo $record['title'] ?></span><br />
<span class="body-text"> <?PHP echo $record['start_date'] ?>&nbsp;</span>
<span class="body-text">
<?PHP if ($record['end_date']): ?>Through&nbsp;<?PHP echo $record['end_date'] ?></span><br/>
<?PHP endif; ?>
<?PHP if ($record['reception_date_and_time']): ?>
<span class="heading-text-bold">Reception</span><br /><span class="body-text"> <?PHP echo $record['reception_date_and_time'] ?> </span>
<?PHP endif; ?>
</td>
</tr>
<tr>
<td align="left" height="125" valign="top"><div class="body-text"><?PHP echo $record['content'] ?></div></td>
</tr> <tr>
<td align="center">
<!-- display image --> <?PHP foreach ($record['image'] as $upload): ?>
<?PHP if ($upload['hasThumbnail']): ?>
<img src="<?PHP echo $upload['thumbUrlPath'] ?>" width="<?PHP echo $upload['thumbWidth'] ?>" height="<?PHP echo $upload['thumbHeight'] ?>" alt="" />
<?PHP elseif ($upload['isImage']): ?>
<img src="<?PHP echo $upload['urlPath'] ?>" width="<?PHP echo $upload['width'] ?>" height="<?PHP echo $upload['height'] ?>" alt="" />
<?PHP else: ?>
<a class="special" href="<?PHP echo $upload['urlPath'] ?>">DOWNLOAD<?PHP echo $upload['filename'] ?></a>
<?PHP endif ?>
<div class="body-text-bold">
<?PHP echo $upload['info1']; ?><br />
<?PHP echo $upload['info2']; ?> </div></td>
<?PHP endforeach ?>


ITEMS FROM A SINGLE RECORD EDITOR NOT SHOWING ON MULTI RECORD DETAIL PAGES


I had an image that came from a single record that I wanted to appear on my details pages from a multi record viewer. It showed up on the first record in the list but gave me an error saying that the argument supplied for foreach() was invalid for other records.


The solution?

Try removing this line from the single page call in the details page header :

'where' => whereRecordNumberInUrl(1),

It works like a charm.


ALTERNATING THE BACKGROUND COLOR OF TABLE ROWS
A CMSB user wanted to know how to automatically alternate between 2 background colors in a table.

Dave Edis, from Interactive Tools, had an effective approach, he said:

Here's some code to do that:

<?php $bgColor = (@$bgColor == '#F8F8F8') ? '#EFEFEF' : '#F8F8F8'; ?>

Then you can display it like this: <?php echo $bgColor ?>

and the result was:

<table>
<tr>
<th>title</th>
<th>name</th>
<th>phone</th>
</tr>
<?php foreach ($contact_listRecords as $record): ?>
<?php $bgColor = (@$bgColor == '#F8F8F8') ? '#EFEFEF' : '#F8F8F8'; ?>
<tr bgcolor="<?php echo $bgColor ?>">
<td><?php echo $record['title'] ?></td>
<td><?php echo $record['name'] ?></td>
<td><?php echo $record['phone'] ?></td>
</tr>
<?php endforeach; ?>

</table>

 

   


The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service