Retrieving value from {content block...}

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
User avatar
aleksanderlech
Forum Members
Forum Members
Posts: 113
Joined: Thu Jan 29, 2009 1:37 pm

Retrieving value from {content block...}

Post 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
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Retrieving value from {content block...}

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Retrieving value from {content block...}

Post 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.
User avatar
aleksanderlech
Forum Members
Forum Members
Posts: 113
Joined: Thu Jan 29, 2009 1:37 pm

Re: Retrieving value from {content block...}

Post 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
uniqu3

Re: Retrieving value from {content block...}

Post 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.
Post Reply

Return to “Layout and Design (CSS & HTML)”