首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MovableType:有可能为“今日”条目提供一个rss提要吗?

MovableType:有可能为“今日”条目提供一个rss提要吗?
EN

Stack Overflow用户
提问于 2010-03-09 16:23:52
回答 2查看 330关注 0票数 2

背景

我们的电子邮件供应商支持动态内容的rss提要,我们成功地用于“每日标题”类型的电子邮件。这是一个很大的帮助自动化许多不同的电子邮件,我们没有工作人员每天创建。我们的一位工作人员要求,他的每日电子邮件(最近从他的活动类型博客标题)只有标题从条目张贴在那一天。

我的问题

既然我们在他的博客中使用可移动类型,那么是否有一种方法可以生成一个只包含当前发布的条目的rss提要呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-03-12 15:04:25

您的解决方案可以通过在mt:Entries上使用"天数“参数来简化:

代码语言:javascript
复制
<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><$MTBlogName remove_html="1" encode_xml="1"$></title>
<link rel="alternate" type="text/html" href="<$MTBlogURL encode_xml="1"$>" />
<link rel="self" type="application/atom+xml" href="<$MTBlogURL$>atom.xml" />
<id>tag:<$MTBlogHost exclude_port="1" encode_xml="1"$>,<$MTDate format="%Y"$>:<$MTBlogRelativeURL encode_xml="1"$>/<$MTBlogID$></id>
<link rel="service.post" type="application/atom+xml" href="<$MTCGIPath$><$MTAtomScript$>/weblog/blog_id=<$MTBlogID$>" title="<$MTBlogName encode_html="1"$>" />
<updated><MTEntries lastn="1"><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></MTEntries></updated>
<MTIfNonEmpty tag="MTBlogDescription"><subtitle><$MTBlogDescription remove_html="1" encode_xml="1"$></subtitle></MTIfNonEmpty>
<generator uri="http://www.sixapart.com/movabletype/">Movable Type <$MTVersion$></generator>

<MTEntries days="1">

<entry>
<title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>  
<link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>" />
<link rel="service.edit" type="application/atom+xml" href="<$MTCGIPath$><$MTAtomScript$>/weblog/blog_id=<$MTBlogID$>/entry_id=<$MTEntryID$>" title="<$MTEntryTitle encode_html="1"$>" />
<id><$MTEntryAtomID$></id>

<published><$MTEntryDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></published>
<updated><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></updated>

<summary><$MTEntryExcerpt remove_html="1" encode_xml="1"$></summary>
<author>
    <name><$MTEntryAuthorDisplayName encode_xml="1"$></name>
    <MTIfNonEmpty tag="MTEntryAuthorURL"><uri><$MTEntryAuthorURL encode_xml="1"$></uri></MTIfNonEmpty>
</author>
<MTEntryCategories>
    <category term="<$MTCategoryLabel encode_xml="1"$>" />
</MTEntryCategories>
<content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTBlogURL encode_xml="1"$>">
<$MTEntryBody encode_xml="1"$>
<$MTEntryMore encode_xml="1"$>
</content>
</entry>

</MTEntries>

不需要自己检查日期,这也会删除您的版本创建的空"entry“标记。

票数 2
EN

Stack Overflow用户

发布于 2010-03-09 19:26:36

好吧,所以我自己想出来了。首先,我必须创建一个新的提要,我将其命名为"daily.xml“,并将默认代码从atom.xml复制到其中。然后,我使用setvarblock来定义当前日期和发布日期的变量。完成之后,我使用if来比较这两个变量,并显示匹配的变量。

代码:

代码语言:javascript
复制
<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
    <title><$MTBlogName remove_html="1" encode_xml="1"$></title>
    <link rel="alternate" type="text/html" href="<$MTBlogURL encode_xml="1"$>" />
    <link rel="self" type="application/atom+xml" href="<$MTBlogURL$>atom.xml" />
    <id>tag:<$MTBlogHost exclude_port="1" encode_xml="1"$>,<$MTDate format="%Y"$>:<$MTBlogRelativeURL encode_xml="1"$>/<$MTBlogID$></id>
    <link rel="service.post" type="application/atom+xml" href="<$MTCGIPath$><$MTAtomScript$>/weblog/blog_id=<$MTBlogID$>" title="<$MTBlogName encode_html="1"$>" />
    <updated><MTEntries lastn="1"><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></MTEntries></updated>
    <MTIfNonEmpty tag="MTBlogDescription"><subtitle><$MTBlogDescription remove_html="1" encode_xml="1"$></subtitle></MTIfNonEmpty>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type <$MTVersion$></generator>

    <MTEntries lastn="15">


    <entry>

    <!-- this sets the current date to a variable named "TodaysDate" -->
    <mt:setvarblock name="TodayDate"><$mt:Date format="%Y%m%d"></mt:setvarblock>

    <!-- this sets the entry publish date to a variable named "PublishedDate" -->       
    <mt:setvarblock name="PublishedDate"><$mt:EntryDate format="%Y%m%d"></mt:setvarblock>

    <!-- starts an IF statement comparing equality of "PublishedDate" and "TodayDate". note: for some reason the second variable needs to have an '$' added to the front --> 
    <mt:if name="PublishedDate" eq="$TodayDate">

    <!-- the rest of this (except the end of the IF statement) is copied from default template -->
    <title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>  
    <link rel="alternate" type="text/html" href="<$MTEntryPermalink encode_xml="1"$>" />
    <link rel="service.edit" type="application/atom+xml" href="<$MTCGIPath$><$MTAtomScript$>/weblog/blog_id=<$MTBlogID$>/entry_id=<$MTEntryID$>" title="<$MTEntryTitle encode_html="1"$>" />
    <id><$MTEntryAtomID$></id>

    <published><$MTEntryDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></published>
    <updated><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></updated>

    <summary><$MTEntryExcerpt remove_html="1" encode_xml="1"$></summary>
    <author>
        <name><$MTEntryAuthorDisplayName encode_xml="1"$></name>
        <MTIfNonEmpty tag="MTEntryAuthorURL"><uri><$MTEntryAuthorURL encode_xml="1"$></uri></MTIfNonEmpty>
    </author>
    <MTEntryCategories>
        <category term="<$MTCategoryLabel encode_xml="1"$>" />
    </MTEntryCategories>
    <content type="html" xml:lang="<$MTBlogLanguage ietf="1"$>" xml:base="<$MTBlogURL encode_xml="1"$>">
    <$MTEntryBody encode_xml="1"$>
    <$MTEntryMore encode_xml="1"$>
    </content>

    <!-- end of our IF statement -->
    </mt:if>
    </entry>


    </MTEntries>

</feed> 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2410593

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档