4

I can not run the relationship feature since upgrading to 2.6.1. I've searched through he forums and I found similar issues, but the answers there didn't help me, so I'm posting my question here. Sorry if I duplicate anything. I have a channel called "noticies" with a field that relates inputs of the same channel. The channel field is single relationship called "noticies_relacionades" My code is as follows:

{exp:channel:entries  status="not closed"}
…
    {if noticia_relacionada}
     <div class="well well-small">
        <p class="blau-fosc bottom">TAMBÉ ET POT INTERESSAR</p>
          {noticia_relacionada}
              <h4 class="top">
                 <a href="{title_permalink="noticies/article"}" target="_top" title="{title}">
                    <i class="icon-arrow-right" style="padding-top: 2px;"></i>
                    {noticia_relacionada:title}
                 </a>
              </h4>
           {/noticia_relacionada}
        </div>
    {/if}
{/exp:channel:entries}

Thanks in advance. Any help is wellcome.

4
  • What isn't working about it? Are you getting no output at all within the relationship field tag pair itself? Commented Aug 22, 2013 at 11:36
  • 2
    The subject-line of this question sounds hilarious (and awfully familiar) when taken out of context.. :') Commented Aug 22, 2013 at 13:54
  • Jean, I'm sorry. The problem is that I'm not getting any output from that code. I also tried without the conditional and it didn't worked. Commented Aug 22, 2013 at 14:34
  • Adrian, I didn't realized when I wrote, but it souns hilarious, indeed. Commented Aug 22, 2013 at 14:35

3 Answers 3

2

One change I would recommend is to the structure. Try something like this instead:

{exp:channel:entries  status="not closed"}
{if noticia_relacionada:count == "1"}
 <div class="well well-small">
    <p class="blau-fosc bottom">TAMBÉ ET POT INTERESSAR</p>
{/if}
      {noticia_relacionada}
          <h4 class="top">
             <a href="{title_permalink="noticies/article"}" target="_top" title="{title}">
                <i class="icon-arrow-right" style="padding-top: 2px;"></i>
                {noticia_relacionada:title}
             </a>
          </h4>
       {/noticia_relacionada}
{if noticia_relacionada:count == noticia_relacionada:total_results}
    </div>
{/if}
{/exp:channel:entries}

A relationship field is a bit different than a regular text field - and so the most practical way to handle the conditional around whether it has any entries within it is to use the loop itself - since it won't return results if no entries (related entries) exist.

I'm not certain if this will solve whatever issue it is that you're facing since you haven't described what's not working about it - but I thought I'd make that recommendation regardless.

3
  • Thanks for the suggestion, Jean. I've tried and it doesn't work. In addition, the second conditional closes a div and break the grid. Thanks anyway :-) Commented Aug 22, 2013 at 14:44
  • The first conditional opens the div and the second conditional closes it - but if the relationship tag pair isn't returning anything, neither should have any impact. Have you tried using the children tag pair instead of the fieldtype tag pair? The docs don't provide an example of a relationship field pointed to the same channel so it's hard to say exactly what the issue might be. Commented Aug 22, 2013 at 15:06
  • In fact, I've tried it and also other possibilities. Before version 2.6 worked perfectly with the old relationship field: it allowed to relate current news and older within the same channel. In the documentation there is no exemples of such relationship in the same channel, as you say, but the fact that the configuration allow to choose the same channel, the channel itself is not the problem. I think so… Thanks for your atention. Commented Aug 22, 2013 at 16:22
1

I'm not sure if this could be the answer, but just a thought.. instead of status="not closed" using status="open" ?

1
  • Hi, Cedric. The "not closed" status isn't the problem. I'm using "not closed" because there are custom status other than "open | closed". The site has a lot of content and I used statuses to direct entries to different templates. That template is an "any content" template and it can contain articles from any channel, any category and any status. Thanks :-) Commented Aug 23, 2013 at 6:27
1

I believe I had the same problem when I tried using a relationship field relating to the same channel. When I included status="not closed" within the relationship field call as well, it finally worked for me!

Here's my code: {exp:channel:entries entry_id="133" channel="channel_name" status="not closed"} {relationship_field status="not closed"} Assigned Student: {relationship_field:title} {/relationship_field} {parents field="relationship_field" status="not closed"} Assigned Coach: {parents:title} {/parents} {/exp:channel:entries}

Make sure to change out relationship_field with the name of your custom field.

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.