• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Share page content between sites using RSS
PostPosted: Wed Jun 11, 2008 10:59 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Jan 26, 2006 11:46 am
Posts: 700
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 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)


Attachments:
page2rss-draft2.txt [3.72 KiB]
Downloaded 127 times

_________________
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


Last edited by kermit on Wed Jun 11, 2008 12:00 pm, edited 1 time in total.
Top
 Profile  
 
 Post subject: Re: Share page content between sites using RSS
PostPosted: Wed Jun 11, 2008 11:26 am 
Offline
Support Guru
Support Guru
User avatar

Joined: Mon Jul 04, 2005 5:12 pm
Posts: 4827
Location: Ferrara, Italy
kermit wrote:
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

_________________
CMSMS Support Team
Italian Admin and Moderator

Plugins: Geolocate hostip, Multiple random image, Image rotator (beta), Content Pagination
Modules: ForumMadeSimple (Howto), TranslationManager
Multilingual: MLE is not CMSMS


Top
 Profile  
 
 Post subject: Re: Share page content between sites using RSS
PostPosted: Wed Jun 11, 2008 11:49 am 
Great work - thanx.


Top
  
 
 Post subject: Re: Share page content between sites using RSS
PostPosted: Wed Jun 11, 2008 11:51 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Jan 26, 2006 11:46 am
Posts: 700
alby wrote:

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).

_________________
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


Last edited by kermit on Wed Jun 11, 2008 12:01 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Share page content between sites using RSS
PostPosted: Wed Jun 11, 2008 6:43 pm 
Offline
Support Guru
Support Guru

Joined: Mon Jul 24, 2006 3:27 pm
Posts: 3694
Location: Paris
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.

_________________
-- Pierre, support team member. comodérateur du forum francophone.
Please read "how to submit installation/support requests" before posting. Don't send private messages to ask for support.
Want to contribute to CMSms ? Improve the wiki with your forum account.


Top
 Profile  
 
 Post subject: Re: Share page content between sites using RSS
PostPosted: Wed Jun 11, 2008 11:50 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Jan 26, 2006 11:46 am
Posts: 700
Pierre M. wrote:

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).

_________________
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


Top
 Profile  
 
 Post subject: Re: Share page content between sites using RSS
PostPosted: Thu Jun 19, 2008 3:11 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 5828
Location: Fernie British Columbia, Canada
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& ... late=false

which you can access with the smarty fetch plugin.

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

_________________
Follow me on twitter
For quality help follow these instructions:
a) Think about the problem for an hour
b) research the problem for an hour
c) spend 1/2 an hour explaining it and providing as much information as you can muster
(too much information is okay, not enough information may get your question ignored).
--
if you can't bother explaining your problem well, why should we bother helping with it.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: Share page content between sites using RSS
PostPosted: Thu Jun 19, 2008 7:13 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Thu Jan 26, 2006 11:46 am
Posts: 700
calguy1000 wrote:
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& ... late=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?

_________________
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


Top
 Profile  
 
 Post subject: Re: Share page content between sites using RSS
PostPosted: Tue Jul 01, 2008 3:13 pm 
Offline
Forum Members
Forum Members

Joined: Wed Jun 20, 2007 5:40 pm
Posts: 71
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?

_________________
Tring Web Design Services, Hertfordshire, UK
www.tring-web-design.co.uk
www.berkhamsted-web-design.co.uk


Top
 Profile  
 
 Post subject: Re: Share page content between sites using RSS
PostPosted: Tue Jul 01, 2008 3:41 pm 
Offline
Forum Members
Forum Members

Joined: Wed Jun 20, 2007 5:40 pm
Posts: 71
my bad, it was fcukeditor changing the & in the query string to &

_________________
Tring Web Design Services, Hertfordshire, UK
www.tring-web-design.co.uk
www.berkhamsted-web-design.co.uk


Top
 Profile  
 
 Post subject: Re: Share page content between sites using RSS
PostPosted: Wed Jul 02, 2008 9:08 am 
Offline
Forum Members
Forum Members

Joined: Wed Jun 20, 2007 5:40 pm
Posts: 71
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

_________________
Tring Web Design Services, Hertfordshire, UK
www.tring-web-design.co.uk
www.berkhamsted-web-design.co.uk


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner