how to call functions/methods within CMS block or page?
We are trying to make all our blocks and pages static so that designer or anyone else can easily c开发者_开发知识库hange the content or design of the website, however. There is a feature that uses our own custom module. So, the template that we want to make static is calling methods out of our custom block, for example,
<!--some html code-->
.....
<?php $this->helpMeBePartOfCMS(); ?>
.....
<!--some html code-->
How do i incorporate these method calls inside cms block or page?
Thank you
The CMS system makes it easy to include custom blocks (or widgets in Enterprise), but not so easy to make method calls. This is because the templates are never parsed as PHP, so you cannot just include a PHP tag.
Why don't you define a custom block to accomplish this? If that won't work, please provide a little more detail about what you're actually trying to include, so that we can troubleshoot further.
Hope that helps!
Thanks, Joe
Since CMS block templates are not parsed as PHP code, there's no way to inject a call as you are describing. However, all classes descending from Mage_Core_Block_Abstract have the ability to call child and parent blocks. Use one of these methods to do what you are looking for from the block directly:
getParentBlock
getChild
getSortedChildren
there is a way that you call these php codes in any phtml file (create a new and save any where in your templates) then call that phtml file in your cms page as a block (which we usually do for calling blocks)
精彩评论