0

I have an {entry.footer} field outputting just fine everywhere before {% set entry... %} Added {% endset %} tags after closing anchor tag and caused an error. Any idea what the issue is?

{% extends "_layout" %}

{% block home_slider %}
{% include 'global/home-slider.html' %}
{% endblock %}

{% block content %}
            <main id="main" role="main">
                <div id="content">
                    <div class="holder-top">
                        <div class="holder">
                            <div class="text-wrap">
                                <div class="wrap">
                                     {{ entry.body }}
                                </div>
                            </div>
                            <div class="three-columns">
                                <div class="wrap">
                                    {% for block in entry.threeHomepageImages.type('images') %}
                                        <div class="col">
                                            <div class="image-block">
                                                <div class="image">
                                                    {% if block.image|length %}
                                                        <a href="{{ block.pageLink.first().getUrl() }}"><img src="images/{{ block.image.first }}.jpg" alt="{{ block.alt }}"></a>
                                                    {% endif %}
                                                </div>
                                            </div>
                                            <h1><a href="{{ block.pageLink.first().getUrl() }}">{{ block.imageTitle }}</a></h1>
                                        </div>
                                    {% endfor %}
                                </div>
                            </div>
                            <div class="btn-holder">
                                <div class="btn-wrap">
                                    {% set entry = craft.entries.slug('get-a-quote').first %}
                                    <a href="{{ entry.url }}" class="btn-quote">request a quote</a>
                                    {% endset %}
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="holder-bottom">
                        <div class="quote">
                            {{ entry.footer }}
                        </div>
                    </div>
                </div>
            </main>

{% endblock %}
4
  • 1
    Not seeing the {% endset %}. What error are you getting where? Commented Sep 23, 2014 at 16:48
  • when I include {% endset %} I get the following error: Internal Server Error Unexpected tag name "endset" (expecting closing tag for the "block" tag defined near line 8) I added entire template code to original post.
    – frshjb373
    Commented Sep 23, 2014 at 17:40
  • Definitely ditch the {% endset %}, per Marion's suggestion below. Do you have Dev Mode enabled on your local site? What happens when you put {{ dump(entry) }} after your {% set entry %} tag?
    – Lindsey D
    Commented Sep 23, 2014 at 20:35
  • It outputs a ton of code...same either way.
    – frshjb373
    Commented Sep 23, 2014 at 20:48

2 Answers 2

5

Here's your problem... You're redefining entry halfway down the page.

This page clearly uses the section's built-in routing functionality. I can tell because you use entry.body near the top of your page without explicitly declaring the value of entry.

However, you later on use {% set entry %} to reassign the value of entry. Based on the new value of entry, the entry.footer property no longer exists or is empty.

How to fix it...

Instead of {% set entry %}, use a different variable name:

{% set getQuoteEntry = craft.entries.slug('get-a-quote').first %}
<a href="{{ getQuoteEntry.url }}" class="btn-quote">request a quote</a>

This will leave the original value of entry untouched, and you'll still have access to entry.footer at the bottom of the page.

3
  • Where do I declare the value of {{ getQuoteEntry.url }}. Would that be done as a global variable?
    – frshjb373
    Commented Sep 23, 2014 at 21:00
  • Just updated my answer to clarify... entry is an Entry, created automatically for you by Craft's magical routing system. getQuoteEntry is also an Entry, but you'll need to set it manually.
    – Lindsey D
    Commented Sep 23, 2014 at 21:05
  • entry is this entry. getQuoteEntry is a separate entry.
    – Lindsey D
    Commented Sep 23, 2014 at 21:07
3

The twig set tag has two syntaxes. You can use it like this:

{% set foo = 'bar' %}

or like this:

{% set foo %}bar{% endset %}

They are both useful in different ways.

The error you were getting was about mixing them.

1
  • still doesn't solve issue however, as nothing in the {{ entry.footer }} field will output when added below that {% set... %} code. Neither of the syntaxes are working for me, unless I'm still missing something.
    – frshjb373
    Commented Sep 23, 2014 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.