0

I want to provide a way for content managers to easily select and unselect "Featured Content" (choosing from existing entries) on our EE site. This content would come from about four channels, all of which use the same field group.

The field group contains a "File" field which is used to add an image to the entry. Not all entries have an image, but only entries with images are eligible for "Featured Content."

Ideally, we'll also be able to set a minimum and maximum number of featured entries.

I thought about setting up a "Featured Content" channel, and adding a single "Featured Content" entry to it, using a multi-select Relationships field to add or remove featured entries. However, this does not limit entries to only those containing images, rendering the system cumbersome (as managers would have to check entries individually for images before featuring them) and prone to error (in case they don't do so carefully enough.) I'm willing to look into this further if anyone knows how to work around this limitation.

The second thought I had was to somehow use a Channel Form to do the job. The idea would be to use a Channel Entries tag to pull in recent entries that contain images, display enough information about them for managers to decide what to feature, and add a checkbox beside each one to feature or un-feature it. While this obviously addresses the "must contain image" requirement, I'm not sure how to handle almost anything else about the system. How would they actually be set as "Featured?" How could we enforce the minimum and maximum featured entries? Can a Channel Entries tag even be nested within a Channel Form? Etc.

We're also open to other possibilities not yet explored (including PHP in templates or even stepping outside of EE if necessary - although obviously not preferred.)

I'm working on this at the moment and will answer this question myself if I find a solution. Otherwise, I'd very much appreciate any other answers the community can provide!

2 Answers 2

2

Have a field (checkbox or anything) called 'featured', if you want an entry Featured check the box. the feature template would then look for any entry that had that field checked AND had an image (though presumably you'd have added an image if you wanted it featured).

Alternatively create an entry specific for home page content, with a field group for home page areas (specifically the feature area in this case), and make a relationships field (or fields) then when ever you want to update the feature you go to one entry (the home one) instead of each of the entries that you want featured. down side of this is you can't filter for entries with images. to get around this have a generic image that is used if no image is found.

1
  • Thanks for those thoughts. Building from your first idea, I was able to put together a very simple interface that meets our needs exactly!
    – Matthew
    Feb 3, 2016 at 20:19
1

Well, it took a bit of effort, but building from sheferd's comments, I was able to create a really nice little system. Here are the features:

  • Separate lists of entries available to feature, and currently-featured entries
  • Uses Channel Entries tag to build the list of featureable entries, meaning any criteria that can be used in the tag can be applied to what can be featured.
  • Includes a single button to feature or un-feature each entry.

It does NOT limit the number of featured entries.

The page loads kind of slowly, but it works and is very easy to use. Just set up a checkbox field for "Featured" and give it a value of "Yes." Here's some skeleton code, which will obviously need to be modified to match whatever fields it's supposed to work with:

<div class="col-md-6">
    <h2>Available to Feature:</h2>
    {exp:channel:entries channel="foo|bar" search:featured="not Yes" search:image_field="not IS_EMPTY" limit="10" cache="yes" refresh="1440" orderby="date" disable="categories|member_data"}
        {snp-pagination}
        <table cellpadding="0" cellspacing="0" border="0">
            <tr>
                <td valign="top">
                    <a href="{url_title}"><img src="{image_field}" width="120" /></a>
                    <div>
                        {exp:channel:form channel="{channel_short_name}" entry_id="{entry_id}" include_jquery="no" return="same/page"}
                            <input type="hidden" name="featured" value="Yes" /> 
                            <center><input type="submit" name="submit" value="Set Featured"></center>
                        {/exp:channel:form}
                    </div>
                </td>
                <td valign="top">
                    <h4>
                        <a href="{url_title}">{title}</a>
                        <span class="small">
                            By {author}
                        </span>
                    </h4>
                    {exp:ce_str:ing trim truncate='350|&hellip;' remove_tags_except='a'}{content}{/exp:ce_str:ing}
                    <br /><div class="label label-default">{channel}</div> <div class="label label-default">{entry_date format="%F %d, %Y"}</div>
                </td>
            </tr>
        </table>
    {/exp:channel:entries}
</div>

<div class="col-md-6">
    <h2>Current Features:</h2>
    {exp:channel:entries channel="foo|bar" search:featured="=Yes" limit="10" cache="yes" refresh="1440" orderby="date" disable="categories|member_data"}
    <table cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td valign="top">
                <a href="{url_title}"><img src="{image_field}" width="120" /></a>
                <div>
                    {exp:channel:form channel="{channel_short_name}" entry_id="{entry_id}" include_jquery="no" return="same/page"}
                        <input type="hidden" name="featured" value="" /> 
                        <center><input type="submit" name="submit" value="Un-Feature"></center>
                    {/exp:channel:form}
                </div>
            </td>
            <td valign="top">
                <h4>
                    <a href="{url_title}">{title}</a>
                    <span class="small">
                        By {author}
                    </span>
                </h4>
                {exp:ce_str:ing trim truncate='350|&hellip;' remove_tags_except='a'}{content}{/exp:ce_str:ing}
                <br /><div class="label label-default">{channel}</div> <div class="label label-default">{entry_date format="%F %d, %Y"}</div>
            </td>
        </tr>
    </table>
    {/exp:channel:entries}
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.