1

I have two sections: 'reviews' and 'games'. Games has an field called 'GamesReviews' which is type entries and points to 'reviews'. An example of a games entry is located at: http://www.colorcomputergames.com/games/donkey-king

Towards the bottom, I link to the related reviews for this entry. That sends me to: http://www.colorcomputergames.com/reviews/1983-06-01/donkey-king

At the bottom of the review, I want to link back to the related entry of that review.

I am able to display the name of the game 'Donkey King', but the URL is not pointing to: http://www.colorcomputergames.com/games/donkey-king

But instead: http://www.colorcomputergames.com/reviews/1983-06-01/donkey-king

The code I am usinng in the template (reviews/_entry.html) is:

<h1>{{ entry.title }}</h1>
<ul>
    {% if entry.ReviewsAuthor|length %}<li>Reviewer: {{ entry.ReviewsAuthor }}</li>{% endif %}
    {% if entry.ReviewsMedia|length %}<li>Media: {% for category in entry.ReviewsMedia %}<a href="{{ category.url }}">{{ category.title }}</a>{% endfor %}</li>{% endif %}
    {% if entry.ReviewsDate|length %}<li>Date: {{ entry.ReviewsDate.format('F Y') }}</li>{% endif %}
    {% if entry.ReviewsRelatedLink|length %}<li>Related Link: {{ entry.ReviewsRelatedLink }}</li>{% endif %}
</ul>
{{ entry.body }}

{% set entries = craft.entries.section('games').relatedTo(entry) %}
<h3>Info:</h3>
    <ul>      
        <li><a href="{{ entry.url }}" title="{{ entry.title }}">{{ entry.title }}</a></li>
    </ul>
1

You are returning an elementCriteriaModel (which always returns an array-like object regardless if there is one or more than one result), which you either need to loop over or just grab the first entry (because in this case there can only be one).

{% set gameEntries = craft.entries.section('games').relatedTo(entry) %}
<h3>Info:</h3>
{% for gameEntry in gameEntries %}
    <ul>      
        <li><a href="{{ gameEntry.url }}" title="{{ gameEntry.title }}">{{ gameEntry.title }}</a></li>
    </ul>
{% endfor %}

or

{% set gameEntry = craft.entries.section('games').relatedTo(entry).first %}
<ul>      
    <li><a href="{{ gameEntry.url }}" title="{{ gameEntry.title }}">{{ gameEntry.title }}</a></li>
</ul>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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