This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

trollkotze
trollkotze

Hello!

It seems, currently it is not possible to do this, for example:

In some layout template:

        {% placeholder aboveall %}
        {% page %}

In some page template:

{% set ontopofstuff 'aboveall' %}
{% put ontopofstuff %}
    <h1>HELLO!</h1>
{% endput %}

So we cannot use

{% put 'placeholder_so_and_so' %}

with a variable string placeholder name, but instead have to

{% put placeholder_so_and_so %}

with a fixed name that has to be known on "compile time".

I could imagine some scenarios where this would be nice to have it possible to be set dynamically, and recently actually wanted to use it that way, but realized it was not possible. (I wanted a component to put stuff into some side menu placeholder that would be displayed on a different place independently from the rest of the component's markup. Of course one could use a fixed required placholder name there, or rather leave the whole templating thing to the end user anyway [as components' partials should merely be suggestions or examples on how to display the data or what's going on in the component]. So maybe this is a silly example.)

Or for example one could imagine that based on some nifty logic in the backend one would want to do something like:

{% set panel_index = 3 %}
{% put 'panel'~panel_index %}
     {{stuff_to_display_in_some_panel}}
 {% endput %}

where one has placeholders named panel1, panel2, panel3 etc.

Okay, the examples may be a bit lame. But you can get the concept. And it could be useful, couldn't it?

Is there a reason why this would not be possible in general?

Last updated

amdad
amdad

Yes, I'm also missing this function.

jan-vince
jan-vince

How about using {% partial %}?

You can do something like this:

    {% set index = 1 %}
    {% partial 'test_' ~ index %}

Docs are here

amdad

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.