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.

Variable Question

August 08, 2007 3:11pm

Subscribe [1]
  • #1 / Aug 08, 2007 3:11pm

    muddygrey

    9 posts

    I have a weblog whose entries relate to another weblog.  Is there anyway for me to take the title from the related entry weblog and store it as a variable? 

    Here was my first shot at it:

    {related_entries id="prod_container_issue"}
       {assign_variable: issue_title="{title}"}
    {/related_entries}

    However I can’t seem to access the newly created {issue_title} variable.  Does anyone have any ideas or advice?

    Thanks.

  • #2 / Aug 08, 2007 4:11pm

    BlackHelix

    226 posts

    The assign_variable call won’t work; due to the processing order that EE parses pages.  Assigning variables is done very, very early in the parsing process, long before any weblog tags are used. 


    I assume you have looked over the documentation for the related entries tag here.  You can access the {title} variable directly inside the {related_entries} tag pair—is that what you need, or are you somehow trying to use the related entries {title} outside the related entries tag? 

    I think if the latter is true, you have to use php inside your templates.

  • #3 / Aug 08, 2007 4:42pm

    muddygrey

    9 posts

    Vanceone, I have looked over the documentation.  I’m trying to use the {title} variable outside the {related_entries} tag pair and in a conditional statement.  It’s looking like I may have to use php to accomplish this.  I was hoping to avoid that due to my limited knowledge of php. 

    Thanks for the help and if you have any ideas I’m all ears.

  • #4 / Aug 08, 2007 5:28pm

    muddygrey

    9 posts

    I figured it out.  Sort of.

    Here is what’s in the first template:

    {exp:weblog:entries weblog="prod_container" dynamic="on" orderby="date" sort="desc" limit="15"}
        
        <h1>{title}</h1>
        {if prod_container_tagline}
            <h2>{prod_container_tagline}</h2>
    <p>    {/if}<br />
        <br />
        {if prod_container_summary}<br />
            <br />
                {prod_container_summary}<br />
            <br />
        {/if}<br />
        {embed="products/listings" issue="{related_entries id="prod_container_issue"}{entry_id}{/related_entries}" page="{prod_container_page}"}<br />
    {/exp:weblog:entries}

    And here is what is in the embedded template:

    {exp:weblog:entries weblog="prod_listing" orderby="date" sort="asc"}
    
    <?php
    $listing_issue = "{related_entries id="prod_listing_issue"}{entry_id}{/related_entries}";
    $container_issue = "{embed:issue}";
    
    if ($listing_issue == $container_issue)
    {
    ?>
    
    {if prod_listing_page == "{embed:page}"}
    <h3>{title}</h3>
    <p>{prod_listing_des}<br />
    {/if}</p>
    
    <p><?php<br />
    }<br />
    ?></p>
    
    <p>{/exp:weblog:entries}

    The new problem is if I add the URL Title to the URL string it’s displaying the info from the entry in the prod_container weblog but none of the entries from the embedded template pulling from prod_listing.

    Does anyone have any ideas?

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

ExpressionEngine News!

#eecms, #events, #releases