Behind the Curtain Part III
Posted: 24 April 2007 01:20 PM   [ Ignore ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16399
Joined  06-03-2002

I promised more meat in the next installment of entries peeking behind the curtain of the ExpressionEngine.com redesign, and I shall deliver.  Meatier, but still lean: this design decision was low fat.  If you subscribe to our feeds, you’ll notice that the URLs all begin as http://expressionengine.com/feeds/atom/ and http://expressionengine.com/feeds/rss/.  The reason quite simply is that we have only two templates for feeds, which saved us quite a bit of template creation and cut and pasting.

Continue reading…

 Signature 
Profile
MSG
 
 
Posted: 25 April 2007 10:19 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  887
Joined  12-14-2004

I’ve gotta tell you, that is damn impressive. You don’t even know how bad I wish I understood it in practice enough to do on my own with our multiple feeds. I get the concept, and it’s stellar…damn me and my lack of PHP knowledge.

 Signature 

Love gadgets, technology, and pop culture? Visit us at Gear Live: http://www.gearlive.com

Profile
 
 
Posted: 25 April 2007 08:42 PM   [ Ignore ]   [ # 2 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16399
Joined  06-03-2002

Just give a try, Dru.  Cut and paste our template into a new RSS type template with PHP parsing set on Input, and get rid of all of the “case ‘segment’:” blocks except for one.  Whatever you want to use as the third segment, put that in place of ‘segment’, and then change the other variables to match your custom fields, paths, statuses, etc.  Then access that template with the third URL segment that you set the block up for.  Then you can cut and paste the working “case block” within the switch { } control structure and begin adding the information for your other feeds.

 Signature 
Profile
MSG
 
 
Posted: 26 April 2007 01:15 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  267
Joined  02-22-2006

This looks like another great blog post! Thanks Derek! I am totally looking forward to your next post. I really enjoy seeing how the pros do advanced things in EE. smile

Keep-up the great work!
Cheers,
Micky

Update: Oooh, this is great! I just setup my atom feed… works perfectly! Many many thanks! Moving-on to the RSS template. Derek, you rock! grin

Profile
 
 
Posted: 26 April 2007 10:17 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  192
Joined  03-31-2006

Holy schmolly! Thank you so much for this detailed walkthrough! :D

 Signature 

Elegant webstandards based design - Rockatee

Profile
 
 
Posted: 27 April 2007 06:35 AM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1477
Joined  09-16-2004

Another great article,Derek. It’s indeed amazing what you can pull off by using even some basic php in your templates.

 Signature 

Peace, e-man.
stookstudio.com, websites built with care and web standards. LinkedIn profile

Profile
 
 
Posted: 24 May 2007 05:48 PM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  768
Joined  03-16-2002

First: Thanks for the BTC series so far, Derek ... very interesting indeed!

Am I correct in asuming that the

exp:weblog:entries site="expressionengine|ellislab"

parameter in your example isn’t available in EE 1.5.2?

Oh ... and I’d really love to see more BTC parts. Any chance for the mentioned next part in the near future?

-Markus

Profile
 
 
Posted: 24 May 2007 05:51 PM   [ Ignore ]   [ # 7 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16399
Joined  06-03-2002
ms - 24 May 2007 05:48 PM

First: Thanks for the BTC series so far, Derek ... very interesting indeed!

Am I correct in asuming that the

exp:weblog:entries site="expressionengine|ellislab"

parameter in your example isn’t available in EE 1.5.2?

Oh ... and I’d really love to see more BTC parts. Any chance for the mentioned next part in the near future?

-Markus

Sharp eye, Markus, surprised no one remarked on that parameter yet. :-D

My attention has been pulled pretty tightly in the past couple weeks, which is why the next BTC hasn’t been published yet, but they have not been forgotten.

 Signature 
Profile
MSG
 
 
Posted: 22 October 2007 09:45 PM   [ Ignore ]   [ # 8 ]  
Lab Assistant
RankRank
Total Posts:  134
Joined  08-22-2007

I have been attempting to implement your setup for hours to no avail :-(.  I’m sure I’m missing something, and I hate to ask questions when I think I must be missing something simple.  I just cant seem to get it.  The feed processes, but it comes up with the title and no entries.  Any assistance would be appreciated.

Thanks!

Here’s what I have:

<?php
global $IN;

$seg3 = (isset($IN->SEGS['3'])) ? $IN->SEGS['3'] : '';
$weblog         = '';
$entry_path     = '';
$category_path    = '';
$statuses        = '';
$fields            = '';
$use_entry_id    = FALSE;

if (
$seg3 == '')
    
$seg3 = 'full';
    
switch (
$seg3)
{
    
case 'guides':
        
$weblog            = 'guide_blog';
        
$entry_path        = 'articles/entry';
        
$category_path    = 'guides';
        
$fields            = '{summary}{body}';
        
$statuses        = 'open';
        break;
      
}
?>

{exp
:rss:feed weblog="<?=$weblog?>" status="<?php echo $statuses;?>"}

<?xml version
="1.0" encoding="{encoding}"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="{weblog_language}">

    <
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=xml/atom/{segment_3}}" />
    <
updated>{gmt_edit_date format='%Y-%m-&#xdT;%H:%i:&#xsZ;'}</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="<?=$weblog?>" limit="15" rdf="off" dynamic_start="on" disable="member_data|trackbacks" status="<?=$statuses?>"}
    
<entry>
      <
title>{exp:xml_encode}{title}{/exp:xml_encode}</title>
      <
link rel="alternate" type="text/html" href="<?php if ($use_entry_id === TRUE): ?>{entry_id_path='<?=$entry_path?>'}<?php else: ?>{url_title_path='<?=$entry_path?>'}<?php endif; ?>" />
      <
id>tag:{trimmed_url},{gmt_entry_date format="%Y"}:{relative_url}/{weblog_id}.{entry_id}</id>
      <
published>{gmt_entry_date format="%Y-%m-&#xdT;%H:%i:&#xsZ;"}</published>
      <
updated>{gmt_edit_date format='%Y-%m-&#xdT;%H:%i:&#xsZ;'}</updated>
      <
author>
            <
name>{author}</name>
            
{if url}<uri>{url}</uri>{/if}
      
</author>
{categories}
      
<category term="{exp:xml_encode}{category_name}{/exp:xml_encode}"
        
scheme="{path='<?=$category_path?>'}"
        
label="{exp:xml_encode}{category_name}{/exp:xml_encode}" />{/categories}
      
<content type="html"><![CDATA[
        <?
=$fields?>
      ]]
></content>
    </
entry>
{/exp:weblog:entries}

</feed>

{/exp:rss:feed}

Profile
 
 
Posted: 22 October 2007 10:59 PM   [ Ignore ]   [ # 9 ]  
Lab Assistant
RankRank
Total Posts:  134
Joined  08-22-2007

well…  I figured it out.  Maybe it is something that is documented, but I didn’t know any better.  Your cases cannot match any existing template group names!

Just changed articles to articles_feed and amazing…  it works!  grin

Thanks for the Behind The Curtain posts Derek!!  They are excellent.

Profile
 
 
Posted: 23 October 2007 06:06 AM   [ Ignore ]   [ # 10 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16399
Joined  06-03-2002

Template groups will only be in the first, not the third segments, but I see that you have ‘guides’ there and not ‘articles’ nor ‘articles_feed’, so I’m confused.  In any case, glad you got it working and found it useful!

 Signature 
Profile
MSG
 
 
Posted: 23 October 2007 08:09 AM   [ Ignore ]   [ # 11 ]  
Lab Assistant
RankRank
Total Posts:  134
Joined  08-22-2007

Sorry.  It was late.  I actually have 9 different feeds, articles is another one of the feeds. 

It is working great!  Well the atom one is at least.  Now I need to go figure out what I messed up in the rss template.  The feeds that have custom fields and statuses in them are not working at all.  I’m sure I just messed something up while trying to figure out why none of them work working. 

Also I’m not so sure how I can create a “full” feed?  my entry templates are different for each blog.  Any ideas?

Thanks!

Profile
 
 
Posted: 23 October 2007 08:33 AM   [ Ignore ]   [ # 12 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16399
Joined  06-03-2002

A “full” feed will only work if you have an acceptable way to list all of the entries together with a weblog entries tag.  Whether or not that will work for your site you will have to make that determination.

 Signature 
Profile
MSG
 
 
Posted: 23 October 2007 11:17 AM   [ Ignore ]   [ # 13 ]  
Lab Assistant
RankRank
Total Posts:  134
Joined  08-22-2007

How can I handle conditionals such as the following:

{if '{summary}' != ''}{summary}{if:else}{exp:word_limit total="100"}{body}{/exp:word_limit}{/if}

as a value for $fields in the case select?

Profile
 
 
Posted: 23 October 2007 11:33 AM   [ Ignore ]   [ # 14 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16399
Joined  06-03-2002

Just like you have it there, but double check the Troubleshooting Conditionals KB article.  You shouldn’t be using a quoted and braced variable in your conditional.

 Signature 
Profile
MSG
 
 
Posted: 23 October 2007 12:12 PM   [ Ignore ]   [ # 15 ]  
Lab Assistant
RankRank
Total Posts:  134
Joined  08-22-2007

Derek,
Thanks for the heads up on the quoted and braced.  I have that issue throughout my site.  Cleaning it up now.

With the RSS feed, I’m getting the following error when I run it:

XML Parsing Error: junk after document element
Line Number 2, Column 1:Parse error:  parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /www/eh6627/public_html/XXXXX/core/core.functions.php(635) : eval()‘d code on line 35

^

Here’s the case code:

case 'guides_feed':
        
$weblog                = 'guide_blog';
        
$entry_path            = 'guides/entry';
        
$category_path        = 'guides/index';
        
$fields                = '{if summary != ''}{summary}{if:else}{exp:word_limit total="100"}{body}{/exp:word_limit}{/if}';
        
$statuses                = 'open';
        break;


EDIT:  the $fields line is line 35

I don’t want to keep bugging you, so whenever you get a chance, let me know.

I appreciate your help!!

Profile
 
 
Posted: 23 October 2007 12:23 PM   [ Ignore ]   [ # 16 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16399
Joined  06-03-2002

$fields = '{if summary != ''}{summary}{if:else}{exp:word_limit total="100"}{body}{/exp:word_limit}{/if}';

You have single quotes within a single quoted string, so you either need to escape them, or what I prefer for code legibility is to consistently use the opposite quote within a quoted string.  In other words, if you have a single quoted string, use double quotes for attributes inside.  If you have a double quoted string, use single quotes inside.

$fields = '{if summary != ""}{summary}{if:else}{exp:word_limit total="100"}{body}{/exp:word_limit}{/if}';

 Signature 
Profile
MSG
 
 
Posted: 23 October 2007 01:29 PM   [ Ignore ]   [ # 17 ]  
Lab Assistant
RankRank
Total Posts:  134
Joined  08-22-2007

ahh…  something so simple grin.  Thanks for the explaination!

Thanks for all of your assistance on this.  I owe you a beer!

Best regards,

Rick

Profile
 
 
Posted: 23 October 2007 04:38 PM   [ Ignore ]   [ # 18 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16399
Joined  06-03-2002

lol, thanks Rick!

 Signature 
Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66457 Total Logged-in Users: 69
Total Topics: 84841 Total Anonymous Users: 20
Total Replies: 455264 Total Guests: 219
Total Posts: 540105    
Members ( View Memberlist )
Newest Members:  AtosheviboyjbcobbsOut_ThereChrisClowerstevelovePhoenix FirstgoyoqshimshimSchaapy