Forum for discussing general topics related to Couch.
6 posts Page 1 of 1
Hi there, my title is really poor - apologies. I'll describe what I'm trying to do as best as I can.

I have a client who periodically runs open days. I've created a page for their open days which isn't linked to anywhere in the site because 90% of the time it isn't relevant as there are no open days coming up.

However

I want to implement a feature that allows my client to log in to the admin panel and really easily "flick a switch" or check a checkbox or somthing similar.

Once this is done, some predefined html is printed on the homepage (which advertises the open day and links to the open day page).

Once the open day is over, the client can "flick the switch again and the html disappears. From my research, it seems like the "if" statement will be useful in allowing me to print the necessary html but I can't work out what mechanism to use for the "flicking the switch" part.

Thanks for your help!
Hi :)

You can use a type 'checkbox' editable region to create that 'switch to flick' and then depending on the state of the switch display the link to the open-days template.

The definition for the chechbox could be as follows
Code: Select all
<cms:editable 
    name='show_open_days'
    label='Show Open Days'
    opt_values='Yes=1'
    type='checkbox'
/>

You'll, however, have to decide as to which template you'll define the checkbox in.
It has to be done in a non-clonable template as it is a single value.

If either your home-page or the open-days template happens to be non-clonable, you can place the definition in it. Else, you'll have to use a separate template (e.g. named 'globals.php') for showing the checkbox.

Assuming the checkbox is in place and you can 'flip the switch' from the admin-panel, we can now use its value for the second requirement (i.e. show the link on the homepage).

Assuming the checkbox is defined in a template named 'globals.php', you can place the following code in the homepage -
Code: Select all
<cms:if "<cms:get_custom_field 'show_open_days' masterpage='globals.php' />" >
    ... display the open days link here ..
</cms:if>

Hope it helps.
Hi KK,

Thanks for your help!

Since I posted I actually experimented with the checkbox and managed to get it to work beautifully.

I have 1 issue, however.

For some reason, the result of the checkbox (in this case "opt_values='Enable=1 | Disable=0'")
is being printed on my page above all the content. When I enable or disable the checkbox in the admin panel the corresponding 1 or 0 is shown above everything on my page.

At no point in the page am I calling it or using <cms:show open_day />

Any idea why?

Edit** Just tried it on a fresh page and the same problem is occurring, with the 1 or 0 being displayed. ON the fresh page the only cms code is:

<cms:editable
name="open_day"
label="Open Day"
desc="Is Open Day Enabled or Disabled?"
opt_values='Enable=1 | Disable=0'
type='radio'
/>

**IGNORE**

I changed it from radio to checkbox and now all is working perfectly, thank you KK

:)
You are welcome :)
This is exactly what I was looking for. I'm using it to enable seasonal content for a hotel, eg Christmas, Mothers day menus etc.

However, the block I'm switching on or off, needs to be editable itself, it contains seasonal menus that change, but because it's within the cms if statement (I assume?) the cms: editable is being ignored - any way around this please?

Regards,

Nick
Actually forget that, I've just realised once the content is enabled and the page is reloaded, the option to edit the menu does appear in the admin menu - exactly what's needed!

I can't seem to prevent the '1' showing up for the selection though when using radio button?

Its OK I just put the checkbox in a div with a class of hidden ie, display:none and all is well!
6 posts Page 1 of 1