Skip to content

A Textpattern Conditional Plugin for Facebook's Instant Articles

Notifications You must be signed in to change notification settings

michaelkpate/mkp_if_ia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

mkp_if_ia

This conditional tag examines the url of the current page and determines if the url ends in ‘ia.’ This allows for a custom page to be rendered using the standards for Facebook’s Instant Articles.

Links

Required Plugins for RSS Feed

mkp_if_ia

Attributes

None

Examples

You will need to create an RSS Feed that meets Facebook’s requirements for Instant Articles.

Create a new section. I called mine ‘ia.’ This is the page template.

<txp:aks_header name="Content-Type" value="application/rss+xml" strip="0" gzip="1" nodebug="1" /><?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
 <channel>
  <title><txp:site_name /></title>
  <description><txp:site_slogan /> - instant articles feed</description>
  <link><txp:link_to_home /></link>
  <atom:link href="<txp:link_to_home /><txp:page_url type="s" />/" rel="self" type="application/rss+xml" />
  <pubDate><txp:rah_function call="safe_strftime" str="rfc822" /></pubDate>
  <txp:article_custom form="ia" section="article" />
 </channel>
</rss>
I made an article template – also called ‘ia’

<item>
<title><txp:title /></title>
<content:encoded>
 <![CDATA[
  <txp:body />
 ]]>
</description>
<guid><txp:permlink /></guid>
<description>
 <txp:rah_function call="strip_tags">
	<txp:body />
 </txp:rah_function>
</description>
<link><txp:permlink />ia/</link>
<pubDate><txp:posted format="%a, %d %b %G %T %Z" /></pubDate>
<author><txp:author /></author>
</item>

You can see an example of the results: http://ampdemo.cmsstyles.com/ia/

You will want something similar to this in your individual article template to display the alternative formatting.

<txp:mkp_if_ia>
 <txp:output_form form="layout_archives_ia" />
<txp:else />
 <txp:output_form form="layout_archives_standard" />
</txp:_mkp_if_amp>

Release History

Version 1.0: May 10th, 2016

About

A Textpattern Conditional Plugin for Facebook's Instant Articles

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages