Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6367463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:33:02+00:00 2026-05-25T00:33:02+00:00

Is it possible to create a layout file inside of a module ? How

  • 0

Is it possible to create a layout file inside of a module ? How ?

For what:
I want to add a some kind of statistics hit counter for products, and I don’t want to override the products class, as that is already done by some module I’m using. Thus I thought it would be best to have a custom module with a block that would be called by a layout statement.
Of course I could easily edit my private local.xml or make changes to another layout-xml in the layout folder of my theme, but I want this feature to be available in all themes (independent of any selected theme).

Some constraints:

  • All code in one single module
  • … so that it is theme independent
  • … so that the module can be shared with others without them having to change anything (like theme files), so that the install/load of my module would be enough

I would also accept different approaches for my statistics hit counter loading (using the same constraints)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:33:02+00:00Added an answer on May 25, 2026 at 12:33 am

    Yes it is possible. Just create your layout xml file in the following path: /design/frontend/default/default/layout/yourlayout.xml(or whatever your theme name is), and add a proper statement in your modules etc/config.xml:

    <config> 
     <frontend>   
      <layout>
        <updates>
          <yourmoduleshortname>
             <file>yourlayout.xml</file>
          <yourmoduleshortname>
        </updates>
      </layout>  
     </frontend>
    </config>
    

    This sample is for frontend user, but adminhtml layouts can be updated in a similar manner. If something doesn’t work, be sure to check if your layout is in the proper theme/package directory.

    Edit:

    Second approach:

    You can use a controller of your own, which will extend the core functionality (one of the catalog controllers) – just rewrite it (or just product view action). Inside its action method add something like this:

    $thiss->getLayout()->createBlock('namespacename/block','layout-block-name',
    array('template' => 'relativepathtotemplate.phtml'));
    $this->getLayout()->getBlock('content')->append($block);
    run-original-parent-code();
    

    Third approach:

    Similar to the previous one, but you can use some event observer, and try Mage::getSingleton('core/layout'), and inject your block there. Not in all events the layout will be already available (try the post_dispatch family).

    I don’t really recommend the second and third approach, because if someone else wants to find where this ‘magic’ block comes from, it will most surely look int app/design/(…) directory. Finding it in your controller or model, may be very tricky…

    If you don’t want to display your statistic counter, you can also use events (like post_dispatch) to count the controller dispatches. Just create an observer attached to it, and store your data in the DB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if it were possible to dynamically create an XML layout file
I want to know whether it is possible to use an xml layout file
Is it possible to create a .CSS file for each SharePoint Page Layout I
Is it possible to convert R.java into layout file xxx.xml.. In some project which
Possible Duplicate: Create Excel file in Java How to save output in excel format
Is it possible to create a custom library in Android (having its own layout
I want to create my main UI like this one: http://lh3.ggpht.com/RYB2ckycDc_4rb2bmsDzqLLmYcj37xDOA7d7sR6XIVfwRb3a44_HqMqfb1vdmtxTEidenVY4C9RcTREl Is it possible
In my Android application I create the layout programatically (ie an xml layout file
I'm having some trouble shaping the form layout the way I want it to
I try using Devexpress Layout-Control (For costume usage). So I want add all item's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.