4

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> 

2 Answers 2

4

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.

3
  • That is nice but does not work for me. I have two stores and the custom variables are always global for all stores. Commented Sep 25, 2014 at 9:24
  • @PiTheNumber Has this changed in ce 1.9? I have a store view switcher when I edit a custom variable. I have updated the answer with other options available. Commented Sep 25, 2014 at 12:14
  • Oh, right. It shows after save. Thanks, that would work! Commented Sep 25, 2014 at 12:29
1

The right way is:

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

with "".

It's work for me.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.