Magento – Assigning a custom CSS-file to a store

csslayoutmagento-1.9xml

This question has been "half-answered" already here:
custom CSS-files for single storeviews

However I can't make it work just yet, so I need some additional explaining, if you'd be so kind.
This is the answer from the related question:

Use the STORE layout handle:

<?xml version="1.0"?>
><layout version="0.1.0">
>    <STORE_en>
>        <reference name="content">
>            ...
>        </reference>
>    </STORE_en>
></layout>

Where en is the code of the store in question. This will add the layout changes to all >pages for that store in the same way as the layout handle does for all pages of >all stores. By default there is no way to use the STORE layout handle and only have >layout changes for certain pages in that store.

And this is where I need a bit more explaining:

</default>

<STORE_hafner_de>
    <reference name="header">
        <action method="addCss"><stylesheet>css/hafner.css</stylesheet><params>media="screen"</params></action>
    </reference>
</STORE_hafner_de>

that </default> is just to show that <default> is closed.

So how do I reference a block used in the <default> layout already, so I can add a css-file to the store-view in question (hafner_de)?

If you need more code or whole files, I'll be happy to provide you with those.
I know I'm going to need this often, because we are currently working on opening a multi-store with different layouts, images and css-files.

Thanks in advance

edit: If I understand this correctly, and I don't think I do, I have to add the code like this:

<STORE_hafner_de>
        <block type="page/html_head" name="head" as="head">
            <action method="addCss"><stylesheet>css/hafner.css</stylesheet><params>media="screen"</params></action>
        </block>
</STORE_hafner_de>  

or do I say <reference name="header"> instead of <block name="head">
Because if I just add the css file, it's working (but for all stores)

Best Answer

I fixed it myself. Thanks again, Johnathan Hussey, for the answer.

I had to enter the code like this:

<STORE_hafner_de>
        <reference name="head">
            <action method="addCss"><stylesheet>css/hafner.css</stylesheet><params>media="screen"</params></action>
        </reference>
</STORE_hafner_de>  

Apparently there's some trouble when selecting a single block per <block>, but calling the block's name as reference works.

Related Topic