Jump to content

If language equals


Recommended Posts

I bought the "Additional Product Fields" Plugin.

Unfortunately those fields are for all languages. I want to use them to add language sensitive Downloads to a product page.

So I am wondering how I can select parts depending on language.

For example like this

{if $language == EN}

<div style="margin-top:50px;">{$SFWS_ADDITIONAL_PRODUCT_FIELD_01}</div> // Show field with english content

{/if}



{if $language == DE}

<div style="margin-top:50px;">{$SFWS_ADDITIONAL_PRODUCT_FIELD_02}</div> // Show field with german content

{/if}

Obviously "$language == Whatever" is made up. How would the correct syntax be for this?

 

Thanks

Coffee

Link to comment
Share on other sites

I think that is a good approach, but (of course) more analysis of the plugin's code would need to be made.

The five-character language codes can be found in the /languages/ folder.

"Language-sensitive downloads."

Would these downloads be product-oriented files, but not what are considered downloadable products (MP3s, apps, PDFs, etc). Currently, downloadable digital products are limited to one file associated to that product.

 

Link to comment
Share on other sites

You are correct. They are not downloadable products but they are like manuals and flyers for those products that are free to download for everyone.

The plugin basically just adds html wherever you paste in your.

{$SFWS_ADDITIONAL_PRODUCT_FIELD_01}

(or 02, 03, to 08) in your skin.

So basically all it did was adding 8 fields to the database and adding the input fields to the backend.

My question was more about the syntax for the language if-query which is not related to the plugin but to cubecart itself.

Edit: I just recalled that I think I asked that before and the solution was 

{if $current_language.code=='de-DE'} 

and 

{if $current_language.code=='en-GB'} 

- I will try that, but that should work actually.

Edit2: Strangely it did not work. The if-query seems to be always "no", so the PDFs do not show. Strange.

The following works in box.search.php

{if $current_language.code=='en-GB'}
		 <img alt="Invoice payment" src="/images/source/invoice-payment.png" align="right" style="margin-right:8px; margin-top:10px">	{/if}

But this does not work in content.product.php

			   {if $current_language.code=='de-DE'} 
					{$SFWS_ADDITIONAL_PRODUCT_FIELD_03}
				   {/if}

 

Link to comment
Share on other sites

Hopefully, in a later version of CC, this will be fixed (requires a major rewrite).

CubeCart first populates and renders the main content. Then, one at a time, populates and renders the outer areas.

If, for example $current_language is first seen and populated in an outer area (the language selector in the header area), then when rendering the main area, which comes earlier, that template variable is not yet available.

So, we need to find a variable that is available right from the start.

You can try:
$CURRENT_LANGUAGE (mind the lettercase),
$CUSTOMER.language,
$HTML_LANG (probably too late),
($current_language is a loop variable from $LANGUAGES that populates a language selector - not available outside the loop)

If none of the above work, we will need to add the code to get it to the template in time, or enhance the plugin.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...