|
I have also searched for this list of handles, and reached the conclusion that it does not exist, simply because it will change from one install to another - simply depending on what themes and modules are available.
To try and get my head around the themes (and that is *really* hard to do) I am putting together a script to provide theme reports for me. It is possible through admin settings to see what templates are being rendered, but it is not so easy to see - or predict - what is invoking those templates in the first place.
The first draft of my script is running here on a stock Magento 1.4 installation:
http://magento.consil.co.uk/themes.php
It will simply allow you to chose an interface and a theme, and then list all the layout files that make up the theme. For each layout file it will list all the handles that it contains.
By clicking on the “handle” link, you can flip that relationship up-side-down and view all the layout files that contain a specific handle. Clicking on the handle will then list the XML from those layout files.
I intend to keep expanding the script as I learn more about how the themes work. Being able to drill down into the detail of the handles, listing all the widgets, menus, templates etc. involved would be the next step. Putting some documentation against the handles would also be a good idea.
Eventually I would like to be able to see at a glance where the rendering for any particular item on the screen is coming from, and from there be able to see at a glance where else in the shop that item will appear. I would like to see where things are being added to menus (in the layout files at least - I’m sure there is just as much going on in the code to manipulate menus, but hopefully not too much).
It has taken writing this script to understand exactly why Magento themes are so hard to do: it is simply that in any page render, the layout can be affected by *any* module, *any* layout file, and *any* widget could get inserted. You can’t just look at one file to determine how a page is built, because *all* the files in a theme are involved in *every* page.
Here is an example:
http://magento.consil.co.uk/themes.php?interface=default&theme;=modern&group;=handle&handle;=catalog_category_default
This is looking at the handle “catalog_category_default”. It shows that four layout files contribute to this handle, and lists the actions that each performs. What isn’t clear yet is just how this handle gets “invoked” - is it always from some single point in the application code, or could it be from widgets or other handles too? If it is, then that explains why the Magento themes can get even hairier (scarier).
Beyond the handles, the references also need to be extracted. When you see something like “customer_account_dashboard” as a reference - what on Earth does it mean? What does it represent and where do I find it? That bit I don’t understand fully yet. I realise the three parts to it customer/account/dashboard should help to find that - in this case it points us towards app/code/core/Mage/Customer/controllers/AccountController, where I can see a block called “customer/account_dashboard” is created, which (I think) leads to a template at app/design/frontend/base/default/template/customer/account/dashboard.phtml. But writing a script that can interpret that code and extract that information to help a theme developer - maybe that is asking too much?
I always tell my colleagues that writing a Magento theme is a one-way process: you can write a theme from scratch, but trying to reverse-engineer an existing theme is nearly impossible.
-- Jason
|