December 11, 2009

Custom Magento Pages using your Text Editor, not the Admin CMS

magento_ecommerceFor me, one of the most annoying things about Magento is the fact that the home page needs to be written in the Admin’s CMS. For that matter, any “custom” page you wanna build in Magento has to be done through the CMS.

I heart my text editors, and I hate writing HTML code into a CMS. It’s just not friendly. Tab indenting is impossible; if you hit tab your browser thinks you wanna select the next button! Think a textarea is gonna give you code hinting? Forget it!

Futhermore; I’m not a big fan of hosting files whose code I must edit regularly within the database. It’s just not practical.

Brad Frost recently blogged about the power of using Magento’s CMS blocks. I’m gonna take it one step further – let’s use the short code Brad Frost shows us in his blog to create custom pages that we can control through PHTML files in our theme; not code that is stored in the database. All you have to do is follow these steps:

  1. In the backend, create a new CMS page. Make sure to choose the appropriate layout (in the sidebar, click “custom design”) and enter in the page’s title, as well as it’s URL reference.
  2. Instead of writing your code in the textarea, stick this guy in there:
    {{block type=”core/template” name=”yourPageTitle” template=”cms/custom/your-file.phtml”}}
  3. In the above line, replace “yourPageTitle” with your page’s title – this isn’t terribly necessary, but good practice.
  4. More importantly, replace “cms/custom/your-file.phtml” with the directory that your PHTML file will be stored within the template folder of the theme you’re using. I store all my files in the “cms” folder under the template folder, and I created a folder called “custom” to store all my custom PHTML files. You can do the same or choose your own path; whatevs.

And that’s it! Save the page within the CMS, write some code into the PHTML file, and you should now be able to visit the URL you specified and see the code you wrote OUTSIDE of the CMS!

RSS feed for comments on this post.

  1. Pingback hate writing code into the magento CMS? then stop doing it http://sankhomallik.com/blog/2009/12/11/magento-pages-using-text-editor-not-cms/ | Magento News — March 2, 2010 @ 10:58 am

    [...] hate writing code into the magento CMS? then stop doing it http://sankhomallik.com/blog/2009/12/11/magento-pages-using-text-editor-not-cms/ Posted in December 17, 2009 ¬ 8:45 pmh.adminNo Comments » [...]

  2. burlap coffee bag — August 23, 2010 @ 12:35 am

    excellent writing .

Leave a comment

Best of Blog

  1. Let’s do the kids a favor: HTML as a classroom language
  2. USTORE.js – cross browser local and session storage
  3. Add Facebook Connect to your PHP Web App
  4. Setting up your website on Rackspace Cloud Servers – Manage Your Own Hosting
  5. Tutorial: Using Zend_Captcha_Image

Search if you must