Site: US UK AU |
Nexcess Blog

Updating an Old Theme to Work With Magento

August 1, 2011 4 Comments RSS Feed

Updating an Old Theme to Work With Magento

Many Magento store owners continue to operate old versions of the rapidly maturing e-commerce application. With the 1.6 release looming on the horizon, now seems like a good time to consider upgrading. If you’re running a version prior to the 1.4 release, you will need to make some changes to your theme in order for it to be compatible with newer versions. While the extent of these changes depends on the customizations you have performed, there are a few that we have run into consistently, and therefore apply them every time we perform an upgrade on an older store.

Changes to page.xml

Two changes to the stock page.xml file need to happen whenever you upgrade from a 1.3 release. First, you need to add a new javascript for credit card validation. Second, you need to add a “name” attribute to the core/profiler block.

To add the new javascript file:

  1. Open the page.xml file located in your theme’s layout directory using your favorite editor.
  2. Locate the “page/html_head” block near the top. You’ll see a list of <action> nodes like the following:
    &lt;action method=&quot;addJs&quot;&gt;&lt;script&gt;prototype/validation.js&lt;/script&gt;&lt;/action&gt;<br />
    &lt;action method=&quot;addJs&quot;&gt;&lt;script&gt;scriptaculous/builder.js&lt;/script&gt;&lt;/action&gt;<br />
    &lt;action method=&quot;addJs&quot;&gt;&lt;script&gt;scriptaculous/effects.js&lt;/script&gt;&lt;/action&gt;<br />
    &lt;action method=&quot;addJs&quot;&gt;&lt;script&gt;scriptaculous/dragdrop.js&lt;/script&gt;&lt;/action&gt;<br />
  3. Anywhere within that block definition, add the following line:
    &lt;action method=&quot;addJs&quot;&gt;&lt;script&gt;lib/ccard.js&lt;/script&gt;&lt;/action&gt;

To update the “core/profiler” block:

  1. Scroll down to the end of the <default> block and look for the “core/profiler” block type.
    &lt;block type=&quot;core/profiler&quot; output=&quot;toHtml&quot;/&gt;
  2. Add the “name” attribute as follows:
    &lt;block type=&quot;core/profiler&quot; output=&quot;toHtml&quot; name=&quot;core_profiler&quot;/&gt;

Save the changes to that file and clear the cache.

Changes to the Pager & Toolbar

The other theme update that occurred in the 1.4 release deals with the way the toolbar pager works. A Google search returns a number of different workarounds for this change, but I’ve found that the one offered in Magento’s release notes for works the best.

  1. Back up your theme’s toolbar.phtml file by renaming it to .orig or .bak:
    mv -v app/design/frontend/mypackage/mytheme/template/catalog/product/list/toolbar.phtml{,.bak}
  2. Copy the new toolbar.phtml file from the base package:
    cp -pv app/design/frontend/base/default/template/catalog/product/list/toolbar.phtml \<br />
  3. Open the catalog.xml layout file in your favorite editor and append this line:
    &lt;block type=&quot;page/html_pager&quot; name=&quot;product_list_toolbar_pager&quot;/&gt;

    Underneath this line:

    &lt;block type=&quot;catalog/product_list_toolbar&quot; name=&quot;product_list_toolbar&quot; template=&quot;catalog/product/list/toolbar.phtml&quot;&gt;
  4. You should find two locations in that file where you’ll need to add the new “page/html_pager” block.

Changes to the Wishlist Layout

Finally, a modification of the wishlist.xml layout file should take care of a change that occurred in

  1. Open the wishlist.xml file in your text editor.
  2. Find the following <reference> block:
    &lt;reference name=&quot;top.links&quot;&gt;<br />
        &lt;block type=&quot;wishlist/links&quot; name=&quot;wishlist_link&quot;&gt;<br />
             &lt;action method=&quot;addWishlistLink&quot;&gt;&lt;/action&gt;<br />
        &lt;/block&gt;<br />
  3. Replace it with the following:
    &lt;reference name=&quot;top.links&quot;&gt;<br />
        &lt;block type=&quot;wishlist/links&quot; name=&quot;wishlist_link&quot;/&gt;<br />
        &lt;action method=&quot;addLinkBlock&quot;&gt;&lt;blockName&gt;wishlist_link&lt;/blockName&gt;&lt;/action&gt;<br />

Keep in mind that for each of the above modifications you will need to clear the cache to see the change. These theme updates are ones we find ourselves making every time we upgrade a shop from the 1.3 release or earlier. So, if you don’t want to scrap the hard work you put into your designs, give these updates a try. Chances are, you’ll still find some bugs, but hopefully you won’t have to start from scratch.

Posted in: Magento