Back to Top

how to call chunk into the snippets in Modx

Here is one more quick article to share how to call chunk into the snippets in Modx Revolution.

When I was working on my first MODx website which will use a number of chunks and if you have basic knowledge of Modx then you know that a chunk is simply a block of HTML code so we can’t place any PHP condition to execute chunk.

Let me explain with an example, If you want to execute chunk for a specific page like only for the homepage, you need to place chunk within a PHP condition so it is not directly possible from the chunk.For that, you can use snippets to execute chunk data for a specific condition.

Let’s have a look into the below example, Here, I am going to explain how you can display chunk data into homepage only from the snippet.

First of all, Create one chunk and place your data into that chunk.Next, create one new snippet and place below condition and call your chunk with using getChunk function.

If you want to use chunk with specific condition directly from template,you can use [[$chunkname]],like here I have explained how you display chunk data only on homepage.

Let’s have a look into the below code, you can place below code into the template file to call chunk in Homepage/site start page only

Further Reading:

Accordion Menu with Modx
Setting the Time Zone for Modx Installation

I hope you have enjoyed this article.Thanks for reading and feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How To use Pagination in Joomla

Posted on 12 years ago

Bhumi

Angularjs 2 Tutorial for Beginners

Posted on 8 years ago

Bhumi