pdaleramirez / super-filter

Other
6 stars 2 forks source link

Cannot find template after calling craft.superFilter.setup #1

Closed nitech closed 4 years ago

nitech commented 4 years ago

Craft is not able to find referenced templates after craft.superFIlter.setup("...") is called.

I have one defined search setup called kompressorer:

image

It references this template:

image

This is the setup (I haven't done anything here):

image

As far as I understand, it seems that searchTypes.php:599 with the following code is causing the error: Craft::$app->getView()->setTemplatesPath($builtin);, because when I add _blocks\footer.twig to the vendor\pdaleramirez\super-filter\templates-folder, the template is found and everything is golden:

image

pdaleramirez commented 4 years ago

Do you have an included template after all the superFilter twig function? can you paste the whole content template here. I may have a fix with this issue

pdaleramirez commented 4 years ago

@nitech If the issue is what i think it is. I released a v1.0.4 to fix this issue. You will require to add {{ craft.superFilter.close() }} after all superFilter twig function is being called. Check updated Readme.

nitech commented 4 years ago

Yes, I include a template after all the superFilter twig functions.

Calling the superFilter functions

{% extends "index" %}
{% block more %}

    {# Filters #}
    <section class="container" id="search-app">
        <div class="row">
            <div class="col-12">
                <h2 class="mark mt-4 mb-4 pl-0">Test av filtere</h2>
            </div>
        </div>
        <div class="row">
            <div class="col-12">
                {{ craft.superFilter.setup('kompressorer') }}
                {{ craft.superFilter.displaySearchFields() }}
                {{ craft.superFilter.displaySortOptions() }}
            </div>
        </div>
    </section>

    {# Filters #}     
    <section class="container pt-5">
        <div class="row">
            <div class="col-12">
                <h2 class="mark mt-4 mb-4 pl-0">Testutlisting av produkter</h2>
            </div>
        </div>

        {{ craft.superFilter.items() }}
        {{ craft.superFilter.getPaginateLinks() }}

    </section>

{% endblock %}

kompressorer\items.twig


{% if items %}

    {% for group in items|batch(4) %}
        <div class="row">

            {% for p in group %}
                {% set image = p.productImage.one()|default(null) %}
                {% set transformedImages = craft.imager.transformImage(image, [
                    { width: 400 }, 
                    { width: 400 }
                    ], { ratio: 1/1, position: image.getFocalPoint()|default("50% 50%") }) %} 
                {% set first = transformedImages|first %}

                <div class="col-6 col-md-3 d-flex align-items-stretch mb-4">
                    <div class="card">
                        <a href="{{ p.url }}" class="card-link" aria-label="{{ 'Read more'|t }}"></a>
                        <div class="card-img-top-container">
                            <img class="card-img-top" src="{{ first ? first.url }}" sizes="100vw" srcset="{{ craft.imager.srcset(transformedImages) }}" alt="{{p.title}}">
                        </div>
                        <div class="card-body">
                            <h5>{{ p.title }}</h5>
                            <p class="card-text">{{ p.productDescription }}</p>
                            <a href="{{ p.url }}" class="float-right read-more underline">{{ 'Read more'|t }} →</a>
                        </div>
                    </div>
                </div>     
            {% endfor %}

        </div>
    {% endfor %}

{% endif %}

index.twig

{% extends "_layouts/site" %}

{% block main %}

    <main>
        {% if entry|default(null) %}
            {% include '_blocks/neo-sections' with { sections: entry.neoSections } %}
        {% endif %}

        {% block more %}{% endblock %}
    </main>

{% endblock %}

site.twig

{% extends "_layouts/base" %}

{# Set the `title` variable to the nav item that matches the first segment #}
{% set title %}{% if title is defined %}{{ title }} - {% endif %}{% endset %}

{% block body %}
    {% block main %}{% endblock %}
{% endblock %}

Except from base.twig

The exception occurs on the line that includes the footer. _blocks\header loads fine.

    <!-- Partial Include: Header -->
    {% include '_blocks/header' %}

    <main>{% block body %}{% endblock %}</main>

    {# {% include '_blocks/newsletter' %} #}

    <!-- Partial: Footer -->
    {% include '_blocks/footer' %}
pdaleramirez commented 4 years ago

can you add {{ craft.superFilter.close() }} after {{ craft.superFilter.getPaginateLinks() }} and make sure you updated v1.0.4. Let me know if that solves your issue.

nitech commented 4 years ago

@pdaleramirez I can confirm that it works when I upgrade to version 1.0.4 and add the call to {{ craft.superFilter.close() }}

Thanks for the speedy response!