Skip to content

Instantly share code, notes, and snippets.

@MaximKeegan
Created December 7, 2012 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaximKeegan/4231780 to your computer and use it in GitHub Desktop.
Save MaximKeegan/4231780 to your computer and use it in GitHub Desktop.
<?php
$path_node = explode("?", substr($_SERVER["REQUEST_URI"],count(dirname($_SERVER["PHP_SELF"]))));
$path_node = urldecode($path_node[0]);
$path_chains = explode("/", $path_node);
function fucking_drupal_cant_load_node_by_url($path_node) {
// такой изподвыпердный изврат для получения PATH_INFO требуетя из-за разных настроек серверов
$query = "SELECT src FROM {url_alias} WHERE dst = '%s';";
// fuckig php have't closure!
$_result = db_query($query, $path_node);
$_result = db_fetch_object($_result);
$_result = array_reverse(explode('/', $_result->src));
$_result = $_result[0];
$node = node_load(array('nid'=>$_result));
return $node;
}
$node = fucking_drupal_cant_load_node_by_url($path_node);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment