Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hi,

I am having trouble with an if statement which I can't get to resolve to True, ever! Please help me :)

On Page1.php I have (simplified version)

Code: Select all
<?php 

require_once( 'couch/cms.php' );
?>

<cms:capture into='showBackgroundImage' scope='global'>
<cms:editable name='BgImage' label='Background Image' desc='Do you want to show the background image on this page?' opt_values='True | False' type='radio'></cms:editable>
</cms:capture>

<cms:embed 'Template.inc' />

<?php
COUCH::invoke();

?>


Then in Template.inc I have

Code: Select all
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head />
<body>
                        <cms:if showBackgroundImage = 'True' >
                        <span><cms:show showBackgroundImage /></span>
                        </cms:if>
</body>
</html>


The span element will ne ver show on the page regardless of the radio button I choose in the editor. What am I doing wrong I hope you can help.
Hello and welcome :)

I wonder why you are capturing the editable region's value into a variable instead of using it directly e.g. the following would work exactly the same -
Code: Select all
<cms:template>
   <!-- this is a common place to define all editable regions -->
   <cms:editable name='BgImage' label='Background Image' desc='Do you want to show the background image on this page?' opt_values='True | False' type='radio'></cms:editable>

</cms:template>


Code: Select all
<!-- in the embedded template use value of 'BgImage' directly -->
<cms:if BgImage= 'True' >
   <span><cms:show showBackgroundImage /></span>
</cms:if>

Anyways, the code seems to be working just fine for me.
I think you can try this
<cms:editable name='BgImage' label='Background Image' desc='Do you want to show the background image on this page?' opt_values='True | False' type='radio'>False</cms:editable>
to explicitly provide a default value where no selection has yet been made.

Hope this helps.
Hi,

I am new to this and not familiar with the template tag.

The reason for storing to a variable is because I have the variable being set in a common template page which is imported by a number of website pages.

Each page in the design is very similar, so all this commonality is kept in a Template.inc embedded file. Each page of the site then holds variables to tweak the common design as per the editors requirements.

I'll take another look then - I'm certainly having trouble. I'll try stripping it down and see how I get on.

Thanks for your response.
3 posts Page 1 of 1