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.

Comparing variables contained in multiple weblogs

August 07, 2007 7:00pm

Subscribe [2]
  • #1 / Aug 07, 2007 7:00pm

    muddygrey

    9 posts

    Is there any way to compare the values from two similar custom fields in two different weblogs?  The site that I am working on is for a magazine.  In the printed publication several articles are nothing more than listings of various products they recommend.

    I have two weblogs currently set up for this.  One weblog is for the individual products.  I did this for the benefit of searches.  For example say a visitor comes to the site looking for books on gardening, they would be able to pull all the books on gardening individually without any unrelated books and they would be able to see gardening books that appeared in multiple issues.  The second weblog is kind of a “container”, it will be used to add information such as article title, tagline and if there was some lead in text it would be stored here.

    I’d like to set up a template that first pulls in the information stored in the “container” and then pull in only the listings that appeared in that article in the printed piece.  So in both weblogs I have set up two custom fields.  The first is a relationship to a third weblog where I am storing issue information.  The second will be a unique field used only to match listings to the correct container.  For now I am using a page number.

    Is there anyway in the template that I can compare these fields so I can pull the correct listings into the appropriate container?

  • #2 / Aug 08, 2007 3:39am

    Ingmar

    29245 posts

    I am not following your setup completely, but to compare two custom fields in different weblogs, you’ll probably need to resort to direct SQL.

  • #3 / Aug 08, 2007 12:01pm

    muddygrey

    9 posts

    Thanks for the reply Ingmar, I was afraid that I would have to do something like that.

    As far as the setup is concerned I had been trying to use an embedded template within a template and then passing the custom fields that I wanted to compare over as embedded variables.  But for some reason when the variable were passed to the embedded template I couldn’t use them in my conditional. 

    Here is the code from the first template:

    {exp:weblog:entries weblog="prod_container" 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="site/header" issue="{prod_container_issue}" page="{prod_container_page}"}<br />
    {/exp:weblog:entries}

    And here is the second template, the embedded one, and the conditional:

    {exp:weblog:entries weblog="prod_listing" orderby="date" sort="desc"}
    
        {if prod_listing_issue == "{embed:issue}" && prod_listing_page == "{embed:page}"}
            <h3>{title}</h3>
    <p>        <br />
                {prod_listing_des}<br />
            <br />
        {/if}</p>
    
    <p>{/exp:weblog:entries}

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

ExpressionEngine News!

#eecms, #events, #releases