Share page content between sites using RSS
Posted: Wed Jun 11, 2008 10:59 am
Share any page's {content} block with other site(s) via RSS.
In the absence of multisite capabilities and until that feature is added at some point in 2.0 (see roadmap); I've come up with a Quick-and-Dirty way to share (duplicate) a page's content between different sites using some template modifications and RSS.
Test configuration: Apache 1.3.xx and PHP/cgi 5.1.xx on Linux 2.6.xx running CMSMS 1.3 with mod_rewrite enabled.
Notes:
1. You need to know what IP address your ("destination") server uses for outgoing http requests. We will be modifying the output template(s) on the "origin" site based upon this IP.
2. May require slight modifications to work on configurations other than above.
3. The entire content of the "origin" page's {content} block (as generated and output) is inserted into the resulting RSS feed. As this includes links, you need to ensure you're using FULL domain/path in your links (including images) pointing elsewhere on the "origin" site.
4. What will happen on pages with forms or other complex content is unknown and untested. Has been tested with simple static content (html, text, images) only.
Main use here is a half-dozen sites of same client with shared pages that include things like contact and company info, a list of events (in static html), some simple online shopping pages (that use paypal cart), etc.. This shared content can now be edited via only ONE of the CMSMS installs instead of having to copy/paste it into the other five after every editing session.
Step 1. Modify site template(s) in ORIGIN site's CMSMS:
At the very beginning, before and on the SAME line as DOCTYPE if you have one, add:
where xx.xx.xx.xx is the IP address the REQUESTING server's http requests come from.
At the very end, starting after and on the SAME line as your closing tag, add:
Step 2. Import feed to other site using RSS feed importer. For this example and CMSMS, we'll be using RSS2HTML.
Install RSS2HTML and add the following as a new template, RSSimport:
For each page on the "origin" site you wish to use on the "destination" site, add a RSS feed to RSS2HTML (on "destination" site) using the standard URL to access that page via a browser.
In a ("destination" site) page's content area, use the following module call to bring in the content from the "origin" site via the RSS feed:
Note that each page to be "shared" will have its own feed in RSS2HTML.
Step 3. As necessary...
1. add CSS to destination site to format imported content to fit design
2. adjust internal links on origin site's pages so images and links work as desired on destination site.
EOF 10JUN08/0430CST draft1
EDIT 11JUN08/0555CST draft2 replace UDTs with Smarty variables; eliminates a step and a couple queries.
(attachment is contents of this post as a text file)
In the absence of multisite capabilities and until that feature is added at some point in 2.0 (see roadmap); I've come up with a Quick-and-Dirty way to share (duplicate) a page's content between different sites using some template modifications and RSS.
Test configuration: Apache 1.3.xx and PHP/cgi 5.1.xx on Linux 2.6.xx running CMSMS 1.3 with mod_rewrite enabled.
Notes:
1. You need to know what IP address your ("destination") server uses for outgoing http requests. We will be modifying the output template(s) on the "origin" site based upon this IP.
2. May require slight modifications to work on configurations other than above.
3. The entire content of the "origin" page's {content} block (as generated and output) is inserted into the resulting RSS feed. As this includes links, you need to ensure you're using FULL domain/path in your links (including images) pointing elsewhere on the "origin" site.
4. What will happen on pages with forms or other complex content is unknown and untested. Has been tested with simple static content (html, text, images) only.
Main use here is a half-dozen sites of same client with shared pages that include things like contact and company info, a list of events (in static html), some simple online shopping pages (that use paypal cart), etc.. This shared content can now be edited via only ONE of the CMSMS installs instead of having to copy/paste it into the other five after every editing session.
Step 1. Modify site template(s) in ORIGIN site's CMSMS:
At the very beginning, before and on the SAME line as DOCTYPE if you have one, add:
Code: Select all
{if $smarty.server.REMOTE_ADDR neq 'xx.xx.xx.xx'}
At the very end, starting after and on the SAME line as your closing tag, add:
Code: Select all
{else}<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>{title} on {sitename}</title>
<link>{root_url}</link>
<description>The {title} page from {sitename}</description>
<language>en-us</language>
<pubDate>{modified_date format="%A, %d %b %Y %H:%M:%S %z"}</pubDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<item>
<title>{title}</title>
<link>{root_url}{$smarty.server.REQUEST_URI}</link>
<description>{content|escape:'html'}</description>
<pubDate>{modified_date format="%A, %d %b %Y %H:%M:%S %z"}</pubDate>
<guid isPermaLink="true">{root_url}{$smarty.server.REQUEST_URI}</guid>
</item>
</channel>
</rss>
{/if}
Step 2. Import feed to other site using RSS feed importer. For this example and CMSMS, we'll be using RSS2HTML.
Install RSS2HTML and add the following as a new template, RSSimport:
Code: Select all
{foreach from=$rss->items item=item}
{$item.summary}
{/foreach}
In a ("destination" site) page's content area, use the following module call to bring in the content from the "origin" site via the RSS feed:
Code: Select all
{cms_module module="RSS2html" feed='feednamehere' template='RSSimport'}
Step 3. As necessary...
1. add CSS to destination site to format imported content to fit design
2. adjust internal links on origin site's pages so images and links work as desired on destination site.
EOF 10JUN08/0430CST draft1
EDIT 11JUN08/0555CST draft2 replace UDTs with Smarty variables; eliminates a step and a couple queries.
(attachment is contents of this post as a text file)