Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 716 Vote(s) - 3.45 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Magento - Parse widget/cms declarations from static block

#1
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; ?>

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through