Page 1 of 1
[solved]Need help with updating tpl to twig
Posted: Sun Aug 02, 2020 12:05 pm
by khnaz35
Hello guys/girls,
I am converting my tpl file to twig and running in this is issue.
Code: Select all
Fatal error: Uncaught Twig\Error\SyntaxError: Unknown "else" tag in "extension/payment/braintree_tlt.twig" at line 54.
This is line 54
this is my whole div code
Code: Select all
<div class="form-group">
<label class="col-sm-3 control-label" for="input-use-default"><span data-toggle="tooltip" title="{{ help_use_default }}">{{ entry_use_default }} ({{ default_currency }})</span></label>
<div class="col-sm-9">
<select name="braintree_tlt_use_default" id="input-use-default" class="form-control">
{% if braintree_tlt_use_default %}
<option value="1" selected="selected">{{ text_yes }}</option>
<option value="0">{{ text_no }}</option>
{% endif %}{% else %}
<option value="1">{{ text_yes }}</option>
<option value="0" selected="selected">{{ text_no }}</option>
</select>
</div>
</div>
Any help and suggestions are highly appreciated.
Re: Need help with updating tpl to twig
Posted: Sun Aug 02, 2020 12:55 pm
by letxobnav
well, in twig, the else comes before endif.
so:
Code: Select all
{% if ... %}
[code]
{% else %}
[code]
{% endif %}
Re: Need help with updating tpl to twig
Posted: Sun Aug 02, 2020 1:19 pm
by pprmkr
Code: Select all
<div class="form-group">
<label class="col-sm-3 control-label" for="input-use-default"><span data-toggle="tooltip" title="{{ help_use_default }}">{{ entry_use_default }} ({{ default_currency }})</span></label>
<div class="col-sm-9">
<select name="braintree_tlt_use_default" id="input-use-default" class="form-control">
{% if braintree_tlt_use_default %}
<option value="1" selected="selected">{{ text_yes }}</option>
<option value="0">{{ text_no }}</option>
{% else %}
<option value="1">{{ text_yes }}</option>
<option value="0" selected="selected">{{ text_no }}</option>
{% endif %}
</select>
</div>
</div>
Re: Need help with updating tpl to twig
Posted: Sun Aug 02, 2020 1:42 pm
by khnaz35
letxobnav wrote: ↑Sun Aug 02, 2020 12:55 pm
well, in twig, the else comes before endif.
so:
Code: Select all
{% if ... %}
[code]
{% else %}
[code]
{% endif %}
Thanks for help
Re: Need help with updating tpl to twig
Posted: Sun Aug 02, 2020 1:42 pm
by khnaz35
pprmkr wrote: ↑Sun Aug 02, 2020 1:19 pm
Code: Select all
<div class="form-group">
<label class="col-sm-3 control-label" for="input-use-default"><span data-toggle="tooltip" title="{{ help_use_default }}">{{ entry_use_default }} ({{ default_currency }})</span></label>
<div class="col-sm-9">
<select name="braintree_tlt_use_default" id="input-use-default" class="form-control">
{% if braintree_tlt_use_default %}
<option value="1" selected="selected">{{ text_yes }}</option>
<option value="0">{{ text_no }}</option>
{% else %}
<option value="1">{{ text_yes }}</option>
<option value="0" selected="selected">{{ text_no }}</option>
{% endif %}
</select>
</div>
</div>
Thanks for help
Re: Need help with updating tpl to twig
Posted: Sun Aug 02, 2020 1:44 pm
by khnaz35
Guys one more question, when updating my OC 2.X extension to OC 3.X, do i have to update only tpl files to twig or controller files also ?
Re: Need help with updating tpl to twig
Posted: Sun Aug 02, 2020 2:43 pm
by xxvirusxx
khnaz35 wrote: ↑Sun Aug 02, 2020 1:44 pm
do i have to update only tpl files to twig or controller files also ?
All files
Re: Need help with updating tpl to twig
Posted: Sun Aug 02, 2020 3:02 pm
by letxobnav
when updating my OC 2.X extension to OC 3.X, do i have to update only tpl files to twig or controller files also ?
depends on the controller.
Re: Need help with updating tpl to twig
Posted: Sun Aug 02, 2020 10:13 pm
by khnaz35
Hello again guys, thanks for help, the twig file is almost look ok now, but i have a problem while am trying to save my changes into file pressing the save button
https://prnt.sc/tsp5bp its redirect me to this admin/<?php%20echo%20$action;%20?>
Re: Need help with updating tpl to twig
Posted: Mon Aug 03, 2020 1:54 am
by xxvirusxx
Nice example of your conversion work...
Also on 3.x is:
payment_braintree...
And:
Code: Select all
<form action="<?php echo $action; ?>"....
is:
Re: Need help with updating tpl to twig
Posted: Mon Aug 03, 2020 1:56 am
by sw!tch
khnaz35 wrote: ↑Sun Aug 02, 2020 10:13 pm
Hello again guys, thanks for help, the twig file is almost look ok now, but i have a problem while am trying to save my changes into file pressing the save button
https://prnt.sc/tsp5bp its redirect me to this admin/<?php%20echo%20$action;%20?>
A picture of the save button is not very helpful.
You have to convert all PHP variables from your .tpl to proper .twig variables. anything in your .twig with <?php won't parse.
Read the docs on twig -
https://twig.symfony.com/doc/2.x/templa ... #variables
Re: Need help with updating tpl to twig
Posted: Mon Aug 03, 2020 2:01 am
by xxvirusxx
@sw!tch
Sometimes is hard to open files from 2.xx and 3.xx to compare the changes
[Solved] Need help with updating tpl to twig
Posted: Mon Aug 03, 2020 8:34 am
by khnaz35
xxvirusxx wrote: ↑Mon Aug 03, 2020 1:54 am
Nice example of your conversion work...
Also on 3.x is:
payment_braintree...
oh my bad
... didn't notice all the payment options in 3.X i have done earlier for oc 2.3.0.2
And thanks for :
Code: Select all
<form action="<?php echo $action; ?>"....
is:
Re: Need help with updating tpl to twig
Posted: Mon Aug 03, 2020 8:35 am
by khnaz35
Thanks for the tip and link