I am new to Magento, and one of the things that I find inconvenient when studying the system is to bind a given element on the generated (X) HTML page to the name of the created block. I know System-> Configuration-> template path hints. However, it is very ugly, sometimes it changes the arrangement of elements on the page and does not display all the blocks (I think that it covers only blocks of templates).
The approach I tried is to change the toHtml() method in Mage_Core_Block_Abstract to add empty elements before and after the content, for example.
<blockStart xmlns="http://some/url" name="the_block_name"/> <blockEnd/>
(There may be a way to do this without modifying the kernel files, but at the moment I am not opposed to this approach, since it is only for my own use. However, any ideas are welcome.)
These elements give me enough information in the document to use the browser side jQuery .nextUntil() function to add data-magento-blockname to the elements between the blockStart and blockEnd elements. Then I can use these attributes to display a tooltip containing the full name of the "path" block to the content under the pointer at any given time.
The problem with this approach is that although Magento creates XHTML with strict DOCTYPE, it rigidly sets the Content-Type to "text / html" (see app/code/core/Mage/Core/Model/App.php line 1246 ) This means that the XML is interpreted by the browser as an βHTML soup tagβ, which leads to strange things - many of my tags disappear altogether, appear in the wrong places, or donβt close right away, so they contain different content. Also, not all HTML elements in a document are displayed in the DOM.
I tried modifying App.php to change the Content-Type to application / xhtml + xml, and this allows my mechanism to work successfully. However, it has some serious flaws:
- I had to disable add-ons, in particular Commerce Bug, which do not produce valid XHTML. Losing Commerce Bug is pretty bad, since I really want to access my page and batch XML viewer functions while my add-in is working.
- Most of the javascript included in Magento uses document.write (), which does not work with XHTML, so I get javascript exceptions and, apparently, some functions do not work.
Does anyone know of any solutions to these problems with my approach or know of some easier way to link the HTML elements in the output to the Magento blocks that produce them?
source share