OpenBayou Posted September 29, 2016 Share Posted September 29, 2016 Hey again, Is it possible to display ProcessWire posts on another site? I'm looking for a CMS to use as an affiliate network and to serve banners. I have an idea of how to do this by using RSS feeds but want to know if other ways exist. Thanks again, Link to comment Share on other sites More sharing options...
Macrura Posted September 30, 2016 Share Posted September 30, 2016 You can serve any content from a PW install by creating placeholders on the target page, then use javascript to populate those placeholders. Here's one way, though there are probably many - i did this once and it worked pretty well: The JS would load it's html from the remote server. In the template that will display the content, you would put something like this at the top: $request_headers = apache_request_headers(); $http_origin = $request_headers['Origin']; $allowed_http_origins = array( "www.example.com" ); if (in_array($http_origin, $allowed_http_origins)){ header("Access-Control-Allow-Origin: " . $http_origin); } if(!$input->pid) exit("no page id specified"); if($input->pid) { // Sanitize the request $pageRequest = $sanitizer->int($input->pid); // Look for the page $banner = $pages->get($pageRequest); if(!$banner->id) exit("banner not found"); // echo your banner here exit(); } on the target site custom.js: var baseUrl = "http://www.example.com/services/banners/"; // the location of your custom js file: var script = $("script[src*='scripts/custom.js']"); var pageID = $(script).data('page-id'); if( typeof pageID != 'undefined' ) { $( "div#p"+pageID ).html('<p>Loading...</p>'); $.get( baseUrl + "?pid=" + pageID, function( data ) { $( "div#p"+pageID ).html( data ); }); } and on the page that will display the banner: <script data-page-id="1020" src="scripts/custom.js" type="text/javascript"></script> <div id="p1034"></div> 5 Link to comment Share on other sites More sharing options...
OpenBayou Posted September 30, 2016 Author Share Posted September 30, 2016 Thanks! However, my thinking is to do the RSS because of people using Ad Block addons that disable JS. I use WordPress and they have the ability to create an RSS feed from a template file in your theme. Does ProcessWire that the ability to create a custom RSS feed using a template? Link to comment Share on other sites More sharing options...
adrian Posted September 30, 2016 Share Posted September 30, 2016 http://modules.processwire.com/search/?q=rss 4 Link to comment Share on other sites More sharing options...
Macrura Posted September 30, 2016 Share Posted September 30, 2016 9 hours ago, OpenBayou said: people using Ad Block addons that disable JS The technique i described above would not be blocked unless the adblockers decided specifically to block your server. Otherwise this would operate just like any other content on the page that is generated or manipulated by JS. 4 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now