texts: User register and login functions are called from hook_form_alter, but user isn't logged in

texts:
Background

I'm attaching the user register form, to the node create form with hook_form_alter. that way I create a node and user at once.

In order to validate and register the user, in hook_form_alter I add the relevant functions to my node form submit and validation calls.

function mymodule_form_alter form_alter(&$form, &$form_state, $form_id) {
   ....

    $form['#validate'][] = 'user_account_form_validate';
    $form['#submit'][] = 'user_register_submit';

Problem

The node is created and the user is created but the user isn't logged in.

Why isn't the user logged in?

The user register and login code seems to be running ok (see below), I can only think somehow the node creation is logging the user out? I have no idea how to continue debugging this.

Debugging

Thanks to Felix, I was able to debug by logging dpm (because it doesn't appear on the page) and the code is running correctly.

user_login_submit is called from user_register_submit

function user_login_submit($form, &$form_state) {
  global $user;
  $user = user_load($form_state['uid']);
  $form_state['redirect'] = 'user/' . $user->uid;
  user_login_finalize($form_state);
}

And then user_login_finalize is called.

function user_login_finalize(&$edit = array()) {
  global $user;
  watchdog('user', 'Session opened for %name.', array('%name' => $user->name));
  // Update the user table timestamp noting user has logged in.
  // This is also used to invalidate one-time login links.
  $user->login = REQUEST_TIME;
  db_update('users')
    ->fields(array('login' => $user->login))
    ->condition('uid', $user->uid)
    ->execute();

  // Regenerate the session ID to prevent against session fixation attacks.
  // This is called before hook_user in case one of those functions fails
  // or incorrectly does a redirect which would leave the old session in place.
  drupal_session_regenerate();

  user_module_invoke('login', $edit, $user);
}

I printed out $edit and $user and $edit is $form_state and $user is the newly created user. I can't see anything going wrong. The session opening is logged by watchdog, however perhaps it's never assigned?

How else could I continue to debug this? Could drupal_session_regenerate() be logging me out?

EDIT: I switched the user_register_submit to logintoboggan_user_register_submit, which worked on my dev environment but then broke on production with the same problem as above.

It doesn't appear to be a code problem, but something to do with the database or a setting. I dropped my production front end in front of my dev backend and it works fine, so it's some sort of database setting (which could of course effect the front end code).


texts: Creating account type where email not required to be unique

texts:
I'm developing a platform for Drupal 8 where there are several account types: students, their parents, teachers.
The students are young and we want their accounts associated with their parents' emails for security reasons, and there are cases where the parent has two or more students on the system. Also, each parent and student will have logins to their own areas.
So I need to be able to create student accounts where the email address is not required to be unique. And for the student accounts I need the password management (forgot/reset) to be done by username, not email).
Is it possible? How can I achieve this?


texts:
I'm working with Twig templates, and often see messages like this in the browser when I make a mistake:

The website encountered an unexpected error. Please try again later.

Twig\Error\SyntaxError: Unclosed &quot;{&quot;. in Twig\Lexer-&gt;lexExpression() (line 153 of themes/mytheme/templates/page.html.twig).
Twig\Lexer-&gt;lexBlock() (Line: 126)
Twig\Lexer-&gt;tokenize(Object) (Line: 705)

...etc.

Is there a way to automatically render the above HTML rather than having it output as a string? Thanks.


texts: It's possible to pass a variable on attach_library in a template on Drupal 8?

texts:
I need to pass a variable to a library called on a Twig template, is this possible?

{{ attach_library('theme/some-library') }}


texts:
How is it possible to create a new Drupal distribution based on site that I already built? I've already exported the content types using

drupal config:export:content:type MYCONTENTTYPE --module MYMODULE

Drupal console has the following function which may be useful.

https://hechoendrupal.gitbooks.io/drupal-console/content/en/commands/generate-profile.html

This following link leads to the current drupal.org documentation on creating a Drupal 8 distribution. It looks like it only shows how to create a distribution manually though.

https://www.drupal.org/docs/8/creating-distributions/how-to-write-a-drupal-8-installation-profile

I was hoping that there was something in Drupal console or Composer that would take all the information in my current database and create an installation profile out of it.

EDIT

The Drupal Profile Builder seems wonderful but current only supports D7.


texts: Comments not displaying for node that was added to a custom page

texts:
I’m attempting to make it possible for users to add comments to a custom page that was created via Page Manager. My understanding is that it is not possible to set up and allow commenting for page but only for nodes. Therefore i created a special content type and corresponding node and added it to the page. i added via ‘Add existing node’ option.

I’ve added comments to this special node but they are not being displayed when viewing the node in context of the custom page. Does anyone know how i can get these comments to display?


texts: Access denied for custom configuration form translation

texts:
I get access denied for just the translation page of a config form. I can access the configuration form and update it. No problem there.
The form lists in config-translation page as well, but when I click on Translate it gives access denied. I'm logged in as Admin. Below is the code as suggested here in my custom module (samplewil.module).

samplewil.links.menu.yml

samplewil.set_admin:
  title: 'sample settings'
  parent: system.admin_config_system
  description: 'Configure sample settings'
  weight: -10
  route_name: samplewil.set_admin

samplewil.routing.yml

samplewil.set_admin:
  path: '/admin/config/sample-settings'
  defaults:
    _form: '\Drupal\samplewil\Form\SampleForm'
    _title: 'Sample'
  requirements:
    _permission: 'administer site configuration'

samplewil.settings.yml

message: 'Hello'
 langcode: 'ar'

samplewil.config_translation.yml

samplewil.set_admin:
  title: 'Example Translatable config'
  base_route_name: samplewil.set_admin
  names:
    - samplewil.config

samplewil.schema.yml

samplewil.config:
  type: config_object
  label: 'Example config'
  mapping:
    message:
      type: text
      label: 'Message'

My default language is Arabic and I've given 'ar' in settings.yml.
Any idea why I'm not able to translate?


texts: How are .inc files actually utilised in a module?

texts:
I am trying to learn more about modules and have noticed several of the ones I've been investigating contain .inc files, eg: module_name.inc or module_name.theme.inc.

It's clear these contain hooks and functions and are probably separated out just for organisational purposes.

But how does the module/Drupal know these exist? How are they called upon? I see no reference to these files in the module_name.module file. Does Drupal automatically include all .inc files within the module's directory?


texts:
I tried Dynamic background module but it seems it's not what I am looking for. Is there such a module that will allow me to change the background for a certain pages or group of pages that works the same like block?

Like in Block, I can select which pages this block will be shown.

Example:

    Show background on specific pages
         All pages except those listed
         Only the listed pages

I believe there's a module that can do this, I would be very glad if somebody can point me to the URL of the module.

Thanks in advance.


texts: user relationships - add friend link in a content-profile node

texts:
I have installed the User Relationships module, and I have questions about how it works.

When you install the module, a "relationships" link should be added in a user profile page (users/myname), but in my case it doesn't; I've modified user-profile.tpl.php, and cleared the cache, but still the link doesn't appear. What's wrong?

How can I add a link to "add/remove friend" on a content-profile node of user? And also how to output list of user's friends? I guess a view block would help me in this situation.


texts: What is the Views 3 equivalent of the MySQL Limit 1 in order to return just the latest record

texts:
I want to display data from the latest activity record for each contact in a report created using views 3 / Drupal 7

In MySQL I'd use sorts and limit to give me the result I want (the following is not the full query, which of course would have joins)...

SELECT column_name FROM table_name
ORDER BY column_name DESC
LIMIT 1;

What is the equivalent in Views 3? I know how to sort, but how do I limit?

I don't think that limiting the results on a page is the answer - I'm quite happy with a table with 200 rows, it is just that I want only one row for each contact displaying the data from just the latest activity record associated with that contact.

Any clues anyone?


texts: How reliable is hook_post_action module?

texts:
I am using this module under Drupal 7 to execute some code after nodes of a particular content type get updated. My question, is this module reliable? Would the post save event be called every time my target nodes get updated?

This is the module's page:
https://www.drupal.org/project/hook_post_action


texts: Modify the visibility of a form field label with #label_display attribute

texts:
In D7, I am trying to "hide" a field label through form_alter:

 case 'postal_code_node_form':

   // Set fields as not required
    $form['title']['#required'] = FALSE;
    $form['body']['#required'] =  FALSE;

    // Add css to hide fields.
    $form['body']['#attributes']  = array('style' => 'display:none');
    $form['title']['#attributes'] = array('style' => 'display:none;');

    $form['body']['#label_display']  = 'hidden';
    $form['title']['#label_display'] = 'hidden';

    break;

Unfortunately, the label is still displayed. I could do it through CSS or JavaScript, but I would prefer doing this through hook_form_alter(), so all form modifications are at the same place.


texts: Bootstrap Subtheme undefined variable error for custom node type template

texts:
I am using the Bootstrap theme, I created a subtheme and duplicated page.tpl.php into my subtheme: /subtheme/templates/system/page.tpl.php

I then duplicated page.tpl.php and renamed to node--[mytype].tpl.php. The template is registering but it is filled with "undefined variable" errors. The errors don't happen /subtheme/templates/system/page.tpl.php  but happen when I add node--[mytype].tpl.php despite having the same code.

I've tried putting in node--[mytype].tpl.php in different directories including subtheme root and /templates/ but errors persists.


texts: Colorbox + jCarousel + slideshow + compact mode?

texts:
I'm looking for a good solution (preferably as one integrated module) that would allow to display images in a multi-value image field in any kind of a lightbox, have a compact mode so that only the first image is shown, display a carousel beneath, and provide slideshow.

I've tried: Colorbox, Field Slideshow, jCarousel, Shadowbox.

Colorbox was nicely integrated with Field Slideshow and provided a pager, but it had a strange bug which causes certain images on the main page beneath to be cloned upon every click within the Colorbox layer. Shadows wins over it even though is paid. Colorbox does not have a compact mode - if I set explicitly number of images to show to 1, all remaining images become unavailable and the slideshow is automatically disabled, otherwise, all of them appear on the node.

A while ago I gave also a try to Lightbox2, but I gave up on it, being unsuccessful at enabling its compact mode.


texts: js file run again when file upload ajaxly

texts:
I have a js file that I add it to my form in hook_form_alter with drupal_add_js, in my js I set a click handler on Html object(lets name it ".myhtml" ), everything work correctly in first load. I have a multi value image field in my form and when try to upload a image ajaxly , my js run again , and when I click on ".myhtml" my click handler called twice ( if I upload two image it fired triple and ... ).

One of my solution was first unbind then bind click,it work but I used icheck Jquery plugin for that  field,then when I unbind it( icheck plugin ) will not work.
So my problem is  prevent run js file to again when file uploaded by ajax.

part of my code
in hook_form_alter

    $scripts = drupal_add_js();
    $jspatah = drupal_get_path('module', 'tgdev') . '/tgsp.js';
    if(!isset($scripts[$jspatah])) {
        drupal_add_js($jspatah, array(
            'type' => 'file',
            'scope' => 'footer',
            'every_page' => FALSE,
            'weight' => 10,
        ));
    }

and part of my js file

 (function ($) {
Drupal.behaviors.tgdev = {
    attach: function (context, settings) {
      $(document).ready(function(){
            if($('#edit-field-images .image-preview').length==0){
            $('.form-item-field-feature-und-email .iCheck-helper ').on('click', function () {
                  if($(this).parent('.icheckbox_line').hasClass('checked')) {
                  console.log('checked');
                     getSubsAj('mail');
             });
             }
        console.log($('#edit-field-images .image-preview').length);
        });
      }
    };
})(jQuery);


texts: New Modules Not Listed at admin/build/modules

texts:
So I'm trying to install the Backup and Migrate module on an older drupal site (still 6.22) but it, or any other module, wont show up on the list of modules at admin/build/modules.  The current modules (active and not active) show up, but nothing new will.

All files and sub-folders have the same permissions and owner of the new modules, also tried flushing all caches.

What else could cause this?


texts: How to show fontawesome icons in admin page inside Ckeditor?

texts:
I managed to insert fontawesome iconS using Ckeditor with the Font Awesome Icons v1 module.

I just put this code in the HTML view of Ckeditor.

<i class="fa fa-camera-retro fa-lg">&nbsp;</i>

The icon is shown correctly in frontend but in CKEditor it is not shown at all.

I guess I need to load all fontawesome files inside Ckeditor. How can I do this? I need to see the icon in ckeditor in the same way as I see it in frontend.

Fontawesome is located at: sites/all/libraries/fontawesome


texts: Feeds Setup to Automatically Update and Delete Nodes

texts:
I have an RSS feed from which I use Feeds module to fetch data from this to create nodes of a particular content type, I then use Views to display this information.

What settings do I use to setup Feeds module to automatically keep the nodes created in sync with an RSS feed?

This seams like it should be quite easy but I am coming across some trouble with this. The RSS feed has new items added, items updated and items deleted, so the feeds module need to look for all of these and be in sync with these changes.

These are my Settings:

Attached to: None
Use Standalone form
Periodic import: Often as possible
HTTP Fetcher
XPath XML Parser
Replace existing nodes
Skip has check
Expire nodes: after 1 day (this I set to delete nodes to keep in sync with items being removed)
Elysia Cron is set to run update at 2am.


texts:
I have taxonomy terms installed and there I have article categories listed.

I have a lot of categories and articles. Now I need to import more categories from .txt file.

What is the best way to do this? I don't want to create these categories one by one.


texts: How add new tab in structure when manage it?

texts:
I try to do own User Graffic Interface. That interface must help to managers do they are own form displays. By drug`n drop elements in space. Then when they push save. I will save coordinats of elements. I need to show my module in other (new one) tab when manage in structure. I have little exp. working with drupal. But deadline is coming close. I sware i will give this module for avryone. So i need help. (pls. didn't write about Display Suit.)

<?php
/**
 * Implements hook_form_FORM_ID_alter().
 */
function admt_form_node_type_form_alter(&$form, &$form_state) {
  $default_value =TRUE;// auto_nodetitle_get_setting($form['#node_type']->type);

  $type = $form['#node_type'];
  $form['#theme'] = 'admt_form_theme_function';
  $form['admt'] = array(
    '#type' => 'fieldset',
    '#title' => t('Graffic User Interface'),
    '#weight' => 0,
    '#collapsible' => TRUE,
    '#collapsed' => false,
    '#group' => 'additional_settings',
    //'#theme' => 'admt_form_theme_function',
    '#attached' => array(
      'js' => array(drupal_get_path('module', 'menu') . '/menu.admin.js'),
    ),
  );

    if (isset($type) && $type->has_title) {
    $title = $type->title_label;
    }
    $fields = array();
    $arrFieldsType=array(
    "number"=>"textfield",
    "text_textfield"=>"textfield",
    "options_select"=>"select",
    "taxonomy_autocomplete"=>"textfield",
    "text_textarea_with_summary"=>"textare",
    "image_image"=>"file",
    "checkboxes",
    "radios"
    );
  $instances = field_info_instances('node', $type->type);
  $extra_fields = field_info_extra_fields('node', $type->type, 'form');

  // Fields.
  foreach ($instances as $name => $instance) {
    $form['admt'][$name] = array(
    '#type' => $arrFieldsType[$instance["widget"]["type"]],
    '#title' => t($instance["label"]),
    '#default_value' => array('value' => '...'),
    //'#options' => $type2,
     );
        if($arrFieldsType[$instance["widget"]["type"]]!="select") $form['admt'][$name]['#size']= '20';
  }

  // Non-field elements.
  foreach ($extra_fields as $name => $extra_field) {
    if(!empty($extra_field["type"]))
    $typ=$arrFieldsType[$extra_field["type"]];
    else
    $typ="textfield";
    $form['admt'][$name] = array(
    '#type' => $typ,
    '#size' => '20',
    '#title' => t($extra_field["label"]),
    '#default_value' => array('value' => '...'),
    '#description' =>  t($extra_field["description"]),
    //'#options' => $type2,

     );
  }
  return $form;
}
function admt_theme($existing, $type, $theme, $path,$form)
{
  return array(
    'admt_form_theme_function' => array(
      'render element' => 'form',
      'template' => 'admt',
      'form' => $form,
    ),
  );
}


texts: How to hide 'Configuration' tab for specific user

texts:
I'm looking for a way to configure the Backend for a specific user.
For example: I want to hide the 'Configuration' tab.


texts: This is a general question that I couldn't find a satisfactory answer to. Apart from the obvious, making a node visible on the user side versus keeping it in a 'draft' mode, what does publishing a node accomplish? Especially if the node isn't front-end content.


texts: How to create a module Dependency Graph?

texts:
I am running a D7 site with 164 enabled modules. I need to create a module dependency graph so that I can get a better understanding of the module dependencies and find out which modules are critical.

I have checked out https://drupal.org/project/drush_mm but the page says it is obsolete and not present for D7.

Any alternatives?


texts: Images not appearing properly when migrated from web server to local

texts:
I copied all the files from my web-server to my local-host. Then i imported the databases as well. All functionality on the site works perfectly, but most of the images are breaking.

I tried opening any image on new browser tab, but i got an error: Error Generating Image.

I checked all the permissions and also the file path in admin/settings/filesystem and it set to sites/default/files.

Whenever i inspect any image i get the following address

 http://localhost/sites/default/files/styles/square_thumbnail/public/pictures/picture-177-1368495296.jpg

It looks fine but it shows Error generating image. Any suggestions.


texts:
I am creating a website in which i am already created two view (1. Category 2. Location) , now i am created the taxonomy for Location and in Category view  I am exposed the Location Taxonomy,,, and in Location View here also i am exposed the view-block,,, so the Taxonomy is same in both views,, Now I want to know that if I will select the Category view Location  then automatically Location will be select in @nd view (Location view),,,

Plz provide any suggestion ..?

Here is the image of Location View (1st pic):

Checkbox (2nd pic):

So if i will select the Bangalore in Search Menu in 1st pic,  then the Bangalore will automatically selected in 2nd pic (View) (i.e. in checkbox).


texts: I istalled webform2pdf and tcpdf for download forms and i create form i cconfigure webform2pdf  but when i Click in download pdf on the form that i was created i have a error say :  Fatal error: Call to a member function setHeaderFont() on a non-object in C:\wamp\www\drupal\sites\all\modules\webform2pdf\includes\webform2pdf.theme.inc on line 96 i dont know why ??!!


texts:
I have used the following code on submit of a form to first send the form contents via guzzle and then redirect the form.  I get the error

Error: Call to undefined function TrustedRedirectResponse()

this is my code:

use Drupal\Core\Routing\TrustedRedirectResponse;

function mymodule_submit(&$form, FormStateInterface $form_state){
$url="xyz.com";
$post_data=array("color"=>"red");

$client = \Drupal::httpClient();
  $response = $client->request('POST', $url, [
    'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
     'verify'=>false,
    'form_params' => $post_data,

     ]);
    $status = $response->getStatusCode();

    $response = TrustedRedirectResponse(Url::fromUri($url));
    $form_state->setResponse($response);
}

I have two questions - how can I avoid the error , and is the order of getting the guzzle response and then getting the redirect response the correct order?


texts:
Is it possible to filter nodes based on whether a certain context (defined by context module) is active? I can't find a way to do this. I'm using Drupal 6 and context 6.x-3.0.

Let's say we have a certain menu path that activates a context. In this context I have a view and I need to filter nodes that belong to the context (that is they belong to the menu, that activates the context).


texts: How to delete a module from the Modules menu?

texts: I have installed a few modules that I don't use at all. I can't find any option to uninstall them. How do I do it? Is there a separate module to do it?


texts:
I'm making a site that has three different content types.  I would like a Main-Menu link to each content type.  Additionally, I would like each of these three pages to list recent nodes for that content type, with a link to to that node.  I would think this is pretty standard.

So I've created the content types, and I can click directly to each content type, but I do not know what the "best practice" would be to create these pages.  I could create an override of node--mycontenttype.tpl.php but is this the right way to go?  How would I link to the general page (instead of the specific node)?


texts: Custom node access, need to rebuild permissions for each content item created

texts:
I have a module that handles node access to a custom content type with hook_node_access. Basically, an anonymous user needs to enter a passcode to view the page. Currently, I'm doing this through session variables. If they have $_SESSION['example'] set, return NODE_ACCESS_IGNORE, otherwise

drupal_goto('form');
return NODE_ACCESS_DENY;

Currently, after I create a new content item, the anonymous user will submit the code, be redirected to the content item, and then get an access denied error.

If I rebuild the permissions, the access will work properly, but not for any content items I create after the rebuild.

The Content Access module is enabled on the site. Testing locally, I have tested both disabled (not uninstalled) and enabled content access module and access is currently working as intended.


texts: Passing third-party variables to contact form view

texts:
I am using the following modules provided by default from Drupal's core - Contact and Contact Storage to manage simple contact forms.

For my module, I needed to include a title and sub-title fields in my contact forms, so I decided that the approach taken in Contact Storage suits me the most and I did the following:

In my .module file I implemented hook_form_FORM_ID_alter() like this - module_form_contact_form_form_alter(&$form, FormStateInterface $form_state) {} in which I placed my fields $form['title'] and $form['sub_title']
Then I added custom form builder function so that I can store my extra data using the functionality provided by ThirdPartySettingInterface like this $form['#entity_builders'][] = 'module_contact_form_form_builder';
In my custom builder function I invoke only the method to store my custom data, like this: $contact_form->setThirdPartySetting(/** **/);

So far - so good. I can save and later on, edit the data, but there comes in my problem:

How am I supposed to pass these two fields to my view/template? I tried to look for some _preprocess hooks, but I don't know how to access the data stored by ThirdPartySetting outside of form scope.

I want to state that I am fairly new to Drupal development whatsoever, so any kind of advice would be highly appreciated.


texts: Taxonomy menu limited to certain number of terms

texts:
Wondering if anyone can steer me in the right direction on this. I'd like to have a taxonomy menu where I have a few main terms listed with with around 5-7 children terms. When the user is on the page of the main taxonomy term, all of the child terms are shown.

For example, when the user is on the home taxonomy page that lists all of the terms then the menu would show this:

-Term 1
--Term A
--Term B
--Term C
--Term D
<more>

-Term 2
--Term A
--Term B
--Term C
--Term D
<more>

Clicking on  or clicking on the Term 1 page would then show all of the children of Term 1:

-Term 1
--Term A
--Term B
--Term C
--Term D
--Term E
--Term F
--Term G

-Term 2
--Term A
--Term B
--Term C
--Term D
<more>

Here is a link to a site that already does this and that is where I got the idea.

Any help would be much appreciated!!


texts: How can I alter node markup from a custom module (not theme)?

texts:
In a custom D8 module (not a theme or sub-theme) what is the best way to alter all nodes of a specific content type by prepending them with simple markup?
I'm trying this approach with no success ...
custom/custom.module:
<?php
/**
 * @file
 * Custom module hook implementations.
 */
/**
 * Implements hook_theme().
 */
function custom_theme() {
  return [
    'custom_article_node' => [
      'template' => 'custom-article-node',
      'variables' => [],
    ],
  ];
}

custom/templates/custom-article-node.html.twig:
<i>This is a Custom Article node.</i>
{{ content }}

I'm not sure how to pass the node to the template, or to test what content type it is ... and I'm not sure if this theme hook is even executing.
(I know how to override templates in the theme layer, but in this case I need to do it in a custom module.)


texts: I've installed Entity Print in order to create PDF files. I've read the documentation to enable a twig template to customize the pdf output, but I don't know how to do simple things, in the twig file, like add a page header and footer, add a front page, etc. Are there any docs about how to customize it?


texts: Add a class to the first li.pager-item for a view pager?

texts:
How can I add a class to the first li.pager-item and a different class to the last li.pager-item for for a Views pager?

I know that I need to make a theme override of theme_pager
https://api.drupal.org/api/drupal/includes!pager.inc/function/theme_pager/7

However I cant figure out what PHP to change.


texts: How to display comments of current node in a view

texts:
I would like to display comments of the current node in a view. The reason for doing so is that I want the comments to be neatly displayed in a table and views seems to be an easiest way to do so than messing with theme template etc. (I am new to drupal)

I have created a comment view and selected comment: nid as a filter selector. How do I provide the "current NID" as the argument for the filter? I have tried Comment:nid is equal to "current" but this does not work.

Any suggestion?


texts: Commerce 2.x multicurrency / multiprice setting

texts:
Is it possible to set two prices each with its currency for the same product so that it appears in two stores with correct price? For example, I have set up two stores one for Czech Republic with CZK as a currency and second one for Germany with EUR as a currency. Now I want to create a product (for example t-shirt) that should appear in both stores but with price for each store different. I haven't found a way to do that, could somebody please shed some light on this problem, or at least point me in the right direction, I am kind of lost here.

Thanks.

[edit]
Still not found the correct way of resolving this problem. I have created a search index and view based on the documentation, the view has two pages each for one store. If I create a product with just one variation, price and currency, then publish it in one of the stores it all works as it is supposed to, but if I create product with two variations and two prices with two currencies, publish it in both stores then it doesn't work.


texts: How to combine multiple view result sets, limiting the combined result set

texts:
I want to create a 'suggested content' display that, by default, displays 4 nodes that share terms on a term reference field belonging to the currently node. So, if the current node is tagged with "baking" and "family", it should display nodes that have those terms in common. I have this working — all is good here.

Also, on the reference node I've added an entity reference field that allows editors to curate their own suggested content. My intention is to put this curated content at the beginning of the suggested results, so that if an editor specifies 2 nodes, the other view will populate the other 2 nodes.

Basically, what I think I need to do (correct me if I'm wrong), is to combine the results from two views (one displaying the curated nodes, the other displaying the term-related nodes), and limit them to the top 4 entries, ensuring that the curated nodes are displayed first.

If this was confusing, this image should make it clearer;

How can I combine the results from two views and limit the combined result set? Also, note that each view only uses a single field for each row (a rendered node).


texts: Programmatically create alias using pathauto for node

texts:
Developing a site that allows users to post images (node type = my_image) to a specific category.  Basically, we create the categories and users submit images to them.

Users do not have menu or url permissions, we want to do this for them.  When a user is in a category, the drupal form is displayed on that page using drupal_render_children().

In HOOK_node_insert (type == my_image) we identify what category they were in and add it to the menu.  Following this we are trying to use pathauto_create_alias to generate the alias (based on title) but have been unsuccessful thus far (HOOK_node_update would, well update the alias).

Obviously, if we grant the user permission for menu and url, the alias is created.  We don't want the user to have direct access to the menu system nor aliasing.

Does anyone know the proper way to use pathauto_create_alias in the above scenario?


texts: Limit account applicants with certain email addresses

texts:
Hi I am working on a website for a student organization of my college.
In order to prevent spams, I have been looking for ways to limit account applicants only with email addresses from the college but haven't figure out how


texts: Drupal 6 - form submission data loss from empty required fields

texts:
Scenario: Content profile node-type has new required fields added after many users have already filled out their profile info.  (this scenario can work for any node-type).  They go back to update their profile, and don't see the need to fill in the required fields, submit the forms, miss seeing the error message, and walk away, thinking that their updates have been submitted successfully.

I've had various versions of this same scenario play out across different websites and situations.  And have tried out various home-made solutions where I have data collected at the validation stage in a nodeapi hook implementation.  But those solutions are painful and flawed.

Anyone know of a simple solution to this pervasive problem?


texts: Views 3 "Use aggregation true" with exposed filter

texts:
I have a searching page and I need to show the results separated by there bundle type (all are nodes)  and I need to show how many results(In total) received for each content type .
I created a view the shows the main results and attached views for each separated content type then I made another attached view (inherit the filter from the main view) and then choose node type in the fields twice one I selected the count option from  the aggregation config .
when there is no expose filter and default is for show all I received in the attached view the correct results (shows all the content types with the number of Occurrences) but when I enter a word in the exposed filter it shows me the correct results but its not aggregate them


texts: How to include a Google font not available in @font-your-face module?

texts:
I want to use a Google Font on my site. I saw the @font-your-face module and installed it. Unfortunately, it does not offer the version of the 'Pacifico' font I want.

Google suggests adding the following:

<link href='http://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet' type='text/css'>

Is it possible to add it to all my Drupal page without fiddling with core code? Or is there are better way to add a font to my site?


texts:
As interim solution to an issue in JavaScript, I changed the User module code, to disallow single quotation mark. I changed the following line.

if (preg_match('/[^\x{80}-\x{F7} a-z0-9@_.\'-]/i', $name)) {

After my edit, it becomes as follows.

if (preg_match('/[^\x{80}-\x{F7} a-z0-9@_.-]/i', $name)) {

One of our senior Drupal developers said that this is not an acceptable solution because it could open up the site to serious security risks and it could potentially lead to a security flaw around form injection.

I do not understand why that could happen. Can anyone explain me why?

PS. I understand that this will get overwritten on Drupal update. This was to temporarily prevent serious bug that is blocking the whole page from functioning.


texts:
It appears there is no End Date or Date Repeat options for the datetime field in Drupal 8.

Are there any contrib options for recurring events in Drupal 8?


texts: Create Text Field Programmatically to Media Type

texts:
I want to create a text field to videos with code. I have the following in the .install file in a custom module:

function video_update_8101() {
  $field_name = 'field_video_alternative_text';
  // Make sure the field doesn't already exist.
  if (!FieldStorageConfig::loadByName('file', $field_name)) {
    // Create the field.
    $field = FieldStorageConfig::create(array(
      'field_name' => $field_name,
      'type' => 'text',
      'settings' => array('max_length' => 64),
    ));
    $field->save();

    // Create the instance.
    $instance = FieldStorageConfig::create(array(
      'field_name' => $field_name,
      'entity_type' => 'file',
      'bundle' => 'video',
      'label' => 'Alternative tekst',
      'description' => 'En beskrivelse kommer her.',
      'required' => TRUE,
    ));
    $instance->save();
  }
}

I get the following when running update.php

Attempt to create a field storage field_video_alternative_text with no entity_type.                                                                                [error]
Performing emu_video_update_8101                                                                                [ok]
Failed: Attempt to create a field storage field_video_alternative_text with no entity_type.

Furthermore, I want this to happen when I install the module. I suppose it's not at this point?

Edit: I got inspiration from this post: How do programmatically create fields for content types, and ADD them to the the content type form


texts: How should I get data from the node table?

texts:
I am creating a Drupal Dashboard (PHP 7.2, Drupal 8.9). I'm trying to query the node table using the following code.
$database = \Drupal::database();

$query = $database->query("SELECT field_advertiser_id_value FROM {node__field_advertiser_id} WHERE entity_id = :entity_id", [
    ':entity_id' => $entity_id
]);

$result = $query->execute();
print_r($result);

I am not sure why $query->execute() returns false. This table exists in the l database.
The database contains both the node and the node__field_advertiser_id tables.

Inserting data in the node__field_advertiser_id works correctly.
$database = \Drupal::database();

$database->insert('node__field_advertiser_id')
    ->fields([
      'entity_id' => $advertiser_nid,
      'revision_id' => 1,
      'delta' => 0,
      'field_advertiser_id_value' => $advertiser_id
    ])
    ->execute();

I am trying to fetch details from the node__field_advertiser_id from hook_node_delete(). The data is still there in the table when I try to run the SQL query.
It would be great if anyone can help me out with this.


texts: Content profile + rules. Problem with action, when user is created a profile then logged in

texts:
guys. Got a problem with content_profile and rules modules. By default rules has a

  Redirect to profile creation page, if users have no profile.

It works fine. When a user is registering on the site then logging in, it redirects the registered user to a node/add/profile (Content profile creation page). But when a user that already has a profile node logs in, he's redirecting to mysite.com/node, not on a user page.

What's wrong?


texts:
If I have 2 date fields in a content type: Event Start Date and Action Start Date.

Is there a way to validate that Action Start Date is later/greater than Event Start Date while creating the content?


texts: How do I copy a "purchase limit" field from a product to a product line item

texts:
I am working with Drupal Commerce and am trying to copy a field on the product named "copy limit" to the line item when it's added to the cart so that I can access it in shopping cart form view when a user views his/her cart.

I am not sure of the best way to go about this.

I am using Commerce 7.x-1.0 and Drupal 7.7.


texts: Page admin/config/development/performance not saving at Pantheon

texts:
I am working on improving Google Page Speed on a site. As part of this, I made a couple of changes to the js and css loading code in my template.php, installed (and uninstalled) the async_js module, and installed the AdvAgg modules.

Everything works as expected in my local environment. When I checked in and pushed to Pantheon, I noticed that any changes to the performance settings don't get persisted. When I make a change and click "save Configuration", the page displays The configuration options have been saved and reverts back to the original:

Then, before deploying anything to Test, I tried this in the Pantheon Test environment, and the page did persist changes. So I deployed my changes (about 5 or 6 commits). Now it no longer worked in Test, either. I made no other changes, just deployed my commits.

Then I reverted all my commits and pushed to Dev. The page still does not save in Dev, even though, at least in theory, the environment should now be the same as when I started.
This always worked locally, and no, there is no reason to believe that caching is causing this. I tried different user accounts in Dev and they all behave the same. There is nothing in the log.
I have been pulling my hair out over this for hours and would appreciate any pointers.

Thanks to Clive's suggestion I checked the code in settings.php directly in the Pantheon environment and found this code, and it explains everything .... and yes, the live environment did show the same behavior. Why I thought that the test environment did not, prior to my deployment, I really cannot say.

if (defined('PANTHEON_ENVIRONMENT')) {
  // Drupal caching in development environments.
  if (!in_array(PANTHEON_ENVIRONMENT, array('test', 'live'))) {
    // Anonymous caching.
    $conf['cache'] = 0;
    // Block caching - disabled.
    $conf['block_cache'] = 0;
    // Expiration of cached pages - none.
    $conf['page_cache_maximum_age'] = 0;
    // Aggregate and compress CSS files in Drupal - off.
    $conf['preprocess_css'] = 0;
    // Aggregate JavaScript files in Drupal - off.
    $conf['preprocess_js'] = 0;
  }
// Drupal caching in test and live environment
.... etc


texts: How do I show related nodes as attachment in the term view block?

texts:
I have created a term view and content view for list the terms nodes.
How can I show related nodes as insert view in term view block in Drupal 7?


texts:
I have translated my site into Japanese using all the required modules and po files.

But now I'm not able to translate the text "Order total" which appears in Checkout process.

I tried applying patches as suggested here but it didn't help me. Please tell me how to change this text.


texts: How To Add Entity_ID Column (Entity ID) To Userpoints List Transactions in Admin?

texts:
/admin/config/people/userpoints/transaction

This report is generated in the Userpoints module. It does -everything- we need, but it doesn't display the entity_id field (the ID of the source which generated the points transaction.) There's no hook into the code which generates the report.

I can get it to do what I want by hacking the userpoints.module directly and changing two lines (the header array and the row array around line 1925 and 1995).

But is there a way to add this column -without- hacking the module directly? I don't see any hooks into those functions. I'd =much= rather do something that doesn't change the original code if possible.


texts: Path aliases not updating or setting automatically

texts:
I have an Open Atrium site where the path aliases are not generated automatically and not updated if I change them manually.

How can I fix this?


texts: How can I programmatically create a node?

texts:
How can I programmatically create nodes with date and image fields?
I know I can do it in Drupal 7 with the following code.
global $user;

$node = new stdClass();
$node->title = "YOUR TITLE";
$node->type = "YOUR_NODE_TYPE";
node_object_prepare($node);
$node->language = LANGUAGE_NONE;
$node->uid = $user->uid;
$node->status = 1; //(1 or 0): published or not
$node->promote = 0; //(1 or 0): promoted to front page

$existing_filepath = "/home/nzcodarnoc/sites/default/files/imported/picture.jpg";
$new_filepath = "public://picture.jpg";
$drupal_file = file_save_data(file_get_contents($existing_filepath), $new_filepath);
$drupal_file->alt = $node->title;
$drupal_file->title = $node->title;
$node->field_my_file[$node->language][0] = get_object_vars($drupal_file);
$node->birth_date[LANGUAGE_NONE][0]['value'] = time();
$node = node_submit($node);
node_save($node);

What is the equivalent code for Drupal 8?


texts:
I know how to get the nid for a node, but not for a teaser. I want to show a button in the teaser, created by a field with the PHP filter, that allows printing the node to pdf, but that requires the nid. The functions that work in the node, like menu_get_object(), don't work in the teaser.

Googling this has only brought up methods of printing a teaser if you already know the nid, not getting the nid if you only have the teaser. It should be available; it appears in the id for the teaser.

EDITED: I went with the suggestion posted below by f0ns. I don't understand why the nid is not available when it's in the teaser's id in the html, but that seems to be the case.


texts: How to programatically update time offset in a Featurized Rule?

texts:
I have a rule that compares the value of a date field to the current date. I also have a custom module with a config form that allows the user to set a number of hours of time offset. The rule is exported using Features, and I've edited the rule definition in the Features module to use the user-defined variable instead of hardcoding a value into the rule.

The only problem is now, in order to update the rule to match user-defined offset config, the feature that contains the rule has to be reverted. This is too much complication for the users, so I need to figure out a way to make the Rules config match my users' config without reverting a feature.

How can this value be updated?


texts: redirect in hook_init makes body text disappear

texts:
What is wrong with this code. It makes my body text disappear in all of my nodes.

function MYMODULE_init() {
  if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
    $node = node_load(arg(1));
    if ($node->type = 'event') {
      if ($items = field_get_items('node', $node, 'field_event_date')) {
        $date = date_create($items[0]['value']);
        drupal_goto('news/events/day/' . date_format($date, 'Y-m-d'));
      }
    }
  }

I'm using the Calendar module. I don't want to display the full event node, I want to redirect to the Calendar's day display. The redirect works fine. Just when I go to view other nodes there is not body text. I also have Workbench moderation installed. On all of my non-workbench managed nodes I also get a workbench draft tab and errors related to workbench. It is not workbench related as I uninstalled workbench and body text is still not visible.

It seems to be related to node_load, as all is well when I remove that area of code.


texts: Drupal and its modules kept in two different subfolders -- possible/how?

texts:
New to Drupal... I was wondering if it was possible to install it with the core and the modules kept in separate folders, rather than in a hierarchy. A bit like with WordPress, so to speak:

/.htaccess <-- site is here, in /, and in git
/drupal    <-- Drupal core, pulled as a git submodules
/content   <-- plugins and themes, each pulled as git submodules

I'm guessing it's possible, but the installation manual and a bit of googling (skeleton, subfolder, enterprise, etc.) led me nowhere. If so, I could use a pointer to get me in the right direction. If not, will it be possible with Drupal 8, which unless I am mistaking is using Symfony components?


texts:
I understand how to edit a specific content type with form_alter

my_module_form_node_form_alter(&$form, $form_state) {

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

  if ($type == 'my_content_type') {

  }
}

I would like to hide all collapsible fieldsets EXCEPT scheduling. How do I only target these other fieldsets to hide?

http://screencast.com/t/ozHu5esPGc


texts:
Could you please advice how to set additional CSS class for the comment block using Drupal hook. I'd like to paint the author and date of the comment with green color if the author of comment is not the author of a node.

Something like

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

    if ($author_comment_id !== $author_node_id) {

        $form['#attributes']['class'][] = 'add-class';
    }
}

The problem is that I don't see the #attributes for comment block via dsm ($form). Maybe I'm using the wrong hook? Is there any different way to achive this?

Could you please help?


texts: How to set stock to 0 before product import?

texts:
I want to set the stock of every product with label X to 0 before I do a product import. This to make sure items with label X that are not in the CSV file, have stock 0 (and are disabled) because we don't have them in stock anymore (= sold in the physical shop).

Label X is a taxonomy term which I use it to determine if the product is new collection or outlet.

But I can't get a working Rule that does that. Can anyone help me out?

I allready tried the Commerce Feeds patch to Disable/Unpublish Commerce Product if non-existant in feed (https://www.drupal.org/node/2454175) but that does not work for me.


texts: Starting batch operations from hook_node_update()

texts:
When importing content using Feeds using an importer associated with a node type, the mapping can be configured to assign taxonomy terms from the Feed Node to the imported Feed Items. On a project, we need to extend this feature by also updating all the already imported Feed Items when a Feed Node is updated.

This can be done using hook_node_update($node). But since a single Feed Node can have a lot of Feed Items, they cannot be all updated in a single HTTP request otherwise we may encounter a timeout. The obvious way to avoid timeouts, is to use the Batch operations API.

Most of the time, hook_node_update() implementations will be executed because node_save has been called from a form submit handler, therefore, most of the time, there is no need to call batch_process from a hook_node_update() since it will be called automatically at the end of the form processing. Calling batch_progress from hook_node_update()  may also produce unexpected result since it will prevent other implementation of the same hook or others hooks to be executed.

But what about the times when the hook_node_update() implementations are not executed from a form submit handler. For instance, when node_save is called from an implementation of hook_cron? Is there a way to detect these cases to either run all the update at once or delay them to a dedicated queue?


texts: How can I add something after the day/hour/time in a date select list?

texts:
On Drupal 8, the select list provided by the Date module looks like this:

The site I am building in Japanese, and in Japanese, it's common to add a character to indicate what the number means, like this:

2018 2 5 15 00　-> 2018年 2月 5日 15時 00分

How can I add these labels?  I attempted to do it through the string translation UI screen, but since the year, day, hour, and minutes are just numbers, there is no way to "translate" them.  The month shows up correctly because it is translated from Jan/Feb/etc.

I am thinking the solution involves hook_form_alter() but I don't know how to modify the way the values are displayed in the select widget without actually changing the values input and causing the form to fail.


texts:
I would really like to port my website to Drupal 7, but my site requires an issue tracker. I tried the support module, but it seems heavily orientated towards support tickets (you must add clients, all users can't view eachothers tickets).

With the project issues module still working on complete Drupal 6 support, I really don't think I should be holding my breath.

What options are there, If I want a bug tracker on Drupal 7?


texts: How to render two views in the same twig template

texts:
I want to render two views in the same twig template, but only one of them is rendered, and the second is always override with the same content as the first one.
I have a content type 'contacts' and when its nodes are displayed (full view) I want to render two views in the same page after the node fields. I use a twig template node--contacts.html.twig :

.....  node fields twig template ....
{{ viewCalls }}
....
{{ viewAppointments }}
....

And my function my_theme_preprocess_node(&$variables) in my .theme file:

....
$view = \Drupal\views\Views::getView('view_calls');
$view->setDisplay('default');
$view->setArguments(array($variables['node']->id()));
$view->setOffset(0);
$view->execute();
$variables['viewCalls'] = $view->render();

$view2 = \Drupal\views\Views::getView('view_appointments');
$view2->setDisplay('default');
$view2->setArguments(array($variables['node']->id()));
$view2->setOffset(0);
$view2->execute();
$variables['viewAppointments'] = $view2->render();
.....

As I said, the second view always shows the same content as the first. If I reverse the order of rendering, then the content is reverse too, and the one which is first rendered is the only one I see, and always two times. It is as {{ viewCalls }} and {{ viewAppointments }} always get the same content.


texts: Inline Javascript throws an error on drupal_add_js() within an AJAX callback

texts:
I am trying to get JavaScript to measure a text field and auto submit at a character limit for an Ajax callback to be validated against a Luhn Algorithm and errors out on failure to validate.
I found this code in Firing ajax_callback on textfield after a minimum number of character.
// Trigger ajax event on myitem only after 5th character typed.
$('.myitem-class').on('keyup', function() {
  if ($(this).val().length == 5) {
    $(this).trigger('change');
  }
});

The JavaScript can allegedly be put inline in a wrapper like this to be used in an Ajax callback in a form. See drupal_add_js within AJAX callback.
function my_module_form($form, &$form_state) {
  drupal_add_js('Drupal.ajax.prototype.commands.myFunction = function(ajax, response, status) {
    // …
    }',
    'inline'
  );

  return $form;
}

I got to run replacing function(ajax, response, status) with function($, Drupal).
When I put in the code, it throws a PHP error at ).on(. I wasn't able to get the inline wrapper recommended in Converting 6.x modules to 7.x / JavaScript should be compatible with libraries other than jQuery to work because it fails seeing the $ as a variable.
(function ($) {
  // […]
}(jQuery));

Right now, I am stopped by syntax errors.
Does anyone know how to get this JavaScript code work?


texts: Why does my custom block disappear after page reload?

texts:
I have created a custom block with a custom module (Example: https://www.webwash.net/programmatically-create-block-drupal-8/). The goal is to display some external content, which is working. The only issue is if i reload the frontend page where this block is loaded, it disappears. I have to flush caches to bring it back.
Does anybody know the reason why have to flush caches to bring the block back? How can I make the block persistent?
Function for loading the external url:
class LebenslagenGeburt extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {

    return [
      '#markup' => $this->_populate_markup(),
    ];
  }

  private function _populate_markup() {

    function getter($url) {
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      $data = curl_exec($ch);
      curl_close($ch);
      return $data;
    }

    echo getter('https://www.muster.at/.syndication?pageShortcut=L-GB&format=html');
  }
}


texts:
How would it be possible to postpone payment processing (move out of checkout) to a later stage/order status change?

I always thought the payment processing is a rule to be invoked on checkout completion, that I could easily modify, but as it comes out, no such rule can be found.

I'm using Stripe payment gateway with card on file. How I'd like the process to work is that the user puts in the card information in checkout as usual (because of card on file, the information is tokenized and a token stored to my server) But instead of the payment happening right away, I'd like to invoke the payment for the order only after the order has been fully processed and sent on it's way.

Therefore I'd like to ask, what would be the recommended process for achieving such functionality?

My ideal solution would be to somehow skip the payment processing in checkout, and process the payment with a rule on another order status change with the card data stored, but am currently unable to find solutions for this.

Best,

Alari


texts:
In Drupal 8 we have the command drush cr which is the new version of the deprecated drush cc all.
However we had drush cc menu and some more specific cache clear commands.
If I try to execute them, I get weird symfony error.

What I want to achieve:
Find the replacement commands for drush cc (specific cache) in Drupal 8.

What I have checked/tried already:
The documentation is a bit scarce:
https://drushcommands.com/drush-8x/cache/cache-clear/

Manually typing all types of commands like drush cr menu, etc. They don't seem to work.

Regards,
Oleg


texts:
Is there a way to automatically generate end-user documentation (likely in a stubbed or skeletal format) for content types that you have setup?

Perhaps there is a module that does this?


texts: Is it possible to resize image before saving it with media module?

texts:
I am building a site using Drupal 7, in which users can upload content in a form, also images. The images will be uploaded and stored with the Media module version 7.x-2.x-dev.

I want to allow users to upload any image up to 10 MB of size.

But, I don't want to have many pictures as big as 10 MB on my server. I prefer to save the image only after it has been resized to 800x600 to have more space on my server.

How can I achieve this with the Media module?

In addition, what is the difference between the field type "file" to "image" when rendering images with the Media module?

There is an option to chose "Field Type: File" and "Widget Type: Media Browser", and then chose rendered file, and then image on the Media settings (here is a great guide to the Media module). Another option is to chose "Field Type: image" and "Widget Type: Media Browser".


texts: How do I disallow future dates in CCK date field?


texts: RulesAction to send notification for specific users after node has been created

texts:
The Background

I'm using the module 'Permissions by Term' (https://www.drupal.org/project/permissions_by_term) to make some nodes only visible to users which are allowed to see the assigned term. This works pretty well for me. However, I also need to notify those users that a new node has been created, which seems to be a lot more challenging.

The Challenge

Whenever a node with Permissions by Term is published, notify all users which are allowed to see this node, that it has been created.

The Solution

I created a Rule, which is triggered whenever new content is created. I also created a custom RulesAction to send the notifications. The parameter submitted to the RulesAction is the newly created node.

The Problem

It looks like $node->access('view', $user) === TRUE is always TRUE for newly created nodes.

protected function doExecute($node) {

    $users = user_load_multiple();

    foreach ($users as $user) {
        if ($node->access('view', $user) === TRUE) {
            // SEND NOTIFICATION HERE
        }
    }
}

This always sends notification to all users.

I also thought about rebuilding the node access table before checking for access like this:

protected function doExecute($node) {

    $nid = $node->id();

    $node->save();

    // rebuild the node_access table
    node_access_rebuild();

    // reload the node - maybe unnecessary?
    $node = node_load($nid);

    $users = user_load_multiple();

    foreach ($users as $user) {
        if ($node->access('view', $user) === TRUE) {
            // SEND NOTIFICATION HERE
        }
    }
}

But no success.

The Question

Doesn't Permission by Term affect the $node->access at all? If so, what other query can I use to check if a certain user is allowed to view the newly created node?

Thank you very much!


texts: Drupal 8 : Get a config settings value being stored in blocs

texts:
I have create a block with a form and stored something i called 'submit_action_amu_dud_form_block_settings'

 public function blockSubmit($form, FormStateInterface $form_state) {

    $this->configuration['submit_action_amu_dud_form_block_settings'] = $form_state->getValue('submit_action_amu_dud_form_block_settings');

 }

in a method of the same class i can retrieve the value

      $config = $this->getConfiguration();
      $my_stored value=$config['submit_action_amu_dud_form_block_settings']

how can i get it from . module hook_form_alter callback ?

    function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {

if ($form_id == 'amu_dud_form') {
    $form['actions']['submit']['#submit'][] = 'my_submit_method';
}
}

 function my_submit_method(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {

//$my_stored_value=??


texts: is it possible to search for user names with solr?

texts:
I'm trying to allow users to be able to search and find their friends on my site.  I'm not sure how to do this. Could someone guild me please?

I read that solr is not able to search usernames so instead you must convert their profile to nodes..I installed Content Profile, and migrated but still no luck.  Not sure how to do this.

please help!

Thanks!


texts: How can i override all node book/book_alias usng alias

texts:
How can i override all node "book/book_alias" using View
when i tried "contextual filter" not provided for alias
i must use a node id rather then book_alias.

Any Solution to override a multiple node using alias ?


texts:
When using the layout builder module, the contextual links module is a hard dependency. This works quite well in the context of the layout builder. But I don't want those links anywhere else, because elsewhere they are not helpful at best, and completly mess up my frontend theme at worst.

I've already written a custom theme negotiator to force my admin theme in layout building mode.

But I don't know how to remove all contextual links when I'm in frontend. My current ugly hack is

function wt_cms_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
  /**
   * Suppress the contextual edit pen on frontend themes, we only want it
   * for layout builder in admin theme
   */
  if (isset($build['#contextual_links'])) {
    $routeName = \Drupal::routeMatch()->getRouteName();
    if (!in_array($routeName, ['layout_builder.overrides.node.view', 'layout_builder.defaults.node.view'])) {
      unset($build['#contextual_links']);
    }
  }
}

and an additional rule in my frontend CSS

.contextual-toolbar-tab, [data-contextual-id] {
  display: none !important;
}

This does at least hide the contextual edit pen in frontend, but it does not really remove the contextual link menu. (There still is an empty placeholder div).

I've also tried @Shreya Shetty's suggestion

function mymodule_contextual_links_alter(array &$links, $group, array $route_parameters) {
  $routeName = \Drupal::routeMatch()->getRouteName();  //incorrect, this always returns "contextual.render"
  if (!in_array($routeName, ['layout_builder.overrides.node.view', 'layout_builder.defaults.node.view'])) {
    $links = [];
  }
}

In contextual alter I've got other problems: The current $routeName is always contextual.render and not the route of the host page, so I've no "entry point" to specifically alter non-layout bulder-pages. It also has the same problem as the hook_entity_view_alter workaround: The menu items are suppressed, but the empty contextual placeholder divs are still rendered.

Can anyone tell me how to reliably and cleanly remove the contextual links? I don't want them anywhere, except in layout building mode.


texts: REST API POST: User is not authorized despite being admin

texts:
I'm working on a quick script as a proof of concept to POST content to my Drupal instance using the REST API.

The user I'm trying to post as is an Administrator, but I get an error that they don't have permission to create the Content.

Here's the simple script I'm using so far (removed a lot of debug and extra code for brevity). It gets a CSRF token, constructs the JSON body and POST's the request to the REST endpoint to create a piece of content of the game type.

<?php

$autoloader = require_once __DIR__ . '/../../vendor/autoload.php';
use GuzzleHttp\Client;

$client = new Client([ 'base_uri' => $url ]);

$csrfResponse = $client->request('GET', '/rest/session/token');
$csrfToken = trim($csrfResponse->getBody());

$jsonPayload = [
    'type' => 'game',
    'title' => [[ 'value' => 'Test Game ' . strtotime('now') ]],
];

$postResponse = $client->request('POST', '/entity/node?_format=json', [
    'auth' => [$user, $password],
    'body' => json_encode($jsonPayload),
    'headers' => [
        'Content-Type' => 'application/json',
        'X-CSRF-Token' => $csrfToken
    ]
]);

debug("Status Code: " . $postResponse->getStatusCode());
debug($postResponse->getBody());

Problem: I get 403 Forbidden response telling me:

{"message":"You are not authorized to create this node entity of bundle game."}

This despite the fact that the user is an Admin (and I even tried giving them explicit permission to Create and Review contents of the Game type). I get the same error if I put in a bogus username and password as well.

The answers suggested in the related question about "403 Forbidden when creating a page with RESTful API" did not work for me.


texts: Is it possible to pass configuration values as arguments to services?

texts:
I'm writing a module that makes calls to a Web service to read and store data.
Here's my services.yml file:

services:
  example.connection:
    class: Drupal\Core\Http\Client

I've already a settings form (inheriting from ConfigFormBase) that stores a base URL in configuration, and I'd like to pass that as an argument to the Client class's constructor. I've tried this:

class ExampleServiceProvider implements ServiceModifierInterface {

  /**
   * Modifies existing service definitions.
   *
   * @param ContainerBuilder $container
   *   The ContainerBuilder whose service definitions can be altered.
   */
  public function alter(ContainerBuilder $container) {
    $base_url = $container->get('config.factory')
        ->get('example_entity.settings')->get('base_url');
    if ($base_url) {
      $arguments = array('base_url' => $base_url);
      $container->getDefinition('example.connection')
        ->setArguments(array($arguments));
    }
  }
}

But that gives me HTTP 403 errors for every page on the site. Should it be possible to pass arbitrary arguments like this? Hardcoding a URL into the $base_url variable works fine.


texts: Execute a Backup and Migrate backup via PHP

texts:
I'm trying to create a custom module that will overwrite my testing site with a copy of my live site (I can't use SSH and I can't install my own PEAR modules, so Drush is a no-go).

I've been using PHP execute() commands to manipulate the file system and dump the database, but I'm getting errors on the testing site when importing the SQL dump, and I usually have to resort instead to the Backup and Migrate module, using a profile that copies my main database over to my testing database.

Now I'm wondering, is there any way I can hook into this and execute it as part of the chain of commands in my custom module? The goal is to turn the process of migrating to the testing site into a one-click (followed by a lot of grinding) process. But since Backup and Migrate doesn't apparently expose any API or hooks, or even the machine names of its profiles and destinations, how could I execute a backup command with a specific preset from a different module?

Say, for instance, I want a PHP command that will tell Backup and Migrate to backup database live_db to destination test_db, both of which are already recorded as mysql://[db_name] in the B&M settings.


texts: Webform multipage - different page.tpl for different page

texts:
Is it possible to use specific page.tpl for webform pages?

For example: page--form1.tpl for page 1 and page--form2.tpl for page 2.

I wanted to do this via URL but it's same on all pages.

Any ideas?


texts: How to export paragraph bundles with features?

texts:
According to paragraphs documentation, it's should be possible to export paragraph bundles with features module, but whatever I search, I can't find any option in the features component section for doing this.

Paragraphs documentation

  Features:
  This module has some overlapping function with field_collection, but this module has some advantages over field_collection.

  Different fields per paragraph bundle
  Using different paragraph bundles in a single paragraph field
  Displays per paragraph bundle
  Bundles are exportable with features.
  Entities, so: exportable field bases/instances, usable to show in Search API, used in Views

It seems that features not treated the same for every paragraph types because I can't see paragraph type in the features component section for some of the created paragraph types.


texts: How do I use an external data source in a view?

texts:
I am trying to display some TV schedule information from a thirdparty json api.
I need to know what is the best way to do this.
I have tried various module wsclient module,json query plugin, wsclient view integration. But none of them worked and overkill.

I can write a module to do this, but I need some information. One option I was thinking off was making a new data source available to the Views module. What hooks need to implemented for this?


texts: Looking for exposed filter for private file name

texts:
We have a view for a type of node that includes a Private File.

We cannot see a way to add an exposed filter, such as "Contains any word", and have it filter based on the file's name.

Are we missing something obvious?


texts: inheriting fields from a base content type

texts:
I need to create 10 content types which, apart from their specific fields, will have 4 common fields (e.g name, surname, email, age).

Since I'm using Features I could create the first and copy paste the definitions to the other 9 content types. The problem though is that if the specifications ever change and I need to add or change any of those common fields I'll still need to do repetitive work.

How should I solve this? Is there a module which allows the construction of a "base content type" from which other content types can inherit fields? Or should I just reuse fields?

The following modules don't seem to be active for D7:

http://drupal.org/project/field_inherit
http://drupal.org/project/bundle_inherit
http://drupal.org/project/inherit


texts: Need help or idea on how to setup a Drupal site on a given scenario

texts:
I need ideas/help on how to setup a drupal website with following given scenario. I just come up with the scenario this is not real but if I get the answers then I think I can apply on real poject.

I have two content-type Movies & Celebrities.

Movies content type will list all the movies information like...
"Movie story overview", "movie review" and "movie cast"

Similarly I have Celebrities content type which will Celeb information like
Movies acted, Bio, awards etc.

Now what I want...

First Objective:

When I add a new celebrities node to site, how can I create/add multiple pages automatically
Example: I added a new celebrity named “kate winslet” by using “Add Content”->Celebrities content type. Now when I save it there should be 4 urls created in one go.

a.   Domain.com/celebrity/kate-winslet
   b.   Domain.com/celebrity/kate-winslet /movies-acted
   c.   Domain.com/celebrity/kate-winslet /bio
   d.   Domain.com/celebrity/kate-winslet /awards

Similarly while adding a Movies content type it should generate multiple pages like

a.   Domain.com/movies/titanic/overview
b.  Domain.com/movies/titanic/cast
c. And more like this.

Note: I don’t want to create pages manually. Only one main landing page for each type should be created manually and rest of the pages should be added itself.

Now...

Second Objective:

On the “domain.com/movies/titanic/cast” page, how can I have functionality to look-up all the celebrities page titles & url and link both, a movie with its casts or an actor/actress with movies.

Example: I added a new movie “titanic”, now the movies content type may have a custom filed (CCK) named as “movie cast” where I will be adding actor/actress full name like “kate winslet”, “leonardo dicaprio” etc.

Now what I want is these names should be link to their corresponding celebrity pages like

a.  “kate winslet” shoule be linked to Domain.com/celebrity/kate-winslet

b.  And “leonardo dicaprio” should be linked to Domain.com/celebrity/ Leonardo-dicaprio

Any idea or help is highly appreciated.


texts: Authenticated users can not see own Ubercart order detail

texts:
Using Drupal 7, Ubercart 7.x-3.10.

A user purchases product, gets a user id and logs in. He clicks on Orders tab in My Order History and sees the last order. But, when he clicks on the order number or View order icon, he gets HTTP 500 error (not access denied) instead of seeing order detail.

As admin, I can click on same link and see order detail.

In permissions, Authenticated user has checked:

View own orders
View own invoices

They can see uc_orders_user view /user/606/orders but get page not found error when they click on link to view individual order /user/606/orders/15. Oddly enough, Print order user/606/orders/15/print does work.

Rebuilt permissions, same error.

In order settings, admin/store/settings/orders, I use the Customer On-site invoice template, but I don't see any options to allow users to view orders/invoices (as referred to in this answer to similar question: User cannot view their Orders in Ubercart)

Any suggestions?


texts: What is the CCK module? Is it a core module in drupal 7 or do I have to install it?

texts: When I go to download the CCK module I see that it is available for Drupal in the recommended release. I want to know why it is not available for Drupal 7 or whether I can use the development release.


texts: Automatic Node titles to generate a title based on taxonomy

texts:
I’m using Automatic Node titles to create node titles based on taxonomy terms.
In my node I have 3 flat vocabulary:

Color, size, year.

One CCk field for the price.

And 1 hierarchical vocabulary(Makes and models)using a dropdown list.

I want the title to Show only terms from the hierarchical vocabulary(Makes and models)..Something like this:

 [Make term][ Model term ]  for [ price ] $.

This is easy to do with Drupal 7, using term patterns, but with Drupal 6, I guess the best option would be to use PHP. Which I have no clue about.
I found this code  here:

      <?php  $terms = array_values($node->taxonomy[1]);
       print taxonomy_get_term( $terms[0] )->name;
       print taxonomy_get_term( $terms[1] )->name;
       ?>

But It’s not working at all. Any idea?.


texts: Commerce Kickstart demo: How do I change the region for the blocks Main Menu and Secondary Menu?

texts:
In the Commerce Kickstart demo the blocks Main Menu and Secondary Menu are assigned to the Menu region. You can see in the image:

But I go to /admin/structure/block these blocks are Disabled. I mean they are not assigne to the menu region

Is this done programmatically? I need to move the blocks to other region. How can I do it?


texts: How do I translate a programmatically-created custom block?

texts:
I am searching from long hours about this problem. I created a block programmatically, in my custom module, with hook_block_info(). I create its fields in hook_block_configure() and save values of fields with hook_block_save(). Then I get values of fields (variables) in hook_block_view() and then pass it to theme (template). I will not show you whole process because it is not necessary, I think. Something this way:
function my_module_block_info() {
  $blocks["mm_block"] = array(
    'info' => t("MM block"),
    'status' => TRUE,
    'region' => 'my_region',
    'cache' => DRUPAL_NO_CACHE
  );

  return $blocks;
}

function my_module_block_configure($delta) {
  if ($delta == "mm_block") {
    $form['mm_block_desc'] = array(
      '#type' => 'textfield',
      '#title' => t('Description'),
      '#required' => TRUE,
      '#default_value' => variable_get('mm_block_desc')
    );
    // more fields
  }

  return $form;
}

function mm_module_block_save($delta = '', $edit = array()) {
  variable_set("mm_block_desc", $edit["mm_block_desc"]);
  // more variable_set
}

The problem is that the site is multilingual (has 3 languages), so I have to do everything three times. I created three blocks (mm_block_en, mm_block_es, mm_block_pl) for every language version and every of them has its own variables, etc. I need to make 10 diffrent blocks, so to have every language version, I have to do everything x3 (it gives me 30 blocks...). I don't think it is a good solution (so many blocks, so many variables (if one block has 15 variables, so multiplication it with 3 for 3 languages versions.. omg). And so a lot of code (3x configuration forms for every block, 3x saving every variable).
How to translate custom block (created programmatically) in Drupal 7?
- with not creating 3 separate blocks manually for every language version. I want to have one block in Blocks list in admin panel and there I want to be able to translate its fields (which were created programmaticaly in custom module).
Internationalization module is installed. I tried with Variable translation module - but it is not giving me result I want.
Theoretically I can translate my block. I go to http://mypage.local/admin/structure/block/manage/my_module/mm_block/translate - but there is no fields to translate - there is only title and it is not translatable.
I think I tried everything. Can anyone help?


texts: What hook to use changing image field description

texts:
I wonder how I can alter the description of the custom image field. I can't use hook_form_alter. I couldn't find the variable. Please advise. Thanks!

e.g


texts:
Hope you can help me.

I use drupal 8.

I want pdf preview like this http://prntscr.com/j08ljo.

Need uploud pdf file in node and showing just first image in front page.

I check use module pdfpreview https://www.drupal.org/project/pdfpreview

Have with tutorial and dependence. Setup ImageMagick and configured it in image toolkit.
Sent in server files with imagemagick and write path.

"Path to the package executables" ... http://prntscr.com/j08ogh

After this showing in display manage full content "pdf preview" http://prntscr.com/j08r9i

But nothing happened. I hear about "may be i need install for other way imagemagick"

Can you help me?

Thanks for your future answers.


texts:
I beg you to make it clear for me, can i share tables in multisite installation with different databases and which ones?

If i am to use i18n on multisite, what is the best way to do that. Thanks a lot in advance.


texts: What filter should be used for date field in views

texts:
I am building a view for showing upcoming events.

I have my own content type with CCK field with format  Date (Unix timestamp)  and widget as Pop-up calendar. All works fine, but i views i don't know how to filter it out. I have shown the filter criteria in a screeshot and i don't know what to give in the value field.


texts: Use webforms to search and edit information from a custom table on the database

texts:
I am attempting to search and edit information by using 2 webforms. The custom table is found in the database that my Drupal project is using and is named "test_update." It has 2 records on the table.

The webforms are:

1.Edit Search customer

The user inputs the name which to retrieve the wanted information. A select query is executed using the value captured by the user to identify the record when the webform is submitted.

If the record is identified, it redirects to the Update/Edit Customer webform and displays the values on the respective textfields. Example : Richard was found from the table on the database. Since the record was found, the information "Name: Richard" and "Surname: Warwick" are displayed on the **Update/Edit Customer webform.**
If it is not identified, it displays a message and redirects to the
"Edit Search customer" webform.

2.Update/edit customer

The displayed values on the fields can then be edited. When the webform is submitted, all changes are then saved to the table.

I added the following codes in the webform.module file. They are found inside the function webform_webform_submission_insert($node, $submission) :

$accessnode=$node->nid;
if($accessnode==8) //nid of the eidt search customer form is 8, if this webform is selected
{
    $searchByName=$submission->data[1]['value'];

    //select query
    $result=db_query("SELECT * FROM {test_update} WHERE name = :name",array(':name'=>$searchByName))->fetchAll();

    if(!(empty($result)))
    {
        //redirect to webform with nid 7 (Update/Edit Customer webform)
        //Use the result set to display the values to the webform with nid 7 ()
        //on submit, it updates and saves the data into the table from the Update/Edit customer webform

    }
    else
    {
        //display error message and redirects to the search page
        drupal_set_message(t('The customer does not exist. Try again'), 'error');
        header('Refresh: 5;url=http://localhost/babyDrupal/node/8');// Aim: redirect after 5 secs to the search edit form, Result: it doesn't redirect to the page

    }

}

Can I have some help on how I can acheive this please?


texts: How to transfer multiple databases by sql-sync?

texts:
I've created proper aliases and successfully pulled files/database from live to dev server by:

drush sql-sync @live @dev

But I noticed my secondary database (defined also in settings.php and in alias file) has not been populated when syncing. I have default database and one additional database for some special operations which I use.

There was no any error message after sync, so I presume drush did not try to copy that database.

Is there any additional procedure I must follow when doing sync of 2 databases, or this was presumed to be automatic?

If there is no out-of-the-box answer, or I should show my config files?


texts: How to use field variable (a term) from node in field.html.twig for page title

texts:
When viewing a node I want to display an associated vocab term field inline with the node. The vocab is called "field_related". If I add {{ node.field_related.entity.label }} to node.html.twig and view the node it outputs the term, but if I add the same print tag to my custom twig template field--node--title--topic.html.twig ("topic" is the content type name) it doesn't output anything.
What do I need to do to get it so I can print node.field_related.entity.label in field--node--title--topic.html.twig?

I've been trying various combinations of how to write the tag and fiddling with theme_preprocess_field but so far all I've gotten is a headache.


texts:
I need to take a view result, check all the row and render only some of it;

I found this code

$view = views_get_view('view_name');
$view->execute('block_1');
$view->preview();

$renderer = $view->style_plugin->row_plugin;
foreach ($view->result as $index => $row) {
  $view->row_index = $index;
  echo $renderer->render($row);
}

but I changed it in:

$view = views_get_view('view_name');
$view->execute('block_1');
$view->preview();

$renderer = $view->style_plugin;

foreach ($view->result as $index => $field) {

  $full_line_item = commerce_line_item_load($field->field_commerce_line_items[0]['raw']['line_item_id']);
  $data = unserialize($full_line_item->data);

  if(isset($data[0]) && $data[0] == 'ticket' && $data[2] == $content->nid){
    dsm($field);

    $view->row_index = $index;
    $output .=  $renderer->render($field);
  }
}

return $output;

But this code give me all the table rendered 2 times [the field the view have to render is two.. I don't know if this can be related.. ]

How can I solve this?


texts: How to make a theme hook suggestion for blocks according to region?

texts:
Since Drupal 8 it is not possible with template naming conventions to load a specific block template according to the region it is placed in ("Per-region block markup and per-region block templating feature removed"). But I need to have different html for blocks if placed in a certain region. How do I accomplish this?

I've thought about using MYMODULE_theme_suggestions_block_alter but I don't know how to get the current region.


texts:
When debugging with kint in a twig tpl the output is seen also by site visitors although they are not logged in.

Permissions "Access kint information" are set just for admin.

Is this a bug?


texts:
I use the Pathauto module to redirct my user/nid  to /username ,
I set all of it's setting with my disired option,
but have a exception in it,
all of this name

blah.blah
d.dddd
df33.dddd
fafdd.dd

But when I start it with a.s???? it's don't work and I can't handle this, and don't register it. Do you know any thing about this pattern a.s in pathauto?


texts: How do I create a block only for the user "owning" the profile page?

texts:
I made so the logged in user have a recap of their last comments/added node on their profile with a view.
As I am making the profile page public, I need to be able to hide those blocks from others authenticated users.

How can I make the block visible to the user for which the profile page is?


texts:
I have a page with a view on it and some exposed inputs. I need to get the results programatically. I can load a view programmatically no problem but setting the exposed input has not been working.

$view = Views::getView('inventory_listing');
$view->initDisplay();
$view->setExposedInput($view->getExposedInput());
$view->preExecute();
$view->execute();

results in ALL the rows, not the ones filtered out. I am running this in my hook_form_alter function because I need to change the display of my exposed filters. That may be part of the problem. Any ideas?


texts:
My site (running D7) is divided into four sections to organise its content. This is implemented via a taxonomy vocabulary, and my main menu lists each term in this vocabulary. So when a user clicks a main menu item, it is highlighted and all articles in that section (nodes with that term) are shown. Brilliant.

But, when a user then clicks one of these articles to view the whole thing, the main menu item is no longer highlighted. Although the article does display the taxonomy term, I would very much like to keep the main menu item highlighted so it's obvious to the user which section she's browsing.

How can I achieve this?

Edit: Clarified that I'm using Drupal v7. Also, managing the menu itself is not a goal (that's easy enough), the goal is only keeping the menu highlighted when viewing an article node as opposed to the term node.


texts: Exposed Filter Fulltext Search having the Searched fields as options along with the text box

texts:
I have created a exposed fulltext search filter with the searched fields["tile", "Description","Keywords"]. This brings the widget to the form as a textfield, which searches the input for all the three fields.

I'm trying to bring the searched fields["title","Description","Keywords"] to the form as a radio button list, So that the user can type the input and select under what field to refine the result.

Any help really appreciated!


texts:
I want to change my all internal url to absolute from relative as of now.

For e.g. my menu link urls are "/about" as so on I want this to be absolute url like xyz.com/about.

How can I do this ?


texts:
I have a $category variable containing country names separated by comma. So I use the following code to save them as taxonomy terms:

$tids = array(); $ctids = array();
$category = explode(',',$category);
foreach($category as $cat) {
  insert_term_if_not_exists($cat, 'countries');
  $term_country = taxonomy_get_term_by_name($cat);
  $tid_country = key($term_country);
  $lang_country = field_language('node', $node, 'field_country');
  array_push($ctids, $tid_country);
}
foreach ($ctids as $index => $ctid) {
 $node->field_country[$lang_country][$index]['tid'] = $ctid;
}

As you see the above code uses the insert_term_if_not_exists() function which works perfectly well to check if a taxonomy term exists and to create it programmatically if it doesn't:

function insert_term_if_not_exists($term_name, $vocabulary_name) {
   $vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name);
   $matched_terms = taxonomy_get_term_by_name($term_name, $vocabulary->machine_name);
  if(empty($matched_terms)) {
    $term = new stdClass();
    $term->vid = $vocabulary->vid;
    $term->name = $term_name;
    taxonomy_term_save($term);
  } else {
    $term = array_shift($matched_terms);
  }
return $term;
}

However, I also need to check and avoid creating a new taxonomy term if it is a synonym of already existing another taxonomy term. So I modified the above code in the following way:

function insert_term_if_not_exists($term_name, $vocabulary_name) {
   $vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name);
   $matched_terms = taxonomy_get_term_by_name($term_name, $vocabulary->machine_name);

    if(empty($matched_terms)) {
      $matched_synonym = synonyms_get_term_by_synonym($term_name, $vocabulary);
      if (empty($matched_synonym)) {
        $term = new stdClass();
        $term->vid = $vocabulary->vid;
        $term->name = $term_name;
        taxonomy_term_save($term);
      } else {
        /*
        * Here I need to do something, but don't know what exactly. Using
        * $term = taxonomy_term_load($matched_synonym);
        * here doesn't work.
        */
        }
    } else {
        $term = array_shift($matched_terms);
    }
  return $term;
}

Having troubles to make it work properly.


texts: How can I override the HTML of options on the user edit page so that they do not appear as collapsible fieldsets?

texts:
In Drupal 7, several modules on the user edit page provide options in collapsible fieldsets (I think this is the right word-- you can click the title above the option and the area containing the option will "collapse" and fold up).

For example,
* timezone (Core)
* whether to receive e-mail notifications upon receipt of messages from other members (privatemsg)
* disable HTML mail (mimemail)

However, I would prefer to have the titles of these options to be regular titles (i.e., even if you click them, they don't collapse; nothing happens).  How can I override this behavior?

I tried the following code based on this question:

function mymodule_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
    $form['timezone']['#collapsible'] = FALSE;
}

However, after clearing my cache, the timezone field is still collapsible on the user edit page.

EDIT: I had accidentally called form_user_profile_form_alter twice.  Consolidating the two overrides fixed my problem.


texts: I get a white screen with nothing in the source when i update a content type to include a location

texts:
So I have a site running drupal 7, i have a content type called seminar... inside that content type I have a form field for location to be added, but not required(if required would never save) So I can create seminars just fine but if i make one with a location or edit a seminar and adda location... upon clicking the save button i get refreshed to a black page with same url but nothing in the source code, error 500 internal server error.

I'm not sure where in my phpMyAdmin this info gets stored, I that could be my error location but just wanted to see if anyone has had a similar encounter with what I am going through now.


texts: How can I list all the IP address and referrers of visitors of a specific node?

texts:
The tracker module is active on the website and I want to get all the Track statistics of a node created.

www.example.com/node/3/track lists all the redirection etc. But what I want to do, is to get all IP addresses that visited this node:

In Track Tab I can see the logs but the IP address and the referrer details are not listed here, to see this info I have to visit the link (www.example.com/admin/reports/access/24488 etc.) for per log listed in Track page.

How can I list all the IP address and referrers of visitors of a specific node via Drupal interface, Views or via PHPMyAdmin etc.?


texts: How can i use Form Api in a custom block?

texts:
I’ve created a custom module and it works fine. I use the Form Api to display form and it is also working fine.

For now, i can access my module with the route that i defined in xxx.routing.yml

Now, for templating reasons, i would like to create a block.

I’ve followed this tutorial :

https://www.drupal.org/docs/8/creating-custom-modules/create-a-custom-block

I’ve added my block and i can see it in font end.

My question is how tu reuse my previous class in src/Form/WebservicesBulletinForm.php :

class WebservicesBulletinForm extends FormBase {
    // code based on Api form
}

now i have in src/Plugin/Block/WebservicesBulletinBlock.php

class WebservicesBulletinBlock extends BlockBase {
    // code based on  APi form
}

I can see my block in front, i see my forms but i have some issues due to the fact that i extand BlockBase and not FormBase.

How can i use Form Api in a custom block ?

I’ve look in the module folder to see other example but did’t manage to clearly understand.

For now, if i do this :

class WebservicesBulletinBlock extends BlockBase {

    public function build() {
    $form = \Drupal::formBuilder()->getForm('Drupal\webservices_bulletin\Form\WebservicesBulletinForm');
    return $form;
   }

}

I can see the form but it doesn't work. Should i insert all the form process code in WebservicesBulletinBlock ?

I need a simple example in order to adapt my code.


texts:
I have some content types (nodes) that are attached to various taxonomies.  For specific node types, I want to do some validation on the taxonomy.  I do not want to hard-code the nodes types and their corresponding fields that reference the taxonomy.  So I put them in array.  However, I am unable to dereference the field names.  I've tried double $$, quotes, etc, but can't get it to work.  Is what I want to do possible?

<?php

$node = (object) array(
    'nid' => NULL,
    'vid' => NULL,
    'uid' => '1',
    'type' => 'price_document',
    'language' => 'und',
    'field_taxonomy_price' => array(
        'und' => array(
            array(
                'tid' => '94'
            )
        )
    ),
);

  $nodes_to_check = array("price_document" => "field_taxonomy_price",
                          "package"        => "field_taxonomy_package",
                         );

  if (array_key_exists($node->type,$nodes_to_check)) {
    $taxonomy_field = $nodes_to_check[$node->type];
    print_r($taxonomy_field);
    $tid = $node->field_taxonomy_price ['und'][0]['tid']; //  <- this works but, how
    //$tid = $node->"$$taxonomy_field" ['und'][0]['tid'];     <- can I deref variable?
  }
?>


texts:
How to create sticky Social Media Tabs to the right of the website?

See the below screenshot for how it stick at the right:

Is there any Drupal module or plugin available?


texts:
I have a taxonomy like this in our Drupal 7 website.

(Group1)
 |
 +---- (Group1SubGroup1)
 +---- (...)
 +---- (Group1SubGroup10)

(Group2)
 |
 +---- (Group2SubGroup1)
 +---- (...)
 +---- (Group2SubGroup4)
 ...

And we've use a module (I dont remember the name) that gives users rights depending on the term. For example, for user1 we give him CRUD rights on Group2SubGroup4, but nothing on Group2SubGroup1.

There's a shared directory where you can upload media files when you create an article.

So, when the user1 want to create a new article with term Group2SubGroup4, we'd like to  give him rights to upload a file, but only in a sub-directory of the "shared multimedia files directory" called Group2SubGroup4.

For example if the directory is /www/htdocs/multimedia, when the user1 want to create a new article with term Group2SubGroup4, he will have rights to upload multimedia files but its "base" directory will be /www/htdocs/multimedia/Group2SubGroup4

How would you do this?

And if you have an easy solution for this, I'd like to do more: have the rights to write on the right directory (/www/htdocs/multimedia/Group2SubGroup4) and still the possibility to read everything else (/www/htdocs/multimedia and other subdirectories). How would you do this?


texts: One content type two different node--MYCONTENTTYPE.tpl.php for content style

texts:
I've got one content type, in the teaser I've limited the chars lenght for title and body through a script in the file .tpl.php

<?php $limited_title = (substr($title,0,60));
    print $limited_title."..."; ?></h2>

For the same content type I've got two views, both in "content" mode with a different filter criteria.
What I wanna do is to have one view showing 60 chars of the title and the other view showing 100 chars of the title. Is it possible to create two different node.tpl.php like we do with the view giving the name of the page? like node--mycontentType--page-1.tpl.php.

if it's not, what the best way to get the result I want?

No javascript please.

Thanks in advance.


texts: Disable the message shown when a node is created

texts:
I'm using Rules to redirect the user to a different page after a node has been created.

Is there an easy way to suppress the sticky "XXXXX has been created" message?


texts:
I want to add a class to the <a> tag of a field that consists of a link and  text. (It's a field of type Link.) The name of the field is content.field_c_button_link.

In the template file, I want to add something like the following.

{{ content.field_c_button_link.0.addClass('button blue') }}

How can I add a class properly?

According to Patrick Scheffer's answer, I looked at the settings for a field where I can add extra CSS classes, but I could not find any. This is a screenshot of what I can edit in the link field.


texts: How can I update the field of the entity?

texts:
I have an "Question" entity, and I need to updates its 'key' field (of string type):

My code isn't working:

  $storage = \Drupal::entityManager()->getStorage('question');
  $query = $storage->getQuery();
  $query
          ->condition('key', $key);

  $entity = $query->execute();

 $entity -> set ('key', 'new_value');
 $entity->save();

It returns the error Fatal error: Call to a member function set() on a non-object