Reputation: 4293
I have been asked to update a Magento site, however, I have not had much experience with Magento in the past. So far, I have been able to apply the changes required, but I have just hit a road block, and cannot find where a certain bit of code is stored.
The code in question is right at the beginning of the body
section, but it is located before the beginning of the header.phtml
file. I have also looked in the head.phtml
file, but it is after that. There appears to be a block of about 15 elements (including a google analytics script) that appears after the opening body
tag, and before the header.phtml
content. I have checked the static blocks, but cannot find anything in there. Does anyone know where else to look?
EDIT
I have been checking the included files, but so far, I cannot identify which file the code is located in. I had done a test to see what files where being included and when, and I have determined that the /Mage/GoogleAnalytics/Helper/Data.php
file is being included, then the notices.php
file, and when inspecting the code, I can see that the code is being included right after <!-- END GOOGLE ANALYTICS CODE -->
, and right before the notices.php
file is included.
Upvotes: 0
Views: 1382
Reputation: 4293
At last, found it. It was within a file called 1columns.phtml
which I had assumed contained only layout information for a part within the page, but it contained the functions that called the header, notices, and the other code. I found it with a php script written to do a recursive search through all the files within the director /app
searching for the unique identifier
Upvotes: 2
Reputation: 166076
Unfortunately, the HTML you need to edit could be anywhere. It might have been added via a phtml
block in the layout (app/design/
), or it could be be coming from PHP module code in an observer (app/code/community
, app/code/local
, or even app/code/core
if someone's dropped a core hack in place).
There's a few ways to approach solving this. First, turn on Template Path Hints for your store view (it won't show up for the default configuration scope)
System -> Configuration -> Developer -> Debug
This will make your frontend render with outlines around most of the block on the page.
It that doesn't help, use grep
, ack
, or your favorite text-searching program to search the entire source tree for a unique bit of HTML from the part you're trying to edit.
Finally, there's more powerful, Magento specific debugging tools available. I sell one called Commerce Bug (demo), this article includes a description of it's block diagramming features, which would be applicable to the problem you're currently facing. If you're going to be doing a lot of Magento work, it's worth investigating a tool like this.
Upvotes: 1
Reputation: 5685
Use Firebug. Inspect that HTML element and find to see if you can identify the class or some other naming thing to know which block is rendered
Turn on template path hints, you will come to know which template is used to display that HTML. You can then easily find the Block attached to it.
To turn template path hints: System >> Configuration >> Developer, change Current Configuration Scope to website >> Debug Template Path Hints, set it to Yes.
Upvotes: 2