how does partials module work?
Created 7 years ago by stevenweijdt

I've tried to add this to the view.twig file of the pages module: {% include "partials::blabla" %}

I also tried to add it to the content field of a page. blabla is the slug of the partial I made. There's no documentation. So I have no idea how and where to use the partials I made. Templates module just works.

ryanthompson  —  7 years ago

I think I might go ahead and release document this one.. test er our for me! We've used it in production a few times but will be nice to have more eyes on it:

{{ partial($slug) }}

If a partial is a relationship - then you can do like:

{{ page.partial|raw }}

stevenweijdt  —  7 years ago

I've added this to the view.twig and to the content type of a page: {{ partial($slug) }} {{ partial("blabla") }} {{ partial(blabla) }}

I'm trying everything. Doesn't seem to work

stevenweijdt  —  7 years ago

So $slug is a string. It's the slug name you can find here:

yourdomain.dev/admin/partials

(you need to create a partial first there. If you already have one, click on edit) When you call your partial My Partial, the slug will become my_partial.

yourdomain.dev/admin/pages/types/edit/1

if you go here you find the default type for a page. Add the partial code to the layout field on the bottom of the page like this:

{{ partial('my_partial') }}

You can also edit a page and add the {{ partial('my_partial') }} to the content field:

yourdomain.dev/admin/pages/edit/1

That's the welcome page that comes out of the box with pyro.

finnito  —  6 years ago

How can one use {{ partial('my_partial') }} to get raw content of that partials in the case of a code block? {{ partial('my_partial')|raw }} doesn't seem to work.

ryanthompson  —  6 years ago

Not sure what you mean? You want the layout? {{ partial.type.layout.content }} is the layout.. You can access entry level fields (custom fields) like partial.custom_field though too. `|raw' will process HTML (no escaping).