ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Reverse Relationship Problems

February 17, 2011 6:12am

Subscribe [3]
  • #1 / Feb 17, 2011 6:12am

    Nate Rowe

    21 posts

    Hi I have just experienced a few problems using Reverse Relationships.

    Firstly I am using EE 2.1.3 - build 20101220

    I have setup two channels.
    Both have different but similar custom field groups and contain a relationship field to another (third) channel.

    I ran this script:

    {exp:channel:entries channel="services" limit="1" url_title="{segment_2}"}
        {if logged_in}
            {reverse_related_entries channel="exclusive_offers" sort="desc" orderby="date"}
                {if exclusive_image == ""}
                    <h3>{title}</h3>
    <p>                {exclusive_description}<br />
                {if:else}<br />
                    {exclusive_image}<br />
                    </p><h3>{title}</h3>
    <p>                {exclusive_description}<br />
                {/if}<br />
            {/reverse_related_entries}<br />
        {/if}</p>
    
    <p>    {reverse_related_entries channel="special_offers" sort="desc" orderby="date"}<br />
            {if offer_image == ""}<br />
                </p><h3>{title}</h3>
    <p>            {offer-description}<br />
            {if:else}<br />
                {offer_image}<br />
                </p><h3>{title}</h3>
    <p>            {offer-description}<br />
            {/if}<br />
        {/reverse_related_entries}<br />
    {/exp:channel:entries}

    And got the follow 3 errors

    A PHP Error was encountered
    Severity: Notice
    Message: Undefined index: 1
    Filename: channel/mod.channel.php
    Line Number: 4044
    A PHP Error was encountered
    Severity: Warning
    Message: Invalid argument supplied for foreach()
    Filename: channel/mod.channel.php
    Line Number: 4044
    A PHP Error was encountered
    Severity: Warning
    Message: Cannot modify header information - headers already sent by (output started at /Users/MacPro/Sites/-RBM/system/codeigniter/system/core/Exceptions.php:170)
    Filename: core/Common.php
    Line Number: 409

    So then, I changed the channels to share the same custom fields, and it worked like a charm. Could this be a bug?

    Next, I went to delete the old custom field group, and also when trying to delete just the relationship field that I no longer needed and get the follow fatal error:

    A PHP Error was encountered
    Severity: Notice
    Message: Undefined property: Rel_ft::$db
    Filename: fieldtypes/ft.rel.php
    Line Number: 202
    Fatal error: Call to a member function select() on a non-object in /Users/MacPro/Sites/-RBM/system/expressionengine/fieldtypes/ft.rel.php on line 202

    My site is working fine now I changed the custom field groups to be the same, but wanted to let someone know about the problem incase it is a bug. Although I cant delete the custom field group still.

    Thanks Nathan

  • #2 / Feb 17, 2011 3:34pm

    Ingmar

    29245 posts

    Thank you for bringing this up. I believe you’re experiencing this bug which should have been fixed in the 2.1.4 Beta.

  • #3 / Feb 17, 2011 4:35pm

    Nate Rowe

    21 posts

    Ok thanks, I’ll wait for the release 😊

    Is this is the same for the top error too, as the bug only mentions, the deleting of a relationship field?

  • #4 / Feb 17, 2011 5:31pm

    Ingmar

    29245 posts

    I’d definitely try upgrading, yes. Let us know how it goes.

  • #5 / Feb 18, 2011 5:04am

    Nate Rowe

    21 posts

    Hi Ingmar,

    Thanks for your help, I made the changes to my 2.1.3 version as per the bug report. It did then allow me to delete the custom field group.

    However, I am now experience the top error again, I have now noticed that the error appears when I am logged in and am calling the reverse_related_entries tag twice, once for entries available to logged in users, and entries available to all. I have changed all the related fields in my entries to blank, but still get the message, which makes me think its in my tag coding?

    Any ideas would be a great help. Here is a simplified version of the code I am using:

    {exp:channel:entries channel="services" limit="1" url_title="{segment_2}"}
        {if logged_in}
            {reverse_related_entries channel="exclusive_offers" sort="desc" orderby="date"}
             Show only to Logged in users!
            {/reverse_related_entries}
        {/if}
        {reverse_related_entries channel="special_offers" sort="desc" orderby="date"}
             Show to all users!
        {/reverse_related_entries}
    {/exp:channel:entries}


    Thanks

    Nathan

  • #6 / Feb 18, 2011 5:33am

    Nate Rowe

    21 posts

    Ok further development,

    The pages that have relationship fields that have never been set, do not display the error message, however, the pages that have been set do display the error, and even if the relationship is then removed, the error still shows.

    I hope this helps to diagnose, as i’ve hit a brick wall on this.

  • #7 / Feb 18, 2011 9:03am

    Sue Crocker

    26054 posts

    Hi, Nate. Do you have access to a local install for testing? Could you test this locally with the 2.1.4 beta?

    EEBeginners:// HowTo Download EE2.1.4 Beta

  • #8 / Feb 18, 2011 9:08am

    Nate Rowe

    21 posts

    Hi Sue,

    Thanks for the message, I updated to 2.1.4 just after posting. Unfortunately it made no difference.

    Also to let you know, there appears to be a bug in it. If you create a new template and select to use another template as default content, it still appears blank.

  • #9 / Feb 18, 2011 9:23am

    Nate Rowe

    21 posts

    Hi Sue,

    I have just tried a very basic example on a new install of EE 2.1.4. And it seems to be working.

    I will try and convert my site over, and see how I get on. I think it got confused when I changed the custom field group. It didnt seem to work from then on.

    I will keep you posted.

    Thanks

  • #10 / Feb 18, 2011 9:43am

    Sue Crocker

    26054 posts

    Sounds good, we can keep this thread open. Thanks for helping out with testing. 😊 As far as the bug with the saving template with default content, I can replicate that. Looking to see if there is already a bug listed.

  • #11 / Feb 18, 2011 11:30am

    Nate Rowe

    21 posts

    Hi Sue,

    I think I have found the culprit while rebuilding my template one line at a time.

    I was using the {file-image}{filename}{/file-image} tag within the template. Once I removed this all three php errors disappear?

    The tag worked if I did not use the reverse relationship tag, and visa-versa.

  • #12 / Feb 18, 2011 3:50pm

    Ingmar

    29245 posts

    What tag is that, where does it come from? What does it do?

  • #13 / Feb 18, 2011 5:11pm

    Nate Rowe

    21 posts

    It’s the file field you can use it as a tag pair

    See the docs here:
    http://ellislab.com/expressionengine/user-guide/modules/channel/custom_fields.html#file_fields

  • #14 / Feb 20, 2011 1:14pm

    Greg Salt

    3988 posts

    Hi Nate,

    Can you clarify please that these errors only appear in version 2.1.3 but do not appear in version 2.1.4?

    Cheers

    Greg

  • #15 / Feb 21, 2011 4:03am

    Nate Rowe

    21 posts

    Hi Greg,

    Unfortunately, this error occurs on both 2.1.3 and the new 2.1.4 beta.

    I also tried a fresh install of 2.1.4 with a very basic setup and the 3 php errors appear too.

    To reproduce the errors i setup EE like so;

    2 channels say “services” & “offers”, give offers a relationship field to services.

    Give offers a file field. post a sample to both linking the offer to the services channel.

    I then setup a basic template like so;

    Again, I am just notifying you incase this is a bug.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html >
    <head>
    </head>
    <body>
    {exp:channel:entries channel="services" limit="1" url_title="{segment_2}"}
    {title}
    {reverse_related_entries channel="offers" sort="desc" orderby="date"}
    - {title}{if offers-image != ""}
    {offers-image}{filename}{/offers-image}
    {/if}
    {/reverse_related_entries}
    {/exp:channel:entries}
    </body>
    </html>
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases