Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
Page 2 of 4
Templating Magento… Useful Techniques & Tools
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

In case anyone needs the toolset:

The Ultimate FireFox Web Developer:
http://www.howtogeek.com/howto/internet/firefox/create-the-ultimate-firefox-web-development-profile/

Trust me… its very helpful.

 Signature 

nickL ~ i build stuff
Twitter me: twitter.com/ibuildstuff
My Blog: ibuildstuff.wordpress.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
Scott
Guru
 
Avatar
Total Posts:  319
Joined:  2007-08-31
Northwest Ohio
 

I have just about all of those. grin

 Signature 

Need a Magento designer? I specialize in helping developers and shop owners create Magento themes designed with aesthetic bliss, crisp refreshing style, and usability-focused design. Check out Tealo, the first public Magento theme!

Your Magento Partner for Stunning Creative Work!

 
Magento Community Magento Community
Magento Community
Magento Community
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

I know.. they’re great right?

Wanted to share the love with others..

 Signature 

nickL ~ i build stuff
Twitter me: twitter.com/ibuildstuff
My Blog: ibuildstuff.wordpress.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
Primary Numbers
Jr. Member
 
Total Posts:  17
Joined:  2007-09-03
 

Nick, Very nicely done.  Thanks for taking the time any information helps people figure out what is going on faster with the templating.

 
Magento Community Magento Community
Magento Community
Magento Community
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

Hey all… Here’s a brief update as to progress with Templating Magento.  It’s definitely coming along smoothly.  I’ll gather all my notes soon and post them to a Wiki or as supplementary documentation for any other material that gets published. I’m at work now… so this will be brief. I’ll elaborate more tonight.

LAYOUT / PAGE STRUCTURE

Your CORE Layout is defined by Default.XML.  Located /app/design/frontend/default/layout/core/

This does 2 things: 
1.) It definies the DEFAULT Layout for your store. By Default Magento uses a 3column layout, so it defines use of 3columns.phtml (Located in your template/page/ folder):

<layoutUpdate>

    <
block type="page/html" name="root" output="toHtml">
        <
action method="setTemplate"><template>page/3columns.phtml</template></action>

If you wanted to change your store to say, a 2column layout, you would change the line above to reflect the .phtml you’d like to use.
For example, If I wanted to change the store to a 2 column layout , I’d change the line read:
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>

2.) Default.xml creates “block containers” filled with application data for output to your .phtmls.  First, \ake a look at your standard 3column.phtml file you’ll see it calls a variety of “ChildHtml”:

(excerpt from 3columns.phtml - Starting at line 56):

<?=$this->getChildHtml('header')?>
        
</div><!-- [end] header --><!-- [start] middle --><div class="main-container">
        <
div id="main" class="col-3-layout">
       
        
<?=$this->getChildHtml('breadcrumbs')?>
            
<!-- [start] left -->
            <
div class="col-left side-col">
        
                
<?=$this->getChildHtml('store')?>
                <?
=$this->getChildHtml('left')?>
            
</div>
            <!-- 
[end] left -->

Each of these references point towards the “block containers” defined in your Default.xml and subsequent Module .xml files.  You’ll notice a container for the “left” column, for the “right”, for “content”, and other standard areas.  It serves up output for your .phtmls to use. Take a look at it:

/app/design/frontend/default/core/default.xml

<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>

        <
block type="core/text_list" name="left" as="left"/>

        <
block type="core/messages" name="global_messages" as="global_messages"/>
        <
block type="core/messages" name="messages" as="messages"/>

        <
block type="core/text_list" name="content" as="content"/>

        <
block type="core/text_list" name="right" as="right">

So basically your Default.xml creates Data Blocks, your .Phtml Outputs that data where you want it. Hence, the names for left, right and so forth in your .phtml.

Even further, Your MODULES will UPDATE the available “block containers” with more specific content. For example, you’ll notice once you navigate pass the frontpage and click a Category.. The “Compare Box” appears, Once you click down further.. “The Layered Navigation” appears. 

These blocks are made available via their specific initLayout.xml files.  These initLayout.xml’s UPDATE your default layout with MORE specific blocks.  So for the compare box to appear .. it is set to show once you click into the actual Catalog.  So it’s located at layout/catalog/initLayout.xml

Here’s the code:

<layoutUpdate>
    <
reference name="top.menu">
        <
block type="catalog/navigation" name="catalog.topnav">
            <
action method="setTemplate"><template>catalog/navigation/top.phtml</template></action>
        </
block>
    </
reference>
  
    <
reference name="right">
        <
block type="catalog/product_compare_sidebar" name="catalog.compare.sidebar">
            <
action method="setTemplate"><template>catalog/product/compare/sidebar.phtml</template></action>
        </
block>
    </
reference>

If you read the code.. and think about whats going on. It makes sense.  <layoutUpdate> is UPDATING your code with new blocks. How does it know where to put the new blocks?  Well remember in your default.xml you defined “block containers” for left, right, etc.  So when it says <reference name = “right"> it’s telling Magento to insert the following block into the RIGHT column when you get into “Catalog” view. (Remember, its located at layout/catalog/) so it appears once you’ve entered the catalog.  It also defines a TEMPLATE for the new block to use, so for the example above the compare box has its own template located at catalog/product/compare/sidebar.phtml (in your template folder).

I’ll elaborate a bit more later. But this should help a bit for some folks just getting started.  It basically just like this:

core/Default.xml ---> Defines “Block containers” (left, right, content, footer) full of Application Data for your .phtmls to use

specific Module .xml’s ----> Update your Default layout with NEW blocks to use specific for them, OR change the layout entirely to fit their needs

Template .phtmls ---> Create the design layout for the application and define the exact areas where you want the above “block containers” full of data to be placed.  Basically.. where you want the HTML output to be.  (left column, right column, content, header, footer, etc)

Hope this helps! I’ll try and post more notes later.

 Signature 

nickL ~ i build stuff
Twitter me: twitter.com/ibuildstuff
My Blog: ibuildstuff.wordpress.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
A.Piotrowski (Lento.pl)
Sr. Member
 
Avatar
Total Posts:  152
Joined:  2007-08-31
 

Nick, please tell me if i can use your notes in current documentation that i’m writing now. Maybe we can meet on IRC and share our knowledge :D . What do you think ?

My documentation is very detailed because i wanted to show every possible method, action, reference etc. that we can use in our layout xml. Therefore the chapter 2 of Designing for Magento isn’t finished yet.

You’re doing great work so i think that working together will speed up the whole process of creating documentation.

PS. maybe IRC isn’t the best idea because of my working hours so if you prefer, please send an email () with your concerns, questions, resolutions etc.

 
Magento Community Magento Community
Magento Community
Magento Community
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

AP,
Yeah DEFINITELY, I’d love to contribute.  Use all the notes you want!  I’ll send you an email and you can let me know where your at, and what you need help with. I’m definitely interested in helping though. Send me a PM, and maybe we can setup a time to chat (irc, gTalk, however). 

Thanks man.

 Signature 

nickL ~ i build stuff
Twitter me: twitter.com/ibuildstuff
My Blog: ibuildstuff.wordpress.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
mckooter
Sr. Member
 
Avatar
Total Posts:  91
Joined:  2007-08-31
 

through working on this ive been trying, starting to realize i need to brush up a bit on my css, Im getting all the pieces now, just having a struggle placing them together to form one idea of structure, slowly but surely

 Signature 

this signature could be much nicer

 
Magento Community Magento Community
Magento Community
Magento Community
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

McKooter,
Try out BluePrint CSS Framework.  http://code.google.com/p/blueprintcss/

It’s gods gift to css if you ask me… as much as I love developing , I hate having to start from complete scratch on every new site.  I started using Blueprint to build that general “structure"… then everything else flows from there.  And it’s real great for e-commerce sites since it’s easy make any # of columns you need.

I’ve been plugging Magento into it and it’s looking good.

 Signature 

nickL ~ i build stuff
Twitter me: twitter.com/ibuildstuff
My Blog: ibuildstuff.wordpress.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
mckooter
Sr. Member
 
Avatar
Total Posts:  91
Joined:  2007-08-31
 

thanks so much NickL, ill look into it, hopefully ill be able to get a better grasp on this, hows the implementation? easy with M?

 Signature 

this signature could be much nicer

 
Magento Community Magento Community
Magento Community
Magento Community
 
NickL
Sr. Member
 
Avatar
Total Posts:  188
Joined:  2007-08-31
 

Mckooter,
The implementation isn’t too hard once you get the hang of it. Make a test page outside of Magento first to get yourself familiar..  then use it within Magento.  Just look at the sample pages that come with the Blueprint package.

Actually, Now that I think about it. You only have to implement within your layout pages (3columns.phtml, 2columns.phtml etc) . Since those are the general layout files, I just used Blueprint to make my column framework and then plugged in Magento’s PHP statements. 

I’ll post a demo soon of a customized Magento front-end, I think that’ll help too.

 Signature 

nickL ~ i build stuff
Twitter me: twitter.com/ibuildstuff
My Blog: ibuildstuff.wordpress.com

 
Magento Community Magento Community
Magento Community
Magento Community
 
Scott
Guru
 
Avatar
Total Posts:  319
Joined:  2007-08-31
Northwest Ohio
 

I have my own blueprint that I work with on my projects. But I agree, it’s nice not to have to start from scratch every time.

 Signature 

Need a Magento designer? I specialize in helping developers and shop owners create Magento themes designed with aesthetic bliss, crisp refreshing style, and usability-focused design. Check out Tealo, the first public Magento theme!

Your Magento Partner for Stunning Creative Work!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brandon
Sr. Member
 
Avatar
Total Posts:  76
Joined:  2007-08-31
Web Developer
 

My blueprint’s in my head :D I always start from scratch, but I don’t mind it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
mckooter
Sr. Member
 
Avatar
Total Posts:  91
Joined:  2007-08-31
 
NickL - 08 September 2007 06:39 AM

Mckooter,
The implementation isn’t too hard once you get the hang of it. Make a test page outside of Magento first to get yourself familiar..  then use it within Magento.  Just look at the sample pages that come with the Blueprint package.

Actually, Now that I think about it. You only have to implement within your layout pages (3columns.phtml, 2columns.phtml etc) . Since those are the general layout files, I just used Blueprint to make my column framework and then plugged in Magento’s PHP statements. 

I’ll post a demo soon of a customized Magento front-end, I think that’ll help too.

thanks NickL, ive been playing a bit, definately much easier than my mediocre css alone, hopefully ill get the hang of it soon, i would like to create a new skin just to show something different

 Signature 

this signature could be much nicer

 
Magento Community Magento Community
Magento Community
Magento Community
 
A.Piotrowski (Lento.pl)
Sr. Member
 
Avatar
Total Posts:  152
Joined:  2007-08-31
 

Damn, i posted a reply in wrong thread. Sorry smile

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 2 of 4
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
52361 users|836 users currently online|105723 forum posts