3

I would like to add block to the website (in general on every page) just below menu but not into header, "root" eventually "content".

I managed to add it into content but it's not what I wanted.

=> My layout :

    <reference name="content">
        <block type="core/template" name="banman" before="-" template="banman/block.phtml"/>
    </reference>

This is what I needed to put it there.

Because I'm using Ultimo(latest version), there is a slider before everything else.

Slider is in "root" so I was thinking if I change "content" into "root" then I'll be able to position it before or after slider but it does not work.

I can add it into top.container and it works pretty. But, I can't move it before breadcrumbs.

Doesn't like how it look like if I place it inside menu.Menu bar is far too high.

2

If you want to add your new block in all pages after the breadcrumbs:

1) app/design/frontend/{package}/{theme}/layout/local.xml

<default>
    <reference name="root">
        <block type="core/template" name="banman" template="banman/block.phtml"/>
    </reference>
</default>

2) app/design/frontend/{package}/{theme}/template/page/1column.phtml

add this:

<?php echo $this->getBlockHtml('banman') ?>

after this:

<?php echo $this->getChildHtml('breadcrumbs') ?>

NB: If you want that your block will be just displayed in some page, the same thing but the xml will be changed like this:

<your_layout_handle>
    <reference name="root">
        <block type="core/template" name="banman" template="banman/block.phtml"/>
    </reference>
</your_layout_handle>

EDIT

To display your block with a condition configuration, you have to add your config field in system.xml a multiselect choice to tel to Magento in wich page you want to display your block something like this:

<fields>
    <displayblock translate="label">
        <label>Where you want to display the banman block</label>
        <frontend_type>multiselect</frontend_type>
        <source_model>yourmodule/system_config_source_view</source_model>
        <sort_order>40</sort_order>
        <show_in_default>1</show_in_default>
    </displayblock>
</fields>

You have an exemple here

NB: Dont forget to add this in app/design/frontend/{package}/{theme}/template/page/1column.phtml

if(Mage::getStoreConfig('section/group/field')){
    <?php echo $this->getBlockHtml('banman') ?>
}

EDIT2:

how to insert my block without changing local.xml

Go to your phtml where you want to display your block and add this, you dont need with this the xml

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('path_to_your_block')->toHtml(); ?>

You can set the createBlock('block/type') with your block type.

  • I would like to have it on every page (depending on configuration - will or will be not displayed on every page or only on selected pages). – Rob D. A. Jan 3 '18 at 9:37
  • Module I developed allow you to display element on home page and on every other page and it actually works except the place where this element should be displayed. This is the only thing I must sort out. So far I can insert my block directly either into content or top.container only :( If possible I would like to be able insert it anywhere else without changing local.xml or 1pagexxx.phtml. Is it possible in Magento ? – Rob D. A. Jan 3 '18 at 9:41
  • I dont know your module and where is this config, but if you want ofcourse display this block with some config you have to create in this module a new config in system.xml to have the entry config in BO, you have to use getStoreConfig() method, look my edit – PЯINCƏ Jan 3 '18 at 9:46
  • look my edit please – PЯINCƏ Jan 3 '18 at 9:53
  • I think this might be very useful however more important is how to insert my block without changing local.xml. I would like to have everything just/only in my module. – Rob D. A. Jan 3 '18 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.