added template selection regarding simplenews categorie (trough url query)

This commit is contained in:
Bachir Soussi Chiadmi 2014-04-23 18:40:19 +02:00
parent 4d0605604f
commit d7dddd5764
3 changed files with 26 additions and 4 deletions

View File

@ -46,13 +46,34 @@ function materio_admin_form_simplenews_node_form_alter(&$form, &$form_state, $fo
// dsm($form_id, '$form_id');
// dsm($form_state, '$form_state');
// dsm($form, '$form');
// dsm($_GET, 'GET');
if(!$form['nid']['#value']){
$form['body']['und'][0]['#default_value'] = materio_admin_getSimplenewsNodBodyTemplate();
$form['body']['und'][0]['#rows'] = 50;
if(isset($_GET['cat'])){
$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(){
return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_node_template.html');
function materio_admin_getSimplenewsNodeBodyTemplate($template){
return file_get_contents(drupal_get_path('module', 'materio_admin').'/templates/simplenews_'.$template.'_node_template.html');
}

View File

@ -0,0 +1 @@
<p>TODO</p>