Reputation: 5
Code which was ok in tpl file of lod version opencart 1.5
<?php $counter=0;$fb_var=0; foreach ($totals as $total) { ?>
<?php if($counter==0){ $fb_var=$total['value'];?>
<?php echo "</pre>";}$counter++;} ?>
Now i have used following code for twig file in view of opencart 3.0.2.0 but says fatal error for $ sign
counter0fb_var0 {% for total in totals %}
{% ifcounter is 0%} fb_vartotal.value
{{ "</pre>" }}{% endif %}{% $counter = $counter + 1 %}{% endfor %}
Upvotes: 0
Views: 1643
Reputation: 152
You can use these free resources:
http://openconverter.io/ - online converter
https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=29835 - Twig Manager (add .twig support for your Opencart 2.x)
https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=31589 - OpenCart Template Switcher.
Quote: This module, when enabled, causes OpenCart to automatically detect the correct template engine depending on a template file extension (e.g. '.tpl', '.twig', '.smarty' etc). Extensions and web themes can now use both PHP-templates and Twig-templates. This allows developers to easily port old OC 2.x web themes with PHP templates (*.tpl files) to the new OC 3.0.x releases.
Upvotes: 0
Reputation: 17954
You may use this instead:
{% set counter = 0 %}
{% set fb_var = 0 %}
{% for total in totals %}
{% if counter == 0 %}
{% set fb_var = total.value %}
{{ "</pre>" }}
{% endif %}
{% set counter = counter + 1 %}
{% endfor %}
Keep in mind:
$
or anything else. just type in the variable name.{{
and }}
to print it out.{%
and %}
at the beginning and end of your if
, for
and block
s.Upvotes: 1