close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

IF statement to show or hide a div with CMS

Thread began 4/18/2010 4:18 pm by mrs | Last modified 4/19/2010 5:05 am by mrs | 655 views | 2 replies |

mrs

IF statement to show or hide a div with CMS

Hi, I have created an div on a page where I want the content to show or hide based on what is entered into the admin area, and I am trying to make it disappear if the content is equal to 'blank', but I keep getting an error.

I can get an if statement to work if I have a recordset to compare contents to, but as a site with CMS doesn't need a recordset, I am struggling to get the thing to work.

----------

This is the code I have which is similar to that I would use on a recordset:

<?php /*START_PHP_SIRFCIT*/ if($database_localhost, $localhost, ['in focus', 'Main area']<>"blank"){ ?>
<div id="infocuspanel">
<?php echo WA_getCMSContent($database_localhost, $localhost,"in focus", "Main area"); ?>
</div>
<?php } /*END_PHP_SIRFCIT*/ ?>


----------

I keep getting this error no matter what change I make though:

Parse error: syntax error, unexpected ',' in /Users/username/Sites/website/includes/in_focus.php on line 1

----------

Any ideas on what I can do to make this show or hide based on the content being 'blank'?

Thanks.

Sign in to reply to this post

anonymous

Run your if statement like this:


php:
<?php if (WA_getCMSContent($database_localhost$localhost,"in  focus""Main area") != "" ) {
         echo 
WA_getCMSContent($database_localhost$localhost,"in  focus""Main area");
}
?>



Make sure you use "!=" when testing for Not Equal To.

Also, don't use the word "blank"... just two back to back quotes with no string between like this "" will signify empty.

Best regards,

Brian

Sign in to reply to this post

mrs

Thanks for that. I've never seen != before... I thought that <> was a universal not equal to, but hey, I'll give it a go.

Also, I've used the word 'blank' because the CMS solution doesn't allow for an actual blank entry in the database. I was hoping to use the two quotes, but unfortunately something has to be entered into the text editor to ensure that it submits to the database.

I would remove the validation on it, but I need it to be there for when the same page is working on other areas of the site.

Thanks again.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...