Posted by roy_k on July 6, 2014 at 9:56am
Hi all,
Im trying to crack it for awhile now without any success.
m trying to create a new content type with class name, day (checkbox), hours (start - end as list) for each day.
I
The idea is I have a teacher/manager who sign up his students and than s/he can send mass emails/SMS to the group of a specific class or day or hour (start hour).
I tried to search on google for tutorial without much success, the tutorial I found there are not complete or not explainable enought.
Im tring to do it by code. I
m using drupal 7 for this one.
How do I create this content type?
Thank you for the help in advance
Comments
Organic Groups
Hi RK,
Without knowing more details, it's hard to give a precise answer.
But, you should consider using Organic Groups for this. Each class can be a group (node), and then every one who joins this class can be mass notified.
You could also look at using Drupal Commons for a quick start on setting up this type system, or even just to investigate how that is built.
Mark Conroy,
Lead Frontend Developer,
Annertech - Web Agency of the Year 2016.
If drupal commons is an over
If drupal commons is an over kill for you you can tear it apart. Just use OG and the message stack.
Please, help.
Hello,
I created a new custom content type (field) after a long hard work (didn`t find any easy to understand guide).
I have few problem with it, the 1st and most important one is that it does not save the data to table (DB).
When I enable the module, I can add the new type field to a content type and I can enter the data alright but it does not save it.
I have noticed that it doesn`t create a table in DB.
mymodule.install:
/
* Implements hook_field_schema().
*/
function field_classime_field_schema($field) {
if ($field['type'] == 'field_classime'){
$schema['field_data_field_classime'] = array(
'description' => 'Field Classime table',
'columns' => array(
'fcid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'sunday' => array('type' => 'int', 'unsigned' => TRUE, 'title' => 'Sunday'),
'sun-hours' => array('type' => 'varchar', 'title' => t('Hours'), 'length' => 15),
'monday' => array('type' => 'int', 'unsigned' => TRUE, 'title' => 'Monday'),
'mon-hours' => array('type' => 'varchar', 'title' => t('Hours'), 'length' => 15),
'tuesday' => array('type' => 'int', 'unsigned' => TRUE, 'title' => 'Tuesday'),
'tue-hours' => array('type' => 'varchar', 'title' => t('Hours'), 'length' => 15),
'wednesday' => array('type' => 'int', 'unsigned' => TRUE, 'title' => 'Wednesday'),
'wed-hours' => array('type' => 'varchar', 'title' => t('Hours'), 'length' => 15),
'thursday' => array('type' => 'int', 'unsigned' => TRUE, 'title' => 'Thursdau'),
'thu-hours' => array('type' => 'varchar', 'title' => t('Hours'), 'length' => 15),
'friday' => array('type' => 'int', 'unsigned' => TRUE, 'title' => 'Friday'),
'fri-hours' => array('type' => 'varchar', 'title' => t('Hours'), 'length' => 15),
'saturday' => array('type' => 'int', 'unsigned' => TRUE, 'title' => 'Saturday'),
'sat-hours' => array('type' => 'varchar', 'title' => t('Hours'), 'length' => 15),
'translate' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
),
'indexes' => array(
'translate' => array('translate'),
),
'primary key' => array('fcid'),
);
}
return $schema;
}
/
* Implements hook_install().
*/
function field_classime_install() {
drupal_install_schema('field_data_field_classime');
}
/**
* Implement hook_enable()
*/
function field_classime_enable() {
//Check if table exists, if not install the schema.
if(db_table_exists('field_data_field_classime') == FALSE) {
drupal_install_schema('field_data_field_classime');
}
}
mymodule.module
/
* Implementation of hood_field_info()
*/
function field_classime_field_info(){
return array(
'field_classime' => array(
'label' => t('Class (day - hour)'),
'description' => t('custom class field'),
'default_widget' => 'field_classime_form',
'default_formatter' => 'field_classime_default',
),
);
}
/
* Implementation of hood_field_widget_info()
*/
function field_classime_field_widget_info(){
return array(
'field_classime_form' => array(
'label' => t('classime default'), //try another test here for widget ???
'field types' => array('field_classime'),
'behaviors' => array(
'multiple values' => FIELD_BEHAVIOR_DEFAULT,
'default value' => FIELD_BEHAVIOR_DEFAULT,
),
),
);
}
/
* Implementation of hook_field_widget_form()
*/
function field_classime_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element){
$base = $element;
if ($instance['widget']['type'] == 'field_classime_form'){
$widget = $instance['widget'];
$settings = $widget['settings'];
$element['sunday'] = array(
'#type' => 'checkbox',
'#title' => 'Sunday',
'#default_value' => isset($items[$delta]['sunday'])?$items[$delta]['sunday']:NULL,
);
$element['sun-hours'] = array(
'#type' => 'textfield',
'#title' => t('Hours'),
'#size' => 15,
'#maxlength' => 15,
'#default_value' => isset($items[$delta]['sun-hours'])?$items[$delta]['sun-hours']:NULL,
);
$element['monday'] = array(
'#type' => 'checkbox',
'#title' => 'Monday',
'#default_value' => isset($items[$delta]['monday'])?$items[$delta]['monday']:NULL,
);
$element['mon-hours'] = array(
'#type' => 'textfield',
'#title' => t('Hours'),
'#size' => 15,
'#maxlength' => 15,
'#default_value' => isset($items[$delta]['mon-hours'])?$items[$delta]['mon-hours']:NULL,
);
$element['tuesday'] = array(
'#type' => 'checkbox',
'#title' => 'Tuesday',
'#default_value' => isset($items[$delta]['tuesday'])?$items[$delta]['tuesday']:NULL,
);
$element['tue-hours'] = array(
'#type' => 'textfield',
'#title' => t('Hours'),
'#size' => 15,
'#maxlength' => 15,
'#default_value' => isset($items[$delta]['tue-hours'])?$items[$delta]['tue-hours']:NULL,
);
$element['wednesday'] = array(
'#type' => 'checkbox',
'#title' => 'Wednesday',
'#default_value' => isset($items[$delta]['wednesday'])?$items[$delta]['wednesday']:NULL,
);
$element['wed-hours'] = array(
'#type' => 'textfield',
'#title' => t('Hours'),
'#size' => 15,
'#maxlength' => 15,
'#default_value' => isset($items[$delta]['wed-hours'])?$items[$delta]['wed-hours']:NULL,
);
$element['thursday'] = array(
'#type' => 'checkbox',
'#title' => 'Thursday',
'#default_value' => isset($items[$delta]['thursday'])?$items[$delta]['thursday']:NULL,
);
$element['thu-hours'] = array(
'#type' => 'textfield',
'#title' => t('Hours'),
'#size' => 15,
'#maxlength' => 15,
'#default_value' => isset($items[$delta]['thu-hours'])?$items[$delta]['thu-hours']:NULL,
);
$element['friday'] = array(
'#type' => 'checkbox',
'#title' => 'Friday',
'#default_value' => isset($items[$delta]['friday'])?$items[$delta]['friday']:NULL,
);
$element['fri-hours'] = array(
'#type' => 'textfield',
'#title' => t('Hours'),
'#size' => 15,
'#maxlength' => 15,
'#default_value' => isset($items[$delta]['fri-hours'])?$items[$delta]['fri-hours']:NULL,
);
$element['saturday'] = array(
'#type' => 'checkbox',
'#title' => 'Saturday',
'#default_value' => isset($items[$delta]['saturday'])?$items[$delta]['saturday']:NULL,
);
$element['sat-hours'] = array(
'#type' => 'textfield',
'#title' => t('Hours'),
'#size' => 15,
'#maxlength' => 15,
'#default_value' => isset($items[$delta]['sat-hours'])?$items[$delta]['sat-hours']:NULL,
);
}
return $element;
}
/
* Implements hook_field_formatter_info()
*/
function field_classime_field_formatter_info(){
return array(
'field_classime_default' => array(
'label' => t('default'),
'field types' => array('field_classime'),
),
);
}
/**
* Implements hook_field_formatter_view()
*/
function field_classime_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display){
$element = array();
switch ($display['type']){
case 'field_classime_default':
foreach ($items as $delta => $item){
$element[$delta]['#markup'] = theme('field_classime_default', $item);
}
break;
}
return $element;
}
What did I missed that it doesn`t save?
Mail !
Is this your module?
You can try Event Calendar project. It seems it has a mailing integration feature too.
Calendar project
Hi Oltean74,
I did checked it out earlier than my developing the module.
It didn
t apply for my needs that is why I
m trying to make mine working.Any idea how to fix the saving problem?
Thanks