Magento – Statischen CMS Block in Seite / Artikelbeschreibung einbauen

If you want to install a static block in the Magento site, There are several ways this. Either on the appropriate. Xml (im Layout Ordner des Templates), directly on the template or the CMS itself.

If a static block directly to a CMS (So a CMS page) be involved, might also lead to the following code happen:

{{block type="cms/block" block_id="Ihr_Seitenbezeichner" template ="cms/content.phtml"}}

Ihr_Seitenbezeichner here in each case, neither the block title (Name of the page) nor the number (ID).

but it is also sufficient

{{block type="cms/block" block_id="Ihr_Seitenbezeichner"}}

since Magento 1.9 is a common Scandals, that one forgets the block via System > permissions > Blocks to allow. There is more info HERE.

Soll ein statischer Block hingegen z.B. in eine Artikelbeschreibung eingebunden werden, geht dies nicht so einfach, da die Artikelbeschreibung mit dieser Zeile (more) nichts anfangen kann. Damit auch in der Artikelbeschreibung ein statischer Block eingefügt werden kann, muss zuerst noch die Datei Product.php aus dem Verzeichnis

app/code/core/Mage/Catalog/Model

in das Verzeichnis

app/code/local/Mage/Catalog/Model

kopiert werden und dann folgender Code (am besten vor der letzten abschließenden Klammer) be inserted:

function getDescription()
 {
   $content = $this->getData('description');
   $templateFilter = Mage::getModel('cms/template_filter');
   $cms = $templateFilter->filter($happy);
   return $cms;
 }

function getShortDescription()
 {
    $content = $this->getData('short_description');
    $templateFilter = Mage::getModel('cms/template_filter');
    $cms = $templateFilter->filter($happy);
    return $cms;
 }

Mit diesem Code kann dann ein statischer Block sowohl im Langbeschreibungs- wie auch Kurzbeschreibungsbereich verwendet werden.

Another variant of the integration of static blocks is the appropriate XML (e.g.. cart.xml) im Layout Ordner. Here insert the following code where you want it:

<reference name="happy">
<block type="cms/block" name ="cms_Ihr_Seitenbezeichner">
<action method="setBlockId"><block_id>Ihr_Seitenbezeichner</block_id></action>
</block>
</reference>

As simple static blocks can be integrated into the Magento Store.

Would you like a static block in a (P)HTML page installed, such as e.g.. Information for the shipping directly from the shipping methods in checkout, is incorporated in this case in the shipping-method.phtml at the gewünschtn, replace the code:

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('Shipping info')->toHtml() ?>

in which “shipping info” of the static code block is. This can then be used like any other code, of course, other pages can be used PHTML.

Update vom 08.09.2021 for Magento 2:

In Magento 2 the above snippet no longer works and a slightly modified one must be used. But if you know this, it is not a problem. But you can also use two different codes again:

{{block class="Magento\\Cms\\Block\\Block" area="frontend" block_id="[CODE DES BLOCKS bspw. agb]"}}
ODER
{{widget type="Magento\Cms\Block\Widget\Block" template="widget/static_block/default.phtml" block_id="[ID DES BLOCKS bspw. 3]"}}

It just has to be taken into account, that in the code above, the “Code” of the block and the ID (So the sequential number automatically assigned by Magento).

Weiterführende Links:

Static block / Static Block in Seite und phtml einbauen

(Static) Show block only on homepage

Static block installed in the header

Published by Covos

Since 2009 I have been working intensively with Magento. I started with the creation and operation of B2C stores. This was extended through my work in the logistics sector. This resulted first specialized B2E systems. Today I work day-a day with exciting B2C, B2B- and B2E projects and reports in this blog about challenges and give insider tips.

4 comments on “Magento – Statischen CMS Block in Seite / Artikelbeschreibung einbauen”

  1. Hallo Covos,

    Unfortunately, your Captcha funktioiert under the post http://www.fly2mars-media.de/seoblog/magento/magento-statischen-cms-block-im-template-ausgeben-101390/ not. Therefore, in this way. I fight with my Magento navigation and would love to replace the entire horizontal Hauptnavi through a static block. My approach: a static block to the page identifier “navigation” page.xml create and in the block ” ” by replacing “navigation”. Unfortunately, I receive only a plain white page.

    What is wrong?

    Kind regards,
    Marcus

    1. Ene navigation can be well integrated with the help of tables in each page. The page name link with / your-page-url and via copy and paste to reproduce quickly .

    1. This is a possibly useful extension, should there be problems with the simple integration of static blocks in the shop. But I generally recommend it first without the extension to try.

Leave a Reply

Your email address will not be published. Required fields are marked *