You have an error in your xml, the <layout>
tag at the end should be closed, but I will assume that it's a copy/paste mistake and that is not the problem
Your problem is here:
<default>
<reference name="root">
<block type="core/template" name="page_head" output="toHtml" template="page/html/head.phtml" />
<action method="addCss"><stylesheet>css/normalize.css</stylesheet></action>
</reference>
</default>
What you are doing is:
- Referencing the root block in all pages, adding to it a block of type
core/template
that is using the page/html/head.phtml
as its template.
- Calling the
addCss
method of the page/html
block (since the root is of that type if you look in the page.xml
layout file)
What you should be doing is referencing the head
block as the addCss
function is in that one.
Now before answering your main question, I would like to put out a few remarks:
-
It is my understanding from reading the tutorials that Magento will load the default handle and apply to all the pages in this .xml file.
This is somewhat true, except that anything in the
<default>
handle, will applied website-wide, not just for pages of that particular layout file.
-
which class is used to load action method="addCss"? (I have looked in various Mage/Core/Block folders)
If you look at the
page.xml
file, you can find it. In fact there are 2 methods to add CSS files,
addCss
and
addItem
<block type="page/html_head" name="head" as="head">
<action method="addCss"><stylesheet>css/styles.css</stylesheet></action>
<action method="addItem"><type>skin_css</type><name>css/styles-ie.css</name><params/><if>lt IE 8</if></action>
<!-- etc. -->
</block>
From the type of the block, page/html_head
, you would be able to figure out that the block is Mage_Page_Block_Html_Head
. (It's in the format of module/path
)
-
how do I set up the .xml file to add css to the pages in my module?
Since you need the css to be ONLY in you module's pages, you cannot put it in the
<default>
handle. As it would be loaded in all pages throughout the website.
But what you can do, is create your own "default" handle, and make all other handles "extend" it.
So using all that info, this is how your XML would look like:tl;dr
<layout>
<!-- First we create the default handle that should be applied to all
of the module pages in this layout file-->
<user_register>
<reference name="head">
<!-- There is no need to reference the root handle, we just
reference the head handle and call the addCss method -->
<action method="addCss"><stylesheet>css/normalize.css</stylesheet></action>
</reference>
</user_register>
<!-- The next handle will match the BASE_URL/user/register/form path -->
<user_register_form>
<!-- This is the tag which "extends" the user_register handle-->
<update handle="user_register"/>
<block type="core/template" name="prefcentre_regform" output="toHtml" template="ps/prefcentre/signup.phtml" />
</user_register_form>
</layout>
-
where do I need to locate my css for magento to find them?
Since you used
css/normalize.css
as the path for the CSS file, it should be located at
frontend/default/default/css
and not inside a subfolder.
The problem you're experiencing is that .NET/C# is having trouble parsing the content type Magento is sending along with it's response. SOAP is notoriously finicky about receiving just the right stuff in just the right format. Couple that with PHP's rather poor implementation of the protocol and you're in for a lot of fun.
I'm looking at a Magento 1.9 for the following information:
After some digging I found that the header for the SOAP calls are set in app/code/core/Mage/Api/Model/Server/V2/Adapter/Soap.php
on line 52.
51. ->clearHeaders()
52. ->setHeader('Content-Type','text/xml; charset='.$apiConfigCharset)
53. ->setBod...
Note that that Content-Type header matches your text/xml; charset=utf-8
desired charset. Adjusting line 52 to:
52. ->setHeader('Content-Type','text/xml; charset='.$apiConfigCharset, true)
tells Magento to force overwriting that header if it's already set.
Make sure to make a copy of the file with it's full path to the app/code/local/Mage/...
to avoid overwriting core files. You'll thank me when you want to upgrade Magento at some point.
Also, make sure to look carefully, there's two setHeader() calls in that file.
And finally, there's also a WS-I compliant SOAP adapter available, the same fix applies to that file. You can find it in app/code/core/Mage/Api/Model/Server/Wsi/Adapter/Soap.php
.
Best Answer
This is not possible. Because..
Proof :
head
block stands forMage_Page_Block_Html_Head
and by default it usespage/html/head.phtml
file. Inside that file, you can see thisFrom the above code, it is obvious that, blocks included in
head
section will get rendered "later".So you can probably go with below method. It may work in your case.
You need to add
menu_default.js
inside the phtml file itself.That is your layout update xml should only contain the phtml file.
Here you need to make sure the above
js
block type is actually valid and does define inside magento block section.Next update your
global.phtml
file with this content.This way javascript variable
BASE_URL
is now defined beforemenu_default.js
and hence you can get the value inside that file.