New answers tagged

0

In Drupal 8: function YOURMODULENAME_page_attachments(array &$attachments) { global $base_url; $attachments['#attached']['library'][] = 'core/jquery.form'; $attachments['#attached']['library'][] = 'core/drupal.ajax'; $attachments['#attached']['library'][] = 'MODUL/login_module'; $attachments['#attached']['...


0

Publish a node in Drupal 8 drush php-eval '$node = node_load(123); $node->setPublished(true); $node->save();' Publish a node node in Drupal 7 drush php-eval '$node = node_load(123); $node->status = 1; node_save($node);’ Publish all the nodes of a specific content type in Drupal 8 drush php-eval '$nodes = node_load_multiple(array(), array("type"...


0

In many ways, Rules is just a wrapper around core Drupal functionality. So while Rules tries to make this core functionality accessible to users who aren't hard-core Drupal programmers, there are of necessity quirks and assumptions inherited from Drupal that govern and explain how Rules behaves. Specifically, in this case, the "After saving new content" ...


1

The advanced fields are added by the node.module in node_form_search_form_alter() (a hook_form_FORM_ID_alter() implementation). It sounds like your module's hook_form_alter() is getting called before the node.module one, so you're not seeing it's additions. The ordering of when hooks are fired is controlled by the weight column in the system table. Have you ...


0

The user-profile.tpl.php template file doesn't get a variable containing the user ID, nor a user object. The $user_profile variable contains what needs to be rendered for the user profile. template_preprocess_user_profile() retrieves the user object used for the profile, but it doesn't pass it to the template file, nor does it pass the user ID. If the user ...


0

Given there is an issue in the project issue queue (Solr 7 integration) about allowing to use the module with Solr 7, the module is at the moment only compatible with Solr 5 and eventually Solr 6. Notice that the README.txt file has not been updated since 6 years ago and that the solr-conf directory contains configuration files for Solr 1.4, 3.x, 4.x, and 5....


0

So far as there is no support for nested groups in Drupal 7, we shoud do it slight differently. Join general filters (Published and Node type) in first AND group. May be we also should to add there "State IS NOT NULL" condition to exclude content with empty State field. In second group we should place State = 'active' OR test = 'false'. This group - OR ...


0

For theming user profile page use page--user--%.tpl.php template file. To see all possible template suggestions right in your code you can enable Theme debug mode in sites/default/settings.php: $conf['theme_debug'] = TRUE;


0

It could be that there's a bug in the parser's reporting progress. As long as the parser doesn't tell Feeds parsing is done, Feeds will keep calling the parser over and over again. Workflow of Feeds Fetch data. Parse 50 first items of data. Process 50 items. Feeds checks if the parser's progress is complete. If not, the next 50 items of data are parsed. ...


0

Supposing that the first version of the function is working, it doesn't restrict the values by the entity ID, since you aren't providing any value for the :user_id placeholder. The second version of the function doesn't work because, instead of passing the 'user' string as value for the :user_id placeholder, it's passing an object which, if casted to a ...


0

You could achieve this by either one of the following: By using db_query(): function custom_get_user_account_id() { global $user; return db_query('SELECT field_account_target_id FROM {field_data_field_account} WHERE entity_id = :user_id AND bundle = :bundle', [ ':user_id' => $user->uid, ':bundle' => 'user', ])->...


1

Once a field is created, you can still change its settings clicking on the Field settings tab you see in the screenshot you took. As you notice, the warning tell you the settings cannot be longer changed, as there is already a node containing data for that field. That doesn't mean you cannot change anything for that field. For example, I was able to add ...


1

Click on "field settings" in the top right hand corner of that screen. That's where storage specific options are held. If you can edit the options there then it's a simple text list. But it may be that field is referencing a taxonomy term or content/entity but that tab will lead you in the right direction to add an item


0

Take a look for the issue https://www.drupal.org/project/commerce_fees/issues/2191191, maybe a patch can help you.


0

Try to use the Simple Image Rotate module.


0

Firstly, will be better if you host a Drupal site on the separate domain/subdomain. About your error, seems you forget copy all files (for example a folder with themes). About the DRUPAL_ROOT constant, you shouldn't change it.


0

In case you have bootstrapped drupal instance, drush and jq installed drush status --fields="db-driver,db-hostname,db-port,db-username,db-password,db-name" --format="json" | jq '."db-driver"+"://"+."db-username"+":"+."db-password"+"@"+."db-hostname"+":"+."db-port"+"/"+."db-name"'


1

In your post request you have specified 'Content-Type' => 'application/x-www-form-urlencoded' but your post data is in JSON format. Perhaps you need 'Content-Type' => 'application/json' alternatively, pass the raw $data array as the post data for key=value&key1=value2 form encoding. You also need to pass the function parameter $options ...


0

1 Read an image in JS from attached file https://developer.mozilla.org/ru/docs/Web/API/URL/createObjectURL 2 Use Lib for reading Exif data from jpg for autorotation as default option https://github.com/exif-js/exif-js 3 Create controls for manual rotate image on canvas as manual tool https://stackoverflow.com/questions/17411991/html5-canvas-rotate-image 4 ...


0

I placed this code in field--[field name].tpl.php <?php foreach ($items as $delta => $item) : ?> <div class="col-sm-<?php print round(12/count($items)); ?>"> <?php print render($item); ?> </div> <?php endforeach; ?> It seems to work !


0

I'm not sure what caused the problem in the first place, but it was ultimately resolved by running solr with a different user. In trying to address the original problem (whatever it was), I ran solr using the wrong user. Once I ran it with my designated "solr" user, Drupal could then reach solr.


0

If you inspect the "Edit Vocabulary" link the vid is in the ID attribute e.g. "edit-12-edit".


0

In Drupal 8 you can reset it by curl POST 'http://YOUR_SITE.URL/user/password?_format=json' \ --header 'Content-Type: application/json' \ --header 'Content-Type: application/json' \ --data-raw '{ "mail": "USER_EMAIL" }'


0

After seeing the results of drupal_get_profile() and querying for that value in the system table, the result of the query showed that the profile's files were (supposed to be) in: /var/www/html/profiles/[profile name]/ However, that folder path did not exist. Since Drupal could not find the profile's files in that folder path, it could not set a ...


0

Assuming that $gid contains the group ID and $uid contains the user ID, you can get the list of the permission names that user has on the group using the following code. $group = entity_object_load($gid, 'group'); $permissions = $group->userPermissions($uid); $permissions will contain an array with all the permission names.


0

The Group class has a userHasPermission() method you can use. So something like this: if ($group->userHasPermission($user->uid, 'some permission')) { // do something. }


0

checking if page is group if so loading the group then checking if the user is a member of the group. if (!empty(menu_get_object('group'))) { $group = group_load(arg(1)); if($group->getMember($user->uid)) { return TRUE; } }


0

You don't need any module. Edit the view > Advanced > Exposed form in block. Put: Yes. You can now add the filter in Structure as a block.


0

You can get the object for the current page in Drupal 7 using menu_get_object(). if ($group == menu_get_object('group')) { // do something with $group }


3

To return 403 Forbidden in your callback function, use drupal_access_denied() function something like: function user_is_api_user() { watchdog("GLOBALS", "<pre>" . print_r($GLOBALS['user'], TRUE) . "</pre>"); if ($GLOBALS['user']->name !== 'api'){ drupal_access_denied(); } }


1

For anyone who lands here like I did looking for a way to set maxlength in a Drupal 8 textarea, this worked for me using form_alter: $form['field_NAME']['widget'][0]['value']['#maxlength'] = 220; Here is an example using a custom module: function mymodule_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) { $node = $form_state-...


0

There is a module for that; you can use Views Dependent Filters which allows the presence of exposed filters on a view to being controlled by values in another exposed filter. Dependent filters are hidden when not relevant, and their values are not considered when the exposed form is submitted.


0

In Drupal 8 this works for me: (disable ajax for the field) $form['document'] = [ '#title' => $this->t('Document'), '#type' => 'managed_file', '#required' => TRUE, '#attached' => [ 'library' => [], ], ]; And add this to your_theme.theme file: (hide the upload button). /** * Implements template_preprocess_file_managed_file()...


Top 50 recent answers are included