Created
May 20, 2011 10:57
-
-
Save anonymous/982721 to your computer and use it in GitHub Desktop.
Ajax Node Content Reload Module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name = Ajax reload | |
| description = "Ajax Node Content Reload Module" | |
| core = 7.x | |
| files[] = ajax_reload.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function ($) { | |
| Drupal.behaviors.ajax_reload = { | |
| attach: function (context, settings) { | |
| $('.region-submenu a').bind('click', function () { | |
| var url = $(this).attr('href'); | |
| // $('.article-content').slideUp('slow'); | |
| $('.article-content').empty(); | |
| $('.article-content').load(url); | |
| return false; | |
| }); | |
| } | |
| } | |
| }(jQuery)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @file | |
| * Ajax Node Content Reload Module | |
| */ | |
| /** | |
| * Implements hook_init() | |
| */ | |
| function ajax_reload_init() { | |
| drupal_add_js(drupal_get_path('module', 'ajax_reload') . '/ajax_reload.js'); | |
| } | |
| /** | |
| * Implements hook_preprocess_html() | |
| */ | |
| function ajax_reload_preprocess_html(&$vars, $hook) { | |
| // page called via AJAX? | |
| if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) { | |
| // add AJAX template | |
| $vars['theme_hook_suggestions'][] = 'html__xhttp'; | |
| } | |
| } | |
| /** | |
| * Implements hook_preprocess_page() | |
| */ | |
| function ajax_reload_preprocess_page(&$vars, $hook) { | |
| // page called via AJAX? | |
| if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) { | |
| // add AJAX template | |
| $vars['theme_hook_suggestions'][] = 'page__xhttp'; | |
| } | |
| } | |
| /** | |
| * Implements hook_preprocess_node() | |
| */ | |
| function ajax_reload_preprocess_node(&$vars, $hook) { | |
| // page called via AJAX? | |
| if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) { | |
| // add AJAX template | |
| $vars['theme_hook_suggestions'][] = 'node__xhttp'; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // html--xhttp.tpl.php | |
| print '<!-- Rendering html--xhttp.tpl.php -->'; | |
| print $page; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // node--xhttp.tpl.php | |
| print '<!-- Rendering page--xhttp.tpl.php -->'; | |
| hide($content['comments']); | |
| hide($content['links']); | |
| print render($content); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // page--xhttp.tpl.php | |
| print '<!-- Rendering page--xhttp.tpl.php -->'; | |
| print render($page['content']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment