I have a long entry list of authors and I am using global cache to help with the page load, but this global cache prevents the if
statement from adding selected
to the appropriate option. When I remove the global cache everything performs as intended.
<select name="filter-by-author" onchange="window.location.href=this.value;">
<option value="/blog">All Authors</option>
{% cache globally %}
{% nav author in craft.users({ group: 'blogAuthors', order: 'firstName', limit: null }) %}
<option value="{{ url('blog/author/'~author.username) }}"
{% if craft.request.getLastSegment() == author.username %}selected{% endif %}>
{{ author.name | title }}
</option>
{% endnav %}
{% endcache %}
</select>