I'm just learning EE and I have the following example url, http://mydomain.com/work/preview/clientname
where I want clientname to match a channel field I have setup ("client_name") and to pull in channel content only if it matches that channel field.
For example, http://mydomain.com/work/preview/google, would display channel content if the specified channel field "client_name" for a particular entry is "google".
I know how to use the following to pull in content from the channel "videos":
{exp:channel:entries channel="videos"}
{title}
{/exp:channel:entries}
...but how do I accomplish this for different url segments?
I believe what you're looking for is searching the channel entries tag by field name.
Here's an example:
{exp:channel:entries channel="videos" search:client_name="google"}
{title}
{/exp:channel:entries}
Do keep in mind though if you want to use the segment for this you'll likely have to pass the segment through an embed as a variable. You can read about this here.
Making this change works for me:
{exp:channel:entries channel="videos" dynamic="no" search:client_name="segment_2"}
{title}
{/exp:channel:entries}
Related
I'm trying to use the "URL title to Entry ID" plugin to feed the entry_id parameter into a Channel Entries tag, but can't figure out a way to get the ID information inserted early enough in the template parsing order.
This doesn't work - it picks up no entry ID, and so displays all entries:
{exp:channel:entries entry_id="{exp:url_title_to_entry_id parse="inward" url_title="{last_segment}"}" dynamic="no"}
{title}
{/exp:channel:entries}
Any suggestions would be much appreciated.
You can't have a function tag as a parameter to another function tag.
So either you have to pass the {exp:url_title_to_entry_id} result as an embed variable to another template that holds the channel:entries tag, or you have to use tag pairs so that one function tag, wraps the other and uses variables.
url_title_to_entry_id doesn't allow for tag pair, so either use the embed technique, or use another add-on.
BUT, you don't need the add-on at all...
{exp:channel:entries url_title="{last_segment}" dynamic="no"}
{title}
{/exp:channel:entries}
reference.
I'd also suggest added required_entry="yes" and limit="1" and then add {if no_results}...{/if} conditional inside. This will prevent it outputting all entries if it can't find a match.
I've got a website with two channels, news and products.
Products are displayed using an embedded channel entries tag pair called marketing. The news articles are displayed using a regular channel entries tag pair.
When the user clicks on a news article, the website navigates to a new page (news/view) containing the contents of just the news article in question. The template also includes the embedded template containing the products tag pair. This is where the problem occurs: the only published item that displays is the news article. None of the products display on the news article template.
The homepage and 'news/view' mock-up:
{exp:channel:entries channel="news"}
{title}
<some markup>
{body}
{/exp:channel:entries}
{embed="includes/marketing"}
The marketing embedded template looks something like:
<some dividing markup>
{exp:channel:entries channel="products"}
<list markup>
{product_image}
{product_description}
</list markup>
{/exp:channel:entries}
</some dividing markup>
Since the homepage and the 'news/view' template are essentially the same, I have no idea why the products are displaying on the homepage and not the 'news/view' page.
I'm not entirely sure but try adding dynamic="no" to your channel:entries loop. This seems to resolve 99% of my EE problems :)
{exp:channel:entries channel="products" dynamic="no"}
I have a series of entries that need to be displayed as part of a Category Archive.
I did the code this way:
{exp:channel:category_archive channel="botanical_gardens" style="linear"}
{categories}
<h3>{category_name}</h3>
{if category_description}
<p>{category_description}</p>
{/if}
{/categories}
{entry_titles}
{title}<br />
{/entry_titles}
{/exp:channel:category_archive}
This works with the exception of the URL which ties into the site url. Since each of these entries link to outside sites, how do I write the code to get the correct URL?
Thanks!
Custom fields can't be displayed within the Category Archive tag. Instead, you'll have to use the Channel Categories tag, and put a Channel Entries tag within it.
{exp:channel:categories channel="botanical_gardens" style="linear" disable="category_fields"}
<h3>{category_name}</h3>
{if category_description}
<p>{category_description}</p>
{/if}
{exp:channel:entries channel="botanical_gardens" category="{category_id}" disable="member_data|pagination|categories"}
{title}<br />
{/exp:channel:entries}
{/exp:channel:categories}
I'm trying to create a Safecracker form in ExpressionEngine to create a recipe. I have a recipe channel, which can have many ingredients from an ingredients channel (using the multi-relationship add-on from devot:ee). However, I'm having trouble listing the ingredients within my form. This is my mark-up:
{exp:safecracker channel='recipes' datepicker='no' id='add-recipe-form' include_jquery='no' return='recipes/view/ENTRY_ID' safecracker_head='no'}
{related_entries id='ingredients'}
{title}
{/related_entries}
{/exp:safecracker}
The problem is, the actual EE tags are just getting output on my web page.
I figure I'm doing something fundamentally wrong, so could someone point me in the right direction? Thanks.
This is called "variable collision" - you're nesting entries which use the same variable/tag names as those used by the parent tag (in this case, {title}), and due to how EE's parse order works, the parent tag is winning every time.
The solution is to put your above code into another template, and embed that template within your Safecracker form. Embeds are run at the very end of template processing, after all of the other EE tags are parsed, so you won't run into the same collision.
Derek is right, you need to embed your related entries. I've got this working on my Toronto EE meetup site with this code.
Simplified Template code:
{exp:safecracker channel="gta-attendee"}
<div class="form_row" style="display:none;">
<label class="small">Choose Meetup to Attend:<span class="required">*</span></label>
{embed="includes/_playa_select" selected="{attendee-event:child_ids}" }
</div>
{/exp:safecracker}
embedded code:
{exp:channel:entries dynamic="no" channel="gta-meetup" limit="1"}
<input value="{entry_id}" name="attendee-event[selections][]" type="hidden">
{/exp:channel:entries}
In the code I'm using the Playa Module, but the principle is the same.
Hope this helps
Sean
I have 2 channels. Channel 2 has a dropdown select box relating to channel 1. I want to display all info regarding both channels on a single page:
{exp:channel:entries channel="channel1|channel2" require_entry="yes" limit="1"}
{title}
Channel1 info: {tag_from_channel1}
...
{reverse_related_entries id="channel2"}
...
{/reverse_related_entries}
{/exp:channel:entries}
I'm getting ID from {tag_from_channel1} instead of value. How can I display value instead of ID?
Try removing the require_entry="yes" parameter, which aide in your troubleshooting:
{exp:channel:entries channel="channel1|channel2" limit="1"}
{title}
{reverse_related_entries}
{title}
{/reverse_related_entries}
{/exp:channel:entries}
You can further debug your issue by eliminating the URL causing a problem by hard-coding your Channel Entries query with dynamic="off" and specifying a single entry with entry_id="99":
{exp:channel:entries ... dynamic="off" entry_id="99"}
Also, the {reverse_related_entries} tag shouldn't have an id= parameter. From the ExpressionEngine Relationship Documentation:
Unlike the Related Entries tag, the Reverse Related Entries tag does
not contain an ID parameter as there is no need.
Did you perhaps intend to use {related entries} instead?