1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- /**
- * Implements hook_init().
- */
- // function materio_user_init() {
- // drupal_add_js(drupal_get_path('module', 'materio_user').'/js/materio_user.min.js');
- // }
- /**
- * Implements hook_permission().
- */
- function materio_display_permission() {
- return array(
- 'view full materiau description' => array(
- 'title' => t('view full materiau description'),
- 'description' => t('view full materiau description'),
- ),
- );
- }
- /**
- * Implements hook_preprocess().
- */
- function materio_display_preprocess_field(&$vars, $hook) {
- // dsm($vars);
- $element = $vars['element'];
- if($element['#field_name'] == 'field_description'){
- // dsm($vars);
- if(!user_access('view full materiau description')){
- $value = $element['#items'][0]['value'];
- switch ($element['#view_mode']) {
- case 'cardbig':
- case 'cardfull':
- $limit = 210;
- break;
- default:
- $limit = 130;
- break;
- }
- $summary = truncate_utf8($value, $limit, TRUE, TRUE);
- $summary .= '<div class="upgrade"><p>'
- . t("In order to access full description, information about manufacturers and more, you need to upgrade your account.")
- . l(t("Pricing"), 'node/11187')
- . '</p></div>';
- // dsm($summary);
- $vars['items'][0]['#markup'] = $summary;
- }
- }
- }
- /**
- * Implements hook_entity_info_alter().
- */
- function materio_display_entity_info_alter(&$entity_info) {
- $entity_info['node']['view modes']['homeblock'] = array(
- 'label' => t('Home block'),
- 'custom settings' => TRUE,
- );
- }
|