Help creating intitial section structure

9 posts by 2 authors in: Forums > CMS Builder
Last Post: August 15, 2008   (RSS)

By Capt'n Morgan - August 15, 2008

I'm building my first site using CMSB for almost the entire site.
This site is setup with 4 top level pages, and each of those pages has several pages beneath it.

I was planning to create sections for each of those top level pages, and then put their sub pages as items within the respective section.
However if I do that, then the styling of each of the sub pages has to be identical. That's not a big deal, exceptfor a masthead photo that is unique to each page. I don't need that photo to be editable or changeable, I really just need it to be a fixed design element. Any thoughts on how to accomplish this?

If I don't go that route, I'll just need to add each page in as a separate section. It seems though that the menu bar in the CDSB admin will get rather cluttered with 20 or sections. Is there any other way to group these?

Re: [Capt'n Morgan] Help creating intitial section structure

By Capt'n Morgan - August 15, 2008

Iv'e been working on this for a bit, and I think I found a good way to do it, by including the mastehead image as a uploadable field (only I set it to only be editable by admin). What I would like to figure out now, is how can I modify the viewer code for this section so that if a image isn't uploaded, it will display a default image in that area instead?

Re: [Capt'n Morgan] Help creating intitial section structure

By Dave - August 15, 2008

Hi Capt'n,

Your upload field will be named something like this: $record['uploads']. If it's named differently use the name from you code and try this:

<?php if (!$record['uploads']): ?>
No masthead! <img src="..." />
<?php endif ?>

The ! means no or not, so basically that means "if no uploads - show this".

Let me know if that does the trick for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Capt'n Morgan] Help creating intitial section structure

By Capt'n Morgan - August 15, 2008 - edited: August 15, 2008

Thanks, Dave.

This is my source for that. I can't quite figure out where to put your code, can you help?

I'm sure I can take out the thumbnail and download code too, but I haven't got that far.

<!-- STEP3: Display Uploads from 'masthead_image' (Paste this where you want your uploads displayed) -->
<!-- Upload Program Fields : num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath -->
<!-- Upload Image Fields : isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight -->
<!-- Upload Info Fields : info1, info2, info3, info4, info5 -->
<?php if ($about_usRecord): ?>
<?php foreach (getUploads($about_usOptions['tableName'], 'masthead_image', $about_usRecord['num']) as $upload): ?>

<?php if ($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 ?>
<?php endif ?>
<!-- STEP3: /Display Uploads from 'masthead_image' -->

Re: [Capt'n Morgan] Help creating intitial section structure

By Dave - August 15, 2008

Hi Capt'n,

Put it just below the endforeach like this:

<?php endforeach ?>
... insert code here...
<?php endif ?>

Let me know if you have any troubles with that.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Help creating intitial section structure

By Capt'n Morgan - August 15, 2008

I must be close, but something's not right. Maybe my record or variable name?



<!-- Upload Program Fields : num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath -->
<!-- Upload Image Fields : isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight -->
<!-- Upload Info Fields : info1, info2, info3, info4, info5 -->
<?php if ($about_usRecord): ?>
<?php foreach (getUploads($about_usOptions['tableName'], 'masthead_image', $about_usRecord['num']) as $upload): ?>

<?php if ($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 ?>

<?php if (!$about_usRecord['masthead_image']): ?>
No masthead! <img src="images/header.jpg" />
<?php endif ?>


<?php endif ?>


Re: [Capt'n Morgan] Help creating intitial section structure

By Dave - August 15, 2008

Oh, sorry I didn't realize you were using an older version.

We updated the code generator a few months ago to automatically load uploads. Try this (changes in red):

<?php if ($about_usRecord): ?>
<?php $uploads = getUploads($about_usOptions['tableName'], 'masthead_image', $about_usRecord['num']); ?>
<?php foreach ($uploads as $upload): ?>

...

<?php if (!$uploads): ?>
No masthead! <img src="images/header.jpg" />
<?php endif ?>

If that doesn't work feel free to send me an email with FTP and CMS login details to dave@interactivetools.com (email, don't post login details to forum) and I can take a look. I'll be able to debug it quicker for you that way.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Help creating intitial section structure

By Capt'n Morgan - August 15, 2008

Yeah, I have .14. I might just upgrade before I get too deep into this...

Re: [Capt'n Morgan] Help creating intitial section structure

By Dave - August 15, 2008

Well maybe give it a try, and or upgrade if you have a lot more to do. The new code generator is nicer and gives you more options.

Your old code will continue to work after you upgrade as well, but the new code you generate might look a little different.

Let me know if you need anything else.
Dave Edis - Senior Developer
interactivetools.com