I have defined a {CAPTURE} variable in Smarty using:
{capture name='websitediv'}
//code to generate some output to be captured.
{/capture}
and assigned the output to a template variable
{capture name='websitediv' assign='ws'}
I have condition set in my code whereby depending whether the above captured variable has a value or not, the contents of will be shown or hidden:
<div {if !isset($ws)} style="display:none" {/if}>
//else do something
</div>
Unfortunately, the last code does not work. No matter is the captured variable is available or not, the div remains displayed.
Just like a PHP variable, there is a difference between a Smarty variable being "unset", and it simply having a value which looks empty to a human.
In this case, your {capture}
block is always processed, and always assigned to the variable, so the variable will always exist, and have some string content in it.
What you need to test is not its existence, but its content - is it an empty string, or, more likely, a string containing only the whitespace that sits between your Smarty tags.
Like in PHP, a completely empty string evaluates to false in a Smarty {if}
statement, so you can say {if !$ws}...{/if}
to detect that. But you want to ignore the whitespace, so what you probably want is {if !trim($ws)}...{/if}