Ajax Nodeloader module allow you easy:
- Load and display Drupal nodes via AJAX technology
- Use custom css selectors for display your content (body, title, etc)
- Support loading any of node fields (D7)
- Track your AJAXified links with Google Analytics (option)
- Use advanced navigation based on HTML5 history API or hashtags (back/forward button, share your links) (option)
- Dynamically change browser title with your node title (option)
Examples:
1. To load node via AJAX you should add class "nodeloader" to link for node you want to load , i.e.:
<a href="/hode/1" class="nodeloader">Test link</a>for load /node/1.Alias path also supported:
<a href="/contacts.html" class="nodeloader">Test link</a>2. Module have patrial support for hashtag navigation, for example link to page
http://yoursite.org/#/contacts.htmlwill load
/contacts.htmlpage instead of main page of "yoursite.org"3. To make your menus load nodes via AJAX you can use module
http://drupal.org/project/menu_attributes4. Added support for custom display-to targets selectors via rel attribute and JSON. Example:
<a link="/node/2" class="nodeloader" rel={'title':'#selector1','body':'#selector2'}>This link shows your node #2 title in id="selector1" element, and your node #2 body in id="selector2" element</a>You can point title or node separately from each other, so
<a link="/node/2" class="nodeloader" rel={'title':'#selector1'}>Only title custom target</a> or <a link="/node/2" class="nodeloader" rel={'body':'#selector2'}>Only body custom target</a>also allowed. Custom target string must be single quoted for correct work.
5. Enable or disable Google Analytics tracking with Ajax Nodeloader in your admin panel.
6. Drupal 7 version now can load and display all node fields instead only body field by default.
You can load field to custom selector use the same syntax. For example, if you have custom fields "field_text" and "field_price" you can load them by this way:
<a href="/node/2" class="nodeloader" rel="{'title':'#some-id-selector1','body':'.someclass span','field_text':'#some-id-selector2','field_price':'#selector3'}">Load title, body and custom fields link</a>Module will support fields labels soon.
2. Project page: http://drupal.org/sandbox/nick-denry/1447152 and GIT URL: git clone http://git.drupal.org/sandbox/nick-denry/1447152.git ajax_nodeloader
Comments
Comment #1
Nick Denry commentedComment #2
rudiedirkx commentedProject page URL? Very useful!
The GIT URL is wrong. Only you can log in like nick-denry@... Good URL:
git clone http://git.drupal.org/sandbox/nick-denry/1447152.git ajax_nodeloaderComment #3
Nick Denry commented>>Project page URL? Very useful!
Sorry, first time on drupal.org, do u mean web-page for this project?
>> The GIT URL is wrong. Only you can log in like nick-denry@...
Fixed, I guess. Sorry one more time.
Comment #4
rudiedirkx commentedYeah, the project's page: http://drupal.org/sandbox/nick-denry/1447152
Also, explain what it does better. I shouldn't have to download it to know that. Load what? Load how? And do what with it?
Put all this in the original issue, not a comment.
Comment #4.0
rudiedirkx commentedFix git url for non-mantainer
Comment #4.1
rudiedirkx commentedGood URLs
Comment #5
rudiedirkx commentedOeh I like this one...
A few functional things though:
1. HTML 5 introduces the History API. (Is that what it's called?)
history.pushState()and thepopstateevent in particular. Use that. Nobody likes#.2. The node view isn't complete. Reproduction is simple: add and display a few fields. Load them via nodeloader. Only the body will show. What if I don't have a body, but I do have a lot of fields?
3. If I link to /, I get a 404 back. The frontpage isn't ajax_nodeloadable?
And a few technical things:
1. Don't define functions like
load_nodeif your module is calledajax_nodeloader. Prefix everything with your module's name. I.e.ajax_nodeloader_load_node.2. Don't do this:
What's
und? UseLANGUAGE_NONE, if you really must. But don't. Use field_view_field to load a node's field values. Explore the Field API. It's awesome. Drupal contains (almost) everything you need. Things like this aren't necessary:3. Automated code review issues here. You can use this tool yourself.
Comment #6
Nick Denry commented>>Oeh I like this one...
Sorry, is it was sarcasm?
Comment #6.0
Nick Denry commentedLink
Comment #7
rudiedirkx commentedNope. Not sarcasm. I like it. (That's why there's "though" in first issues title.) Are you worried?
PS. There's a Quote button in your editor. Use that instead of
>>. For code, use the code or PHP button. Etc.Comment #8
Nick Denry commented>> Are you worried?
No, I hope not :) Just think is that required conditions to confirm project as useful or not (as I said, I first time there and don't know drupal policy so good).
1. Also I knew about History API, but my own purpose first of all was support of old browsers, which unfortunally don't support History API. But History API can be additional functionality in next versions of this module. (BTW as you can see it have version 0.01 beta).
2. What fields do you mean for example?
3. Yes, frontpage itself now not ajax_nodeloadable, if it hasn't associated node, like /node/1, which link for logo for example can be overrided in custom theme. But I guess this not make it more useless for some kind of sites. I'm trying to keep this module simple first of all, before it became fat and unuseful, so I want implement new functionality step-by-step.
-----
Working on your technical comments...
Comment #9
Nick Denry commentedBtw module was created for commercial site, you can see it in action here , (I'll remove link to this test domain after your answer), I've seen some implementation of ajax node loads, but all of them was non-full cookbooks, and I guess module like this can save time for few people, I hope for it :)
Comment #10
Nick Denry commentedThanks
Comment #10.0
Nick Denry commentedfix typerrors
Comment #10.1
Nick Denry commentedCorrect module description to actual state
Comment #11
rudiedirkx commentedA module's usefulness is a condition. There are way too many useless, bad, broken and identical modules around. It also means a module maker has to think about their module (and its usefulness) and that's good.
I can't find a module that does what (I think this module) does/should do, so that's good. Can you?
1. You can use HTML 5 as progressive enhancement. If it's not available, use the
#pathoption. Next version is fine.2. I mean any and all fields. Try it. Add a few fields to your node type, fill them and load that load via your module. The fields won't show. As bad: remove the
bodyfield and you'll get a notice. Not all node types have a body field. You can remove it and some people do that. So instead of showing the node's title & body, show all of it, or whatever the user has set in his node type's "Manage display" tab. Follow and explore the URL I gave you. The Field API is awesome.3. You could make any page ajax loadable by sending the full URI. Substract
Drupal.settings.basePathfrom the link'shrefand send that part. Might be "node/1" or "" (empty for frontpage) or "content/some-alias/349". You can use Drupal's router to find the node. Not difficult, but very powerful. (You might have to google some.)Don't expect responses as quick as this any more =) There are over a hundred modules in line for review, so I should've let you wait a few days. Take a few days to perfect it. Your friends:
field_view_field,node_view,menu_get_itemetc.Comment #12
misc commentedWelcome with your application!
A short manual review:
$output = falseshould be$output = FALSE, if you really need to set a FALSE value here?load_node()should beajax_nodeloader_load_nodeor maybe better_ajax_nodeloader_load_node.Original JavaScript code. Is this by somebody else?Automatic review:
http://ventral.org/pareview/httpgitdrupalorgsandboxnick-denry1447152git
You have some code formatting to take care about.
Please ask if you have any questions. We are here to help each other.
Comment #13
misc commentedWelcome with your application!
A short manual review:
$output = falseshould be$output = FALSE, if you really need to set a FALSE value here?load_node()should beajax_nodeloader_load_nodeor maybe better_ajax_nodeloader_load_node.Original JavaScript code. Is this by somebody else?Automatic review:
http://ventral.org/pareview/httpgitdrupalorgsandboxnick-denry1447152git
You have some code formatting to take care about.
Please ask if you have any questions. We are here to help each other.
Comment #14
Nick Denry commentedThank you for your comments, will try to fix/remove wrong technical things you've point. Hope see you here after few days.
Also thanks, questions be here next day(s) I guess, now alot to do and to learn, and it's already night in my timezone.
Thanks all.
Comment #15
Nick Denry commentedIt's from from the Drupal 7 upgrade guide:
http://drupal.org/update/modules/6/7#javascript_compatibility
I'm new to Drupal 7 instead of 6, so that was a bit problem for me. Init code
was copied as is from that guide.
Image was created via service http://ajaxload.info/
Service habe point that "Generated gifs are totally free for use" at the bottom of the page. Is there MUST be any licence information for it?
Comment #16
Nick Denry commentedTechnical and formatting things fixed, need review
Comment #16.0
Nick Denry commentedMake info more useful
Comment #17
Nick Denry commentedAdd information about custom-display targets
Comment #17.0
Nick Denry commentedAdd information about custom-display targets
Comment #17.1
Nick Denry commentedFix JSON string
Comment #18
rv0 commentedHad a brief look as I'm looking into doing this properly myself.
It doesn't seem to use a lot of the standard drupal 7 javascript stuff (which is why I checked this module, I'm looking for examples)
Also has some drupal coding standards errors (like the placement of the { bracket on a new line)
I also dont think it will attach js behaviors and css, which seems like a must to me?
Comment #19
Nick Denry commentedThank you for spent your time with review.
1. I knew already about Drupal.attachBehaviors, but could you point me about the same with css?
2.
I need some info about drupal code standarts, because following automatic review tool messages don't point me to a brackets in javascript. Is automatic review tool only for .module files? (btw I've remember, I have some warnings about js from automation tool, but not now).
Also, could someone tell me about how-to make properly CHANGELOG file? How I can point and determine current version of my module?
Also I'm looking some information about structure of branches for 6.x, 7.x Drupal versions and also developer branch.
Thanks in advance.
Comment #20
Nick Denry commentedAlso please point what do you mean with "standard drupal 7 javascript stuff".
Thank you.
Comment #21
rv0 commentedgoogle is always a good friend: http://drupal.org/coding-standards
Comment #21.0
rv0 commentedFix typeerrors
Comment #22
rv0 commentedMight be interesting to you:
http://www.computerminds.co.uk/comment/2014
Comment #23
Nick Denry commentedThanks, quite interesting!
It's will need to be maneuver between d6 and d7 versions of this module, but I'll see the way to use that anyway.
First of all I want js part to be unified between module versions in base parts.
Next ver I want implement HTML 5 history (patrial maybe) support and I'll search the way to load page-related blocks.
Can anyone point me to right CHANGLOG making? In correct Drupal way, can't find info unfortunally.
Comment #24
rv0 commented(optional) Before committing a major change, add a change log entry to CHANGELOG.txt that summarizes the change. Wrap the text at 80 characters. Some projects are listing all changes in CHANGELOG.txt; you should follow the existing or agreed-on practice.
source: http://drupal.org/node/363367
Just check the changelog of drupal core to see how it goes..
http://api.drupal.org/api/drupal/CHANGELOG.txt/7
On topic though, your JS part may be very minimal, everything you need is in core.
I'm not even sure that you need a JS file at all..
Comment #25
Nick Denry commentedThank you for providing CHANGELOG information.
>> On topic though, your JS part may be very minimal, everything you need is in core.
Think you're wrong depend on fact I want also support Drupal 6 version (so, both Drupal 6/7 same functionality). I'll think about, thanks anyway.
Comment #25.0
Nick Denry commentedCorrect some info
Comment #26
Nick Denry commentedAdded 6.x branch, so module not only Drupal 7 only.
Just add info to issue for future
Branch 6.x is not tested with autotools.
Branch for 6.x is much different from 7.x, consist some improvements of work logic and code,
so please, don't spent your time on 7.x branch review - it will be rewriten soon.
Thanks anyone.
Comment #27
Nick Denry commentedFixed errors with automated review of 6.x.
Need manual review of 6.x branch.
Comment #28
Nick Denry commentedBranch 7.x rewrited to the same logic as 6.x. Need reviews.
Thanks in advance.
Comment #28.0
Nick Denry commentedAdd info about Drupal 6 both 7 version support
Comment #29
Nick Denry commentedDrupal 7 version can load any node fields to content or custom selectors.
Comment #29.0
Nick Denry commentedAdd info about load fields in Drupal seven
Comment #30
migmedia commentedFirst: The drupalcs -pareview of the 7.0-branch ...
Source: http://ventral.org/pareview - PAReview.sh online service Retry: (http://ventral.org/pareview/httpgitdrupalorgsandboxnick-denry1447152git-...)
There's nothing serious, just comments, whitespace etc. - easy to fix.
Micha
Comment #31
Nick Denry commentedBranch 7.x-0.x formatting errors from PAReview fixed, need review
Also, should I fix pareview errors from 6.x-0.x branch if "wrong formatted code" is little bit adapted code from JQuery project (original branches identations etc.)?
http://ventral.org/pareview/httpgitdrupalorgsandboxnick-denry1447152git-...
Comment #32
Nick Denry commentedAdded Google Analytics tracking support, both 6.x/7.x branches.
Comment #33
bcooper commentedThis isn't working for me. With the following code, when I click the link, all fields from the target node load replacing all of my current page including the current page title. It isn't refreshing the page so it is kind of working.
Also, I have a field with multiple images and it is only pulling up one of the images. Take a look and let me know if I am doing something wrong???
Thanks
Comment #34
Nick Denry commentedThe part of multifield content wasn't tested in all apply cases, so I guess there is can be some errors.
Could you create an issue for module via http://drupal.org/node/add/project-issue/1447152 ? Please add your demo-site (if possible) and I'll try to fix that bug(s) as soon as possible. Thank you.
Comment #35
misc commentedManual review:
Anyhow, this looks RTBC for me.
Comment #36
Nick Denry commentedThank you, MiSc.
Branches renamed to 7.x-1.x and 6.x-1.x
Comment #37
chi commentedThe module has security vulnerabilities. It doesn't check node access rights.
Here is some usefull information about the node access system.
http://api.drupal.org/api/drupal/modules!node!node.module/group/node_access/7
Comment #38
misc commentedAdded security tag.
Comment #39
Nick Denry commentedSorry, I can't understand isn't access arguments are not enough for menu item wich is provide address for loading node?
I've test loading nodes under anonymous user and disable ability to see published materials on "/admin/people/permissions" admin page, and module just return error 403 for '/node_load/node/%nid'.
See code lines 81-87 (branch 7.x-1.x, as exmaple)
If thats not enough pls tell me. Thank you.
Comment #40
Nick Denry commentedOf course I can use "node_access" function (http://api.drupal.org/api/drupal/modules!node!node.module/function/node_...) to check if user has access rights before display content, but I think this is duplicate checkouts.
Set needs review again.
Comment #41
chi commentedWith your module anybody who has «access content» permission can view unpublished nodes.
Comment #42
duozerskIsn't it a duplicate for http://drupal.org/project/ajaxit project? Looks like ajaxit can make any page to load through AJAX request using jQuery library, not just a node page.
And one more similar project - http://drupal.org/project/ajax_regions
AndyB
Comment #43
Nick Denry commentedFix security issue with view unpublished nodes from anyone, who has 'access content' permission.
Now user must have "view unpublished (sometype) content" or "view all unpublished content".
Add ability to load nodes for sites without clean URLs.
Comment #44
Nick Denry commentedDon't think so, because ajaxit is only for 6.x and with no further development, and ajax_regions is also only for
Drupal 7.x with much harder using via JS programming.
Main purpose of Ajax Nodeloader is provide ability to end-user of loading nodes content for some parts of sites that no need full-reload of page, like some local or not-very-important additional information, wich can be loaded a bit faster than all-page reload.
Comment #45
chi commented@Nick Denry, you misunderstood me. The issue is not about published and unpublished nodes. It's just a particular case. You should use a node access system provided by Drupal api. There is a lot of content access modules that govern access to nodes but your module allows users to bypass the access control from these modules.
Comment #46
Nick Denry commentedThanks. I'm still new to Drupal, I'll try to see into API and fix this issue.
Comment #47
xenyo commentedManual Review;
1. load_node should be ajax_nodeloader_load_node().
2. you should use field_get_items to get field value.
for example : to get body field value
field_get_items('node', $node, 'body', $node->language);
3. If someone enters the path through node_load/node/nid in browser, anonymous users can see the node contents even if unpublished. May have some security issues for some sites.
4. Deprecated function: Function split() is deprecated in load_node() (line 43 of /var/www/html/drupal-7.14/sites/all/modules/ajax_nodeloader/ajax_nodeloader.module).
This function has been DEPRECATED as of PHP 5.3.0.
you should use explode function.
5. drupal_add_http_header('Content-Type', 'text/javascript; charset=utf-8'); is this necessary?
Comment #48
Nick Denry commenteddeleted
Comment #49
misc commented@Nick Denry, please do not review the reviews. We have trouble to getting people to do reviews for me beginning.
And your repo have a lot of branches. @xenyo reviewed the 7.x-0.x branch, which still looks like stated in #47. That branch should be deleted, like 6.x-0.x.
So please clean up your repos, so people more easy could do reviews. Thanks.
Comment #50
Nick Denry commented@MiSc, thanks for your support. I don't understand, I've deleted both branches (7.x-0.x and 6.x-0.x) via git-gui few days ago from both drupal.org and github.com and can't see them.
Also it can't be checked via pareview (http://ventral.org/pareview/httpgitdrupalorgsandboxnick-denry1447152git-...), so I don't understand how @xenyo had rewiev it.
Do I miss something with that branches?
Update: There is I also can see only 7.x-1.x and 6.x-1.x
http://drupalcode.org/sandbox/nick-denry/1447152.git
Okay, I wont.
Offtopic: Is there some team reviewing new modules/etc. or just volunteers?
Comment #51
misc commentedTo delete remote branches you have to do like:
git push origin :6.x-0.x
Offtopic: It is drupal, we are all volunteers.
Comment #52
Nick Denry commentedI still cant see 7.x-0.x and 6.x-0.x
http://drupalcode.org/sandbox/nick-denry/1447152.git/shortlog/refs/heads...
http://drupalcode.org/sandbox/nick-denry/1447152.git/shortlog/refs/heads...
And
git push drupal.org :6.x-0.xgive me an error. How I can be sure that branches are deleted?Comment #53
misc commentedI think you should remove drupal.org from the the push.
Comment #54
Nick Denry commentedOn both 7.x-1.x and 6.x-1.x branches.
Comment #55
Nick Denry commentedHavn't tested with "Automatic review" yet because of http://ventral.org not working at moment.
Comment #56
Nick Denry commentedTested with "Automatic review".
Comment #56.0
Nick Denry commentedpreview
Comment #56.1
Nick Denry commentedHTML5 history support and options
Comment #57
andyhawks commentedI'd like to set this to RTBC, it's been dormant for a few weeks. The remaining ventral issues are minor, http://ventral.org/pareview/httpgitdrupalorgsandboxnick-denry1447152git, just
Line exceeds 80 characters;andExpected 1 space before "+";. I can't speak to the JS security, but the issues warranting the security tag in #38 were resolved on June 27 and the rest of the code looks good to me. Nick is definitely responsive in resolving issues that arise and dedicated to this module. I think this module has a lot of real-world use cases; I am actively using this on a site in development and hope it gains some traction before D8.Comment #58
klausiWe are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)
Comment #59
patrickd commentedThere is still a master branch, make sure to set the correct default branch: http://drupal.org/node/1659588 .
Delete master branch:
Review of 7.x-1.x:
* @nidIncorrect doxygen documentation, should be like @param int $encoded_url'title' => 'load node via alias',sounds like a comment, not like a page title - use a comment'access arguments' => array('administer ajax_nodeloader'),this permission does not exist - you have to define it by hook_permission()Review of 6.x-1.x
* @encoded_urlIncorrect doxygen documentation, should be like @param int $encoded_urlWhat about drupal_json()?
None of these points are super-important, anyway I'd like to see some of them fixed.
Set it back to RTBC yourself after your done.
Comment #60
Diogenes commented@Nick Denry
Keep going Nick. I think this is a good idea, I like the fact that you have it in both D6 and D7 and I bet you could get a D8 version up and running pretty quickly. I'll try it out the module next chance I get.
In the meantime, your sandbox still has a master branch. I had trouble with getting rid of this myself.
To delete it, you must first set a different 'Default branch' on http://drupal.org/node/1447164/edit
Set it to 7.x instead of master. Then you will be able to delete master from the remote origin.
git ls-remote origin
git push origin :master
Cheers
-Dio
Comment #61
squarecandy commented+1 for "Keep going". Cool idea. I disagree with anyone suggesting you are duplicating existing modules, from what I've found.
Comment #62
klausiClosing due to lack of activity. Feel free to reopen if you are still working on this application.
If you reopen this please keep in mind that we are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)
Comment #62.0
klausiTypeerrors fix