07-20-2023, 02:09 PM
Consider a standard Magento block that loads in the content of a static block. If I want to parse out any widget (or for that matter, any other CMS declarations) out of that block, will it be necessary to construct a method that does standard preg_match type of operations to parse these strings or am I able to use built-in methods to grab each declaration and add it to my own array/object?
Looking at the 'widget/template_filter' class that handles normal parsing of these declarations, the only method up the chain I can find that may prove useful is the protected _getIncludeParameters() method in Varien/Template.php.
It's rather late, so I imagine I will update this question tomorrow with additional details.
--edit--
Err... reading this following day, and I certainly worded this poorly. I blame my girlfriend.
A better way to phrase this would be...
Consider the following static block:
<?php $block = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load('my_static_block') ?>
<?php $content = $block->getContent() ?>
$content will give me the unparsed content with cms/widget declarations still intact, such as:
{{widget type="my/widget" template="my/template.phtml"}}
Now I simply want to convert this declaration back into an object (or more appropriately, I will have several {{widget}} declarations that I want to drop into an array) so that I can check param values, do other work, etc, such as:
<?php foreach ($content->getWidgets() as $widget) : ?>
<?php echo $widget->getValue() ?>
<?php endforeach; ?>
Looking at the 'widget/template_filter' class that handles normal parsing of these declarations, the only method up the chain I can find that may prove useful is the protected _getIncludeParameters() method in Varien/Template.php.
It's rather late, so I imagine I will update this question tomorrow with additional details.
--edit--
Err... reading this following day, and I certainly worded this poorly. I blame my girlfriend.
A better way to phrase this would be...
Consider the following static block:
<?php $block = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load('my_static_block') ?>
<?php $content = $block->getContent() ?>
$content will give me the unparsed content with cms/widget declarations still intact, such as:
{{widget type="my/widget" template="my/template.phtml"}}
Now I simply want to convert this declaration back into an object (or more appropriately, I will have several {{widget}} declarations that I want to drop into an array) so that I can check param values, do other work, etc, such as:
<?php foreach ($content->getWidgets() as $widget) : ?>
<?php echo $widget->getValue() ?>
<?php endforeach; ?>