3

This seems possible, but I'm missing something. I'm using plone.app.theming (diazo). I'm trying to pull in pages from a cold fusion site. I can get the first page to load using but the page then has urls that refer to more data pages. The urls are formatted like this "./undergraduates_classes_info.cfm?crse=001A&sectnum=A" (which Plone is more than happy to parse) I've tried a variety of permutations to this and I can't seem to get it to work.

 <xsl:param name="ExtUrl" select="'http://exeternalsite'" />
    <xsl:template match="a/@href[contains(.,'/undergraduates')]">
        <xsl:attribute name="href">
            <xsl:value-of select="concat($ExtUrl, .)" />
        </xsl:attribute>
 </xsl:template>

I also need to pass the url to the command so that i can get the actual data back.

Any help is appreciate -- and maybe I'm approaching this incorrectly?

ZnArK
  • 1,533
  • 1
  • 12
  • 23
CMcStone
  • 51
  • 3

3 Answers3

2

It's a very bad idea to depend on a remote service before you can finish processing the request. Imagine that site goes down or is slow? Now you're waiting on it to finish or timeout before you serve your page.

A better solution is to use javascript to pull in the contents of the page.

It could look something like this:

$(document).ready(function(){
  $('#containerofcontent').load('http://remoteurl #contentselector');
});

Assuming your site is on a different domain, you'll also need to set some special headers on the remote site in order for browsers to allow the ajax request:

Access-Control-Allow-Origin: http://plonesiteurl

That's pretty easy to override headers with any web server though.

vangheem
  • 3,293
  • 17
  • 18
2

You can include content from an external site by specifying the href attribute as documented here: http://docs.diazo.org/en/latest/advanced.html#including-external-content

You will need to enable the "Read network" option in plone.app.theming to allow inclusion of external urls, see: http://pypi.python.org/pypi/plone.app.theming#usage

As others have pointed out, this does have a performance impact, but if you are caching the resulting pages that might be ok. You can avoid that performance cost by caching the fragment and using the SSI or ESI method options documented on the diazo site, but you will need to setup Nginx to run the filter.xsl stylesheet or a diazo proxy.

Laurence Rowe
  • 2,909
  • 17
  • 20
0

Unless I am misunderstanding your question (always possible), I think you are misunderstanding p.a.theming. p.a.theming can include theme assets (e.g. templates, images) from a remote site, but it is not intended for nor really capable of proxying in content from a remote site.

Jon Stahl
  • 2,090
  • 10
  • 10
  • And it's not a good idea either. Depending on a remote request before you can finish processing your own request is a recipe for disaster. – vangheem Jun 23 '12 at 01:59
  • I think you're likely correct and I need to actually use the full version of diazo rather than plone.app.theming – CMcStone Jun 25 '12 at 17:07
  • Yes, you could use standalone Diazo to theme your cold fusion and Plone pages similarly/identically (but it still won't let you literally insert your CF page content within a Plone-generated page, but with sufficient theming, that's probably not needed). Please accept my answer if you feel it's sufficiently correct. ;-) – Jon Stahl Jun 26 '12 at 23:33