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.

RSS template issue

February 24, 2010 10:14am

Subscribe [2]
  • #1 / Feb 24, 2010 10:14am

    George K

    75 posts

    I want to include in the RSS feed different templates sets.

    Is it possible to do this:

    If master web log name = weblog1 then :

    <link rel="alternate" type="text/html" href="http://mywebsite/index.php/id/{entry_id}" />

    If master web log name = weblog2 then :

    <link rel="alternate" type="text/html" href="http://mywebsite/index.php/id3/{entry_id}"
    />

    (the change is simply in the id after index.php)

    Is this possible?? If yes, can I get some example code?

  • #2 / Feb 24, 2010 3:21pm

    Ingmar

    29245 posts

    I don’t see why not? What have you tried so far? Can you show us a little more of your code? It looks like a simple conditional might suffice.

  • #3 / Feb 24, 2010 3:27pm

    George K

    75 posts

    Well this is the code. I have never used an if statement.

    Is it possible you give ma a hint and I will take it from there?

    {assign_variable:master_weblog_name="buy_sell_hold|special_situation|global_macro|essay|all_forex| charts|market_intelligence | market_talk_news|  podcast"}
    
    {assign_variable:atom_feed_location="site/atom"}
    
    {exp:rss:feed weblog="{master_weblog_name}"}
    
    <?xml version="1.0" encoding="{encoding}"?>
    <feed >
    
        <title type="text">{exp:xml_encode}{weblog_name}{/exp:xml_encode}</title>
        <subtitle type="text">{exp:xml_encode}{weblog_name}:{weblog_description}{/exp:xml_encode}</subtitle>
        <link rel="alternate" type="text/html" href="{weblog_url}" />
        <link rel="self" type="application/atom+xml" href="{path=/feed/atom}" />
        <updated>{gmt_edit_date format='%Y-%m-%dT%H:%i:%sZ'}</updated>
        <rights>Copyright (c) {gmt_date format="%Y"}, {author}</rights>
        <generator uri="http://expressionengine.com/" version="{version}">ExpressionEngine</generator>
        <id>tag:{trimmed_url},{gmt_date format="%Y:%m:%d"}</id>
    
    {exp:weblog:entries weblog="{master_weblog_name}" limit="15" rdf="off" dynamic_start="on" disable="member_data|trackbacks"}
        <entry>
          <title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
    
          <link rel="alternate" type="text/html" href="http://www.market-talk.net/index.php/id/{entry_id}" /> 
    
    
          {gmt_entry_date format="%Y-%m-%dT%H:%i:%sZ"}</published>
          <updated>{gmt_edit_date format='%Y-%m-%dT%H:%i:%sZ'}</updated>
          <author>
                <name>{author}</name>
                <email>{email}</email>
                {if url}<uri>{url}</uri>{/if}
          </author>
    {categories}
          <category term="{exp:xml_encode}{category_name}{/exp:xml_encode}"
            scheme="{path=site/index}"
            label="{exp:xml_encode}{category_name}{/exp:xml_encode}" >{/categories}
          <content type="html"><![CDATA[
           {summary}
    
    Original link:<a href="http://www.market-talk.net/index.php/id/{entry_id}">http://www.market-talk.net/index.php/id/{entry_id}</a>
    
    
          ]]></content>
        </entry>
    {/exp:weblog:entries}
    
    </feed>
    
    {/exp:rss:feed}
  • #4 / Feb 24, 2010 5:14pm

    Ingmar

    29245 posts

    You can read more about conditionals here. Let me move this thread to Howto for you.

  • #5 / Feb 24, 2010 6:15pm

    George K

    75 posts

    {exp:weblog:entries weblog="{master_weblog_name}" limit="15" rdf="off" dynamic_start="on" disable="member_data|trackbacks"}
        <entry>
          <title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
    
    {if weblog == "contrarian"}
    
          <link rel="alternate" type="text/html" href="http://www.market-talk.net/index.php/id/{entry_id}" /> 
    
    {if:else weblog != "contrarian"  }
    
          <link rel="alternate" type="text/html" href="http://www.market-talk.net/index.php/id3/{entry_id}" /> 
    
    {/if}

    Ok I tried this and I get errors. I also tried {master_weblog_name} instead of weblog and got the same thing.

    What am I missing?

  • #6 / Feb 24, 2010 6:30pm

    George K

    75 posts

    Ok I got the erros to stop.

    But now I have another problem.

    in this code:

    {if weblog == "contrarian"}
    
          <link rel="alternate" type="text/html" href="http://www.market-talk.net/index.php/id3/{entry_id}" /> 
    
    {if:else}
    
     <link rel="alternate" type="text/html" href="http://www.market-talk.net/index.php/id/{entry_id}" /> 
    
    {/if}

    I always get the second statement to execute, even though the weblog contrarian registers in the feed.

    Am I using weblog wrong or something?

  • #7 / Feb 24, 2010 6:36pm

    George K

    75 posts

    I have tried

    weblog and {weblog_short_name} and I get the same result

  • #8 / Feb 24, 2010 6:38pm

    George K

    75 posts

    hmmmm I found it

    I used

    {if (weblog_short_name) == "contrarian"}

    And it worked!!

    Is there another way?

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

ExpressionEngine News!

#eecms, #events, #releases