• Welcome to WebsiteBaker Community Forum. Please log in or sign up.
Welcome, Guest
News
Support WebsiteBaker
Your donations will help to:
PayPal
  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!
You can donate by clicking on the button below.

Using TWIG in template

Started by KEnik, August 04, 2022, 05:20:01 PM  ( Read 7,193 times )

KEnik

Hi,
I am trying to use twig in template.
I try "DefaultTemplate" - there is "templates/index.html.twig" but this template is not using...

Some working wit Twig is in template.functions.php but this file  not used by template..

Thank You in advance

    crnogorac081

    Web developer

    KEnik

    Quote from: crnogorac081 on August 04, 2022, 07:28:15 PM
    Look at the index.php
    Which one?
    /templates/DefaultTemplate/index.php
    or
    /index.php

    IMHO this template is not complete - twig does not work - cannot work because
    1, is it wrong set in default.ini
    -templates_dir        = "templates/"
    -default_template     = "index.twig"
    +templates_dir        = "/templates/"
    +default_template     = "index.html.twig"

    2, variables used in twig does not exist anywere  like sTmpHeaderTitle


    This works for me:
    in /templates/DefaultTemplate/index.php
    add:
    add include_once 'template.functions.php';

    and replace code from
    // TEMPLATE CODE STARTS BELOW
    ?><!DOCTYPE HTML>
    <html lang="<?= $sPageLang; ?>">


    by code:
    echo $oTemplate->render(
           [
               
    'sTmpHeaderTitle' => 'Test title',
               
    'register_frontend_css' => register_frontend_modfiles('css'),
               
    'register_frontend_js' => register_frontend_modfiles('js'),
               
    'register_frontend_jquery' => register_frontend_modfiles('jquery'),
               
    'pageContentMain' => $pageContentMain,
           ]
       );


      \n\n