简体   繁体   中英

Magento add banner to a custom phtml

i'm new to magento, I'd like to add a banner that I can handle using the CMS so I don't need to edit the HTML directly.

Actually I'm using a Static Block, so I can edit it and it shows up inside the page. I've read online some example using a widget, but it's not clear to me what is the advantage of a widget over a simple static block. By the way, the widget doesn't show up inside the page, as a result of a long googling it seems that may depend on the custom theme that doesn't support widgets...

How can I include a widget inside the page and/or re-enable the opportunity to choose where to place it inside the CMS?

What is the advantage of a widget over a simple static block?

I'm working on a magento 1.6

To show a banner or banner slideshow markup in your pages you may create a static block with the required html.

Then add it to any pages using a layout update. I prefer to use the app\\design\\frontend\\default\\absolute\\layout\\local.xml . If you haven't got it already, create this file then put the below xml in it.

Here the id of your static block is assumed as custm_slideshow . The below snippet is specific for the home page. But if you want to show it in all the pages, instead of <cms_index_index></<cms_index_index> use <default></default> .

<layout version="0.1.0">
    <cms_index_index>
        <reference name="content">
            <block type="cms/block" name="custom.slideshow">
                <action method="setBlockId">
                    <block_id>custom_slideshow</block_id>
                </action>
            </block>
        </reference>
    </cms_index_index>
</layout>

If you wanted to read more about widgets here is a good one , in case you missed it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM