5

I have a quotes channel, and right now I want to use a specific quote on a specific page of my webiste, so i'm using the code below with a conditional based on the url title. Let's say down the road someone decides they want to change that quote and so they delete entry_id 21, and create a new entry. Am I correct in assuming that a new entry would be given a new entry_id and would no longer display on that particular page? If that assumption is correct, should I stay away from the type of code below? maybe use url_title instead?

{exp:channel:entries channel="quotes" limit="1" disable="categories|member_data|pagination" entry_id="21"}
{/exp:channel:entries}
5

I would do this using a 'featured quote' relationship field (either native or Playa depending on whether you want the client to be able to select more than one quote per entry).

  • Agreed, with the assumption that the "page" hyphen81 mentions is an EE entry itself in a channel to which a relationship field may be pointed from the quotes channel. A relationship field added to the quotes field group, which would allow you to identify its "parent" would be a very flexible way to handle it. And as James mentioned, Playa would give you the ability to create many to many relationships, assigning a quote to multiple entries, if applicable (and therein multiple quotes for a single entry). – Jean St-Amand Jan 7 '13 at 12:59
5

Using a specific entry_id begs for a problem later - I wouldn't. What you can do is create a custom status for that channel and then let the entries tag target that status specifically. Limiting the results to 1 also will help focus on the individual entry; if you add a new entry with the same status, it will take only that last, most-recent version, no matter what the id.

4

Entry ID's are not re-used, so you are right - if someone deletes that entry and publishes another the code will fail.

URL_titles are re-created, so if the original entry is deleted and a new one is published with exactly the same title (and hence, url_title), the code will still work. So url_title is safer, but still not awesome.

A custom status would work as Holland suggests - I've found that I dislike using custom statuses because once you go outside of the standard ones you have to remember to explicitly specify them everywhere as the channel:entries tag assumes the "Open" status only.

I would consider the relationship-based approach mentioned earlier as well.

Here's a additional thought - if you create a Select Dropdown field you are given the option to populate the field from the contents of another Channel/field in the installation. You could use this feature to grab the quotes from your quotes channel and drop them into the channel with your main pages content. Just keep in mind with this approach your Quotes would not be "dry" - they would end up being stored in 2 different channels. An interesting idea (and using a feature of EE that I've yet to), but probably not ideal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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