Share data between websites: the cache_remote_file tagPrevious article Next article
Our community website is built out of multiple CMS Made Simple™ websites. Some content is the same at all websites, i.e. analytics code, global navigation code, sponsors, etc. When something changes I didn't want to do it multiple times. Call me lazy, or call me practical... It was a problem that needed a custom answer, because the available (PHP) options weren't working when the master website was offline for a while... It wasn't fail proof. The content needed to be stored at the website: caching!
Lots of scenarios passed by during the development of the Cache Remote File tag. But at the end it worked like I expected it to be! The plugin tag reads content from the source website and caches it for a adjustable time. When that time has elapsed, it checks if the source content is available. If so, create a new and possibly updated cache file. If not, don't touch the content and try again later.
I use it for:
- analytics code
- cookie law information text
- showing CGBlog post from one site to another
- display a progress bar from one site at another one
How to use
Make the information available at the source website, so it can be read by the other website(s). We do this by creating a dynamic "file", in fact it is a page without template/styling.
Therefor create a new Core::Page template with in the content only:
Now create a new page and attach it to the new blank template. Set the page not visible in navigation.
What ever you put in this page (in HTML) can be read and displayed/processed at another website.
At the other website(s) you can read and show or process the content by adding in a page or template:
Move a value (number) to another site
At WeLoveCMSMS.com there are lots of awesome CMS Made Simple-powered websites showcased!
But how many are there???
The website is using the CGBlog module. I created a new summary template named "itemscount" and the content only:
In a hidden page I call this module template, like:
Now I read this page here in this article with the cache_remote_file tag. Note: don't use pretty URLs in the tag!
There are 181 websites in the showcase.