Magento - How do you return results of unlimited CMS Static blocks (with certain “Identifier”) to a CMS Page

前端 未结 1 1730
清酒与你
清酒与你 2021-01-11 17:24

Quick Overview: I am trying to return results from a specific set of static blocks to a phtml file (which is then called on from a

1条回答
  •  礼貌的吻别
    2021-01-11 17:48

    You are not printing block inside foreach loop. Solution: move } parenthesis to the end of pasted code

    $blockNum = 1;
    foreach($collection as $key => $value){
        $_blockId = $this->getIdentifier();
        $block_ID = $_blockId . $blockNum;
        echo "Key: " . $key . " - " . "Block ID: " . $block_ID . "
    "; $blockNum++; $_block = $this->getLayout()->createBlock('cms/block')->setBlockId($block_ID); if ($_block) : ?>
    getTitle(); ?>
    toHtml(); ?>

    I think that on Magento Connect are some Testimonial Modules, that are doing job you want. On the other hand, if you are looking for 'simple' solution or if you are trying to play with Magento, is this approach ok.

    0 讨论(0)
提交回复
热议问题