Drop-Down Menu Reset Woe!

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

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

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