ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Easiest way to turn on/off code snippet?

September 23, 2011 9:26am

Subscribe [2]
  • #1 / Sep 23, 2011 9:26am

    Argyll

    67 posts

    I’ve got a block of code that I’d like to turn off or on (either have it rendered in a template, or stay hidden) via the CP. What is the easiest way to accomplish it without editing the template each time?

  • #2 / Sep 23, 2011 4:07pm

    John St-Amand

    865 posts

    If your snippet is an entries loop you could make it’s display dependent on a particular status.  Then it’s an easy on/off in the edit view without going into the template.

    Another way I’m starting to do that sort of thing is to have a “site settings” channel set up to store some fixed items for the site but still have them editable in the channel editing view - then it remains familiar to the client.  So I often store key things like their address, phone number, a starting year for their copyright notice, etc. - things that I know likely won’t change but they might still want to control.  You could easily have a set of yes/no fields used for turning certain things on or off.  Then have your snippet displayed only when the value for that custom field in the settings channel is “yes”, for example.  So use a channel’s custom field value determine whether the snippet gets used.  Then the on/off functionality you’re looking for stays out of the template realm.  Just an idea.  I’m sure there are others.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases