Call-back icon  Sales: Call 800.374.8146 (N America)|757.278.0920 (International)

Magento

Open Source eCommerce Evolved

Magento Forum

   
Page 1 of 2
How to Add Specific Content to Home Page (from a phtml file)? 
 
Raymond Brigleb
Jr. Member
 
Avatar
Total Posts:  26
Joined:  2007-09-05
 

I’m trying to get a “welcome” banner to appear on the home page. I want the two columns, with the sidebar, but I want my banner to span the width of the page. The problem is that there’s no easy way to do so via the Magento home page editing interface - it doesn’t clear the right column.

I don’t need my users to be able to change this, really. I just want to detect if we’re on the home page or not from page/2columns-right.phtml, I’m thinking. I’ve looked around a bit, but I can’t figure out how to write a conditional that simply asks if that’s the current page or not.

Can anyone help?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1771
Joined:  2007-08-07
Los Angeles
 

1. Create a CMS block with HTML content of your banner and give it identifier “home_banner”
2. Edit 2columns-right.phtml and add <?=$this->getChildHtml('banner')?> where you’d like it to be.
3. In Home CMS page edit “Custom Layout Update”:

<reference name="root">
  <
block type="cms/block" name="top_banner" as="banner">
    <
action method="setBlockId"><id>home_banner</id></action>
  </
block>
</
reference>

 Signature 

- I would love to change the world, but they won’t give me the source code -

 
Magento Community Magento Community
Magento Community
Magento Community
 
Raymond Brigleb
Jr. Member
 
Avatar
Total Posts:  26
Joined:  2007-09-05
 

Moshe, thanks for your quick and helpful reply.

One point I am unclear on: in step 3, where exactly am I putting that code? I can’t figure out what you mean by “In Home CMS page edit Custom Layout Update.”

It seems like that’s an update to an XML file, but I’m not sure if that’s what you mean.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1771
Joined:  2007-08-07
Los Angeles
 

When you edit the CMS Page, right under Content textarea you should have Custom Layout Update textarea.

 Signature 

- I would love to change the world, but they won’t give me the source code -

 
Magento Community Magento Community
Magento Community
Magento Community
 
Raymond Brigleb
Jr. Member
 
Avatar
Total Posts:  26
Joined:  2007-09-05
 

Thanks again. Unfortunately, I’ve triple-checked my work, but it’s still not working. I even tried changing the reference to “top_banner” in your XML to “home_banner”, just be be sure it wasn’t a random typo. Looks like it wasn’t!

I’ll keep plugging away, and if I stumble across the answer, I’ll be sure to post it here.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1771
Joined:  2007-08-07
Los Angeles
 

Try to clean the cache in System > Cache Management.

I’ve tried this just before posted it, and it worked for me…
Should be working for you too smile

 Signature 

- I would love to change the world, but they won’t give me the source code -

 
Magento Community Magento Community
Magento Community
Magento Community
 
Raymond Brigleb
Jr. Member
 
Avatar
Total Posts:  26
Joined:  2007-09-05
 

No, I have all caching off in Magento, since I’m working on the layout and templates right now. But I did force them to clear, just in case there was some weirdness there. But alas, nothing weirder than usual.

When I preview the home_banner page, at /index.php/home_banner, I do see the banner image just fine.

When I preview (or normally view) the home page, it’s not there - no trace in the source or anything.

The concept I’m seeing is very interesting - that you can change the page layout from within a constituent piece of HTML by adding Layout XML. Note that this template, and all of my templates, are not in the ‘default’ interface, they are in a ‘custom’ interface that I’m working from. I think I’ve got those concepts right, and haven’t had any trouble with that up to now. But I was thinking that perhaps adding that XML to the home page might require some adjustment for this reason.

I will keep looking for a way to get this to work!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1771
Joined:  2007-08-07
Los Angeles
 

Mmm… why do you have home_banner page?.. it was suppose to be CMS block..

 Signature 

- I would love to change the world, but they won’t give me the source code -

 
Magento Community Magento Community
Magento Community
Magento Community
 
Raymond Brigleb
Jr. Member
 
Avatar
Total Posts:  26
Joined:  2007-09-05
 

Ah ha! Just a simple matter of following your directions correctly!

Working great now. Thanks so much.

 
Magento Community Magento Community
Magento Community
Magento Community
 
josh_trivera
Member
 
Avatar
Total Posts:  56
Joined:  2008-02-12
Wisconsin, USA
 

Lets say.. i wanted something more like… “header_links” to populate into a child phtml file from the admin CMS/Static blocks area.
(to match the functionality of footer links)

Instead of putting it directly into each parent phtml file (one column, 2 column, etc.) I am looking to keep it in the child header.phtml that they refer to as it will be on every page.

I plan to keep it inside of the <div class="header-nav"></div>

What would the referencing be then in:
the Child phtml file
and the static block.

Thanks, ill be testing.

~josh

 
Magento Community Magento Community
Magento Community
Magento Community
 
Camel
Jr. Member
 
Total Posts:  2
Joined:  2008-04-17
 
Moshe - 23 January 2008 01:12 PM

When you edit the CMS Page, right under Content textarea you should have Custom Layout Update textarea.

Hi.

In reference to above, there is NO Custom Layout Update textarea under Content textarea (please refer to the screenshot). Can anyone please help me out taking my first step. I’m using v1.0. Thanks.

Image Attachments
snap.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
Ajazza
Sr. Member
 
Avatar
Total Posts:  272
Joined:  2007-08-31
Brisbane, QLD, Australia
 

Click on “Custom Design” on the left.
Cheers
Adam

 Signature 

adam martin: internet consultant / web developer
contact | adam.martin@internetconsultants.com.au | +61 4 3331 3374 | skype adam.j.martin
http://www.tweakmag.com - Tweaking and Customizing The Magento eCommerce Platform

 
Magento Community Magento Community
Magento Community
Magento Community
 
alanin
Member
 
Total Posts:  64
Joined:  2008-02-25
Meuselwitz, Germany
 

is it possible to put a static block to a specified position in a phtml?

i am trying to write an own module to manage servicestuff and would like to have a text block above my form.

i were able to have the static block parsed below my formular or above the page-head, but not at the correct position, seems its controlled by the xml - i were also able to delete the getChildHtml part and the text was in my browser aswell…

Thanks for any hint.
Alanin // Joerg

my *.phtml:

<div class="page-head">
    <
h3><?php echo $this->__(' Header of my Page'?></h3>
</
div>
<?=$this->getChildHtml('textVorabtausch')?>
<form action="<?=$this->getFormAction()?>" id="registerForm" method="post" enctype="multipart/form-data">...

my *.xml

<layout version="0.1.0">
    <default>
    </default>  
    <
vorabtausch_index_index>
        <
reference name="root">
            <
action method="setTemplate"><template>page/2columns-left.phtml</template></action>
            <
block type="cms/block" name="textVorabtausch" as="textVorabtausch">
                <
action method="setBlockId"><block_id>text_vorabtausch</block_id></action>
            </
block>
        </
reference>        
        <
reference name="content">  
            <
block type="bcregister/formular" name="bcregister.form" template="vorabtausch/formular.phtml"/>
            <
block type="cms/block" name="textVorabtausch" as="textVorabtausch">
                <
action method="setBlockId"><block_id>text_vorabtausch</block_id></action>
            </
block>           
        </
reference
        <
reference name="left">
            <
block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
                <
action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
                <
action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
                <
action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
                <
action method="addLink" translate="label" module="customer"><name>rechnung_list</name><path>rechnung/liste/</path><label>abgeschlossene Rechnungen</label></action>
                <
action method="addLink" translate="label" module="customer"><name>vorabtausch</name><path>vorabtausch/</path><label>Vorabtausch</label></action>
            </
block>
        </
reference>  
    </
vorabtausch_index_index>
</
layout>

 
Magento Community Magento Community
Magento Community
Magento Community
 
overhaulmedia
Jr. Member
 
Total Posts:  12
Joined:  2008-05-23
 

I’m having a hard time getting flash to render from my homepage. I followed the instructions and it render the block but not the flash fully. It renders the right size and the runactivecontent.js is recognized.

Its just blank but the actual swf file renders fine from its location within a sub directory on the root level /flash/

This flash does use an XML file to pull JPG images into the flash. (slideshowpro)

On an important side note, how can I create a conditional static block? I need this static block to display on the homepage but every sub page it will be replaced with a static JPG half the height.

 
Magento Community Magento Community
Magento Community
Magento Community
 
vlad_md
Jr. Member
 
Avatar
Total Posts:  9
Joined:  2008-06-17
Global Citizen
 
Moshe - 22 January 2008 02:50 PM

1. Create a CMS block with HTML content of your banner and give it identifier “home_banner”
2. Edit 2columns-right.phtml and add <?=$this->getChildHtml('banner')?> where you’d like it to be.
3. In Home CMS page edit “Custom Layout Update”:

<reference name="root">
  <
block type="cms/block" name="top_banner" as="banner">
    <
action method="setBlockId"><id>home_banner</id></action>
  </
block>
</
reference>

Hello! I tried to do the same way, it worked, but I can’t get into the CMS block such code as:

<img src="<?php echo $this->getSkinUrl('images/section_1.jpg')?>" />
as it doesn’t interpret it, and output on front-end exactly. My question, is how to include an image in the custom CMS block, indicating the correct path with getSkinUrl?

thank you!

 Signature 

My Cocktail of Pixels
Magento Newbie

 
Magento Community Magento Community
Magento Community
Magento Community
 
suma_user
Jr. Member
 
Total Posts:  9
Joined:  2008-04-23
 

Hi ya,
I would like more help with knowing which tags you can place in to static blocks. Perhaps someone could prodce some examples? I did figure out that you can put an image in a static block by using the following syntax:

<img src="{{skin url=’images/filename.gif}}” />

Hope this helps smile
Amy

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 1 of 2
 
Sales: Call 800.374.8146 (North America) 757.278.0920 (International)
© Copyright 2008 Varien. Magento is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
33438 users|322 users currently online|74337 forum posts