Post by khnaz35 » Sun Aug 02, 2020 12:05 pm

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

Code: Select all

{% endif %}{% else %}
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 }}&nbsp;({{ 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.
Last edited by khnaz35 on Mon Aug 03, 2020 8:36 am, edited 1 time in total.

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by letxobnav » Sun Aug 02, 2020 12:55 pm

well, in twig, the else comes before endif.

so:

Code: Select all

{% if ... %}
[code]
{% else %}
[code]
{% endif %}

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by pprmkr » 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 }}&nbsp;({{ 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>

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by khnaz35 » Sun Aug 02, 2020 1:42 pm

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 :)

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by khnaz35 » Sun Aug 02, 2020 1:42 pm

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 }}&nbsp;({{ 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 :)

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by khnaz35 » Sun Aug 02, 2020 1:44 pm

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 ?

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by xxvirusxx » Sun Aug 02, 2020 2:43 pm

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

OC 2.3.0.2 | OC 3.0.3.6 | Extensions converted by me | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by letxobnav » Sun Aug 02, 2020 3:02 pm

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.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by khnaz35 » 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?>

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by xxvirusxx » Mon Aug 03, 2020 1:54 am

khnaz35 wrote:
Sun Aug 02, 2020 10:13 pm
https://prnt.sc/tsp5bp
Nice example of your conversion work... :laugh:

Also on 3.x is: payment_braintree...
And:

Code: Select all

<form action="<?php echo $action; ?>"....
is:

Code: Select all

<form action="{{ action }}"......
Last edited by xxvirusxx on Mon Aug 03, 2020 1:58 am, edited 1 time in total.

OC 2.3.0.2 | OC 3.0.3.6 | Extensions converted by me | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by sw!tch » Mon Aug 03, 2020 1:56 am

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
Last edited by sw!tch on Mon Aug 03, 2020 2:15 am, edited 2 times in total.

Backup and [ learn how to recover ] before you make any changes.


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by xxvirusxx » Mon Aug 03, 2020 2:01 am

@sw!tch

Sometimes is hard to open files from 2.xx and 3.xx to compare the changes :)

OC 2.3.0.2 | OC 3.0.3.6 | Extensions converted by me | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by khnaz35 » Mon Aug 03, 2020 8:34 am

xxvirusxx wrote:
Mon Aug 03, 2020 1:54 am

Nice example of your conversion work... :laugh:
:D :D :D :D
Also on 3.x is: payment_braintree...
oh my bad >:D ... 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:

Code: Select all

<form action="{{ action }}"......

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by khnaz35 » Mon Aug 03, 2020 8:35 am

sw!tch wrote:
Mon Aug 03, 2020 1:56 am
Read the docs on twig - https://twig.symfony.com/doc/2.x/templa ... #variables
Thanks for the tip and link :)

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia
Who is online

Users browsing this forum: No registered users and 11 guests