Views and Panels Ajaxified
If you haven't read Roger Lopez Ajax without Javascript take a 5 minutes break and do it. If you are not a developer and all this code makes you frightened then you are excused. This post will also have a little code, but take a big breath and you'll see how easy it is to Ajaxify your Panels!
- Download this feature and the related modules
drush dl ctools panels views
drush en page_manager panels views_content views_ui story_list php -y - Add a few story nodes (title and body), or use Devel generate module to do it for you
- Navigate to
/story-listand you should see a list of the last 10 stories on the left and the body of the first story on the right - Click on any of the titles and notice how the body text changes, without any page load. Hooray!

Lets go over the things we did to achieve this behavior:
- We have created a View that has two different displays. The "Story list" shows a list of 10 stories. The fields of this display are the node ID which is "excluded from display" and the node title. In the node title configuration we disabled the "Link field to its node", and we craft our own link so it will link to the new Panels page we created. We also add a the
ctool-user-ajaxcss class, which will ajaxify those links
- In the story list view we add one line of PHP in the header -
ctools_add_js('ajax-responder');This line will make sure that "somebody" is listening to our ajax links
- In the panel page, we add to the right pane a generic css class
ajax-result-pane. When the ajax command will want to replace the existing text with the new text it will look for this class

- Next we have our custom code, which is in the
.modulefile. I won't go over every line of code, since it is well documented. Even if you are not a developer it should be pretty clear from the comments what needs to be replaced in order to re-use the code for your own needs

תגובות
slight path revision needed
Ok, this is ultra cool mojo you're sharing with us. And a schnifty use of features to boot 8^)
One minor correction for the post though, in step 3 "Navigate to /story-test" it should be /story-list
Gizra, Drupal slathered in awesome.
-James
@James, Corrected the typo,
@James,
Corrected the typo, thanks.
AWESOME share! thanks!
AWESOME share!
thanks!
Step 4 - please explain
"Next we have our custom code, which is in the .module file" - where is this, not understood. What should be done in this step?
> which is in the .module
> which is in the .module file
It's in step one -- download the attached feature, there you will see story_list.module. You just need to enable it.
This doesn't help if I want
This doesn't help if I want to learn how to do it in another context... That is, if I manually made things written in steps 1 to 3 - according to MY business logic - I would like to know what should I do next - an abstracted step, not an example.
Thanks
> This doesn't help if I want
> This doesn't help if I want to learn how to do it in another context...
It does - if you will open the .module file and read the comments, which tell you what needs to be replaced for your custom code.
AHA! You should have said do...
Got you, thanks! I will try this.
Super rad! Since you already
Super rad!
Since you already require a custom module it might be a good idea to implement a views hook to call ctools_add_js('ajax-responder'); rather than to use the PHP module and thus avoid its security/maintainability/performance issues.
@dalin, That is correct,
@dalin,
That is correct, however I wanted the tutorial to appeal to non-developers as-well, so I've used "acceptable" quick-n-dirty ways to achieve this.
Doing this without panels
Don't have it working yet, but this should be doable without the monster that is Panels, right? I user a Skinr-enabled theme, and I'm planning to have a block view and a page view, with the page view taking the place of the node panel. Just need use the page view path and css class as needed, instead of the panel instructions.
Like I said, not working yet, but I don't expect to have any issues :)
Oy. Heads up if you're using
Oy. Heads up if you're using Fusion to make this happen with Views only (no Panels):
http://drupal.org/node/804674
The issue involves the views page template missing the code to print custom css classes. Caused me a bit of grief...
> doable without the monster
> doable without the monster that is Panels, right?
I doubt if the performance will be much different between the two options - you should test and compare it.
Also, your solution is not exportable, which for me is sub-optimal.
> taking the place of the node panel
This is not a node panel. This is a panel page :)
Active Links?
First of all - thank you for this. I was searching for this for a while.
Using this method how would you go about adding a class of "active" or such to the list elements of the view in the first column?
I'd like to differentiate the menu list item that we are currently on from the rest by grabbing the node id from the 2nd column. But I'm not sure how to do that exactly.
Any help?