Home » PHP » Twig

Twig

Top Twig Template Interview And Answer Part 4

1. How we can append text in title with separator in twig template? {% do pimcore_head_title().append('Pimcore Website') %} {% do pimcore_head_title().setSeparator(' : ') %} 2. How can we include image through asset in twig template? <img src="{{ asset('static/img/logo-white.svg') }}" alt="Image"> 3. How can we check asset is the instance of …

Read More »

How AJAX calls work with TWIG

Twig can load a template through AJAX.. The following details are below /var/www/html/my-project/src/AppBundle/Controller/DefaultController.php namespace AppBundle\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; class DefaultController extends FrontendController { /** * Fetch data from ajax call. * @param Request $request * @Route("/xyz/{id}", methods={"GET"}) */ public function proAjaxAction(Request $request){ $this->view->id = $request->get('id'); } } …

Read More »

How ajax do work in Pimcore 5 in twig template?

It’s is simple to use ajax code in twig template. The action part be define in controller. it will be clear from following example which are below 1. Pimcore Controller Code /** * *@param Request $request *@Route("/url/{parameter}") */ public function funAction(Request $request){ } 2. Twig Template Code {% do pimcore_head_script().captureStart() …

Read More »

How Can We Create Custom Twig Navigation Builder

nav.html.twig {% set nav = app_build_nav(document, navStartNode) %} {% set menuRenderer = pimcore_nav_renderer('menu') %} <ul> {% for page in nav %} {% if (page.isVisible and menuRenderer.accept(page)) %} <li class="{{ page.isActive(true) ? 'active' }}"> <a href="{{ page.href }}">{{ page.label }}</a> {% if page.hasPages %} <ul> {% for child in page.pages %} …

Read More »