{% for blk in m.rsc[id].blocks %}
    {% optional include ["blocks/_block_view_",blk.type,".tpl"]|join 
blk=blk id=id %}
{% endfor %}

Understand, thanks for the correct format. 

Thanks again,
Seann

On Monday, January 15, 2024 at 1:42:45 AM UTC-7 Marc Worrell wrote:

> Hi Seann,
>
> I would expect it to be:
>
> {% for blk in id.blocks %}
>
>         {% include "blocks/_block_view_text.tpl" %}
> {% endfor %}
>
>
> But that renders only blocks of the type ’text’.
>
> The suffix _text is the type of the block, we added different templates 
> for the different types.
> You can see in the mod_survey how we use those to render the different 
> questions.
>
> That is also why we add the type of the block when including using the 
> “_blocks.tpl”:
>
> {% for blk in m.rsc[id].blocks %}
>     {% optional include ["blocks/_block_view_",blk.type,".tpl"]|join 
> blk=blk id=id %}
> {% endfor %}
>
>
> (id.blocks is shorthand for m.rsc[id].blocks)
>
> Cheers, Marc
>
>
> On 15 Jan 2024, at 09:32, 'Seann Aswell' via Zotonic developers <
> [email protected]> wrote:
>
> When I use the following, without .title on the end, it works.
>
> {% for blk in id.blocks.name %}
>         {% include "blocks/_block_view_text.tpl" %}
> {% endfor %}
>
> If there is a better way, let me know. 
>
> Else, thanks again. Much appreciated.
> On Sunday, January 14, 2024 at 3:23:27 AM UTC-7 Marc Worrell wrote:
>
>> You can use:
>>
>> id.blocks.name.title
>>
>> Where “title” is a property of the block. And name is the name of your 
>> block.
>>
>> If your name includes spaces:
>>
>> id.blocks[“name of block”].title
>>
>> Cheers, Marc
>>
>>
>>
>> Sent from my iPhone
>>
>> On 14 Jan 2024, at 09:32, 'Seann Aswell' via Zotonic developers <
>> [email protected]> wrote:
>>
>> 
>>
>> Very interesting...
>>
>> So, if I add a Header block called "header1" and a Text block called 
>> "text1", are those fields directly addressable using something like "
>> blk.name"? 
>>
>> For instance, I see in "_block_view_page_inline.tpl 
>> <https://github.com/zotonic/zotonic/blob/master/apps/zotonic_mod_zotonic_site_management/priv/skel/blog/priv/templates/blocks/_block_view_page_inline.tpl>
>> ":
>>
>>     {% for blk in id.blocks %}
>>         {% if blk.type == "header" %}
>>
>> Is there a blk.name variable associated with the name of the block 
>> added? If so, can you recommend how to address each block via name directly?
>>
>> What I am hoping to achieve is to have one resource with multiple Header 
>> and Text blocks, but I need to address each one directly, to display in a 
>> particular place in the HTML layout. However, I am unsure how to display a 
>> specific blk by name, rather than listing them all as the above example 
>> shows.
>>
>> The flexibility you built into the system is impressive, but I am still 
>> learning my way around...
>>
>> On Saturday, January 13, 2024 at 5:14:14 AM UTC-7 Marc Worrell wrote:
>>
>>> Hi!
>>>
>>> There are nested in the “blocks” property. 
>>>
>>> You can check the _blocks.tpl here:
>>>
>>>
>>> [image: zotonic.png]
>>>
>>> zotonic/apps/zotonic_mod_base/priv/templates/_blocks.tpl at master · 
>>> zotonic/zotonic 
>>> <https://github.com/zotonic/zotonic/blob/master/apps/zotonic_mod_base/priv/templates/_blocks.tpl>
>>> github.com 
>>> <https://github.com/zotonic/zotonic/blob/master/apps/zotonic_mod_base/priv/templates/_blocks.tpl>
>>>
>>> <https://github.com/zotonic/zotonic/blob/master/apps/zotonic_mod_base/priv/templates/_blocks.tpl>
>>>
>>>
>>> Cheers, marc 
>>>
>>>
>>> Sent from my iPhone
>>>
>>> On 11 Jan 2024, at 21:51, 'Seann Aswell' via Zotonic developers <
>>> [email protected]> wrote:
>>>
>>> 
>>>
>>> Another question...
>>>
>>> In the admin there is the option of adding content blocks to resources, 
>>> which seems really handy. 
>>>
>>> How can I address the additional blocks in HTML? I am obviously missing 
>>> something, as I do not see any properties defined in m_rsc 
>>> <https://zotonic.com/docs/1278/m_rsc> regarding content blocks.
>>>
>>> Currently on a few webpages, I have added multiple resources and called 
>>> {id.body} multiple times in HTML to achieve the same affect...
>>>
>>> -- 
>>>
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Zotonic developers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/zotonic-developers/971f861c-3850-4fe1-b1fc-815c4d6ba794n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/zotonic-developers/971f861c-3850-4fe1-b1fc-815c4d6ba794n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>>
>> -- 
>>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Zotonic developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>>
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/zotonic-developers/f442e3c8-8ef6-4b9a-b8f9-5425de3acbe7n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/zotonic-developers/f442e3c8-8ef6-4b9a-b8f9-5425de3acbe7n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>>
> -- 
>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Zotonic developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/zotonic-developers/69b0dfe5-7846-414e-9408-d59ea3f4bcb2n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/zotonic-developers/69b0dfe5-7846-414e-9408-d59ea3f4bcb2n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Zotonic developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/zotonic-developers/9999dae6-8acc-4d09-a758-4257ec589626n%40googlegroups.com.

Reply via email to