3

I added several pages (cms) in my Magento admin panel. I know I can attach blocks to a specific page by using {{block..}} within the content field.

I do not want to define blocks there, but within the cms.xml file. So other store admins are not annoyed by weird codes ({{block..}}) in the backend editor.

I defined the index/home page with the following xml tag:

<cms_index_index>
    <reference name="content">
        <block... />
    </reference>
</cms_index_index>

How can I define other cms pages (by id or seo-identifier) within cms.xml?

I tried defining them by;

<cms_page_[seo-ident]>
<cms_pageid_[id]>
<cms_[seo-ident]>
<cms_[id]>

3 Answers 3

4

I'm not super familiar with the CMS module, but I can tell you how to get the XML tag/handle (cms_index_index) for any page in your system.

You should now see a list of "handles". Handles are used to identify particular requests. For example cms_index_index is the handle that identifies a request for the CMS module's index action on the its index controller. You should see similar handles on your other CMS pages.

If this works post a follow up in the comments, I'm curious how the CMS handles are formed and haven't had time to search it out.

Update: I've done this on a testbed install of Magento that I have kicking around. I created a simple CMS page available at the following URL

http://example.com/index.php/this-is-my-identifier

And I got the following handles

  1. default
  2. cms_page
  3. STORE_default
  4. THEME_frontend_default_default
  5. cms_page_view
  6. page_one_column
  7. customer_logged_out

So, based on this, it looks like Magento doesn't create an individual handle for each CMS page (I'm kind of surprised the cms_index_index you mentioned above works ... which means there's probably something going on I don't quite understand).

So, what I'd try to do is define your blocks within a <cms_page> or <cms_page_view> tag. That should make them available to all your CMS pages.

1
  • Would you care to update this answer or is it no longer worth it? I would be interested to see what you have learned on this.
    – 1984
    Commented Dec 15, 2016 at 9:20
0

Wow Alan Storm is not familiar with CMS module, it is surely a very old thread.

It's on the top list when I Google-ed it though

Matthias Zeis provide a nice answer for this: https://magento.stackexchange.com/questions/289/cms-xml-handles-for-layout-updates

Basically the idea is to observe event cms_page_render and then we define our own handle.

0

Well, Magento is not so easy to handle in terms of the layouts. You can check this blog entry of my own, even when it doesn't explain about blocks specifically I think it might help you understand how the custom layouts work with CMS pages.

Once from there, you might get a clearer idea of the process.

I hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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