Drop-Down Menu Reset Woe!

6 posts by 2 authors in: Forums > CMS Builder
Last Post: June 18, 2008   (RSS)

By Perchpole - June 16, 2008

Hi, Dave -

I've been "having a play" with some of the options in the Section Editor toolkit...

I've set-up a special category called "Adverts" where my client can input some text (and perhaps a picture) via the WYSIWYG box. I've also set-up a separate "Main" category which holds all of the main pages of the site. These pages have been set-up in such a way as to allow the user to select one of the adverts to appear on the page (in a margin). I've done this by setting-up a list field which then draws the (Advert) info straight from the MySql table.

It's a fairly simple technique but is more than fit for purpose. However, there is a snag...

I'd like the user to be able to select an advert by means of a drop-down menu - which works very well. The trouble is, if a user selects an Ad and then (at some point in the future) decides to edit that Ad, the drop-down menu will reset! The user will be forced to go through all of the Main pages re-selecting the appropriate Adverts again.

As you can imagine, this completely torpedos my well-laid plan! IS there any way I can prevent the reset?

:o/

Perch

Re: [Perchpole] Drop-Down Menu Reset Woe!

By Dave - June 16, 2008

Hi Perch,

What "adverts" fields are you using for the pulldown value and label? If you use the advert record "num" as a value you can be sure that won't change. So updates to the advertisement won't reset the pulldown.

If you store the advertisement based on number you may need to add some extra code to load it. Something like this:

list($advertRecords, $advertMetaData) = getRecords(array(
'tableName' => 'adverts',
'where' => 'num = "{$record['advertNum']}"',
'limit' => '1',
));
$myAdvert = @$advertRecords[0]; // get first record


Let me know if that works for you (and makes sense). The first step is storing the advert by record number.

The next step is get that advert record number showing on your webpage.

The last step is adding some viewer code to load an advert by number.

Hope that helps. Let me know if you need more details about any of that.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Drop-Down Menu Reset Woe!

By Perchpole - June 16, 2008

Hi, Dave -

Thanks for such a prompt reply. The fields I'm using for the list are the record title for the label (for recognition purposes) and the record content for the value. These are the only editable fields in the "Adverts" category.

There is a simple php include in the template: <?php echo $mainRecord['advert'] ?> where I want the content to appear.

Then, when I edit a page in the "Main" category, all I need do is select the title of the advert I want to display from the drop-down list and the content duly appears on the page.

As I say, it appears to work well - it just gets a bit screwy when you edit an advert. When you go back to a "Main" page the drop-down menu has reset and shows the default <select> option.

The same problem occurs when you use radio buttons. (All of the available options become unselected)

It's a shame because this would be a good way to allow people to add interesting blocks of information to the margins of their layouts - which adds a bit more interest to a design.

:0(

Perch

NB: I've just reworked the List Option set-up to use the record num as the label and it makes no difference.

Re: [Perchpole] Drop-Down Menu Reset Woe!

By Dave - June 16, 2008

Try using the record num as the value, and the title for the label, then using some viewer code to load the whole advert record that matches the num.

It's just one more step, and should work exactly how you need.

Let me know how that goes.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Drop-Down Menu Reset Woe!

By Perchpole - June 18, 2008

Hi, Dave -

Thanks for the the tips and the code. However I'm not sure how the latter would help as the problem I'm experiencing occurs in the back-end - not the rendered pages.

I've just tried using the code and there appears to be an error in the line hi-lighted below:

list($advertRecords, $advertMetaData) = getRecords(array(
'tableName' => 'adverts',
'where' => 'num = "{$record['advertNum']}"',[/#ff0000]
'limit' => '1',
));
$myAdvert = @$advertRecords[0]; // get first record




Which generates the following error message...

Parse error: syntax error, unexpected T_STRING, expecting ')' in /homepages/...


Any clues?

:o(

Perch