title: remove pagination in admin content page

text:
# Question
Title: remove pagination in admin content page
I cloned /admin/content (via the Views module). The clone uses a different URL (e.g. /admin/content/clone) and doesn't use any pagination.

In the view, I've set the pagination to *Display all items*; then, I hit save. When I navigate to /admin/content/clone, it still shows the pagination. I've already cleared the cache.

Does anyone know what I'm missing?

This is the exported view.

```
$view = new view();
$view->name = 'clone_of_admin_view_nodes';
$view->description = 'Find and manage content.';
$view->tag = 'admin';
$view->base_table = 'node';
$view->human_name = 'Clone of Admin View: Nodes';
$view->core = 0;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['title'] = 'etaewtaweta';
$handler->display->display_options['css_class'] = 'admin-views-view';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'menu';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['distinct'] = TRUE;
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['reset_button'] = TRUE;
$handler->display->display_options['exposed_form']['options']['autosubmit'] = TRUE;
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['columns'] = array(
  'views_bulk_operations' => 'views_bulk_operations',
  'type' => 'type',
  'title' => 'title',
  'timestamp' => 'timestamp',
  'title_1' => 'title_1',
  'title_2' => 'title_2',
  'field_content_owner' => 'field_content_owner',
  'status' => 'status',
  'changed' => 'changed',
  'edit_node' => 'edit_node',
  'delete_node' => 'delete_node',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'views_bulk_operations' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'type' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'timestamp' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'title_1' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'title_2' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'field_content_owner' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'status' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'changed' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'edit_node' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'delete_node' => array(
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
/* No results behavior: Global: Unfiltered text */
$handler->display->display_options['empty']['area_text_custom']['id'] = 'area_text_custom';
$handler->display->display_options['empty']['area_text_custom']['table'] = 'views';
$handler->display->display_options['empty']['area_text_custom']['field'] = 'area_text_custom';
$handler->display->display_options['empty']['area_text_custom']['empty'] = TRUE;
/* Relationship: Content: Author */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'node';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
/* Relationship: Content: Taxonomy terms on node */
$handler->display->display_options['relationships']['term_node_tid']['id'] = 'term_node_tid';
$handler->display->display_options['relationships']['term_node_tid']['table'] = 'node';
$handler->display->display_options['relationships']['term_node_tid']['field'] = 'term_node_tid';
$handler->display->display_options['relationships']['term_node_tid']['vocabularies'] = array(
  'forums' => 0,
  'tags' => 0,
);
/* Relationship: Book: Top level book */
$handler->display->display_options['relationships']['bid']['id'] = 'bid';
$handler->display->display_options['relationships']['bid']['table'] = 'book';
$handler->display->display_options['relationships']['bid']['field'] = 'bid';
/* Relationship: Book: Parent */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'book_parent';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
/* Field: Bulk operations: Content */
$handler->display->display_options['fields']['views_bulk_operations']['id'] = 'views_bulk_operations';
$handler->display->display_options['fields']['views_bulk_operations']['table'] = 'node';
$handler->display->display_options['fields']['views_bulk_operations']['field'] = 'views_bulk_operations';
$handler->display->display_options['fields']['views_bulk_operations']['label'] = '';
$handler->display->display_options['fields']['views_bulk_operations']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['views_bulk_operations']['hide_alter_empty'] = FALSE;
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['display_type'] = '0';
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['enable_select_all_pages'] = 1;
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['force_single'] = 0;
$handler->display->display_options['fields']['views_bulk_operations']['vbo_settings']['entity_load_capacity'] = '1';
$handler->display->display_options['fields']['views_bulk_operations']['vbo_operations'] = array(
  'action::node_assign_owner_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 1,
    'override_label' => 1,
    'label' => 'Change author',
  ),
  'action::views_bulk_operations_delete_item' => array(
    'selected' => 1,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 1,
    'label' => 'Delete',
  ),
  'action::views_bulk_operations_delete_revision' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::views_bulk_operations_script_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::node_make_sticky_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 1,
    'override_label' => 1,
    'label' => 'Stick',
  ),
  'action::node_make_unsticky_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 1,
    'override_label' => 1,
    'label' => 'Unstick',
  ),
  'action::views_bulk_operations_modify_action' => array(
    'selected' => 1,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 1,
    'label' => 'Change content owner(s)',
    'settings' => array(
      'show_all_tokens' => 0,
      'display_values' => array(
        'book::field_content_owner' => 'book::field_content_owner',
      ),
    ),
  ),
  'action::views_bulk_operations_move_to_book_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::views_bulk_operations_argument_selector_action' => array(
    'selected' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
    'settings' => array(
      'url' => '',
    ),
  ),
  'action::node_promote_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 1,
    'override_label' => 1,
    'label' => 'Promote to front page',
  ),
  'action::node_publish_action' => array(
    'selected' => 1,
    'postpone_processing' => 0,
    'skip_confirmation' => 1,
    'override_label' => 1,
    'label' => 'Publish',
  ),
  'action::node_unpromote_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 1,
    'override_label' => 1,
    'label' => 'Demote from front page',
  ),
  'action::views_bulk_operations_remove_from_book_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::node_save_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::system_send_email_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::node_unpublish_action' => array(
    'selected' => 1,
    'postpone_processing' => 0,
    'skip_confirmation' => 1,
    'override_label' => 1,
    'label' => 'Unpublish',
  ),
  'action::node_unpublish_by_keyword_action' => array(
    'selected' => 0,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
  'action::pathauto_node_update_action' => array(
    'selected' => 1,
    'postpone_processing' => 0,
    'skip_confirmation' => 0,
    'override_label' => 0,
    'label' => '',
  ),
);
/* Field: Content: Type */
$handler->display->display_options['fields']['type']['id'] = 'type';
$handler->display->display_options['fields']['type']['table'] = 'node';
$handler->display->display_options['fields']['type']['field'] = 'type';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
/* Field: Content: Has new content */
$handler->display->display_options['fields']['timestamp']['id'] = 'timestamp';
$handler->display->display_options['fields']['timestamp']['table'] = 'history';
$handler->display->display_options['fields']['timestamp']['field'] = 'timestamp';
$handler->display->display_options['fields']['timestamp']['label'] = '';
$handler->display->display_options['fields']['timestamp']['element_label_colon'] = FALSE;
/* Field: Content: Title */
$handler->display->display_options['fields']['title_1']['id'] = 'title_1';
$handler->display->display_options['fields']['title_1']['table'] = 'node';
$handler->display->display_options['fields']['title_1']['field'] = 'title';
$handler->display->display_options['fields']['title_1']['relationship'] = 'bid';
$handler->display->display_options['fields']['title_1']['label'] = 'Book';
/* Field: Content: Title */
$handler->display->display_options['fields']['title_2']['id'] = 'title_2';
$handler->display->display_options['fields']['title_2']['table'] = 'node';
$handler->display->display_options['fields']['title_2']['field'] = 'title';
$handler->display->display_options['fields']['title_2']['relationship'] = 'nid';
$handler->display->display_options['fields']['title_2']['label'] = 'Parent';
/* Field: Content: Content Owner(s) */
$handler->display->display_options['fields']['field_content_owner']['id'] = 'field_content_owner';
$handler->display->display_options['fields']['field_content_owner']['table'] = 'field_data_field_content_owner';
$handler->display->display_options['fields']['field_content_owner']['field'] = 'field_content_owner';
$handler->display->display_options['fields']['field_content_owner']['type'] = 'taxonomy_term_reference_plain';
$handler->display->display_options['fields']['field_content_owner']['delta_offset'] = '0';
/* Field: Content: Published */
$handler->display->display_options['fields']['status']['id'] = 'status';
$handler->display->display_options['fields']['status']['table'] = 'node';
$handler->display->display_options['fields']['status']['field'] = 'status';
$handler->display->display_options['fields']['status']['not'] = 0;
/* Field: Content: Updated date */
$handler->display->display_options['fields']['changed']['id'] = 'changed';
$handler->display->display_options['fields']['changed']['table'] = 'node';
$handler->display->display_options['fields']['changed']['field'] = 'changed';
$handler->display->display_options['fields']['changed']['label'] = 'Updated';
$handler->display->display_options['fields']['changed']['date_format'] = 'short';
/* Field: Content: Edit link */
$handler->display->display_options['fields']['edit_node']['id'] = 'edit_node';
$handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node';
$handler->display->display_options['fields']['edit_node']['field'] = 'edit_node';
$handler->display->display_options['fields']['edit_node']['label'] = 'Operations';
/* Field: Content: Delete link */
$handler->display->display_options['fields']['delete_node']['id'] = 'delete_node';
$handler->display->display_options['fields']['delete_node']['table'] = 'views_entity_node';
$handler->display->display_options['fields']['delete_node']['field'] = 'delete_node';
$handler->display->display_options['fields']['delete_node']['label'] = '';
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'book' => 'book',
);
$handler->display->display_options['filters']['type']['group'] = 1;
$handler->display->display_options['filters']['type']['exposed'] = TRUE;
$handler->display->display_options['filters']['type']['expose']['operator_id'] = 'type_op';
$handler->display->display_options['filters']['type']['expose']['label'] = 'Type';
$handler->display->display_options['filters']['type']['expose']['operator'] = 'type_op';
$handler->display->display_options['filters']['type']['expose']['identifier'] = 'type';
$handler->display->display_options['filters']['type']['expose']['remember'] = TRUE;
$handler->display->display_options['filters']['type']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
);
/* Filter criterion: Content: Title */
$handler->display->display_options['filters']['title']['id'] = 'title';
$handler->display->display_options['filters']['title']['table'] = 'node';
$handler->display->display_options['filters']['title']['field'] = 'title';
$handler->display->display_options['filters']['title']['operator'] = 'contains';
$handler->display->display_options['filters']['title']['group'] = 1;
$handler->display->display_options['filters']['title']['exposed'] = TRUE;
$handler->display->display_options['filters']['title']['expose']['operator_id'] = 'title_op';
$handler->display->display_options['filters']['title']['expose']['label'] = 'Title';
$handler->display->display_options['filters']['title']['expose']['operator'] = 'title_op';
$handler->display->display_options['filters']['title']['expose']['identifier'] = 'title';
$handler->display->display_options['filters']['title']['expose']['remember'] = TRUE;
$handler->display->display_options['filters']['title']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
);
/* Filter criterion: Content: Title */
$handler->display->display_options['filters']['title_1']['id'] = 'title_1';
$handler->display->display_options['filters']['title_1']['table'] = 'node';
$handler->display->display_options['filters']['title_1']['field'] = 'title';
$handler->display->display_options['filters']['title_1']['relationship'] = 'bid';
$handler->display->display_options['filters']['title_1']['value'] = 'Demo';
$handler->display->display_options['filters']['title_1']['group'] = 1;
$handler->display->display_options['filters']['title_1']['exposed'] = TRUE;
$handler->display->display_options['filters']['title_1']['expose']['operator_id'] = 'title_1_op';
$handler->display->display_options['filters']['title_1']['expose']['label'] = 'Book';
$handler->display->display_options['filters']['title_1']['expose']['operator'] = 'title_1_op';
$handler->display->display_options['filters']['title_1']['expose']['identifier'] = 'title_1';
$handler->display->display_options['filters']['title_1']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
);
$handler->display->display_options['filters']['title_1']['is_grouped'] = TRUE;
$handler->display->display_options['filters']['title_1']['group_info']['label'] = 'Book';
$handler->display->display_options['filters']['title_1']['group_info']['identifier'] = 'book';
$handler->display->display_options['filters']['title_1']['group_info']['remember'] = 1;
$handler->display->display_options['filters']['title_1']['group_info']['group_items'] = array(
  1 => array(
    'title' => 'Products and Investments',
    'operator' => '=',
    'value' => 'Products & Investments',
  ),
  2 => array(
    'title' => 'Systems and Technology',
    'operator' => '=',
    'value' => 'Systems and Technology',
  ),
  3 => array(
    'title' => 'Ops and Admin',
    'operator' => '=',
    'value' => 'Ops & Admin',
  ),
  4 => array(
    'title' => 'Compliance',
    'operator' => '=',
    'value' => 'Compliance',
  ),
  5 => array(
    'title' => 'Dept and Services',
    'operator' => '=',
    'value' => 'Dept & Services',
  ),
);
/* Filter criterion: Content: Title */
$handler->display->display_options['filters']['title_2']['id'] = 'title_2';
$handler->display->display_options['filters']['title_2']['table'] = 'node';
$handler->display->display_options['filters']['title_2']['field'] = 'title';
$handler->display->display_options['filters']['title_2']['relationship'] = 'nid';
$handler->display->display_options['filters']['title_2']['operator'] = 'contains';
$handler->display->display_options['filters']['title_2']['group'] = 1;
$handler->display->display_options['filters']['title_2']['exposed'] = TRUE;
$handler->display->display_options['filters']['title_2']['expose']['operator_id'] = 'title_2_op';
$handler->display->display_options['filters']['title_2']['expose']['label'] = 'Parent';
$handler->display->display_options['filters']['title_2']['expose']['operator'] = 'title_2_op';
$handler->display->display_options['filters']['title_2']['expose']['identifier'] = 'parent';
$handler->display->display_options['filters']['title_2']['expose']['remember'] = TRUE;
$handler->display->display_options['filters']['title_2']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
);
/* Filter criterion: Content: Content Owner(s) (field_content_owner) */
$handler->display->display_options['filters']['field_content_owner_tid']['id'] = 'field_content_owner_tid';
$handler->display->display_options['filters']['field_content_owner_tid']['table'] = 'field_data_field_content_owner';
$handler->display->display_options['filters']['field_content_owner_tid']['field'] = 'field_content_owner_tid';
$handler->display->display_options['filters']['field_content_owner_tid']['group'] = 1;
$handler->display->display_options['filters']['field_content_owner_tid']['exposed'] = TRUE;
$handler->display->display_options['filters']['field_content_owner_tid']['expose']['operator_id'] = 'field_content_owner_tid_op';
$handler->display->display_options['filters']['field_content_owner_tid']['expose']['label'] = 'Content Owner';
$handler->display->display_options['filters']['field_content_owner_tid']['expose']['operator'] = 'field_content_owner_tid_op';
$handler->display->display_options['filters']['field_content_owner_tid']['expose']['identifier'] = 'content_owner';
$handler->display->display_options['filters']['field_content_owner_tid']['expose']['remember'] = TRUE;
$handler->display->display_options['filters']['field_content_owner_tid']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
);
$handler->display->display_options['filters']['field_content_owner_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_content_owner_tid']['vocabulary'] = 'content_owners';
$handler->display->display_options['filters']['field_content_owner_tid']['hierarchy'] = 1;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 'All';
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['exposed'] = TRUE;
$handler->display->display_options['filters']['status']['expose']['operator_id'] = '';
$handler->display->display_options['filters']['status']['expose']['label'] = 'Published';
$handler->display->display_options['filters']['status']['expose']['operator'] = 'status_op';
$handler->display->display_options['filters']['status']['expose']['identifier'] = 'status';
$handler->display->display_options['filters']['status']['expose']['remember'] = TRUE;
$handler->display->display_options['filters']['status']['expose']['remember_roles'] = array(
  2 => '2',
  1 => 0,
  3 => 0,
  4 => 0,
);

/* Display: System */
$handler = $view->new_display('system', 'System', 'system_1');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['hide_admin_links'] = TRUE;
$handler->display->display_options['defaults']['access'] = FALSE;
$handler->display->display_options['path'] = 'admin/list';

/* Display: System 2 */
$handler = $view->new_display('system', 'System 2', 'system_2');
$handler->display->display_options['defaults']['access'] = FALSE;
$handler->display->display_options['path'] = 'admin/blah4';

```

# Answer
> 1 votes
Ok, now I get it: the problem is this is using the System display, not the regular Page one. You can see it in the Views list:

> **Administration: Nodes**
> Display: *System*
> In code
> Type: Content

What you should do is just create a regular 'page' display with all the settings you want to use.

If you just want to change the pagination and not have to re-create the whole view just go on and edit the main one!

BTW there was a guy with a similar problem on the issues list from the Administration Views module: https://www.drupal.org/node/2539256

---
Tags: views, paging
---


# Question
Title: How to add values to field collection fields within user profiles
I have a field collection that contains several other fields (text and taxonomy reference) for collecting and unlimited number of addresses. I have added this field collection to user profiles. This is for a custom e-commerce site, where users may also enter new addresses during the checkout process. So, I need to be able to add values to this field collection during the checkout process (not just within the user's profile). I have tried a 1/2 dozen examples out there, but, all of the available examples are for adding values to a field collection that is attached to a NODE, not to a USER. I've replaced the NODE code with USER code, but, I get errors when I run it. Here is the latest that I tried:

```
module_load_include('inc', 'entity', 'includes/entity.controller');
global $user;

// Setup the values in the structure expected by the field_collection entity.
$values = array(
  'field_cnm_address_fname' => array(
    'und' => array(array('value' => $address['fname'])),
  ),
  'field_cnm_address_lname' => array(
    'und' => array(array('value' => $address['lname'])),
  ),
  'field_cnm_address_street1' => array(
    'und' => array(array('value' => $address['street1'])),
  ),
  …etc.
);

//This line added via MrD's suggestion.
$values['field_name'] = 'field_cnm_address';   // field collection name.

$entity = entity_create('field_collection_item', $values);
$entity->setHostEntity('user', $user);
$result = $entity->save();

```

The error that I am getting is "Fatal error: Cannot access empty property in /.../sites/all/modules/field\_collection/field\_collection.module on line 326" which shows the line:

```
//(field_collection.module, line 326)
$entity->{$this->field_name}[$this->langcode][] = array('entity' => $this);

```

So, I'm thinking it does not recognize the host entity that I'm setting with setHostEntity()? I have added debugging output after each line of execution and can clearly see that it is failing at this line in my code:

```
$entity->setHostEntity('user', $user);

```

Any help or suggestions?

**edit 1:** I added the field\_name to the array as suggested, and, now the address is added without error. However, when I try to access the value now in the same way I had previously, I get a new error:

```
$wrapper = entity_metadata_wrapper('user', $user);
foreach ($wrapper->field_cnm_address as $a){
  $country_term_obj = $a->field_cnm_address_country->value();
  //the above line using ->value() returns this error:
  //Fatal error: Call to a member function value() on a non-object
}

```

Prior to programmatically adding values, the -\>value() function worked fine, it would return a taxonomy term object. When adding values to the field non-programmatically (via the user profile interface with the field collection that contains the taxonomy reference field), -\>value() would return a fully functioning object.

**edit 2:** Also, I have set this field collection to allow unlimited values. And, after programmatically adding to it's values, it appears that the "unlimited" feature has disappeared (the "add another" and "remove" buttons are gone on the user profile page).

**edit 3:** Ok sorry, ignore the above 2 edits. I see what's happening. The values that I'm adding via the code above is actually *replacing* the value that already exists in those fields for that user. Since this is a "unlimited" field collection, I'd like to be able to *add another*, versus replacing what's already been entered into those fields. Any idea how to do that?

**edit 4:** I've tried MrD's suggestion below for "Creat new multi value", However, now I have an error when trying to add a taxonomy term tid (my "field\_country" field in this field collection is a *term reference* field). For example:

```
$values[0]['field_country'][LANGUAGE_NONE][0]['tid'] = 123;

```

Error output is:

```
Notice: Undefined property: stdClass::$name in taxonomy_term_save() (line 628 of /.../modules/taxonomy/taxonomy.module).
Notice: Undefined property: stdClass::$vid in taxonomy_term_save() (line 630 of /.../modules/taxonomy/taxonomy.module).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /.../includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 354 of /.../includes/entity.inc).
Notice: Trying to get property of non-object in taxonomy_term_save() (line 631 of /.../modules/taxonomy/taxonomy.module).
EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7818 of /.../includes/common.inc).

```

It appears to be trying to save a taxonomy term. However, I am trying to assign an existing taxonomy term tid to the field, not save a new term. Any ideas?

# Answer
> 1 votes
You can try this

**Creat new one field**

```
  global $user;
  $values = array();
  // I think you missing field name of field collection.
  $values['field_name'] = 'field_address';   // field collection name.
  $values['field_field_name'][LANGUAGE_NONE][0]['value'] = 'Mr';
  $values['field_last_name'][LANGUAGE_NONE][0]['value'] = 'D';
  $values['field_street'][LANGUAGE_NONE][0]['value'] = 'Vietnamese';
  $field_entity = entity_create('field_collection_item', $values);
  $field_entity->setHostEntity('user', $user);
  $field_entity->save();

```

**Creat new multi value**

```
global $user;
  $values = array();
  $values[0]['field_name'] = 'field_address'; // field collection name
  $values[0]['field_field_name'][LANGUAGE_NONE][0]['value'] = 'Mr 0';
  $values[0]['field_last_name'][LANGUAGE_NONE][0]['value'] = 'D 0';
  $values[0]['field_street'][LANGUAGE_NONE][0]['value'] = 'Ha Noi 0';
  $values[1]['field_name'] = 'field_address'; // field collection name
  $values[1]['field_field_name'][LANGUAGE_NONE][0]['value'] = 'Mr 1';
  $values[1]['field_last_name'][LANGUAGE_NONE][0]['value'] = 'D 1';
  $values[1]['field_street'][LANGUAGE_NONE][0]['value'] = 'Ha Noi 1';
  foreach ($values as $key => $value) {
    $field_entity = entity_create('field_collection_item', $value);
    $field_entity->setHostEntity('user', $user);
    $field_entity->save();
  }

```

**Note**

```
  $field_entity->setHostEntity('user', $user);

```

**this line auto save data to field collections and save data to user. You don't need to do anything.**

**Update Field**

```
global $user;
// User need load user to get ids of field collections
$user = user_load($user->uid);
$array_ids = field_get_items('user', $user, 'field_address');
foreach ($array_ids as $key => $id) {
  $data = field_collection_item_load($id['value']);
  $wrapper = entity_metadata_wrapper('field_collection_item', $data);
  //Update value
  $wrapper->field_field_name->set('First Name');
  $wrapper->field_last_name->set('Last Name');
  $wrapper->field_street->set('Street');
  //Save value to field
  $wrapper->save();
}

```

---
Tags: entities
---


# Question
Title: What part of the Feeds api knows if there is a difference between old and new data?
i want to flag an item if the feed has made any changes in a record. What hook can I use to do a check of the new data and the old data to see if there is a difference? I need to mark data that is changed with a flag and also get a log of all changed nodes. Right now feeds seems to mark everything as updated even if there is no change.

I tried looking in hook\_feeds\_presave, but both the $item and the $entity are already changed there. What hook can see a comparison between the old and the new ?

# Answer
I am modifying the code in hook\_feeds\_before\_update and writing the code like this :

```
if ($item){
    $node = node_load($item);
    $changed=false;

      if ($entity['ITEM'] != $node->field_item[LANGUAGE_NONE][0]['value']){
         if (trim($entity['ITEM'])=="UNKNOWN"){
             $entity['ITEM'] = $node->field_item[LANGUAGE_NONE][0]['value'];

         }

      }

```

AND then I flag it with a rule :

```
{ "rules_flag_when_updated_by_feed" : {
"LABEL" : "Flag when updated by feed",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "flag", "feeds" ],
"ON" : { "feeds_import_csv_importer" : [] },
"DO" : [
  { "flag_flagnode" : {
      "flag" : "flag_asset_for_review",
      "node" : [ "node" ],
      "flagging_user" : [ "site:current-user" ],
      "permission_check" : "1"
    }
  }
]

```

} }
> 0 votes

---
Tags: feeds, flags
---


title: Views question with user reference

text:
# Question
Title: Views question with user reference
I have a content type courses with course name, instructor, coordinator and ta fields. Instructor and coordinator are of type user\_reference.

My data looks like below

course instructor coordinator

101 joe guo

102 joe larry

103 guo joe

My course view has filter criteria as below content access: access and Contextual filter : author ID

When Joe logs in, the display looks like

Courses

101

102

103

I'm trying to figure out how to display only the courses joe is an instructor for. It should not show 103.

Any ideas?

# Answer
> 1 votes
What you want is a contextual filter on your user reference field. It should be label like *Content: Instructor* (or whatever you named your instructor or coordinator field). For the **When the filter value is not in the URL** option, select *Provide the default value* and use the *User ID from logged in* user option.

# Answer
> 1 votes
I actually found the answer to my question. I add this code php code WHEN THE FILTER VALUE IS NOT AVAILABLE -\> Provide default value -\> Type is PHP Code.

```
global $user;
if (in_array('administrator', $user->roles)) {
  return 'all';
}
else {
  return $user->uid;
}

```

---
Tags: views, users
---


title: Drupal automatic TFA

text:
# Question
Title: Drupal automatic TFA
I want to setup the Two-factor Authentication (TFA) configuration automatically for each user that signs up in my site. Is that possible?

Because from what I have tried till now, all the users for whom I want TFA to be active needs to be configured individually. But shouldn't the ideal situation be such that the TFA will get active per user as soon as the user gets in the system?

What am I missing here? Isn't this a very obvious requirement?

# Answer
> 0 votes
There is currently no mechanism to require existing users to use TFA; if you use "authenticated user" with "Roles required to have set up TFA", then new users cannot set up TFA and existing users without TFA will not be able to log in.

TFA doesn't provide any mechanism for this, so I wrote a module that provides Rules integration and created a basic rule that would do it.

https://www.drupal.org/project/tfa\_rules

Instructions on setting up basic TFA on a site:

Download and install Two-Factor Authentication, TFA Basic Plugins, Rules and TFA Rules

```
drush dl tfa tfa_basic rules tfa_rules

```

Enable.

```
drush -y en tfa tfa_basic rules rules_admin tfa_rules

```

Configure TFA: /admin/config/people/tfa

* \[X\] Enable TFA
* Default validation plugin: TOTP
* \[Save configuration\]

Configure permissions: /admin/people/permissions

* Set up TFA for account
    + \[X\] authenticated user
* \[Save permissions\]

Visit /admin/config/workflow/rules to configure the rule.

Testing:

* Log out
* Create a user
* Login
* User will be redirected to the security page to set up TFA.

---
Tags: 7, users
---


title: How to add CKeditor Templates

text:
# Question
Title: How to add CKeditor Templates
Using CKeditor module I am trying to add a new template.

I have modified `default.js` in

`\sites\all\modules\ckeditor\ckeditor\plugins\templates\templates\default.js`

By adding a new entry, however after Flushing caches/restarting web server, I still don't see the new template when I edit content.

# Answer
> 11 votes
It was hard to find the information but I succeed:

1. Copy `ckeditor.config.js` from the ckeditor module ( `sites/all/modules/contrib/ckeditor/` ) to your theme ( `sites/all/themes/MYTHEME/` )
2. Edit the ckeditor profile configuration in Drupal ( `admin/config/content/ckeditor/edit/Full` ): in ADVANCE OPTION, set **Load ckeditor.config.js from the theme path** to YES
3. Modify the `ckeditor.config.js` from your theme to add your custom template file: `CKEDITOR.editorConfig = function(config) {`

`config.templates_files = [ Drupal.settings.basePath + 'sites/all/themes/MYTHEME/js/ckeditor.custom.templates.js' ];
//...continue the config file`
4. Copy your image template to `sites/all/themes/MYTHEME/ckeditor-tpl/`
5. In your JS theme file ( `sites/all/themes/MYTHEME/js/` ) create a file `ckeditor.custom.templates.js` as following: `CKEDITOR.addTemplates( 'default',
{
imagesPath: CKEDITOR_BASEPATH + '../../themes/boson/ckeditor-tpl/' ,
templates :
 [
 {
 title: 'My template',
 image: 'my-template.PNG',
 description: 'Your custom template.',
 html: 'Hello world!'
 },
 ]
});`

it works well for me. Hope it will help someone.

# Answer
> 1 votes
Maybe I'm missing something, but you could just use the Wysiwyg API template module. Here's a pretty good tutorial on adding templates step-by-step.

---
Tags: 7, wysiwyg
---


# Question
Title: How to limit number of displayed images within one field under views?
I've created a content type **News** with different fields, one of the fields is **field collection** that allows administrator to upload unlimited images with a detailed description text.

I used **Views** module to display a list of news on the homepage, now I want to limit the number of displayed images within field collection to **max 2** per news and when users clicks on the news to see full detail page they will be able to see all images that have been added by administrator.

Is there a way to limit number of items in the frontend but keep unlimited in the backend (admin)?

# Answer
When you use field collection in Views, go to the settings of field collection field in views and follow these steps :

```
1. There is a setting named "Multiple Field Setting"
2. Enter the number of pictures in the textfield you want to show in Field 'Display'

```

and you also specify Start from to where to start.
> 1 votes

# Answer
in order to do this you need direct access for the image field that exist in the field collection, so you need to add relation to field collection and then you add that image field directly.

In this way you will have control over the image field only, not the whole field collection, then you can limit the number of images in the Multiple Field Setting.
> 0 votes

---
Tags: views, media, entities
---


# Question
Title: Can a javascript variable be made configurable?
I defined a variable in my .js file and want the user/client to change that as per his needs. Is it somehow possible to use that value in forms in drupal?

# Answer
Too vague of a question, bring some examples of code.

It might go in a custom module (thus doing differently) or just using JavaScript where you can surely alter values of a variable.
> 0 votes

# Answer
Best practice is to store configuration in code, not in the database. With that said, the following will add an arbitrary JavaScript snippet:

```
drupal_add_js(variable_get('your_variable'), array(
  'type' => 'inline',
  'scope' => 'footer',
));

```
> 0 votes

---
Tags: javascript
---


# Question
Title: What is the best way to restrict website's direct access through node urls?
How can I prevent a node from being accessible on its own page, through `node/xxx`, but still be accessible through node description eg: `/homepage`?

I tried using the Rabbit Hole module, which restricted the page access through `nodes/xxx`. But it is restricting access even through the node's descriptive path. I don't want people having some knowledge of Drupal to play around with the website by typing in `node-IDs`.

So what is the best way to achieve this?

# Answer
> 1 votes
Using the Rules module you can implement a rule that looks similar to this:

```
{ "rules_check_url" : {
    "LABEL" : "Disallow node/* access",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "text_matches" : {
          "text" : [ "site:current-page:url" ],
          "match" : "node\/\\d+$",
          "operation" : "regex"
        }
      }
    ],
    "DO" : [
      { "drupal_message" : {
          "message" : "Sorry, URLs like [site:current-page:url] are not allowed around here ...",
          "type" : "error"
        }
      },
      { "redirect" : { "url" : "no_access" } }
    ]
  }
}

```

It assumes you'll have a node with a path like `no_access` (which is where a user trying to use node/xxx will be rerouted to). Feel free to adapt to any other path that fits).

The above rule does not (yet) take into account to only apply the "action" for selected user roles. E.g.: you may want such paths to be used (allowed) anyway for roles like 'administrator' or 'content-editor'. But for anybody a bit familiar with the Rules module, that is a straight forward "Condition" to add.

To experiment with this rule in your own site, just copy the entire Rules code above, and paste it in a new Rule in your own site, created via the "Import" function. Then further edit/refine to make it fit in your own environment (eg the "Sorry, ..." message to be shown.

If you have to still install the Rules module, you'll discover tons of other use cases to also be resolved by the same Rules module (possibly complemented with the Flag module soon ...)

---
Tags: nodes, uri, users, security
---


# Question
Title: How to add an id element to a field in Drupal 7
I am try to find out a way that I can add in #ID element to a link field in Drupal 7. When you Edit the field it give you a chance to create a CLASS (Additional CSS Class) for it, however I want to add an #ID element so that I can use it to trigger an event for google analytics. I actually was able to add and #ID to that panel display but it is 2 above and not triggering it.

Is there a way to do this without code, if not what approach would I take to handle through code(not my specialty). Here is an example of what I have...

```
<div class="panel-pane pane-entity-field pane-node-field-print-link"  id="newsletterPrint">
  <div class="pane-content">
    <div class="field-print-link">
      <a href="http://stage.ecgcme.com/print/project/MTH095AE1">Print</a>  </div>
  </div>
  </div>
  </div>

```

and I want this...

```
<div class="field-print-link" id="newsletterPrint">
          <a href="http://stage.ecgcme.com/print/project/MTH095AE1">Print</a>  </div>

```

# Answer
First of all are you using the Link module? Just so we know.

I would create a template to the field:

You can copy the `/modules/field/theme/field.tpl.php` to your theme, change the name to `field--field-print-link.tpl.php` and customize it in any way wanted.

Don't forget to flush your caches!

Or, of course, you could add the id with JS using a bit of jQuery (as Drupal already uses it):

```
$('element').attr('id', 'value');

```
> 2 votes

---
Tags: entities
---


# Question
Title: Drupal Import Commerce Product Display Multiple Images With Feed?
So... I have been attempting to import a list of products from a D6 site into Commerce Kickstart 2.6 and at every turn it's fraught.

My latest attempt has been to a) Use Node Export to get a CSV of products from old site. Good.

b) Import using Commerce Product Feeds, first to get the Product and then again to get the Display (nodes). Three problems:

How does one map the 'images' field in the CSV? The CSV I'm importing has a path to the JPG file for each product in the folder where the images can be found. Eg.

```
  /sites/default/products/myproduct.jpg

```

Two issues:

1. This works for -one- image, but not if the product has multiple images. I tried mapping the CSV columns for each image path to the 'Images' field in the importer multiple times but this did not work. Again, only the 1st image imported
2. I can't figure out how to add the ALT tag to each product.

So: should each image be simple strings or is there some other data format (eg. array)?

# Answer
When using Feeds & Commerce Product Processor you might want to to install Feeds Tamper as well. If the field that you are importing has multiple values you will typically have a delimiter (comma). I'd suggest using the explode function from Tamper to break the field into an array of values to import. It might also help if you do a replace on the values you exploded to use the public file URI syntax (public://products/myproduct.jpg).
> 1 votes

---
Tags: feeds, commerce
---


title: Custom output for user profile list

text:
# Question
Title: Custom output for user profile list
I have a "`user list`" view, which displays an "`unformatted list`" of user accounts.

While the row display is controlled via `views-view-unformatted.tpl.php` and customizing it works, the row plugin "`user`" in `views/modules/user/views_plugin_row_user_view.inc` directly outputs the user profile into the row.

Now as I already have a customized `user-profile.tpl.php` I cannot customize it for both view row and user profile page...

How do I implement custom display of user profiles in the user list, then?

# Answer
It's trivial, but—did you try changing the row plugin to Fields instead of User? With fields, you have granular control over the display of the user profile, so this might in effect be what you're looking for.
> 0 votes

---
Tags: views
---


title: Get Json From Module

text:
# Question
Title: Get Json From Module
I have to create a module that return a list of my language, only the list without template,and I have to call this url via curl

I create something like this ( inside my module )

```
function my_module_menu() {
  $items['my_module'] = array( //URL
    'page callback' => 'get_all_languages',
    'access arguments' => array(''),
  );
  return $items;
}

/**
 * @return string
 */
function get_all_languages() {
    $out = array();
    $result = language_list('enabled');
    foreach ($result as $key => $value) {
      foreach ($value as $k => $v) {
        $out[$v->language] = $v->name;
      }
    }

    $p = json_encode($out);
    print $p;
    drupal_exit();
}

```

I tried also

```
  drupal_add_http_header('Content-Type', 'application/json');
  $p = drupal_json_encode($out);

```

But this url is not Json infact if call this url by Curl, I can see all the template. I want to have the result like using this module, or can i Create a view that use my module result?

I have another problem when use curl, my content is

> You are not authorized to access this page.

# Answer
> 2 votes
Pretty close; here's the correct way:

```
/**
 * Implements hook_menu().
 */
function YOURMODULE_menu() {
  $items['languages'] = array(
    'page callback' => 'YOURMODULE_languages_enabled_json',
    'access callback' => TRUE,
  );
  return $items;
}

/**
 * Render enabled languages in JSON.
 */
function YOURMODULE_languages_enabled_json() {
  $out = array();
  foreach (language_list('enabled') as $languages) {
    foreach ($languages as $language) {
      $out[$language->language] = $language->name;
    }
  }
  drupal_json_output($out);
}

```

The important piece is https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal\_json\_output/7 which should be used for JavaScript callback functions returning data in JSON format, and it sets the header for the JavaScript output.

---
Tags: views, 7
---


# Question
Title: How to automatically send a push notification when content is created?
I have set up and configured the Push Notifications module for a site. But, I want to automatically send a Push Notification to all the mobile devices registered in the site when content of an specific content type is created. Can this be done?

I have called the content type "alert", and the user that can send alerts doesn't have access to the administration console, where the push is sent from.

# Answer
Use the Rules integration of the Push Notifications module. Refer to the issue "Add support for Rules module" for more details on this (issue status = needs review ...) and also use the appropriate patch from that issue.

For the "event" part of such rule to be created, just use "After saving content", limited to (= Rules condition) content type "alert".

If you have to still install the Rules module, you'll discover tons of other use cases to also be resolved by the same Rules module (possibly complemented with the Flag module soon ...).
> 2 votes

# Answer
Haven't used that particular module but, there are a few ways you could do this. Create a rule to send a push notification when an alert is created. It looks like from the module page that some work is needed with Rules integration. I would look there to see specifics on how to do this w/ Rules.

https://www.drupal.org/node/1658132#comment-8512423

You could also create a custom module to send a notification. You would use the hook\_node\_insert() and problematically send the notification.
> 1 votes

---
Tags: 7, nodes
---


# Question
Title: How does the views page style options work?
I have recently discovered the power of Views. I am using the Unformatted list Format and an Entity Reference bringing two content types that I created (myprojects and mytasks) together such that if there are any tasks associated with a given project they are listed below the related project. This works pretty well.

I know very little about HTML and really don't want to have to get into it. I want a simple indentation on each output task row displayed so that the report is easier to read. It would also be nice if it was double spaced.

The theme I'm using in my site is Outreach. What happens is each project is h3 and each row is inside div and underlined with a smaller font.

This list of projects and tasks becomes an agenda for meetings when copied into Word.

How can I use Settings for Unformatted list and/or Settings for Fields in the view to indent the rows of tasks?

# Answer
It is a CSS question, not Drupal.

I understand that using the Open Outreach theme you probably run a non-profit organization of some kind, so I'll try to help you.

You already said that you don't want to learn HTML/CSS in other questions so I will try to be straightforward: you can't.

What you might do is change from Unformatted List to HTML List and hope that the basic CSS don't change it. And yes, the preview **will be** different from the final view because templates. The closed admin part uses a template different than the open part.
> 0 votes

---
Tags: views
---


title: Page not found in drupal 7

text:
# Question
Title: Page not found in drupal 7
I am new to Drupal. I added a new content type and a view that points in the google map for the locations I entered

This worked fine in my local site. I implemented the same in the live site. But that gave a `page not found` error for every page and all the pages are redirected to some another unneccessary page.

Please let me know if adding a view can cause this kind of errors.

I used these modules: Location Map, Geocoder, geoPHP , Geofield and Geomap.

Or did this effect occure because of using these modules?

# Answer
Check if anything in this list of typical things might help:

Another option is to check the logs. If you find errors there (like PHP Fatal errors), then try to narrow down that error to the module that causes the error and disable that module (and report it in its issue queue on Drupal.org). If you don't know which module is causing it, then first disable all modules, and enable them one by one again. If at some point the error then comes back, then that must be the problem module causing your problem. Then disable that module again and re-enable all others.
> 1 votes

# Answer
*'Page not found'* is exactly what it refers to. That means that particular url is still not created. There are multiple ways to do that in Drupal 7 depending on your approach.

Since you indicated views, for views you would set the page at `Path:` under the `Page Settings` tab incase a Page Level view is being added.

Here is a link that can introduce some of those concepts.

If this does not help, please add the link where you would like to display the view at?
> 1 votes

---
Tags: views, 7
---


title: Using VDD with Drupal 6 site

text:
# Question
Title: Using VDD with Drupal 6 site
I'm trying to get a Drupal 6 site up and running with the Vagrant Drupal Development project.

I can get VDD going.. get my site installed, the database imported etc.. but I need to make VDD use an old version of PHP. I see some instructions online that say you can set which PHP version to use, but it isn't happening.. it doesn't say where in the json the setting needs to appear.

I tried with the following json, but it ended up as `PHP Version 5.4.39-1+deb.sury.org~precise+2` :

```
{
  "php": {
    "version": "5.2.17"
  },
  "vm": {
    "ip": "192.168.44.44",
    "memory": "1024",
    "synced_folders": [
      {
        "host_path": "data/",
        "guest_path": "/var/www",
        "type": "default"
      }
    ],
    "forwarded_ports": []
  },
  "vdd": {
    "sites": {
      "drupal6site": {
        "account_name": "root",
        "account_pass": "root",
        "account_mail": "box@example.com",
        "site_name": "drupal6site",
        "site_mail": "box@example.com",
        "vhost": {
          "document_root": "drupal6site",
          "url": "drupal6site.dev",
          "alias": ["www.drupal6site.dev"]
        }
      }
    }
  }
}

```

# Answer
> 1 votes
VDD of 8 version doesn't support the feature of changing PHP version. You may try other Vagrant box for Drupal. For example this one, it has very good documentation.

# Answer
> 0 votes
After having issues with both vampd and vdd I used a Turnkey linux iso for my virtualbox. They have one with Drupal 6 but I am using the Drupal7 one. Installs easily, configures one NAT adapter but you have to do the Host-only adapter yourself. Either start from the site they give you or replace it with your own existing site. I renamed the /var/www/drupal7 site folder and then did a `ln -s my.git_cloned.site drupal7` to just sym link my site (managed in git) to the existing apache configuration. Comes with phpmyadmin out of the box.

---
Tags: 6, installation, virtual-machine
---


# Question
Title: Permissions to edit only the Status of an order
I have created a role called "Order Manager", he should be able to

1. View all the orders.
2. Update the status of any order.
3. Not be able to edit(can edit only the status field, nothing else)/or delete any order.

How do I achieve this in Drupal Commerce?

# Answer
> 0 votes
1. Install Views Bulk Operations
2. Clone the default user/orders/% view of all the orders, and restrict it to your new role.
3. Add a Bulk Operations field to the view in step 2.
4. Follow the steps outlined as you add the new field from step 3. You can limit which status states the user can select while modifying.

---
Tags: 7, commerce
---


# Question
Title: Boost module, drupal-server encoding issue
## Background

I use Drupal 7.38 and Boost 7.x-1.0. According to Cron everything is up2date. I store my site at a (CentOS) NGINX-based **shared** hosting plan that seemingly **does** include UTF-8 encoding (my site is in Hebrew and the problem is language related). I have no idea if the following problem is a Boost bug or a fail, from my side, providing one of Drupal's encoding-related system requirements.

## The problem

The Boost module is installed and working (verified it's work when visited root/sitename/cache...) but now, in the bottom of each non-English webpage, I get the following 2 errors:

> * Warning: Cannot modify header information - headers already sent by (output started at /home/user/public\_html/sitename/includes/common.inc:2748) in drupal\_send\_headers() (line 1232 of /home/user/public\_html/sitename/includes/bootstrap.inc).
> * PDOException: in dblog\_watchdog() (line 160 of /ho/home/user/public\_html/modules/dblog/dblog.module).

## The exact whereabouts

These errors appear ONLY in non-English webpages... In English ones, they just don't appear... moreover, The cached webpage files that BOOST creates are named in Hebrew - i.e their file names are in Hebrew and actually resemble their H1. If I change the **file name** to an English one, and visit it from the site --- these errors no longer appear in it's bottom.

Maybe the server\Drupal\Boost fails to access the files correctly and and therefore prints these errors in their bottom. Note: It doesn't happen on a local Windows WAMP server, so it's likely the problem is in my online server and not in Drupal.

# Answer
> 1 votes
boost\_deliver\_html\_page() sounds like the issue. In your settings set `$conf['boost_message_debug'] = FALSE;` FALSE is the default value for that variable, this being TRUE seems to be causing the issue for you.

---
Tags: i18n-l10n, caching
---


# Question
Title: Theming custom entity created with Entity API: accessing entity's fields in template file
First of all let me say that this is my first project in Drupal and I am still confused, I apologize if my question is stupid.

I created a custom entity in Drupal 7 using Entity API. The custom entity represents a golf course.

I used this tutorial: http://www.sitepoint.com/series/build-your-own-custom-entities-in-drupal/ Then I tried to add a custom theme, to do so I followed this: https://www.drupal.org/node/1238606

My callback function looks like this:

```
function view_my_entity($id) {
  $entities = entity_load('my_entity_type', array($id));
  $entity = $courses[$id];
  drupal_set_title($entity->name);
  $output = entity_view('my_entity_type', array($entity));
  $output += array(
    '#theme'     => 'my_theme',
    '#element'   => $output,
    '#view_mode' => 'full',
    '#language'  => LANGUAGE_NONE,
  );
  return $output;
}

```

And this is my `hook_theme()`:

```
function my_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_theme' => array(
      'variables' => array('element' => null),
      'template' => 'my_template',
    ),
  );
}

```

The problem is that in `my_template.tpl.php` I can only access the golf course variables this way (in this example I will access the address):

```
render($element['my_entity_type']['The Name of my Entity']['address']['#markup'])

```

As you can see, in order to access the address I have to use 'The Lakes Golf Club', (which is the name of the currently displayed golf course), as a key, but obviously that name is going to change every time I display a different golf course, so my question is:

How can I access the golf course attributes without having to use the golf course name as a key?

**EDIT**

the docs for entity\_view() (http://www.drupalcontrib.org/api/drupal/contributions!entity!entity.module/function/entity\_view/7) say the following:

> Return value
>
> The renderable array, keyed by the entity type and by entity identifiers, for which the entity name is used if existing - see entity\_id(). If there is no information on how to view an entity, FALSE is returned.

So how do I avoid that the array is keyed by the name of the entity? If it was keyed by the id it would be OK because I have the `$id` variable in scope.

# Answer
> 0 votes
This can be easily solved by including this snippet at the beginning of your template file:

```
// my_template.tpl.php
<?php
$keys = array_keys($element['my_entity_type']);
$my_entity_name = $keys[0];
$my_entity = $element['my_entity_type'][$my_entity_name];
?>

```

Now you can easily print values like so:

```
<?php print render($my_entity['address']['#markup']); ?>

```

---
Tags: theming, entities
---


title: protecting a staging Drupal environment

text:
# Question
Title: protecting a staging Drupal environment
I've been using this code block inspired by Acquia to protect a client's staging environment.

```
if($_SERVER['SERVER_ADDR'] == '192.168.1.1') {

    $username = 'user';
$password = 'password';

if (!(isset($_SERVER['PHP_AUTH_USER']) && ($_SERVER['PHP_AUTH_USER']==$username && $_SERVER['PHP_AUTH_PW']==$password))) {
header('WWW-Authenticate: Basic realm="This site is protected"');
header('HTTP/1.0 401 Unauthorized');
// Fallback message when the user presses cancel / escape
echo 'Access denied';
exit;
}
}

```

I'm finding that I'm getting mixed results with it though.

I can access fine - as can some users but others can't get the user/password to accept.

I did post the same thing on SO but kinda got shot down so hoped the Drupal community could be more indulging/enlightening as to where we're falling down.

Thanks in advance. Steven

# Answer
That shouldn't have been shut down on SO as this is more a general PHP / Acquia hosting problem than it is with Drupal.

You should have your code echo out the contents of `$_SERVER['PHP_AUTH_USER']` & `$_SERVER['PHP_AUTH_PW']` in your "Access Denied" message; that will let the user inform you of exactly what's going on by the relaying the output of the script.

One of 2 things is going on to give inconsistent results:

1. The user's browser in question aren't sending the authentication header over (`Authorization:Basic dXNlcjpwYXNzd29yZA==` for "user" / "password")
2. The code executed at the time of user request isn't setting the correct vars `$_SERVER['PHP_AUTH_USER']` & `$_SERVER['PHP_AUTH_PW']` upon script execution (e.g. caching, something filtering out the `Authorization` header before it reaches the target host machine executing the PHP script).
> 0 votes

---
Tags: staging
---


# Question
Title: How can I add a second submission handler to a form to run after the default handler node_form_submit
I need to generate a node of a dependent content type when creating a node of the primary content type.

I have successfully created the function to be called and attached it to the form and it creates the node as desired, but since the function that generates the secondary node runs first, it cannot be populated with the node id of the primary node, nor with any other data elements from the primary node.

How do I ensure that the submit handlers are executed in the proper order?

```
   $form['#submit'][] = 'nttac_custom_tta_submit';
   $form['actions']['submit']['#submit'][] .= 'nttac_custom_tta_submit';
   $form['actions']['submit']['#submit'][] = array('node_form_submit','nttac_custom_tta_submit');

```

None of the above methods seem to work although they do get the handlers in the proper order

# Answer
All the methods you have mentioned should be calling your custom submit handler at the end. However check your $form array when the page is loaded to confirm your custom submit handler is at the right place.

If not try

```
MYMODULE_entity_insert($entity, $type) {

//Paste your secondary node creation code here

}

```

See https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook\_entity\_insert/7 for more details on this hook
> 2 votes

# Answer
you should user a hook instead :

https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook\_node\_submit/7
> 0 votes

---
Tags: forms
---


title: Views and Taxonomy Terms Page Layout

text:
# Question
Title: Views and Taxonomy Terms Page Layout
I have a view that sorts by a taxonomy term. After the view layout, i need to find a specific way to have that page that's clicked on to be styled with a different background. For instance, this view will show a background of a Football, but I also have a view for other sports. Is there a way to determine the page name? Right now, its just a node-page-profile. Here's the link.

http://dev-httpwwwrestechsyscom.pantheon.io/profiles-football

# Answer
Ok, you want to expose your taxonomy to your nodes to change the background.

**Using the Context Module**

> Add a condition Taxonomy and select your term (football) and the reaction Theme HTML add the class (football). As far as I got here you will need one rule for each term, you can't use a token directly.

**Using a custom module**

You can do it with a custom module or just throw a preprocess\_page it in your theme:

```
function my_theme_preprocess_page(&$vars, $hook) {
  if (module_exists('taxonomy') && $vars['node']->nid) {
    foreach (taxonomy_node_get_terms($vars['node']) as $term) {
      $vars['node_terms'] .= ' taxonomy-'.strtolower(eregi_replace('[^a-z0-9]', '-', $term->name));
    }
  }
}

```

Got from: https://www.drupal.org/node/67587

BTW you should really change the path for the nodes! I know it is still in dev but don't forget it!
> 1 votes

# Answer
You can apply different background for different pages using body class which will be unique for each pages. The way you have done right now is correct.

```
body.page-profiles-football .container{background-image:url(''); }

```
> 1 votes

# Answer
There is many ways to do this , the most easy way is to use the classes name that added to your body tag , so you do in your css

```
.page-node-52 #main-content{
  background: ....
}

```

this classes changes based on the current node ID

Another way you can add image field to node and update the background and in node.tpl file you render that image as background.

also you can add any class to the body array based on page\_preprocess in your template.php checkout Drupal API - template\_preprocess\_page
> 0 votes

---
Tags: views, nodes, taxonomy-terms, theming
---


# Question
Title: The test case is not recognized by the Simpletest module
I am using Drupal 7, and the latest version of the Simpletest module. I have written a test case like the following one:

```
class SimpleTestDemoTestCase extends DrupalWebTestCase {
  function setUp($modules = array()) {
    parent::setUp('simpletestdemo');
  }

  public function getInfo(){
    return array(
      'name' => 'Simpletestdemo testcase',
      'description' => 'Simpletestdemo testcase desc',
      'group' => 'Simpletestdemo'
    );
  }

  public function testBlockView() {
    $simpletestblockview = module_invoke('simpletestdemo','block_view);
    $this->assertTrue(t('Simpletest Demo'),$simpletestblockview['title']);
  }
}
?>

```

This does not get recognized by the Simpletest module. Is there anything wrong in this test case?

# Answer
> 2 votes
As srihita pointed out in a comment, you need to add the file which contains the test class to the files\[\] array in your module's info file like this:

```
files[]=yourmodule.test

```

Then, let it rebuild by submitting the modules page or use the "Clear information" (or similar, not sure about the exact label right now) at the bottom of the Testing page.

Also, you're code is missing a ', but that might be a copy/paste error.

# Answer
> 0 votes
I am also facing same problem.

The test case is not recognized by the Simpletest module.
i have added files\[\] = jobs.test in info file

Jobs Tests is visible in http://localhost/drupal7/admin/config/development/testing

'Jobs Tests', 'description' =\> 'Unit Tests for this module', 'group' =\> 'Jobs', ); }

function setUp() { parent::setUp(); }

/\** public function jobrecivedapplicationTest() { $result = jobs\_recieved\_applications(); $this-\>assertNOTNULL($result, 'should retrieve all the informtion'); } \*/ function jobrecivedmailTest() { require\_once(jobsssssss.module); $result = simpletest2(); // $this-\>assertNOTNULL($result, 'should retrieve all the informtion'); // assertMail($name, $value = '', $message = '') $this-\>assertMail($result, "kumara.suresh25@gmail.com", 'The last message subject was "My latest email"'); } }

---
Tags: 7, testing
---


title: displaying a webform in an overlay

text:
# Question
Title: displaying a webform in an overlay
I want the user defined webform to be popped up in an overlay when a button is clicked. I am using colorbox and colorbox-node modules. I am able to display the whole node. But I am not understanding how to display just the webform instead of the whole node. I used the following code:

```
 <a class="colorbox-load" href="enquiry?width=600&height=600&iframe=true"><input value="Send Enquiry" type="submit"> </a>

```

# Answer
> 5 votes
If I need to display *webform* in popup, then I would use *ctools modal*.

You can use modal forms module which make use of the modal feature in the ctools module to open some common forms in a modal window.

Supported forms

* Log in (modal\_forms/nojs/login)
* Request new password (modal\_forms/nojs/password)
* Create new account (modal\_forms/nojs/register)
* Contact (modal\_forms/nojs/contact)
* Comment (modal\_forms/nojs/comment/reply/%node)
* Webform (modal\_forms/nojs/webform/%node)

May be this is not answer to your question as you are using *colorbox*, but I am adding this so that you can check other option.

# Answer
> 4 votes
1. you can enable webforms as a block --\> select the webform content you created, tab "Webform" \> "Form Settings" \> "Enable as a block"
2. put the block inside a region, I've put mine in the footer region
3. CSS style the footer webform block as "display: none;"
4. for colorbox: in "configuration", "Media", "Colorbox" --\> advanced settings, activate "Enable Colorbox inline"
5. add this as the html code for opening the colorbox webform link:

> `<a class="colorbox-inline" href="?width=310&height=460&inline=true#name-of-your-block">`

You can also display the webform in popup using Colorbox Node module.

> Gives the user the ability to display ANY page inside a colorbox modal without the header and footer. Those pages include:
>
> * Node Pages
> * User Pages
> * Views Pages
> * **Webforms (requires Webform Ajax Module)**
> * Integration with Views
> * Integration with Context
> * Integration with Panels

# Answer
> 0 votes
Check out these link how to display webform in overlay

Allow webforms to open in Colorbox

display a popup box containing webform using simple dialog module

---
Tags: 7, webforms, modal-dialogs, javascript
---


# Question
Title: load node author uid to be used as contextual link inside template.php D7
I need to load node author uid to be used as part of a href link inside template.php, I managed to add a **contextual link** according to this post, and call it from node.tpl.php but I can't access node author uid to complete my link. I have a view with the following path: `/userview/%/post`, link inside node.tpl.php it appears, but does not work. I tried to do it by custom module, but I do not know how to load the 'node being viewed' in a custom module, that's why I'm trying to do it in template.php. Any help will be appreciated.

This is my code in template.php

```
function MYTHEME_node_view_alter(&$build) {

         $node_author = user_load($node->uid);

          // Add your own custom link
          $build['links']['node']['#links']['user-post'] = array(
            'title' => t('User post'),
            'href' => '/userview/' . $node_author . '/post',
            'html' => TRUE,
            'attributes' => array(
              'title' => 'User post',
            ),
          );

        }

```

# Answer
> 2 votes
You have just a tiny mistake , use **$build\['#node'\]-\>uid** instead **$node-\>uid** :)

```
function MYTHEME_node_view_alter(&$build) {

         $node_author = user_load($build['#node']->uid);

          // Add your own custom link
          $build['links']['node']['#links']['user-post'] = array(
            'title' => t('User post'),
            'href' => '/userview/' . $node_author . '/post',
            'html' => TRUE,
            'attributes' => array(
              'title' => 'User post',
            ),
          );

        }

```

---
Tags: 7, theming, navigation
---


# Question
Title: Where is views exposed form's submit handler located?
When views exposed form is submitted without ajax it redirects to somepage like http://example.com/reports?taxonomy=tid&date=27%20F6%20f2005 etc.

I am curious to know ,in views module,inc file where it's submit handler is located,where is ajax callback?

I tried for some hours but no luck.

I know about hooks like form alter but that's not a concern.

I have no specific requirements,just for drupal learning :)

# Answer
All of its functions are handled in programmatic way. You can look all functions are declared in `theme.inc` file located at `module/views/theme/theme.inc` location. Its hard to understand that core functions. But if you want to play with these functions then you will have to use the hooks .

**NOTE:** Never try to change any core file.
> 1 votes

# Answer
You can hook in to the form and see submit handlers and which form elements have ajax callbacks by debugging the form.

`kpr()` is a function available when you have installed the Devel module.

```
function MYMODULE_form_views_exposed_form_alter(&$form, &$form_state) {
  kpr($form);
}

```

You will need to put the function above in a custom module.
> 0 votes

---
Tags: views
---


title: Taxonomy terms are not linked to nodes

text:
# Question
Title: Taxonomy terms are not linked to nodes
I have a content type with a field term reference to a vocabulary using selection list widget. When i fill the content type, i get in the output the term selected. But i click on that term i have the message : There is currently no content classified with this term.

Any help please ?

# Answer
> 0 votes
I think you have multi language site.
I suggest you use the Taxonomy display module, here is a quote from its project page:

> The taxonomy display module allows administrative configurable term display pages. This allows administrators to override the default presentation of taxonomy term pages per vocabulary through the taxonomy term page's manage display form.

---
Tags: nodes, taxonomy-terms
---


# Question
Title: slide through nodes from the same content-type?
I've got a content-type called `design_portfolio`, and created an amount of fields

I've created a view (using the Views module) of only the the field 'thumbnail-design'-image, which is sorted on taxonomy terms in the header

which gives me the next result on the front-end

Each 'thumbnail' links to its' own content, which is a node from the content-type 'design\_portfolio' and gives me this result (I wrote a file 'node--design\_portfolio.tpl.php' to style the pages for this content-type). Each thumbnail directs to another content within the content-type 'design\_portfolio'

Everything what I have right now is working properly and has to stay, but what I want to achieve right now is, the posibillity to slide through all the pages/nodes of just this content-type 'design\_portfolio'. Like this:

I've allready tried to achieve it with creating a view with 'views slideshow'. Which gives me a good result, but when I click on my thumbnail, it still goes to the corresponding content (page/node), but not the the slideshow that I've created. I want every link to direct to the corresponding slide, because every thumbnails has it's own content.

settings of field thumbnail-design in my first view

inspecter to target a specific link of one slide in the slideshow (created of all content from content-type design\_portfolio, used 'views-bootstrap-carousel')

Any solutions for my problem?

# Answer
> 2 votes
# Views Slideshow

### About this module

You could use the Views Slideshow module for this. Here is a quote from its project page:

> ... can be used to create a slideshow of any content (not just images) that can appear in a View. Powered by jQuery, it is heavily customizable: you may choose slideshow settings for each View you create.
>
> **Potential uses**:
>
> * News item slideshow (such as the title, image and teaser of the last 5 news articles submitted).
> * The Last X number of X submitted (images, videos, blog entries, forum posts, comments, testimonials, etc.).
> * Rotate any image, based on any filters you can apply in views.
> * Hottest new products for any ecommerce drupal site.
> * Rotate contact links, share links, etc.
> * You could rotate entire nodes, categories, image galleries, etc. I wouldn't suggest it, but you have that power.
> * It's also a great space saver. Places where you had multiple images or multiple items such as RSS feeds or category listings can now be presented in a slideshow.
>
> The possibilities are really endless, as the more ways you can think of to categorize and add to views, the more you can rotate.

### How to install and use this module

***Option a***: Use the available (Community) Documentation

To actually enable and use this module, make sure you follow the instructions detailed in the module's Community Documentation within "3.x - Views Slideshow Tutorial". Especially this part of it:

> ...
>
> 8. Enable the `Views slideshow` and `Views Slideshow: Cycle` modules.
> 9. You should now **see** the new **views style** option called **"Slideshow"**.

So make sure that you also enabled the `Views Slideshow: Cycle` sub-module.

***Additional refinements***:

Since in this case you want to do something special (tricky?), you need to do some extra things, within "settings of field thumbnail-design in my first view" (as in your last screenprint):

* Where there is your "red arrow" (higlighter), it should say "link to" = "nothing" (you now have, in Dutch, "inhoud", which is "content"). FYI: That is what explains what is happening "now": you're asking a click on that image to be translated to something link "type an URL path = the path of the node where that image field is related to ...
* Where there is your "red cross" (rewrite result), within the 'text' box ('Tekst' in Dutch), you need to further refine what you already have (with that div and token). More specifically, you need to REWORK that to something that corresponds to an hyperlink ('href', etc) (in which you can still use that div, with its class, and image token you already have). The PATH in that href needs to match the exact path that will bring you to what further on in your question you described as "*I want every link to direct to the corresponding slide, because every thumbnails has it's own content.*". What exactly that path is I cannot tell (I hope YOU know that path, if not we're done). However read on in the next bullet for 1 more hint to CREATE that path for the hyperlink to be added in this tekst box here ...
* To create the correct path in the previous bullet, I "expect" that you might need something like the "nid", or something similar, of the actual node. It is possible that it is not available (yet) in the list of tokens within "replacement patterns". In my environment, at first I did not have the `[nid]` token available at first, only things like `[title]`, %1, !1, %2 and !2 . However, also making the `[nid]` token available is possible like so: add an extra field (node Id) BEFORE (important) the field you already have, and mark it with "exclude from display". That's tricky, but that's how this works in Drupal ...

***Option b***: Restart from scratch

From the details provided in the question, it appears that it might be an option to consider starting from scratch (which is what I sometimes also do ...). Use HOW TO INSTALL & SETUP VIEWS SLIDESHOW MODULE ON DRUPAL7? as a possible step-by-step tutorial to do so.

As a variation, carefully review that tutorial to get ideas about what in your current approach seems to be wrong, and go back to option 'a'.

***Option c***: Try another module

If you rather want to change to using "Views Bootstrap" (cfr. one of the prior "versions" of this question, which contained "*Views slideshow didn´t pop-up while creating a view, so I used Views Bootstrap.*"), then please create a NEW question about using Views Bootstrap (which I'd be happy to answer "also" if I can. Because that is a completely different question (and compliant to recent guidance / instructions from @Clive also).

### Further enhancements

Possibly you may want to further extended this with related modules (there are dozens of modules to further enhance views) such as Views Slideshow: Galleria. Here is a quote from that module's project page:

> Integrating Galleria with Views Slideshow.
>
> Galleria is a JavaScript image gallery framework built on top of the jQuery library. The aim is to simplify the process of creating professional image galleries for the web and mobile devices.

# jCarousel

Another option is to consider the jCarousel module. Here is a quote from its project page:

> ... This module allows developers and themers to make use of the jCarousel jQuery plugin. It includes a developer API that other modules can use, as well as Views integration in the 2.0 version so that you can turn any list of content or images into a carousel.
>
> **Features**:
>
> * Built-in Views support.
> * AJAX-loading of additional items as needed.
> * Carousel pager/navigation to jump between multiple pages.
> * Circular wrapping of items.
> * API for direct usage of jCarousel without Views.

---
Tags: views, nodes
---


# Question
Title: Trying to add a class to a menu in a preprocess function
I want to add a class to a menu - doing it in hook\_menu won't work because I'm adding an icon with the icon API, and this seems to override any classes put on the menu items.

I have this preprocess function:

```
/**
 * hook_preprocess_page().
 */
function MYMODULE_preprocess_page(&$vars) {
  $vars['main_menu']['menu-1914']['attributes']['class'] = array('message');
}

```

But it doesn't seem to add the css class "message" onto my element.

How do I reliably add a css class to a menu item before display, but before icon API would display it. Theming has to be my weakest Drupal skill.

# Answer
To add class in navigation's `<ul>` element, include below code in template.php

```
function THEMENAME_menu_tree__menu_MENUNAME($variables) {
return '<ul class="CLASSNAME YOU WANT TO ADD">' . $variables['tree'] . '</ul>';
}

```
> 1 votes

# Answer
I was able to apply a class to the menu item this way:

```
function MYMODULE_preprocess_menu_link(&$variables) {
  if($variables['element']['#original_link']['link_title'] == "Messages") {
  $variables['element']['#attributes']['class'][] = "no-message";
  }
}

```
> 0 votes

---
Tags: routes, theming
---


# Question
Title: Get UC product attributes using Views Global PHP
I tried using below code in Views \> Global PHP field.

```
<?php

$request = db_query("SELECT data FROM {uc_order_products } WHERE order_id= $row->order_id")->fetchField();
$att =  $request;

$data = unserialize($att);

if (is_array($data['attributes'])) {
  foreach ($data['attributes'] as $attribute => $option) {
    echo $attribute . ':   ' . implode(', ', (array)$option) . '<br>';
  }
}

?>

```

Adding above code I get the below error :

> SQLSTATE\[42000\]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Also how do I print each attribute in a different field?

# Answer
```
<?php

$request = db_query("SELECT data FROM {uc_order_products } WHERE order_id= $row->order_id");
foreach($request as $rwq){
$att =  $rwq;

$data = unserialize($att);

if (is_array($data['attributes'])) {
  foreach ($data['attributes'] as $attribute => $option) {
    echo $attribute . ':   ' . implode(', ', (array)$option) . '<br>';
  }
}
}
?>

```

try this
> 0 votes

# Answer
If you use a variable in your request, it's preferable to use it like this : WHERE o.order\_id = :oid', array(':oid' =\> $row-\>order\_id).

So I guess it would be :

```
$request = db_query('SELECT o.data FROM {uc_order_products} o WHERE o.order_id= :oid', array(':oid' => $row->order_id)')->fetchField();

```

To have different fields, you can do this processus for each field, by using multiple PhP fields in your view. But to rationalize requests, I would first do that request in the "**setup code**" and set all your data in the $static variable.
> 0 votes

---
Tags: 7, views, theming, ubercart
---


# Question
Title: Inline css is not working in ck editor full html
I have installed updated version of the CKEditor - WYSIWYG HTML editor module with CK editor library.

Every time I put `inline css` in my **HTML full editor**, it vanished.

I have searched the web for it, but not found proper solution.

Anybody any suggestions about this?

# Answer
> 1 votes
This is just an example where you can add inline class to P tag. Similarly you can do this with other tags. Refer CKEditor documentation

In the "**Advanced Content Filter**" section of CKEditor profile add this:

```
P [*]

```

In the "**Advanced options**" section of CKEditor profile add this:

```
config.allowedContent = true;

```

This did the trick for me.

# Answer
> 0 votes
I think your problem is in the Advanced content filter settings of you profile: You can add an exception or disable it.

---
Tags: wysiwyg
---


# Question
Title: Menu access callback function called multiple times
I have following menu defined with access callback function. As You can see this is a *hack* so I can use REST via GET ( normally Services do not offer this ).

All my endpoints are defined `/rest/api/[endpoint]` this is a `/config` one:

```
function MYMODULE_menu() {
    $menus['rest/api/config'] = array(
        'title' => 'Configuration',
        'page callback' => 'MYMODULE_config',
        'access callback' => 'MYMODULE_access_callback_basic_auth',
        'type' => MENU_CALLBACK,
    );
    return $menus;
}

```

The issue is that the `MYMODULE_access_callback_basic_auth` is called 5-times for every request.

Can You help me why this happens ?

# Answer
> 0 votes
Drupal forms are clever enough to know whether or not they've been submitted in the current page call and can react accordingly. Your best bet would be to move your code logic to inside the form function, where I think you can check for `$form_state['#submitted']` to decide whether this code runs or not.

Alternatively you could check for the existence of `$_POST` variables in the `MYMODULE_menu()` function.

> Check and read it out `$form_state['cache'] = true;` from here.

Hope that helps.

---
Tags: 7, routes, services
---


# Question
Title: Add show more/read more to CKEditor Drupal
How can I add a button to CKEditor so users can use read/show more in their editor. This would help me a lot. I have looked in a lot of places, but no succes. I am no programmer, so I'm not familiar with drupal/php code.

# Answer
> 0 votes
You should use the Collapse Text Module and here is a good description how to install it.

And there is already a CKEditor Plugin for this module as well.

# Answer
> 1 votes
I don't think this is possible within CKEditor and even if it's possible you need to make sure that your theme understands the tags inserted by CKEditor which is not always the case.

This is because when the text content is displayed on the theme layer CKEditor is not involved at all at that point and Drupal, the Text Formats you define, views if configured, and the theme layer take care of displaying the text.

Possible solution: by default Drupal gives you the body text as "Long text and summary" with the widget "Text area with a summary" and hence your editors, by default, can click on "Edit Summary" on top of the editor to input summary text. I highly recommend you stick to inputting the summary text here and then the "read more" text in the body as most themes and views use that functionality by default. Some don't, but I see this as standard most of the places.

Good luck.

---
Tags: 7, wysiwyg
---


# Question
Title: Serve 404 page based on field within a node
I have a content type which has a field that when set to a specific value it should serve a 404 page instead of the nodes content.

What's the nicest way to achieve this?

# Answer
You can use template\_preprocess\_field for this

```
function templatename_preprocess_field(&$variables) {
  if ($variables['element']['#field_name'] == 'myfield') {
    if ($variables['element']['#items'][0]['value'] == 'somevalue') {
      drupal_not_found();
    }
  }
}

```
> 0 votes

# Answer
you can do it using node--node-type.tpl.php using dsm get field value and set value against it

```
if (your_field_name = your_condition){
print '404 page';   //or to redirect on specific node page
}else{
print render($page['content']);
}

```
> 0 votes

# Answer
You could use Panels for this. It might be overkill to install it for just this purpose but if you have it installed I think it's a nice visual way of doing it instead of a code snippet.

Install Panels and create a node view variant under admin/structure/pages/edit/node\_view.

Set the type to be HTTP response code. Check selection rules to be used.

Select which response code you which to give.

Configure the selection rules to be triggered according to your rules.
> 0 votes

---
Tags: 7
---


title: How to convert date format on view?

text:
# Question
Title: How to convert date format on view?
I have created a View. Its display format is grid.One of field is Time.

It is displayed as "Time: 1300". I need to get it printed as "Time: 1:00 pm". I am using Room Reservations module and in my reservations tab time is displayed.

Can it be done with GUI or code needs any modification?

# Answer
> 2 votes
To convert date format in Views, you have to go the settings field which you are added to view. In settings, there is a `Date Format` select list field. You can choose the default time format provided or you can make your custom date format by selecting the `Custom` from select list. A new textfield will appear "Custom Date Format". In this field, you can make your own custom date format using the link `PHP Manual` link provide in the description of this field.

# Answer
> 1 votes
I believe the date field is used to create the Time field you mentioned.

You need to create new Date format in **yourdomain/admin/config/regional/date-time/formats**, refer the PHP date manual, in your case it will be (g a).

Followed by create the date type in **yourdomain/admin/config/regional/date-time** and choose the format you created. Then open your views and edit the Time field and choose the Date format what you created earlier as follows,

# Answer
> 0 votes
You might want to check your global time settings:

admin/config/regional/settings

Otherwise you can check the settings of your field of your contenttype:

admin/structure/types/manage/your\_contenttype/fields

# Answer
> 0 votes
You may want to check if using the Views Date Format SQL module could be a solution for you. Here are some quotes about it (from its project page):

> ... allows to format date fields using SQL.
>
> The core functionality is to remove the date formatting from render() and put it in query(). I.e. format date values using SQL's DATE\_FORMAT rather than PHP's format\_date. This is achieved by assigning a new default handler to node 'created' and 'changed' date fields. This handler extends and overrides views's build in views\_handler\_field\_date.
>
> The UI is completely unobtrusive, only a single checkbox "Use SQL to format dates" is added to the handler configuration popup.

Your question is not about creating charts in Drupal, but you may want to refer to this comment also for an example of how we typically use it within the Charts module.

---
Tags: views, datetime
---


title: Multilingual search problem

text:
# Question
Title: Multilingual search problem
I have a site which is setup with 2 languages. Primary language is English. If I do a search in English then I can find all content and get search results. When searching in the second language I only get results if the search term is present in content in both languages.

So if Node23 has the word "plant" in both English and the translation in the 2nd language too then I will have a search result in the 2nd language. Result shown is in the 2nd language.

If node23 contains the word "plant" only in the 2nd language then I get no results. What can I do to fix this issue? Looks like indexing only takes place on the primary language and when found it is displayed in the second language.

I tried built in search, Display suite search and Search configuration module. Very strange behavior if you can build a multilingual site but can not search.

# Answer
*I do not as yet have significant experience with internationalisation in drupal.*

Having said that, if you would like greater control over your search indexes I would definitely look at using search api instead of the default drupal search.

As well as allowing you to pick which fields are indexed, it also abstracts your search index so that you can take advantage of Apache solr etc. In your case, at least to start, I would suggest you stick to the simple database backend for search api.

The more flexible approach of search api brings additional functionality via other modules. For your use case I would look at Search API Entity Translation, which

> generates separate search index items for all/selected available languages for each translatable entity

It looks like this relies on entity translation rather than internationalisation, so make sure you survey any potential implications for translation of your content first.
> 1 votes

# Answer
You could overwrite the search functionality by adding a view for your search results, and add a filter to be the Current User's Language (site language).

If you decide doing this, you might also need to override the search box, for which you can expose form block (set it to YES). By doing this, the search box will be available as a block, so you can place it in any region of your page (or even embed it in your code if needed).

Your view might look like this one:
> 1 votes

# Answer
This is how I approach it.

Create a hook\_node\_update\_index() in your custom module with the following code.

```
/**
 * Implements hook_node_update_index().
 *
 * @see _node_index_node() function in modules/node/node.module
 */
function hook_node_update_index($node) {
  global $language;
  $languages = language_list();
  unset($languages[$language->language]);

  $text = '';
  foreach (array_keys($languages) as $langcode) {
    $build = node_view($node, 'search_index', $langcode);
    unset($build['#theme']);
    $node->rendered = drupal_render($build);

    $text.= '<h1>' . check_plain($node->title) . '</h1>' . $node->rendered;
  }

  return $text;
}

```
> 0 votes

---
Tags: search, i18n-l10n
---


# Question
Title: How to integrate Datatables in my Bootstrap theme (to make it match the look and feel of my site)?
I am developing an intranet portal using a custom made bootstrap 3 theme.

One of the views I created is a phonebook with 4 columns: Name, Department, Telephone, Email.

When I use table as the view format, I get a really nice bootstrap table, as shown here:

But when I use the views style ***Datatables*** (provided via the DataTables module I have installed), I get a table which is fully functional (i.e. paging, search, sorting, etc works perfectly). But the css is not bootstrap, as shown here:

Any suggestions?

# Answer
Have a look at what is described in http://www.datatables.net/manual/styling/bootstrap . Here is a quote from that link:

> Bootstrap is a CSS framework that lets you quickly and easily build a user interface that has a unified look and feel. The great news is that it is very easy to integrate Bootstrap and DataTables such that your fully featured DataTables will match the same look and feel of the rest of your site.
>
> Bootstrap provides a number of options for styling HTML tables, giving you flexibility over the table, while ensuring they look very slick. The DataTables / Bootstrap integration ensures that you can use all of these features as well as the enhancements that DataTables makes to a plain HTML table.
>
> **Installation**:
>
> To have DataTables styled by Bootstrap, all you need do, as well as including the DataTables core Javascript file on your page, is include the DataTables / Bootstrap CSS and Javascript integration files. These files simply alter the DataTables defaults, such as class names to use the names used by Bootstrap, and add styling information specific to DataTables.
>
> Both files are both available on the DataTables CDN (below) or you can obtain these files directly from the DataTables integration plug-ins repository on GitHub.

Head over to that link above for more details ...

**Bonus tip**: there is also an interesting blogpost about this topic ...

PS: I consider Datatables (the module + the library) as one of those hidden Drupal gems, so easy to install/enable, such a great set of features it adds (paging, searching, sorting as you also mentioned). Can't think of a site where we don't use it ... Checkout the questions tagged with for more interesting questions (+ answers) about it.
> 1 votes

---
Tags: views, theming
---


# Question
Title: Can I clone a view but keep it independent of it's content?
I'm looking to duplicate(clone) of a view, so that I may reuse it on other pages and have it will not pull through the same content.

I'm using Views 7.x-3.8 on Drupal 7.34 this will be updated later when the site goes live.

# Answer
> 0 votes
Yes it is possible to duplicate a `views` as much as you need and edit them independently. It saves a lot of work and time.

---
Tags: views
---


# Question
Title: How can I access an external table in a MySQL database?
I have a database (MySQL) with information about food.

It has several columns, for example:

```
-----------------------------------------
| product name | calories | fat | unit  |
-----------------------------------------
| bread        | 100      | 10  | grams |
| potatoes     |  50      | 20  | grams |
-----------------------------------------

```

Is there anyway way to import this dataset into Drupal and work with it in a field type, perhaps with taxonomy? Or should I program my own module?

# Answer
> 1 votes
Here is a module that will help you: http://drupal.org/project/data

\[ edit re MPD suggestion below ...\]

This module will help by providing an automatic Views integration for your data, meaning that you can show the data via Views.

It also includes an API which simplifies custom programming to get access to your data (perhaps for use in preprocess functions, which would permit the data to be themed on a node page, etc.)

Regarding your desire to include taxonomy, one way to do that would be to fold the data onto a node and then attach taxonomy to that node, however, that might depend on how you're mapping your data onto individual nodes.

# Answer
> 0 votes
Module Forena can be used to query (not update) any MySQL database table.

For more details about Forena, 2 types of documentation are available:

* Community documentation.
* Documentation that comes with Forena, which you can access right after install and enable of the module. Checkout the demo site for an online example of the current:

+ **Forena documentation** \- use the link 'Reporting documentation' or visit relative link /reports/help.
    + **Forena samples** \- use the link 'Reporting samples' or visit relative link /reports/samples (these samples are fully functional, so make sure to experiment a bit with it, such as the drill downs available on the SVG Graph sample).

Disclosure: I'm a **co**-maintainer of this module,
I hope this does not violate the site's policy on self-promotion.

---
Tags: 7, taxonomy-terms, importing-exporting, database
---