Page 1 of 1
Retrieving value from {content block...}
Posted: Mon Nov 04, 2013 6:11 am
by aleksanderlech
Hi there,
I can't resolve such problem:
Heres template code (fragment)
Code: Select all
<h1>{title} - {$var}{/h1}
{content block="some-name" oneline="true" label="some-label" assign="var" scope="parent"}
Here's the problem - how to make variable "var" available before content block?
I tried this:
Code: Select all
{content block="some-name" oneline="true" label="some-label" assign="var" scope="parent"}
{capture "var1"}
{$var}
{/capture}
then trying to retrieve {$var1} before content block, but with no luck.
I'm sure it is possible

just don't know how to do that.
Best regards
Olek
Re: Retrieving value from {content block...}
Posted: Mon Nov 04, 2013 7:07 am
by Rolf
Re: Retrieving value from {content block...}
Posted: Mon Nov 04, 2013 10:17 am
by velden
You can not make an variable available before it's initialised.
Why don't you just use it the other way around?
Code: Select all
{content block="some-name" oneline="true" label="some-label" assign="var" scope="parent"}
<h1>{title} - {$var}{/h1}
I'm not sure why you use the scope parameter. I never use it nor do I know if it's a valid parameter.
Re: Retrieving value from {content block...}
Posted: Mon Nov 04, 2013 10:39 am
by aleksanderlech
velden wrote:I'm not sure why you use the scope parameter. I never use it nor do I know if it's a valid parameter.
I don't know that either

it was just there.
Best regards
Olek
Re: Retrieving value from {content block...}
Posted: Tue Nov 05, 2013 9:03 am
by uniqu3
Templates are processed in a specific order (here is a article that explains it
http://www.i-do-this.com/blog/75/Under- ... -Templates) so i guess you want to have content blocks in backend in some other order then on frontend so a editor isn't confused.
What you do, is you assign content blocks (also main {content} tag) on top of template in order that you want them to apear in backend:
Code: Select all
{strip}
{process_pagedata}
{content assign='main_content' label='Main Content'}
{content block='title_for_some_block' label='Please enter title' oneline='true' assign='alt_title'}
{content block='some_block' label='Some nice label' assign='alt_block'}
{* you can also use tabs in 1.11.x *}
{content block='some_area' label='Enter stuff here' tab='Additional stuff' wysiwyg='false' assign='alt_area'}
{/strip}<!doctype html>
<!-- and the rest of template -->
Once you have your stuff configured, you can use assigned variables anywhere in your template, don't forget to replace {content} with {$main_content} as assigned above.