A
A
Alexander Pupkin2015-11-11 20:12:45
Drupal
Alexander Pupkin, 2015-11-11 20:12:45

Question about your module. Where to dig?

Guys, guys, guys... Please tell me... Trying to make my own module...
<?php
/**
*
* Test my first module
*
*/

function test_menu() {
  $items['admin/config/system/test'] = array(
    'title' => 'Test Modul',
    'description' => 'Hello, this my first module',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('test_form'),
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

function test_form(){
  $form['quantity_comments'] = array(
    '#title' => t('Убрать количество комментариев в Тизере...'),
    '#type' => 'checkbox',
  );
  $form['quantity_new_comments'] = array(
    '#title' => t('Убрать количество новых комментариев в Тизере...'),
    '#type' => 'checkbox',
  );
  $form['add_new_comments'] = array(
    '#title' => t('Убрать "Добавить комментарий"...'),
    '#type' => 'checkbox',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}
function test_form_submit($form,&$form_state){
  if ($_POST['quantity_comments'] == TRUE) {
    //Что тут должно быть...!!!
  }
}

If you do not use the module, then in node.tpl.php I write:
if ($teaser) {
    unset($content['links']['comment']['#links']['comment-comments']);
}

All OK.
But if in the module, then where to contact (get through) to this field?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tlito, 2015-11-11
@sakrab

ts, you need to use one of the Drupal API functions to define a system function hook in your module. to influence the material teaser, you need to use the following function:
https://api.drupal.org/api/drupal/modules!node!nod...

S
Sergey, 2015-11-11
@serega_kaktus

see hook_preprocess_node(&$vars). $vars contains a set of variables that will be available in node.tpl.php. Should be something like

function test_preprocess_node(&$vars) {
  if ($vars['teaser']) {
    unset($vars['content']['links']['comment']['#links']['comment-comments']);
  }
}

PS The argument of the t() function must be text in English.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question