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: [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

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

By Dave - June 18, 2008

Ahh, I used the wrong quotes. Try this instead:

'where' => "num = '{$record['advertNum']}'",

Double quotes "like $this" replace variables in them with their values, single quotes 'like this' don't.

If you're still having problems with the backend feel free to send me CMS login details to dave@interactivetools.com (email, don't post login details to forum) and I'd be happy to take a look for you.

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