Adding hide/display option for a list of services... displaying list 2 ways

9 posts by 4 authors in: Forums > CMS Builder
Last Post: August 19, 2009   (RSS)

By gagester - July 9, 2009

Hello,

We have a site that has 10-12 services. All of these will be listed on the "Services" page. We ALSO want some of these services to be listed (like banner buttons of sorts) in the left column of all pages (with the ability to edit and update this list). This list will only highlight a few of the services. I want the site editor to be able to simply check a "Display in Left Column" in the Admin area to pull in the title, and short intro, and a 'read more' button for each of the services checked.

Is this possible? If so, how?


I imagine i will need to be doing something similar to the direction given here: ?

http://www.interactivetools.com/iforum/CMS_Builder_F35/gforum.cgi?post=61341;search_string=hide%20or%20display%20options%20in%20list;t=search_engine#61341


Any help will be greatly appreciated!

thanks

Re: [gagester] Adding hide/display option for a list of services... displaying list 2 ways

By gkornbluth - July 9, 2009

If I'm understanding you correctly, you could probably put a "display_on_left" checkbox field in your multi record section editor. Since checkboxes have a value of "1" or "0", you could then use an "if" statement to display only those records where the "display_on_left" field = 1.

Something like this might work.

<?php foreach ($your_listingRecords as $record): ?>

<?PHP if ($record['display_on_left'] == "1"): ?>

<?php echo $record['your_first_field'] ?>

<?php echo $record['your_second_field'] ?>

<?php endif ?>

You can simultaneously display all the records in another place by leaving off the "if" statement.

If statements are a really powerful way of limiting the amount, type and format of information that's displayed in a viewer.

See what you can do with this idea.

Best,

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: [gagester] Adding hide/display option for a list of services... displaying list 2 ways

By ross - July 10, 2009

Hi there.

Thanks for posting

Jerry is definitely on the right track there :). You can also use a

'where' => 'display_on_left = 1'

option in your viewer code. That would mean you don't need the if blocks down in the page.

The best place to start with all this though is your template. Did you already have that setup? Can you show us some examples?

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] Adding hide/display option for a list of services... displaying list 2 ways

By gagester - July 16, 2009

Hello,

I really appreciate your help. i think i'm getting pretty close here... but still have a few issues/questions.

Question... i'm attempting the idea of the "'where' => 'button_on_left = 1' option. But can't seem to get it working...

In the code generator window I input that code into the "filter results" line. (right?)

I think my issue now is getting the record to actually 'pull in' to the pages...

I added the display info to the template, but the php info will need to be added individually to each page, right? (as each page has other php info that i'll just need to add:

list($servicesRecords, $servicesMetaData) = getRecords(array(
'tableName' => 'services',
'loadUploads' => '0',
'allowSearch' => '0',
'where' => '\'where\' => \'button_on_left = 1\' ',
));


near the other 'list' info, right?

(is it obvious enough that i don't understand php at all yet? ;)

anyway... Here's some links:

[the buttons are displaying 'kind of correctly' on this one (the styling is a work in progress), in that they're actually there. But it's pulling in all of them. I'm just showing you what it 'should' kind of look like.]
http://www.centrasodablasting.com/services.php

and on other pages... i get a warning.
http://www.centrasodablasting.com/index2.php

I'm sure it's simple... but may try Jerry's idea soon if i can't figure this out.

any thoughts? direction?

thanks!

Re: [ross] Adding hide/display option for a list of services... displaying list 2 ways

By gagester - July 17, 2009

http://www.centrasodablasting.com/index2.php

that appears to have worked! thanks.

how in the world do i get it to work on the services and services detail pages?

Re: [gagester] Adding hide/display option for a list of services... displaying list 2 ways

By ross - July 20, 2009

Hi there.

That's great!

Can we take a look at those other pages separately? Pick one and post a copy of it for me. Is the code pretty much identical to the page that is working (just points to a different table), or is the whole thing completely different?

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: Adding hide/display option for a list of services... displaying list 2 ways

By gagester - August 18, 2009

Hey, finally getting back to this project.

Attached are the two files it's not quite working properly on...

it's doing funky things that I can't quite figure out.. ;)

http://www.centrasodablasting.com/services.php

I appreciate how helpful and responsive you guys are. REALLY GREAT!

Re: [gagester] Adding hide/display option for a list of services... displaying list 2 ways

By Chris - August 19, 2009

Hi gagester,

I just responded to your other thread regarding the <div>s not properly wrapping your records on the left there, but there are a couple more problems with the two files you uploaded.

Basically the problem with your services.php page is that you're trying to display two "views" of your services section on the same page and both views use the same variable names:

list($servicesRecords, $servicesMetaData) = getRecords(array(
'tableName' => 'services',
'loadUploads' => '0',
'allowSearch' => '0',
'where' => 'button_on_left = 1',
));
list($servicesRecords, $servicesMetaData) = getRecords(array(
'tableName' => 'services',
'allowSearch' => '0',
));


The way things are currently, your second getRecords() call is overwriting the records from the first call. The solution is simple -- just rename one of the variables:

list($servicesFeaturedRecords, $servicesMetaData) = getRecords(array(
'tableName' => 'services',
'loadUploads' => '0',
'allowSearch' => '0',
'where' => 'button_on_left = 1',
));
list($servicesRecords, $servicesMetaData) = getRecords(array(
'tableName' => 'services',
'allowSearch' => '0',
));


You'll also need to change the foreach later in the page which is supposed to deal with the "button_on_left" records to refer to the new variable name:

<?php foreach ($servicesFeaturedRecords as $record): ?>

As for your services_Detail.php page, you are missing the button_on_left getRecords() call, which will again need to use a different variable name just like services.php.

Let us know how it goes. :)
All the best,
Chris