expression engine: Content in channel fields don't show up on the webpage when called in a template - expressionengine

I have a snippet called sidebar with the following code.
<div id="ebook_offer">
{exp:channel:entries channel="test"}
<h3>Ebook</h3>
{/exp:channel:entries}
</div>
<div id="about_blog">
{exp:channel:entries channel="blog_sidebar"}
<h3>About Obsia's Blog</h3>
{/exp:channel:entries}
</div>
<div id="testimonials">
</div>
<div id="demo" dynamic="no" limit="1">
</div>
<div id="recent posts">
{exp:channel:entries channel="blog" limit=5 offset=1}
<h3>Recent Posts</h3>
<li>{title}</li>
{/exp:channel:entries}
</div>
<div "connect">
</div>
<div = "subscribe">
{exp:mailinglist:form list="blog_list" form_id="blog_subscribe"}
<h3>Subscribe</h3>
<p>First Name <input type="text" name="first_name"="{first_name}"></p>
<p>Email <input type="text" name="email" value="{email}"></p>
<p><input type="submit" value="submit"></p>
{/exp:mailinglist:form}
</div>
This snippet is called inside the index.php template for blog template group and the code is as follows:
<div id="blog_display">
{exp:channel:entries channel="blog" limit="5"}
<h2>{title}</h2>
{author}
{if blog_images} <img src="{blog_images}" alt="blog image {title}" class="some_class" />
{/if}
{teaser}
<p>comments {comment_total} </p>
{/exp:channel:entries}
</div>
{sidebar}
I also have channel called sidebar with fields such as ebook_offer, about_blog, recast posts, testimonials, subscribe. I can get the subscribe forms to show up. I can see recent posts on my webpage but can't see any of the content that has been filled in about_blog field.
Anyone know why blog channel works but not my sidebar channel.

I'm not quite sure what the problem is exactly without having all of your code in front of me, but it could be a few things. For starters, if your blog homepage template has an {exp:channel:entries} tag in it, and you're including the snippet inside of that tag, you'd run into problems. You can't nest an {exp:channel:entries} inside of another.
Also, channel entry tags are set to dynamic by default. They will look at the URL for hints about what entries to pull from the database. Try adding the dynamic="no" parameter to your sidebar entries tag, which you can learn more about here. This should make the tag ignore the page's URL, which is what you want. You might also want to add the limit="1" parameter to that tag as well, to ensure that only one sidebar entry is being rendered.
Please let me know if neither of those answers help!

The best strategy would be to move what's in your snippet into a separate template file while you try to figure this out. I noticed a couple of things that seem off to me in your sidebar snippet code.
<div id="ebook_offer">
{exp:channel:entries channel="test"}
<h3>Ebook</h3>
{/exp:channel:entries}
</div>
<div id="about_blog">
{exp:channel:entries channel="blog_sidebar"}
<h3>About Obsia's Blog</h3>
{/exp:channel:entries}
</div>
This doesn't really seem the right way to use the {exp:channel:entries} tag. You mentioned "ebook_offer" was a channel field. But here you're using it as a static id for an HTML div. If "ebook_offer" is a field I would expect something like this:
<h3>Ebook</h3>
{exp:channel:entries channel="test"}
{ebook_offer}
{/exp:channel:entries}
Same with "about_blog"
<h3>About Obsia's Blog</h3>
{exp:channel:entries channel="blog_sidebar"}
{about_blog}
{/exp:channel:entries}
Also I noticed you said the channel was named "sidebar" but in your {exp:channel:entries} tag you're using "blog_sidebar". Which isn't the same thing, is your channel's shortcode "sidebar" or "blog_sidebar"?
Finally this is a little off to me
<div id="demo" dynamic="no" limit="1">
</div>
"dynamic" and "limit" only work on ExpressionEngine {exp:channel:entries} tags, not regular HTML elements (like DIVs). I would try using Bitmanic and Peter's suggestion again, but apply it to {exp:channel:entries} like so:
{exp:channel:entries channel="blog_sidebar" dynamic="off"}
...
{/exp:channel:entries}
If you're new to ExpressionEngine I highly recommend videos & tutorials by Ryan Ireland http://eeinsider.com/videos

Related

Liferay 7.3: How can I use custom ADTs in a page template?

I want to have ready components for a page, when a page template is used. E.g. when I create a page using subpage-1 template, it'd give a place to drop a banner image (or leave a template image) and add breadcrumbs automatically (no need to customise).
They both have custom ADT, which I can't seem to find from the Page Template options. (It seems to have it's own "site" in the admin bar, when editing the template, so my guess is it doesn't find anything from my main site.)
Is there a way to get the custom ADTs for the page template? For clearance, the route to the template is Site Builder --> Page Templates --> New Collection --> New page template.
Possible workaround?
This is my subpage-1-column.ftl code, which has two dropping places: One for the banner image and breadcrumbs (which I would like to have automatically placed) and the other for the other stuff. Is it possible to add all the things here, that I want my page template to do (content place, type, adt...)?
<div id="main-content" class="container-fluid subpage-1-column">
<div class="portlet-layout row no-gutters">
<div class="portlet-column portlet-column-only col-12" id="column-1">
${processor.processColumn("column-1", "portlet-column-content portlet-column-content-only")}
</div>
</div>
<div class="portlet-layout row no-gutters">
<div class="portlet-column portlet-column-only col-12" id="column-2">
${processor.processColumn("column-2", "portlet-column-content portlet-column-content-only")}
</div>
</div>
</div>
Promoting a comment to answer:
ADTs can live in global scope, there they're independent of a "current site".
Downside: Global means global and comes with the general downside of anything global. In this case, I believe that it's not much of a problem, but you'll have to validate that for yourself.
My recommendation is to look at Content Pages / Master Pages though, as they're a lot easier to edit than Freemarker Templates.
In your comment you say that Master Pages "destroy" your footer, header etc, which they're not supposed to do and I wonder about the root cause there. But anyway: You seem to have your ADT already, and global scope seems to fix your issue. I'll leave it at that. Going after the Master Page issue's root cause would be a different question (but might no longer be programming related)
If you're looking for a code template for the possible "workaround":
<div id="main-content" class="container-fluid subpage-1-column">
<div class="portlet-layout row no-gutters">
<div class="portlet-column portlet-column-only col-12" id="column-1">
${processor.processColumn("column-1", "portlet-column-content portlet-column-content-only")}
<#assign portletPreferences = { "displayStyle" : "ddmTemplate_ADT_CUSTOM", "portletSetupPortletDecoratorId": "borderless", "headerType" : "none", "delta" : "10", "paginationType" : "none" } />
${processor.processPortlet("com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet", portletPreferences)}
</div>
</div>
<div class="portlet-layout row no-gutters">
<div class="portlet-column portlet-column-only col-12" id="column-2">
${processor.processColumn("column-2", "portlet-column-content portlet-column-content-only")}
</div>
</div>
</div>
This will add an AssetPublisher to your first column with a specific ADT (ddmTemplateKey = ADT_CUSTOM)
To see all available portletPreferences check your database or copy the following code in one of your ADTs:
<#list portletPreferences?keys as prop >
<li>
${prop}
</li>
</#list>

MODX Revo album list pagination

I want to make pagination for my albums list using Gallery.
Trying to do it with getPage.
For photos inside album all works perfect:
[[!getPage?
&element=`Gallery`
&limit=`8`
&album=`portfolio`
&totalVar=`gallery.total`
&thumbWidth=`180`
&thumbHeight=`150`
&containerTpl=`NewGalleryAlbumTpl`
&thumbTpl=`NewGalItemThumb`
&cache=`0`
&cache_expires=`0`
&pageNavVar=`page.nav`
]]
<div class="system-nav-orange">
<span class="pages">Page [[+page]] from [[+pageCount]]</span>
<ul class="pager">
[[!+page.nav]]
</ul></div>
<div class="clear"></div>
but for albums pagination shows, but doesn't work:
[[!getPage?
&element=`galleryalbums`
&rowTpl=`rowTpl`
&pageNavVar=`page.nav`
&limit=`1`]]
<div class="system-nav-orange">
<span class="pages">Page [[+page]] from [[+pageCount]]</span>
<ul class="pager">
[[!+page.nav]]
</ul></div>
<div class="clear"></div>
What am I doing wrong?
Gallery does not support getPage out the box. You can edit the source code but not very future proof. There is also a possible work around which doesn't require code changes: https://forums.modx.com/thread/37769/revolution-gallery---how-to-add-pagination?page=2#dis-post-439685
However I would recommend looking at MoreGallery. It's a premium extra so not free but does support pagination and is far superior to Gallery imo.

Is there any way to control/route content by referrer value in Expression Engine?

Let’s say that I have a carousel on my index page.
Inside the template for index, it loads a particular channel, “Foo”
<div "slider">
<ul class="slides">
{exp:low_reorder:entries set="foo" dynamic="no"}
<li class="foo_{entry_id}">
<div class="container">
<div class="row-fluid">
<div class="span12">
{foo_html}
<style type="text/css">{foo_css}</style>
</div>
</div>
</div>
</li>
{/exp:low_reorder:entries}
</ul>
</div>
That channel, naturally, has a list of content items
I want the list of content items displayed to exclude one of the items in the channel if the referrer is not bing.
Can anyone show me the way that they would go about accomplishing that? I'm not getting any traction on the ellislab forum.
I whipped up a plugin for you, which you can find here
You can wrap the item in a conditional using that plugin to check if it should be output.

ExpressionEngine - related_categories_mode not working

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.

Nesting an ExpressionEngine Channel Entry Tag Pair within another Channel Entry Tag Pair?

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}.

Resources