Search code examples
phptwigopencart-3

opencart 3 how to Custom variable in twig page


i want to show custom text come from a variable in language template.

so i declared a variable in:

admin/language/en-gb/extension/theme/mytheme.php

$_['text_label_menu_count']  = 'Some count';

and then try to print that variable in

catalog/theme/mytheme/template/common/menu.twig

<h4 class="text-white"> {{ text_label_menu_count }} </h4>

but nothing happens.

Can you explain me how to achieve this? Thanks a lot

... I found a lot of twig similarities with angulajs.


Solution

  • If you need to print some text from language file to TWIG

          catalog/view/theme/your_template/template/common/menu.twig
    
    <h4 class="text-white"> {{ text_label_menu_count }} </h4>
    

    Your language file should be placed to the corresponding folder... in this case to:

    catalog/language/en-gb/common/menu.php
    
    $_['text_label_menu_count']  = 'Some count';