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.

Double-Posting - Shouldn't this work?

October 23, 2012 4:16pm

Subscribe [5]
  • #1 / Oct 23, 2012 4:16pm

    For this example let’s assume that:

    1. I have a News and Music weblogs. I’d like to have an option to double post from News to Music. Both weblogs have the same fields group.
    2. I have a multi drop-down custom field where when publishing something in News I can select to also publish to the Music landing page.
    3. On the Music landing page template I’d like to display News entries only if they’ve been selected from the above custom field.
    Also, in the same template I need to mix these selected News entries with entries published from the Music weblog in a normal fashion.

    I’ve been testing with this, but it doesn’t seem to work with that double conditional in there. Let’s say News weblog_id was 10 and the multi drop-down list custom field was called multi_publish.

    {exp:weblog:entries weblog="news|music" disable="categories|member_data|trackbacks|pagination" dynamic="off" orderby="entry_date" sort="desc"}
    {if weblog_id == "10" AND multi_publish == "Music"}
    <h1><a href="http://{url_title_path=">{title}</a></h1>
    {if:else}
    <h1><a href="http://{url_title_path=">{title}</a></h1>
    {/if}
    {/exp:weblog:entries}

    You can see that I also need to link to different section URL detail templates depending on where the entry was published from originally. The code above should display url_title_path=“news/details” and url_title_path=“music/details”

    =======

    I know I can also do this (search parameter) and it works when I tested it, but I don’t want to make the same selection in the drop-down when publishing from the Music weblog every time. It would be very redundant.

    {exp:weblog:entries weblog="news|music" disable="categories|member_data|trackbacks|pagination" dynamic="off" orderby="entry_date" sort="desc" search:multi_publish="=Music"}
    {if weblog_id == "10"}
    <h1><a href="http://{url_title_path=">{title}</a></h1>
    {if:else}
    <h1><a href="http://{url_title_path=">{title}</a></h1>
    {/if}
    {/exp:weblog:entries}

    The code above should display url_title_path=“news/details” and url_title_path=“music/details”

    Somebody must have done something like it before…

    Virtual high-give and kudos if you can help.

    😊

    -Martin

  • #2 / Oct 23, 2012 9:49pm

    Just a quick update on this. I’ve lost most of the day trying to figure it out.

    The only way I can get the conditionals to work is with the search parameter in the weblog:entries tag (example 2 above), however that makes it for a very poor user experience when publishing Music entries to the Music weblog. I should only be asking to make the selection in the custom field when publishing from the News weblog, not Music’s.

    FYI, if I don’t use the search parameter in the weblog:entries tag the system is trying to spit out ALL the entries until it gets to the one that was selected. If I have to set the limit to 10 and I published the selected entry as number 15 in the system (by entry_date), it will never display.

    There’s gotta be a way to make this work.

    :grrr:

    -Martin

  • #3 / Oct 23, 2012 10:13pm

    MediaGirl Inc.

    186 posts

    Try:

    {if weblog_id == "10" AND "{multi_publish}" == "Music"}
    
    or even
    
    {if "{weblog_id}" == "10" AND "{multi_publish}" == "Music"}
  • #4 / Oct 23, 2012 10:15pm

    MediaGirl Inc.

    186 posts

    Can I ask why you aren’t using categories for this? If my code suggestion doesn’t work, I’d suggest changing to two categories. The channel tag code is straight forward.

  • #5 / Oct 23, 2012 10:17pm

    Benjamin Kohl

    10 posts

    This may have nothing to do with it, but I couldn’t help but notice that your a tag’s href is referencing the url_title_path variable incorrectly. There is an equal sign where there should be a closing curly brace.

    <a href="http://{url_title_path}">{title}</a>
  • #6 / Oct 23, 2012 10:18pm

    MediaGirl Inc.

    186 posts

    Nice catch Ben! I didn’t even see that. Was so focused on the conditional. A missing } would cause issues for sure.

  • #7 / Oct 23, 2012 10:24pm

    Anna,

    Thank you. I’ve tried all variations, including the examples you’ve posted. Still nothing. I can output the value of the custom field fine, so I know it’s working. When I combine the two weblogs and use the double conditional is when things stop working. Without the search parameter and with the limit=“10” the system tries to spit out everything until it finds the “selected” entry, like I’ve mentioned in my first reply.

    Also, I’m not using categories because they are used to archive something else already.

    Benjamin,

    The “code” on the forums doesn’t display url_title_paths correctly, it’s been like that forever… that’s why I posted this below each block of code: The code above should display url_title_path=“news/details” and url_title_path=“music/details”

    😊

    -Martin

  • #8 / Oct 23, 2012 10:28pm

    MediaGirl Inc.

    186 posts

    Are you on the most recent version of EE? Might be a bug. I’ve never seen it though.

    Also, triple check that “Music” is what’s being stored in the DB. Is there a space maybe before or after?

    Can you paste your exact code to pastie.org so we know we’re seeing it correctly?

  • #9 / Oct 23, 2012 11:41pm

    Anna & others,

    It’s on the latest 1.7.x

    The values are being stored correctly. I’ve tested against the multi_publish field selected and not from both news and music weblog entries to make sure nothing weird was going on.

    Here’s the code that should have been displayed correctly in the original post.
    http://pastie.org/5106905

    Like I said I’ve tried countless combinations of conditionals only to come to the conclusion posted in my first reply. I believe the key to everything is in it somewhere.
    http://ellislab.com/forums/viewthread/228518/#1036992

    -Martin

  • #10 / Oct 23, 2012 11:51pm

    MediaGirl Inc.

    186 posts

    Is that code in Pastie a direct paste from your code? If so, your hrefs are reversed in your conditional. Is it possible that’s the issue?

    If not, then I’d need to talk to you on the phone to help more. Feel free to call… (505) 205-1597. I’m working for awhile more.

  • #11 / Oct 24, 2012 12:01am

    Anna,

    Not sure what you mean. But when doing all different variations I’ve dumbed it down even more to just test against entry {titles} and nothing else. What you’re seeing is basically the first original variation.

    I have to make a late run to the vet to get my doggie medicine. I’ll be back shortly, so I’ll try to give you a buzz then!

    -Martin

  • #12 / Oct 24, 2012 12:04am

    MediaGirl Inc.

    186 posts

    You have this…

    {if weblog_id == "10" AND multi_publish == "Music"}
    <h1><a href="http://{url_title_path=">{title}</a></h1>
    {if:else}
    <h1><a href="http://{url_title_path=">{title}</a></h1>
    {/if}

    but it should be based on your conditional:

    {if weblog_id == "10" AND multi_publish == "Music"}
    <h1><a href="http://{url_title_path=">{title}</a></h1>
    {if:else}
    <h1><a href="http://{url_title_path=">{title}</a></h1>
    {/if}

    I swamped “music/details” and “news/details” in your hrefs.

  • #13 / Oct 24, 2012 12:33am

    Anna,

    You can see the code tags in the EE forums don’t work correctly. Either way it doesn’t really matter what’s between the conditionals. I’m calling ya…

    -Martin

  • #14 / Oct 24, 2012 2:06am

    Thanks goes out to Anna! The code was fine, what I was trying to do with the conditionals was not going to work, and the search parameter was gonna hinder the site’s performance too much. I decided to do the same with the categories. Thanks for that multi-categories tip, Anna! It works like a charm.

    -Martin

  • #15 / Oct 24, 2012 8:28am

    Boyink!

    5011 posts

    FWIW if you are in this situation in the future there is no need for a conditional to point links to weblog (or channel) specific detail pages in results from mixed weblogs/channels. 

    You can specify the detail page in your weblog/channel prefs then use the {comment_url_title_auto_path} variable for the link.

    I’ve a tutorial on the approach here:

    http://www.train-ee.com/courseware/free-tutorials/comments/working-with-combined-weblogs

    I’m not sure it would have ultimately been a success with your other logic going on but would have removed some of the conditional logic at least.

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

ExpressionEngine News!

#eecms, #events, #releases