WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.9 R22 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • General Help & Support »
  • Using TWIG in template
  • Print
Pages: [1]   Go Down

Author Topic: Using TWIG in template  (Read 5750 times)

Offline KEnik

  • Posts: 27
Using TWIG in template
« on: August 04, 2022, 05:20:01 PM »
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
Logged

Online crnogorac081

  • Posts: 2168
  • Gender: Male
Re: Using TWIG in template
« Reply #1 on: August 04, 2022, 07:28:15 PM »
Look at the index.php
Logged
Web developer

Offline KEnik

  • Posts: 27
Re: Using TWIG in template
« Reply #2 on: August 04, 2022, 08:19:10 PM »
Quote from: crnogorac081 on August 04, 2022, 07:28:15 PM
Look at the index.php
Which one?
Code: [Select]
/templates/DefaultTemplate/index.phpor
Code: [Select]
/index.php
IMHO this template is not complete - twig does not work - cannot work because
1, is it wrong set in default.ini
Code: [Select]
-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:
Code: [Select]
add include_once 'template.functions.php';
and replace code from
Code: [Select]
// TEMPLATE CODE STARTS BELOW
?><!DOCTYPE HTML>
<html lang="<?= $sPageLang; ?>">

by code:
Code: [Select]
    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,
        ]
    );
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • General Help & Support »
  • Using TWIG in template
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2