0
Welcome Guest! Login
0 items Join Now

Override search.php in Gantry 5

    • scs's Avatar
    • scs
    • Newbie
    • Posts: 12
    • Thanks: 1

    Override search.php in Gantry 5

    Posted 7 years 4 weeks ago
    • Hi.
      Im using Wordpress, Gantry 5 and g_helium theme. I want to create a new look for search and therefore need to add a custom (/theme/g_helium/)search.php. I have tryed to add a new file in several locations in the custom folder but still the search.php in theme root is used.

      Do anyone know where in the custom folder the file should be added?

      (the search results can be changed by adding archive.html.twig to custom/views but i need to change other things as well)
    • Matt's Avatar
    • Matt
    • Preeminent Rocketeer
    • Posts: 21595
    • Thanks: 3098
    • messin' with stuff

    Re: Override search.php in Gantry 5

    Posted 7 years 4 weeks ago
    • That's a core WP file, not part of Gantry, so it can't be overridden in Gantry...

      simplest would write be to write a small PHP conditional or something like that to include 'custom/search.php'
    • The following users have thanked you: scs

    • SEARCH the forum first! These boards are rich in knowledge and vast in topics. This includes searching just the 'Solved' forums, using Google, and using ChatGPT :woohoo:
    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22450
    • Thanks: 2679
    • Web Developer

    Re: Override search.php in Gantry 5

    Posted 7 years 4 weeks ago
    • Do it like this:
      Copy this /wp-content/themes/g5_helium/views/archive.html.twig to /wp-content/themes/g5_helium/custom/views/ and rename it to search.html.twig and style it as you want!

      replace this on top:
      {% extends "partials/page.html.twig" %}
      {% set twigTemplate = 'archive.html.twig' %}
      {% set scope = 'archive' %}

      with this
      {% extends "partials/page.html.twig" %}
      {% set twigTemplate = 'search.html.twig' %}
      {% set scope = 'search' %}
    • The following users have thanked you: scs, Matt

    • Available for CUSTOM WORK with Joomla, WordPress and Grav Templates and Gantry Framework!

Time to create page: 0.044 seconds