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

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

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

Post 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!
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

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

Post 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...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

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

Post 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.
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

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

Post 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.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

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

Post by paulbaker »

Thanks Jo.

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

I see <!-- NULL --> :'(
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

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

Post 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...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

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

Post by paulbaker »

Thanks, I see <!-- '1' --> when box is ticked and <!-- '0' --> when it is not ticked.
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

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

Post by Jo Morg »

Now you can use:

Code: Select all

{if $showtwitter}
<!-- extra content to show here -->
{/if}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

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

Post 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).
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

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

Post 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}
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

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

Post by paulbaker »

That works Rolf, thank you. And thanks again to Jo.
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
Post Reply

Return to “Modules/Add-Ons”