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.

Limit options in relationship field on publish page

July 21, 2009 12:36pm

Subscribe [3]
  • #1 / Jul 21, 2009 12:36pm

    box-head

    177 posts

    I’ve set up two weblogs, and have them relating to one another using a relationship field. Pretty straight forward.

    Both weblogs can we written to by multiple users.
    What I need to be able to do is only display (in the relationship field drop down on the publish page) just the entries that the currently logged in user has written. That way they can’t inadvertently post an entry related to somebody elses entry. Currently it shows ALL entries written by every user.

    Any ideas anybody.

    Thanks

  • #2 / Jul 21, 2009 8:23pm

    box-head

    177 posts

    If this can’t be done is there anyway a similar thing could be replicated on the front end.

    I suspect you would have to use the author of the parent post and make sure any children (relationship entries) displayed have the same author. This sounds a little like a php variable approach. Actually just writing this has triggered an idea. I’ll be back with my findings…

  • #3 / Jul 21, 2009 8:50pm

    box-head

    177 posts

    Got it sorted, for anyone else ever needing something similar in the future here’s what I did.

    {exp:weblog:entries weblog="weblogA"}
        <?php 
            $parent_author = "{author_id}";
        ?>
            
        INSERT ANY OTHER TAGS IN HERE
    
        {reverse_related_entries sort="desc" orderby="date"} 
            <?php
                $child_author = "{author_id}";
                if($parent_author === $child_author) :
            ?>
    
            INSERT ANY OTHER TAGS HERE
    
            <?php
                endif
            ?>
        {/reverse_related_entries}
    {/exp:weblog:entries}

    Because the reverse_related_entries loop doesn’t accept the author_id parameter meant I had to find the child author and then use a conditional to only display those written by the same author as the parent entry.

  • #4 / Sep 04, 2009 5:30am

    Seamus

    47 posts

    THANK YOU!  This is the closest I’ve gotten to the final piece of a personal project I’ve been working on forever. Except… I’m trying to do the reverse of what you did, show only the parents that a user hasn’t written a related entry for. Any thoughts on inverting this?

    Seriously though, thank you for getting this far and sharing your results.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases