Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

HTML blocks - language variable not showing correctly Rate Topic   - - - - -

 
  • Maky
  • Advanced Member
  • Members
  • Join Date: 16-Nov 11
  • 71 posts

Posted 18 February 2012 - 04:39 PM #1

Hi guys,

I created HTML block with <div> tags but {$lang.sign_in} or any other variable is showing in block as "{$lang.sign_in}" not its value.
Anybody can help?

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11306 posts

Posted 19 February 2012 - 06:24 AM #2

You can't use template variables in html blocks. The template engine has already run. HTML only.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Maky
  • Advanced Member
  • Members
  • Join Date: 16-Nov 11
  • 71 posts

Posted 19 February 2012 - 07:56 AM #3

You can't use template variables in html blocks. The template engine has already run. HTML only.


Thank you tbirnseth.
I will create html file and include it into bottom.tpl file where I need html block for my site.

 
  • grayloon
  • Senior Member
  • Members
  • Join Date: 29-May 08
  • 450 posts

Posted 02 May 2012 - 03:27 PM #4

You can't use template variables in html blocks. The template engine has already run. HTML only.


Can template variables be used in language variables? For example, I'd like to add the following to the top of the "edp_access_granted" language variable:

<a href="{$config.http_location}/{$config.customer_index}?dispatch=orders.order_downloads&amp;order_id={$order_info.order_id}">{$lang.edp_access_subj}</a>

7 CS-Cart licenses - 2.2 through 4.2

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11306 posts

Posted 02 May 2012 - 07:51 PM #5

No, you can't nest template variables (I don't think). So having a lang variable of:
my_lan_var = This is a {$lang.big} test
Won't work.

If you need to use template variables, then don't use a HTML block, just create a regular block and use them all you want.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • grayloon
  • Senior Member
  • Members
  • Join Date: 29-May 08
  • 450 posts

Posted 02 May 2012 - 07:54 PM #6

I would probably need to do something like this where [limit] is the in the language variable:

{$lang.file_download_limit_exceeded|replace:"[limit]":$file.max_downloads}

7 CS-Cart licenses - 2.2 through 4.2

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11306 posts

Posted 02 May 2012 - 08:14 PM #7

That's fine, you just can't do it in an HTML block. It has to be a normal block to use template variables. Note that an html block is really only
<div>
{$content}
</div>
In the html block template.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • johnjohn
  • Member
  • Members
  • Join Date: 05-Mar 09
  • 35 posts

Posted 06 May 2012 - 02:24 AM #8

Is the Smarty function {eval} available to use? for example, {eval var=$content} so it parses Smarty variables added into the HTML Block editor?

EDIT: This does work!
For example, the template variable inside of the customer template, blocks/unique_html_block.tpl, can be changed to:
{eval var=$items.block_text|unescape}

Then smarty variables will be parsed. For example, try placing {$config.current_url} inside of the HTML block editor to see the page's address string after the domain name.

The other cool thing about this is that HTML and Unique HTML blocks are not cached. Other blocks, like product and category menus are cached and makes it impossible to use template variables that change when the page changes. And the Smarty nocache parameter is ignored in them. So, the HTML Blocks appear to give full use of template variables and Smarty.