We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Are there any pjax addons/frameworks for ExpressionEngine? What's the best approach?

Development and Programming

TrevC's avatar
TrevC
39 posts
13 years ago
TrevC's avatar TrevC

I was curious what the best and most correct method would be for implementing pjax on an ExpressionEngine-powered site.

There’s PHP examples, along with thematic-pjax for Wordpress, so it’s definitely possible.

If there any better approach with EE, aside from manually hacking in support? Any input or advice is greatly appreciated.

Thanks

       
freerange's avatar
freerange
1 posts
13 years ago
freerange's avatar freerange

Hey,

I’ve thought a lot about how you would do this, but haven’t had a project where I can explore the possibilities. A couple not-really-ideal solutions are:

1) If you are not concerned about the overhead of loading the stuff that you don’t need, you can always have jQuery pull in the whole page but then only load the content:

$("#stage").load('http://example.com/page.html #your-content');
window.history.pushState(data, "Title", "page.html");

2) Another option is to put your content inside embedded templates and write some javascript to intercept the links, like this:

“some.group/template.html” would be the full template, “ajax.group/some-template.html” would be the embed/fragment. The latter would be embedded inside the former. “ajax.group/some-template.html” would start with {if segment_1 == "ajax"}{redirect="404"}{/if} to protect your SEO. Then you would write some javascript to intercept your internal links and replace your first segment (inside the href attribute) with “ajax/first segment-” This would return the cromeless version, aka the embedded template. The only thing left after that is to get crafty about doing the same when your URLs have three segments instead of two. This approach wouldn’t work with the Pages module/Structure of course.

Obviously it would be much better to do things with server headers the way the pjax guys have it, but I have no idea how you would do that. Hopefully someone else around here does.

St

       
TrevC's avatar
TrevC
39 posts
13 years ago
TrevC's avatar TrevC
Hey, I’ve thought a lot about how you would do this, but haven’t had a project where I can explore the possibilities. A couple not-really-ideal solutions are: 1) If you are not concerned about the overhead of loading the stuff that you don’t need, you can always have jQuery pull in the whole page but then only load the content:
$("#stage").load('http://example.com/page.html #your-content');
window.history.pushState(data, "Title", "page.html");
2) Another option is to put your content inside embedded templates and write some javascript to intercept the links, like this: “some.group/template.html” would be the full template, “ajax.group/some-template.html” would be the embed/fragment. The latter would be embedded inside the former. “ajax.group/some-template.html” would start with {if segment_1 == "ajax"}{redirect="404"}{/if} to protect your SEO. Then you would write some javascript to intercept your internal links and replace your first segment (inside the href attribute) with “ajax/*first segment*-” This would return the cromeless version, aka the embedded template. The only thing left after that is to get crafty about doing the same when your URLs have three segments instead of two. This approach wouldn’t work with the Pages module/Structure of course. Obviously it would be much better to do things with server headers the way the pjax guys have it, but I have no idea how you would do that. Hopefully someone else around here does. St

I’ve been using djax on several static sites. It might not be ideal for everything, but it certainly does the trick. The sites it’s running on certainly seem “faster” than they did before, and there’s never the annoying page flicker with navigating pages.

There’s no reason why it couldn’t be integrated with an EE site.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.