Drupal quick fixes
Views arguments
Use url arguments to limit views by taxonomy on term pages
If you are on a taxonomy page, with a known term, we can use views2 arguments. Use the following snippet to perform this task.
First add an argument “Taxonomy: term id” and add the following code in the textarea:
-
tid);
-
?>
Use url arguments to limit views by taxonomy on node pages
On node pages, we can use the node id to return taxonomy term id arguments. With these arguments the sql is limited to the returned tids.
First add an argument “Taxonomy: term id” and add the following code in the textarea:
-
$arg_1 = arg(1);
-
$tax_node = node_load($arg_1);
-
// here you could hardcoded test on a vocab id if you wish:
-
/*
-
foreach ($node->taxonomy AS $tid => $term) {
-
if ($term->vid == $vid) $tids[] = $tid;
-
}*/
-
$args = $tids;
-
}
Various fixes
Hide tabs on node form pages, except for certain roles
-
uid == 1) || in_array(‘redactie’, array_values($user->roles)) || in_array(‘webmaster’, array_values($user->roles))) { ?>
Log next page with google analytics
-
function logOutgoingUrl(a) {
-
pageTracker._trackPageview(‘/outgoing/’+a);
-
$.ajax({
-
type: "POST",
-
url: "/log/exiturl",
-
data: "url=" + a,
-
success: function(msg){
-
window.location = a;
-
}
-
});
-
return false;
-
}
Create submenu-items from selected menu-item (1 depth)
-
$menu_item = menu_get_item();
-
$menu_name = db_result(db_query_range("SELECT menu_name FROM {menu_links} WHERE link_path = ‘%s’ ORDER BY mlid ASC", $menu_item[‘href’], 0, 1));
-
$menu_tree = menu_navigation_links($menu_name, 1);
-
-
$output = ”;
-
-
if($menu_tree) {
-
-
foreach($menu_tree as $link) {
-
$menu_link = theme(‘menu_item_link’, $link);
-
$output .= theme(‘menu_item’, $menu_link, false);
-
}
-
$output = theme(‘menu_tree’, $output);
-
-
}
-
return $output;