added template selection regarding simplenews categorie (trough url query)
This commit is contained in:
parent
4d0605604f
commit
d7dddd5764
@ -46,13 +46,34 @@ function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $fo
|
|||||||
// dsm($form_id, '$form_id');
|
// dsm($form_id, '$form_id');
|
||||||
// dsm($form_state, '$form_state');
|
// dsm($form_state, '$form_state');
|
||||||
// dsm($form, '$form');
|
// dsm($form, '$form');
|
||||||
|
// dsm($_GET, 'GET');
|
||||||
|
|
||||||
if(!$form['nid']['#value']){
|
if(!$form['nid']['#value']){
|
||||||
$form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodBodyTemplate();
|
if(isset($_GET['cat'])){
|
||||||
$form['body']['und'][0]['#rows'] = 50;
|
$cat = $_GET['cat'];
|
||||||
|
switch($cat){
|
||||||
|
case 6374:
|
||||||
|
$template = 'daily';
|
||||||
|
break;
|
||||||
|
case 6274:
|
||||||
|
$template = 'news';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepopulate type of news
|
||||||
|
$form['field_simplenews_term']['und']['#default_value'] = $cat;
|
||||||
|
$form['field_simplenews_term']['und']['#disabled'] = true;
|
||||||
|
|
||||||
|
// change default template regarding type of news
|
||||||
|
$form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodeBodyTemplate($template);
|
||||||
|
$form['body']['und'][0]['#rows'] = 50;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$form['field_simplenews_term']['und']['#disabled'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function materio_admin_getSimplenewsNodBodyTemplate(){
|
function materio_admin_getSimplenewsNodeBodyTemplate($template){
|
||||||
return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_node_template.html');
|
return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_'.$template.'_node_template.html');
|
||||||
}
|
}
|
1
templates/simplenews_news_node_template.html
Normal file
1
templates/simplenews_news_node_template.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p>TODO</p>
|
Loading…
x
Reference in New Issue
Block a user