Posted In Tutorials

Pull Latest Entries In Sidebar Of An Expression Engine Website

We use two main web publishing systems here at J Taylor Design, those systems being WordPress and ExpressionEngine. This article is going to focus on pulling recent blog articles in the sidebar of a website that is built on ExpressionEngine.

Why Such A Simple Article?

Though the topic may sound simple for developers who use other systems, there is an important step to discuss within ExpressionEngine to make sure the sidebars show the correct information. That step is using the “Dynamic” parameter.

The Dynamic= Parameter In ExpressionEngine

From ExpressionEngines user guide, “The channel display engine sets some parameters dynamically, based on what is in the URL. 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”.

Imagine that your website blog has a sidebar that pulls the latest 3 blog entries dynamically. If you were to paginate between pages of different blog entries, you would still want your sidebar to pull those same latest 3 blog entries regardless if you were on page 1, page 10, or an individual blog entry. If you were to ignore the “dynamic” parameter in ExpressionEngine, the sidebar would not function as you would want. Page 1 of your blog entries would be fine, but if you were on page 2 of your blog entries, the sidebar would pull the same top 3 blog articles that are listed on the top of page 2. Further, if you were on an individual blog entry, the sidebar would only pull the title of that Individual blog entry, and nothing else. That result is certainly not ideal for the typical blog.

Add In The Parameter

To fix the sidebar, simply add in the parameter of dynamic=“no” (or dynamic=“off”) and your sidebar will pull your latest 3 entries without issue, regardless of what page you are on. Your opening Channel Entries tag may look something like the following:

{exp:channel:entries channel="news" limit="3" dynamic="off"}

Learn More

Train-ee has a nice video further explaining dynamic=“off” that you can watch here. For more information, be sure to browse through the User Guide of ExpressionEngine.

Spread The Word