This module is used to create or convert links to load content via JQuery Load

With this module you can either

  • create link with this function l_ajax($title,$path,$target) or
  • make any , be it menu item or any links by providing class="ajax_link"

Required

jquery_update (for Drupal 6)

Before you start (Important) :

STEP 1 : Copy page-ajax.tpl.php (page--ajax.tpl.php for drupal 7) (from module ajax_links_api/templates) to your theme.

STEP 2 : Open the page.tpl.php file for your theme, and search for $content ($page["content"] for drupal 7).This should be surrounded by a div with an id (or class).If no div, add the div yourself.

Example : <div id="content-content"><?php print $content; ?></div>
Drupal 7
<div id="content-content"><?php print $page["content"]; ?></div>
In this case, just enter "#content-content" in 'admin/settings/ajax_links_api'

How to use Ajax links API :

METHOD 1 : in your tpl =>
l_ajax($title, $path, $target)

* $title: Title.
* $path : Drupal path.
* $target (optional): ID or CLASS of DIV to be replaced. Default value is #content-content, you can change default value in admin page 'admin/settings/ajax_links_api'

Example : l_ajax("add page", "node/add/page", "#content-content")

METHOD 2 : Add class="ajax_link" to any link. Target div will be default CSS selector defined in module setting. You can override target by specifying rel="".

Example : <a class="ajax_link" href="node/add/page" rel="#content-content">Add page</a>

DEMO :

<YOUR SITE>/ajax_links_api/test

some codes inspired from code by Sun

Project page

Project page : http://drupal.org/sandbox/serjas/1713192
GIT Repo : http://drupalcode.org/sandbox/serjas/1713192.git
git clone http://git.drupal.org/sandbox/serjas/1713192.git ajax_links_api
Drupal 6, 7

Projects reviewed so far
http://drupal.org/node/1718722#comment-6328246
http://drupal.org/node/1689300#comment-6328286
http://drupal.org/node/1719892#comment-6328186
http://drupal.org/node/1717766#comment-6328046

CommentFileSizeAuthor
#17 drupalcs-result.txt2.02 KBklausi

Comments

klausi’s picture

Welcome,

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 :-)

serjas’s picture

Hi, i didnt reviewed any other module yet, but will do from now on , any way i found some coding standard error for my module itself,

no idea how to fix it? please help

#error report
51 | ERROR | Missing parameter type at position 1
53 | ERROR | Missing parameter type at position 2
55 | ERROR | Missing parameter type at position 3
58 | ERROR | Data type of return value is missing
72 | ERROR | Concat operator must be surrounded by spaces

Also

/ajax_links_api.module: all functions should be prefixed with your module/theme name to avoid name clashes. See http://drupal.org/node/318#naming
function l_ajax($title, $path, $target) {

used this name to make function simpler, otherwise for a developer he has to use ajax_links_api_l($title, $path, $target). this change is a must?

serjas’s picture

Issue summary: View changes

updated desc and git repo link

klausi’s picture

Make sure to do manual reviews of other project by reading through their source code and reporting issues that you find. Posting results of automated reviews is not enough. If you did that don't forget to add the "PAreview: review bonus" tag as described in #1410826: [META] Review bonus.

Regarding the errors: "@param $var" should be "@param string $var" where string is the parameter type. Same for "@return" vs. "@return int". See http://drupal.org/node/1354#functions

You can keep the short function name, I think that is a valid exception.

klausi’s picture

Issue summary: View changes

review bonus links

serjas’s picture

Issue summary: View changes

fixed git link

serjas’s picture

Issue tags: +PAreview: review bonus
serjas’s picture

Issue summary: View changes

review bonus links

patrickd’s picture

Issue tags: -PAreview: review bonus

Your "manual review"'s are only pointing out single issues, most of them are minor others are simply wrong or just links to automated reports

sorry, removing review bonus, it would not be fair to others who really make efforts for their reviews

patrickd’s picture

Issue summary: View changes

review bonus links

serjas’s picture

serjas’s picture

Issue summary: View changes

review bonus links

klausi’s picture

Status: Needs review » Needs work
Issue tags: -PAreview: review bonus

manual review:

  1. l_ajax(): do not call theme_ajax_links_api() directly, use theme('ajax_links_api', ...) and hook_theme() so that others can easily override it.
  2. ajax_links_api_menu(): why is the test menu path unprotected? I think it should also use an administrative permission.
  3. ajax_links_api_footer(): remove that function, you can add scripts to the footer with the scope option on drupal_add_js().
  4. ajax_links_api_preprocess_page(): I think you can use hook_theme() to register your template.

Otherwise this looks nearly ready. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

klausi’s picture

Thank your for your reviews. When finishing your review comment also set the issue status either to "needs work" (you found some problems with the project) or "reviewed & tested by the community" (you found no flaws) as indicated in #1410826: [META] Review bonus.

serjas’s picture

Status: Needs work » Needs review

hi fixed all except 4

ajax_links_api_preprocess_page(): I think you can use hook_theme() to register your template.

i want to print $scripts,$style,$content only for loaded content, how can i use hook_theme here?

patrickd’s picture

patrickd’s picture

Issue summary: View changes

project description

serjas’s picture

Issue summary: View changes

review bonus links

serjas’s picture

Issue tags: +PAreview: review bonus

this issue was posted earlier in forum http://drupal.org/node/1706098 .
This is the requirement
# display only $content for page loaded via ajax

already implemented using preprocess, but user has to copy tpl to default theme

anyway we can always do this in later releases. committed other changes. please review :)

serjas’s picture

ported module to 7, but dont know how to create a branch
followed instruction here http://drupal.org/node/1066342

cd ajax_links_api (this is where 6.x-1.x)
git checkout -b 7.x-1.x
git push origin 7.x-1.x

now a branch is created in drupal rep with same contents as 6.x-1.x! i supposed to get a blank tree! what went wrong?

patrickd’s picture

nothing that's the normal behaviour.
Create your new branch while beeing in 6.x-1.x, make your changes that are required for your port, commit and push the branch

this way anyone can see what and how it was ported and it's easier to detect error that came due to the port.

patrickd’s picture

Issue summary: View changes

review bonus links

serjas’s picture

Issue summary: View changes

ported to drupal 7, made changes in description

serjas’s picture

Assigned: patrickd » Unassigned
Status: Closed (fixed) » Needs review
Issue tags: +PAreview: review bonus

ported to drupal 7 :) please review

for those who wnat to refer how i ported 6 to 7 here

Milena’s picture

Status: Needs review » Needs work

I do not understand why I should copy template files to my theme.
Many user use some of the default themes which should not be changed any way (as they are in Drupal core). I should use your module with such theme also without killing kittens ;)
You have settings form with defining selector. So why also changing theme?

In your .install file you have

/**
 * @file
 * Make any links or create new links with ajax.
 */

That is not what file does. Of course it is not a bug, but probably better comment would be: "Delete unnecessary variables." or "Uninstall function for AJAX links API module."

In your .module file:

 /**
 * Implements hook_init().
 */
function ajax_links_api_init() {
  drupal_add_js(drupal_get_path('module', 'ajax_links_api') . '/files/ajax_links_api.js');
  drupal_add_css(drupal_get_path('module', 'ajax_links_api') . '/files/ajax_links_api.css');
}

Why not to add these files into .info file? They will be properly aggregated then.

Do not use t() function in hook_menu.

Your .js function:
Try to use Drupal.behaviors instead of document.ready.

I think l_ajax() function is a good name, even if does not follow coding standards. I think that such API should not provide lengthy function names, it is simple and clean.

You can also add configure option to your .info file. It will display small icon on the admin/modules list.

With overlay enabled I cannot use your module properly. Link is appearing in overlay (demo page) rather than in my #content. You should provide information about how your module works with core overlay module.

If i do not have an access to the page it only shows loader and do not show access denied page for me. I do not know if it is something specific with my Drupal installation, but I think I should mention it.

I'm not sure if this issues should block your application into RTBC, I've also did a review of 7.x branch.
But for now it requires changing core in some situations, it does not like core overlay module and uses t() in hook_menu(), so I'm changing to need work.
If someone think that it should be needs review - feel free to change.

serjas’s picture

Status: Needs work » Needs review

Hi Milena,

Thanks for reviewing module

# I do not understand why I should copy template files to my theme.
This is to load only $content , if page-ajax.tpl is not in your theme, loaded content will have header, footer etc. I am still investigating a way to do it in module itself . check here

With overlay enabled I cannot use your module properly
tested with overlay. when access settings its displayed in an overlay (admin/config/development/ajax_links_api) and when click demo , demo page will open in new page , not in overlay!

If i do not have an access to the page it only shows loader
currently it wont show access denied error. will do in future . have to find a way to display access denied and not found error!

# Fixed other errors

serjas’s picture

Issue summary: View changes

drupal 7

klausi’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus
StatusFileSize
new2.02 KB

Review of the 7.x-1.x branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

manual review:

  • ajax_links_api.info: why do you need your CSS/JS on every single page request? I think you should only add it when you actually output an ajax link, no?

But otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

serjas’s picture

Hi Klausi,

In earlier code, i have used js and css in hook_init. But based on Milena's comment , added js and css to .info.

Now i am confused , which one i have to use , .info or hook_init?

Milena’s picture

You were adding css and js file on every single request through hook-init(). It makes your files no aggregated when user enables aggregation so if you need your files on EVERY page you shoud add them to .info file.

Although I should have asked if you really need your files on every request before suggeting moving it into info .file. But it is not an application blocker, so I did only little harm ;)

serjas’s picture

Hi Milena

Ofcourse i want it on every page as it should work with any links with class=ajax_link . So what should i do? include in .info or hook_init?

Milena’s picture

I do not have an access to your repository right now (using mobile phone), so I'm not able to give you full and right answer based on code, just talking about some theory for now.

Imagine situation where ajax link is only on one page - adding your files to every page might not be so good idea, because all other pages will not use your style and scripts. It would be better to add them only to pages that have your link.
But if you are sure that you really need your files on every request - I suggest .info file for proper aggregation.

I can look at your code later and we can work out the best solution if you will be having problems decide what option choose or how to implement it.

serjas’s picture

Fixed issue #If i do not have an access to the page it only shows loader . Now it will show error message if page is no accessible

klausi’s picture

Assigned: Unassigned » klausi
klausi’s picture

Assigned: klausi » Unassigned
patrickd’s picture

Assigned: Unassigned » patrickd
patrickd’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

It appears that you have been granted the 'create full projects' permission:

Once their first application has been successfully approved, then an applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue.

serjas’s picture

@patrickd

my profile was updated to promote full project on this aug 22! though there was no messages updated in this post!

serjas’s picture

Status: Closed (won't fix) » Closed (fixed)
wMarius’s picture

Assigned: Unassigned » patrickd
Status: Needs review » Closed (fixed)
Issue tags: -PAreview: review bonus

Hi, i want to use this module but he is loading all css, js files after an ajax request is something wrong with how i use this module, because i just want to load at least just css,js files for loaded content and not for the entire page. Ty for the feedback.

patrickd’s picture

This issue is not the right place for feedback or support requests.

Please create a support issue in the projects issue queue instead and leave closed issues closed.

patrickd’s picture

Issue summary: View changes

explaining why page-ajax is required

rukya’s picture

Hi,

I'm using ajax_links_api and every page is loading via ajax, except for the homepage. I can see response in "network" section of firebug, but it's not loading.

How can I debug that?

Thanks

aleinad’s picture

Title: Ajax links API » Ajax links API - affecting other views on the page
Assigned: patrickd » aleinad
Category: Task » Bug report
Priority: Normal » Critical
Issue tags: +Affecting views

Hello,

Ajax links API module and is working fine the problem is that is affecting other modules in the page

http://isafe.org/?q=content/design-home-page

I'm using a view to work as a search, in this view I'm not using Ajax

below that view I'm using the Ajax links API module to display some pages, the problem is when I click on a button to display the page the view above this section gets affected

I'm not very good with javascript and I'm very new in Drupal I'm using Drupal 7

Thank you for your help

avpaderno’s picture

Title: Ajax links API » [D7] Ajax links API