ExpressionEngine - related_categories_mode not working - expressionengine

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.

Related

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.

How to link to an entry in a channel in expressionengine?

I have the following code
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
{exp:channel:entries channel="static" sort="asc" dynamic="off"}
<li>{title}</li>
{/exp:channel:entries}
</ul>
</div><!--/.nav-collapse -->
Which is looping through a channel I have for static pages on my website. Technically it is showing all the stuff it should do. This is the code it outputs:
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>Small Builders</li>
</ul>
</div>
However, when I click the link it gives me a white page. I have the htaccess from the documentation set up. I'm new to ExpressionEngine. Am I missing something completely obvious? I just want to link the the entry I've created.
If you try to go to abc.com/index/small-builders does it work? (added index)
I don't know if you're hiding index in the url or not but that can cause it.
The way I fixed this was the enable the Pages plugin on ExpressionEngine. Where I'm using ExpressionEngine 3.0.5 the plugin isn't installed/activated by default like it is on EE2.
Once this was activated I was able to assign templates and url structure no problem.
guess your post would be better on the expressionengine.stackexchange.com site.
Post it there and i´ll have a look if i can explain this to you

MODx Revo Wayfinder 3rd level <ul> different to 2nd level <ul>?

I've used the Wayfinder menu building extra with MODx Evo and am now attempting to use it with MODx Revo for a new site. It's working well apart from I can't yet see a way to have the 3rd level different to the 2nd level . See the way Wayfinder is currently outputting the menu (simplified here for clarity):
<ul class="nav nav-pills nav-main" id="mainMenu">
<li class="dropdown">
<a class="dropdown-toggle notransition" href="index.php?id=200">
Help
<i class="icon-angle-down"></i>
</a>
<ul class="dropdown-menu pull-right " style="display: none;">
<li>
<a href="index.php?id=31">
FAQs
</a>
</li>
<li class="dropdown-submenu pull-left">
<a href="index.php?id=54">
Policies
</a>
<ul class="dropdown-menu pull-right" style="display: none;">
<li>
<a href="index.php?id=490">
Privacy Policy
</a>
</li>
<li>
<a href="index.php?id=489">
Terms and Conditions
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
I need the 'Policies' sub-menu, with 'Privacy Policy' etc, to pull to the left, not to the right - defined in Wayfinder InnerTpl:
<ul class="dropdown-menu pull-right" style="display: none;">[[+wf.wrapper]]</ul>
So, is it possible with Wayfinder to have a 3rd level different to the 2nd level ???
I've browsed the docs and forums for days to no avail and hope that the amazing SO community has some insights. Thanks in advance!
I think you are going to have to do this with CSS, you can add the &levelClass to your wayfinder call [docs say " CSS class denoting every output row level. The level number will be added to the specified class (level1, level2, level3 etc if you specified 'level').]
that way when you can write some css for your third level items when you see something like:
<li class="dropdown-submenu pull-left level2">
your css could go something like:
li.dropdown-submenu.pull-left.level2 > ul {
/* css for pulling it right */
}
unfortunately the &levelClass does not do anything if you add [[+wf.classnames]] to the UL tag in the outer wrapper so you have to come at it sideways.
OR
your inner wrappers could be written to use a snippet to decide what classes to add:
<ul class="dropdown-menu [[!pullLeftOrRight? &id=`[[+wf.docid]]`]]">
[[+wf.wrapper]]
</ul>
Then in your snippet use the docid to determine where in the menu tree that subnav is.
[hopefully docid is available in the outerTpl - I'm not sure]
UPDATE
After reading your comments & the docs again, I think I have an idea that might work - check out the &categoryFoldersTpl attribute, setup your tpl for that with your pull right classes & for your 3rd level drop downs, set the rel="category" on only the third level resources as suggested in the docs. [which doesn't help anyone who wants different submenus for different levels, but may get you out of your bind]

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

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

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