Welcome, Guest. Please login or register.
Did you miss your activation email?
06 Oct 2008, 10:35

Login with username, password and session length
Home Chat Help Search Calendar Login Register
Pages: [1]
Print
Author Topic: Share page content between sites using RSS  (Read 1791 times)
0 Members and 1 Guest are viewing this topic.
kermit
Power Poster
***

Karma: 32
Offline Offline

Posts: 654


Hug a Penguin today!


« on: 11 Jun 2008, 06:59 »

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:

Code:
{if $smarty.server.REMOTE_ADDR neq 'xx.xx.xx.xx'}

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 </html> tag, add:

Code:
{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:
{foreach from=$rss->items item=item}
{$item.summary}
{/foreach}

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:

Code:
{cms_module module="RSS2html" feed='feednamehere' template='RSSimport'}

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)

* page2rss-draft2.txt (3.72 KB - downloaded 39 times.)
« Last Edit: 11 Jun 2008, 08:00 by kermit » Logged

eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
alby
Member Support Team
Support Guru
Power Poster
****

Karma: 114
Online Online

Posts: 3039

Location: Ferrara, Italy


My kids


« Reply #1 on: 11 Jun 2008, 07:26 »

Step 1. Add a couple of UDTs to ORIGIN site's CMSMS:

UDT: requesturl
Code:
echo $_SERVER["REQUEST_URI"];

UDT: remotehost
Code:
echo $_SERVER["REMOTE_ADDR"];

Cool, well done kermit.
Only a note:

in smarty you did not need the two UDT, you may use superglobal variables PHP: $smarty.server.XXXX
example: {if $smarty.server.REMOTE_ADDR neq 'xx.xx.xx.xx'}

Alby
Logged

Member CMSMS Support Team
Italian Forum Moderator - Italian admin Project

Plugins: Geolocate hostip - Multiple random image - Image rotator (test beta) - Content Pagination

Modules: ForumMadeSimple (Howto FMS)

Multilingual: CMSMS MLE 1.4.1 (Doc/Howto/Tips)
cyberman
Support Team
Dev Team Member
Power Poster
*****

Karma: 141
Offline Offline

Posts: 6800

Location: Dohna / Saxony / Germany


Reality.sys is corrupt. Reboot universe (Y/N)?


WWW
« Reply #2 on: 11 Jun 2008, 07:49 »

Great work - thanx.
Logged

Fr deutschsprachige Anwender / for german speaking users only
http://www.cmsmadesimple.de/ - die deutschsprachige Seite fr CMSms
http://demo.cmsmadesimple.de/ - die Informationen der CMSms-Musterinstallation in deutsch
http://wiki.cmsmadesimple.org/index.php/Main_Page/de - deutschsprachiges CMSms-Wiki
http://dev.cmsmadesimple.org/projects/german/ - deutsche Sprachdateien fr CMSms
kermit
Power Poster
***

Karma: 32
Offline Offline

Posts: 654


Hug a Penguin today!


« Reply #3 on: 11 Jun 2008, 07:51 »


in smarty you did not need the two UDT, you may use superglobal variables PHP: $smarty.server.XXXX
example: {if $smarty.server.REMOTE_ADDR neq 'xx.xx.xx.xx'}


thanks for that. by same token, i find that the other one can be replaced with {$smarty.server.REQUEST_URI}. modified original post.

i had looked for a 'definitive list' of server vars available to smarty.. but didn't find one when i was working on this, so i had used php instead (and udt's to keep from having to enable php in content via config.php).

« Last Edit: 11 Jun 2008, 08:01 by kermit » Logged

eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
Pierre M.
Support Team member
Support Guru
Power Poster
****

Karma: 31
Offline Offline

Posts: 2870

Location: Paris

Please keep it simple


« Reply #4 on: 11 Jun 2008, 14:43 »

Hello,

thank you for the {content|escape:'html'} tip. Smarty is unlimited...

I would have designed the content syndication another way : separate links by type (one for html, one rss), not type by IP. Oups, thought too quickly... better separate by user agent ? nevermind, thx.

Have fun with CMSms :-)

Pierre M.
Logged

-- Pierre, support team member. comodrateur du forum francophone.
Please read "how to submit installation/debug help requests" before posting. Don't send private messages to ask for support.
Want to contribute to CMSms ? Improve the wiki with your forum account.
kermit
Power Poster
***

Karma: 32
Offline Offline

Posts: 654


Hug a Penguin today!


« Reply #5 on: 11 Jun 2008, 19:50 »


I would have designed the content syndication another way : separate links by type (one for html, one rss), not type by IP. Oups, thought too quickly... better separate by user agent ? nevermind, thx.


i was GOING to go by URL requested instead of IP but i have absolutely no idea if/how you can override a page's template in the URI  -- something like this: domain.com/index.php?page=somepage&template_id=22

so i settled on using IP addresses instead. since the feeds weren't meant to be 'public', no big deal. and by restricting the feeds to only those systems configured by the cmsms admin.. we get extra protection against misuse/abuse of the feeds compared to just using a different URL (which could potentially be discovered even if they aren't posted on the site).
Logged

eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
calguy1000
CMS GURU - 2nd Tier Support.
Dev Team Member
Power Poster
*****

Karma: 141
Offline Offline

Posts: 3942

Location: Calgary, Canada


Second Tier Support


WWW
« Reply #6 on: 19 Jun 2008, 11:11 »

in cms 1.3 (and probably a bit earlier) you can extract the default content block from any page with a
url like:

http://mysite.com/index.php?page=tests&showtemplate=false

which you can access with the smarty fetch plugin.

{fetch file='http://mysite.com/index.php?page=tests&showtemplate=false'}
Logged

kermit
Power Poster
***

Karma: 32
Offline Offline

Posts: 654


Hug a Penguin today!


« Reply #7 on: 19 Jun 2008, 15:13 »

in cms 1.3 (and probably a bit earlier) you can extract the default content block from any page with a
url like:

http://mysite.com/index.php?page=tests&showtemplate=false

which you can access with the smarty fetch plugin.

{fetch file='http://mysite.com/index.php?page=tests&showtemplate=false'}


will smarty cache that or fetch it on every pageview?
Logged

eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
essexboyracer
Forum Member
*

Karma: 2
Offline Offline

Posts: 45


« Reply #8 on: 01 Jul 2008, 11:13 »

I tried {fetch file='http://www.mywebsite.co.uk/index.php?page=our-values&showtemplate=false'} on a 1.3 and between 1.3 / 1.4.1.1 installs and both occasions it also pulled in the template as well as content, thus creating the full page, within the other sites main template? if that makes sense? Any ideas?
Logged

Tring Web Design Services, Hertfordshire, UK
www.tring-web-design.co.uk
essexboyracer
Forum Member
*

Karma: 2
Offline Offline

Posts: 45


« Reply #9 on: 01 Jul 2008, 11:41 »

my bad, it was fcukeditor changing the & in the query string to &amp;
Logged

Tring Web Design Services, Hertfordshire, UK
www.tring-web-design.co.uk
essexboyracer
Forum Member
*

Karma: 2
Offline Offline

Posts: 45


« Reply #10 on: 02 Jul 2008, 05:08 »

Actually, maybe not. Have upgraded the 1.4.1.1 to 1.2.5 and it still pulls in the whole page rather than just the content area
Logged

Tring Web Design Services, Hertfordshire, UK
www.tring-web-design.co.uk
Pages: [1]
Print
Jump to: