The code I have works, but I don't understand why and am seeking an explanation rather than a fix.
I have a template which displays a list of news articles. The channel is called news
. I also have another channel called news_overview
which is used to create an "intro" page to my list of news articles (which belong in the news
channel).
So my template is as follows:
{exp:channel:entries channel="news_overview" limit="1"}
<!-- Display banner and other details from `news_overview` channel -->
{/exp:channel:entries}
{exp:channel:entries channel='news' orderby='date' sort='desc' limit="9" paginate="bottom"}
<!-- Display each article's title and a link to read it -->
<h1>{title}</h1>
<p><a href="{url_title_path='news'}">Read article</a></p>
{/exp:channel:entries}
My news entries are categorised.
When I go to a URL (/news
) it loads up the template above and everything works.
However when I go to a category based URL such as /news/category/events
it loads the appropriate articles....but not the information from news_overview
. In other words, it loads the appropriate list of news articles (which are categorised as "events") but is missing the banner and intro text from news_overview
at the top of the template - nothing is output there.
I managed to fix this by adding dynamic="no"
to the first channel entry tag:
{exp:channel:entries channel="news_overview" limit="1" dynamic="no"}
This fixed the problem. But I don't understand why?
According to the documentation
There are times, however, where you do not want the parameters affected by what the URL contains. To override the dynamic nature of the channel tag, use dynamic="no".
Why does the URL affect loading data in this way? My understanding of my initial channel entries tag is that it's just asking for 1 entry from news_overview
. Given that this is the same on every page, and isn't even from the news
channel, why does it affect it in this way? I understand why it affects the news
entries that are found in the query...because the categories are tied to news
, but not news_overview
.