texts: form_state[triggering_element] not being set on button click

texts:
I have been experiencing a problem for the past two days that I can't find an answer too. I have two buttons in a form that use an ajax callback (an example is shown below).

$date_selector_container = FALSE;

// Check to see if the user clicked one of the navigation buttons.
// If so, then change the date forward or backward by a week.
if (isset($date_selector['#value']['display_date'])) {
  dd($form_state, 'form_state');
  dd($form_state['triggering_element']['#date_selector_direction'], 'triggering element');
  if (isset($form_state['triggering_element']) &&
    isset($form_state['triggering_element']['#date_selector_direction'])) {
    if ($form_state['triggering_element']['#date_selector_direction'] == 'prev') {
      dd("User pushed prev button");
      $display_date = $date_selector['#value']['display_date'] - 604800;
    } else if ($form_state['triggering_element']['#date_selector_direction'] == 'next') {
      dd("User pushed next button");
      $display_date = $date_selector['#value']['display_date'] + 604800;
    }
    $date_selector_container = TRUE;

  }
  dd("new display date = ".$display_date);
  unset($date_selector['#value']['display_date']);
}

// A whole bunch of date calculations happen here...

$prev_button = array(
  '#type' => 'button',
  '#value' => '<<<',
  '#id' => $id . '-prev',
  '#name' => $date_selector['#name'] . '[prev]',
  '#date_selector_direction' => 'prev',
  '#ajax' => array(
    'callback' => 'my_date_picker_ajax',
    'wrapper' => $id . '-date-selector-wrapper',
    'progress' => array(
      'message' => NULL,
      'type' => 'throbber',
    ),
  ),
);

$next_button = array(
  '#type' => 'button',
  '#value' => '>>>',
  '#id' => $id . '-next',
  '#name' => $date_selector['#name'] . '[next]',
  '#date_selector_direction' => 'next',
  '#ajax' => array(
    'callback' => 'my_date_picker_ajax',
    'wrapper' => $id . '-date-selector-wrapper',
    'progress' => array(
      'message' => NULL,
      'type' => 'throbber',
    ),
  ),
);

$date_selector['#rows'] = $rows;
$date_selector['#header'] = $header;
$date_selector['#tree'] = TRUE;
$date_selector['#prefix'] = (isset($date_selector['#prefix']) ? $date_selector['#prefix'] : '') . '
';
$date_selector['#suffix'] = '
' . (isset($date_selector['#suffix']) ? $date_selector['#suffix'] : '');
$date_selector['#display_date'] = $display_date;
$date_selector['next'] = $next_button;
$date_selector['prev'] = $prev_button;
$date_selector['#hidden_values'] = $hidden_values;
if ($date_selector_container) {
  $form_state['ajax_date_selector_container'] = $date_selector;
}
return $date_selector;

Each button is uniquely labelled but follow the same pattern.

The issue I am having is that when either button is clicked $form_state[triggering_element] is not being set. I can tell from debugging statements that the callback is happening but when I query $form_state there is no triggering_element key. I have reviewed the API, checked the code and Googled for answers but can't find anything wrong. Can anyone possibly tell me what the issue might be. I am going crazy here.

Update:

After digging around some more I looked at the $_POST statement and see the field [_triggering_element_name] being set to the button but for some reason never gets put into $form_state. I also see the submit handler is also called but this time $form_state[triggering_element] is set but has a different button's id in that field (ie a button that wasn't clicked). Perhaps that sheds some light on the issue.

Thanks.


texts: REQUEST_TIME is in GMT eventhough site timezone is IST

texts:
In admin/config/regional/settings I can see that IST timezone is set.

But when I print REQUEST_TIME constant I see GMT one.

How to get the IST time in REQUEST_TIME ?


texts: FullCalendar: how to remove entries from 'Select Language' dropdown list?

texts:
I use Fullcalendar View to display some nodes:

I'd like to restrict the content of 'Select Language' dropdown list to specific entries (let's say English, French and Finnish).

I couldn't find how to do that.
Is it in the module code, in the library?
Any help?


texts:
I just install Drupal Console, then adding it to my pre-installed Drupal 8 with this into the drupal folder:

 php  ~/bin/composer.phar require drupal/console:~1.0 --prefer-dist --optimize-autoloader

as noticed.But I don't have all commands, like generate...seem console "module" is missing despite everything .

What can I do to fix this ?

thanks

EDIT: no console folder in core/lib/Drupal/Core as it seem to be done.
EDIT2:

export GEM_PATH=/home/xxx/.gem/
export GEM_HOME=$GEM_PATH
export COMPOSER_PATH=/home/xxx/bin/composer/composer.phar
export COMPOSER_HOME=$COMPOSER_PATH

#export PATH=/home/xxx/.gem/bin:/home/xxx/drush:$PATH
export PATH=/home/xxx/.gem/bin:$PATH

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.composer/vendor/bin:$PATH"

alias drush='$HOME/bin/composer/composer.phar/vendor/drush/drush/drush'


texts: DBupdate schema update can't rename table because it already exists -

texts:
I recently updated a couple of modules and core:
To Drupal 8.8.6
Modules updated: metatag, Search API, Feeds, External Links and EntityQueue.

There was a small hiccup that broke the site, so I re-pulled files into our development environment and tried again. Everything seems to run smoothly until doing the Database update at update.php. There are 6 pending updates that cannot be done because of an error thrown:

Failed: Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. Cannot rename tmp_431b95entity_subqueue_field_data to entity_subqueue_field_data: table entity_subqueue_field_data already exists. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1615 of /var/lib/nginx/website/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Not sure which update caused the issue, though probably EntityQueue. Caches cleared and tried again with no luck.

What are the steps to overcoming this? And is there a way to update the other five database changes, so I can get everything but the one issue resolved?

If it helps, the outstanding edits that are outstanding and not getting applied:

entityqueue module
    •   8004 - Add the publishing status field to subqueues.
    •   8005 - Add the revision metadata fields to subqueues.
    •   Update subqueues to be revisionable and translatable.
    •   Remove the obsolete 'reverse_in_admin' queue setting.
metatag module
    •   8108 - Need to clear caches after updating from 8.x-1.12.
extlink module
    •   Forces a cache rebuild in order to add new `extlink.setting_save.subscriber`.
feeds module
    •   Replace deprecated action ID's for 'update_non_existent' setting.
search_api module
    •   Re-save Search API index configurations to fix dependencies.


texts: How to remove stylesheets only for anonymous users?

texts:
I am trying to remove all unnecessary/unused stylesheets for anonymous visitors to get better performance and a clean <head> section. This works fine by listing them inside mytheme.info.yml:
stylesheets-remove:
  - path/to/stylesheet.css
  - path/to/another/stylesheet.css
  - core/modules/system/css/components/hidden.module.css

However, the third entry in this example breaks the styling of the toolbar - which is only visible to the admin. Is it possible to programatically tell Drupal which stylesheets to remove only for anonymous visitors? I appreciate your help!


texts:
I have this condition in access callback:

$args = drupal_get_query_parameters();
  return (user_is_anonymous() &&
    !empty($args['idp']) &&
    !empty($args['applicationId']) &&
    !empty($args['language_preference']) &&
    !empty($args['token_url']));

however, when accesing the domain accessing

domain.com/ajax/pathxxx?idp=XXX&applicationId=YYY... it works, but when using www.domain.com/ajax/pathxxx?idp=XXX&applicationId=YYY... (note www prefix), I'm getting access denied in the Drupal log.

Is there any way to debug this?

EDIT: The log says "Anonymous user"


texts:
I'm having trouble finding a solution for combining location & weight-based shipping with drupal commerce.

I need to have three shipping zones (DK, EU, ROW) with individually priced weight steps inside each zone (0-500g, 500-1000g, 1000-2000g, 2000-5000g).

I've gone through a bunch of tutorials and looked at other forums where people have similar requests. But haven't found a solution yet - which should be possible for such a 'simple' problem, right?

To sum up I need advice on how to configure the following shipping calculation rules:

Free Shipping (no weight)
DK Shipping (1-500g)
DK Shipping (501-1000g)
DK Shipping (1001-2000g)
DK Shipping (2000-5000g)
EU Shipping (1-500g)
EU Shipping (501-1000g)
EU Shipping (1001-2000g)
EU Shipping (2000-5000g)
ROW Shipping (1-500g)
ROW Shipping (501-1000g)
ROW Shipping (1001-2000g)
ROW Shipping (2000-5000g)

I can't figure out how to check for a line item's weight in a rule?

I've got Shipping, Flat Rate, Physical Product, Physical Fields and Rules Extra enabled.


texts:
I don't understand why the ajax validation functionality was suddenly deactivated on my WebForm. Perhaps is it possible to activate it again?

After fresh webform install all required fields were marked "required" with ajax functionality, if I tried to send unfilled form.

Do you have an idea?


texts: Newly (programmatically created) blocked user gets access denied when resetting

texts:
I'm trying to import some users into Drupal programmatically as blocked. I found two methods to do this: user_save and drupal_execute. However, the first one doesn't send notification email with the link to reset the password while the other method does send the mail, but when clicking the link I get a denied access.

I tried the code in 2 environments (Ubuntu and Windows) with one fresh installation. Here is the code I'm actually using:

// register a new user
$form_state['values']['name'] = 'username';
$form_state['values']['mail'] = 'mail@example.com';

// generate and assign password
$pass = user_password(8);
$form_state['values']['pass'] = array (
    'pass1' => $pass,
    'pass2' => $pass
);
$form_state['values']['status'] = 0; // add user as blocked
$form_state['values']['notify'] = 1; // send notification with reset link
$form_state['values']['op'] = t('Create new account');

// check if user it's not already imported
$sql = "SELECT uid FROM {users} WHERE name = '%s'";
$result = db_query($sql, $form_state['values']['name'] );
$data = db_result($result);
#print_r($data);
if (!$data) {  // if the user does not exist, add it
    drupal_execute('user_register', $form_state);
}

The user is added correctly in the database as blocked, I receive the notification email but when I click on the reset link I get access denied (which, by the way, it's appearing twice: all the elements of my theme twice with the error as content; really nasty bug... don't know why, anyone?)

Here goes the second code:

// user details
$users = array(
    'name' => 'username',
    'pass' => user_password(8),
    'mail' => 'mail@example.com',
    'access' => '0',
    'status' => 0,
    'notify' => 1,
    'timezone' => 7200,
    'init' => 'mail@example.com'
);

$sql = "SELECT uid FROM {users} WHERE name = '%s'";
$result = db_query( $sql, $users['name'] );
$data = db_result( $result );
#print_r($data);
if (!$data)
    user_save( NULL, $users, NULL );
}

With this method, everything works fine but I don't get the email, which is pointless because the users are blocked.

I don't know if this is a hard question (only for Drupal gurus), but I would appreciate any help.

Thank you!


texts: Get a particular module's information programmatically

texts:
Is there any function to retrieve all the hook used by a particular
module and also
A function to return all menu links (along with its description) created by
    a particular module

  I looked into module_hook and module_implements but both
  were used to find whether a particular hook is used in a module. But
  what I need is vice versa.

I need it because configuration options for a particular module can be easily found by getting menu links in a page as a overview.


texts:
I have added a custom field (taxonomy reference) to my users.  Now I want to run a rule based on the values in that field, but the field does not show up in the available items on the "data selection".

Any ideas on why the field does not show up in rules or how to make it show up in rules is greatly appreciated.

field configuration:

langcode: en
status: true
dependencies:
  config:
    - field.storage.user.field_workbench_access_groups
    - taxonomy.vocabulary.intranet_units_committees_and_gr
  module:
    - user
id: user.user.field_workbench_access_groups
field_name: field_workbench_access_groups
entity_type: user
bundle: user
label: 'User's Workbench Access Groups'
description: ''
required: false
translatable: false
default_value: {  }
default_value_callback: ''
settings:
  handler: 'default:taxonomy_term'
  handler_settings:
    target_bundles:
      intranet_units_committees_and_gr: intranet_units_committees_and_gr
    sort:
      field: name
      direction: asc
    auto_create: false
    auto_create_bundle: ''
field_type: entity_reference

Reaction Rule:

langcode: en
status: true
dependencies: {  }
id: sync_existing_user_workbench_access
label: 'Sync Existing User --> Workbench Access'
events:
  -
    event_name: 'rules_entity_update:user'
description: ''
tags: {  }
config_version: '3'
expression:
  id: rules_rule
  conditions:
    id: rules_and
    conditions:
      -
        id: rules_condition
        context_values:
          type: user
        context_mapping:
          entity: user
        context_processors:
          type:
            rules_tokens: {  }
        provides_mapping: {  }
        condition_id: rules_entity_is_of_type
        negate: false
      -
        id: rules_condition
        context_values:
          field: field_workbench_access_groups
        context_mapping:
          entity: user
        context_processors:
          field:
            rules_tokens: {  }
        provides_mapping: {  }
        condition_id: rules_entity_has_field
        negate: false
  actions:
    id: rules_action_set
    actions: {  }


texts: How to alter tabs that have wildcard in bartik main menu

texts: The problem is that I have some menu items with wildcard that I wanna add in main menu tabs, but can't realize how to do it. It can't be solved by hook_menu as I undestood. Tried use preprocess_links__system_main_menu, menu_tree__main_menu but they didn't execute. How correctly do this?


texts: What is the difference between hook_field_attach_validate() and hook_field_validate()?

texts:
I'm a bit confused as for the difference between these two hooks,  and which one I should use for custom  validation of attached fields in my code.

Is there a better way to define a custom validation for an attached field (I am attaching the field programatically if that helps)?

EDIT: Looking more into it, I don't really get all that much information in hook_field_attach_validate(). All I'm pretty much getting is the entity_type, entity object and an errors array.

Whereas with hook_field_validate(), I get the field I'm actually validating against, which, I'm assuming is where I need to put the bulk of my custom field validation logic. The only issue I'm having now is that I'm unable to find a function that will invoke this method for me. Should I manually invoke this function or is there an API function I can use in this instance?


texts: Add non mandatory fields to user registration form

texts:
I can add custom fields to the user registration form, if I add the fields to the user profile: admin/config/people/accounts/fields

There is a checkbox "Show on user registraion" which is inactive:

The checkbox only gets active if I check "Mandatory field", but some of the fields must not be mandatory. Is that a bug? Is there a workaround (without using module 'Profil2') ?

I'm using Drupal Core 7.28


texts:
I need to produce PDF/HTML output from my Drupal 6 app; is there a "Drupal way" to create a template with variables and then substitute them when the output is rendered or do i have to realize it by hand?

EDITED

Data is not on a node, but need to select from a non-drupal table


texts: WSOD and Drush cc all fail after deleting a view of a long-time-ago deleted module

texts:
Background

Drupal 7.40 site, all is up2date, the site itself worked, until the last hour, just fine.

The problem

I once had a module named Flexslider and have deleted it 5 months ago. One of it's views and/or content types stayed alive and I've deleted it in the last hour; Since then there is a WSOD in my site and each time I try to flush all caches with Drush I get the following error about the impossibility to access a Flexslider file.

Any ideas why would that happen?

Image update for user - Les Lim:


texts: How a block already created (with Views) I could insert into my template (mytemplate.html.twig)?


texts: Outputting front page to a different url

texts:
I currently have this site tobyNews that is up and running with Drupal 7. However,
while in the process of giving the site a mobile version, I thought maybe it would be easier if the front page content that is displayed when you first visit the site was simply output to another page, like m.tobynews.com . Is there any way to sort of add another output without altering the main page?


texts:
Case:

- Aegir server 2.1 on Drupal 6.31
-- Platform Hostmaster: Drupal 6.31
--- Hostmaster: ?
-- Platform 1: Drupal 7.31
--- Site 1: HACKED
--- Site 2: HACKED
-- Platform 2: Drupal 7.32
--- Site 3: ?
--- Site 4: ?

Actions:

So the attackers get access on site 1 + site 2 using the SA-CORE-2014-005.
Platforms 1 and sites 1 and site 2 totally deleted or restored from an old backup and then updated (files and db).

Questions:

Is there a case that the hackers gain access on Hostmaster or on sites 3 and site 4?
Or even worst… the hackers gain that level of access on the server that can compromise a new Aegir install?


texts:
I hate making posts like this because I feel like I am asking people to do all my work for  me! However, in times like this, when I am pressed for time, I have to. So...

I am trying to add an user profile in the topics in the Forum module. I have found a brilliant tutorial, but unfortunately it is for Drupal 6 and some of the functions are not compatible with Drupal 7; I couldn't find the equivalent functions, and I figured some of you may know them.

If you do, I would greatly appreciate it if you could share them with me; even if you don't provide the whole of the functions in tutorial (which would be nice), and just provide me with the Drupal 7 functions to replace the ones in the tutorial; anything would help.

The main functions that do not work are the profile_load_profile($user), and the get_user_####($user) functions.

By the way, I am assuming it is because those functions are depreciated in Drupal 7 when it says "Undefined"! I can't see any other reason for it not to work, and I kind of expected some of the tutorials wouldn't work properly on Drupal 6.


texts: Tablefield output in No Results behaviour

texts:
I have achieved to display the raw value of this tablefield in views - Global no results but not in the table format.

I have this in PHP-format in the Global - No results behaviour in views.

$view = views_get_current_view();
$node = node_load( $view->args[0] );
$table = $node->field_modal_parameters_tabel[und][0]['value'];
print $table;

This gives me this.

a:34:{s:8:"cell_0_0";s:1:"N";s:8:"cell_0_1";s:21:"nat. freq. meas. [Hz]";s:8:"cell_0_2";s:22:"&xij";s:8:"cell_0_3";s:1:"N";s:8:"cell_0_4";s:21:"nat. freq. calc. [Hz]";s:8:"cell_0_5";s:17:"damping calc. [%]";s:8:"cell_0_6";s:7:"MAC [-]";s:8:"cell_0_7"; ...

How can I display the table format?


texts: what is the default file template in drupal when you set your own theme?

texts:
What is the default template in drupal when you set your own template and you don't have page.tpl.php
??
where does the html beeing rendered from?


texts: How to integrate some fields into a node more efficient?

texts:
in my node.tpl.php i want to display a custom field (field_cta) which is part of my page.
It is working this way, but it looks so terrible...is there a drupal command to shorten all the array-walk-trough precedure?

if (isset($content['body']['#object']->field_cta['und'][0]['value'])){ print $content['body']['#object']->field_cta['und'][0]['value'];}

Thanks a lot!


texts: How to invite Facebook, twitter, gmail friends into organic groups

texts:
How can i invite Facebook, twitter,Gmail friends in to my Organic Groups in Drupal 6.
Is there any possibility about this. Let me know.
Thanks,
Thiru


texts: How to implement quotation replies on Commerce orders by multiple users?

texts:
Commerce order will have 0 price when being placed, Once the order is placed all the users of specific role will get notification(this is working) and should be able to reply to that order(I am making a custom module and view for this) with their own price for that order. There will be multiple fields data to reply like price, qty, destination, etc.

I don't want to create a new order or order revision.I want to be able to somehow add all quotation data to that order for each user.I have seen some quotation like modules but they do not do what I need.

My question is where to save all those fields and data?How to relate it with that order?

How do I achieve that?


texts:
There is a way to see if the Drupal tests are working? I wanted to test the FileSystemTest, but when I type phpunit command on the test folder this error appears:

1) Drupal\Tests\Core\File\FileSystemTest::testChmodFile
Argument 1 passed to Drupal\Core\File\FileSystem::__construct() must be an instance of Drupal\Core\File\StreamWrapperManagerInterface, instance of Mock_StreamWrapperManagerInterface_428d696c given, called in /var/www/html/drupal-8.0.5/core/lib/tests/FileSystemTest.php on line 43 and defined

/var/www/html/drupal-8.0.5/core/lib/Drupal/Core/File/FileSystem.php:62
/var/www/html/drupal-8.0.5/core/lib/tests/FileSystemTest.php:43
/home/bianca/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:153
/home/bianca/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:105

Someone know how to make the test work with phpunit?


texts: How to allow user registration based on roles?

texts:
I have two roles on my site:

Visitor, the normal user who can register on our site without any admin approval procedure
Business role, the business user who can register and add their business to our site, with admin approval.

Can anyone suggest how I can allow registration based on role, so that one requires approval, and the other doesn't?

Also there are two different registration links for users whether they want to register as normal or business user; based on which link the user click, the registration process will take place.


texts: How to detect same user when they submit two webforms?

texts:
User A submit a newsletter form and come to thank you page. At the thank you page there is another general comment form.

Here is my question: How to detect both of them are belong to User A?

Reason: So that I can extract both information together from database.


texts: Is It Possible To Show One More Views In Homepage

texts: I have created some Views to show in Home page. I have successfully installed one View in my homepage but i really can't understand is it possible to show one more Views in Homepage. If it possible then please take a time to describe it.. Thanks


texts: Can I extend the image field formatter without defining a custom one?

texts:
XY problem: I need to extend the default image widget in the entity edit form with some custom fields so that, per image, e.g. a copyright and description, independently from the alt and title field, can be set.

I can add the fields by altering the core image module files, and by manually adding the respective database columns. But of course, I would like to alter the plugins with a custom module.

I was able to create a custom formatter based on the ImageWidget as described in this tutorial.

My question is: is there a way to alter the default image widget/ field type to add custom fields rather than defining custom formatters/ widgets?


texts:
On the node display I would like to create a list of services but for some of the services, I would like the list element to be displayed as a link to a certain node, and some will not have links.

I tried creating a vocabulary called Services with an additional Link field, but with no luck.

Ideally it would be good to reference the NID, incase the path changes in the future, and display the link URL without the NID as its final path. But if there is a simpler way using final paths, then I am happy with this.

Below is the desired outcome.

Services:
- Website Design <--Linked to node/2
- SEO <-- no link
- Hosting <-- linked to node/4


texts: How to list duplicate nodes, with views, based on compared fields with links

texts:
I'm trying to create a list with duplicate nodes, so i can delete those.
I'm not coder and I have already tried the module "remove duplicates" without success, so i have to use views with vbo module.

The field i have to compare nodes, contains a link.
If the same link is in more than one node, i need it to be listed.

I have turned aggreation on.
I have one field, displaying a link.
I have created a filter, pointing at the above field with link,  with "count" and set it to "show only greater than 1" acording to other similar questions on how to list duplicate  titles.

Unfortunately this does nothing for me. As soon as i turn on the filter, there is no output.

Can you tell me what I'm missing here ?
Sorry for the poor english.


texts:
I have the following code that is throwing an error:

/**
 * Custom content function
 *
 * Get system status from the helpdesk database
 *
 * @return
 *   An key => value pairing of systems and their status
 */
function system_status_sjhc_status_check() {
    //connection info for the helpdesk database
    $helpdeskDB = array(
            'database' => 'mydb',
            'username' => 'myuser',
            'password' => 'mypass',
            'host' => 'myhost',
            'driver' => 'mysql',
    );
    Database::addConnectionInfo('helpdeskDB', 'default', $helpdeskDB);
    db_set_active('helpdeskDB');

    //grab the current light status
    $result = db_select('hd_lights', 'l')
        ->fields('l')
        ->leftJoin('hd_status', 's', 'l.id = s.id')
        ->fields('s', array('stamp', 'message'))
        ->orderBy('`order`', 'ASC')
        ->execute();

    db_set_active(); // without the paramater means set back to the default for the site

    return $result;
}

The error I'm receiving is:

  Fatal error: Call to a member function fields() on a non-object

and its being thrown on this line:

    ->fields('s', array('stamp', 'message'))

I can't figure out what I've done wrong, everything looks OK to me and the code runs fine without the join and additional table fields.

Any thoughts?


texts: Calendar Module Styling of upcoming events

texts: I'm trying to remove the left margin/padding on the event items that show in Upcoming Events when you use the Calendar module(see attached pic). Could anyone advise what element it is that I need to change the CSS on, to remove the left margin or padding? I want the items under the heading to appear flush (left aligning) with the heading. I am also using Omega 3 so I'm not sure if thats relevant.


texts: Unable to debug drush command using xdebug with batch api

texts:
I have been debugging drush commands with xdebug and my IDE (currently PHPStorm 7) for a while, but I have been noticing that there are certain commands that die whenever I have the dubegger enabled in the IDE. From what I can tell, it's commands that do batch processing and therefore call drush_backend_batch_process(). In tracking it down as far as it will let me with the debugger, it looks like it dies in _drush_backend_proc_open().

An off the shelf example is the solr-index command in the apachesolr module. I can debug up to the point where drush_backend_batch_process() is called, but it never returns from that call.

Is this a known issue with xdebug on the command line with drush with no way around it? Or is there something I can do in my configuration?

Thanks.


texts: How to print render each term in a vocabulary?

texts:
I kinda feel ashamed to ask this but I really did not find any answer on this...

How can I print each term in a given display mode, for instance 'teaser', anywhere I have loaded a vocabulary's terms?

<?php
    $vid = taxonomy_vocabulary_machine_name_load('finder_items');
    $tax = taxonomy_get_tree($vid->vid, 0);

    $tids = array();

    foreach ($tax as $key => $value) {
        $tids[] = $tax[$key]->tid;
    }

    // ?? causes exception
    $tvm = taxonomy_term_view_multiple($tids, 'full', 0, 'de');

    print $terms;

?>

I want to fully render them, with all their fields.


texts: How to append classes for dynamic terms in jquery?

texts:
I have installed a rating module, there I want to change the style. for that what I need is
there is a css class called

$('.rate-widget-fivestar)

there are totally 3 widgets. the value of five star increses to 1,2,3 for three widgets respectively.

I want to add a class for each widget.
(ie)

if($('.rate-widget-1))
 {  //class 1
 }
 if($('.rate-widget-2))
 {  //class 2
 }
 if($('.rate-widget-3))
 {  //class 3
 }

how can i acheive that in jquery??


texts: How to hide few default fields for specific user

texts:
I want to hide fields such as password, email when a particular user tries to edit few fields of other users.

How can I achieve this?


texts:
I have 2 languages in my site and a search view for property search
and I am using the Search API module.

When I try to search in English (default language), the search is working.
But when I try to search in the another language the search is not working.

I am searching by tittle.

Any suggestions?


texts: Previous/ next navigation in taxonomy terms

texts:
Due to some complex project, I would like to organize navigation between taxonomy terms programmatically, with generation of custom links.

Example of navigation I need in vocabulary "fruits" with following terms, situated in same order in taxonomy management admin module :

apple -> has next link to apricot
apricot -> has previous link to apple, has next link to banana
banana ->  has previous link to apricot, has next link to cherry
cherry ->  has previous link to banana

The question, is : what is the most convenient method to get the id of previous and next term, in the same order as they organized in vocabulary ?

It's seems what in current taxonomy API of Drupal 7 there is no specific functions to do it in simple way.


texts: How do I override the content region for a specific page?

texts:
I want to override the content region for a specific page, but using the hook page--mypage--region--content.tpl.php won't work. How should I name it?

My site supports block override, I tested this with a dummy region.tpl.php and I currently use a custom page.tpl.php.


texts: How to place an Ubercart order on behalf of another user?

texts:
I would like to ask if it is possible to assign another UID, different from that of the currently logged in user, to an order under checkout process (e.g. via rules)?

Any idea how to do that? Thanks.


texts: How can I sort the order of status messages?

texts:
I add my own validations to forms, for example the user registration. The errors I set with form_set_error are added below the drupal generated errors.
I would like to show them in the same order of my form fields on the page.

I thought I can use theme_status_messages($variables). When I do a dpm($variables) on a from with status messages it just shows an empty array.


texts: open pop up window on map marker from outside map canvas after click an anchor tag in drupal 7 using gmap, location

texts:
I have installed location module, gmap module and views

created nodes of article type say 5 node with their location filled in.
created a views selecting gmap as display.
my nodes are listed on maps perfectly with their markers & also pops up right content.
now I created attachment with the view to show my nodes titles after the view as unformated list.
my nodes are listed well on the map as well as in ul li format beneath the map
i want that when i hover on any title outside of a map it should pops up the related node in the map .

If it is clear to you then please help if not then leave a comment


texts:
How do we stop the heartbeat module from recording node update activity for certain specific content types we have created?

We created a content type that collects voting information. When a user votes, a new node is created or an existing node is updated for this content type.

The heartbeat module seems to be recording this event and creating a new activity. In Drupal Commons this activity is displayed in a block called the "Recent Activity" block. We would like to avoid having this update to our "voting" content type from being recorded as an activity, and being shown in the "recent activity" block.

How would we do this?


texts: How to do dependency injection on complex classes like when extending WidgetBase

texts:
Since the Drupal sniffer whines at you if you call \Drupal::service() in your code, I have been trying to figure out how to use dependency injection on a widget  I’ve been working on. Here’s what I’ve currently arrived at:

<?php

use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\xois\SicsService;
use Symfony\Component\DependencyInjection\ContainerInterface;

class XoisSicSelect extends WidgetBase {

  /**
  * SICs service.
  *
  * @var \Drupal\xois\SicsService
  */
  protected $sicsService;

  /**
  * {@inheritdoc}
  */
  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, SicsService $sicsService) {
    parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
    $this->sicsService = $sicsService;
  }

  /**
  * {@inheritdoc}
  */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('xois.sics')
    );
  }

}

Pretty much the standard DI pattern, no? Only difference is that WidgetBase takes a whole load of construct parameters already.
Problem is, it doesn’t work. When run, it gives this delightful error:

The website encountered an unexpected error. Please try again later.
Recoverable fatal error: Argument 6 passed to Drupal\xois\Plugin\Field\FieldWidget\XoisSicSelect::__construct() must be an instance of Drupal\xois\SicsService, none given, called in /var/www/docroot/core/lib/Drupal/Core/Field/WidgetPluginManager.php on line 125 and defined in Drupal\xois\Plugin\Field\FieldWidget\XoisSicSelect->__construct() (line 35 of modules/xois/src/Plugin/Field/FieldWidget/XoisSicSelect.php).

Anyone got an idea on how to accomplish this?


texts: Features - Is there a way to push changes back into the database

texts:
I have a fairly good understanding of the way that features works:

Make changes to your test site.
Create a feature which contains the changes.
Copy the new module (which was created by features) to live.
activate the new module.
Verify that the changes now exist on the live site.

This works great, but is there a way to take the changes that are contained in the new feature module and move them into the live database?  My goal is to reduce the number of active modules I have on my live site.


texts:
Using views I would like to display the number of posts by a user. This will include a count of nodes as well as comments.

e.g.

Jon
Nodes: 10
Comments:6

Jane
Nodes: 22
Comments: 9

etc....

I have created a view of type user. I can find the user: content relationship and with aggregation turned on, I can get the node count. However I do not see a user: comment relationship o get the comments that the user has created. Am I missing something?


texts: Custom hardcoded functions : in node.tpl.php or theme_preprocess_node?

texts:
For a specific content type, I have many hardcoded functions, to format, display my content, use some ajax, JS, etc.

I was wondering, for performance, scalability and, more globally, best practice, if my functions should be all in node--mycontenttype.tpl.php or in mytheme_preprocess_node.

I actually began my coding with that last solution and I'm kind of worried about performance and other matters.

Do you have an advice ?

Thank you.


texts: How to print a CCK image field alt text in a node template?

texts:
I'm trying to add the alt text from a cck image field in a Drupal 7 node template.  Getting the image style url is done, but I can't figure out how to just get the alt text.  This is what I have

<img src="<?php print image_style_url('160x160', $node->field_image['und'][0]['uri']); ?>" alt="????" class="thumbnail" />

How does one just output the alt text?


texts: Concatenating user submission fields or components in webform Drupal 7

texts:
using Drupal 7 webform module. The module is set to email out results. The problem is that the form submissions are going via email into Zendesk, which ideally would be able to parse out first/last name from the sender.

The problem is that the email from name is set to use the component first name from the form.

The help text below the selector says "Any textfield, select, or hidden form element may be selected as the sender's name for e-mails." Is there a way to concatenate the first and last name fields from the form into the from name field?

the form was previously set (before I started working on it) with 'Value of First Name'  in the "cusstom" from field. That wasn't working. Would [submission: first_name] [submission: last_name] or a similar token work?


texts:
I am trying to use the garland theme on the blocks page rather than using my custom theme.

I have found this question:
Force block page to use admin theme?

Which has given me a code snippet to use. I have placed this in the modules/block/block.admin.inc file on line 36.

The theme is still my custom theme and i must be doing something wrong. If possible i would rather not use a module.

The code i am using:

function mytheme_init() {
  // Hardcode the administration theme onto the blocks page
  if ($_GET['q'] == 'admin/build/block') {
    global $custom_theme;
    $theme = 'garland';
  }
}

Thanks!


texts: How to get form variables data into twig templates?

texts:
I have a form like:

 public function buildForm(array $form, FormStateInterface $form_state, $short_title = '') {
$title = 'xyz';
}

In my .module file, I have a theme function:

function ip_mcq_theme() {
  return [
    'take_mcq_form' => [
      'render element' => 'form',
    ],
  ];
}

How to get form variables like $short_title and $title mentioned in form build function in my take-mcq-form.twig.html file?


texts: Can anyone give me an example of a seperator used in table style in views

texts:
I am not sure what seperator does. I basically want view of the
node:title, and the node body in the same column of a table. How can I acheive this?


texts: How do I enable users to have a browse button (by clicking on the image icon)so that they can upload a picture.

texts:
I added a user to my website and I gave him the permission to use blocks.
I activated wysiwyg and TinyMCE so that he can add also images.

But he has a problem, when he clicks on the icon to add an image then it opens a window where u can add the image url, image description,... but there is no browse button so that u can upload a picture.

thank in advance!


texts: Date Display: How to hide part of repeat rule?

texts:
When displaying recurring event dates for end users I would like to hide a part of the repeat rule (the until date has no meaning for end users):

Current display:

  Repeats every week every Thursday until Mon Dec 31 2012

Expected display:

  Repeats every week every Thursday

How to do this ?


texts: My submit function for the node form doesn't execute

texts:
I need to add my submit function to the node insert/edit form.

Here's my code.

function yrv_event_trainer_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
    if (in_array($form_id, ['node_veranstaltung_edit_form', 'node_veranstaltung_form'])){
        // Here we're adding our submit function before standard one.
        array_unshift($form['#submit'], 'yrv_event_trainer_submit');
    }
}

function yrv_event_trainer_submit(&$form, FormStateInterface $form_state){
// Here's code inside my submit function
}

But when I'm pressing the "Save and publish" button on the form, this submit function doesn't execute.

For example, I can't debug it having set a breakpoint inside the submit function.

But the array $form['#submit'] has my submit function.

Could you clarify me, what can be a reason of the problem ?


texts: What can make value in theme variables be empty by template render?

texts:
I have one site with a theme that has a page.vars.php where there are various assignments like $variables['content_column_class'] = 'classname' and by the time the page.tpl.php tries to print $content_column_class, there is no value.

This same theme is in another site without this issue. What can make the value in theme variables be empty by template render? Is there something in the database? I've run drush cc all, I've run the update.php, all with no change. What methods for debugging these type of issues can I take?


texts:
I have a node type with two field_collection fields. When I save the node I need to write the entity_id of the first field_collection into the secondo field_collection. This is my code:

function mymodule_node_update($node){
    $entity_id = $node->field_collection_1['und'][0]['value'];
    $entiry_array = entity_load('field_collection_item',array(entity_id));
    $entity = array_shift($entity_array);

    if (empty($entity->field_reference['und'][0]['value'])) {
        $entity->field_reference['und'][0]['value'] = $node->field_collection_2['und'][0]['value'];
        $entity->save();
    }
}

There are 2 problems there:
1) in hook_node_update() data is not committed yet https://drupal.org/node/1677830
2) $entity->save() triggers again hook_node_update() (and in my opinion it shouldn't)

So at the end in $node->field_collection_1 I have the right id $node->field_collection_2 would have, but due to recursive call to hook_node_update() and the fact that in hook_node_update() data is not committed to database yet field_collection_2 entity and all changes made to the node vanish.

Can someone suggest me a possible solution?

Thank you


texts: Setting exposed filter default value from query string

texts:
I have a view which show products and an exposed filter block (category, manufacturer, price).

I want to set category default value from URL, like this:

/browse-products/category-id

though, I wrote this module which take the parameter from URL and put it into exposed filter default value.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  global $request;

  if ($form_id == 'views_exposed_form') {
    $category_id = (int)($request->attributes->get('_raw_variables')->get('arg_0'));
    $form['category_id']['#default_value'][$category_id] = $category_id;
    dpm($form['category_id']);
  }
}

dpm output for /browse-products/5

Array
    (
        [#type] => checkboxes
        [#multiple] => 1
        [#options] => Array
            (
                [5] => Tablets
                [10] => -Ainovo
                [7] => -Galaxy Tab
                [6] => -IPad
                [1] => Smart Phones
                [4] => -Galaxy
                [3] => -IPhone
                [9] => --IPhone C
                [8] => --IPhone X
            )

        [#size] => 9
        [#default_value] => Array
            (
                [5] => 5
            )

        [#bef_nested] => 1
        [#theme] => bef_checkboxes
    )

but it doesn't work?

another thing, why dpm($form) prints the views exposed form data twice!

update 1: I tried something like this (but didn't work):

function mymodule_views_pre_build(Drupal\views\ViewExecutable $view) {
    $view_filters = $view->display_handler->getOption('filters');
    $view_filters['field_category_target_id']['value'][8] = 8;
    $view->display_handler->setOption('filters', $view_filters);
}

or this:

function mymodule_views_pre_build(Drupal\views\ViewExecutable $view) {
  $filters = $view->getExposedInput();
  $filters['field_category_target_id'] = 8;
  $view->setExposedInput($filters);
}


texts: What are the pros and cons of using Acquia Drupal install packages?

texts: My firm is considering using the Acquia Drupal install packages at http://acquia.com/downloads as a default boilerplate to start with for new client sites. What are the pros and cons of taking this approach?


texts: Main differences between registry and file_registry tables in Drupal SQL tables structure?

texts:
I already know that in computing in general, registry is the main data structure for paths (whether as a table in DB or a as a standalone DB).

In the case of Drupal, I saw two tables in the DB's. When is "registry" and the second is "file_registry".

While I understand that file_registry table holds paths for files, I wonder what are the main kinds of paths that the "general" registry table holds, and thus what are the main differences between them. I hope a Drupal developer who have dived into these SQL files could explain the main differences,


texts:
I'd like to expose data/views coming from 6.19 as json.

What I tried so far are the JsonRPC/REST service modules, but none of them worked for me.


texts:
I have a Drupal 7 installation and several admin pages are incredibly slow and time out after 30 seconds.  I've tried several things without success:

APC is enabled
innodb_buffer_pool_size is set to 100 M
No unused modules are enabled.  I still have 155 modules enabled, for localization, commerce, captcha, questions & answers, etc.
Standard cache is enabled and JS/CSS compression enabled. Memcached not being used.
Drupal 7, latest version

Even with that, the site is still really slow and there are pages that won't open (time out).  For example, installing a module will always fail the first time.  Accessing the settings of the Language Selection Page module will always fail, and so on.  Any recommendations other than increasing the timeout?

I'm using WAMP.

UPDATE: The time out error shows it takes a while in this function mainly: drupal_flush_all_caches( )   ..\system.admin.inc:1766

Sometimes in other functions too.


texts: How field values are stored in the database

texts:
I'm working in a migration from Drupal 7 and I'm trying to find out where the value of some fields are. I've tried but could not find an answer for this on this site.

I see each field has a pair of tables:

field_data_field_{field_name}
field_revision_field_{field_name}

Some of the field_data tables have a column named field_{field_name}_value and that's easy to find.

However, other tables don't have this column and have one called field_{field_name}_target_id. Inside it they have an integer but I can not find where it is referenced to...

I'm looking only at the database, I don't have the code (yet) and I don't know if this is related to a module, or if this is Drupal native. Anyhow, I can't find any other table with the values that relate to these Ids...


texts: Hide zip in addressfield form on commerce checkout pane?

texts:
How can I hide some fields from addressfield module (for example zip code) on checkout process if certain country is selected?
E.G. If US country selected then hide postal code field. If CA country selected then show postal code.


texts: Filtering on a field from field collection in a view

texts:
I have several node types (merchandise vendor, food vendor, festival vendor) which all have an embedded field collection called equipment, which can contain multiple values. The field collection has a taxonomy field called event and some others.

For example, a merchandise vendor can have equipment for event 1 (a taxonomy term), and different equipment for event 2 (a different taxonomy term).

My view can sort out the vendors for event 1 just fine. I can include the equipment for the events in the view, but I can't seem to filter it to just event 1.

I want to be able to visit the view page for event 1, and have it show all the vendors for event 1, and the equipment each vendor needs for event 1. Right now, it shows all the equipment for the vendor for all the events.

Is there a way to filter a field collection in a view?


texts: in commerce, how to assign child to a parent product

texts:
Is it possible to create a parent product that will contains all basic informations for a product  (Product title, Product Descriptions) and attach this parent product to children product (Sku, Color, Size, Price)

for the moment, the only solution I found is to create all the children at first and than create a Parent Product node with Product reference field pointed on child product where I can choose many childs.

Is it possible to do the oposite. I would like to create all the parent product first and assign ONE parent product to a child product during the child creation process. That's mean, I would like to have a dropdown with all the parent in there.

Thanks a lot


texts: Core blog module only shows two blog entries?

texts:
I've enabled the core blog module, but it only shows two entries on exampe.com/blog

If I "unpublish" one of them, it brings up the next published blog post, which shows me that it does recognize that there are additional blog posts.

There are about 137 in the database. How do I show them all with pagination? The core blog module doesn't seem to have any config settings.

EDIT: The site was recently migrated from D6 to D7, is there anything that may have caused this issue given this fact?


texts: Get date from date field and store into content entity

texts:
I'm wondering how I can grab the date from a datepicker in a form (format is d/m/Y) and store it into my content entity. The form is produced from said content entity, so I don't see why there should be any issues between formats - but it doesn't copy directly. I know the date fields are stored as varchar(20) in the database, so it must be a string at some stage!

I'm grabbing the value from my form as below:

$dob = $form_state->get('field_dob');
$given = new DrupalDateTime($dob, \Drupal::currentUser()->getTimezone());
$given->setTimezone(new \DateTimeZone("UTC"));
$dob = $given->format(DATETIME_DATETIME_STORAGE_FORMAT);

This gives me a string formatted as per the storage format, yet still won't copy across to the corresponding content entity.

Also, this is with Drupal 8.1.x. :)

Any insight would be much appreciated, thanks!


texts: How to make a page the home page of another domain

texts:
I have some pages with urls like this:

http://example.com/landing/abcd
http://example.com/landing/efgh

as menu items:

    $items['landing/%'] = array(
        'title' => 'Landing page',
        'description' => 'Landing page',
        'page callback' => 'mymodule_landing_display',
        'page arguments' => array(1),
        'access arguments' => array('access content'),
        'type' => MENU_NORMAL_ITEM,
    );

Now i want to use them as the home page of the domains:

http://abcd.com/
http://efgh.com/

I don't want to use a simple redirect.

What is the best way to do it ?


texts: Custom Compound Field with an Image/Media Field in it

texts:
i have a question regarding the Field API and Image Fields.
I am able to create custom "compound" fields with the Field API. So afterwards, i have a Field Type, with for example 3 Textfields and 2 Checkboxes.

My question is, if its possible to add an Image Upload widget, like the one in Media, to my custom field. If so, how can i do that ?

I tried a lot in hook_field_widget_form but i need some help to get this working.

Thx in advance,
Jan


texts: Auditing my D7 Site after upgrade to 7.32 w/ Zen

texts:
As a security nut case, I should have taken the last Drupal Core security update seriously. I did not, as we're in the process of building a brand new version of the website, and were planning on launching it onto a brand new server within the next month or two.

Until today, when I read more about it, and said "oh, yikes!" to myself.

Note that I do not have evidence that the website or the server was compromised. Everything done below was completed as a precaution.

After realizing to my horror that my MySQL backups hadn't run in quite a long time and realizing that restoring from backkups was out of the question, I pulled fresh code for Drupal Core, all of the drupal modules, and Zen.

I then deployed to a brand new server (fresh install of CentOS 7), which incidentally was a nice upgrade from the older CentOS 6 I had been using), taking a copy of the database I made today.

Obviously, the code is freshly downloaded, but my Zen subtheme and the database remains.

Before dumping the MySQL database from the old server, I did a spot check in /admin/people (This is purely an anonymous user site except for the site admin - me), the list of the content (/admin/content), and the settings on our webforms.

I didn't look at each individual page, but out of this list of what I did do, nothing seemed out of the ordinary. I also reviewed bandwidth & CPU graphs for the server, and didn't see any out-of-the-ordinary spikes in traffic.

I also ran a scan of the site using http://sitecheck.sucuri.net/, ran a check on http://tools.pingdom.com/fpt/#!/dqyWYp/developcents.com (and mentally compared it to previous scans I've run), and check blacklists using http://mxtoolbox.com/SuperTool.aspx?action=blacklist%3adevelopcents.com&run=toolpage.

All come up clean.

Are there any additional measures I should take to either
a) ensure the website is "cleaned up" and
b) check for backdoors, malware, etc...?


texts: Prevent Serialization or Unserialize via ODBC

texts:
Drupal, while a great CMS/Website/Intranet platform, is poor at providing users ability to edit datasets as one might in a spreadsheet or openly editable database table. We get forced into form update, form update, form update etc. Point, scroll and click time wasted. I've yet to find the module or View to edit data like a spreadsheet but still maintain database structure.

In Drupal 6, via ODBC we could easily edit node title, node body, comments or other text fields through programs like OpenOffice Base, LibreOffice Base, Microsoft Excel/Access or HeidiSQL. With Drupal 7 the text/data is serialized (BLOBs) and therefore what was easy changes to many text fields at once is now not possible, easily anyway.

What Drupal View setting, module or api/hook allows datasets to be edited, or
How to unserialize BLOB data for viewing in external programs
Stop Drupal 7 from serializing in the first place? or,
Other


texts: How to check if library is present in vendor folder?

texts:
I have a form in which I am providing some options to users. But I want the options to appear in the form on the basis of presence of 3rd party libraries in vendor directory. I want something like this:

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['settings']['tools'] = array(
      '#type' => 'radios',
      '#title' => $this->t('tools'),
      '#options' => array(),
      '#default_value' => $this->config('module.settings')->get('tools'),
    );
if(check_whether_xyz_library_is present_in_vendor_folder) {
  $form['settings']['tools']['#options'] = array('xyz' => 'xyz');
}

The vendor folder is present in the module directory itself and I am using composer to download third party dependencies. Since I do not want to check this  during installation of module but during form rendering then I suppose hook_requirements is not option. Any ideas on how to do so?


texts: How to use Rules to send an E-mail after saving a new comment, to users who checked a boolean in their profile?

texts:
What I try to achieve with Rules:

After saving a new comment, this comment has to be sent only to those users who've checked a corresponding boolean box on their profile page.

Any suggestions?


texts: How to theme the PAGE template for user account?

texts:
The user account page should have the title(name or username),user pic on the left, basic details like gender, city, state and country to the right. The local tasks tab should be available below those regions.

I tried page--user.tpl and page--user--profile.tpl. Doesn't work.

Am using drupal 7 with an adaptive sub theme and don't know PHP much.


texts:
When uploading images to D8 programmatically the setting for Maximum image resolution will be ignored and images will not be scaled down. Some of the images i have to upload are even larger then 10MB.

I am currently using this code.

$file_type = explode('.', $image)[1];
$data = file_get_contents($image);
$path = 'public://images/';

if (file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {

  $file = file_save_data($data, $path . md5($image) . '.' . $file_type, FILE_EXISTS_REPLACE);

  $node = Node::create(array(
    'type' => 'image',
    'title' => $image,
    'field_image' => array(
      'target_id' => $file->id(),
    ),
  ));
  $node->save();

}

I've tried to work with ImageStyle::load('max_2600x2600'), but that will only create a style in styles directory.

It would be possible to use a custom shell command but i would love to use the Drupal 8 way. How to make sure original images will get resized?


texts: Sending a file in e-mail message body using Views Send

texts:
I have a drupal site that holds thousands of client details. What I want to do is to create an emailer to send out campaigns to the clients.

So far I have a view set up to filter clients by company and using Views Send I can send all selected an email.

What I would like to do is to send a file in the email. Either that or be able to paste the data from the file into the email. The file is stored in my drupal site within a content type.

Does anyone know how I would be able to do this? To be able to select from a list which file to send in the e-mail message body?


texts: Display custom block to specific content type programmatically

texts:
I created one custom module, it will create one custom block when it is installed. I want to display it on "product" content type only. Can I do the same with programmatically. It'll save my time. Here is my code.

<?php
function my_module_block_info() {
    $blocks = array();

    $blocks['my_module_config'] = array(
            'info' => t('My Module'),
    );
    return $blocks;
}

/**
 * Implements hook_block_view().
 */
function my_module_block_view($delta = '') {
    $block = array();

    switch ($delta) {
        case 'my_module_config':
            $my_module_form = drupal_get_form('my_module_form');
            $my_module_form = drupal_render($my_module_form);
            $block['subject'] = '';
            $block['content'] = $my_module_form;
            break;
    }
    return $block;
}
?>


texts: How do I avoid a link is closed within a custom text field too soon

texts:
I am creating a custom View for my Search API results page. I have many fields added and they are all set to hidden. This allows me to have a custom text field at the end that can have a unique layout.

I am trying to make each search result have a card-based UI - and the whole card needs to be clickable.

So, I have added a link around the entire
 but it's not working. Drupal is injecting a  immediately after the opening  tag. This is leaving a 0 pixel tall link.

Here is the code I'm using in the custom text field:

          {{ field_featured_image }}

{{ title_1 }}

{{ field_designation|length > 50 ? field_designation|slice(0, 50) ~ '...' : field_designation  }}

I've tried moving the link inside the outer div.
I've tried using the "Output as custom link" feature but it did the same thing.

The link wrapping around the entire thing is being closed too early (immediately before the
. I need that link to make the entire div clickable.


texts: How do you clear a field value with entity_metadata_wrapper()?

texts:
Suppose I have an entity with a field field_foo on it and I want to clear that field's value.

What should I pass to $wrapper->set()?

I have tried NULL and array() and both produce an error message.


texts: How set div in a specific position inside .tpl.php file

texts:
I use views module in my website (built in drupal-7). I have a custom theme.
I have set a views-view-fields--XX.tpl.php like follows.

    <?php /**`
 * Default simple view template to all the fields as a row.
 *
 * - $view: The view in use.
 * - $fields: an array of $field objects. Each one contains:
 *   - $field->content: The output of the field.
 *   - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
 *   - $field->class: The safe class id to use.
 *   - $field->handler: The Views field handler object controlling this field. Do not use
 *     var_export to dump this object, as it can't handle the recursion.
 *   - $field->inline: Whether or not the field should be inline.
 *   - $field->inline_html: either div or span based on the above flag.
 *   - $field->wrapper_prefix: A complete wrapper containing the inline_html to use.
 *   - $field->wrapper_suffix: The closing tag for the wrapper.
 *   - $field->separator: an optional separator that may appear before a field.
 *   - $field->label: The wrap label text to use.
 *   - $field->label_html: The full HTML of the label to use including
 *     configured element type.
 * - $row: The raw result object from the query, with all data it fetched.
 *
 * @ingroup views_templates
 */
?>

<?php foreach ($fields as $id => $field): ?>

<?php if ($id == 'field_voti'):?>

<?php endif; ?>
    <?php if (!empty($field->separator)): ?>
    <?php print $field->separator; ?>
    <?php endif; ?>
    <?php print $field->wrapper_prefix; ?>
    <?php print $field->label_html; ?>
    <?php print $field->content; ?>
    <?php print $field->wrapper_suffix; ?>
    <?php if ($id == 'distance'): ?>

<?php endif; ?>
<?php endforeach; ?>`
"

in order to insert some fields into a new div with a specific class.

With firebug I see the following:

..

    ..
    ..

..

..

..

All that I want to do now is to have the div with class="uniscicampischeda" before the div with class="views-field views-field-field-foto", so that with css I will give the right attributes (I want class "uniscicampischeda" with float=right attribute)
HOw can I do that? do I have to write some code into views-view-fields--XX.tpl.php file? How?
Can anybody help me?
Thanks.


texts: Why does drush rsync require a local site?

texts: It's clearly documented that drush rsync requires one of the sites to be local.  I'd like to understand why this restriction is in place.  I have configured site aliases to work with ssh, and I'm able to ssh into a system and then launch drush rsync.  Why can't drush do that?


texts:
I'm using the Apache Solr Search Integration and Facet API modules. I'm trying to implement facets for custom fields publication_date, publication_author, and journal, which are part of the content type publication.

These 3 fields are indexed successfully as ss_date, ss_author, and ss_journal. Furthermore, I can search against these fields on the default apachesolr search page. However, the facets for these fields show up as "_empty_". For example, when the search page loads, under the "publication_author" facet header, one bullet item shows up as "_empty_ (10)", which to me means that the author field is being indexed successfully with value "NULL" or possibly literally "_empty_" for all 10 publication nodes. Code is below for just the author facet.

define custom facets

function HOOK_facetapi_facet_info(array $searcher_info) {
    $facets = array();
    // Facets are usually associated with the type of content stored in the index.
    if (isset($searcher_info['types']['node'])) {
        $facets['ss_author'] = array(
            'name' => 'ss_author',
            'label' => t('custom: author'),
            'description' => t('Shows the authors'),
            'field' => 'ss_author',
            'dependency plugins' => array('role'),
            'default widget' => 'links',
            'allowed operators' => array(FACETAPI_OPERATOR_AND => TRUE, FACETAPI_OPERATOR_OR => TRUE),
            'facet missing allowed' => FALSE,
            'facet mincount allowed' => FALSE,
            //'map callback' => 'not used for now',
            'max callback' => FALSE,
            'default sorts' => array(
                array('active', SORT_DESC),
                array('count', SORT_DESC),
                array('display', SORT_ASC),
            ),
        );
    }
    return $facets;
}

"ss_author" is the name of the field added to the ApacheSolr document during indexing. If you'd like the code used to actually index these fields, let me know. Thanks very much!


texts: How to get URL parameters values inside access callback

texts:
I have a link looking like this:

members/get-certificate/<user_id>/<group_id>/<pass date>

The access callback should work like this:

if($user->uid == <user_id>)
{
    //any user can get his own certificate
    <generate certificate>
}
else
{
    //user with low admin priviledges can generate a certificate for any user
    if (user_access('low admin task'))
    {
        <generate certificate>
    }
    else
    {
        print "Access denied";
    }
}

In hook_menu I wrote this:

$items['members/get-certificate'] = array(
    'page callback'    => 'members_get_certificate',
    'access callback' => 'members_access_get_certificate',
    'access arguments' => array('access content', $user_id),
    'type' => MENU_CALLBACK,
    );

Access callback

function members_access_get_certificate($permission, $user_id)
{
    global $user;

    if ($user_id != $user->uid)
    {
        if (!user_access('low admin task'))
        {
            return false;
        }
    }

    return true;
}

Page callback

function members_get_certificate($user_id, $group_id, $pass_date)
{
    //generate certificate
}

Problem

Unfortunately, $user_id is undefined in members_access_get_certificate and I am unable to do the validation. How can I pass the parameter from URL into the callback?


texts:
I'm trying to use hook_node_access in my custom module to do the following:

I have a lot of nodes (of type 'order') with a field called customer (1, 2, 3, 4)  and there are users who also have a field called customer (1, 2, 3, 4). I need to have it so that only the user with the customer field value of '2' can view, update and delete nodes only with customer field value of '2'


texts:
I have a ticketing system where the path aliases are set like ticket/[node ID], e.g. http://example.com/ticket/1234.

I would like to create multiple path aliases for the same node, and be able to access it also as discussion/[node ID], e.g. http://example.com/discussion/1234.

I will be using different node templates basing on the path.

Is there any way to set multiple path aliases for the same node?


texts: Breadcrumbs disappear on cache clear, come back with subsequent cache clear

texts:
I have a site where the breadcrumb is in different locations depending on what node type or page is being viewed.

In some places, it is interspersed with node content, so the only solution was for my colleague to inject it into the page as a variable, like so (from .theme):

$block = Block::load('breadcrumbs');
$variables['content']['breadcrumbs'] = \Drupal::entityTypeManager()->getViewBuilder('block')->view($block);

I've noticed that when I deploy code, the breadcrumbs disappear. I then have to clear the cache, clear Varnish, and clear the cache again and finally hard refresh in my browser to see them again.

Is this related to how breadcrumbs are being injected into the page and if so, is there a better way to do it?


texts: Programatically create user that needs admin aproval

texts:
When creating a new user with user_save, it seems to get the "approved" role automatically, even though I pass an empty array to $user->roles.

How can I force the programatically created user to need admin approval before being activated?


texts: Custom Views Sort Order Using Filter Value

texts:
I have a View containing a list of events.  There is a date field on the event content type which contains start and end time:

There is a filter for start time, which is setup using the Views Between Dates Filter:

This means that entering 11:00am in the filter will ensure that the event with time 10:00 AM to 3:00PM exists in the results since 11 falls between 10 and 3.

The full result set might look like the following when using 11am for the filter:

7am to 3pm
8am to 12pm
9am to 11:30pm
11am to 12:00pm
11am to 1pm

How can I create a custom sort, such that the exact matches for start time are ordered first?  These are the results I need:

11am to 12:00pm
11am to 1pm
7am to 3pm
8am to 12pm
9am to 11:30pm

Is there a way to create a custom sort handler for views using filter values?

EDIT: I'd hoped I could use hook_views_post_execute to re-order the data but I'm using a pager, so only the first 10 results exist in $view->result


texts:
(Pathauto: Leave case the same as source token values)

When I create a node with "Nullam vehicula pharetra" as title, the Pathauto module will create /content/Nullam-vehicula-pharetra as URL alias. But we can browse the same content with a different URL case, such as /content/NULLam-vehicula-pharetra.

How do I make Drupal strict on the URL alias case?

Wikipedia is good example about what I need. Two different case request return different contents:

https://en.wikipedia.org/wiki/Drupal
https://en.wikipedia.org/wiki/DruPal


texts:
I would like to create a top 5 of selected options from a webform.

As users fil in the webform i would like to create a view with the top 5 selections of the list.
How can i do this with views?

Example: i have a webform with 5 options.

a,b,c,d,e

User get a dropdown to choose 1 or multiple options.

When 10 users have filled out the form these are the results

option a is chosen 4 times
option b is chosen 7 times
option c is chosen 2 times
option d is chosen 1 time
option e is chosen 9 times

How can i create a view that show this

Top 5 of selected options:
Option e
Option b
Option a
Option c
Option d

Kind regard Kevin


texts:
I want to restrict concurrent edit by the users.

If user A is editing a content then  user B should not be able to edit the content at the same time. That content should be visible, just not editable.

I am unable to find any module that provides this feature for Drupal 7.

Is there any module, or how can I achieve this programmatically?


texts:
I have an external application written in VB.NET that needs to add user accounts to a drupal database.

We tried posting to the /user/register but something is funky with that code and it is not working. I also considered using a RESTful API plugin but that has proven to be more work than we are capable of delivering on short notice.

Just when I figured we could:

Add a value to sequences table
Use that previous value as ID of next user

We now discover that we need some fancy smancy hashed password. I look into the code and see D7 uses sha512 but also some hashing salt -- which again is yet another drupal method which accepts the number or iterations to hash (or something to that effect).

If the VB app uses a sha512 on a password will this suffice with Drupal? Will uses be able to login?

Tips, comments, etc more than welcome :)

Alex


texts: How to pass a form field value from THEME_system_theme_settings_alter() to THEME_form_system_theme_settings_submit()

texts:
MYTHEME/theme-settings.php: THEME_form_system_theme_settings_alter() builds an input form for /admin/appearance/THEME and the input (values) of the user will not be known by Drupal nor by theme_get_settings() before saving the user given input.

I'm kind of curious how to pass this value to THEME_form_system_theme_settings_submit() in theme-settings.php?

In other words: I need the value from the user input of the theme settings form BEFORE we leave theme-settings.php - Is that possible? Or do I need another way around this?

Test: Let's say the value gets stored in a 'textfield', build by the THEME_form_system_theme_settings_alter() function:

// theme-settings.php
function THEME_form_system_theme_settings_alter(&$form, &$form_state) {
// Test form
$form['whatever_fieldset_group']['user_input'] = array(
    '#type' => 'textfield',
    '#title' => t('Test to get value'),
    '#default_value' => theme_get_setting('user_input'),
    '#description' => t('
         Type some text in textfield
         to get shown in submit message'),
);
}

To test if I can pass that value to THEME_form_system_theme_settings_submit() we try to show the value of this field in a submit message:

// theme-settings.php
function THEME_form_system_theme_settings_submit($form, &$form_state) {

    // the following will not work inside theme-settings.php
    // because value is not known yet by theme_get_setting()
    $data = theme_get_setting('user_input');

    drupal_set_message(
          'For testing purposes we submit that you have
           filled the textfield with the following
           mindless value: '.$data
          );
}

This will not work. Of course. And variable_get() and variabel_set() seems to be no option ether, because we can not fill any variable without knowing the value in theme-settings.php.

The reason for asking this is, I want to write css from user input in a css file while saving theme settings. Maybe there is a way to fire a function after theme-settings got saved? Not sure. Maybe I need more examples of custom themes and how they solved it there without an additional module ...


texts: How to trigger hook_form_alter() on my custom $form?

texts:
I have written a custom module which builds a custom user_profile_form():

mymodule_user_profile_form($form, $form_state, $user) {
  module_load_include('inc', 'user', 'user.pages');
  $form = user_profile_form($form, $form_state, $user, 'account');
  // doing stuff with $form ...
  return $form;
}

Now, it's working as desired but I noticed a lot of contrib modules are altering the user_profile_form() calling a hook_form_alter() on the $form_id == 'user_profile_form'.

Now, I want all these modifications applied to my custom profile form, too. How to achieve that?

The hacky way would be to go through all modules and change the checks for $form_id == 'user_profile_form' || $form_id == 'mymodule_user_profile_form', but this is a no-go and I would appreaciate a clean way to do this. Any idea?

Update: drupal_get_form() is not the answer as it is not working as desired. This is only returning the $form object without re-building it which causes many issues with theming layer and $form_state['values']. I'm adding this information as requested by moderator, but this is not part of my question. This is the not working code with drupal_get_form() b6d1f1d8 and this is the working code with user_profile_form() d5d43dc0.


texts: Views Auto-Refresh: is there a way to deactivate the ''Please Wait" message

texts: I am building a live message tracker, and I am using 'Views Auto-Refresh" to update my list of messages every 5 seconds.  My problem: every time the page updates, a "Please Wait" message appears above mt view for a second, and bumps the content down, then back.  This is very annoying.  Is there a built in way to move or hide this message of will I need to use CSS to hide it?


texts:
This is a follow up question to: How do I show user attributes on articles?

I still can't get the "Twitter URL" field to show up on articles, and got tired of reading through the Fields API docs; I figured I couldd ask if anyone can look at my template files, and tell me why the twitter URL is not output, as I know it is being set.

This is the node preprocess function from node.tpl.php:

function blogbuzz_preprocess_node(&$vars, &$variables) {
  if ($vars['view_mode'] != 'full' && $vars['id'] == 1) {
    $vars['classes_array'][] = 'node-first';
  }

  if ($vars['view_mode'] == 'full' && node_is_page($vars['node'])) {
    $vars['classes_array'][] = 'node-full';

  }
  // Even though there's a user object in $variables['user'], we need to
  // load a new copy because the preloaded one doesn't have have field data
  $user = user_load($variables['uid']);

  // Retrieve the data and its value for the Twitter URL field
  // Replace field_twitter_url with the short name of the field
  // found at admin/config/people/accounts/fields
  $items = field_get_items('user', $user, 'field_twitter_url');
  $field = field_view_value('user', $user, 'field_twitter_url', $items[0]);

  // Get the rendered output of the field for use in the submitted line
  $twitter_url = drupal_render($field);

  // If you wanted to get more fields, repeat the last three lines, replacing
  // field_twitter_url with the names of the other fields.
  $variables['twitter_url'] = $twitter_url;
}

And here is  the template.tpl where I use $twitter_url:

<div class="<?php print $classes; ?>">

    <?php print render($title_prefix); ?>
    <?php if (!$page): ?>
      <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?>

    <?php endif; ?>
    <?php print render($title_suffix); ?>

      <?php if ($display_submitted): ?>
        <?php print t('Published by '); ?><?php print $name.t(' on ').$date; ?>
         <?php print t('Twitter '); ?><?php print $twitter_url; ?>
      <?php endif; ?>

      <?php if (!empty($content['field_tags'])): ?>
        <?php print ' in '.render($content['field_tags']);  ?>
      <?php endif; ?>

    <?php
      hide($content['comments']);
      hide($content['links']);
      hide($content['field_tags']);
      print render($content);
    ?>

    <?php if ($content['links']): ?>

        <?php if (!$page): ?>

<?php print l(t('Read more'), 'node/' . $nid, array('attributes' => array('class' => t('node-readmore-link')))); ?>

        <?php endif; ?>
        <?php print render($content['links']); ?>

    <?php endif; ?>

    <?php print render($content['comments']); ?>


texts: How do I put this custom CSS and JavaScript into a certain block?

texts:
I'm having a hard time getting this:
http://dev.chrisruno.com/sahshe/quiz/
To go into a block in this node:
http://sahshe.chrisruno.com/?q=node/22#

I've successfully included the two Javascript files I need, but I can't figure out how to apply the css to ONLY what is inside the block.  I've only gotten as far as including the CSS file in my theme's .info file, but that makes the whole site look crazy.


texts: Converting Term names with special characters to Term ID's in Views

texts:
I have a view where I want to use multiple termID's as arguments. I want to use a term name from the url and convert it to a termID. I've managed to do this easily enough and it works with simple 1 word terms or even multiple words by checking the 'Transform dashes in URL to spaces in term name arguments'

I have a few terms that have special characters eg: "news & politics".

Is there any way to have nice URL's (news-politics) and get views to recognise the correct term and convert it to the correct termID? Will I have to urlencode the ampersand? Will that even work?

Edit: You can setup path aliases for single taxonomy terms, but is a problem when you want to use the term name as a second argument in a path with multiple arguments eg:

Say I wanted to filter the view results by %1 News term then %2 News & Politics

/news/news-politics

second term would not be recognised.


texts: How to prevent granting Userpoints again after a user already passed a Quiz?

texts:
I'm using the Quiz and the User Points module.

After a user takes a quiz, the points are granted. But if the quiz is taken multiple times, the points are granted multiple times also. For example;

points balance: 0
after quiz (1st time), point balance: 10
take the same quiz again, point balance becomes: 10+10=20

I don't want it to be cumulative. How can I prevent this?


texts: Drupal 7 | Associate dynamic user to a content type

texts:
I have a  content type "Article", with a field "author".

Is it possible to assign users with "writers" role dynamically with this field ?

The goal is to display in the article node, a link which redirects to the writer(user) profile.

For example :

-Article Title

-MM/DD/YYYY

-Written by : randomWritter (dynamic link)


texts: how to overreide page.tpl.php with my custom menu

texts:
I have override page.tpl.php with my new custom menu created in my custom module. my menu look like below

$items['node/edit/restaurant/%/barcodes'] = array(
    'title'=>'Barcodes',
    'menu_name' => 'barcodes',
    'description'=>'Barcodes',
    'page callback'      => 'drupal_get_form',
    'page arguments' => array('leo_MSTag_barcode', 5),
    'access callback'=>TRUE,
    'type' => MENU_CALLBACK,
  );

I already try with page--barcodes.tpl.php, page--node--edit--restaurant--barcodes.tpl.php but not work for me. any new template suggestion for override mu menu page?


texts: Menu subitems only displaying on a single page

texts:
I have several menu items in our main menu, and each of them has several sub-items. All of them display correctly EXCEPT one - this particular menu only displays the top-level menu item, unless you're actually on the page that the top-level item links to - then it displays all the dropdown sub-items.

The only difference in the non-working menu is that the sub-items link to external sites, rather than internal pages.

Here's the menu setup:

The Featured Exhibitor menu works - i.e. the dropdown displays on all pages. The Contact menu doesn't work - on all pages, all you see is the top-level Contact link. When you click that and are taken to /contact, the menu suddenly displays all the dropdown links. Because the sublinks are to external sites, there are no issues with node permissions or anything, and even if there had been, at least things would have been consistent (they wouldn't have displayed anywhere if the user didn't have access.)

Here's the menu displayed on /contact:

We've tried switching the theme to see if there was something funky about ours, but it does the same thing no matter what template we try. Any idea what would cause this?

EDITED TO ADD

When I look at the rendered source, the subitems of the contact menu are not included on pages other than /contact. So it doesn't seem to be a style issue.


texts: How can I write an input selector for the states API?

texts:
I'm trying to use the #states API but my input selector isn't being picked up.  This is the code I've added to hook_form_alter() in a custom module:

  case 'my_form':
    $form['revision_information']['#access'] = FALSE;
    $form['field_guide_link_hosting']['#states'] = array(
      'visible' => array(
        ':input[name="field_guide_types[und]"]' => array('value' => 's'),
      ),
      'required' => array(
        ':input[name="field_guide_types[und]"]' => array('value' => 's'),
      ),
    );

And here's the rendered form for field_guide_types:

  How can you help tourists? 必須

 <input type="checkbox" id="edit-field-guide-types-und-o" name="field_guide_types[und][o]" value="o" class="form-checkbox">  Answer questions and offer information online

 <input type="checkbox" id="edit-field-guide-types-und-m" name="field_guide_types[und][m]" value="m" checked="checked" class="form-checkbox">  Meet in person

 <input type="checkbox" id="edit-field-guide-types-und-s" name="field_guide_types[und][s]" value="s" class="form-checkbox">  Provide a place to stay (like through AirBNB, CouchSurfing, etc.)


texts: Drupal 7 Hierarchtical Taxonomy Translations

texts:
I currently have hierarchical select installed but on the pages it's it doesnt apply basic localization. I need it to use the translations i have set up in the translation database of drupal. I have searched around google but havn't had luck finding a working solution.

Any help appriciated, thanks!


texts:
I'm having difficulty with setting up a view in Drupal 7. I'm going to use a sports example as a way to illustrate my problem:

I have three content types:
1. Team
2. Roster
3. Player

On the ROSTER editing page, I select which TEAM this roster belongs to, via Entity Reference.

On the PLAYER editing page, I select which TEAM this player belongs to, via the SAME entity reference field.

I've created a view, specifically a block, that lists the players on the roster page. However, right now, it's displaying ALL players. I know this is what contextual filters/relationships are for.

However, I get lost in the contextual filter and relationship settings. I've read a lot of documentation about each, impressed by all the different explanations and demos, but can't seem to find the right configuration that works for my problem.

I'm trying to filter the players on the ROSTER page, based on the TEAM that is selected both in the ROSTER and PLAYER content types.

Any help, suggestions, advice is appreciated. Thank you.


texts: How do I troubleshoot 'Theme key "" not found'?

texts:
How do I troubleshoot the error Theme key "" not found?

I found dozens of search results regarding specific keys, but nothing useful for debugging an empty key ("").

Here is the full entry from syslog:

Sep 12 09:45:47 core drupal: http://www.example.com|1347457547|theme|192.168.1.10|http://www.example.com/|http://www.example.com/admin/config/development/logging|1||Theme key "" not found.

What exactly triggers this error and how should I go about debugging it?


texts:
I have a Search view that uses the Filter: Search terms.

I've tried using <?php print arg(0); ?> in the header, but that only returns the view url (search).

How do I get the value of the query key /search?keys=term to be able to use it as a token in a Global: Text area in the Header?

My header title would be something like : Results for [search term]


texts: Hiding a filter in a view with same filter in contextual filters

texts:
I've a simple problem. In Views I've city filter(exposed) set that'll show jobs in a city. Now I've set the same City in contextual filters as well with the condition to show all values when no argument is supplied. So this view is "General Advanced Job Search"

Now I want to offer "Jobs in Citi1", "Jobs in Citi2". But I want to reuse the same View without duplicating it. I'd call it "Advanced Job Search given a city".

So I can pass the arguments as Citi1 etc and it'd show Jobs in Citi1 at the same time it'll show City filter as drop down in Filter Criteria. I want to hide this City in Filter criteria as it is of no use as cities are already being limited by the argument passed(Citi1).

I've tried searching here and there but nothing found.

In short if argument is passed to a view I want to hide an exposed field show in filter criteria.


texts:
I ran pm-update with drush which is giving me this error

  File mediabox-7.x-1.x-dev.tar.gz_date=1393593819 is corrupt (wrong
  [error] md5 checksum). Updating project mediabox failed. Attempting to
  roll back to         [error] previously installed version. Backups
  were restored successfully.                                  [ok]

Same thing worked on my local server but not on ubuntu server. Anyone know how to resolve this issue? I can manually copy the files but I am not looking for that solution.


texts: Show block on specific views search result

texts:
My view exposed search results path looks like this:

www.xyz.com/?field_port_tid=5971&field_length_value=&field_length_value_1=&field_cabins_value=&field_cabins_value_1=&field_price_week_range_value=&field_price_week_range_to_value=

I would like a block to show only if the path has specific taxonomy term in it (in this case tid=5971).


texts: Commerce cart line item to show original price, not the one with discounts subtracted

texts:
Using Drupal Commerce Kickstart, when the user is at the shopping cart and activated any kind of discount (most of the times, a coupon) the line item price in the Cart table is updated with the discount.

I'd like to show the original price there and let the Summary describe what kind of changes the prices went through.

Here is a screenshot that might help https://www.dropbox.com/s/matvseodarii41m/Screenshot%202014-08-19%2014.46.45.png?dl=0

I'd like the top Price value to be $395 and everything else could stay exactly like this.

How can I make this happen?

Thank you!


texts: db_affected_rows gives fatal error in drupal 7

texts:
How can i get the number of affected rows in drupal 7? db_affected_rows which i was used in d6 is not working in d7. It shows an error

 $bool = db_query("SELECT * FROM {template_config} WHERE user_role = ':d'",array(':d'=> $id));
        $num = db_affected_rows();
        if ($num != 0) {
            $result = db_fetch_array($bool);
            $custom_theme = $result['theme_name'];
        }

i want to check if there is any affected rows.db_num_rows also is not working in d7
How can i do this in d7?


texts: Custom Field Type only shows -hidden- Widget

texts:
I want to create a Field Type with text_textfield as default widget.
But all I get is -hidden-

Here is my FieldType Class

<?php

namespace Drupal\gettweet\Plugin\Field\FieldType;

use Drupal\Component\Utility\Random;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\DataDefinition;

/**
 * Plugin implementation of the 'get_tweet_field_type' field type.
 *
 * @FieldType(
 *   id = "get_tweet_field_type",
 *   label = @Translation("Get tweet"),
 *   description = @Translation("Reference a tweet token"),
 *   default_widget = "text_textfield",
 *   default_formatter = "text_default"
 * )
 */
class GetTweetFieldType extends FieldItemBase {

  /**
   * {@inheritdoc}
   */
  public static function defaultStorageSettings() {
    return [
      'max_length' => 255,
      'is_ascii' => FALSE,
      'case_sensitive' => FALSE,
    ] + parent::defaultStorageSettings();
  }

  /**
   * {@inheritdoc}
   */
  public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    // Prevent early t() calls by using the TranslatableMarkup.
    $properties['value'] = DataDefinition::create('string')
      ->setLabel(new TranslatableMarkup('Text value'))
      ->setSetting('case_sensitive', $field_definition->getSetting('case_sensitive'))
      ->setRequired(TRUE);

    return $properties;
  }

  /**
   * {@inheritdoc}
   */
  public static function schema(FieldStorageDefinitionInterface $field_definition) {
    $schema = [
      'columns' => [
        'value' => [
          'type' => $field_definition->getSetting('is_ascii') === TRUE ? 'varchar_ascii' : 'varchar',
          'length' => (int) $field_definition->getSetting('max_length'),
          'binary' => $field_definition->getSetting('case_sensitive'),
        ],
      ],
    ];

    return $schema;
  }

  /**
   * {@inheritdoc}
   */
  public function getConstraints() {
    $constraints = parent::getConstraints();

    if ($max_length = $this->getSetting('max_length')) {
      $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
      $constraints[] = $constraint_manager->create('ComplexData', [
        'value' => [
          'Length' => [
            'max' => $max_length,
            'maxMessage' => t('%name: may not be longer than @max characters.', [
              '%name' => $this->getFieldDefinition()->getLabel(),
              '@max' => $max_length
            ]),
          ],
        ],
      ]);
    }

    return $constraints;
  }

  /**
   * {@inheritdoc}
   */
  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
    $random = new Random();
    $values['value'] = $random->word(mt_rand(1, $field_definition->getSetting('max_length')));
    return $values;
  }

  /**
   * {@inheritdoc}
   */
  public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
    $elements = [];

    $elements['max_length'] = [
      '#type' => 'number',
      '#title' => t('Maximum length'),
      '#default_value' => $this->getSetting('max_length'),
      '#required' => TRUE,
      '#description' => t('The maximum length of the field in characters.'),
      '#min' => 1,
      '#disabled' => $has_data,
    ];

    return $elements;
  }

  /**
   * {@inheritdoc}
   */
  public function isEmpty() {
    $value = $this->get('value')->getValue();
    return $value === NULL || $value === '';
  }

}


texts:
Could someone advise on how to adopt the working composite example that comes with Webform in Drupal 8?

https://www.drupal.org/node/2824714 suggests it can be done.

I've copied the example from modules/webform/modules/webform_example_composite folder. Does this need to go into the webform root folder with other example or root module folder?

I realise that the functions and iterations of webform_example_composite need to be renamed.

I also tried altering the pr-existing example that comes with Webform, without success.


texts:
I made a custom stylesheet for my nice menu in sites/all/themes/mytheme/css/nice-menu-custom.css

under admin -> config -> themes -> global settings I set the path for my nice menus stylesheet as stated above.
After saving this setting, the default css from nice menus actually disapeared from the nice menu block on my site, which obviously verifies that this set up is fine.

other than that, no matter what I do, no css getting processed.

CSS compression is turned off.
My problem actually started with my nicemenu class selectors not working in my at that time sole stylesheet style.css. So figured I'm going to do overriding by the book before asking the my question. Still to no avail.
Flushed caches over and over


texts:
I am using Flexslider module in drupal 7 .  when i checked my website on mobile.  i am not use slider by touch

Is there is any setting for flexslider.

Thanks


texts: how to limit view to just show each type one time?

texts:
I have a content type what is news, the news has a field type that is List (text) to keep different types of news. for example I have Health, Sport, Economic and etc.

So now I am going to create a block and have each of these type in that as a hyperlink.

I can do it and I created a new view block but each news_type may showing more than one time according to published content.

How to set the view (for block) to just show news_types and show them just one time?


texts: How can I unset / remove a paragraph component from within template_preprocess_node?

texts: In Drupal 7, I need to be able to selectively remove paragraph components from a given node. Which parts of the $variables array need to be unset?


texts: why and how the view is putted in the sidebar first block

texts:
I am studying the distrbution OpenAID
http://drupal.org/project/openaid
---
I have a question:
in the block : sidebar first. there are some special view related with the url.

but in admin/struction/block. the sidebar first is none.

so question: why and how the view is putted in the sidebar first.

I get a clue : Exposed form , but more confuse is left.


texts: Node registration form block - hide if registered

texts: I'm using "Node registration: this page's form" block, but I want to hide it when user has registered for this node already. I know i should use 'If' statement but i don't know what condition to use.


texts: How to render a taxonomy field in a Views' PHP code field?

texts:
In Views PHP code, I could render a field by :-

<?php
  print drupal_render($data->field_field_my_text);
?>

But this only seems to work field with type Text. I have a field which is Taxonomy (Term Reference) and I am trying to output that through the above code but it's not working.

This is what I wrote:-

<?php
      print drupal_render($data->field_field_my_category);
    ?>

Unfortunately, this is not working. Any idea what I should do here?

Thanks.


texts: How to link user taxonomy-term to a list with all users with that term applied?

texts: So in my testcase you see, that there are some taxonomy terms applied to this user. However when one does click on a taxonomy term there appeares an empty view. Why are not all users with that taxonomy term listed?


texts: How to programmatically clear library info definition?

texts:
Created a dynamic library which attaches some external CSS & JS thru hook_library_info_build hook and this depends on a dynamic config values set by a config form. So whenever that config form saved, how can I make sure the library info is up to date and latest? and users don't have to always do a complete cache rebuild.
Additionally is it possible to clear(or rebuild) just one library definition?


texts: How to render Entity Reference fields in the current language

texts:
I am trying to render fields from an entity reference in a twig template but they are displaying in the default language instead of the selected one. My twig code:

{% for location in node.field_locations %}

      {{ location.entity.title.value }}
       {{ location.entity.field_sub_title.value }}

 {% endfor %}


texts: additional Social icons in ShareThis module

texts: I am using ShareThis module for social icons. Can anybody please tell me how to add a new social icon not provided by this module? Flickr,Feed and Email icons are not present in the list.


texts:
I had to develop a Drupal 8 based website for a client. This client has a quite strict configuration for its firewall and filters the characters used in POST values. It happens to be a bit too restrictive on the contact form for the taste of the marketing department. The security team would consent to lift some character limitations if I could list them the measures used by Drupal and Webform to filter/sanitize user inputs.

I am pretty confident that Drupal does a good job in that regard. I expect a mixture of htmlentities(), filter_var(), custom functions calls and other related configurations but I couldn't find any details. All my searches on the subject spawns answers around the fact that Drupal does sanitize its input, but nothing concrete.

How does Drupal sanitize the user input?


texts: How to programmatically assign user roles

texts:
I am assigning a role to user by this code:

$user = user_load($user->uid);
$role = user_role_load_by_name("10-dis");
$user->roles = $user->roles + array($role->rid => $role->name);
user_save($user);

I need to replace this role with a new role, means I need to change user role according to some condition. How can I programmatically reassign user role?