Is it possible (or what is the best method) to use a channel field name that is coming from the outside of a related_entries tag? Like so:
{exp:channel:entries channel="test"}
{channel_field_name} <!-- Works here! -->
{related_entries id="test2"}
{channel_field_name} <!-- This won't work! -->
{/related_entries}
{/exp:channel:entries}
Looks like this topic covered it on the ExpressionEngine Stack Exchange earlier:
https://expressionengine.stackexchange.com/questions/496/is-it-possible-to-access-channel-variables-inside-of-a-reverse-related-entries-t#answer-512
Related
I am currently working on generating a master page for a sharepoint instance. It is however giving some issues when attempting to convert over an ASP repeater
The following works in generating a repeated text:
<!--MS:<asp:Repeater ID="TopMenu" runat="server" DataSourceID="selectedSiteMap">-->
<!--MS:<HeaderTemplate> -->
<!--ME:</HeaderTemplate> -->
<!--MS:<ItemTemplate> -->
<li>test</li>
<!--ME:</ItemTemplate> -->
<!--MS:<FooterTemplate> -->
<!--ME:</FooterTemplate> -->
<!--ME:</asp:Repeater> -->
<!--MS:<asp:SiteMapDataSource SiteMapProvider="CurrentNavigation" ShowStartingNode="false"
StartFromCurrentNode="false" StartingNodeOffset="0" StartingNodeUrl="sid:1002"
EnableViewState="true" ID="selectedSiteMap" runat="server" /> -->
However the following does not work:
<!--MS:<asp:Repeater ID="TopMenu" runat="server" DataSourceID="selectedSiteMap">-->
<!--MS:<HeaderTemplate> -->
<ul id="main_menu_ul" class="">
<!--ME:</HeaderTemplate> -->
<!--MS:<ItemTemplate> -->
<li><a href=<!--MS:"<%# Eval("Url")%>"--> class="link">
<!--MS:<%# Eval("Title")%>--></a></li>
<!--ME:</ItemTemplate> -->
<!--MS:<FooterTemplate> -->
</ul>
<!--ME:</FooterTemplate> -->
<!--ME:</asp:Repeater> -->
<!--MS:<asp:SiteMapDataSource SiteMapProvider="CurrentNavigation" ShowStartingNode="false"
StartFromCurrentNode="false" StartingNodeOffset="0" StartingNodeUrl="sid:1002"
EnableViewState="true" ID="selectedSiteMap" runat="server" /> -->
So far I have identified the issue is 2 fold:
1. the converter is does not like the fact that the opening ul and closing ul dont exactly match
2. the converter does not like the eval tags at all.
Any help anyone could give to getting this repeater to work properly would be very helpful. Thank you
The other possibility is that you are manually uploading your master page (as opposed to deploying it using a feature). The <%# Eval("Url")%> tag is seen as server-side code, and it turns out that there is a security limitation that server-side code is not allowed in customized pages - in other words, ones that are unghosted.
So if you customize a master page using SharePoint designer, the new copy exists in the content database, and this is regarded as customized.
I hit this recently - deployed an aspx master page (with a repeater control in it) using a feature, download a copy, re-upload it (with no changes) and bang - error. Code blocks not allowed in this file.
As you're putting this in an html master page, you're probably just masking the real reason for the error. You could try adding an entry to the web.config (see, for example, this blog) to specify that your master page can have code blocks.
It might because You have opened
MS: before you Eval("") but there is no closing ME: after eval tag.
Have a fairly basic template that outputs the main article and then should output three others from the same channel, however when using the following code nothing is output in the "Other partners" area, not even "No posts" so I'm really not sure what's going wrong. There's 5+ articles in the system so there's definitely results to pull out, any ideas?
{exp:channel:entries channel="partner" limit="1" url_title="{segment_3}"}
<article>
<h1>{title}</h1>
{profile_logo:banner wrap="image"}
{profile_body}
</article>
{/exp:channel:entries}
<h2>Other Partners</h2>
{exp:channel:entries channel="partner" related_categories_mode="yes" custom_fields="yes"}
{if no_results}
No posts
{/if}
<article>
<a href="{url_title_path='community/partners'}">
{profile_logo:thumbnail wrap="image"}
<h3>{title}</h3>
<p>{profile_body}</p>
</a>
</article>
{/if}
{/exp:channel:entries}
Looks like you have a random {/if}, not sure if that's causing the issues with the results. You could always pass the current category to a embed and run it like so:
{exp:channel:entries channel="partner" limit="1" url_title="{segment_3}"}
<article>
<h1>{title}</h1>
{profile_logo:banner wrap="image"}
{profile_body}
</article>
{embed="template_group/_related_partners" category="{categories backspace="1"}{category_id}|{/categories}"}
{/exp:channel:entries}
Embed template:
{exp:channel:entries channel="partner" category="{embed:category}" dynamic="no" url_title="not {segment_3}"}
{if no_results}
No posts
{/if}
<article>
<a href="{url_title_path='community/partners'}">
{profile_logo:thumbnail wrap="image"}
<h3>{title}</h3>
<p>{profile_body}</p>
</a>
</article>
{/exp:channel:entries}
Probably all you need to do here is add dynamic="no" parameter to your second channel entries loop where you are using related_categories_mode. You need to do this because you are on a single entry page and EE will try to use the url_title present in segment_3 to load channel data for that entry specifically.
So you should try:
<h2>Other Partners</h2>
{exp:channel:entries channel="partner" related_categories_mode="yes" custom_fields="yes" dynamic="no"}
[...]
{/exp:channel:entries}
Official documentation for the dynamic= parameter is here.
Also be sure the entry you are loading in the browser is categorized in such a way that there are indeed other entries in that channel that are similarly categorized. Without some other entries that share the same category(ies) no entries will be loaded by the channel loop where you are using related_categories_mode.
Also, as #Seibird mentioned, it does look like you have an extra closing if tag after the closing article tag in your code example. That is likely to be interfering.
I have an xPage with this content:
<div class="lotusFrame">
<xc:layoutCommonBanner />
<xp:callback facetName="facetTitleBar" id="callbackTitleBar" />
<xc:layoutDiscrepancyPlaceBar />
<div class="lotusMain">
<div class="lotusColLeft">
<xp:callback facetName="facetColLeft" id="callbackColLeft" />
</div>
<div class="lotusColRight">
<xp:callback facetName="facetColRight" id="callbackColRight" />
</div>
<div class="lotusContent">
<xp:callback facetName="facetContent" id="callbackContent" />
</div>
</div>
<xc:layoutCommonFooter />
<xc:layoutCommonLegal />
</div>
As you can see, there are several custom controls in it composing layout. In the facetContent, there is a document with document datasource. It's the only document in the page. I need to get this document somehow in the layoutDiscrepancyPlaceBar custom control.
I found some old articles on the web with undocumented feature called currentDocument. It should be on every page with document datasource. But it doesn's work. I have Domino 8.5.2 and currentDocument seems to be no longer supported.
Can you help me out? How can I get document datasource from one custom control in another custom control. Is it even possible?
Thanks in advance, Jiří
EDIT: OK, it is still supported, but it only works in custom control, that is included inside the one with document datasource. In the case scenario above it doesn't work.
Your best option is to hand over the binding name in a custom property. (lets call it bindto. Then you bind your field to
"${#{"+compositeData.bindto+"}}"
See details here (inside the prezi)
P.S. currentDocument is documented somewhere.
You can also pass a handle on the data source directly to the custom control, as well as the name of the item to bind to on the data source. Because EL supports array syntax as well as dot syntax, this allows you to define expressions like this:
#{compositeData.dsn[compositeData.fieldName]}
(where "dsn" is the property being passed the handle on the data source, and "fieldName" is the property being passed the name of the item to bind to on that data source.)
More details on this approach can be found here.
I'm building a website that makes heavy use of image carousels. Each section has a different carousel with different slides.
Therefore, I've created an embed called global_embeds/image_carousel.html that contains the logic. It looks like this:
<div class="carousel">
{exp:channel:entries channel="homepage_carousel"}
<div class="slide">
<img src="{image}" alt="{title}" />
</div>
{/exp:channel:entries}
</div>
As you can see, it's a simple HTML snippet that generates a <div> for each item. The problem, however, is that I want to use an embed parameter in the exp:channel:entries tag.
I tried calling the embed in my parent template like so:
{embed="global_embeds/image_carousel" carousel_channel="homepage_carousel"}
And changing my embed template to this:
...
{exp:channel:entries channel=embed:carousel_channel}
...
But it doesn't seem to be passing the variable value through as I'd like, instead just showing all entries in my carousel regardless of channel.
Am I going about this the right way? Or is there a better way to achieve what I'm after in Expression Engine?
D'oh! Practically immediately after posting the question, I realised I can use the curly brace notation wrapped in quote marks:
...
{exp:channel:entries channel="{embed:carousel_channel}"}
...
Sorry to waste people's time.
I did some searching around but I can't seem to find any information on embedding a channel entry tag pair within another.
When I try the following code in a template, it breaks the page and I see the opening {reverse_related_entries sort="desc"} displayed as plain text:
{exp:channel:entries channel="pages"}
{reverse_related_entries sort="desc"}
{if show_testimonial}
{exp:channel:entries channel="testimonials" orderby="random" limit="1"}
<blockquote>
{testimony}
<cite>
<span class="cite_name">{cite_name}</span><br />
<span class="cite_org">{cite_org}</span><br />
<span class="cite_title">{cite_title}</span>
</cite>
</blockquote>
{/exp:channel:entries}
{/if}
{/reverse_related_entries}
{/exp:channel:entries}
Is there a way in ExpressionEngine to nest a channel entry tag pair inside itself?
In order to nest a {exp:channel:entries} tag pair inside of itself, you'll need to embed the template within another template using an {embed} variable.
To do so, just modify your main channel entries tag to look like the following:
{exp:channel:entries channel="pages"}
{reverse_related_entries sort="desc"}
{if show_testimonial}
{embed="template_group/template"}
{/if}
{/reverse_related_entries}
{/exp:channel:entries}
Then, create a new template with the contents of your nested channel entries tag pair:
{exp:channel:entries channel="testimonials" orderby="random" limit="1"}
<blockquote>
{testimony}
<cite>
<span class="cite_name">{cite_name}</span><br />
<span class="cite_org">{cite_org}</span><br />
<span class="cite_title">{cite_title}</span>
</cite>
</blockquote>
{/exp:channel:entries}
Which you can include in any ExpressionEngine template using the following syntax, as shown earlier:
{embed="template_group/template"}
Using embed templates are a standard way around some of ExpressionEngine's quirks and Parse Order (PDF, 32 KB), but they do carry a performance penalty with them so be mindful in deciding between using an {embed} and a {snippet}.