Page 1 of 1

[solved] ECB2 Extended Content Blocks 2 - "read" variables

Posted: Thu Jan 12, 2017 3:01 pm
by paulbaker
I'm probably missing something obvious here. :(

My goal is to have a tick box on the back end of each page. The tick box determines whether a column is shown with a Twitter widget.

At the end of the page template I have:

Code: Select all

{content_module module="ECB2" field="checkbox" block="showtwitter" label="Show Twitter column" default_value="0" description="Tick to show the Twitter column on the right hand side of this page"}
This works in that it shows the tick box when I am editing the page and I can tick it and it saves. So that's great.

How do I then "read" this variable?

I tried displaying {$showtwitter} in the page template - nothing.

I also tried adding assign="test1" to the original code but got nothing when I tested for $test1.

Tried the module help but it doesn't explain how to access the variables.

What I want to do in the template is something like this:

{if $showtwitter}
<!-- extra content to show here -->
{/if}

Thanks!

Re: ECB2 Extended Content Blocks 2 how to "read" variables

Posted: Thu Jan 12, 2017 3:06 pm
by Jo Morg
I would venture saying that you would need to assign it to the variable:

Code: Select all

{content_module module="ECB2" field="checkbox" block="showtwitter" label="Show Twitter column" default_value="0" description="Tick to show the Twitter column on the right hand side of this page" assign=showtwitter}
* untested...

Re: ECB2 Extended Content Blocks 2 how to "read" variables

Posted: Thu Jan 12, 2017 3:53 pm
by paulbaker
Thanks Jo, when I do that and put {$showtwitter} in the template I see nothing on the front end page, I am expecting perhaps a "1" if the box is ticked.

Re: ECB2 Extended Content Blocks 2 how to "read" variables

Posted: Thu Jan 12, 2017 4:03 pm
by Jo Morg
Try {$showtwitter|var_export} to inspect the variable in this case. sometimes printing Boolean values is not all that straight forward... for instance FALSE usually won't print anything and that for debugging purposes can be misleading.

Re: ECB2 Extended Content Blocks 2 how to "read" variables

Posted: Thu Jan 12, 2017 4:35 pm
by paulbaker
Thanks Jo.

I put <!-- {$showtwitter|var_export} -->

I see <!-- NULL --> :'(

Re: ECB2 Extended Content Blocks 2 how to "read" variables

Posted: Thu Jan 12, 2017 4:45 pm
by Jo Morg
OK then, that means that assigning that way won't work... try:

Code: Select all

{$showtwitter="{content_module module='ECB2' field='checkbox' block=showtwitter label='Show Twitter column' default_value=0 description='Tick to show the Twitter column on the right hand side of this page'}"}{$showtwitter|var_export}
Be careful with the quotes, try to use it as posted otherwise you might have conflicting syntax...

Re: ECB2 Extended Content Blocks 2 how to "read" variables

Posted: Thu Jan 12, 2017 4:58 pm
by paulbaker
Thanks, I see <!-- '1' --> when box is ticked and <!-- '0' --> when it is not ticked.

Re: ECB2 Extended Content Blocks 2 how to "read" variables

Posted: Thu Jan 12, 2017 5:01 pm
by Jo Morg
Now you can use:

Code: Select all

{if $showtwitter}
<!-- extra content to show here -->
{/if}

Re: ECB2 Extended Content Blocks 2 how to "read" variables

Posted: Thu Jan 12, 2017 5:55 pm
by paulbaker
Thanks again, I tried that but sadly the extra content does not show when the check box is ticked (or if the check box is not ticked).

Re: ECB2 Extended Content Blocks 2 how to "read" variables

Posted: Thu Jan 12, 2017 6:07 pm
by Rolf
paulbaker wrote:Thanks, I see <!-- '1' --> when box is ticked and <!-- '0' --> when it is not ticked.

Code: Select all

{$showtwitter="{content_module module='ECB2' field='checkbox' block=showtwitter label='Show Twitter column' default_value=0 description='Tick to show the Twitter column on the right hand side of this page'}"}

{if $showtwitter == '1'}
  <!-- extra content to show here -->
{/if}

Re: ECB2 Extended Content Blocks 2 how to "read" variables

Posted: Thu Jan 12, 2017 6:44 pm
by paulbaker
That works Rolf, thank you. And thanks again to Jo.