Skip to content

Instantly share code, notes, and snippets.

@sebyoga
Created August 13, 2013 08:40
Show Gist options
  • Save sebyoga/6219112 to your computer and use it in GitHub Desktop.
Save sebyoga/6219112 to your computer and use it in GitHub Desktop.
<?php
/**
* Défini une nouvelle url d'accès
* --
* Define menu items and page callbacks.
*
* This hook enables modules to register paths in order to define how URL requests are handled.
* Paths may be registered for URL handling only, or they can register a link to be placed in a menu (usually the Navigation menu).
* A path and its associated information is commonly called a "menu router item" * This hook is rarely called (for example, when modules are enabled), and its results are cached in the database.
* @see http://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7
*/
function tonmodule_menu() {
$items['app/getUrl/externe'] = array(
'title' => t( 'Get Url Externe' ),
'page callback' => 'tonmodule_app_geturl_externe',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
function tonmodule_app_geturl_externe() {
$urlExterne = variable_get('tonmodule_cfg_url_externe', 'http://.....');
/** $content = **/
/** Code qui va chercher la page en php... **/
/** http://fr.php.net/manual/fr/function.file.php **/
/** Faire du Curl si possible, tu recuperes les erreurs, ... Un jour, le site distant peut être indisponible... **/
$ajax_return = array('content' => $content);
drupal_json_output($ajax_return);
drupal_exit();
}
/*** EN JS, tu fais un appel ajax sur "app/getUrl/externe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment