0

I have two channels setup, one "blog" and one "authors". The blog channel has all of the blog post entries and the Authors channel has a list of the different post authors.

I am looking on a specific entry (blog post) to show the blog information (body, author, author description and pic). I want to have it so that I just put in the entry the authors name then have a conditional statement that cross checks the authors name in the blog entry with the different authors in the Authors channel, then pulls the information from the authors channel (bio, picture, social media links, etc...) but am having trouble finding anything about doing conditional statements between two channels.

Here is the code to pull everything in which works for the Blogs portion but not the Authors:

{exp:channel:entries channel="blog|authors" text_only="yes"}
<div class="fancy-title title-bottom-border">
    <h2>{title}</h2>
</div>
<ul class="entry-meta clearfix">
    <li><i class="icon-calendar3"></i> {entry_date format="%m-%d-%Y"}</li>
    <li><i class="icon-user"></i> {entry_author}</li>
    <li><i class="icon-folder-open"></i> {exp:channel:entries channel="blog" limit="1"}{categories limit="1"}{category_name}{/categories}{/exp:channel:entries}</li>
</ul>
<br />
<p>{entry_body}</p>

<p><b>Keywords:</b> {entry_keywords}</p>


<div class="panel panel-default">
{if blog/entry_author == authors/author_name}

    <div class="panel-heading">
        <h3 class="panel-title">
        Posted by {author_name}
        </h3>
    </div>
    <div class="panel-body">
        <div class="author-image">
            <img src="{cdn_url}/images/blogs/{author_photo}" alt class="img-circle" />
        </div>
        {author_description}

        </div>
    </div>

</div>
{/if}
</div>
{/exp:channel/entries}

Any help would be much appreciated.

Thanks

1

You could do this with an embed by setting your embed with the author_id or author_name as a variable.

{embed="templategroup/templatename" authorName="{author_name}"}

embed:

{exp:channel:entries channel="authors" search:author_name="={embed:authorName}"

However, if the blog post and the author channel info have the same author, it would be much simpler to set the channel entries tags to pull based on {author_id}. That would eliminate the need to use a custom field search.

Also, it may just be a formatting issue, but your code above looks like its going to output two extra </div> tags per each loop.

  • 1
    This is a textbook example of where a Relationship/Playa field would work without having to jump through any hoops, or embeds. It would also work in the other direction when viewing an authors bio, where you could easily pull a list of articles by any given author. – Jim Wyse Feb 15 '17 at 13:40

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.