title: Magento get layout for given page
body: <p>I'm working on a Magento module where i want to fetch the layout from a frontend page. By frontend page i mean all types of pages, i.e. cms page, category, product, cart, my account, etc.</p>
  
  <p>I've read the excellent magento-nofrills ebook from Alan Storm and i'm using his Commercebug plugin to help me develop my magento site. I've also spent some time on stackoverflow looking for a similair question, please forgive me if i have missed it.</p>
  
  <p>If for example i have a page id or category id, how do i fetch the layout of that frontend page from code run in the backend?</p>
  
  <p>I've been playing with the request and when i run this code in the frontend i can see that the module, controller, layouthandles etc are changed when for instance looking at a catalog page</p>
  
  <pre><code>$request = Mage::app()-&gt;getRequest();
  $request-&gt;setModuleName('cms');
  $request-&gt;setRouteName('cms');
  $request-&gt;setControllerName('page');
  $request-&gt;setActionName('view');
  $request-&gt;setParam('page_id', 6);
  </code></pre>
  
  <p>But when i inspect the xml from the layout, i can't seem to force magento to show me the xml for (in this example) cms page with id=6:</p>
  
  <pre><code>Mage::app()-&gt;getLayout()-&gt;getNode()-&gt;asXml();
  </code></pre>
  
  <p>Maybe i'm thinking way too complicated though. I would like to check if a certain page has sidebars, which blocks and elements are shown on the page and in the sidebars (only active blocks, not the ignored ones).</p>
  
  <p>Thanks in advance!
  Tim</p>