added simplenews local actions + change template selection from query to path
This commit is contained in:
parent
f6d5c40ae2
commit
76efcb0778
@ -44,10 +44,8 @@ function materio_admin_menu() {
|
|||||||
'page arguments' => array('simplenews'),
|
'page arguments' => array('simplenews'),
|
||||||
'access callback' => 'node_access',
|
'access callback' => 'node_access',
|
||||||
'access arguments' => array('create', 'simplenews'),
|
'access arguments' => array('create', 'simplenews'),
|
||||||
// 'description' => $type->description,
|
|
||||||
'file path' => drupal_get_path('module', 'node'),
|
'file path' => drupal_get_path('module', 'node'),
|
||||||
'file' => 'node.pages.inc',
|
'file' => 'node.pages.inc',
|
||||||
'options' => array('query'=>array('cat'=>$tid))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +79,47 @@ function materio_admin_menu_alter(&$items){
|
|||||||
// $items['admin/content/add/simplenews/'.$tid]
|
// $items['admin/content/add/simplenews/'.$tid]
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_menu_local_tasks_alter().
|
||||||
|
*/
|
||||||
|
function materio_admin_menu_local_tasks_alter(&$data, $router_item, $root_path) {
|
||||||
|
|
||||||
|
if ($root_path == 'admin/people/simplenews') {
|
||||||
|
$item = menu_get_item('admin/content/simplenews');
|
||||||
|
if ($item['access']) {
|
||||||
|
$item['title'] = 'Go to '.$item['title'];
|
||||||
|
$data['actions']['output'][] = array(
|
||||||
|
'#theme' => 'menu_local_task',
|
||||||
|
'#link' => $item,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($root_path == 'admin/content/simplenews') {
|
||||||
|
|
||||||
|
$cats = simplenews_category_list();
|
||||||
|
foreach ($cats as $tid => $name) {
|
||||||
|
$item = menu_get_item('node/add/simplenews/'.$tid);
|
||||||
|
$item['title'] = 'Create new '.$name;
|
||||||
|
if ($item['access']) {
|
||||||
|
$data['actions']['output'][] = array(
|
||||||
|
'#theme' => 'menu_local_task',
|
||||||
|
'#link' => $item,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$item = menu_get_item('admin/people/simplenews');
|
||||||
|
if ($item['access']) {
|
||||||
|
$item['title'] = 'Go to '.$item['title'];
|
||||||
|
$data['actions']['output'][] = array(
|
||||||
|
'#theme' => 'menu_local_task',
|
||||||
|
'#link' => $item,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,9 +132,12 @@ function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $fo
|
|||||||
// dsm($_GET, 'GET');
|
// dsm($_GET, 'GET');
|
||||||
|
|
||||||
if(!$form['nid']['#value']){
|
if(!$form['nid']['#value']){
|
||||||
if(isset($_GET['cat'])){
|
$cats = simplenews_category_list();
|
||||||
$cat = $_GET['cat'];
|
$cats_tids = array_keys($cats);
|
||||||
|
$q = parse_url($_GET['q']);
|
||||||
|
$cat = array_pop(explode('/', $q['path']));
|
||||||
|
// dsm($cat, 'cat');
|
||||||
|
if(in_array($cat, $cats_tids)){
|
||||||
// prepopulate type of news
|
// prepopulate type of news
|
||||||
$form['field_simplenews_term']['und']['#default_value'] = $cat;
|
$form['field_simplenews_term']['und']['#default_value'] = $cat;
|
||||||
$form['field_simplenews_term']['und']['#disabled'] = true;
|
$form['field_simplenews_term']['und']['#disabled'] = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user