texts:
I have a rule set up to email the contents of an entity form. I am using replacement patterns to print out the submitted data. However, I cannot get the end date to print out.

I have [entityform:field_venue_reservation_date] - which prints the start date fine.

Here is what the replacement pattern description states:
Field "field_venue_reservation_date". The following properties may be appended to the token: value (Start date), value2 (End date), duration (Duration)

I found a few ideas and have tried them but I still do not get the end date to print.

Here is what I tried.

[entityform:field_venue_reservation_date:value2]
[entityform:field_venue_reservation_date:0]
[entityform:field_venue_reservation_date:0:value:custom:Y]

I have been trying to search for ideas but nothing is working.
Does anyone know how this works?

Thanks!


texts: How can I avoid to return HTML markup for access denied?

texts:
I've developed a custom controller that serves as a simple endpoint, POST method.
This controller has custom access control.
Custom access is done by looking for a header in the HTTP request, by making the controller object a service as well.
Everything works great. Except that when I return AccessResult::forbidden() .. I get the HTML of the access denied page .. and I don't really want that .. I'd like to return just a short bit of JSON.
What can I do to return something that is JSON, and not the Access Denied page HTML, for this particular route, when the access() method returns AccessResult::forbidden() ?
I've read that appending ?_format=json to the url works, and in my case it does. Is there anyway to achieve the same result without adding this url parameter?


texts: How do I convert AddressField "Administrative Area" abbreviation to full name

texts: The Address Field module automatically converts administrative area (i.e., State/Province) abbreviations to full names on node display.  I need to do this in my own custom module but can't find the function that the Address Field module uses to do this.  How can it be done?


texts: Force existing users to complete profile after adding required fields

texts:
I inherited a Drupal (D7) site with existing users. Now I want to add new fields to the user profile, but they will be required.

New users will have to fill out these fields when registering. Existing users will have to fill out these fields when trying to save their profile.

But what I would want is for existing users to be redirected to their profile page after logging in. Of course, I would also like to display a message on that page that they need to complete their profile with this new information.

Is this possible in Drupal?


texts:
Hi I am using Surreal theme for my drupal website, it has regions like "Home, about, projects, and contact us" I want to add one more region like "projects" but i am not getting the way to do the settings.
Tried with adding the region using code in .info file but that couldn't work.


texts:
I've been trying to add a custom classname to a form-item to use as a 'marker' for theming with my css file.

I've been on stackexchange/overflow and several other sites and forums, including the Drupal documentation, but found no reason why it shouldn't work.

Official documentation state the use of the attribute tag like so:

'#attributes' => array('class' => 'myclass'),

But as seen in my example below, this doesn't work or give me errors.

Am I doing something wrong?


texts: Changing '#view_mode' in content type's render array

texts:
I have a content type in Drupal 8 project that has image, name, info and body field as a default display, and image,name and information as a teaser display. I am able to display this content type with teaser view at the page, but right under that i would like to get the default display along with body field so i can create a bootstrap modal with that.

I am using hook_node_view in the module level to change the #view_mode of that render array to 'full' instead of 'teaser'.

function team_bio_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {

if($entity->bundle() == 'about_us'){
 if($view_mode == 'full'){
  if($display->getComponent('field_team_bio')){
    $build['full_view'] =  $build['field_team_bio'];
     $build['full_view'][] = array(
       'full_view' =>array(
         '0'=>array(
            '#view_mode'=>'full'
         ),
         '#weight'=>'103'
       )
    );
    kint($build);

  }
 }
}
}

i can display the content type right under teaser views, but i can't change the view_mode to full. This is what i see when i kint($build):

Current contents have name like '0','1','2','3','4', and they have the view mode that are 'teaser' but i dont how to pass 'view_mode' to 'full'in render array, I am not sure if there is specific name for that or not. Trying this:

     $build['full_view'][] = array(
       'full_view' =>array(
         '0'=>array(
            '#view_mode'=>'full'
         )

didnt change the view_mode neither. So my question: What is the best way to change these view modes to full for the contents? Should I search these numeric keys in the array and pass them to another array then change view_mode like that? Or is there an easier way to approach the problem?


texts: Using view result as an input filter for another view

texts:
Let me explain my scenario at first.

I have two content types in my site.

First is products and second is producer.

Each product has only one producer and each producer has one or more products.

Now in every product page, I want to show the producer information. I made a view block for this issue and it works well.

but in the product page, I also have a plan to show all products of the producer of current product in another block.

In order to show the product nodes of a specific producer I need the node ID of producer content type.

I tried to use Contextual filters --- Provide default value "When the filter value is NOT available" via Content ID from URL but this function returns node ID of current product not producer id. (because we are in a specific page of single product)

Now I am searching to find a solution for this issue.

thanks a lot for your guidance.


texts: How to specify English path alias for Chinese?

texts:
I created a node of type Post in English, and translated it using Entity Translation to Chinese, Traditional. I then set the path alias for the content type to be [node:menu-link:parents:join-path]/[node:title], so it will create an URL alias based on the menu trail and the node title.

However, for Chinese, it is coming up with the Chinese node title, is there anyway to make it display the English title instead? Possibly using Tokens?

I am aware of the Transliteration module, but I am not looking to transliterate, but use the English title altogether.


texts:
I am using Ubercart 2 on Drupal 6 with http://drupal.org/project/uc_product_minmax. It works well, except for the fact that the default catalog only provides an 'Add to cart' button with no quantity field, and the quantity it adds is 1, which makes it useless as the minimum order quantity in this particular case is 2.

I have tried implementing hook_add_to_cart() to forcefully change $qty to 2 if it's lower only to find that I cannot manipulate it before uc_product_minmax implements the hook, so I'm in need of an alternative.

Maybe this isn't even fixable without modifying uc_product_minmax itself, but I'm up for trying any other ideas.


texts: How to change property 'string' in object with class Drupal\Core\StringTranslation\TranslatableMarkup in my hook?

texts:
The property 'string' is protected as I can see here https://api.drupal.org/api/drupal/core!lib!Drupal!Core!StringTranslation!TranslatableMarkup.php/class/TranslatableMarkup/8.2.x

but I need to change word "- Any -" in my exposed filter form to my string "All terms"?

I cannot do this cause I do not know how to use this class and how to change output.

This hook says: cannot get value of protected property.

function MYtheme_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ( ( $form['#attributes']['class'][0] == 'views-exposed-form' ) &&
       ( $form['#info']['filter-field_color_target_id']['operator'] == 'field_color_target_id_op' ) )
  {
      dpm($form['color']['#options']['All']->string);
      //$form['color']['#options']['All']->string = t('All terms');
  }
}


texts: Display Suite Code Field does not display on node

texts: I'm trying to manipulate a field in display suite on a test site, but the field is not displaying in DS format. Is there anything I need to link or enable in order to use this format?


texts: Does it make sense to develop a fantasy sports management system by creating or extending entities?

texts:
I am considering building a fantasy sports management system with Drupal. The system will need content, so that's taken care of with the standard Drupal system. However, does it make sense (or even possible) to create new entities that represent players, teams, leagues, stat-lines, etc?

I have built systems like this in the past (.NET) and it's difficult for me to wrap my mind around the idea of combining content nodes with players, teams, and stats. There are many fields that are exclusive to each type of node/entity and the sheer volume of players and stat data will push the node tables to crazy levels.

I haven't messed with Drupal 7 entities (which I believe abstracts nodes, users, and taxonomies), but I'd like to hear opinions if this concept is possible.


texts: How to show the number of nodes and comments?

texts:
I want to show the number of nodes and comments of the author in the author's comment.

I try to put in template :

function MYTHEME_get_user_comments_count($uid) {
   $query = db_select('comment', 'c');
   $query->condition('uid',$uid,'=');
   $query->addExpression('COUNT(cid)', 'comments_count');
   $result = $query->execute();
   if ($record = $result->fetchAssoc()) return $record['comments_count'];
   return 0;
}

And in comment.tpl :

<?php print MYTHEME_get_user_comments_count(['comments_count'], $comment->uid); ?>

But it doesn't work.

Where have I forgery? Is this the right way?


texts: When entering taxonomy terms are new ones added with different pk even if term is already in the dictionary

texts: I was expecting taxonomy terms to only be added if they weren't already in the dictionary. However, it seems that I have multiple terms added with different tid's or pk which I wasn't expecting. What is happening here?


texts: Can't add new language to a Drupal 8 installation

texts:
I have installed a Drupal 8 installation using the app utility from my hosting.

The main language is Spanish, but when I'm trying to add two new languages from admin/config/regional/language there is no "Add language" button. The module Interface Translation is installed.

Is it possible that languages are locked by any configuration file? How can I make the button appear again?


texts:
I'm trying to unpublish nodes where a field = 'Closed'. This field can change so I need to run this bulk operation automatically. I've tried these hooks:

hook_update_N
hook_flush_caches
hook_cron

The only hook I've had success with is a view hook (hook_view_pre_render) and sure enough my bulk operation worked. Here's my code for the operation:

$query = new EntityFieldQuery();

$query->entityCondition('entity_type', 'node')
  ->propertyCondition('type', 'custom_type')
  ->propertyCondition('status', 1)
  ->fieldCondition('field_status', 'value', array( 'Closed' ), '=' );

$result = $query->execute();

if (!empty($result['node'])) {
  $nids = array_keys($result['node']);

 foreach ($nids as $nid) {
    $node = node_load($nid, NULL, TRUE);
    // do something awesome
    $node->status = 0;
    node_save($node);
  }
}


texts: I want to import my youtube videos to drupal when I upload a video in YouTube

texts:
It will sound stupid but what I want to do is I want to get YouTube videos to my drupal installation.

The challenge is one of my clients he wants to see if he can do like while he is walking and liked the video he can upload it somewhere(preferably YouTube) and it comes up in Drupal as field of node.

Is this possible in Drupal ? I am using version 7.


texts: How do I implement a notification/subscription solution?

texts:
I can't get the Notifications or Subscriptions modules to actually send out emails, and installing the Comment Notify module crashes my entire site.

I realize that Drupal 7 is still fairly young, but I find it pretty remarkable that there is not yet a stable notification/subscription solution. Does anyone have any suggestions beyond the modules I listed here?

Ideally, I would like the following features:

Automatically become subscribed to nodes you create or comment on (with the option to turn this off, of course)
Subscribe to taxonomy terms
Receive notification emails at an interval you specify, such as immediately, once a day, etc.

Seems like maybe 1 & 2 are possible to do through Rules, which I'll begin to explore. But the third point above is pretty critical as well.


texts: What is the accepted way to display certain content on different pages

texts:
I have a couple different pages.  Each page has a main content area and a sidebar.  Each sidebar contains a paragraph unique to that page.  It is necessary that the paragraph in the sidebar and the main content are different content types.

I handled this by using references module.  I created a content type "category page" and a content type "page spotlight".  The page spotlight has a "node reference" field that references a category page.  I then created a view that enforces that relationship.  This allows me to map the spotlight to the pages.

I am wondering is using taxononmy a better approach?  I come from a very structured programming background where there are "right" ways of doing things, and I am just looking for the "drupal way" of approaching this problem.


texts: Main Menu link to all newsletters and another for Articles

texts:
I am very new and not a developer. I would like to create two main menu links for newsletter content type (simplenews) and the core articles type. I want the behavior to be the same as blog.

I assumed that simplenews would add the link when installed but it did not. I have been searching the net for hours, I cannot find a solution.

Thank you in advance for your help.


texts:
I'm trying to delete some content types which are no longer used but are still active.

I'm going to deploy the update using hook_update_N and have this so far (Code taken from node_type_delete_confirm_submit:

function hook_update_N(&$sandbox) {
  node_type_delete('mynodetype');
  variable_del('node_preview_mynodetype');
  node_types_rebuild();
  menu_rebuild();
}

The problem I'm having is that the node type is deleted, but the nodes of that type are still there in the database. Running cron hasn't deleted those nodes (I'm not even sure if that's the default behavior when deleting content types through the admin UI)

My question is:

Are the nodes deleted automatically after a certain time through Cron or some other method? If not then doing it manually, would it be best to do it before deleting the content type or after?


texts: List options without typing on autocomplete

texts:
Is it possible to show options when user clicks to the input field instead of showing after typing at least one matching character?

Autocomplete starts showing the options after user types one character but it is hard to guess for new users what's the possible options for related field.


texts:
I'm trying to use a view inside a loop but it's not working,
I'm using "views_get_view($name)" but "clone_view()" / "copy()" is not working, I can't create another reference.

I have a view with a contextual filter and by settings different arguments on each loop with "set_arguments" the result should be different. I get the result for the first loop but all the others are empty.

I'm trying to use something like this:

for($i=2; $i<=4; $i++){

    $view = views_get_view('view_name');
    $view->set_display($i);
    $view->set_arguments(array($i));
    $view->execute();

    dpm($view->result);
}

and the result is:

... (Array, 4 elements)

... (Array, 0 elements)

... (Array, 0 elements)

The first result is working great (4 elements inside the array) but the others are empty.

I know the above code is not correct as this is not the way to handle objects but at least you will know what I want, a different result for each set of arguments, arguments which are connected to a contextual filter inside view.

Can someone help me with a method to use the view inside a loop ?
I only managed to generate the result once no mather what.

Thanks.


texts: Disabling reply link for comments not working

texts:
I would like to disable reply to comment for anonymous user.

I saw on sereval topics that you have to unset

  $variables['content']['links']['comment']['#links']['comment-reply']

So I ended up adding a preprocess to the .theme file (bartik.theme since I'm using Bartik. Btw I'm using Drupal 8.5.3)

function bartik_preprocess_comment(&$variables) {
  if (\Drupal::currentUser()->isAnonymous()) {
    unset($variables['content']['links']['comment']['#links']['comment-reply']);
  }
}

Despite that preprocess, I still have the reply link when I'm anonymous. Does anyone has an idea about what's going on ?


texts: How to set a different theme when the site is on maintenaince mode?

texts: Hi i am searching for a way to change the active theme when the site is on maintenaince mode (Drupal 7), can you help me? thanks in advice


texts: Can I tell CKeditor to NOT TOUCH my HTML code?

texts:
I am using the CKeditor module only as an administrator, so I don't need any security protection.

When I add Google Adsense code into a block, CKeditor stripes away the <ins> tag. I am aware of this solution though I rather want CKeditor to not stripe away anything. In other words: I don't want to whitelist any tags, I just want to be sure that nothing gets deleted. Is there a solution for this?

Another way might be: Can I configure the Switch to plain text editor toggle to START with a plain text editor as default, allowing me to Switch to rich text editor?

UPDATE: Some additional info: I'm using the latest version of CKeditor, loaded from: //cdn.ckeditor.com/4.4.3/full-all

The profile in use is "Full HTML". In its settings at ADVANCED CONTENT FILTER "disabled" is checked. In ADVANCED OPTIONS, Custom JavaScript configuration, I have set:

config.fillEmptyBlocks = false;
config.autoParagraph = false;
config.allowedContent = true;

To reproduce the problem, just toggle to plain text, paste the following HTML, toggle to rich text and to plain text again. Only "foo bar" will remain.

foo <ins class="adsbygoogle" style="display:inline-block" ></ins> bar


texts:
I have PictureEvents and those have a few boolean fields:

HasCD | HasDVD | HasSlowMo

I'd like to have an icon for each of them that is dim/bright in all the places where it's shown (I have a few Field-Views for the lists of PicutureEvents, and I'd like to place the icons below the video in the main page).

Where do you do this in Drupal 7?


texts:
I want to publish Media associated with content when the content is published.

Is that possible with rules?

If so, what are the conditions I need to set?

The conditions I have set are:

  Node is published - data selector: node
  entity has field - data selector: node, value: field_my_media_field


texts: How to add facebook iframe code directly to block?

texts:
I am trying to display a facebook plugin as a block. I created a new block from the block admin page, and in the "Text" for the block entered the following iframe code and tried a couple of things (none worked) - all show the raw iframe code in the block.

Tried 'Input Format' as FULL HTML (doesnt work)
Tried 'Input Format' as "PHP" (doesnt work, even tried adding  tag.)

Following is the iframe code I am trying:

<iframe src="//www.facebook.com/plugins/follow.php?href=https%3A%2F%2Fwww.facebook.com%2Fzuck&amp;layout=standard&amp;show_faces=true&amp;colorscheme=light&amp;font=verdana&amp;width=450&amp;appId=133506150025748" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px;" allowTransparency="true"></iframe>


texts: Responsive bootstrap grid with 6 columns of equal heights

texts:
In the front page of our website, I would like to list down groups led by researchers and each group is having a thumbnail picture and a title where the picture is of fixed width/height but, the title is not (could be small or large - title appearing a the bottom of the image).

For some reason the grid is not displaying properly and I feel like it is due to the big/small titles of the groups which cause this issue. Column heights could be an issue.

My settings are as follow:

Drupal 7
Views 3 (Block and/or Page)
Unformatted
Fields

http://www.bootply.com/wtGxTJjXva  (I have 18 divs and they have to be divided into six in each row but, it does not) - could anyone point out what I am missing?

According to the image, first row and last column is showing two divs rather than one and in second row I got three divs squeezing into single column.


texts: Migrating data from a CSV source: Where should the source go?

texts:
I'm trying to do a migration of an old (and full of nodes and comments) D7 site, to a Drupal 8 brand new one.

In order to import only the contents, I'm trying to do the migration from a csv file (with the stuff that I've exported using views).

My question is, how to set the source? Full path?
I'm using a test csv file and I put it at the root folder, at the same place where the index.php file is.

I tried this:

source:
  plugin: csv
  path: 'http://www.example.com/myfile.csv'
...

And this:

source:
  plugin: csv
  path: '/myfile.csv'
...

(with and without the slash)

I keep receiving this error when I try to run the migration script:

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /batch?id=20&op=do_nojs&op=do
StatusText: Internal Server Error
ResponseText: The website encountered an unexpected error. Please try again later.

What should I do?


texts:
From the docs :

  Products variations can have attributes and other kinds of fields. Going back to our t-shirt analogy from above, if our t-shirts come in sizes and colors, perhaps the product variation should have an image field so you can upload a picture of a small red shirt. These kinds of non-attribute fields are loaded dynamically when variations are chosen.

What is the difference of purpose and meaning of "non-attribute fields" AND attributes ?
How are they different and similar ?


texts: Export multilingual settings with features

texts:
I'm using features to export 10 content types, but I don't get the multilingual settings. My question is, whether this is even possible, maybe with strongarm or I'm stuck having to change those settings by hand?

I use the i18n module and want the content_type to be translatable, in the content_type edit menu i set:

Publishing Settings->Multilingual Settings-> Enable with Translation
Multilingual Settings->Extended language options->Require language (Do not allow Language Neutral).


texts: How do I programmatically create a file and write it in the private:// folder?

texts:
How do I programmatically create a text file and write to it in the private:// folder in Drupal 8.8? I found some examples, but all of them use deprecated functions and they don't work.

Here what I have now, but i't s not creating folder and text file in it with content:

use Drupal\Core\StreamWrapper\PrivateStream;
...
...
$output = 'Test Text';
$file_save_path_stream_directory =  'private://gmt';

file_prepare_directory($file_save_path_stream_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);

$fileLocation = $file_save_path_stream_directory . '/test.txt';

$file = file_save_data($output, $fileLocation, FILE_EXISTS_REPLACE);


texts: How to use a view block in a dropdown menu item?

texts:
I'd like to create a menu item that generates a dropdown menu with unread messages. I've already used Nice Menus for flyout menus, but I don't think that module supports what I'm looking for: the dropdown should be a view block and should appear when the user hoovers the 'block' in the menu bar.

Is there a module that makes this possible?


texts: How to install a distribution on Docker using ddev composer command?

texts:
I am new to docker. I have to install Openy distribution on docker using ddev CLI. ddev use this command to setup a normal Drupal 8 installation.

ddev composer create drupal-composer/drupal-project:8.x-dev --stability dev --no-interaction --prefer-dist

it's working fine. Now I have to install openy on docker, composer command for openy is:

composer create-project ymcatwincities/openy-project MY_PROJECT --no-interaction --no-dev

I tried writing ddev before openy command and many other changes are made but not successful. Now my main question is that, that how to install any other Drupal distribution using composer command on docker.


texts: Modules to set up audio podcast functionality

texts: I am looking for modules to set up audio podcast functionality which allows playing of uploaded audio files as well as take audio source as external links like iTunes links. Any recommendations?


texts: How can I translate string templates in Metatag module?

texts: I use Metatag module. How can I set different string templates for each site language? Or translate these templates.


texts:
I'm trying to fix a menu problem for a client - I tried saving new settings in the Appearance tab and I got this error

PDOException: SQLSTATE[28000] [1045] Access denied for user 'tester'@'88.208.252.203' (using password: YES) in lock_may_be_available() (line 167 of /home/linweb12/7/7a7.co.uk-1059923790/user/htdocs/includes/lock.inc).

What would cause this error?


texts:
I'm trying to validate a field of a content type.

I've tried different approaches like with hook_form_FORMID_node_form_alter(), hook_field_validate() and even with the Field validate module.

The value of the field should only be alphabetic. So no spaces or special characters.

Here are the functions that I've tried:

Form validation

/**
 * Implements hook_form_FORMID_node_form_alter()
 */
function birthday_form_colleague_node_form_alter(&$form, &$form_state, $form_id) {
  $form['#validate'][] = 'birthday_slackhandle_validation';
}
/**
 *  Validation function
 */
function birthday_slackhandle_validation($form, &$form_state) {
  //for the field_colleague_slack_handle field
  $slacknaam = $form_state['values']['field_colleague_slack_handle'];
  //$special_character_list = '\'^£$%&*()}{@#~<>,|=_+¬-[\Ò]';
  //$pattern = '[a-z]';
  if (preg_match('[a-z]', '$slacknaam')) {
    form_set_error('field_colleague_slack_handle', t('not a valid slackname'));
  }
}

Form rule

/**
 * Implement hook_form_alter
 */
function birthday_form_colleague_node_form_alter(&$form, &$form_state, $form_id) {
  $form['field_colleague_slack_handle']['#rules'] = [
    [
      'rule' => 'alpha',
      'error' => 'Not a valid slack name.',
    ],
  ];
}

Field validation

/**
 * Implements hook_field_validate().
 */
function birthday_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
  //for the field_colleague_slack_handle field
  $special_character_list = '\'^£$%&*()}{@#~?><>,|=_+¬-[\Ò]';
  if (preg_match('/' . $special_character_list . ']/', $field['field_colleague_slack_handle'])) {
    form_set_error('field_colleague_slack_handle', t('not a valid slackname'));
  }
}

The form rule and field validation did absolutely nothing.
The form validation did react, but the same as the field validation module: it accepts EVERY character or none (none if i try !preg_match...)


texts:
I have a my_module.routing.yml file and because of I have multi entity in my module its too big and not pretty.

Is there any way to split it for each entity and include them in one file like symfony, I use below code but it's not work in drupal 8.

acme_demo_user:
  resource: "@acmeDemoBundle/Resources/config/routing/user_routing.yml"

I also use absolute path for yml file but it's not work.


texts: Taxonomy exposed fields options should be visible even when there is no result

texts:
have a multi exposed filters for a view. All are taxonomy reference fields.

For filtering content based on some exposed filters options, for which there is no result, the exposed filters fields also become empty.

The exposed filters options should be visible even when there isn't any result found.
How can I achieve this?


texts:
I know I could use something like hook_theme_suggestions_HOOK_alter() to add a suggestion, which would allow me to get a template rendered, but I wish someone would explain where the original ones come from in the first place.

For example, in the Twig debugging html, I'm seeing this:

<!-- THEME HOOK: 'page' -->

...but I don't know where that 'page' hook came from.  I can't exactly grep for 'page' in core.  Could anyone give me an explanation the order in which these things happen, and how they're connected:

Something creates a list of possible templates to use (How?)
Drupal grabs/renders the files specified from this list, from the theme or parent theme
Something adds new suggestions to existing template names, allowing for specificity
You can add your own template names to elements, which causes it to look for those files

Even a good direction to look in core would be appreciated.


texts: views exposed filter listen to node form values

texts:
If view block with exposed filer or contextual filter is placed on node/add , node/edit form and node is having some field which could be used alternate to exposed filter or contextual filter. Is this setup possible?
ex:
views block having taxonomy exposed filter with select list widget
node form having same taxonomy (vocabulary) field with select list widget.

when selecting the select list on node form views block should be change.Views exposed filter would be made display:none by css if this is possible.
One possible way I am thinking is php code in "provide default value"(listen to field change?) or this has to be passed by node form on field value change.


texts: How to have a field that counts the nodes submitted by the current user?

texts:
My site with existing content needs a field that shows the number of nodes of a certain content type that have been created by the current user.

I can't use Views because the field needs to be able to be used in a Rules condition.

Nor can I use Rules Actions and Flag at the time of adding nodes because so many nodes are pre-existing.

Nor can I use Display Suite code fields because I don't think they are able to be used in Rules either.

Is a computed field and a custom query the best option?

I have so far failed to find a code snippet and I am not experienced in PHP.


texts: Print views fields in a custom view page template

texts:
I am trying to create a custom view page template which will be made of custom fields, which i am trying to print. I created a view page and added all the needed fields to it.

Next, I created a views-view--my-page-name.tpl.php template, which get's recognised, however when i try to print the fields, i get the errors below:

Notice: Undefined variable: fields in include...

Notice: Trying to get property of non-object in include....

Below is the full code of my custom view page template which i copied from the default view page template and modified it. Im trying to print the field with this code:

<?php print $fields['views_field_field_name']->content; ?>

I tried all variables of field name as: field_name, field_field_name, views_field_field_name, but none of them work, as they all give same error.

<div class="<?php print $classes; ?>">
  <?php print render($title_prefix); ?>
  <?php if ($title): ?>
    <?php print $title; ?>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($exposed): ?>

      <?php print $exposed; ?>

  <?php endif; ?>

  <?php print $pager; ?>

  <?php if ($header): ?>

      <?php print $header; ?>

  <?php endif; ?>

  <?php if ($attachment_before): ?>

      <?php print $attachment_before; ?>

  <?php endif; ?>

<?php print $fields['views_field_field_name']->content; ?>
<?php print $fields['views_field_field_age']->content; ?>
<?php print $fields['views_field_field_phone']->content; ?>

  <?php print $pager; ?>

  <?php if ($footer): ?>

      <?php print $footer; ?>

  <?php endif; ?>

  <?php if ($attachment_after): ?>

      <?php print $attachment_after; ?>

  <?php endif; ?>

  <?php if ($more): ?>
    <?php print $more; ?>
  <?php endif; ?>

  <?php if ($feed_icon): ?>

      <?php print $feed_icon; ?>

  <?php endif; ?>

<?php /* class view */ ?>


texts: Recommend a slideshow module that can create a display from a view?

texts:
We have a design comp that looks like this:

We have a content type called speaker, which contains a file field that the headshot image is uploaded to. There are also several other fields, including an entity reference to another content type. What we'd like to do is be able to create a view that contains all the info we need and then have it formatted as a slideshow (where mousing over a single image brings up a div or something containing speaker name, company, etc.)
I've found several slideshow modules that are integrated with Views, but none of them seems to do quite what we need. Any suggestions?


texts: Rendering a nested Paragraph's field using Twig

texts:
We are using the Drupal 8 Paragraphs module and are have a Paragraph which contains a Paragraph type field, called "Steps" (machine name fs_steps), allowing editors to add a number of "Step" Paragraphs (machine name fss_steps) to the parent paragraph for rendering.

Within the twig file, we loop through the entities of the parent's Steps fields, but when we try to render a field of the nested Step paragraph field "Heading" using either (this code is within the context of a for loop):

{{ content.field_fs_step[key]['#paragraph'].field_fss_heading }}

or

{% set step = content.field_fs_steps[key]['#paragraph'] %}
{{ step.field_fss_heading }}

It fails with the following error:

Exception: Object of type Drupal\Core\Field\FieldItemList cannot be printed. in Drupal\Core\Template\TwigExtension->escapeFilter() (line 476 of core/lib/Drupal/Core/Template/TwigExtension.php).

Here is our current code that successfully retrieving the "values" of the bested paragraphs' fields, but does not end up using the renderer (which would respect the field's formatting types) as we need (this is a rudimentary example retrieving text values, but in other cases we want to render more complex data such as links and images):

        {% for key, item in content.field_fs_steps if key|first != '#'%}
                    {% set step = content.field_fs_steps[key]['#paragraph'] %}

{{ step.field_fss_step_marker.0.value|raw }}

{{ step.field_fss_heading.0.value|raw }}

                            {{ step.field_fss_description.0.value|raw }}

                {% endfor %}

We're looking for help in understanding the following:

Why is it that the renderer triggers when calling a top level field against our parent Paragraph, such as {{ content.field_fs_heading }}, but attempting to render a subproperty of the "content" object or rendering a field of a referenced entity, generates an error?
If we are taking the wrong approach to "nested paragraphs", and/or how to render sub-entity fields properly from within the context of a Twig file? Do we need to (as a guess) create a separate template for the nested paragraph template? If so, how would we then pass in the contextual content data to that "partial" and have it properly render there?


texts: Where to use setTrustedProxies() or how to set new trusted proxies

texts:
I need to set a trusted proxy in my installation so that secure cookie flags are set correctly.

Currently as a temporary measure i am setting the following in index.php

$proxies = ['122.128.0.1'];
Request::setTrustedProxies($proxies);

However i would like to be able to set a new trusted proxy from a settings file or module that will persist through a core update without needed to patch.

Where is the best place to specify this?


texts: how to implement a data receiver service in Drupal

texts:
I have a Drupal site which will host a flash application. The application will be inserted in a node body (or as an attachment, not sure yet). I would like this application to send some data to Drupal (e.g. a game progress and score) using Javascript.

What I achieved so far is the ability to have the game score displayed in a Javascript alert  window in Json format. Next step would be to send it to Drupal and I want to save it to a table. I don't know how to do the "Send it to Drupal" part. What is the right way to do it, so it's hacker-proof etc?


texts: Hi i am unable to access values from a node object inside a preprocess_views_view . Below is a screenshot of my object and i want to access the value highlighted. How can i do that?


texts: I have added content type breadcrumbs, but I don't know how to add view's breadcrumbs


texts: Drupal 7 WYSIWYG module with CKeditor library stripping form and input HTML tags when inserted into a block

texts:
I'm wanting to add some code snippets from MailChimp. We are using the WYSIWYG module (7.x-2.5) with the CKeditor library version (4.9.2.9). When I add the code to a block it is stripping out when rendered onto the page.

I want to add form, input and label HTML tags but these are being stripped out. What can you advise to get this form showing inside a block? We have this technique working on another site so I know it is possible.


texts: Show custom view before input entered on exposed form

texts:
I have a page that displays a map with results based on an exposed search field, which is a required field.

I would like to display a custom view when the user visits the page and has not yet entered anything into the field - similar to this question but another view rather than a custom result set. At the moment, the map shows all results when the page is first loaded, and I can't figure out how to change that behaviour.

I know that if I set the form to "Input required" I can enter custom text to be shown before the form is submitted, but I'd like to go a step further and be able to set a custom view to be shown much like the "No results behaviour" option.

Interestingly, with a "no results" view set, I can submit the form with an empty search field and my custom view will show. This is what I also need to be shown before anything has been submitted.

Is there a configuration where this is possible in views, or any way this can be achieved in code?


texts: How can I filter which entities are available in the admin form for an Entity Reference Field?

texts:
I've got a Field which is called "Primary Article" which is an Entity Reference Field. I've configured this field setting the "Reference Type" to be "article", so that only articles show up in the Form when editing this field.
I would want to add two customizations to the current autocomplete field:
)
1) only return some articles based on some logic ( like I only want to return articles which are not selected as primary articles for another taxonomy )
2) change the text of the autocomplete field, so in this case, instead of "Primary Article" I would want to return "Primary article - XYZ" where XYZ is a custom field


texts: Update query not working for db_update and db_query("update

texts:
I'm trying to update a field using the Drupal's bootstrapped db_update or db_query library functions for PHP. However, neither of them are working. IF I RUN THE QUERYS MANUALLY, THEY WORK.

These two queries are the exact same. They are equivalent to doing

update field_data_field_department set delta = 4 where entity_id = 10568 and delta = 0;

Please tell me what I need to do to execute this query from PHP and make it work.

db_query("update field_data_field_department set delta = $highest_delta where entity_id = $entityID and delta = $i");

OR

            $num_affected = db_update('field_data_field_department')
              ->fields(array(
                'delta' => $highest_delta
              ))
              ->condition('entity_id', $entityID)
              ->condition('delta', $i)
              ->execute();
            echo "num_affected: $num_affected\n";

num_affected returns 1 every time.

Here is the state of the database before the query is executed.

MariaDB [db]> explain field_data_field_department;
+----------------------+------------------+------+-----+---------+-------+
| Field                | Type             | Null | Key | Default | Extra |
+----------------------+------------------+------+-----+---------+-------+
| entity_type          | varchar(128)     | NO   | PRI |         |       |
| bundle               | varchar(128)     | NO   | MUL |         |       |
| deleted              | tinyint(4)       | NO   | PRI | 0       |       |
| entity_id            | int(10) unsigned | NO   | PRI | NULL    |       |
| revision_id          | int(10) unsigned | YES  | MUL | NULL    |       |
| language             | varchar(32)      | NO   | PRI |         |       |
| delta                | int(10) unsigned | NO   | PRI | NULL    |       |
| field_department_tid | int(10) unsigned | YES  | MUL | NULL    |       |
+----------------------+------------------+------+-----+---------+-------+
8 rows in set (0.08 sec)

MariaDB [db]> select * from field_data_field_department where entity_id = 10568;
+-------------+--------+---------+-----------+-------------+----------+-------+----------------------+
| entity_type | bundle | deleted | entity_id | revision_id | language | delta | field_department_tid |
+-------------+--------+---------+-----------+-------------+----------+-------+----------------------+
| node        | person |       0 |     10568 |       25093 | und      |     0 |                   39 |
| node        | person |       0 |     10568 |       25093 | und      |     1 |                   30 |
| node        | person |       0 |     10568 |       25093 | und      |     2 |                   41 |
| node        | person |       0 |     10568 |       25093 | und      |     3 |                   38 |
+-------------+--------+---------+-----------+-------------+----------+-------+----------------------+
4 rows in set (0.00 sec)


texts: Show workflow transition bar in all states

texts:
I've created a custom workflow using the workflow module with the transitions listed below and I've noticed that when going to the view page of a node the workflow 'bar' that lets you transition a node between states only appears when it's set for review.

From what I can gather this is because only when it's in the review state is it considered moderated content which is also why it appears on the "Moderated Content" view. What I'd like is to have that appear no matter the moderation state it is in. How could I accomplish this?

States

Draft
Review
Published

Transitions

Draft || Review || Published > Draft
Review > Published
Draft > Review


texts: Error when updating or installing a contrib module with the URL

texts:
I am trying to install a Drupal 7.9 site on a server that hosts several other Drupal sites. I must have gone through this process 50 times before without issue, but now I get an error any time I try to install a module from the URL. Here's an example of the error message with the token module:

Downloading updates failed:

Invalid checksum for file " (function ($) { Drupal.behaviors.tokenTree = { attach: function (context, settings) { $('tab" : 42351 calculated, 0 expected

There is no error in the log, just this cryptic message that doesn't give me any feedback about the problem.


texts: Services 7.3 - Simple Resource Example works only with GET not with POST from Poster

texts:
I created a very simple test service here is the code, for some reason only GET works with it in Firefox Poster, but POST returns a 404 Controller not found. Any tips?
Here is what works
http://mysite.com/services/myendpoint/mytest/retrieve/

with parameter of
id = 1

<?php

/**
 * Implementation of hook_services_resources().
 */
function mytest_services_resources() {
  return array(
   'mytest' => array(
     'retrieve' => array(
       'help' => 'Retrievs a test',
       'callback' => '_mytest_retrieve',
       'args' => array(
         array(
           'name' => 'id',
           'type' => 'int',
           'description' => 'The id of the test to get',
           'source' => array('path' => '0'),
           'optional' => FALSE,
         ),
       ),
     ),
   ),
  );
}

/**
 * Callback for creating  resources.
 *
 * @param object $data
 * @return object
 */
function _mytest_retrieve($id) {
  return "READY TESTING";
}

?>


texts:
I have implemented a private file system for users to upload files. This appears to be working as I can see that the file is uploaded into the proper directory. The problem I have is that no one has permission to view the file (including user 1 which seems odd to me). The error message is:

You are not authorized to access this page.

From what I have read in the documentation, I believe I have everything set up correctly. The file path is outside of the web root directory and accessible by Drupal (as evidenced by the successful file upload). The page that displays the link to the file is in the form of:

/system/files/private/test.pdf

Which is the correct link.

The file permissions set on the directory is: drwxrwxr-x

Which looks right to me as well.

So I am completely stumped. I followed the Drupal 7 documentation page on setting up private directories so I am not sure what I missed. I have obviously overlooked something and hope that someone can tell me what it is or what I should be looking for or what I need to implement to get this working. This is for Drupal 7 by the way.

Thanks


texts: How let users to delete their own comments

texts:
i have installed Comment Delete module to change permissions for the user to delete their own comments. If i click the delete link it throws this error.

  You are not authorized to access this page.


texts: How do I add a file upload field to user registration page?

texts: I need to add a file upload field to user profile, during registration. How can I do this?


texts: Pre-populate an Entity Reference when Adding a Node : Based on URL Alias

texts:
I am trying to pre-populate an entity reference with a specific game node, when a profile node is added; based on URL of the game the add button is on.

The game node I want to reference in profile node is in the URL of the profile's add page.

By using views to contextually filter, matching the first portion of the url (the game node title), with a game node. Then to be used as the field's select list.

Only selection in drop down would make it seem pre-populated.

                         --

Two content types
 - game
 - profile

*game nodes alias pattern is [node:title]. so just /game1/  , /game2/

I added an alias for each game node to go to the profile add page
  game1/add  >  node/add/profile
  game2/add  >  node/add/profile

Using Entityreference prepopulate module i use /node/add/game-profile/?field_gmeprfl_game_eref=[node:nid]  to generate id to reference; the ? (question mark) prevents the [node:nid] from processing to an id. it stays literaly "/node/add/game-profile/?field_gmeprfl_game_eref=[node:nid]". if i take out the "?" it will process to the nid number.

If I use view entity reference list to contextual filter the game1 part of url against the nodes alias , there is not alias for me to add in contextual filter. (id prefer this way so my links look better than  ?field_gmeprfl_game_eref=14

**i use d7 prepopulate entity reference node (?field_gmeprfl_game_eref=[node:nid]), i cant use ? with [node:id] as the ? prevents the tokens from processing. if i can do this and make urls the same as OP: id consider that also.


texts: How to add a value to the object group in group module?

texts:
I have been using the Group module with D7 for a while, but I always regretted that there was no 'creation date' value for each group. I added a column in my database which fills in that value automatically, but I would like it to be part of the object group so that I can retrieve the value more easily. Ideally I want to be able to do this:

$group = group_load($gid);
$thedate = $group->creation_date;

How should I go about it? Thanks.


texts:
I need to detect if I'm currently browsing the site as a different user, having used the devel user switch module.

The LDAP module I have triggers some profile updates on every login, based on some server variables set from AD/SSO. But by using devel switch, it's writing MY user details, to the profile of the person I've switched to.

I need a way of detecting it, so I can prevent the profile write.

I've had a look through the devel API here but can't see that anything is set when running as another user.

Running D7.


texts: Filter Content and Files using the same Taxonomy term filter in Search API

texts:
I have several File (File Entity) and Content (nodes) types both referencing the same Topic taxonomy using the same field (one field, reused). The contents of these files/content are indexed in the same index using Search API (multi-type index). I also have a view that lists down the contents of that index, showing a mixed list of files and content.
Now what I'd like to do is filter the results by the Topic taxonomy using only one dropdown filter, e.g. If I want to find files and content related to "Science", I would just select "Science" from the Topic filter, and the view will show all the files and content related to "Science".
The problem is that when I add a filter to the view, Drupal presents two filter options for Topic, one for the Topic field on the File entity and another for the Topic field on the Content entity - not just one filter. I've already tried Combined Filters, but that doesn't give me a dropdown of Topics. Also hit a dead end on Search API aggregated fields.
How does one filter a view of both files and content by just one taxonomy filter?


texts: Drupal 7 When a new user registers, where is the confirmation e-mail sent?

texts: Im using Drupal 7, when a new user registers an account I want to be able to approve/deny their membership and then allow them on the website as a registered user. When a new user registers, where is that registration e-mail sent to? And can I change where that e-mail goes?


texts: Remove components from a feature using Drush

texts:
Using Features UI to manage a big feature components is a tedious task.

Therefore in order to add a new component I use

drush fe myfeature views_view:myview1

Now how I remove the uneeded component myview2?

From the UI this operation is illustrated as below, I want to remove the conflicted community_content with clone_of_community_content:

The view:


texts: How to give users with role Role2 the right to edit only user accounts with role Role1

texts:
I need to make a user edit users that have a specific role.
In fact we have two user roles here.

Role1 -> is able to edit a particular kind of node
Role2 -> is only able to  administer users with the role "Role1".

My question: how to give users of Role2 access to edit only user accounts of Role1?


texts: How to use views and LDAP query to get a list of names in a webform?

texts:
I am using Views, LDAP query, Webform Views, and Webform to try and produce a webform that -- along with a bunch of other stuff in the webform -- has a select list of names, with emails associated, from our ldap server. So far I have gotten a View page with all the names, but I don't know how to condense that to not just be a giant list (un-collapsible) in the middle of a webform. So any idea how to do this or some similar solution so that the person filling out the form can find a name in a list of names, and for either them to see the email in a list and select/write it in another field, or for them to just select a name from a select list and have that selection effect the results(like providing an email to go with the name)?

Some other info -- the LDAP data has names and emails, as well as a variety of other information that would be useful to the people reading the results. Also, I have tried using feeds, and ldap feeds and was unsuccessful, but I would be happy if there was anyway to use both of those as well.


texts: Drupal 8: "Page cache maximum age" is not working for anonymous users

texts:
I have set a page cache maximum age for anonymous users in Drupal 8, but it seems not to have any effects. Accesing the pages as an anonymous user, changes are visible immediately, and I can't see any headers about max-age on the source code.

I have installed some cache modules as Internal Dynamic Page Cache,     Internal Page Cache and Supercache, but I don't think these should interfere with the cache on the client side.

Any suggestions?


texts: Unable to add list items in item-list.html.twig

texts:
I need to display some links in a list and I'm using item_list theme for this:

$ii = array(
  'id-1' => array('name' => 'name1', 'class' => 'class-1'),
  'id-2' => array('name' => 'name2', 'class' => 'class-2'),
);
$iii = array();
foreach ($ii as $key => $value) {
  $iii[] = array('#value' => ''.$value['name'].'', '#wrapper_attributes' => array('class' => 'class-id'));
}

$aa = array(
  '#theme' => 'item_list',
  '#items' => $iii, //list of items to be displayed
  '#list_type' => 'ul',
);
print_r(drupal_render($aa)->__toString());

But on running this, I got an output of:

where
 tags are empty and 2 empty bullets are displayed on the front-end.

What I'm doing wrong?


texts: Optimize image that does not have an image style

texts:
We are using the imageapi_optimize modules with the imageapi_optimize_resmushit. We are able to flush the caches for all the image styles and see an improvement. However, there are images that are loaded with background-image attribute that do not get optimized and their image styles are set to Original Image under Manage Display for the image field.

How can I set up the image who use the Original Image Styles setting under Manage Display to be optimized as well?

What we tried:

Enable imageapi_optimize
Enabled imageapi_optimize_resmushit
Setup image optimize pipeline and set it to resmushit
Clear all caches and especially the image style cache using drush if all
Observe all images where an image style is used other than Original Image is optimized after cache.
All images where image style is set to Original Image is not not optimized.


texts:
I'm converting an HTML template to a Drupal theme. The HTML template has a 2-level submenu:
ul (main) > ul (first-level) > ul (second level).

In my block--system--main-menu.tpl.php I do only have: <?php print $content ?>

When I check the structure of the Main menu in Drupal (list links) levels are correct.

Now on my frontpage Drupal shows only the first level of the menu. How can I make Drupal show more levels? I'd love to do this without a (non-core) module.

Thanks in advance!


texts: Need to know the most essential JS and CSS files for a Drupal 7 page

texts:
I am creating a module that has a page that is intended to be a viewer for a certain kind of content. The content itself is a Drupal Book viewer meant to behave like an epub reader. Basically I want this page to be a stand-alone, theme-independent, full-screen "player."

To achieve this effect, I don't want to load the usual long list of CSS and JS files, including those from the current theme as well as any from modules that I am not interested in using. I want the page to load only those JS and CSS files that are required for basic Drupal functionality -- e.g. I want Behaviors to work and a few other things, such as overlays.

My question is, what are considered to be the essential JS and CSS files? I realize I can find a way to just dump a list of all files by module. But I am looking for information on importance. I realize this is a little vague and that there are probably a lot of answers that begin with "It depends ..." However, there must be some items that are more fundamental than others.

I am working in Drupal 7 and using hook_js_alter() and hook_css_alter() to remove (unset) items, and a preprocess function to add items.


texts: How to hide Alt and Title fields for anonymus users when they upload images? I use tokens for these field that's why I need to hide them.


texts: What does the checkbox "link to content" do?

texts:
I am creating some custom content but have not got round to creating the views yet. When looking at the layout tab I see this

What content does this refers to? All my Plain text fields have this checkbox, but none of the others.


texts:
I want to print "event_info_date" Date (Unix timestamp) field with custom format in node.tpl.php.

I'm using this code:

<?php print date("Y/m/d h:i:s", $node->event_info_date['und'][0]['value']); ?>

And it prints: 1970/01/01 01:00:00, but it isn't value from my field.

I've also tried this:

<?php print format_date($node->event_info_date['und'][0]['value'], 'custom', 'Y/m/d h:i:s'); ?>

But it doesn't print anything. Any ideas?


texts: Display Suite code field – how to use another image field conditionally

texts:
In my content type I want to show the main image if the thumbnail field is empty. So I use the Display Suite code field and I enter the following code:

<?php
dsm($entity);
if(empty($entity->field_thumbnail)){
    print_r('Thumbnail missing');
    // What code to put here to enable or render another image field
}
?>

When the tumbnail is missing the above code works, but instead of text I want to display another image field, when the thumbnail is missing. I have tried everything I can think of, but the main image dose not show :-(.


texts: How to change Watcher module's time format so it only displays the time in one line?

texts: I am using the Watcher module for a client's site. I am looking for a way to change the time format so instead of saying 2 days 20 hours ago, it says 2 days ago. Of course, it seems to be OK when it is something just posted, and it says X seconds/minutes/hours ago only.


texts: Strange disappearing  problem with Drupal 7

texts:
In CKEditor, source view, I see
 tags around my paragraphs. That's great, makes sense. However when I view the node, the
 tags are gone, replaced with
 tags, thus killing the margins and cramming everything together. Re-editing the node brings the
 tags back again in CKEditor.

I have tried changing the text format to disable "Convert line breaks into HTML", but of course that just removed both
 and
 tags, making one huge paragraph.

How do I prevent this and preserve the
 tags?


texts:
I created a submit button in my config form.

$form['actions']['find_users']  = array(
        '#type' => 'submit',
        '#value' => t('Find users'),
        '#submit' => array('::find_users'),
      );

When I press on submit button, I need to create a table and fill it with the all users of my forum.

First, I created this function:

function find_users(array &$form, FormStateInterface $form_state) {
        $header = [
                    'username' => t('username'),
                    'registered' => t('registered'),
                      'email' => t('e-mail'),
                    'ip' => t('ip'),
                      'last_visit' => t('last visit'),
                  ];

                  $form['table'] = array(
                    '#type' => 'tableselect',
                    '#header' => $header,
                    '#empty' => t('No users found'),
                  );
    }

But when I press on my submit button, table doesn't create. What should I do?

For example, I need to fill table with just the first record from users_field_data table (limit 1).


texts: How to access fields attached to taxonomy term in views-view-field.tpl.php?

texts:
A vocabulary has an additional field field_information attached. In a view i just want to render this information field exclusively (without term name etc). In my views-view-field.tpl.php I did a dpm($field), but I can't figure out how to get to the value of field_information.
Unfortunately due to my setup I can't use the module taxonomy_field_formatter, I'll have to do it manually.


texts: When my module is uninstalled, I want to delete the custom content type created by config files on module installation. On Drupal 7 there was a node_type_delete(node_machine_name). What is the equivalent method/function, in Drupal 8?


texts: Image slider in content type based on selected images from another node (same content type)

texts:
As a novice in Drupal php & hooks, I have a question about content type.
It is all about Drupal 7 with all up-to-date modules installed.

I have a content type for hotels (about 400 hotels). This content type has lots of fields. One of field is for image (unlimited values).  I have user request for image slider in this content type based on images from another node (same content type). Some kind of “We also recommend..:”

My approach was with Advanced Link module where user can enter link to node and this link is then show as field in view (I have view to catch this). Programmatically, I’m then able to take nid from that link and extract image I want from node. But now I’m stuck with putting this image dynamically  into this view. Is this approach good anyway?

In the beginning I was thinking about to add textarea field to content type and give a user ability to insert image from server (image that is already uploaded) with ckeditor uploader.  Only problem with this approach is that all images names from hotel node are in special format (TH-023.jpg…), so they would be in big trouble to find image.

My second thought was to write a module to push image into some kind of field inside content type, immediately after user get link from advanced link field (in edit state of content type node). Is this possible?

Anyway, what would be the best way to do this?

Thanks in advance.


texts: hook_tokens() implementation no longer being called

texts:
We have a custom module in development, the purpose of which is to fetch the email addresses of the users who review content. Upon revisiting this module (after updating from Drupal-7.41 to Drupal-7.51) its hook_tokens() implementation is no longer being called in the same way it was before.

I cannot understand why this functionality no longer works. I thought this was a proper implementation of these functions. It now no longer fires on nodes, but when an entity is on a node.

Why would hook_tokens() not be called on a node? (The module is enabled, depends on tokens and workbench_access, both of which are enabled.)

Please forgive me if my question is framed inappropriately, I may have an inaccurate understanding of the hook function(s), but I've checked the API and haven't gained clarity. I know for a fact that this module worked earlier this year with Drupal-7.41, but I couldn't find any changes in the related API since that release.

function mymodule_token_info() {
   $info = array();
   $info['tokens']['node']['publisher_one'] = array(
     'name' => t('Section Publisher One'),
     'description' => t('Email address of sections primary publisher.'),
   );
   $info['tokens']['node']['publisher_two'] = array(
     'name' => t('Section Publisher Two'),
     'description' => t('Email address of sections secondary publisher.'),
   );
   return $info;
}

function mymodule_tokens($type, $tokens, array $data = array(), array $options = array()) {
   $replacements = array();
   if ($type == 'node' && !empty($data['node'])) {
      print_r('inside if conditional');
      $section_users = array();
      $users = entity_load('user');
      // Get the current Page's section ID (sID).
      $sID = key(_workbench_access_get_node_section_names($data['node']));
      $user_count = 0;
      // Is a given user 1) assigned to the same section as the node and also
      //  of the role identified as the one to be notified.
      // If so, their email address are acquired.
      foreach($users as $user) {
          $user_sections = _workbench_access_get_user_section_names($user);
          if(array_key_exists($sID, $user_sections) && $user_count < 2){
              $role_type = user_roles(TRUE)[variable_get('waemail_role', '0')];
              if(in_array($role_type, $user->roles)){
                  if($user_count == 0){
                      $section_users['publisher_one'] = $user->mail;
                      $user_count++;
                  }
                  else if($user_count == 1){
                      $section_users['publisher_two'] = $user->mail;
                      $user_count++;
                      break;
                  }
              }
          }
      }

      // Assign the values aquired above to the tokens.
      foreach ($tokens as $name => $original) {
          switch ($name) {
              case 'publisher_one':
                  if(!empty($section_users[$name]))
                      $replacements[$original] = $section_users[$name];
                  break;
              case 'publisher_two':
                  if(!empty($section_users[$name]))
                      $replacements[$original] = $section_users[$name];
                  break;
          }
      }
    } //end if($type == 'node'...
 return $replacements;
}


texts: Drupal 7 Rules : How to get Node Object (from Custom PHP) after a node event is triggered?

texts:
In Drupal 7, i am setting up a rule. That rule is applying to trigger on the Node Save event.

After the node is saved [Condition] and the rule is properly triggered, then how can i get that saved Node Object ($node) from the Execute Custom PHP Code [Action]?

Because i put var_dump($node) (in the Custom PHP Code Box) but it doesn't work.


texts: How can I clear all check boxes on failed validation?

texts:
I have form with check boxes. The user checks the boxes and hits the submit button. If validation fails an error message is displayed. I also want all of the user's checks to be cleared so they can try again. Here's my code, but it does not clear the checks? Thanks.

/**
 * Defines a form.
 */
function my_form($form, &$form_state) {

    $form['alerts'] = array(
        '#type' => 'checkboxes',
        '#options' => $options,
    );

    // the rest of my form

    if (isset($form_state['clear_checkboxes'])) {
        $form_state['values']['alerts'] = array_fill(0, count($form_state['values']['alerts']), 0);
    }
    return $form;

}

/**
 * Form validator.
 */
function my_form_validate($form, &$form_state) {

    // if validation fails set error message

    $form_state['rebuild'] = TRUE;
    $form_state['clear_checkboxes'] = TRUE;

}


texts:
I am looking to style a webform that I have with the drupal webform module, but i am having a little bit of an issue. I would like to style the form into 2 columns and I am assuming the best way to go about this would be to throw the content into 2 div separate div tags. I have looked around and came across How do I theme a webform?.

I am using the following line in my file.

<?php print drupal_render($form['submitted']['name']);`

Unfortunately, no matter what I try, I can't seem to get the new webform-form-nodeid.tpl.php to work. They say the file should be created as webform-form-36.tpl.php (where 36 is the node ID, in my case) and that I should put it in my custom theme directory. I have done this and had no luck. I have also tried placing it in the template directory for the webform module, but it didn't work.

Does anyone have any idea on how to help me?

I also found that Drupal 7 looks for two hyphens instead of one. I tried renaming the template file webform-form--36.tpl.php, but it didn't have any effect.

I was able to specify the specific node by changing the filename to node--36.tpl.php, but I still feel like there should be a way doing this with the webform name included. Does anyone have any idea?

Please note that I know I was using 36. I have since then changed to 102.


texts:
My website was working till a few days ago. It suddenly stopped working and showing white screen on every page only when some users including administrator are logging in to it. I added the following line at the top of the index.php

error_reporting(E_ALL); ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

The following error is displaying

  Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away' in /home/******/public_html/includes/database/database.inc:2204 Stack trace: #0 /home/******/public_html/includes/database/database.inc(2204): PDOStatement->execute(Array) #1 /home/******/public_html/includes/database/database.inc(683): DatabaseStatementBase->execute(Array, Array) #2 /home/******/public_html/includes/database/database.inc(2383): DatabaseConnection->query('SELECT expire, ...', Array, Array) #3 /home/******/public_html/includes/lock.inc(167): db_query('SELECT expire, ...', Array) #4 /home/******/public_html/includes/lock.inc(146): lock_may_be_available('theme_registry:...') #5 /home/******/public_html/includes/theme.inc(449): lock_acquire('theme_registry:...') #6 /home/******/public_html/includes/bootstrap.inc(455): ThemeRegistry->set(Array) #7 [internal function]: DrupalCacheArray->__destruct() #8 {main} thrown in /home/******/public_html/includes/database/database.inc on line 2204

I really have no idea what to do.
thanks in advance


texts: How do I pull a featured image from a WordPress feed/post?

texts:
I have a Drupal 7 website. I'm already using Feeds and Feeds Importe modules to pull a feed from a WordPress website. I'm interested in a particular category, for example:

domainname.com/blog/category/obesity/feed

I added a featured image to a post. I used this plugin to add the featured image to the rss feed http://wordpress.org/plugins/add-featured-image-to-rss-feed/

How can I pull the featured image from the feed and post it as a thumbnail image by the teaser text on the Drupal website?


texts: How to capture git's output in drush make?

texts:
We use drush to clone a number of git-repositories during build. Most of the time this "just works", but on (a rare) occasion, a cloning fails.

Unfortunately, all that we get from drush in such cases is:

  Unable to clone repository                                 [error]

The DRUSH_BACKEND piece of JSON is shown, but claims no error ("error":null):

DRUSH_BACKEND:{"type":"notice","message":"Command dispatch complete","timestamp":1411582254.5773,"memory":10891736,"error":null,"packet":"log"}

The actual error message generated by the git-executable is not shown. Is there a way to change that? Simply adding --debug to drush's command line does not do it...

This question may not even be drush-make specific -- the spawning of external programs and capturing their stdout/stderr may be a generic drush thing...

Thank you!


texts:
My site was working absolutely fine but suddenly I got an error:

  The specified URL cannot be found.

Whenever I click on submit button of any form on site (custom/admin, eg: while saving node, while updating user info) browser displays the above error. I found in console, for POST request it shows 404:Page not found error.

I thought server might be blocking POST requests. So I created in test.php file containing simple form and method=POST.  It works fine.  This means there is some problem with my Drupal instance.

I used ddebug_backtrace() for debugging purpose but it is giving me empty response.

Please help me to resolve the issue.


texts: how to make a filter on a view be on the result of a select query

texts: My content has a field called release year  .  I want to be able to make a searchable view which will show only the unique years in this release date as options as a select .  I don't want to hard code the years or have the user have to type in the year.  How can I do this in a view?


texts:
Introduction

I need to prevent node update when two or more users try to update node on almost same instance (simultaneously) and instead put the requests in a queue and process one by one.

A live example

For node/1, if three users u1, u2, u3 try to update node, then only the user on the basis of "First Come First Serve" should be allowed to update the node(read & write) and others should wait in a Queue.

If users u1, u2, u3 request one by one, In this case when the node update by u1 is completed successfully(until then don't allow next request to read data), then only allow u2 to process(read & write), and similarly for u3 and so on.

Here read from u2 depends on final write by u1. One operation should be isolated.

Also the problem is with node_save(). It takes much time when the traffic is more. Is there any way to boost it.

System details:

  Drupal 7.22, 2013-04-03

  Mysql version: 5.1

  PHP : 5.3

  Apache: 2.4


texts:
How to add an existing variation to a product?
When I create a product the form forces me to create a new variation, but I also want to add an existing one to the same product.


texts: Drupal 7 custom form submit handler is not being called

texts:
I am trying to write a custom handler for one of the Drupal 7 forms:

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

 array_unshift($form['#submit'], 'mymodule_formid_submit');

}

function mymodule_formid_submit($form, &$form_state) {
    drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
    return
}

But it is not accessing the handler. Alter method is being called and printing 'mymodule_formid_submit' in the #submit array.

Maybe I am missing something, but exiting answers on Stack Overflow related to custom handlers are not helping in my case.


texts:
I'm pretty new to Drupal, and very new to Drupal 8.  I've created a view, and have set up it up with a display block.  I'm trying to render this on a specific page.  So, I created a page template and a preprocess hook, created the following function.

function MYTHEMENAME_preprocess_node__13(&$variables) {
 $block = \Drupal\block\Entity\Block::load('views_block__downloads_block_2');
 $block_content = \Drupal::entityManager()->getViewBuilder('block')->view($block);
 $variables['downloads'] = $block_content;
}

When I place {{ downloads }} in my page template (page--node--13.html.twig) nothing happens.

Any ideas what I might be doing incorrectly?


texts: how to use "views field view" for entity reference - Not taxonomy

texts:
I've got a view of "webinars," that contains an entity reference "speakers" that can have multiple entries. I can't get those entity references and their own fields into the listings for each webinar, correctly.

I've tried to do this with Views Field View module, but every tutorial shows Taxonomy ID is used. I can't. This isn't a taxonomy. I tried using Content ID, but it doesn't work. What the heck am I missing?

I want:

  WEBINAR 1
   speaker1, title, company
   speaker2, title, company

  WEBINAR 2
  speaker 2, title, company
  speaker 3, title, company


texts:
I've a node with field that store coordinates (in a field with type Geofield).

Now I want to display google map block on page based on coordinates in that field. How should I do it? IS there any module that provide such functionality.


texts: Adding text to a field before save (Drupal 7)

texts:
I run into a situation where I need to wrap text inputted into a field before it is saved. I'm not sure the best way to do this, seems pretty straightforward but I'd like to find the "recommended way", to pull this off.

I have a node type called Post.
There is a field that captures ID -> field_id
Now I want to wrap this in HTML.

For example ->
(some html) . field_id . (/some more html)

Key point is that this append needs to happend before the save, rewritting the field in Views UI happens after the fact.


texts:
In Drupal 7, how can I add additional dynamic markup to a menu item?  As an example, I'm trying to show the number of nodes 'needing attention' to the right of link in my primary navigation as noted in the attached graphic.

It seems like a theme function would be appropriate here, but I'm struggling to find which hook I should be implementing.


texts: copying actual drupal content to a different drupal site

texts: I know that one can use the export link to copy a content type or a view to another drupal site. But if that content type has a lot of content, is there a way to also copy that over as well?


texts: How can I clone and use the default taxonomy view to learn its behavior?

texts:
Views comes with a default taxonomy view packaged with it.

I can see it over here and modify it:

admin/structure/views/view/taxonomy_term/edit

Taxonomy term
A view to emulate Drupal core's handling of taxonomy/term
default/taxonomy/term/%,/taxonomy/term/%/%/feed

Now how do I actually "view" this view!

I want to clone it, modify it and experiment, but can't access it from front end...


texts: How to add behavior-based onclick to ajax-enabled Form API button?

texts:
I have a form with a button:

$form['categories_update'] = array(
  '#type' => 'button',
  '#value' => t('Load category-related properties'),
  '#ajax' => array(
    'callback' => '_mymodule_categories_callback',
    'wrapper' => 'categories_properties',
    'method' => 'replace',
    'effect' => 'fade',
    'prevent' => 'submit',
  ),
  '#limit_validation_errors' => array(),
);

Now, in Behavior I'm using:

(function($) {
  var initialised = false;

  Drupal.behaviors.mymoduleTag = {
    attach: function (context, settings) {

      // Unrelated code

      $('#edit-categories-update', context).on('click', function(){
        console.log('Load category-related prperties clicked');
      });
    }
  };
})(jQuery);

And it simply fails to work - no errors in console, but no code executed either.

It works all right when I comment out '#ajax' part of a button's definition. Is there a way to have both behavior JS and Form API Ajax working for one button?

I'm using jQuery update module in it's dev version, and I have it set to jQuery 1.8. The button is not inside the wrapper, so it's ID is not affected by AJAX call (verified in browser).


texts:
I need to get the date of a scheduled rule and display it to the user.

I also would like (Not necessarily required, I can also use an invisible CCK field) to use the existence of this schedule as a condition in yet another rule.

Is it possible to get this using rules alone or do I need to use the "Execute custom PHP code" condition/action to find them?


texts: Add .active class to a menu link when other menu link is clicked

texts:
I have following scenario:
Drupal 8.5.6, with a bootstrap subtheme.
There are 2 menus (I'll call them main menu and secondary menu).

The links in the main menu are geographic areas, I've managed to add the .active class to the link, based on the url with the help of this answer: https://drupal.stackexchange.com/a/191861/60589 with a preprocess function and tweaking the twig code.

The links in the secondary menu are related to each one of the links in the main menu, so when I click Area 1 in the main menu, a custom secondary menu will appear in this page.

The problem:
I want the main menu link to stay highlihted, when I click on a link of the secondary menu
The URLs look like this:

mysite/areas/area1 ==> the Area1 link in the main menu gets the active class

mysite/areas/area1/otherlink ==> the links in the secondary menu have this structure, I want the Area1 link in the main menu to keep the .active class.


texts: Getting menu heading title in template.php

texts:
I am trying to edit a menu title (heading title) by customising the theme template file.

So far I have been able to customise both the UL and LI elements using THEME_menu_tree__MENU_NAME and THEME_menu_link__MENU_NAME hooks respectively. However, I cannot find a similar function to access the title of the menu.

If anyone has any ideas, I'd be happy to hear them.

Thanks.


texts: Display No Results Text for Individual Field Groups in View

texts:
I have a drupal view set up to show links to certain documents.  These documents are grouped by department in a Grid layout and then sorted by date.  What I want to do is if there are no results available for a particular group in the grid layout, display a no results text line for that.  I am willing to just put php generated text in the header or footer if that is an option.  I do not want to generate a page of non-sense content titled "No Results" to inject it in the grid (that's what we're doing now)...I'm trying to get it to handle itself. Hopefully this layout will demonstrate it better if it's hard to understand:

  Department Documents

  Department 1

  04/25/2015 <--(These dates are rewritten to link to documents)

  04/26/2016

  Department 2

  No results

  ...

Edit

I would rather not make this behavior global for all Grid views, if possible.  I have other grid views where I do not want to display this, it is only on this one view.


texts: Access Denied when Menu CallBack Function is Called

texts:
I am trying to call a function after the user clicks on an ajaxified link below.

$form['link'] = array(
  '#type' => 'item',
  '#markup' => l(t($record->studid),'myid_print/callback', array('attributes' => array('class' => 'use-ajax'))),
);

Below is my hook_menu function:

function myid_print_menu()
{
    $items = array();
    $items['myid_print/callback'] = array(
        'page callback' => 'myid_print_user_page_callback',
        'access callback'    => 'myid_print_user_access',
        'file' => 'myid_print.pages.inc',
        'type' => MENU_CALLBACK,
    );
    return $items;
}

function myid_print_user_access()
{
    return TRUE;
}

myid_print.pages.inc file:

function myid_print_user_page_callback()
{
    return 'Successful';
}

The above code throws the error below:

Where am I missing?


texts: Is it possible to get access to files uploaded via FTP in the media module in Drupal 7

texts: I installed media module to select files from server instead of directly upload them but in the library tab only the http uploaded files are available not the FTP uploaded files. Is it possible to get access and select FTP uploaded files via media module?


texts:
How to retrieve date from a date field and store it in computed field? I have tried this code:

$start_date = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_start_date')));
$entity_field[1]['value'] = $start_date;

But it displays 'datetime'. I want to retrieve the value.


texts: Is it possible to authenticate against LDAP server without creating a drupal user account

texts:
In D7 I have a section of my site I need to limit to authenticated users, but auth needs to take place against LDAP server, not drupal user base.

My users don't have a Drupal account and I am not supposed to create one for them, I am required to just check in with the LDAP server and if TRUE, grant access to these pages, if FALSE deny access.

All the LDAP modules I have tested create a Drupal user to mirror the LDAP user, as far as I can see. And it seems to me I couldn't even really keep the user "logged in" without a Drupal account...

What options do I have here, if any?


texts: how to install drupal with myisam and different collation

texts:
How to install Drupal with MyIsam instead of InnoDb and with utf8_unicode_ci collation?

I know there are ways to change/convert both afterwards, but maybe its possible to specify it as installation parameter - it would be simpler.


texts: Combining views slideshow and views gallery on single page

texts: I have a views Slideshow on one page. I also have a views Gallery on another page. I want the views gallery to appear below the views slideshow on a single page. Please could anyone help me out. I have been trying a lot, but I'm unable to do this.


texts: Understand message before updating a module

texts:
If I go to admin/reports/updates I see modules that need to be updates.

I just need to know what is the difference between the message "Recommended version:..." and the other message with red background. I mean what are the risk of not updating them?


texts:
When I log out of my site, I'm getting these notices.

Notice: Trying to get property of non-object in user_access() (line 798 of /demo/startint/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 810 of /demo/startint/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 811 of /demo/startint/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 817 of /demo/startint/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 820 of /demo/startint/modules/user/user.module).

Just as if $account and/or $user variable(s) failed to set at the beginning of user_access(). Drupal 7.19. Does this ring a bell to anyone?


texts: Nodes not get indexed after running manual cron

texts:
I'm experiencing some unexpected behavior of cron. I have used search_api module, that should index all nodes. Automatic cron is set to 1 hour. So after every hour, cron will run automatically.

So, the issue is, I created node, and search its content, it is not searchable.

I ran cron, then searched again, still its not searchable.

After 2-3 times hitting cron manually, the content becomes searchable.

Although, for 1-2 content types, content will become searchable after hitting cron for the first time.

I have total 4 content types, and 100 nodes in my whole site.

Forcefully running cron after 3-4 times, make nodes content searchable, else my nodes are not searchable.

Is it the known issue of Drupal core or what would be the problem, I'm not able to figure out as why nodes are not getting indexed automatically? Even after cron run for Ist time, nodes not get indexed.

Any help is really appreciated.

Module used: Search_api (version = 8.x-1.5)

Note: I can't used updated version of search_api as of now, because my current version of Drupal is 8.3.6, and latest release of search_api module is not compatible with this older Drupal version.

EDIT
I have written a custom cron too, to run cron after node gets created, but this is also not solving this late cron run issue.

function mymodule_cron() {
  $nids = \Drupal::entityQuery('node')
    ->condition('created', array(time()-3600, time()), 'BETWEEN')
    ->execute();
  // Load all the nodes.
  $nodes = Node::loadMultiple($nids);
  foreach ($nodes as $node) {
    $node->save();
  }
}


texts: Ajax request: 500 (Internal Server Error)

texts:
I am using this jQuery plugin to render a toggle button in a block. When the button is toggled off/on I want to write to a databse table (with entity_save). Here's the relevant code I'm using to try to acheive this:

// hook_menu item
$items['product-status-update'] = array(
  'title'=>'Status update',
  'page callback' => 'my_module_status_update',
  'access callback' => 'product_entity_access',
  'type'=> MENU_CALLBACK,
);

// jQuery
drupal_add_js('
  (function($) {
    $(function() {
      $(".toggle-button").toggles({' . $status . $state . '});
      $(".toggle-button").on("toggle", function (e, status) {
        status = status == true ? 1 : 0
        $.ajax({
          type: "POST",
          url: "?q=product-status-update",
          data: "pid="+' . $pid . '&"status="+status,
        });
      });
    });
  })(jQuery);
', 'inline');

// Callback
function my_module_status_update() {
  $pid = $_POST['pid'];
  $status = $_POST['status'];
  $product = entity_load_single('product', $pid);
  $product->status = $status;
  entity_save('product', $product);
}

// Console log output when toggling
POST http://example.com/?q=product-status-update 500 (Internal Server Error) jquery-1.10.2.js:8706
1 ?q=home:98
0 ?q=home:99
POST http://example.com/?q=product-status-update 500 (Internal Server Error) jquery-1.10.2.js:8706
1 ?q=home:98
1 ?q=home:99
POST http://example.com/?q=product-status-update 500 (Internal Server Error) jquery-1.10.2.js:8706
1 ?q=home:98
0 ?q=home:99

As you can see from the console log output I am receiving: 500 (Internal Server Error).

Any ideas why or what might be the culprit? Thanks.


texts:
I'm working on a site that, in production, will have no logins. We've gone with Drupal to facilitate the creating and editing of content by non-experts.

My question is, in this scenario, what's the best practice for allowing an administrator to log in? Since there no login on the main site, how does an admin access it?

I know there's the standard page mysite.com/user or mysite.com/user/login. Leaving that out there where knowledgeable users could find it seems less than ideal to me.

Is that how people do it? Or is there another way?


texts: ubercart invoice generation to allow user to request funds withdrawal

texts:
I have a site where user purchases some service and once the service is received by the purchased person, i should allow the service provider to raise a invoice order to request funds.

what are the modules that i should use to achieve this


texts: I'm writing a routine to track inline image usage in panel panes every time the panels content form is submitted. The hook_panels_pane_update hook works, but only after the second time the form is saved. Is there a hook that will trigger the first time the form is saved?


texts: Custom form submit handler is called, but node is not saved

texts:
There are many questions about a custom form submit handler not being called, but in my case, the handler is being called; however, the entity is not being saved.  Specifically, I have a custom submit handler on a content type; when I press the button to call the handler, nothing is saved in the database:

function MYMODULE_form_node_CONTENTTYPE_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  $form['actions']['submit_publish'] = array(
    '#type' => 'submit',
    '#weight' => 999,
    '#button-type' => 'danger',
    '#value' => t('Submit for approval'),
    '#submit' => array('MYMODULE_draft2submit_callback'),
  );
}

function MYMODULE_draft2submit_callback(array &$form, FormStateInterface &$form_state) {
  $form_state->setValue('moderation_state', 'submitted');
}

So I thought since the node is not being saved, maybe I have to do it manually.  Following this article, I did this:

function MYMODULE_draft2submit_callback(array &$form, FormStateInterface &$form_state) {
  $form_state->setValue('moderation_state', 'submitted');
  $node = $form_state->getFormObject()->getEntity();
  $node->save();
}

However, in this case, the node is saved, but none of the submitted values (the node body, for example) are saved; everything added by the user is ignored, as is the setValue() in my callback.

I only want to set the moderation_state in my custom form submit handler; in all other ways, I want my custom submit handler to be the same as the normal submit handler (i.e., I want it to save the node).  What am I doing wrong?


texts: Deleting field revisions directly from the database

texts:
With full recognition that this is not considered a best practice (and is generally considered a worst practice) does anyone know if it is safe to delete field revisions directly from the DB via a DELETE query assuming I can guarantee that only the latest revision is being used/referenced everywhere on the site.

I ask this question because I have a particular field that has grown so large the our update hook is taking too long. I'm looking to cheat and seeing if anyone has had experience with this.


texts: How do I force my nodes to all show up at a given path, without adding them to a menu?

texts:
My site has a set of events, all with the content type "event". I don't want to have to add them to the main menu manually, because there's hundreds of them and they'll make the menu very cumbersome to manage. I'd like each event to show up with the same breadcrumb and secondary menu as the view that displays all events.

So I added a hook_node_view to try and force all event nodes to show up in the same place as the events listing:

function MYMODULE_node_view($node, $view_mode, $langcode) {
    $menu_name = variable_get('menu_secondary_links_source', 'main-menu');
    if ($view_mode == 'full' && $node->type == 'event') {
        menu_tree_set_path($menu_name, 'events'); // 'events' is the path to the view listing
    }

This only works when the nodes are already added to the main menu manually (i.e. it can be used to override the path, but won't do anything if the node isn't in the menu already).

Is there an easy way to force Drupal to always return my hardcoded path for a given content type?


texts: How to select FROM {commerce_product} p WHERE p.field_TERMFIELD = $given_tid and the resulted p.product_id is referenced on a given nid

texts:
Known values:

The nid of a node that has reference to more than one commerce_product
The tid from the field_TERMFIELD field attached to the commerce_product entity

commerce_product entity is referenced on the node entity via a multivalued entity reference field. When my known node has more than one referenced commerce product, I gotta figure out which one of those referenced products has a given tid.

A solution via either db_select() or EntityFieldQuery() are welcome.


texts: How to include js file in a module which depend on jquery?

texts:
I have a module called catalog_menu

I included a js file within this module in this way:

drupal_add_js(drupal_get_path('module', 'catalog_menu') . '/js/catalog_menu.js');

Now in the browser I get this error message:

Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function

I think that the problem is that catalogo_menu.js is loaded before jquery.js (the jquery library)

What is the right way to load a js file which depends on jquery library?


texts:
For my template I need to point to a subfolder in templates folder: templates/sub-folder/my-wall1.html.twig, the file is there, but nothing works.

What are the rules?

translate minus (-) to underscore (_)
...

function my_module_theme() {
  return [
    'wall1' => [
      'template'  => 'sub_folder/my_wall1',
      'variables' => [
        'w1' => NULL
      ],
    ],
  ];
}

Update: According to the answers, I tried the following:

test/test.html.twig < does not work
test.html.twig < works, without subfolder and a name like this

An example or point to documentation would be great too?!
Thanks.


texts: Drupal 8 Form Redirect On Failed Validation

texts:
I have a form which, upon failed validation, should query a custom/non-Drupal table, and if that query is successful, to redirect the user to a custom page that is only accessible through a logged-in state (so I need to "fake" successful authentication even if the user does not exist in the official Drupal users table).

The query to the custom table essentially checks a secondary user list in non-Drupal format upon failing to authenticate the official way, and if successful, would redirect the user to another page where they could select a Drupal username and password combination in order to register them in the system / make an official account.

This is the relevant code inside my form validation method:

if ($this->userAuth->authenticate($form_state->getValue('name'), $password) == FALSE) {
    // other stuff
    $uid = $this->userAuth->authenticate($form_state->getValue('name'), $password);
    $form_state->set('uid', $uid);

    $response = new TrustedRedirectResponse('/path/destination');
    $form_state->setResponse($response);
}

I have also tried this instead of the new TrustedRedirectResponse:

    $redirect_path = "/path/destination";
    $url = url::fromUserInput($redirect_path);
    $form_state->setRedirectUrl($url);


texts: Why do I get "Undefined index: mail en comment_form_validate()"?

texts:
Is there a way to fix the notice I get?

  Notice: Undefined index: mail en comment_form_validate()
  Notice: Undefined index: homepage en comment_form_validate()

This appears in my message area with the errors for comments, only if I enable the development snapshot of the module to display errors or warnings (the configuration say I should turn this off in production), but I'm not sure if this is normal.

Should I ignore this? The default comment module doesn't display this bug, with or without the  development snapshot settings working. Does anyone have a suggestion?


texts:
How do I theme a CCK input form?
I tried the approach given in this page, but it is not working even after I clear the cache.
Here are the steps.

Suppose your content-type is: "account_registration" and you theme is "bluemarine".

I edited template.php and added this code:

function bluemarine_theme($existing, $type, $theme, $path) {
  return array(
    'account_registration_node_form' => array(
      'arguments' => array('form' => NULL),
      'template' => 'node-account_registration-edit'
    )
  );
}

I created node-account_registration-edit.tpl.php:

<?php
  $form['buttons']['submit']['#value'] = 'Done';
  $form['buttons']['preview']['#access']= FALSE;
?>

I cleared cache and edited a node, but the above changes are not showing up.


texts:
I've got a block created with views, which displaying a slider.
The slider is created as an unpublished content type with two field collections:

Settings[one value]:

selectors type: thumbs or bullets
slider class: fixed position, faded etc.

Slider content[multiple values]:

slide class
content class
Image
content

I do not use views slideshow module
I'm using views-view--slider-block.tpl.php file to customize the output

All works, but I have stuck with one specific setting "fixed position" - this setting should add to html a special class, which I guess can be added only by preprocess_html function:

function MYTHEME_preprocess_html(&$variables) {
    if ( SLIDER HAS "fixed" SETTING ){
        $variables['classes_array'][] = 'slider_fixed';
    }
}

the problem is:

how to compose the if statement?
Did I have to load $view object which allows me to check what
setting is used?

I'm looking for the solution which has the lowest influence on the performance.

any suggestions?