Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Add static block to Contact Us page
 
e_mick
Jr. Member
 
Total Posts:  8
Joined:  2008-04-10
Melbourne, Australia
 

I hope someone can help.
I have some html, and css knowledge that has served me well to date - but am finding Magento tough.

I want to add physical address information and a location map image for my (physical retail) store to the Contact Us page.  Currently (default) the page only has a title and the Email Contact Form in the main content area.
I have been experimenting with creating a Static Block (identified as “address_block"), then having this Block called/inserted into the Contact Us page above the Email Form.

I must confess however, I do not understand how to achieve this and I have not been able to get it to display at all.  Can someone please provide a step-by-step on how to achieve this, including code snippets and where (and in what files) to put them.

CMS static block title: Address
Identifier: address_block
Content: div’s positioning postal address, actual address, opening hours, and a location map GIF which hyperlinks to Google Maps.

To be called by/positioned in: Contact Us page (below Contact Us title and above Email Contact Form)…

You’d think this would be so easy with CMS managed pages???

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

ok, you created static block with title Adress and identifier address_block and it should be shown within content area of contact us.

So you have to customize contacts.xml located in /app/design/default/default/layout/contacts.xml or if you have a own layout
/app/design/yours/yours/layout/contacts.xml.

Open contacts.xml and add following code to <reference name="content"> node

<block type="cms/block" name="cms_address_block" before="contactForm">
              <
action method="setBlockId"><block_id>address_block</block_id></action>
</
block>

Code should then look like this:

<contacts_index_index>
        <
reference name="root">
            <
action method="setTemplate"><template>page/2columns-right.phtml</template></action>
            <
action method="setHeaderTitle" translate="title" module="contacts"><title>Contact Us</title></action>
        </
reference>
        <
reference name="content">
            <
block type="cms/block" name="cms_address_block" before="contactForm">
              <
action method="setBlockId"><block_id>address_block</block_id></action>
</
block>
<
block type="core/template" name="contactForm" template="contacts/form.phtml"/>
        </
reference>
    </
contacts_index_index>

Cheers

Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tiff
Sr. Member
 
Avatar
Total Posts:  107
Joined:  2008-03-25
Upstate NY
 

I found that it was easier to just add HTML to the contact page than create a static block.

I edited the form.phtml in the contacts folder under apps/design/templates.

Click here to see my contacts page with form.phtml edits.

 
Magento Community Magento Community
Magento Community
Magento Community
 
e_mick
Jr. Member
 
Total Posts:  8
Joined:  2008-04-10
Melbourne, Australia
 

Thanks Stefan,
That got it working!
It’s people like you who make OS communities work, and OS solutions workable for their users (particularly those like me who have limited programming knowledge). I really appreciate it.

Tiffany,
I had initially simply added HTML to the form.phtml page as you suggested - it certainly seemed like the solution to me… however it occurred to me that directly editing the form.phtml page would not be upgrade-compatible. Am I right in thinking so?

I want to ensure that the edits I make are not lost in the ether when Magento recieves a new version.  Part of why, like Stefan mentions, I SHOULD be creating my own theme/layout updates.  Right now I applied those edits to contacts.xml in /default/default/.  When Stefan suggested my own theme/layout, I created a /mine/mine/ directory path and placed a copy of contacts.xml in there, then edited that as suggested, and used the Admin backend to set the design to /mine/mine/ - however when I reloaded the Contact Us page I got a blank page??? Back to the (not-so-easy-to-follow Designer’s Guide for me I think).

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tiff
Sr. Member
 
Avatar
Total Posts:  107
Joined:  2008-03-25
Upstate NY
 

Hmm...good point.  I never really think about the updates when I’m editing.
I’m going to use your block idea now after all!

THANKS!

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 
e_mick - 09 May 2008 11:56 AM

Thanks Stefan,
Tiffany,
I had initially simply added HTML to the form.phtml page as you suggested - it certainly seemed like the solution to me… however it occurred to me that directly editing the form.phtml page would not be upgrade-compatible. Am I right in thinking so?.

Actually I think it’s the other way around, but both approach require manual update anyway!
With Stefen’s method, you need to edit the ‘contact.xml’.  When you do upgrade, the newest Magento will not recognized whatever extra stuff you added to the ‘contact.xml’ or other files in the ‘layout’ folder.

As for Tiff’s method. it’s the same. Whatever block(s) you added, won’t be recognized by newest version Magento anyway.

From a web design’s point of view, I much prefer Tiff’s method for the reason that I am in full control of the layout/theme, and it’s easier because you only need to add the html code directly to ‘.phtml’ file, that is, if you don’t move the structural blocks around that requires further modification on ‘.xml’ files in the layout folder. With Stefen’s method, in additional to adding a block type in the ‘.xml’ file, you also need to create a new ‘.phtml’ file.

IMHO, I think people who kept saying to keep the update compatibility have got the concept all wrong - the only way you can have this is you store looks exactly like the demo site, except the Skins part that you change the colors, widths images, font size etc.

To me, what is important is not to add/edit anything in the ‘code’, so that I can have a better control with each update.

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

You can create your own theme and put the contacts/form.phtml with your custom content there.
Change in admin > configuration > design > default theme = “mycustomtheme”

All the files you have in your theme will be used, and will fall back to /default theme for missing templates.

This way you will not loose your customizations on upgrades.

To include in .phtml file a CMS block without changing xml layouts:

<?php echo $this->getLayout()->createBlock('cms/block')
    ->
setBlockId('my_custom_block')->toHtml() ?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 

Great tips! Moshe. Thank you for pointing that out.

I have a question: In the earlier testing (v0.7x), I created my own theme, when the system couldn’t find my custom content in my theme, it loaded the default theme.  Problem is, if I am using my own design, I don’t want the system loads the default theme when it finds something missing in my theme.

Will your approach shows the default theme when the system can’t find the custom content?

Hmmm, I am thinking maybe I didn’t setup my theme probably last time!

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

@chinesedream: sorry, i didn’t understand the question.

If you want no fallbacks to default templates, you will have to create a new interface.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 

Ah sorry tongue laugh let me explain my thinking again.

First, I fully understand the logic behinds the fallbacks, to default template.

You said:

Change in admin > configuration > design > default theme = “mycustomtheme”
All the files you have in your theme will be used, and will fall back to /default theme for missing templates.

My earlier test showed that, when a custom content was not included in the ‘mycustomtheme’, Magento loads the page from the ‘default’ package. The fallback is a prevention for page showing error codes, this I understand, but from the usability point of view, this defeated the purpose of having to create a new custom theme when I have only one website, one store because I only wanted the page shows my custom theme when something is missing or error occurring.

So, unless I am not fully understand (very likely!) how the default theme works in relation with the fallback feature, the way I look at it, is I am having two choices with upgrade compatibility :

1) A bit more work - Overwrite the ‘template’, ‘layout’ and ‘Skin’ from the default package to my custom theme, and with each upgrade, I replace them back. Thought insignificant, it does save server space because there isn’t a Default package taking up space.

2) Keep the upgrade compatibility runs hassle free, use the Default Theme with fallback feature, but when something is missing in my custom them, my site visitor gets panic because she is seeing a Magento demo page, and the reason she is seeing the Magento demo page is because it’s very unlikely I will spend time to make the Default package looks like my custom theme as it will be like asking me doing double work for the same task.

This looks more like a design decision one needs to make smile

Sorry if I am still not making my point!

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

Did you consider creating a new interface?

app/design/frontend/chinesedream/default/template/…

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 
Moshe - 09 May 2008 03:26 PM

Did you consider creating a new interface?

app/design/frontend/chinesedream/default/template/…

Moshe - 09 May 2008 03:26 PM

Did you consider creating a new interface?

app/design/frontend/chinesedream/default/template/…

No, I did not red face Actually I didn’t quite understand when you said I will have to create my own interface - I thought you were implying that this is how it works, and if I don’t like it, then create my own system.

Thank you so much for repeating the *question*, I don’t ever remember if I read something about creating a new interface before. I thought we can only have
app/design/frontend/default/custome_theme/template

Will definitely try it out. Does is only involve with frontend?

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

The way Magento’s theming is setup is pretty slick.  What Moshe means is that you can have interfaces and themes.  An interface contains themes so for instance you can have:

Default Magento Install:
app/design/frontend/default/default/template/…
-The first default (frontend/default) is the interface name and the second default (default/default) is the theme name.

Custom Theme in Default Interface:
app/design/frontend/default/mycustomtheme/template/…
-The first default (frontend/default) is the interface name and the second mycustomtheme (default/mycustomtheme) is the new theme name.

Custom Theme in Custom Interface:
app/design/frontend/mycustominterface/mycustomtheme/template/…
-The first mycustominterface (frontend/mycustominterface) is the interface name and the second mycustomtheme (default/mycustomtheme) is the theme name.

The point of all of this is to allow you great flexibility in theming.  Say for example you want to create seasonal themes (in the designers guide per example).  You can create a new custom theme in the default interface and then use it when a different season comes around.  This lets you create say packages of themes, a bunch of like-minded themes that are contained in one interface.  You can then create an entirely new interface to contain a bunch of different themes for a completely different look.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
lotusseedsD
Mentor
 
Avatar
Total Posts:  1144
Joined:  2007-08-31
 
alistek - 09 May 2008 05:16 PM

The way Magento’s theming is setup is pretty slick.  What Moshe means is that you can have interfaces and themes.

The point of all of this is to allow you great flexibility in theming.  Say for example you want to create seasonal themes (in the designers guide per example).  You can create a new custom theme in the default interface and then use it when a different season comes around.  This lets you create say packages of themes, a bunch of like-minded themes that are contained in one interface.  You can then create an entirely new interface to contain a bunch of different themes for a completely different look.

-Adam

Hi Adam, yes. Thank you for further explanation. That helps a lot smile

I am totally with you - the more I understand how Magento works, the more I appreciate how great this system is and the great effort and the vision the Varien team has for the software. And I have had better days working on Magento these past weeks smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
turnon
Sr. Member
 
Total Posts:  129
Joined:  2008-02-20
 

Question

i want a diffrent layout for some pages
for example content pages with diffrent staic blocks

content page 1 static block 1 and 2 and for
content page 2 staict block 3 and 4

do i create a new theme for it or are there other possibilities

thanx in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
davidgrun
Sr. Member
 
Total Posts:  245
Joined:  2008-07-10
 

This worked perfect… on question.  My website is in Spanish and English, whats the method to have the address_block change from one language to another (Locale is EN = english_address_block, Locale is Spanish = spanish_address_block)?

Do I need an if statement somewhere or is there something I´m missing in the block CMS gui?

thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top