Magento CE 1.9.0.1 – Using Variables in Static Block for Email Template

ce-1.9.0.1email-templatesstatic-block

I used a static block in my email templates

{{block type="cms/block" block_id="mail_include_header"}}

Now I would like to use variables like {{var logo_url}} in that block but it does not resolve it. Instead {{var logo_url}} get's printed out into the mail.

I would like Magento to show the logo url.

I tried things like

{{block type="cms/block" block_id="mail_include_header" logo_url="{{var logo_url}}"}}

Of course this only breaks it completely… I read that you can pass variables using the xml layout but no idea what layout is used here.

I also tried:

{{block type="cms/block" block_id="mail_include_header" logo_url=$logo_url }}

But that also did not work.

Update: Half solved

Feels like this is a bug because this is working:

{{block type="cms/block" block_id="mail_include_header" }}
{{var logo_url}}

If I use the variable in the mail template I can also use it in the included block. Otherwise I can not. Still I did not found the responsible code in app/code/core.

As a workaround I will include and hide the needed variables in the main template. Until someone can bring some light into this:

<div style="display:none;">{{var logo_url}} {{var logo_alt}}</div>

Best Answer

The logo_url variable is only available to the email template and not to the cms block.

What you could do is: Create a custom variable under System->Custom Variables called logo_url and then include: {{customVar code="logo_url"}} in your block.

In addition you could set:

{{media url="email/logo/"}}{{config path="design/email/logo"}} 

if you have uploaded a logo.

Or

{{skin url="images/logo_email.gif"}}

if you are using the skin directories.