texts: How can I create a custom field block to read from another field from the node?

texts:
I have a page created from views with several nodes. That page is created specifying which nids I want the view to load from. See this thread for details on that. Each node displayed on that page contains taxonomy terms. Each of those terms contain other nodes. Usually a small number like 2 or 3. So it kind of like this;

--------------------Main Page----------------

[Node A:(nid=20)]

Field1: Title
Field2: Image
Field3: Term (Spoons)
Field4: Related Node Image Block (Supposed to read Term from Field3. Created in views)

[Node B:(nid=30)]

Field1: Title
Field2: Image
Field3: Term (Knives)
Field4: Related Node Image Block (Supposed to read Term from Field3. Created in views)

[Node C:(nid=40)]

Field1: Title
Field2: Image
Field3: Term (Forks)
Field4: Related Node Image Block (Supposed to read Term from Field3. Created in views)

-------------------End of Main Page--------------

I created a custom field: Block. I added the block to read from each term, and pull the image used in the other nodes that share the term and link to them. Basically, the same product just of a different color.

-Things I've Tried-

Created a RELATIONSHIP filter; "Content: Taxonomy terms on node". Then created a contextual filter; "Taxonomy term: Term ID" to use that relationship. Didn't Work. (This is a method I used in ANOTHER view block created. But it works because the term is in the url. See next item. The page I created DOES NOT contain the term in the url.
I've seen code for previous versions of drupal. http://drupal.org/node/76923. But, I believe that for D7. They have removed the taxonomy_node_get_terms(). Looking to find a D7 Alternative to get the term from the nid of the current load.
Tried using this method but it didn't work either.

How can I create a block to read from a field from the node its loaded in? (See Field4 in the example)


texts:
I have a requirement in which the user should not be able to register to site, but only request registration by filling the form (first name, last name, email, company, etc.). The request should go to site admin's e-mail id. Using webform I have created the form, but I am not able to send it as email.

Also the "Per user submission limit" option of webform is decided by the IP address or cookie (for anonymous user), whereas I would like to limit the form submission by the e-mail ids of the submitting users. How can this be done?


texts: Determine the location of the snippet to be removed

texts:
I am absolutely unfamiliar with Drupal, but have a task of removing a snippet of code from one of its pages.

The snippet in question had been determined by Google Wabmaster tools to be malware, and I need to just delete it from the code.

How can I find that directory via FTP (or cPanel?)

Or perhaps there's some other, better – easier – way to remove the malicious snippet?

Thank you very much for your help!


texts: How can I hide certain values of CCK on node view page?

texts:
When a cck field can have multiple values I would like to hide certain values to print on node template.

For example,
If field_example has the value "red" "blue" "yellow" "black" "white"  I need to hide "black" and "white" and print only the rest on template file.


texts: Drupal Rooms - How to render the "Book This" form in a node reference full description?

texts:
I absolutely love this module, it works great and is exactly what I am looking for.

I am hoping to extend the functionality so I can render the "Book this" form on a referenced node rather than the bookable unit teaser. I want users to be able to book the room from the referenced node full description.

Here is what I have so far...

I have a content type called “Property display” which references a bookable unit type.
I have the “Rooms Availabity Reference” calendar rendering in the node full description.

What I need…

I would like the “Book This” button to be displayed on the full  node description underneath the rooms availability calendar. I understand that the form will need the correct dates added to it, but I am pretty good at Javascript, so I plan to validate whether the room is available by the user clicking on the availability calendar.

All I need is a little push in the right direction! I am happy to post my final code if anyone else is interested.

My best guess at the minute is to preprocess Product display node and call:

$booking_form = drupal_get_form('book_units_per_type_form', $units_per_type, $start_date, $end_date, $booking_parameters, $b_units, $type);

print render($booking_form);

I can then use Javascript to create a custom date widget that sets the $start_date & $end_date of the form, and validates whether the room is available. I need to know how to how to load in the bookable unit parameters of the referenced bookable unit in my node preprocess function. Or if there is an easier way. –


texts: Date field as dynamic source for contextual filter

texts:
I need a views block with a contextual date filter, based upon a date field of the currently viewed node.

What I've got so far:

I already have created my base view with base filters and sorting.
I've added a relation to the current node ("Get the actual content from a content revision")
I've added a contextual filter Content ID, using Content ID from URL as default value

But I don't want the current node in my views block, I need the next two nodes in my views block, and I don't know how to do this part of the contextual filter:

views_node.field_date > contextual_node.field_date

Concrete use case:

I'm displaying the full view of "event node A", and on that full view of node A, I want to embed a views block, showing the next two "event nodes B and C" after the date of event node A (for selecting and ordering nodes B and C I want something similar to this pseudo-query: select * from view_nodes where view_nodes.field_mydate > context_node.field_mydate order by view_nodes.field_mydate limit 2)


texts: Best way to Improve live site and then push changes from dev to live?

texts:
Currently I am applying a new Drupal theme on an existing site.
I have created a separate instance for Development and copied the live site database and started working.

The new theme requires many new features ( modules, blocks, views etc ). I am just writing down every thing and of-course I need to redo it on live site once the theming is completed.

Is it possible that my Dev database gets updated automatically if changes are made on live site?

So once the theming is finished, I can drop the live DB and replace with Dev DB? Seems like a dream to me ..

Any help ?


texts:
I've got a field collection with has a div wrapper with the classes "field-collection-container clearfix" I'd like to add an additional class to this div. How would I go about this?

I've tried this:

MYTHEME_preprocess_field(&$variables, $hook){
    if($element['#field_name'] == "FIELD_COLLECTION_NAME"){
        $variables["element"]["#prefix"] = '<div class="field-collection-container clearfix MY_CLASS">'
    }
}

But this doesn't seem to have any affect. I'm not sure what else to try, I also found an answer here https://drupal.stackexchange.com/a/142389/39899 but that doesn't seem to do anything either. The code I put above actually runs as I did a var_dump() and saw the results but when I tried that with the answer I linked to I got nothing.

[UPDATE]

Just to clarify, I'm looking specifically to amend the div with the class "field-collection-container" not add another wrapper. The reason being that I think it's just tidier to make use of the markup Drupal already outputs rather than just adding more do it.


texts:
I am writing a custom module for my Drupal 7 site. I have added the code to enable a configure form.

I want to restrict the config to admin users only, and some of the functions to another group of users. How do I go about doing this?

Any and all help greatly appreciated.


texts: Change of files/image location to a new organized structure

texts:
I would like to clean up safely the existing files Drupal 7 structure and change the location of my existing Files/Image to a new organized structure e.g. in files/content-type/year/node-id

Would File Path do this safely with its retroactive update, or is there another module out there?


texts: Adding additional dynamic to a canonical view

texts:
Wasn't sure exactly what to search for in trying to find recommendations for this.

I have created a custom content entity type with some numerical fields. The canonical view for this entity uses "views_data" = "Drupal\views\EntityViewsData" as specified in the entity definition annotation. This entity type does not depend on node. Some modifications are made to the display of the field data using hook_entity_view_alter and hook_page_attachments. This is all working fine.

What I would like to do is two things:

1) add an additional HTML section to the canonical view, below the display of all the entity parameters, which displays the results of a database query. The query being executed will depend on the content of the entity being loaded. Currently I am just using "echo" to test, but that spits the results out at the top of the document.

2) add a form to the canonical view containing one text field, one dropdown, and one button. The contents of the dropdown will also depend on the entity field content. The button should perform some calculations on the numerical fields based on the form inputs, and adjust the build array contents accordingly after reloading the page.

I am not really sure what approach to take here or how to execute it, and would like to ask for recommendations and examples to look at. Should I be creating a custom class that extends Drupal\views\EntityViewsData to accomplish all of this? Should I be doing this with Twig instead (which I am not very familiar with and can't seem to find many examples similar to what I'm trying to do)? Would using jQuery instead be a better approach?


texts: How do I create extra permissions for an eck created entity?

texts:
I have created an entity using Entity Construction Kit (ECK) and wish to add extra permissions for that entity such as view own, edit own and delete own. I see there has been some movement in this thread Better Permissions and a few others to create better permissions in general for entities but I want to know how can I do it in my own custom module.

I do not want every person on the site to be able to view,edit,delete so I have disabled those perms for my created entity.

I'm stuck and cannot find any good documentation on it.


texts:
I am building my first Drupal 8 module and wondering how to optimize work with multiple queries to the database?

$query = \Drupal::database();
$transaction = $query->startTransaction();
$product = new ProductController();

try {
  if (isset($_GET['pid'])) {
    $product->product_update($fields, $_GET['pid']);
  } else {
    $product->product_insert($fields);
  }
} catch (Exception $e) {
  $transaction->rollback();
  throw $e;
}

As you can see I am starting a transaction in order to reverse update of databese in case something went wrong and for this, I need to establish a connection $query = \Drupal::database(); but inside the try catch I am calling functions that again are calling \Drupal::database() :

public function product_update($fields, $id) {
$query = \Drupal::database();
$query->update('product')
  ->fields($fields)
  ->condition('pid', $id)
  ->execute();}

So my question is what is the correct way of working in such an approach?


texts: How to add extra option to the existing drush command?

texts:
I'm trying to add extra option to the existing command as below:

/**
 * Implements hook_drush_command_alter().
 */
function MYMODULE_drush_command_alter(&$command) {
  if ($command['command'] == 'features-revert-all') {
    $command['options']['cleanup'] = dt("Remove non-existing components from the database after revert.");
  }
}

However it seems it doesn't work as expected and drush fra --cleanup fails.

Then the help command doesn't show this option either.

What's the proper way of adding such option, so drush can understand it and can be available for further parsing via drush_get_option?


texts: node_publish_action is not publishing the node

texts:
I'm trying to add a submit handler to a "Done" button that should publish a node when the button is pressed. It's a scenario where the Rules module won't cut it, it has to be in code. I tried to following:

function mymodule_form_alter(&$form, &$form_state, $form_id){
  if($form['#form_id'] == 'my_node_form'){
    if ($form['actions']['done'] !== NULL){
      $user = user_load($form['uid']['#value']);
      $form['actions']['done']['#submit'][] = 'mymodule_publish_submit';
    }
  }
}

function mymodule_publish_submit($form, &$form_state) {
    $nid = $form['nid']['#value'];
    $node = node_load($nid, $vid = NULL, $reset = FALSE);
    node_publish_action($node, $context = array());
}

but it's not working. My debug text shows up so I know the submit handler is getting called. Where am I going wrong?


texts: Boost. What does "Minimum Cache Lifetime" mean?

texts:
In Boost module setting, there are

Maximum Cache Lifetime
and
Minimum Cache Lifetime

settings.

"Maximum Cache Lifetime" is like re-generate the page after that amount of time.

How about "Minimum Cache Lifetime", what does it do?

Updated:

Just a copy / paste from boost handbook for a reference.

Max: Default is 1 hour and can be increased for sites that do not change very much. The maximum cache lifetime is the maximum amount of time that will elapse before the cache is emptied. Cache lifetime gets checked on cron runs. Flushing the content before it is expired can happen, for example when a node is edited.

Min: [< none>] (select box) none is fine for small sites.
On high-traffic sites, it may be necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will elapse before the cache is emptied and recreated, and is applied to both page and block caches. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.


texts:
My site allows users to create content and share them with their friends. The relationships are created using UR module. The content type itself has a "Share:",a User Reference field, where the user can select multiple users, from their list of friends.
Then there is a view, in which users can see the content created by others and shared with them. The problem is that, well, they cant see it, i cant get my head around the filter. What would be the easiest way to filter this? I've come up with this: if the currently logged in users name is in the contents share field, the data is shown. How to implement this in the view?
Any help would be greatly appreciated!


texts:
How can i print a node meta description inside a block?

Tried to use tokens but can't figure out the right path...


texts: too many redirects in directory aside drupal

texts:
I installed drupal in a webroot where there were 4 directories:
_database
_demos
_test
_old

When I try to access to some of those directories there is a message:
"ERR_TOO_MANY_REDIRECTS"

My drupal htaccess is the default of Drupal 7.38 and using clean urls. Those directories doesnt have any index.html


texts: How should I structure a multiple-value Field Collection where each value is uniquely named?

texts:
I have a content type for a collage of six photos. For each photo there is a caption, a link, some link text, and the photo itself. The photos are of different sizes and in different places, and there can be only one photo in each spot per collage.

If I just use Field Groups, I have to create a different CCK field per photo per field, for a total of 24 fields.

If I use a single level of Field Collections I can get that down to six separate Field Collections and four CCK fields, but if I need to make a change that applies to all six photos, I have to make the change six times.

I can use two levels of Field Collections, with a main Collection that contains the four fields, and six other Collections named "Top Left", "Top Right", etc., each of which contains only the main Collection. This is maximally abstracted and would probably do, but it makes the node editing interface look like this:

Those redundant fieldsets are bothersome and are a dead giveaway that the underlying data is architected badly.

Using a single Field Collection that allows multiple values seems the most correct. It gets me down to one Field Collection and four fields. But the repeated groups don't have any identifying information other than their deltas, and if the client ever needs to add one they won't be able to keep track of which line corresponds to which spot in the collage.

Is there a way for me to put identifying information on each of the repeated values of a field or Field collection? Otherwise, is there a better way for me to do this?


texts:
I have to build a breadcrumbs, In fack I only need to add a breacrumbs between the "home" and the "books breadcrumbs" to get something like this:

  home>>view-path>>book-breadcrumbs-with-deep

I have try with paths breadcrumbs, with hansel, and with custom breadcrumbs, I don't get nothing.

There is another module, or I should make my own module?

Thanks

Oskar


texts: Drupal 7, creation of new node, how redirect to the edit page of the new node

texts:
When I create a new node in my website, I want to be redirect to the edit page of the new node.
I see several hook, but according to this post its not possible use drupal_goto..

Is there a way for me ? I prefer a programming approach
Thanks =)


texts: Drush tries to export config for modules I deleted months ago

texts:
I'm using Drush 9.3 and when I export config it wants to create config files for modules that have been gone for months.  One of those is plupload which is nice because it's easy to search the code base to see if I have anything that references plupload whatsoever.  I do not.  Yet when I run "Drush cex" it exports plupload.settings as well as settings for several other modules that are LONG GONE.  When I try to "Drush cim" on the staging server the import fails complaining that these modules do not exist.  I'm sure these modules are in fact referenced in the drupal database but I cannot figure out anywhere in the GUI to remove them, no option to uninstall Plupload from the uninstall page.  If I do install plupload using composer it appears as a module that can be enabled under the modules page, but still no option to uninstall or remove from the Drupal database.  What am I missing?  Why does Drupal think I still have these modules?

Thank you!!!


texts:
Now that Drupal 8 is going to be based mostly on Symfony, is the TDD / unit testing going to change too?

For Symfony, Lime is the preferred testing suite. Is that true for Drupal 8 too?


texts: Save multi value in multi value field programmatically

texts:
apologize every one , my code was correct , I had a mistake in content type .2 similar content type with 2 similar image field :P

but I let it and don't delete this because maybe be useful in futures

I want to save multi image in multi image field programmatically(I set number of value to 5)

Part of my code

        $node = new stdClass(); // Create a new node object
        $node->type = "prodcut_gift_display"; // Or page, or whatever content type you like
        $node->uid = $user->uid;
        $uri = file_build_uri($geturipath);
        $file = new stdClass;
        $file->uid = $user->uid;
        $file->filename = basename($uri);
        $file->uri = $uri;
        $file->filemime = file_get_mimetype($uri);
        $file->filesize = filesize($mainimg_url);
        $file->status = 1;
        file_save($file);
        $node->field_gift_image['und'][0] =(array) $file;
        /***************************************/
        foreach ($upimg_uri_path as $inx=>$upimgtemp){
        unset($file);
        $uri = file_build_uri($upimgtemp);
        $file = new stdClass;
        $file->uid = $user->uid;
        $file->filename = basename($uri);
        $file->uri = $uri;
        $file->filemime = file_get_mimetype($uri);
//        $file->filesize = filesize($mainimg_url);
        $file->status = 1;
        file_save($file);
        $node->field_gift_image['und'][$inx+1]=(array) $file;
        }

        /***************************************/

Then I try to get drupal_json_output , it seems node and image field with 2 value is  ok but only one value saved in field.where is the problem?(I check and sure that my image field is set multi and can get 5 value )

update
Also I try

$uri = file_build_uri($geturipath);

        $imgs_paths[]=file_create_url($uri);
        /***************************************/
        foreach ($upimg_uri_path as $inx=>$upimgtemp){
        unset($file);
        $uri = file_build_uri($upimgtemp);
        $imgs_paths[]=file_create_url($uri);
        }

   foreach ($imgs_paths as $i=>$img) {
    $file_info = system_retrieve_file($img, 'public://pictures/', TRUE, FILE_EXISTS_REPLACE); //storing image inside picture folder
    if ($file_info->fid) {//if fid exist then image is saved from URL.
      $node->field_gift_image['und'][$i]['fid'] = $file_info->fid; //assign image
    }
  }
        /***************************************/
        $node->field_product['und'][0]['product_id'] = $my_prodcut->product_id;
        $node->title = arg(1) . '-' . rand(1, 999999);
        $node->language = 'fa';
        $node = node_submit($node);
        node_save($node);

Also my field settings


texts: Can I force the user profile to render in a language other than the current user's language?

texts:
I am trying to render user profiles in both English and Japanese in user-profile.tpl.php:

$render = user_view($user, 'nopic', 'en');
print render($render);
$render = user_view($user, 'nopic', 'ja');
print render($render);

However, this always returns the translated version of the user's profile twice for the logged-in user's language (both Japanese if viewed from a Japanese language account, and both English if viewed from an English language account).

Is it possible to force the output to render the profile as if viewed from a user with a language other than the account language?


texts: Change print icon programmically through template.php

texts:
I'm using the Print module, version 7.2, and trying to change the icon through the template.php.
After researching, I have found the main functionality in the FAQ of the module, which provides this:

The example below is for the 6.x-1.x and 7.x-1.x branches. In 7.x-2.x
the theme function is theme_print_ui_format_link.
You will have to define a theme_print_format_link function which will replace
the module's function with the same name and where you can indicate your
custom-defined icon, and set the html element to true so that your
image tag is interpreted as HTML. See the following for an example:

function theme_print_format_link() {
  $print_html_link_class = variable_get('print_html_link_class', 'print-page');
  $print_html_new_window = variable_get('print_html_new_window', 0);
  $print_html_show_link = variable_get('print_html_show_link', 1);
  $print_html_link_text = filter_xss(variable_get('print_html_link_text', t('Printer-friendly version')));

  $img = local_path_to_your_img_file;
  $title = t('Display a printer-friendly version of this page.');
  $class = strip_tags($print_html_link_class);
  $new_window = $print_html_new_window;
  $format = _print_format_link_aux($print_html_show_link, $print_html_link_text, $img);

  return array('text' => $format['text'],
               'html' => $format['html'],
               'attributes' => print_fill_attributes($title, $class, $new_window),
              );
}

If I don't change the code at all, it never gets called.

If I change the first line to subtheme_print_ui_format_link() {, it gets called, but then I get the error
Fatal error: Call to undefined function _print_format_link_aux() in ...../public_html/sites/all/themes/subtheme/template.php on line ...

I have tried:

subtheme_print_format_link_aux()
_subtheme_print_format_link()
_print_ui_format_link_aux()
_print_ui_format_link()

and a bunch of others instead of _print_format_link_aux(), but error just replaces the first function with the one I tried.
Note: I have have changed local_path_to_your_img_file to 'images/print_icon.png'


texts: PDOException when setting field value in node presave

texts:
I have a hook_node_presave implementation to set the value of a node field based on one of the user-entered values.

The code for it looks like this:

function er_pr_node_presave($node) {
  .....
  foreach($nameResult as $row) {
    $node->field_co_pi[LANGUAGE_NONE][$i]['value'] = intval($row->entity_id);
  }

  dpm($node);
}

With the dpm function I can see the values in the node, and the correct value is set to the field_co_pi field. However, the placeholder field doesn't get set when the insert query for that custom field is ran, resulting in a PDOException:


texts: Is a block render array built with EntityViewBuilderInterface::view supposed to render full block template or only inner fields?

texts:
After rendering custom blocks in templates, I got this js error:  Quick Edit could not associate the rendered entity field markup. What I've done so far :
In order to render repeatedly custom blocks in templates, I wrote this function in mytheme.theme :
function render_block_in_template($block_id) {
  // $block = Drupal::entityTypeManager()->getStorage('block_content')->load($block_id);
  $block = Drupal\block_content\Entity\BlockContent::load($block_id);

  if(!empty($block)) {
    $block_content = Drupal::entityTypeManager()
      ->getViewBuilder('block_content')
      ->view($block);

    if($block_content) {
      // kint($block_content);
      return $block_content;
    }
  }
}

And I call it in mytheme_preprocess_node :
function mytheme_preprocess_node(&$variables) {
  $node = $variables['node'];

  if($node->bundle() == 'some_bundle') {
    $variables['some_block'] = render_block_in_template(12);
    $variables['some_other_block'] = render_block_in_template(13);
    // ...
  }
}

Then I render the blocks in node--some-bundle.html.twig :
{{ some_block }}
{{ some_other_block }}

So far so good. But I got this js error from quickedit.js :

Error: Quick Edit could not associate the rendered entity field markup
(with [data-quickedit-field-id="block_content/12/body/fr/full"]) with
the corresponding rendered entity markup: no parent DOM node found
with [data-quickedit-entity-id="block_content/12"]. This is typically
caused by the theme's template for this entity type forgetting to
print the attributes.

Which brought me to this issue : Custom blocks break layout builder module - Quick Edit could not associate the rendered entity field markup, but applying the patch did not change anything, and further reading let me thing this is not exactly related.
If I {{ kint(some_block) }} in twig, the #attributes key with expected values is here :

and this is the HTML output :

// FIELD CONTENT

Last, manually wrapping it with the following removes the error :

So it appears that the above wrapper part of block template is not rendered, only the fields are and it causes the error.
Is there indeed a bug or am I doing things wrong ?


texts: Changing value of a field before rendering in Drupal 7

texts: I am trying to change the value of a field. I need to add a dynamic class on-the-fly, based on some complext context, and I need to warp the text value with the span-class-stuff. But I haven't been able to alter the value, even if I am able to read it. I use MYTEMPLATE_preprocess_page(&$variables, $hook), MYTEMPLATE_preprocess_field..., even some hooks in my modules, but to no avail. I am unable to change it. What would be the best and effective approach?


texts: How to create a rule that unpublishes comments that contain links?

texts:
I'm trying to create a rule that does the following.

Event: After saving new content type Forum Topic
Conditions:

User has role 'authenticated', and
Content body contains link (this is the part I can't figure out)

Actions:

Unpublish Content
Show a message on the site:

  "Your user permissions currently do not allow for you to post a forum topic that contains a link. Please remove all links from your post and re-submit by clicking the following edit link: [node:edit-url]

  This precaution helps us keep our forum and comments spam free. If you would like the ability to post links, please e-mail the site admin: [site:mail]"

The general idea is that I want users to register to the forum and be able to create new forum topics but not be allowed to post links since this is the whole purpose behind spam. Once they make a few quality posts, I'll move them to a trusted user group that this rule doesn't apply to, allowing them to post links.

The reason why I don't want to use Text Formats to strip out  tags is because the spam post will still be published, minus the links. This will lead to offensive, spammy posts still showing up in the forum index.


texts: How can i authenticate a user without using Drupal functions?

texts: I need to authenticate a D7 user from a php page from outside a Drupal session. In D6 i could have used the md5() function, now i've seen that this is not possible due to changes to D7 authentication. How can i do it without using Drupal functions?


texts: Is the HybridAuth plugin supposed to update the user info after each login

texts: The reason I ask is that I never see my username info, user picture or region information update on my site.  I only have Facebook enabled and successfully login.


texts: How to create a fields on the users profile to allow them choose from a number of opens then order them based on preference

texts:
On the users profile, I need to add the ability for users to select from a number of options, then order them based on their preference.

e.g.

What are your favorite fruits?

Select from:

Apples

Bananas

Oranges

Grapes

Then I need the users to be be able to reorder them in terms of preference:

e.g.

Grapes

Bananas

Apples

Any thoughts on how to achieve this (existing modules)?


texts: How do I check the value of a field if its empty?

texts:
Is there a way to check, in a preprocess function, if the value of a field is empty?

I'm getting the following error.

  Call to a member function isEmpty()

function iom_preprocess_block__twitterfeed(&$variables) {
  // Get the twitter_username field from node.
  $twitterUsername = \Drupal::routeMatch()
    ->getParameter('node')
    ->get('field_twitter_username')
    ->value;

  if ($twitterUsername->isEmpty()) {
    dump("Empty");
  }
  else {
    dump("Not Empty");
  }
}


texts: Override a node template and its associated translation

texts:
I'm trying to understand how to override a node template in order to "catch" also all the associated node translations.

Let's say I have a node/12 in English and its translation is node/13. To override in the same way both nodes I have to create templates/node--12.tpl.php and templates/node--13.tpl.php inside my theme folder.

Is there a way to avoid this, since the customisations I plan to implement on the node and its translation are the same?


texts: dump(), kint() & print_r() are not working in .theme file

texts:
I've used drupal 8 with devel module. I want to change some values dynamically in views fields. So i tried to use theme_preprocess_views_view_fields(). When i tried to print variables using print_r(), kint() & dump(), no one print values.

/**
 * Implement theme_preprocess_views_view_fields().
 */
function galip_preprocess_views_view_fields(&$variables) {
  $view = $variables['view'];
  print_r($variables['fields']);exit;
}

I've enabled debug mode true in services.yml file. But i can't get any variables. How can i get variables?


texts: Different theme of Media module audio player in Firefox and IE and chrome

texts:
I installed Media module, and there is a content type for audio files. The Manage display of the audio field is Audio. But the player has different themes in different browsers. This is what Firefox displays

This is for IE

and it is chrome

What is the problem? why do they have not the same theme?

thanks


texts:
I have created a content type called 'Home' and I also create a new file called, node-home.tpl.php.

What I understood from the drupal documentation, that when a Node has the content type it should use node-contenttypename.tpl.php as the node template file, if it exists.

But mine isen't working and its defaulting back to node.tp.php.

Any idea what I'm doing wrong?


texts:
I'm having the following issue trying to create nodes from Drupal 7 to a Drupal 6 install. The target Drupal site is running Services 3.x.

Here's my code:

$base_url = $params['path'];
$data = array(
  'username' => $params['username'],
  'password' => $params['password'],
);
$data = http_build_query($data, '', '&');
$headers = array();
$options = array(
  'headers' => array('Accept' => 'application/json'),
  'method' => 'POST',
  'data' => $data
);

$response = drupal_http_request($params['path'] . '/user/login', $options);
$data = json_decode($response->data);

// Check if login was successful
if ($response->code == 200) {
  // Now recycle the login cookie we recieved in the first request
  $options['headers']['Cookie'] = $data->session_name . '=' . $data->sessid;

  // Create a new node
  $data = array(
    'node' => array (
      'type' => 'cloudnode',
      'title' => 'node1',
      'field_ip_address' => array ('value' => '1.2.3.4'),
    )
  );
  $options['data'] = http_build_query( $data, '', '&');
  $options['method'] = 'POST';
  $response = drupal_http_request($base_url . '/node', $options);
}
else {
  die ('Failed to login');
}

I get a 200 response; the node is being created, but somehow it doesn't take care of my 'field_ip_address' CCK field at all.

I've tried any kind of variations but they don't work. There is not much documentation around as well.

If anyone has succeeded in creating nodes using REST, I would be very interested for any help.


texts: wrong translation in admin/structure/views

texts:
I have a multi language site with Drupal 8.7.4
and default language is English.

when i go to en/admin/structure/views i see list of views in English language. if i go to french interface via fr/admin/structure/views i expect to see list of views in french words for example i expect to see 'Surveillance' instead of 'watchdog' but i see all views name in English.

Config Translation is enabled and french translation for view's name is available.


texts: How to combine two batch operations for views data export into one?

texts:
I have been using a custom module that was posted here:

https://www.drupal.org/node/1875456

I slightly modified this module and created two copies of it, as I have two views and planning to add third one but it currently doesn't work properly so let me explain:

dvm_reports module#1 for Denmark

function dvm_reports_views_data_export_batch_alter(&$batch, &$batch_redirect) {
  $view = views_get_view($batch['produkty_denmark_xml']);

  // Add in another operation that will store the file on the server in a location
  // of our choosing.
  $batch['operations'][] = array(
    'dvm_reports_views_data_export_batch_finish', array($batch['eid']),
  );
}

function dvm_reports_views_data_export_batch_finish($eid) {
  $export = views_data_export_get($eid);
  $view = views_data_export_view_retrieve($eid);
  $view->set_display($export->view_display_id);
  $view->display_handler->batched_execution_state = $export;
  $view->display_handler->remove_index();

  // Get path to temp file
  $temp_file = $view->display_handler->outputfile_path();
  file_unmanaged_copy($temp_file, 'public://denmark.xml', FILE_EXISTS_REPLACE);
}

It starts to generate the file correctly when I go to domain.com/denmark

dvm_reports module#2 for Sweden (I copied the denmark module and renamed it from "dvm_reports" to "dvm_reports2")

function dvm_reports2_views_data_export_batch_alter(&$batch, &$batch_redirect) {
  $view = views_get_view($batch['produkty_json']);

  // Add in another operation that will store the file on the server in a location
  // of our choosing.
  $batch['operations'][] = array(
    'dvm_reports2_views_data_export_batch_finish', array($batch['eid']),
  );
}

function dvm_reports2_views_data_export_batch_finish($eid) {
  $export = views_data_export_get($eid);
  $view = views_data_export_view_retrieve($eid);
  $view->set_display($export->view_display_id);
  $view->display_handler->batched_execution_state = $export;
  $view->display_handler->remove_index();

  // Get path to temp file
  $temp_file = $view->display_handler->outputfile_path();
  file_unmanaged_copy($temp_file, 'public://produkty.json', FILE_EXISTS_REPLACE);
}

it starts to generate the file correctly when I go to domain.com/sweden

Problems:

I would like to combine those two modules into one but I don't know how to do it.

Please advice if you can


texts: Disable registration functionality for sub-domain in Drupal 7

texts:
I am using Domain access module for my multi-site creation and using common database for both the site:

1. example1.com (Default domain)
2. example2.com (sub domain)

I want default registration functionality for default domain (example1.com), but don't want this functionality on sub domain (example2.com).

If I configure this registration functionality only for Administrators from admin section (Home » Administration » Configuration » People) from default domain (example1.com) look like below screenshot:

Then this will be applicable for both example1.com and example2.com, as I am using common database and common tables for both the sites.

So can anyone please guide me how can I disable the Registration functionality for sub domain (example2.com) and use this same for default domain (example1.com).

Thanks in advance.


texts:
I have a newspaper web based management system that allow users to manage articles and news and photo album using J2EE (Internal system to the newspaper)

I need to make a website using drupal 7 to this newspaper

I need to make a button in the J2EE system that will save a node in my site(plain text,Full html test,files like images and pdf)

So I need to make a webservice in my drupal site and call it from the J2EE

Is there any module that help me in this issue,if not how to customize it.


texts: Creating Multifield Search with Apache Solr Search

texts:
I'm using Apache Solr Search on Pantheon and trying to figure out how I can create an "advanced" multifield search.

For example if I have a content type called Location, with "city" and "state" fields, how can I make those fields part of the search form, similar to an exposed filter in Views?

I successfully installed and setup Facets using Facets API module, but those just add clickable links. I'm looking for the user to be able to search by multiple fields.

I also tried the Apache Solr Views Integration module, but that only allows text fields as exposed filters.

If anyone has suggestions, documentation, or a tutorial on how to do this that'd be great. Obviously I could do it with Views but I do not want these searches hitting the Drupal database.


texts: How to check if node is being rendered inside view?

texts: I need to check inside node template if its contents are being rendered through view or not. What is the best approach to do it?


texts:
I want to hide the description of the text format under the "Comment" box which says:

No HTML tags allowed.
Lines and paragraphs break automatically.

There are a variety of ways to do this on Drupal 7, but what about Drupal 8?


texts: How do I sort nodes in node_view_multiple()?

texts:
I created a block with node teasers loaded with node_view_multiple($nodes).

Now I want to order the results:

By Node ID
By the time is was created/updated
Random

Of course I can order them with PHP array functions, but is there a Drupal specific way to do it?


texts: Drupal Commons, can't break-contact error

texts:
I am using Drupal Commons (7.x-3.46).. Whenever trying to  "break contact" of a trusted-contacts, I get an error:

  An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=19&op=do StatusText: Service unavailable (with message) ResponseText: EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. Value at og_membership(): . in EntityDrupalWrapper->set() (line 756 of C:\Users\USER\Sites\commons-7.x-3.46or\profiles\commons\modules\contrib\entity\includes\entity.wrapper.inc).

An authenticated user can't break-contact at all. Trying as an administrator, it throws the error, but does complete the operation, and does breaks the contact.
This seems (to me) to be a crucial issue. If users can't remove a contact, I dare-not give them the possibility to add contacts in the first place..

At some point I thought it was all about VBO, so (I think) I uploaded the dev version of it, but I'm still getting the same behavior.
Also, changing the php version as suggested somewhere, made no difference.

In my search for a solution I've come across many similar issues, some of which I've listed below. But I haven't found the very same issue I'm facing, and with so many different solutions I'm not sure where to start. In some posts it's about views-bulk-operations. In others it's about the Entity module. Or about Organic Groups. Or indeed about the Trusted-Contacts module itself.
As I'm no patching-guru, I'm uncertain of how to proceed

Similar but not identical issues:

Views bulk operations interrupted due to insufficient rights
https://www.drupal.org/project/commons/issues/2588155
https://www.drupal.org/node/1925412
https://www.drupal.org/project/views_bulk_operations/issues/1871702


texts: Controlling file paths in multi domain setup

texts:
A site responds to internal.example.com, and external.example.com.

Content editors all use internal. When Drupal generates the cached output, all images are now absolute URLs pointing to an internal domain, making them fail.

How would you handle this?


texts: How do I use a core class from an external script?

texts:
I am trying to access a node programmatically and getting errors though using (AFAIK) the recommended way.
My code (so far) is really simple.
use Drupal\node\Entity\Node;

$nid=1805;
$node = Node::load($nid);
print_r($node, true);

It keeps failing with this error message.

[09-Nov-2020 08:32:31 UTC] PHP Fatal error:  Uncaught Error: Class 'Drupal\node\Entity\Node' not found in test-node-access.php

The program resides (at least currently) in Drupal root directory. I am acting on user action via AJAX call from a paragraph (as a lame explanation to a little un-orthodox implementation).


texts: Drilldown search with Search API and Facets

texts:
I have a type 'projects' referencing two other types ('kustomer','products') via entity reference.
Now I want to implement a drilldown search.
I therefore use search API with facete api. I build a index and a view for Type 'project'. The filtering works well on this view. I have facetes for types 'customer' and 'product' and can filter.

The target is a workflow where you start at a list of 'products'. When you select one you will get a list of 'customers' where a 'project' exists that contains that 'product'. After that you select a 'customer' and you get a List of all 'project's having that 'product' and 'customer' preselected as facetes.

Can someone point out a module or configuration that does that?
Thanks in advance
Clemens


texts: I've added a new theme to my site and I've added a new content type called code_excerpt. Now, I've created a new template called code_excerpt.tpl.php and added it to my theme folder but when I created a new page using the newly created code_excerpt as content type it appears that the template used is still page.tpl.php as opposed to code_excerpt.tpl.php. As I'm pretty new to drupal, is there anything else that I need to do in order to get my content type to utilize that template? Any suggestion would be much appreciated.


texts: How to redirect toward a specific node from front-page in Drupal 7?

texts:
I have a multi language site made in Drupal 7. And I want to check if I am on the front page then if true to redirect the user to a to some specific node.

I have tried different methods:

to create a page front--page.tpl.php and then to check language and then redirect
I have put this code in page.tpl.php:

 global $language;

 if ($node->nid == 1) {
     if ($language->language == "en") {
         header('Location: en/home');
     } elseif ($language->language == "fr") {
         header('Location: fr/accueil');
     }
 }

I am using i18n module for Drupal 7 so I have tried also to use $conf['i18n_variables'] in settings.php like that:

  $conf['i18n_variables'] = array(
     'site_frontpage',
     'site_name',
  );

But I have not succeed to do it. Have you any suggestions ?


texts: cache keys $cid naming practices (cache_set and cache_get)

texts:
For using cache_get and cache_set

According to this comment

  The convention seems to be to use colons to create a sort of
  namespacing. So your module may want to do something like $cid =
  'mymodule:mything:50';

so:

is ':' the recommended delimiter?
should the module name go first? (seems sensible)?
are there characters to avoid?
are there other considerations?


texts: Use hook_cron to send daily mail but I get 4~5 the same mail every day?

texts:
I'd like to make all of my partners in my company receive daily metrics like new users, pageviews everyday, I wrote a custom module using hook_cron.

This is my code:

function custom_metrics_cron() {
  global $language;

  $default = strtotime('-24 Hours', REQUEST_TIME);
  $last_send  = variable_get('custom_metrics_daily_last_send', $default);
  $only_after = strtotime('+24 Hours', $last_send);

  if (REQUEST_TIME >= $only_after) {
    variable_set('custom_metrics_daily_last_send', REQUEST_TIME);
    drupal_mail('custom_metrics', 'daily', MAIL_RECIEVERS, $language);
  }
}

function custom_metrics_mail($key, &$message, $params) {
  $date = date('m-d-Y', strtotime('-1 Day', time()));
  $metrics = custom_metrics_get_metrics();
  switch($key) {
    case 'daily':
      $message['subject'] = t('Daily Metrics: !date', array('!date' => $date));
      $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
      $message['body'][] = custom_metrics_get_metrics();
      break;
  }
}

It works okay, I get the mails everyday, but the problem is I get not only one mail, I already set the variable and make it send ONE mail every 24 hours but I still get 4~5 mails every 24 hours. Can anyone tell me where does I do wrong?


texts: Ajax on a webform affecting comment form and user-registration form

texts:
I have Ajaxified a webform using a (hook) custom module. The code used is:
 function alterwebform_form_alter(&$form, &$form_state, $form_id) {

    //see if webform_client_form_ is in the form_id

    if(strstr($form_id, 'webform_client_form_')) {

      //get the nid so we can use it in the wrapper value

       $nid = $form['#node']->nid;

        $form['actions']['submit']['#ajax'] = array(
            'callback' => 'alterwebform_webform_js_submit',
            'wrapper' => 'webform-client-form-' . $nid,
            'method' => 'replace',
            'effect' => 'fade',
     );

  $form['#validate'] []='alterwebform_test';
      }
    }

The code in the callback function is:
function alterwebform_webform_js_submit(&$form, &$form_state, $form_id) {

  // define the $sid variable (submission id from webform)
    $sid = $form_state['values']['details']['sid'];

 // sid to know the form was properly submitted

    if ($sid) {

  //load up the webform node object

     $node = node_load($form_state['values']['details']['nid']);

  //create an array with the confirmation message of webform
        $confirmation = array(
                 '#type' => 'markup',
                 '#markup' => check_markup($node->webform['confirmation'], $node->webform['confirmation_format'], '', TRUE),
                     );

  // return the confirmation message
    return $confirmation;
    }
  else {
   // return the form
       return $form;
        }
    }

The web-form works fine . The problem is: The AJAX code above is affecting other forms (Comments form and User Register form).

How is it affecting ?

If other (comment and user-register) forms are submitted successfully in the first time then its fine. But if there is some error in the first time and we submit second time, then  click on submit does not perform any action but show ajax effect.
The click on submit button now shows ajax kind of affect but is without any action.

As you can see in the picture, the ajax affect comes in this form. This happens if someone is clicking the button the second time (because of some error on first time).
What could be the possible reason for this and how should I fix this? Thank you in advance.


texts: Multiple results being returned using search for same node

texts:
I have a view-based search in my site. I notice that when I type a phrase like so "search terms" or even just search terms (no quotes) into the search box it returns all results that match that exact phrase as you'd expect BUT it also returns multiple versions of the same node!

I checked to make sure they are the exact same node and I think they are. One of these nodes is returned 6 times. I clicked on each linked result and the pathauto-altered URL is exactly the same for each. So for some reason it's returning it 6 times and I don't know why. Other nodes get returned fewer times. Some don't get returned more than once. I've checked some of the items that get returned multiple times in the mysql database and they appear to only be in there once...

I've cleared caches and run cron/re-indexed site...nothing.

I've got into 'find content' and looked to see if there are multiple copies of the nodes. Nope just the one.

And if, when I search, I just search for one word in the profile it only returns it once.

However, when I search for multiple terms I get multiple copies. I've reviewed the SQL of the returned view and it doesn't look like anything funky is going on.

Any idea why this might be happening?


texts: Updating / Pushing Changes to a Views from Local to Staging Server?

texts: I'm working on a complex view which is from an existing view that currently just needs a bunch of fields and exposed filters added. I have it working on my local desktop and now I want to make these same changes on the Staging/Dev server. How can I update the server without doing everything from scratch?


texts:
I'm trying to create a little module that operates on similar principals as a shopping cart, but has nothing to do with e-commerce. I want to add paired values to $user->data['cart'] on a very frequent basis. Everyone seems to agree that hook_user_presave is the way to do this. My question is this, when does hook_user_presave trigger? Can it be called from inside another fucntion or an .inc file, or does it happen on pageload? I am absolutely befuddled, since I thought hooks were basically event handlers for Drupal Core.

Can I, say, do the following?

test.module:
<?php
function mymodule_user_presave (&$edit, $account, $category) {
    $edit['data']['cart'] = $edit;
}
/* ... */

test.inc:
<?php
/* ... */
function mysavefunction () {
  $myvar = array('sweetdata' => 5);
  $account = user_load($user -> uid);
  mymodule_user_presave ($myvar, $account)
}
/* ... */

If you could even point me to some documentation other than this useless api page, I would be greatly in your debt.


texts: Create a simple module to retrieve record from database?

texts:
I need to create a simple module to fetch some record from database related to a node.

I have product nodes and users who makes bids in this product. Then at the time I load a product I need to retrieve all bids in this product to show them in a block.

I need some start guide/documentation to do it.

This is my first module attempt and this is the code I start working with: no error yet but it doesn't print out the values I need.

function myModule_load($node){

$result = db_query("SELECT * FROM {uc_auction_bids} WHERE nid = :nid", array(':nid' => 258,));
$record = $result->fetch();

// print the fields/values of $record
print('<pre>');
print_r($record);
print('</pre>');

}

Any help for creating this simple module, please?

I just need to know which is the right function/hook where I can fetch the data from the database, and prepare the data to create the block.


texts:
Problem

I have a lot of pages with standalone forms. Because of webdesign issues I ended up using the form element to style.

The problem is certain actions cause the form-id to change.

<form id="user-profile-form">

 //a failed file upload causes the above to become

<form id="user-profile-form--2">

Which breaks a lot of my css.

An example form HTML profile:

<form id="user-profile-form" accept-charset="UTF-8" method="post" action="/drupalie/user/184/edit" enctype="multipart/form-data">
    <div>
        /*form is built in here*/
    </div>
</form>

Is there a way to add a CSS class to my form, add a class to the empty div which surrounds all the form elements or as a last resort, prevent the form increment on certain forms.


texts: How to get a link to entity_reference in ListBuilder?

texts:
I have a custom entity (Person) with these fields: ID, nom, prenom, telephoneportable, estactive, adherentid, userID, created, changed.
I created it with baseFieldDefinitions.

adherentid is a 'entity_reference' link to another custom content entity 'Adherent'.
userID are is a 'entity_reference' link to standard Drupal 'User' entity.

In the PersonListBuilder, I try to have these ids showed as links to the corresponding entities.

Here is the code for userID (and it's working fine):

$row['userid']['data'] = array(
'#theme' => 'username',
'#account' => $entity->getUser(),
);

What should be the code for adherentid (can't make it work so far):

$row['adherentid']['data'] = array(
'#theme' => '???',
'#account' => $entity->getAdherent(),
);

Thanks in advance


texts: Does AJAX callback functions work differently for BEF views?

texts:
I am breaking my head since last two days to implement dependent drop down list. I have followed so many examples in the internet, SE and examples project but for some reason the simple thing isn't working. So I got doubt that the different could be because I am trying to alter an BEF Form.

What I am trying to do is to alter the better exposed form element to populate with locations (second dropdown)of selected city (first dropdown). It looks like there is some ajax call being made because I get the "Please wait..." with spinning icon is displayed but in the end second drop down remains unchanged.

After so much tries I at last decided to test the code with drupal examples project. I have simply put the code into my hook_form_alter (with small tweeks like changing function,elements names etc)  to see if it works. But unfortunately it isn't working so that put me in doubt whether the callback function is called or not so I just added a die statement in the callback function and I got no php error meaning that call back never called.

Is there any different implementation for ajax for BEF views? also my form is themed does it also has any impact?

This is how my form looks like after adding the hook_form_alter. You can see the two new form elements are added in the bottom.

  Update:

  I can see ajax errors in the recent logs which doesnt give much useful information

Location  http://localhost/system/ajax
Referrer  http://localhost/
Message   Invalid form POST data.
Severity  warning

Below is the complete code

function tdyards_form_alter(&$form, &$form_state, $form_id) {

    if ($form['#id'] == 'views-exposed-form-apartments-page-6' /*|| $form['#id'] == 'views-exposed-form-apartments-city-search-results-page'*/) {

        $firstoptions = first_dropdown_options();

        $selected = isset($form_state['values']['first']) ? $form_state['values']['first'] : key($firstoptions);

        $form['first'] = array(
            '#type' => 'select',
            '#title' => 'Instrument Type',
            '#options' => $firstoptions,
            '#default_value' => $selected,
            '#ajax' => array(
              'callback' => 'first_call_back',
              'wrapper' => 'second-replace',
            ),
          );

        $form['second'] = array(
            '#type' => 'select',
            '#title' => $firstoptions[$selected] . ' ' . t('Instruments'),
            '#prefix' => '
',
            '#suffix' => '
',
            '#options' => second_dropdown_options($selected),
            '#default_value' => isset($form_state['values']['second']) ? $form_state['values']['second'] : '',
          );

    }
}
//
function first_dropdown_options(){
    return drupal_map_assoc(
            array(
              t('String'),
              t('Woodwind'),
              t('Brass'),
              t('Percussion'),
            )
          );
}
//
function second_dropdown_options($key = '') {
  $options = array(
    t('String') => drupal_map_assoc(
      array(
        t('Violin'),
        t('Viola'),
        t('Cello'),
        t('Double Bass'),
      )
    ),
    t('Woodwind') => drupal_map_assoc(
      array(
        t('Flute'),
        t('Clarinet'),
        t('Oboe'),
        t('Bassoon'),
      )
    ),
    t('Brass') => drupal_map_assoc(
      array(
        t('Trumpet'),
        t('Trombone'),
        t('French Horn'),
        t('Euphonium'),
      )
    ),
    t('Percussion') => drupal_map_assoc(
      array(
        t('Bass Drum'),
        t('Timpani'),
        t('Snare Drum'),
        t('Tambourine'),
      )
    ),
  );
  if (isset($options[$key])) {
    return $options[$key];
  }
  else {
    return array();
  }
}
//
function first_call_back($form, $form_state) {
  die("call back function"); //added for testing
  return $form['second'];
}


texts: Set up Drupal to use alternative nodes for different incoming urls?

texts:
I have a Drupal website set up selling a single product. Currently the transactions are being processed with paypal with simple buttons set up on a specified node (e.g. www.website.com/buy).

I want to start a referral or affiliate system so that drupal will notice the different incoming links (www.website.com/referral) and will then always route (www.website.com/buy) to (www.website.com/buy_referral) once it detects the different incoming links. This is because I will set up different PayPal buttons for different referrals on different buy_referral nodes.

Is there a module available to do so? or is there an easier way to do things?

Thanks for the help.


texts:
I'm using Drupal 7. I have a CCK field called Placement Date (Placement_Date) that the end user will manually put in. I then have two text fields, Start_of_Period and End_of_Period. Start_of_Period initially is set to Field->Placement_Date and Field->End_of_Period is set to 90 days out. The setup is no problem, but after 90 days Field->Start_of_Period needs to be the old End_of_Period + 1, and Field->End_of_Period needs to be another 90 days out from the new Field->Start_of_Period. I looked to Rules to try to find a way to schedule this, but cannot figure out what I need to be doing.

Any help would be greatly appreciated. Thanks in advance.


texts: How to use different fields for different content types in a view

texts:
I want to construct a view which will include nodes from several content types.

For each different content type, I want to display different fields (say an image for a type, a video for another, some different text for others)

Let me show you the example I want to achieve:

row 1 is "image", row 2 is "video", row 3 is "event" content type. So,

John shared a new image:
IMAGE
Jane is watching a video now:
VIDEO
Jack is thinking "this day is sunny".


texts: Index View donot show 'Contains' operator for (exposed) filter

texts:
I have created an indexed view, for facet search.
Now I want to put a text field from which search provides a result, that contains that string from the title.

Now, title here donot have operator, 'Contains' which is required to filter matching titles.

I am using Global Populate filter as exposed filter.
I tried using hook_views_query_alter which donot work with index view of search api.
How should we do this?


texts: How do I restrict uploaded images to a specific aspect ratio?

texts:
What I would like to do is, using the Image field in core, to restrict uploaded images not just on resolution, but also on aspect ratio.

In other words, the image must be 2:3 width to height, and at least 200 by 300 pixels.

I know that Image Styles can manipulate the way an image is viewed. I'm not interested in that. Rather, I want to restrict uploads the same way that you can currently set min/max settings for resolution, I want to add aspect ratio.

My guess is that I'll need to write my own module to add a new check to Image's checks, but perhaps you know of a simpler way.


texts: Cloning nodes between multisite instances with separate databases

texts:
I'm working on a Drupal 8.6 multisite and my client wants to be able to duplicate content between many of these sites. The codebase of the websites is the same, but each of them uses a different database. For that, I made a module with some hooks that gets the node serialized and posts it to another site. code below:

function a8_replicate_node_insert(Node $node) {
  $type = $node->getType();

  if($type == 'event')
  {
    $portals = $node->get('field_duplicate_to_portal')->getValue();
    $serializer = \Drupal::service('serializer');
    $data = $serializer->serialize($node, 'json', ['plugin_id' => 'entity']);
    $data = json_decode($data); // make it array again

    foreach ($portals as $url) {
      try{
        a8_replicate_post_to_other_site($url['value'], $data, 'insert');
      }
      catch (\Exception $e){
        die($e->getMessage());
      }
    }

  }
}

The a8_replicate_post_to_other_site function just uses curl to post the data as json to the other website. Then I made another module to receive the content, with the following function:

  public function receive() {
    $ip = \Drupal::request()->getClientIp();
    // to make sure it's the machine posting to itself
    if($ip == '127.0.0.1') {
      $data = json_decode(file_get_contents('php://input'), true);

      if($data['action']=='insert') {

        $node = Node::create($data['node']);
        $node->save();// <<<< error happens here
      }
    }
  }

It's my first Drupal development and I'm I don't know pretty well what I'm doing.

Is this the right way to create a node? Is there a better and safer way to do it?


texts: I am using the global redirect module. This makes /node/1 goes to my path auto /node/clean-title. If I goto /node/clean-title/edit I get a 404 error. If I go to /node/1/edit. How can I get it so that /node/clean-title/edit works. I would like this to happen on all my nodes automatically.


texts: Is there a dd() like variable printer that can be used inside a preprocess?

texts:
Many times when I start a hook_preprocess_hook, I start by printing the $vars object. I can do this by dpm()'ing, dsm()'ing, kint()'ing etc. The problem is that all of these functions print $vars in an expanded fashion and bring my computer to its knees. dd() works incredibly well in just about every other thing I do inside drupal, but for some reason dd() just WSOD's inside a preprocess.

Is there anything like dd() (i.e. prints arrays/objects in a collapsed fashion) that can be used inside a preprocess?

I'm aware of XDebug, but I'm wondering if there is something as simple as install module -> use function like devel/dd() works in other drupal applications.


texts:
I'm new to Drupal 8, TWIG, and only a novice at PHP. I'm trying to create a banner section that I can recreate on different pages. I have a banner node section that takes in an image, header, subheader, and link. The structure of the banner will be the same on every template, but obviously the inputs will be different.

I created a preprocess_page function (I think) and then want to call the banner in the template

function tibco_preprocess_page(&$variables) {
return array(
    'banner' => array(
        '#theme' => 'tibco_banner',
        '#image' => 'field_banner_image',
        '#header' => 'field_banner_header',
        '#subheader' => 'field_banner_sub_header',
        '#bannerLink' => 'field_banner_link'
    ),
);}

The call funciton in the template looks like this

{# Banner #}

{{ tibco_banner }}

Unfortunately, nothing is showing up when I do it this way. Have I mixed PHP and TWIG or made a code error?


texts: Why does hook_menu add my menu items multiple times?

texts:
I'm using a hook_menu to add some custom menu items to my user menu. One is a link to an external page, one is a duplicate of the "node/add/discussion" page.

I'd expect these menu links to be added to my user menu once and only once. Instead, these links get added to my user menu once for every time I clear cache.

function MYMODULE_menu() {
    $items['external'] = array(
        'title' => 'External',
        'link_path' => 'http://www.example.com',
        'type' => MENU_NORMAL_ITEM,
        'menu_name' => 'user-menu'
    );
    $items['have_a_chat'] = array(
        'title' => 'Have a chat',
        'link_path' => 'node/add/discussion',
        'type' => MENU_NORMAL_ITEM,
        'access_callback' => 'user_is_logged_in',
        'menu_name' => 'user-menu'
    );
    return $items;
}

Exported from the database (SELECT * FROM menu_links WHERE menu_name = 'user-menu';) the menu looks like:

"menu_name","mlid","plid","link_path","router_path","link_title","options","module","hidden","external","has_children","expanded","weight","depth","customized","p1","p2","p3","p4","p5","p6","p7","p8","p9","updated"
"user-menu","2","0","user","user","User account","a:1:{s:5:""alter"";b:1;}","system","0","0","1","0","-10","1","0","2","0","0","0","0","0","0","0","0","0"
"user-menu","10","2","user/register","user/register","Create new account","a:0:{}","system","0","0","0","0","0","2","0","2","10","0","0","0","0","0","0","0","0"
"user-menu","14","0","user/login","user/login","Log in","a:0:{}","system","0","0","0","0","0","1","0","14","0","0","0","0","0","0","0","0","0"
"user-menu","15","0","user/logout","user/logout","Log out","a:0:{}","system","0","0","0","0","10","1","0","15","0","0","0","0","0","0","0","0","0"
"user-menu","20","2","user/password","user/password","Request new password","a:0:{}","system","-1","0","0","0","0","2","0","2","20","0","0","0","0","0","0","0","0"
"user-menu","336","0","profile-main","profile-main",,"a:0:{}","system","0","0","0","0","0","1","0","336","0","0","0","0","0","0","0","0","0"
"user-menu","1071","0","http://www.example.com",,"External","a:0:{}","system","0","1","0","0","0","1","0","1071","0","0","0","0","0","0","0","0","0"
"user-menu","1072","0","node/add/discussion","node/add/discussion","Have a chat","a:0:{}","system","0","0","0","0","0","1","0","1072","0","0","0","0","0","0","0","0","0"
"user-menu","1074","0","http://www.example.com",,"External","a:0:{}","system","0","1","0","0","0","1","0","1074","0","0","0","0","0","0","0","0","0"
"user-menu","1075","0","node/add/discussion","node/add/discussion","Have a chat","a:0:{}","system","0","0","0","0","0","1","0","1075","0","0","0","0","0","0","0","0","0"
"user-menu","1076","0","http://www.example.com",,"External","a:0:{}","system","0","1","0","0","0","1","0","1076","0","0","0","0","0","0","0","0","0"
"user-menu","1077","0","node/add/discussion","node/add/discussion","Have a chat","a:0:{}","system","0","0","0","0","0","1","0","1077","0","0","0","0","0","0","0","0","0"
"user-menu","1078","0","http://www.example.com",,"External","a:0:{}","system","0","1","0","0","0","1","0","1078","0","0","0","0","0","0","0","0","0"
"user-menu","1079","0","node/add/discussion","node/add/discussion","Have a chat","a:0:{}","system","0","0","0","0","0","1","0","1079","0","0","0","0","0","0","0","0","0"

My Drupal version is 7.23.

One odd thing I notice is that "module" is listed as "system" despite the fact that I'm adding these links in a custom module.

How do I fix my code so that these menu links only get added once?


texts: How to apply authentication to rest endpoint URL?

texts:
I can access the rest endpoint URL for a node in JSON format (e.g. https://192.168.1.235/rest_endpoint/node/1142?_format=json) even if we are not logged-in to the sever.

Is there any way to apply authentication to access this URL?


texts:
My goal is to display a form in a page made with panels. The form will be between content panes.

The single page (made with page manager & panels) will be like below:

Content Pane
Form
Content Pane

How can I achieve that, and display the form in a page made with panels ?

Update 2-4-2014:
I found this article and created the following block that doesn't work (I am getting an error when trying to add that to panels). can sombody help make this thing work?

<?php
function my_answer_form_block_info() {
    $blocks = array();
     $blocks['my_answer_form'] = array(
            'info' => t('My-Answer-Form'),
            'cache' => DRUPAL_CACHE_GLOBAL,
    );

    return $blocks;
}

function my_answer_form_block_view($delta = '') {
    $block = array();
    switch($delta) {
            case 'my_answer_form':
                    $block['subject'] = t('My Answer Form');
                    $block['content'] = drupal_get_form('answer_node_form');
            break;
    }
     return $block;
}
  ?>

Note: Form ID is: "answer_node_form"

I am using the Answers Module. The form I want to put on the panel page is the Answer Form, that was created by the Answers Module. Is that a node form or a custom form?


texts:
We have a view containing two fields that we would like to sort - specifically issue # and Title. We would like to sort the view first by the Issue # field and then secondly by Title, so that nodes from the same issue are clustered and sorted again by title.

How can we sub-sort a view so that one field is the primary sort and another is the secondary sort (similar to sorting in a spreadsheet)?


texts: Combining a digital and a physical version of the same product (without making 2 different nodes/products) using Ubercart

texts:
I have been struggling for weeks now to find the best solution for the following problem.

Suppose I am a filmmaker and want to sell my films on DVD, Blu Ray, but also as a digital download. Without having to create 3 different products.

I suppose for the two physical objects (choice between DVD or blu ray), I could use a product option. But how to combine it with something only virtual (so no shipping fees, ..) ? Any thoughts what the best way to tackle this would be?

Thanks kind internet stranger!


texts: Get all fields defined in a bundle for a view mode

texts: Is it possible to get all the fields and field groups structures defined in a bundle for a view mode, in Drupal 8?


texts: Display "uncaught exception" page as content-type text/html

texts:
When there is an uncaught exception, Drupal 8 displays a simple dump of the exception.

I find that the page is served as 'Content-Type' = 'text/plain', yet it contains HTML:

It looks better to me when I change the code to serve as 'text/html':

I already found the code to change - it's in FinalExceptionSubscriber.php, which outputs

</br></br>
SafeMarkup::format(...) which is documented as

  Formats a string for HTML display by replacing variable placeholders.

My question is:

Does anyone know a reason why the error page is text/plain given that it contains HTML.
Shall I raise an issue and patch?


texts: Webform replacements using %post[key] for Array variables

texts:
I'm trying to set a default value for a hidden field capturing a POST Array Variable (by the way, webform form keys are arrays) but the literal is not replaced with the posted value.

Should I escape/encode the field key in %post[key] when the variable is an array?

e.g
%post[submitted[participant_details][contact_details][name]]

This does not work.
I also tried url-encoding the brackets inside the key like this:

%post[submitted%5Bparticipant_details%5D%5Bcontact_details%5D%5Bname%5D]

This does not work either.
Instead, adding %post[form_id]  (form_id:non-Array form variable) in the same field works as described.

  EDIT
  I figured this out finally. The arrays were previously filtered out. There is a recent patch for everyone interested http://drupal.org/node/824606


texts:
I'm trying to figure out how Drupal's cron effects the page cache of my site.  It would be nice to store as many pages in the cache table as possible so that when requests are made they are being served from the page cache!

However I am getting conflicting answers on the effect of Drupal's cron job on the cache!

This link says that "each cron run clears the cache for all pages":

http://tomroelandts.com/articles/how-to-ensure-that-visitors-always-see-cached-pages-in-drupal-7

as well as -> drupal.org/node/1576686

But this guy, says it only clears caches that can be expired:

https://www.drupal.org/node/1691116#comment-6352756

Would love to get a definitive answer on this!


texts:
I'm working on a small custom module that runs on a Drupal 8.5.1 site, and that automatically deletes user accounts that have been deactivated over 30 days ago. I'm using hook_cron().

It doesn't work, though: None of the user accounts is deleted, and in the log I find the following error message.

  Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "user" entity type did not specify a "delete" form class. in Drupal\Core\Entity\EntityTypeManager->getFormObject() (regel 184 van /home/xxx_staging/apps/default/docroot/core/lib/Drupal/Core/Entity/EntityTypeManager.php).

This is the hook_cron() implementation I am using.

function xxx_delete_inactive_users_cron(){
  $time_for_clearing = _xxx_delete_inactive_users_time_for_clearing();

  if($time_for_clearing->is_due === TRUE){
    // first switch to admin account
    $accountSwitcher = Drupal::service('account_switcher');
    $account = \Drupal\user\Entity\User::load(1);
    $accountSwitcher->switchTo($account);

    // get users that have been deactivated over 30 days ago
    $user_ids = \Drupal::entityQuery('user')
      ->condition('status', 0)
      ->condition('changed', $time_for_clearing->from_timestamp, '>')
      ->condition('changed', $time_for_clearing->to_timestamp, '<=')
      ->execute();

    // flatten array
    $user_id_values = array_values($user_ids);
    // delete the whole bunch
    user_delete_multiple($user_id_values);
    // log
    \Drupal::logger('xxx_delete_inactive_users')->notice('deleted user ids:     ' . implode(', ', $user_id_values));
    // switch back
    $accountSwitcher->switchBack();
  }
}

What's going on? I know user_delete_multiple() is deprecated, but it still should work.

EDIT: To make things significantly more interesting: if I run the above user delete code in Devel php screen on the same installation, it works fine.
I suppose it must be something about the cron context that causes it to fail.

The only contrib module I've found that is active that implements hook_entity_delete is webform. I do not think webform is to blame.


texts: How do I get all the menu items below a certain parent?

texts:
I am currently working on a module that finds out the parent menu item by path, then displays the current tree structure of that related menu by finding the top parent and most important only displaying that menu item and submenus from within that menu.

path = "/system/menu/submenu";
parent = 'system';
output = parent + parent submenus. (other menu items excluded)

All menu items in "Custom menu":

- System
   - Menu wrapper
     - SubMenu 1A
     - SubMenu 2A
     - SubMenu 3A
- Main
  - SubMenu 1B
  - SubMenu 2B
  - SubChildMenu 3B

PHP code should return this:

- System
   - Menu wrapper
     - SubMenu 1A
     - SubMenu 2A
     - SubMenu 3A

My code (currently not working) is the following.

 $menu = 'custom_menu';
 $title = 'System';
 $tree = menu_tree_all_data($menu);
    foreach ($tree as $branch){
      if ($branch['link']['title'] == $title){
        $childtree = $branch['below'];
        break;
      }
    }
 return $childtree;

Notice: This needs to be PHP code only; all other modules don't support this only through manual selection.

People have asked this before but i've tried their solutions and no success.

Your help is very much appreciated.

https://stackoverflow.com/questions/5218861/restrict-menu-tree-to-first-level

https://stackoverflow.com/questions/2716787/how-to-get-all-the-menu-items-below-a-certain-parent-in-drupal

How do I display submenus separately from their menu tree?


texts: Responsive jcarousel doesn't resize images

texts:
Im using the jcarousel module and its responsive setting:

http://smartpeopletalkfast.co.uk/carousel/

Below you can see screenshots of how it works. When I resize the browser and the final image doenst fit it is then hidden.

This is working however the original jQuery plug in also resizes the remaining images so they take up the full available width:

http://sorgalla.com/jcarousel/examples/responsive/

How can I get my Drupal site to behave the same way? The only solution I can think of is pretty hacky. I could run javascript on page load and window resize which measured the images and the container, and then resized the images to take up the full width.


texts: How can I filter multiple nid at the same time using Views exposed filter?

texts:
I have an node view with an exposed filer for nid.
It seems that I can put only one value (one nid) in there.
But is there anyway I can filter down nodes by multiple nid?
I tried these in the form
"1 and 2"  "1,2" "1 2" but didn't work.


texts: how can i specify in my migration not to migrate unpublished content?

texts: in a drupal 8 migration, is there a way to specify in the .yml that i dont want to migrate any content that is unpublished .  Or would that have to be done in a plugin?


texts:
I am very new to Drupal and trying to write a module. I have 2 entities - Membership and MembershipRequest and both are fieldable. A MembershipRequest is a request to the admin of the website to create or update (renew/delete) a Membership entity. On the MembeshipRequest form, I want to populate the form elements with Membership entity values that user are requesting to update. For example, on the request form's First name text box, I want to populate the Membership's First name. I have membership_id property in the the request entity. But the First name and other fields are attached to both entities via Field API.

I am not sure which object (and how) - $form, $form_state, $request - I need to modify so that the request form will show up with populated values.

Thanks a lot.


texts: Advance Poll block keeps caching results

texts:
We have begun testing the Advanced Poll module. We are having an issue where the results from the very first vote are cached, and then all page views from that point are only the results of that single vote.

I need a way to make sure the blocks for the Advanced Poll are not cached.

We use Memcached, and everything I read on it is vague.


texts: How to create a machine name for custom table field with transliteration available

texts:
I think the title is pretty explanatory.
I have a custom table in which i retrieve human readable titles in 'title'. This title could be any language, and since i'm french it could have accents for instance.
I would like to change a title like : "L'océan indien, l'Asie et la végétation" into the 'cleanurl' field : "l-ocean-indien-l-asie-et-la-vegetation".

I've seen this topic that seemed interesting, but neither machine name nor safeword seems to be usable with transliterate (or i don't see how).

I've tried some "custom" function but does not work completely as expected (and is not a serious replacement for transliterate i guess :

function clean_name($string)
{
  $string = html_entity_decode($string);
  $string = str_replace('&#039;', '\'', trim(strtolower($string)));
  $search  = 'àáâãäåçèéêëìíîïðòóôõöùúûüýÿ';
  $replace = 'aaaaaaceeeeiiiioooooouuuuyy';
  $string = strtr($string, $search, $replace);
  $string = preg_replace('/[^a-z0-9-]/', '-', $string);
  $string = trim($string, '-');
  $string = preg_replace('/-{2,}/', '-', $string);
  return $string;
}

What can you suggest to achieve this goal ? I would obviously prefer to use core functions if possible.

EDIT --
@Clive
I tried to use the pathauto/transliteration modules and i've manage to get what i want, but i'm not sure this is the right way.

module_load_include('inc', 'pathauto', 'pathauto');
module_load_include('module', 'transliteration', 'transliteration');
$cleantitle = pathauto_cleanstring(transliteration_get($string));

This might not be the optimal way since as you emphasised : Process the string through the transliteration module, but i'm not at ease enough with Drupal code.
From the code in pathauto_cleanstring(), transliteration_get should be processed automatically if

variable_get('pathauto_transliterate', FALSE) && module_exists('transliteration')

Both are enabled in my Drupal, but if i do
pathauto_cleanstring($string); the transliteration is not aplied.

But again, if nobody tells me why, this works with pathauto_cleanstring(transliteration_get($string));


texts: How to change the icons used for printer friendly module

texts: I would like to change the icons used in the printer friendly module as the default ones supplied don't suit my theme. How do I go about doing this? I assume I should a hook of some sort, but sure which hook is the appropriate one.


texts: WYSIWYG + TinyMCE: Pressing Enter inserts break instead of paragraph

texts:
Does anyone know, how I can manage TinyMCE to insert
 instead of
Paragraphs
 when pressing enter?

The best would be if you press enter once, it inserts a normal break. Pressing enter twice it starts a new paragraph.

And yes I know, that Shift+Enter would do it, but my client would like to have the behavior changed.

Thanks for any help


texts: How to noindex on paginated pages in Drupal 7?

texts:
This question is almost a copy of: How to noindex comment/reply in Drupal 7

However in this case i would like to know how to add noindex,follow on paginated pages. For example I want to add noindex,follow on domain.com/artiklar?page=7 but not on domain.com/artiklar

How can I do this? Thanks!


texts: Check Content Type in Page PreProcess Hook

texts:
I'm attempting to get the content type in my page preprocess function...but apparently I'm missing something.  What am I doing wrong here?  I'm attempting to get the $node variables first - then test from there.

function mytheme_preprocess_page(&$variables) {
   $node = \Drupal::routeMatch()->getParameter('node');
   switch ($node->getType()) {
       case "client":
           $variables['attributes']['class'][] = 'clientpage';
       break;
        case "something_else":
           // ...
       break;
   }
 }


texts: Is there anywhere that I can find a list of add-on modules for the Views module?  If I search for "Views plugins" or "Views add-on", the search just picks up on "Views" and returns a million results that contain "Views".  I was hoping to find a list of things like "views_conditional", "views_or", etc.


texts: responsive tabs (tab to accordion on small screen width)

texts:
I have a task of building a responsive website with custom theme and all that good stuff. One thing I stumbled across is using tabs to display data.

Tabs are a requirement in the site but they are not responsive. I have seen some wordpress sites that have this nice feature of turning tabs into accordion when the screen width is small.

Unfortunately I could not find a way to implement that in Drupal so far. The only way that I thought of is loading to view blocks (1 tabs and 1 accordion) and show/hide one of the two based on screen width using JS but this solution is not an efficient one.

Please let me know if there is a way in which I can accomplish this task.


texts: How can I run javascript code after an item added or removed from an unlimited value field?

texts: I am trying to add some js functionality to an unlimited value field in Drupal 7, it works on page load, but disappears after adding or removing an item, and I did not find a way to notify my code that the table is reloaded, and it is time to reinitialize those functions on the fields. How can I do this?


texts: I need to delete all node revisions before upgrading to Drupal 7 to save time in migration. Is there any way to do that?


texts: Views video file with attached thumbnails

texts:
The idea:
A page "Video" with one embedded youtube video and down bellow will have a small images (screenshots of videos). These images will be linked to a individual video, so when a user click one of the small images, the embedded video will change and on the same location will open the new selected video.

I guess this will be possible with the Views module. Let's say with a display page "video" and will show only one video. Down bellow maybe attached view or separated view, but I don't know what and how to display.


texts: drupal_redirect_form not working with entity

texts:
I have created custom submit form handler for entity using below

$form['#submit'][]='app_contact_form_submit_message_alter';

but when i used

drupal_get_messages($type = NULL);
drupal_set_message('Thanks for your feedback we will contact soon.');
drupal_redirect_form($form_state);

It redirect correctly but entity is not created.

and even if i use drupal_goto() same thing happening.


texts: How to import multiple taxonomy terms from csv using Feeds

texts:
I have a csv with the following structure:

1024    Huwelijk
1024    Communie/Lentefeest
1024    Bedrijfsfeest
1024    Seminarie
1024    Koffietafel
1024    Receptie
1024    Jubileum
1024    Verjaardagsfeest
1024    Doopfeest / Baby borrel
1024    Vergadering

1024 is an ID I have linked to a node and want to use to update taxonomy terms.

When I run this importer , only the last Item (vergadering) is checked on the node.

All terms already exist in the vocabulary.

How can I process this so all items are checked on the node?


texts: `Routing` folder not present inside `Drupal\Core\`

texts:
I am trying to port a module from D7 to D8.

Since hook_help() uses routes instead of paths in D8, so the line use Drupal\Core\Routing\RouteMatchInterface; is added at the beginning of the code as mentioned on this page.

But the thing is that no folder named routing exists inside my Drupal\Core\.

Questions.

Am I supposed to add that folder myself?
How will I configure
    RouteMatchInterface file.


texts: How to define region template, and render it in page.tpl.php

texts:
I want to separate the header and footer wiht 2 tpl files with region, for avoid to write code repeatedly.

That is my directory structure  :

├── style.css
├── template.php
├── templates
│   ├── html.tpl.php
│   ├── pages
│   │   └── page--front.tpl.php
│   ├── regions
│   │   └── region--header.tpl.php
│   └── views
└── yuanjie.info

I add some test text in region--header.tpl.php:

testtest

and render it in page--front.tpl.php:

<?php print render($page['header']) ?>

The I clean the cache, and refresh the front page, not work.


texts: Change site logo for different languages

texts:
I do believe that should be popular issue but I can't find any questions here about this: is there any way to make site's logo different for different languages? I've found some threads regarding this thing in drupal.org forums, but these solutions are not working for me...

p.s. I am using D7 and currently working on Fusion subtheme Acquia Marina (if it helps)


texts: Mail subject and body remain empty using mailManager

texts:
I have been fiddling with sending a mail in my custom module in Drupal 8.
The mail gets sent but the subject and body are empty.
It has been an issue for days and I can't get it to work. The code and var_dump are below. I just can't find the issue. Maybe someone can!

Code in hook_mail:

<?php
/**
 * Implements hook_mail().
 */
function document_mail($key, $message, $params)
{
    $options = array(
        'langcode' => $message['langcode'],
    );
    switch ($key) {
       case 'send_file':
            $message['from'] = \Drupal::config('system.site')->get('mail');
            $message['subject'] = t('@title', array('@title' => $params['mail_title']), $options);
            $message['body'][] = $params['message'];
        break;
    }
}

Code to send mail:

    $mailManager = \Drupal::service('plugin.manager.mail');
    $module = 'document';
    $key = 'send_file';
    $to = 'info@example.com';
    $params['mail_title'] = 'a title';
    $params['message'] = 'a message';
    $langcode = \Drupal::currentUser()->getPreferredLangcode();
    $send = true;
    $result = $mailManager->mail($module, $key, $to, $langcode, $params, null, $send);
    var_dump($result);
    if ($result['result'] !== true) {
        drupal_set_message(t('There was a problem sending your message and it was not sent.'), 'error');
    } else {
        drupal_set_message(t('Your message has been sent.'));
    }

var_dump of result from $result of mailManager

array(12) {
["id"]=> string(18) "document_send_file"
["module"]=> string(8) "document"
["key"]=> string(9) "send_file"
["to"]=> string(24) "info@example.com,"
["from"]=> string(22) "info@example.com"
["reply-to"]=> NULL
["langcode"]=> string(2) "en"
["params"]=> array(2)
{
    ["mail_title"]=> string(7) "a title"
    ["message"]=> string(9) "a message"
}
["send"]=> bool(true)
["subject"]=> object(Drupal\Core\StringTranslation\TranslatableMarkup)#410 (5)
{
    ["string":protected]=> string(6) "@title"
        ["translatedMarkup":protected]=> NULL
        ["options":protected]=> array(1)
        {
                ["langcode"]=> string(2) "en"
        }
        ["stringTranslation":protected]=> NULL
        ["arguments":protected]=> array(1)
        {
            ["@title"]=> string(7) "a title"
        }
    }
    ["body"]=> array(1)
    {
        [0]=> string(9) "a message"
    }
    ["headers"]=> array(7)
    {
        ["MIME-Version"]=> string(3) "1.0"
        ["Content-Type"]=> string(51) "text/plain; charset=UTF-8; format=flowed; delsp=yes"
        ["Content-Transfer-Encoding"]=> string(4) "8Bit"
        ["X-Mailer"]=> string(6) "Drupal"
        ["Return-Path"]=> string(22) "info@example.com"
        ["Sender"]=> string(22) "info@example.com"
        ["From"]=> string(44) "a string"
    }
    ["result"]=> bool(true)
}


texts: Using template on subsite for certain node type

texts:
I am using a custom Theme in a multisite setting. With the help of @leymannx I implemented
hook_theme_suggestion_HOOK_alter to insert a page Template with the following naming convention:
page--NAMEOFSUBSITE.html.twig

See here

If I try to do the same for the node of my content type, which is using a template named node--CONTENTTYPENAME.html.twig at the moment, I can insert a name suggestion node--NAMEOFSUBSITE.html.twig, which will then be used for ALL nodes. I'd like to insert a suggestion such as
node--CONTENTYPENAME--NAMEOFSUBSITE.html.twig, for only this one nodetype.

How can I do that?

Thanx in advance!!


texts: Making it so registered users can't add/edit taxonomy terms to nodes

texts: Is there a way to add a permission so only admins can add/edit taxonomy terms on nodes? I tried http://drupal.org/project/taxonomy_access but I don't really want full module and while rebuilding my content permissions I got an error so that module might not even work.


texts: How to call drupal_bootstrap from custom file in subfolder?

texts:
I'm trying to call drupal_bootstrap from 'temp.php' in a subfolder called 'custom' my code as follow:

chdir('../');
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

Once I call the temp.php I get Drupal homepage.

I also tried an explicit physical path but with no use, code as follow:

define('DRUPAL_ROOT', '/var/htdocs/drupal7');
require_once '../includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

temp.php located under the following folder structure:

- var
-- htdocs
--- drupal7
---- custom
----- temp.php


texts:
How can you just add a breadcrumb to views?
Easy breadcrumb leaves out views.
Views breadcrumb does not work correctly with Drupal 8.
Is there a simple way with hooks?

EDIT 2:
Maybe I mean something else?

In Drupal 7 (with custom breadcrumb) it looks like this:
The view "Informationen" is called:

One node out of the view is called:

In Drupal 8 (with Easy breadcrumb) it looks like this:
The view "Informationen" is called:

One node out of the view is called:

I hope I could explain the difference.


texts: Include external JS/CSS libraries in a module?

texts: What is the Drupal 8 equivalent of including external libraries (like sites/all/libraries) for custom modules?


texts: Selecting image for embedded youtube video

texts: Would like to know how to select the image that is shown on the web page for an embedded youtube video. Currently an image from the video seems to be randomly pulled out and used.


texts: Data coming from entityTypeManager->getStorage is cached data?

texts:
I am working on one Drupal 8.3 site. I created my own custom Authentication provider for REST API authorisation.

Following are the "authenticate" method sample code.

/**
   * {@inheritdoc}
   */
  public function authenticate(Request $request) {
      try {

          $uid = 1;// passing 1 for testing.

          $accounts = $this->entityTypeManager->getStorage('user')->loadByProperties(array('uid' => $uid, 'status' => 1));
          $account = reset($accounts);
          if ($account) {
              return $this->entityTypeManager->getStorage('user')->load($uid);
          }
      }
      return [];
  }

My doubt here is "$this->entityTypeManager->getStorage" is getting data from cache table. Or everytime it connect to db and generate response?


texts:
Im build a module, and this module was add a new field type, and all its good, but when i try to use this field in view, its print empty.. no value.., but when I use delta field, its retrieve value ..

look here:

how i can integrate field value with view ..?

this code I used for create field ..

// Install New type of field module.install
function custom_anees_location_field_schema($field) {
  $schema = array();
  $schema['columns']['option'] = array(
      'type' => 'varchar',
      'length' => 25,
      'not null' => FALSE
  );
  return $schema;
}
 // mymodule.module
function custom_anees_location_field_info() {
  return array(
    'country_list_location' => array(
      'label' => t('Country Location'),
      'description' => t('Field For spesfic Location content'),
      'settings' => array('max_length' => 255),
      'instance_settings' => array(
        'text_processing' => 0,
      ),
      'default_widget' => 'options_select',
      'default_formatter' => 'states_field_options',
    ),
  );
}

function custom_anees_location_field_widget_info_alter(&$info) {
  $widgets = array(
    'options_select' => array('country_list_location'),
  );
  foreach ($widgets as $widget => $field_types) {
    $info[$widget]['field types'] = array_merge($info[$widget]['field types'], $field_types);
  }
}

function custom_anees_location_element_validate($element, &$form_state) {
  switch ($element['#type']) {
    case 'textfield':
      if ($element['#value'] == '') {
        form_error($element, t('Case Name may not be blank.'));
      }
      break;
    case 'checkboxes':
      if (empty($element['#value'])) {
        form_error($element, t('You must give at least one role access to this state.'));
      }
      break;
  }
}


texts: theme function not available, not called?

texts:
I am extending a module, I want to create a new theme function for the output but it somehow is not recognized. I know of theme registry and rebuild it (manually and via devel module)

The issue is tracked down to

function cmis_browser_content_properties() {
    $output = theme('cmis_browser_content_properties', array('cmis_object' => $object));
    debug($output, 'output');
    return $output;
}

function theme_cmis_browser_content_properties($variables) {
  // do sth
  $output = 'sth';
  return $output;
}

When I create a new function by copying the existing to

function theme_cmis_browser_content_propertiesnewtest($variables)

and call it in above module code. There is no output anymore, debug says: ''

$output = theme('cmis_browser_content_propertiesnewtest', array('cmis_object' => $object));

Please enlighten me!

just fyi the cmis module is a connector to alfresco document repository via CMIS http://drupal.org/project/cmis

just seeing similar questions suggested. Will see if one fits, but send this anyaway.


texts: Adding a taxonomy term translation changes the original language value!

texts:
I have an issue when I try to add a translation of a taxonomy term using the site UI. The original language value changes to the translation value that I added.

How can I prevent that from happening?


texts: Drupal module updates failing through administrative interface after update to 7.50

texts:
So, I just updated my site to Drupal 7.50, and in addition to being informed of a host of modules that weren't properly uninstalled, it seems that I can no longer update modules through the administrative interface. I have a long list of module updates and it will be annoying to do all of them manually.

So is there some setting that changed? Or how can I get back to being able to update modules through the admin UI. I've tried a few at a time, as well as one at a time. I get the following warning after trying to update

The file could not be created.
https://ftp.drupal.org/files/projects/google_analytics-7.x-2.3.tar.gz could not be saved to temporary://update-cache-d103ec38/google_analytics-7.x-2.3.tar.gz.
The file could not be created.
https://ftp.drupal.org/files/projects/webform-7.x-4.14.tar.gz could not be saved to temporary://update-cache-d103ec38/webform-7.x-4.14.tar.gz.
Downloading updates failed:

Failed to download google_analytics from https://ftp.drupal.org/files/projects/google_analytics-7.x-2.3.tar.gz
Failed to download webform from https://ftp.drupal.org/files/projects/webform-7.x-4.14.tar.gz