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.

Changing field types based on radio selection

December 09, 2011 7:36am

Subscribe [2]
  • #1 / Dec 09, 2011 7:36am

    Hi all, I’m not sure if such a thing is possible but if you don’t ask…
    I have a site where the home page has a featured area, within this there is a 9 column grid that I am going to give the client the freedom to use in a 6+3 or a 3+3+3 setup.
    For the 6+3 setup they have the choice to display 1 or 2 projects so they can have a big and small image for one project or a big image for one project and a small for the other. The 3+3+3 can only be used for 3 separate projects.

    What I’m wondering is when it comes to them entering the content for this is there a plugin/ add-on that allows an entry type selector at the top that will alter the field set below so that if they select say ‘6+3 for one project’ only the applicable fields will be displayed. I’d rather this whole featured area was handled from within a single entry to avoid the wrong combination being used.

    Would it be possible to achieve this using Matrix by Pixel & Tonic or is there an easier way.

    Thanks for any light anyone can shed on this.

    Patrick

  • #2 / Dec 09, 2011 3:54pm

    Rob Allen

    3118 posts

    Matrix might make life easier for images and data.

    This could be done by adding a field so the author can switch between displays. I normally create a custom Select field and populate it with some variables, in your case yours might be 6+3 and 3+3+3.

    The trick here if you’re using Matrix is to only use the first X number of Matrix rows for content output - this way if there are 9 images you have the ability to switch between both layout types as required.

    Then the basic code to apply the right display might go something like:

    {if your_custom_field == "6+3"}
    Matrix field to output 6 + 3 content
    {/if}
    
    {if your_custom_field == "3+3+3"}
    Matrix field to output 3 + 3 + 3 content
    {/if}

     

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

ExpressionEngine News!

#eecms, #events, #releases