3 highlight that it's not best practice
source | link

The filter directives are processed in Mage_Cms_Model_Template_Filter which inherits from Mage_Core_Model_Email_Template_Filter, so you have all the functionality from email templates in CMS blocks and pages as well.

But you are right that it all depends on which variables are available. And unfortunately the CMS pages do not assign any variables to the filter, as you can see in Mage_Cms_Block_Block::_toHtml():

$processor = $helper->getBlockTemplateProcessor();
$html = $processor->filter($block->getContent());

Between those lines, $processor->setVariables($block->getData()) would be useful.

How to enable template variables in CMS

Rewrite Mage_Cms_Block_Block and Mage_Cms_Block_Page as described above.

You could then set any additional variables with $block->setData() with another rewrite, but I would suggest to use an observer instead to be more flexible. Observe the event cms_page_render for CMS pages or core_block_abstract_prepare_layout_after for static blocks to add dynamic variables like "logged_in" to all blocks/pages.

Why are you not seeing anything?

The reason that you see {{depend}} as plain text is probably that no template variables have been set. If you look at the dependDirective implementation, you will see that if there are no template variables, the directive is returned unchanged ($construction is a match returned by preg_match_all and $construction[0] the whole subpattern):

public function dependDirective($construction)
{
    if (count($this->_templateVars)==0) {
        // If template preprocessing
        return $construction[0];
    }

    if($this->_getVariable($construction[1], '')=='') {
        return '';
    } else {
        return $construction[2];
    }
}

Should you really do that?

Probably not. Please refer to Marius' answer for a solution to your problem as it is intended by Magento.

In both cases, pay attention to effects of the block cache. You might need to add additional cache tags to the block to distinguish the dynamic content.

The filter directives are processed in Mage_Cms_Model_Template_Filter which inherits from Mage_Core_Model_Email_Template_Filter, so you have all the functionality from email templates in CMS blocks and pages as well.

But you are right that it all depends on which variables are available. And unfortunately the CMS pages do not assign any variables to the filter, as you can see in Mage_Cms_Block_Block::_toHtml():

$processor = $helper->getBlockTemplateProcessor();
$html = $processor->filter($block->getContent());

Between those lines, $processor->setVariables($block->getData()) would be useful.

How to enable template variables in CMS

Rewrite Mage_Cms_Block_Block and Mage_Cms_Block_Page as described above.

You could then set any additional variables with $block->setData() with another rewrite, but I would suggest to use an observer instead to be more flexible. Observe the event cms_page_render for CMS pages or core_block_abstract_prepare_layout_after for static blocks to add dynamic variables like "logged_in" to all blocks/pages.

Why are you not seeing anything?

The reason that you see {{depend}} as plain text is probably that no template variables have been set. If you look at the dependDirective implementation, you will see that if there are no template variables, the directive is returned unchanged ($construction is a match returned by preg_match_all and $construction[0] the whole subpattern):

public function dependDirective($construction)
{
    if (count($this->_templateVars)==0) {
        // If template preprocessing
        return $construction[0];
    }

    if($this->_getVariable($construction[1], '')=='') {
        return '';
    } else {
        return $construction[2];
    }
}

The filter directives are processed in Mage_Cms_Model_Template_Filter which inherits from Mage_Core_Model_Email_Template_Filter, so you have all the functionality from email templates in CMS blocks and pages as well.

But you are right that it all depends on which variables are available. And unfortunately the CMS pages do not assign any variables to the filter, as you can see in Mage_Cms_Block_Block::_toHtml():

$processor = $helper->getBlockTemplateProcessor();
$html = $processor->filter($block->getContent());

Between those lines, $processor->setVariables($block->getData()) would be useful.

How to enable template variables in CMS

Rewrite Mage_Cms_Block_Block and Mage_Cms_Block_Page as described above.

You could then set any additional variables with $block->setData() with another rewrite, but I would suggest to use an observer instead to be more flexible. Observe the event cms_page_render for CMS pages or core_block_abstract_prepare_layout_after for static blocks to add dynamic variables like "logged_in" to all blocks/pages.

Why are you not seeing anything?

The reason that you see {{depend}} as plain text is probably that no template variables have been set. If you look at the dependDirective implementation, you will see that if there are no template variables, the directive is returned unchanged ($construction is a match returned by preg_match_all and $construction[0] the whole subpattern):

public function dependDirective($construction)
{
    if (count($this->_templateVars)==0) {
        // If template preprocessing
        return $construction[0];
    }

    if($this->_getVariable($construction[1], '')=='') {
        return '';
    } else {
        return $construction[2];
    }
}

Should you really do that?

Probably not. Please refer to Marius' answer for a solution to your problem as it is intended by Magento.

In both cases, pay attention to effects of the block cache. You might need to add additional cache tags to the block to distinguish the dynamic content.

2 more accurate info
source | link

The filter directives are processed in Mage_Cms_Model_Template_Filter which inherits from Mage_Core_Model_Email_Template_Filter, so you have all the functionality from email templates in CMS blocks and pages as well.

But you are right that it all depends on which variables are available. And unfortunately the CMS pages do not assign any variables to the filter, as you can see in Mage_Cms_Block_Block::_toHtml():

$processor = $helper->getBlockTemplateProcessor();
$html = $processor->filter($block->getContent());

Between those lines, $processor->setVariables($block->getData()) would be useful.

How to enable template variables in CMS

Rewrite Mage_Cms_Block_Block and Mage_Cms_Block_Page as described above.

You could then set any additional variables with $block->setData() with another rewrite, but I would suggest to use an observer instead to be more flexible. Observe the event cms_page_render for CMS pages or core_block_abstract_prepare_layout_after for static blocks to add dynamic variables like "logged_in" to all blocks/pages.

Why are you not seeing anything?

The reason that you see {{depend}} as plain text is probably exactly that no template variables are availablehave been set. If you look at the dependDirective implementation, you will see that if there are no template variables, the directive is returned unchanged ($construction is a match returned by preg_match_all and $construction[0] the whole subpattern):

public function dependDirective($construction)
{
    if (count($this->_templateVars)==0) {
        // If template preprocessing
        return $construction[0];
    }

    if($this->_getVariable($construction[1], '')=='') {
        return '';
    } else {
        return $construction[2];
    }
}

The filter directives are processed in Mage_Cms_Model_Template_Filter which inherits from Mage_Core_Model_Email_Template_Filter, so you have all the functionality from email templates in CMS blocks and pages as well.

But you are right that it all depends on which variables are available.

The reason that you see {{depend}} as plain text is probably exactly that no template variables are available. If you look at the dependDirective implementation, you will see that if there are no template variables, the directive is returned unchanged ($construction is a match returned by preg_match_all and $construction[0] the whole subpattern):

public function dependDirective($construction)
{
    if (count($this->_templateVars)==0) {
        // If template preprocessing
        return $construction[0];
    }

    if($this->_getVariable($construction[1], '')=='') {
        return '';
    } else {
        return $construction[2];
    }
}

The filter directives are processed in Mage_Cms_Model_Template_Filter which inherits from Mage_Core_Model_Email_Template_Filter, so you have all the functionality from email templates in CMS blocks and pages as well.

But you are right that it all depends on which variables are available. And unfortunately the CMS pages do not assign any variables to the filter, as you can see in Mage_Cms_Block_Block::_toHtml():

$processor = $helper->getBlockTemplateProcessor();
$html = $processor->filter($block->getContent());

Between those lines, $processor->setVariables($block->getData()) would be useful.

How to enable template variables in CMS

Rewrite Mage_Cms_Block_Block and Mage_Cms_Block_Page as described above.

You could then set any additional variables with $block->setData() with another rewrite, but I would suggest to use an observer instead to be more flexible. Observe the event cms_page_render for CMS pages or core_block_abstract_prepare_layout_after for static blocks to add dynamic variables like "logged_in" to all blocks/pages.

Why are you not seeing anything?

The reason that you see {{depend}} as plain text is probably that no template variables have been set. If you look at the dependDirective implementation, you will see that if there are no template variables, the directive is returned unchanged ($construction is a match returned by preg_match_all and $construction[0] the whole subpattern):

public function dependDirective($construction)
{
    if (count($this->_templateVars)==0) {
        // If template preprocessing
        return $construction[0];
    }

    if($this->_getVariable($construction[1], '')=='') {
        return '';
    } else {
        return $construction[2];
    }
}
1
source | link

The filter directives are processed in Mage_Cms_Model_Template_Filter which inherits from Mage_Core_Model_Email_Template_Filter, so you have all the functionality from email templates in CMS blocks and pages as well.

But you are right that it all depends on which variables are available.

The reason that you see {{depend}} as plain text is probably exactly that no template variables are available. If you look at the dependDirective implementation, you will see that if there are no template variables, the directive is returned unchanged ($construction is a match returned by preg_match_all and $construction[0] the whole subpattern):

public function dependDirective($construction)
{
    if (count($this->_templateVars)==0) {
        // If template preprocessing
        return $construction[0];
    }

    if($this->_getVariable($construction[1], '')=='') {
        return '';
    } else {
        return $construction[2];
    }
}