0

I have created two store views, each one for a different language. I created two static blocks, having the same identifier but different content (one in English and one in Russian) and each one is assigned to the corresponding store view.

Then, I created two categories, one for the English and one for the Russian language and assigned from the display settings the corresponding CMS static block. When I change language, the category changes accordingly and the static block content is loaded correctly. Now, I need to add one link on home page and the link should redirect me to this category page and display the correct static block content. For example when the user selects EN as language, display the English store view static block and when the user selects the RU as language, to display the Russian store view static block.

This is my code:

<h3 class="product-name"><a href="/family.html"> <?php echo $this->__('Family') ?></a></h3>

The problem with this is that family.html only loads in the English store view but in the Russian store view loads the page without the content (which is a different CMS static block). How can I change the reference in order to load the page and the content in both stores?

2 Answers 2

0

you should add the ___store parameter to the link

<h3 class="product-name"><a href="/family.html?___store=ru"> <?php echo $this->__('Family') ?></a></h3>

this will go to the "russian" store view (assuming "ru" as storeview code)

but you shoudl edit your question because is nto clear wht you mean for "selected" language.

if you are already in "russian" and you dont use the "store code for the url" you are in a serious trouble because Magento cannot understand if /family.html refer to the en or ru store.

Usually we use

/en/family.html

/ru/family.html (or better a locale version)

if you dont use the store code

/family-en.html

/ru/family-ru.html

Hope this helps

4
  • Thanks for the answer, how can I use the /en/family.html and the ru/family.html ? I am new in magento and I don't know how to make this change. Jul 15, 2014 at 11:43
  • Hy, login to magento admin, System>configuration>web and then URL Option. Set the "Add Store code to url" to yes. clear cache
    – Giuseppe
    Jul 15, 2014 at 12:03
  • I changed the store configuration and I have the /russian/ in the store url. Now, what can I use in the <a href=""> in order to change according to the store view so that I can have this result: /en/family.html or /ru/family.html ? Jul 15, 2014 at 12:28
  • Now you can refer to the Pronto answer using base_url should do the task for you.
    – Giuseppe
    Jul 15, 2014 at 12:51
0

I'm not really sure what you want to achieve, but I try to answer nevertheless.

To add a static block to your home page use following snippet (this goes to cms page content tab):

{{block type="cms/block" block_id="my-static-block-id"}}

This displays static block "my-static-block-id" which is assigned to the current view. To add links into static block use:

<a href="{{store url='my-page'}}">My Page</a>

This creates a link that refers to a page {base url}/my-page

One CANNOT "redirect" to static blocks as static blocks are not pages, they are more like complex page components (menus, footer blocks and so on), they only have meaning and value with context.

5
  • I edited my question so I can be more clear. I am not sure how to explain what I am trying to achieve here, thanks for your answer. However, I do not want to add link into the static block, I want to add link that will take me to the category that displays the static block Jul 15, 2014 at 7:29
  • Still -- you have two separate static blocks. You can make each of them point on different product. There's no reason whatsoever that they must have 100% same content.
    – Pronto
    Jul 15, 2014 at 7:58
  • They don't have the same content. I tried your solution and added the <a href="{{store url='my-page'}}">My Page</a> but the reference redirects me to a page with the following url: www.example.com/%7B%7Bstore%20url='my-page'%7D%7D Jul 15, 2014 at 8:51
  • Have you tried creating a URL redirect for the store view that you are linking to? Jul 15, 2014 at 9:26
  • @user1704524 no but I will try this solution. Jul 15, 2014 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.