Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Multiple Viewers On Same Page (need help)

 

 


rasbro
User

Mar 5, 2008, 4:10 PM

Post #1 of 5 (480 views)
Shortcut
Multiple Viewers On Same Page (need help) Can't Post

There have been a couple of posts related to this but I am not seeing any good examples, plus I have tried a few things on my own with some frustration.

I want to add a viewer for a leftnav section I created. This will allow me to edit the leftnav content from within CMS Builder instead of editing the template. In order for this work I will need to add this leftnav section viewer to my existing page templates. Some of my pages are product listings (List Viewer) and others are product pages (Page Viewer). Which viewer do I use for adding the leftnav viewer to my existing pages?

Here is what I tried so far:

--- Trial #1 (added to existing page using List Viewer) ---

Placed at beginning of document...

<?php
require_once "/path/.../lib/viewer_functions.php";
$options = array(); // NOTE: see online documentation for more details on these options
$options['tableName'] = 'insert_leftnav'; // (REQUIRED)
list($listRows, $listDetails) = getListRows($options);
?>

Placed in leftnav area of document...

<?php foreach ($listRows as $record): ?>
<?php echo $record['leftnav_content'] ?>
<?php endforeach ?>

This resulted in errors.


--- Trial #2 (added to existing page using List Viewer) ---

Placed at beginning of document...

<?php
require_once "/path/.../lib/viewer_functions.php";
$options = array(); // NOTE: see online documentation for more details on these options
$options['tableName'] = 'insert_leftnav'; // (REQUIRED) MySQL tablename to list record from. Example: "article";
$options['recordNum'] = ''; // (optional) Record number to display. Example: "1"; Defaults to number on end of url, then 1
$options['where'] = ''; // (ADVANCED) MySQL WHERE conditions to use INSTEAD of recordNum to look up record. Example: "fieldname = 'value'"
$record = getRecord($options);
?>

Placed in leftnav area of document...

<?php if ($record): ?>
<?php echo $record['leftnav_content'] ?>
<?php endif ?>

This displays the content and seems to work fine.

Incidently, when doing the same thing in Trial #1 and #2 with an existing page using a Page Viewer, I get errors with Trial #1 and for Trial #2 I see the leftnav content but get errors for all other content.

I hope I have given enough info to help you understand the issue when I try to use multiple viewers.

Thanks,
Brian


Dave
Staff / Moderator


Mar 5, 2008, 5:53 PM

Post #2 of 5 (478 views)
Shortcut
Re: [rasbro] Multiple Viewers On Same Page (need help) [In reply to] Can't Post

It depends what kind of content you have. If you have a single record you want to display (such as from a single-page section) then method #2 would we the way. If you had a list of pages or records you wanted displayed then you'd want to use method #1.

Assuming you're using method #2, one thing you can do to avoid collisions is to rename some of the variables. For example, instead of using $record, you could rename those to $left_nav or something else.

If you're still getting errors, see if you can post an url to a test page with the errors and attach the viewer to your post and I can have a look at it for you.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com


rasbro
User

Mar 5, 2008, 10:20 PM

Post #3 of 5 (476 views)
Shortcut
Re: [Dave] Multiple Viewers On Same Page (need help) [In reply to] Can't Post

Okay, so would I rename all references to $record parameter, like this:

In the viewer at the beginning of the document...

from, $record = getRecord($options);
to, $leftnav = getRecord($options);

And also in the body of the document...

from, <?php echo $record['leftnav_content'] ?>
to, <?php echo $leftnav['leftnav_content'] ?>

Is this true for the List Viewer parameters also?:

from, list($listRows, $listDetails) = getListRows($options);
to, list($anynameiwantRows, $anynameiwantDetails) = getListRows($options);

and...

from, <?php foreach ($listRows as $record): ?>
to, <?php foreach ($anynameiwantRows as $record): ?>

If this is the case then it certainly opens a lot of options for me. I had no idea these parameters such as $record or $listRows could be changed. Any other parameters or viewer attributes that can be changed like this? Sorry for all the questions - I'm getting excited at the possibilities!

Thanks,
Brian


Dave
Staff / Moderator


Mar 6, 2008, 9:50 AM

Post #4 of 5 (469 views)
Shortcut
Re: [rasbro] Multiple Viewers On Same Page (need help) [In reply to] Can't Post

Yes, that right. Those are just PHP variables so you can give them any name you want. Basically anything that starts with a dollar sign (like $this) you can try renaming.

Give a try and feel free to ask as many questions as you like. :)

Dave Edis - Senior Developer
interactivetools.com


rasbro
User

Mar 6, 2008, 3:52 PM

Post #5 of 5 (466 views)
Shortcut
Re: [Dave] Multiple Viewers On Same Page (need help) [In reply to] Can't Post

Okay Dave, that clarifies it a lot!

Thanks,
Brian

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4