0

Need some help and will try to explain as clearly as possible...

I'm redesigning a law site.

I have a template group called "attorneys" for each lawyer profile that has tabs holding various info. Right now, I have individual templates for each profile page that's working fine, but I want to put all the same data into a channel to allow the client to make additions/changes etc.

Moving the data into a channel, I'm using the index of the group which calls the new channel "attorneys" which holds all the data elements. Custom fields are used for each tabs' content with {if} statements to show or hide based on if there's content entered into the individual entries or not.

Simple enough for a standard template/channel combo.

Here's where the tricky part comes in...

The "attorneys" channel has a custom field called {blog_posts_tab}. It's a yes/no radio selection so each entry can have the option to show or hide the "blog posts" tab and its content.

The {blog_posts_tab} is supposed to display the entries written by that specific attorney that's held in a separate channel "news_and_articles".

For example, if you're viewing the 'Karl' attorney entry and click the 'Blog Posts' tab, it will display the title and date of the articles written by only Karl with links to those articles held in a separate channel.

The problem I'm having now is that the "Blog Posts" tab is empty and not pulling any data, only the title and entry of the entry you're viewing.

I've tried using:

{exp:channel:entries channel="attorneys|news_and_articles"}

combined with

{if blog_posts_tab == 'Yes' || channel_short_name == "news_and_articles"}

Here's the partial template code:

{exp:channel:entries channel="attorneys|news_and_articles"}
    <!-- ========== BIO DETAIL ========== -->
    <div data-equalizer class="row">
        <div data-equalizer-watch class="large-6 columns medium-6 large-push-6 end">
            <img src="{attorney_portrait}" class="right arrow-mask-left" alt="">
        </div>
        <div data-equalizer-watch class="large-5 columns medium-6 large-offset-1 large-pull-6">
            <div class="vertical-align">
                {body}
                <h5><a href="tel: 1-{attorney_phone_number}" class="normal">{attorney_phone_number}</a>
                  {if attorney_phone_extension != ""}, {attorney_phone_extension}{/if}</h5>
                <h5><a href="mailto:{attorney_email}" class="normal">{attorney_email}</a>
                </h5>
                {if v-card != ""}<a href="{v-card}" class="button">V-card</a>{/if} 

                {if attorney_linkedin_profile != ""}
                <h5>
                    <a href="{attorney_linkedin_profile}" class="normal" target="_blank">
                        <img src="/img/global/icon-social-square-blue-linkedin.svg" width="18" height="18" alt="">LinkedIn Profile</a>
                </h5>{/if}
            </div>
        </div>
    </div>
    <br>
            &lt;!-- ==========   TABS CONTENT   ========== --&gt;
            <div class="tabs-content">
                <div id="tab-1" class="content active">
                    <div class="large-12 medium-11 columns medium-centered">
                        {tab-1-content}
                    </div>
                </div>

                {if tab-2-content != ""}
                <div id="tab-2" class="content">
                    <div class="large-12 medium-11 columns medium-centered">
                        {tab-2-content}
                    </div>
                </div>{/if} 

                {if tab-3-content != ""}
                <div id="tab-3" class="content">
                    <div class="large-12 medium-11 columns medium-centered">
                        {tab-3-content}
                    </div>
                </div>{/if} 

                {if tab-4-content != ""}
                <div id="tab-4" class="content">
                    <div class="large-12 medium-11 columns medium-centered">
                        {tab-4-content}
                    </div>
                </div>{/if} 

                {if blog_posts_tab == 'Yes' || channel_short_name == "news_and_articles"}
                <div id="tab-5" class="content">
                    <div class="large-12 medium-11 columns medium-centered">
                        <ul class="no-bullet">
                            <li>
                                <h6><a href="{title_permalink}">{title}
                                    <div class="text-serif">
                                      <small>{entry_date format="%l, %F %d, %Y"}</small>
                                    </div></a>
                                </h6>
                                <hr>
                            </li>
                        </ul>
                    </div>
                </div>
                {/if}
    {/exp:channel:entries}

Is something like this possible??? Do I need an extra plug-in like Stash?

Here's the template that's working: http://www.krinternetlaw.com/attorneys/karl-kronenberger-profile

And entry that's not working: http://www.krinternetlaw.com/attorneys/karl-kronenberger

Thanks so much!!! Danny

3

No add-ons are necessary. You could use an embed, passing the lawyer's member ID to the embedded template. Embedded templates are parsed separately, and would allow you to use a separate channel entries tag inside another one. You would use the passed member ID in the author_id= parameter of the tag on the "inner" template.

7
  • Thanks! But that didn't seem to work on the individual entries, only the main overall template. You can see the results here: krinternetlaw.com/attorneys If you click the "Blog Posts" tab, it pulls up the entries, but on the individual persons entry, it's still blank. Thoughts? – Danny Lewandowski Aug 4 '14 at 23:40
  • Can you share the opening Channel Entries tag on the embedded template? First guess would be dynamic="no". – Derek Jones Aug 5 '14 at 0:51
  • Ah ha! That seemed to do it! You rule. The opening tag for the embedded template is {exp:channel:entries channel="news_and_articles" dynamic="no"}. Now what would be the best way to show just that particular author? – Danny Lewandowski Aug 5 '14 at 3:28
  • You want limit="1" require_entry="yes" author_id="{embed:author_id}". In the parent template you will pass the author ID to the embedded template as described in the link in the answer. – Derek Jones Aug 5 '14 at 15:04
  • Tried that with no luck. To clarify, that embedded template tag would become {exp:channel:entries channel="news_and_articles" dynamic="no" limit="1" require_entry="yes" author_id="{embed:author_id}"} and the parent template embed tag would become {embed="attorneys/_blog-post-tab" author_id="{embed:author_id}"} , right? Since there's no author id association yet, I'll also have to add an author_id entry selection in the Publish section. Thanks again for the help and sorry to be a noob about this. Brain is scrambled. – Danny Lewandowski Aug 5 '14 at 15:30

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.