texts: How can I fix site UUID does not match error during config import?

texts:
I'm getting this error below whenever I try executing the commands drush config-import staging on the CLI. I'm basically in the process of migrating a drupal 7 DB to Drupal 8 and currently following this guide since I'm still new with migration.

https://www.youtube.com/watch?v=_z2FH0efd_g

Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization. in         [error]
Drupal\Core\Config\ConfigImporter->validate() (line 728 of
/Applications/XAMPP/xamppfiles/htdocs/drupal-eight-iom/core/lib/Drupal/Core/Config/ConfigImporter.php).
The import failed due for the following reasons:                                                                [error]
Site UUID in source storage does not match the target storage.
Entities exist of type Shortcut link and Shortcut set
Default. These entities need to be deleted before importing.
The core.extension configuration does not exist.
Can not uninstall the Configuration module as part of a configuration synchronization through the user
interface.

$databases['default']['default'] = array (
  'database' => 'drupal-eight-iom',
  'username' => 'root',
  'password' => '',
  'prefix' => '',
  'host' => '127.0.0.1',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

$databases['upgrade']['default'] = array (
    'database' => 'drupal-seven-iom',
    'username' => 'root',
    'password' => '',
    'prefix' => '',
    'host' => '127.0.0.1',
    'port' => '3306',
    'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
    'driver' => 'mysql',
  );

$settings['install_profile'] = 'standard';
$config_directories['staging'] = 'sites/default/config';
$config_directories['sync'] = 'sites/default/files/config_zB_DnNUK68i5Owp5a8FzTiClQfp3d3jrwcy0_HuS1hNCGv9Y_Iva2Ahm8LCH-P0j0M2jwmQAsA/sync';


texts: How do I populate report page using a controller?

texts:
I'm following this tutorial on creating a report page for a custom plugin, but note that I'm using Drupal 9, and not Drupal 8 as per the tutorial.
I've created a report() method inside my implementation of ControllerBase:
<?php
/**
 * file
 * Contains \Drupal\rsvplist\Controller\ReportController
 */

namespace Drupal\rsvplist\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Database\Database;
use Symfony\Component\HttpFoundation\Response;

/**
 * Controller for RSVP List Report
 */

class ReportController extends ControllerBase {

  /**
   * Gets all RSVPs for all nodes.
   *
   * @return array
   */
  protected function load() {
    $select = Database::getConnection()->select('rsvplist', 'r');

    // join the users table, so we can get the entry creator's username
    $select->join('users_field_data', 'u', 'r.uid = u.uid');

    // join the node table, so we can get the event's name
    $select->join('node_field_data', 'n', 'r.nid = n.nid');

    // Select the specific fields for the output
    $select->addField('u', 'name', 'username');
    $select->addField('n', 'title');
    $select->addField('r', 'mail');

    $entries = $select->execute()->fetchAll(\PDO::FETCH_ASSOC);

    return $entries;
  }

  /*
   * Creates the report page
   *
   * @return array
   *   Render array for report output.
   */
  public function report() {
    $headers = [
      t('Name'),
      t('Event'),
      t('Email'),
    ];

    $rows = [];
    foreach ($this->load() as $entry) {
      // sanitise each entry
      $rows[] = array_map('Drupal\Component\Utility\SafeMarkup::checkPlain', $entry);
    }

    return [
      ['table'] => [
        '#type' => 'table',
        '#header' => $headers,
        '#rows' => $rows,
        '#empty' => t('No entries available'),
      ],
      ['message'] => [
        '#markup' => t('Below is a list of all Event RSVPs including username, email address and the name of the event they will be attending.'),
      ]];

  }
}

My routing file seems to be set up correctly since I see the link to the report page:

However, when I navigate to the report page, I just see a blank page;

I thought perhaps I'm supposed to return a HTTPFoundation\Response object, so I tried this;
$response = new Response();
$response->setMaxAge(0);
$response->setContent('hello world');

return $response

But that seemed to have the effect of completely nuking the HTML of my page and just printing "hello world" to the screen with all menu items gone, so clearly that's not correct either. What am I doing wrong here? Better yet, where should I go to learn about how to do this correctly?


texts: Properly adding an action to a ContentEntityForm

texts:
I've created an add/edit form for a custom entity type, which extends Drupal\Core\Entity\ContentEntityForm. By default this form always comes with a "Save" button, and a "Delete" button if editing. I've been asked to add a "Cancel" button as well, but can't figure out how this is supposed to be done in Drupal.

I've seen plenty of answers about using hook_form_alter(), but nothing that is really working. My current solution is to add

$form['cancel'] = array(
    '#type' => 'submit',
    '#weight' => 10001,
    '#submit' => array('cancel_submit'),
    '#value' => t('Cancel'),
);

to the form's form() function, where cancel_submit() is a custom function, but that renders like  which looks awful.

How can I get the two buttons to be in line with each other? Is there a way to properly add a button to the form actions?


texts: Get fields from a collection field in .theme

texts:
I would like to know how I have to collect the field collection to get the fields it contains

$fieldItemList = $node->field_collection_gallery;
$fieldCollection = $fieldItemList[0];
$fieldCollectionItem = FieldCollectionItem::load($fieldCollection->value);


texts: Permission to create new users but not to manage them

texts:
I need to create a permission that allows any user to create other users without allowing them to manage all users (ie without granting them 'administer users' permission).

My approach was altering menu 'admin/people/create' but it - for unknown reason - doesn't work. Even though the permission for the menu is granted the menu item with link for is invisible and when I go to the specific url it - if I don't have 'administer users' permission - just redirects me to current user profile page.

    /**
 * Implements hook_menu_alter().
 */
function fm_users_more_menu_alter(&$items) {
  $add_new_user = &$items['admin/people/create'];

  unset($add_new_user['access callback']);
  unset($add_new_user['access arguments']);

  $add_new_user['access callback'] = 'fmu_add_user_access_callback';
  $add_new_user['access arguments'] = array(1);
}

/**
 * Callback that manages access to create user page.
 */
function fmu_add_user_access_callback($arguement) {
  dsm('test23');
  return true;
}

It does the same - redirects you to current user profile page - with User register form.

  $register_new_user = &$items['user/register'];

  unset($register_new_user['access callback']);
  $register_new_user['access callback'] = 'fmu_register_user_access_callback';

/**
 * Callback that manages access to create user page.
 */
function fmu_register_user_access_callback() {
  dsm('test23');
  if (user_register_access() || user_access('create users under self')) {
    return true;
  }
  else {
    return false;
  }
}


texts: acquia cloud - images in content break, different path local vs cloud/server

texts:
On my local dev environment, my images are stored in (relative to server root) /sites/default/files/images/

On the server, acquia cloud implements a virtual directory and the end result is that images are stored relative to root in /files/images

In my content nodes, I'm using root-relative paths for my images.  But this means any time I migrate my content between the local environment and the server, all images break.

I don't want to have to take any manual steps to change image paths every time I migrate content (I migrate content "down" from server to lcal periodically so that I am developing against "real" content).

Shouldn't there be some simpler way to configure things so that the root-relative image paths can intelligently choose the correct path based on which environment is being accessed?


texts: Why my template suggestion is not called (the return)

texts:
I have seen many questions like this ones and I have tried all the solutions...
Here is my setup:
1-I have a custom entity with the id defined as follow:
 * @ContentEntityType(
 *   id = "bank_operation",
 *   label = @Translation("Bank Operation"),

2- My hook_theme():
function bank_operation_theme() {
  return [
    'bank_operation' => [
      'render element' => 'elements',
     ],
  ];
}

3- My hook_theme_suggestions_HOOK()
function bank_operation_theme_suggestions_bank_operation(array $variables) {
  $suggestions = [];
  $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
  $suggestions[] = 'bank_operation__' . $sanitized_view_mode;
  return $suggestions;
}

4- My Route to display the entity with a "receipt" view mode
entity.bank_operation.receipt:
  path: '/bank_operation/receipt/{bank_operation}'
  defaults:
    _entity_view: bank_operation.receipt
    _title: 'Receipt'
  requirements:
    _entity_access: 'bank_operation.view'

5-My twig files:
modules/custom/bank_operation/templates/bank-operation.html.twig
modules/custom/bank_operation/templates/bank-operation--receipt.html.twig

Result: Everything works fine :
-receipt view mode is used
-suggestions seems to be correctly added:
<!-- THEME HOOK: 'bank_operation' -->
<!-- FILE NAME SUGGESTIONS:
   x bank-operation.html.twig
   * bank-operation--receipt.html.twig
   x bank-operation.html.twig
-->
<!-- BEGIN OUTPUT from 'modules/custom/bank_operation/templates/bank-operation.html.twig' -->

Except that bank-operation--receipt.html.twig is not called
I have tried all combinations of file name/suggestions/base hook name/... without any success
I have added all the possible twig file name in my templates folder (with or without dash)
I have the feeling that the problem is coming from the fact that the ID of my entity have an underscore in its name...


texts: Changing a filter in a view without modifying the filter clone?

texts:
I duplicated a block from view using clone display, but when I change the language on the block cloned filter, the filter is changed in the master view also. How to avoid this? I need 3 blocks, the block to master the English language and the other 2 blocks to English and Spanish.

Thank you


texts: Custom block doesn't work correctly when not logged in

texts:
So I have a custom block module that displays three links, which then when clicked, reload the page and redirect to checkout based on a GET variable.

function innovista_donate_contents() {
  if(isset($_GET['d'])){
    switch ($_GET['d']) {
      case 1:
        $product_id='6';
        break;
      case 2:
        $product_id='8';
        break;
    }
    commerce_cart_product_add_by_id($product_id, $quantity = 1, $combine = TRUE);
    drupal_goto($path = 'checkout', $options = NULL, $http_response_code = 302);
  }
  else {
    return '

      Link 1
      Link 2
';
  }
}

The issue is that if you are not logged in then often the top half of this function that uses the GET var doesn't work. I thought it might be a cache issue so cleared the cache but this hasn't resolved the issue. Any idea what is going on here?


texts: What are the Steps to Translate the Current Search Block and Facet Search block(s)

texts:
I have been unable to configure things such that the Current Search Block or Search Facet block(s) have their strings show up in the Translation tool at :

  admin/config/regional/translate/translate

They are however available in options in the translation tools filter

I do have Facet API Translation installed

I have tried refreshing String translations at:

  admin/config/regional/translate/i18n_string

And I have tried specifying the blocks as translatable on their respective blocks configuration forms (the form states that because the module is responsible for the content of the block that only Title translations are possible ... this is obviously not what I need to do to translate the blocks contents)

What are the Steps required to Translate Facet Search Block(s) and Current Search Block ?


texts: How to create Dummy Content with certain data restrictions (specific date ranges, users, values, ...)

texts:
I know about the Devel Module's capability to generate random content (BUT almost no control over the data entered) and also about the D7 Devel script which is a possibility, but i'd like to have a module and not a script. The Dummy Content Module creates the content only upon installation, thats why it does not help me either cause i want to create it via a menu option like it is with the Devel Module.

I searched high and low but could not find a module that gives me that option, can anybody give me a hand here?

Problem

Creat Dummy Content with specific ranges for

date fields: e.g. between "now" and "now +10 day"
number fields: e.g. between 10 and 20 step 2
...


texts: Print specific block from a region in drupal 7

texts: The region name is "sidebar_first". and it has two blocks. How can I print this block separately. Please help. I can not find the way to print a specific block from a region in drupal 7.


texts: On a Drupal user application form, is it possible for the user to lookup existing users?

texts: I'm looking to add a user lookup form to my Drupal site's application form. One question would ask the applicant/registrant to look up an already existing user on the site. What's the best way to go about something like this in Drupal?


texts: I have a content type with a private image field. I would like to render the image on the twig template in order to show it to the user when it has enough permission, but the image source is a private directory and I don't know what could be the path to show it.


texts: Display in the child node content from the parent node

texts:
i'm new to Drupal 6 and i have a specific question, which can't be solved so far.
In my project i'm working with a Taxonomy menu module. So the menu structure is shown below.

Item1
-Subitem1 (Node1->Content_type1)
--Subsubitem1 (Node2->Content_type2)
--Subsubitem2 (Node3->Content_type2)

I also have 3 articles of different content types, which are associated with sub and subsubitems (See the structure above).
In Node2 and Node3 i must to display some content taken from the parent Node1 (title, image and file field). And i have to do this in each node, which has a content_type_2.

I'll be very thankful if you could provide me some information, which helps better understand and solve my problem.


texts: Impossible to enable modules in SimpleTest

texts:
I am building SimpleTests for my modules:

It seems like the standard procedure for enabling modules it doesn't work for me:

function setUp() {
    parent::setUp('mymodule');
 }

I constantly get a stupid error code: Duplicate entry 'bartik-system-main' for key 'tmd': INSERT INTO {block}

As I am using profiles I used the $profile variable:

protected $profile = 'myprofilename';

I have forced this by using a Drupal function:

module_enable(array('mymodule'), $enable_dependencies = TRUE);

In this final case the error that persists is

Undefined property: stdClass::$name

Here below is a sample of my code:

class mymoduleWebTestCase extends DrupalWebTestCase {

  protected $privileged_user;

  protected $profile = 'myprofile';

  public static function getInfo() {
    return array(
        'name' => 'mymodule',
        'description' => 'mydescription.',
        'group' => 'mygroup',
    );
  }

  function setUp() {
    $this->privileged_user = new stdClass();
    parent::setUp();
   // Login a user that has access to the content sync server admin settings
    $this->privileged_user = $this->drupalCreate();
    $this->drupalLogin($this->privileged_user);
  }

  function testMyModule() {

    //Create content of community type
    $settings = array(
      'type' => 'mycontenttype',
      'title' => 'Sample Content',
      'link' => 'http://www.google.com',
      'body' => array(LANGUAGE_NONE => array(array('body'))),
      'moderate' => 1,
      'status' => 1,
      'revisions' => NULL,
      'taxonomy' => NULL,
    );
    $node = $this->drupalCreateNode($settings);
    $this->drupalGet('mymodule/sample-content');
    $this->assertRaw('Sample Content', t('Content created.'));

    $node = $this->drupalCreateNode($settings);

   //This if we have a valid link inside
    $this->clickLink(t('http://www.google.com'));

  }


texts: Database password revealed in PHP error_log?

texts:
Noticed some errors while updating to Drupal 8.9.11. As I'm reviewing I come across the following. Replaced the actual password with PASSWORD below.
Is this intentional or a bug? I can't see why the db password should be printed. Or could this be a PHP misconfiguration? Running PHP 7.3.25 and mysql 5.7.32 on a Cpanel server without Composer/Drush.
I'm also not sure what the error is trying to tell me. I only see this logged a handful of times over the last year. If anyone is able to help, thank you.
[08-Dec-2020 07:12:14 UTC] PDOException: SQLSTATE[HY000] [2002] No such file or directory in /home/site/public_html/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php on line 79 #0 /home/site/public_html/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php(416): PDO->__construct('mysql:host=loca...', 'site_live', '>PASSWORD...', Array)
#1 /home/site/public_html/core/lib/Drupal/Core/Database/Database.php(374): Drupal\Core\Database\Driver\mysql\Connection::open(Array)
#2 /home/site/public_html/core/lib/Drupal/Core/Database/Database.php(169): Drupal\Core\Database\Database::openConnection('default', 'default')
#3 [internal function]: Drupal\Core\Database\Database::getConnection('default')
#4 /home/site/public_html/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php(79): call_user_func_array('Drupal\\Core\\Dat...', Array)
#5 /home/site/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(173): Drupal\Component\DependencyInjection\PhpArrayContainer->createService(Array, 'database')
#6 /home/site/public_html/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php(212): Drupal\Component\DependencyInjection\Container->get('database', 1)
#7 /home/site/public_html/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php(62): Drupal\Component\DependencyInjection\PhpArrayContainer->resolveServicesAndParameters(Array)
#8 /home/site/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php(173): Drupal\Component\DependencyInjection\PhpArrayContainer->createService(Array, 'cache.container')
#9 /home/site/public_html/core/lib/Drupal/Core/DrupalKernel.php(544): Drupal\Component\DependencyInjection\Container->get('cache.container')
#10 /home/site/public_html/core/lib/Drupal/Core/DrupalKernel.php(910): Drupal\Core\DrupalKernel->getCachedContainerDefinition()
#11 /home/site/public_html/core/lib/Drupal/Core/DrupalKernel.php(477): Drupal\Core\DrupalKernel->initializeContainer()
#12 /home/site/public_html/core/lib/Drupal/Core/DrupalKernel.php(707): Drupal\Core\DrupalKernel->boot()
#13 /home/site/public_html/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#14 {main}


texts: Creating Select Fields in a module with Drupal 7

texts:
I am trying to write my own module to add a content type with the help of node_example and this page. I made small tweaks and got it to work, yet I cannot find any example to create a select box as a field, and I failed in my each attempt. I have also checked the official documentation for field_create_field, still no clues.

Is there any documentation or sample you can guide me?


texts: Wrong order of entities, how to change that?

texts:
I've created my first module which shows a list with nodes containing a certain term (like a taxonomy list, like usual), but the entities gets listed in an unknown way - I'm new to this and don't know - and I want them to be listed in alphabetical order.

How do I change that?

Code to retrive and print the entities:

function mymodule_cmp($a, $b) {
  $a = (array) $a;
  $b = (array) $b;
  return strcmp($a['name'], $b['name']);

}

$terms = taxonomy_get_tree(10,0,1);

usort($terms, "mymodule_cmp");

$counter = 0;

$result = taxonomy_select_nodes($tid, FALSE);

foreach($result as $nid) {

    $node = node_load($nid);

            // Prints all that is needed.
    }


texts:
Using s3 file system & feed import module. Issue is the fetching of csv file from s3 working... says no file or folder detected ... have the folder under s3://public/repo.csv and had read/write permission.

When running import, it will have a no file / directory found.


texts:
I have problems configuring the search-result.tpl. Is it so, that the fields set in Search result view mode are always snippet'ized as plain text? I have for example a taxonomy term on each node, which I set to appear as link in the Search result view mode, yet it is always output as plain text.

I'm using Custom Search and Search API, if that matters.


texts:
I have installed Barrio Bootstrap (8.x-4.33) and it worked so far.
But I can't override a template for a specific node type.
I copied the original template into my subtheme/template folder and named it like suggested in the FILE NAME SUGGESTION (debug mode).
E.g.: bs-2col-bricked--node-cuba-casa-particular-full.html.twig
This doesn't work.
Only when I name it like the original file bs-2col-bricked.html.twig it works.
I tried also 5.1.4, but it's the same. Anything wrong with the FILE NAME SUGGESTIONS?
In my Bootstrap3 theme it worked.
Can anybody help, please.


texts: What might cause a Views preview to not display?

texts:
For some reason I can't preview my views, as shown in this screenprint:

Any idea what is going on? Maybe it's a setting?


texts: "Translate" tab does not appear for every content

texts:
I have installed the Localization module in my drupal project. All was working fine until now but i just noticed the "Translate" tab isn't visible for all my contents...

What i'm doing is simply :

-I go to content management
-content
-edit

-> Translate tab isn't visible...

On the other hand, when i try to translate another content of another content type, translate appears...

did anyone else face this problem previously?
thanks in advance


texts: File for template suggestion not picked up

texts:
I am using suggestions for a node , I have in the html source the suggestions:

node--1.html.twig,
node--1--article-list.html.twig,
node--article-list.html.twig,
and node.html.twig

Whenever I use node--article-list.html.twig, it is not picked up, but when I rename to anything else, like for example node--1--article-list.html.twig , everything works fine. Anyone has an idea why? I could not find any other file named node--article-list.html.twig as part of drupal so I don't think it is a conflict issue. Thanks for your help.


texts: Is it possible to change the "add new comment" text on certain content types?  Also is it possible to only allow certain roles to post comments on this content type?


texts: How can I show two users what taxonomy terms they have selected in common?

texts:
I have a taxonomy vocabulary, Hobbies.  Users can select their hobbies from a list of about 300.  Many users select a few dozen hobbies, which makes for an extremely long list.

What I'd like to do is show a special list of those hobbies that the logged-in user has in common with the user being viewed.

I'm using Panels to override the user profile page, so I can easily attach views/content panes, blocks, etc.  I also have access to the logged-in user and the user being viewed through Panels contexts.

Is it possible to use Views to filter out taxonomy values in this way?  If not, how might I show users those terms that they have in common?


texts: How to handle Dev and Production servers having different file structure

texts: I know you are not supposed to do this, but for reasons beyond my control the location of my web root is different on my Dev and my production server.  As a result everytime I copy the database from my production server to my Dev server, all of my modules become confused and point to the wrong file location. What is the recommended way to handle this?


texts: Creating iframe to be used in other websites

texts:
I've created a controller with the route "/get-info", the controller return a template custom-info.html.twig

my_module/src/Controller/MyController.php file:

<?php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;

class MyController extends ControllerBase {

  public function content() {

    return [
      '#theme' => "custom_info",
    ];
  }
}

my_module/templates/custom-info.html.twig file:

<h1> Hello World </h1>

When visiting the path: www.mySite.com/get-info I get response with the header an footer of my site and "Hello World" as content. but when using <iframe src="www.mySite.com/get-info"></iframe> in an other Drupal project I get an empty iframe.

Is this the right way to create iFrame-ready Widgets in Drupal 8? if so what should I add/remove to make it work?


texts: How to view content from admin theme (Seven), when logged in as admin

texts:
I use Drupal 8.2.3 and can't view content in my admin theme (seven), when logged in as admin (I can only view management pages with Seven, but not content pages as in general).

I thought that this would help but it doesn't:


texts:
Hello i have an awful feeling im just simply doing something fundamentally wrong. I think they are both the same function possin;y Can anyone tell me how to get it all together possibly? thanks

<?php

function ukf2_preprocess_page(&$vars) {
 if (isset($vars['node'])) {
$vars['theme_hook_suggestion'] = 'page__'.$vars['node']->type; //
}
}
// Finish copy Template for Content type

function ukf2_preprocess_page(&$variables) {

if (!empty($variables['page']['sidebar_first'])) {
    $variables['content_column_class'] = ' class="col-sm-10"';
  }

 else {
    $variables['content_column_class'] = ' class="col-sm-12"';
  }

if (!empty($variables['page']['sidebar_second'])) {
    $variables['content_column_class2'] = ' class="col-sm-8"';
  }

 else {
    $variables['content_column_class2'] = ' class="col-sm-12"';
  }

}


texts: How to debug #states mecanism - trying to get #states to work with inner fieldsets & webform

texts:
I have a relatively simple webform, with 2 fieldsets and a few other fields. The fields aformentionned have #states  actions configured and behaving proper like in a regular form.

It is in the fieldset shown below I have a problem.
THe fieldset should be collapsed (via #states) and there is nothing I can do to make it so.

The offending fieldset has #states defined in the bottom form_alter, I outlined the error location in caps:

// Implements hook_form_alter()
function formHelper_form_alter(&$form, $form_state, $form_id)  {
switch ($form_id)  {

        case 'webform_client_form_1':

           // Set fieldsets as collapsible
          $form['submitted']['inscription']['#collapsible'] = true;
          $form['submitted']['inscription']['#collapsed'] = true;

          $form['submitted']['inscription']['enfant_1']['#collapsible'] = true;
          $form['submitted']['inscription']['enfant_1']['#collapsed'] = false;

          $form['submitted']['inscription']['enfant_2']['#collapsible'] = true;
          $form['submitted']['inscription']['enfant_2']['#collapsed'] = true;

            //vardump of fieldset
           dpm($form['submitted']);

           // Show datepicker for child one if inscription is part time
           $form['submitted']['inscription']['enfant_1']['jrs_semaine']['#states'] = array(
              'visible' => array(   // action to take.
                ':input[name="submitted[inscription][enfant_1][horaire]"]' =>
                  array('value' => 't_partiel'),
              ),
           );
           // Show datepicker for child two if inscription is part time
           $form['submitted']['inscription']['enfant_2']['jrs_semaine2']['#states'] = array(
              'visible' => array(   // action to take.
                ':input[name="submitted[inscription][enfant_2][horaire_2]"]' =>
                  array('value' => 't_partiel'),
              ),
           );
            // THIS IS THE FIELDSETY THST DOES NOT WORK:
           // set state on second fieldset to be visible only when two is seiected.
           $form['submitted']['inscription']['enfant_2']['#states'] = array(
              'expand' => array(   // action to take.
                ':input[name="submitted[inscription][enfant_1][horaire]"]' =>
               array('value' => 't_partiel'),
              ),
           );
          break;
 }
}

Now, in the drupal docs (example module) there is a fieldset shown  with working code using  as the state to change, and it seems in the docs fieldsets are clearly supported, alas not the one in my webform.

I am using the same condition that is working on the other field so I assume the problem is not with the selector. In light of this fact, I have no clue of what even to really look for but I really want to figure it out.

Is anyone familiar enough with #states to tell me how I could debug the js in this case?

I know it is in /misc/states.js, I just don't know what to look for in states.js, or even if this is what is preventing the fieldset from collapsing.

update: Reposted the full hook_form_alter function as per request.


texts: why am I unable to install/update modules as an admin?

texts:
I have a website created using Drupal-8 within a sub directory as: /var/www/html/drupal

so http://example.com/drupal is the path used to access the website.

In order to access the website without the sub directory name, I have created a .htaccess with rewrite rule and placed it in the root folder

Then I got the error "User error: Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it"

To solve this, I have included the below code snippet in .settings.php:

if (isset($GLOBALS['request']) and
'/drupal/index.php' === $GLOBALS['request']->server->get('SCRIPT_NAME')) {
$GLOBALS['request']->server->set('SCRIPT_NAME', '/index.php');
}

As my expected domain is at domain.com. Drupal sends the request to itself there, the request is forwarded to Drupal because it's not located where Drupal expects itself to be and as a result fails validation

Now after doing this, I'm able to access the website without using the sub directory name in the URL but the problem is

I'm unable to install or update modules even though I'm logged in as an admin.
I see in the logs that the user is identified as "Anonymous" only while trying to install/update module. Before this in the log, there is a log of user identified as "Admin" after logged in.

I've tried clearing the cache, and repairing the session table from the database. commenting out $cookie_domain solved the issue for many who had the same problem in earlier versions of Drupal.

Appreciate any help with this.


texts: Dynamic nid for drupal_field twig tweak function

texts:
I have a field_slides paragraph field on my home page, on drupal 9.1.3. It is for rendering a carousel.
I want to iterate over the elements of the paragraph field (eg the slides with title, description and button fields). I'm using drupal_field twig tweak function for the sake of translability.
I have tried something like the following :
  {%  for slide in element['#items'] %}

{{ drupal_field('field_titre', 'node', {{ slide.entity.nid }}) }}

{{ drupal_field('field_bouton', 'node', {{ slide.entity.nid }}) }}

{{ drupal_field('field_corps', 'node', {{ slide.entity.nid }}) }}

   {% endfor %}

Any idea on how to dynamically get the nid of the paragraph entity in the drupal_field function?


texts: Submitting a form with ajax, when multiple instances of the same form are on a page

texts:
I am battling with D8 ajax right now, hoping someone can shed some light on where I'm badgering this implementation.

The goal is to update a value based on the on the state of a checkbox.  The issue seems to be that there are multiple instances of this same form on the page.  However, I've confirmed they all have unique build ids.  They do have the same $form['#form_id'], but I think that's to be expected, $form['#id'] is different.

Here is the code:

public function buildForm(array $form, FormStateInterface $form_state) {
  $widget = $form_state->getBuildInfo();
  /* @var $widget Factorywidget */
  $widget = current($widget['args']);

  if ($form_state->has('widget_id')) {
    $widget_id = $form_state->get('widget_id');
  }
  else {
    $form_state->set('widget_id', $widget->id());
  }

  $ajax = [
    'wrapper' => 'widget-toggle-status-wrapper',
    'callback' => '::ajaxRebuildForm'
  ];

  $form['#prefix'] = '
';
  $form['#suffix'] = '
';

  $form['toggle_widget_status'] = [
    '#type' => 'checkbox',
    '#title' => 'Toggle Status',
    '#default_value' => $widget->field_widget_status->value,
    '#ajax' => $ajax + ['trigger_as' => ['name' => 'widget_toggle_submit']],
  ];
  $form['widget_id'] = [
    '#type' => 'textfield',
    '#default_value' => $form_state->get('widget_id'),
    '#title' => 'widget ID is',
    '#size' => 10,
    '#disabled' => TRUE,
  ];

  $form['widget_toggle_submit'] = [
    '#type' => 'submit',
    '#name' => 'widget_toggle_submit',
    '#value' => $this->t('Submit'),
    '#submit' => ['::widgetToggleSubmit'],
    '#limit_validation_errors' => [],
    '#ajax' => $ajax,
    '#attributes' => [
      'class' => ['js-hide']
    ]
  ];

  return $form;
}

/**
 * Ajax submit handler that will return the whole form structure.
 *
 * @param array $form
 *   An associative array containing the structure of the form.
 * @param \Drupal\Core\Form\FormStateInterface $form_state
 *     The current state of the form.
 *
 * @return array
 *   The form structure.
 */
public function ajaxRebuildForm(array &$form, FormStateInterface $form_state) {
  return $form;
}

public function widgetToggleSubmit($form, FormStateInterface $form_state) {
  $widget = $form_state->get('widget_id');
  $form_state->setRebuild();
  /* @var $widget Factorywidget */
  //$widget = FactorywidgetService::toggleFactorywidgetwidgetStatus($widget);

  //return new AjaxResponse();
}

Again, there are multiple instances of this form on the page.  I added in widget_id as a textfield just to see if the widget Id was correct.  When viewing the page, widget ID in the textfield is correct:

The problem is, no matter what toggle I click, the widget_id in $widget = $form_state->get('widget_id'); in widgetToggleSubmit is always the widget Id for the first form on the page.  I added a shuffle to the render array which displays these to confirm - it's always set to the first form on the page.

To, hopefully illustrate, this screenshot shows the Debugger for a breakpoint I put in widgetToggleSubmit at $form_state->setRebuild():

The toggle has been triggered for the widget with id 3, but $form_state->get('widget_id') will only return the value for the first form on the page.


texts: Problems creating Drupal Commerce Product Display, list of available products not populating

texts:
This is something that has happened to a site I'm maintaining. I can't create product displays for many of my products because the select list of products in the product field isn't populated with many of my products.

I have a content type called "Product Display" with product field of type product reference. When adding products the select list of products is only display 10 of about 100 products.

This only diagnostic information is that two javascript errors are reported

Uncaught TypeError: cannot read property 'behaviors' of undefind in jquery-noconflict.slicknav

And

Failed to load resource: Server responded with a status of 403 (forbidden)

This leads me to thing it's a jquery issue, but not sure how to debug this further.

So, how do I get that list of products to contain all of the products in the store?


texts: How to securely store user's credit card information by using Drupal and Paypal?

texts:
I am working with payment process in my drupal project. Also I have asked to use papal payment gateway (Paypal pro).

My outstanding requirement is to store user's credit card information for their future purchases.

What is the best way to implement this? I got with the suggestion to use Commerce Card on File module. Will this work with Paypal also?


texts:
I have 2 tables:

|users |       |users_roles|
--------       -------------
| uid  |       |uid| rid   |
--------       -------------
|  1   |       | 1 |   3   |
|  2   |

For the authenticated users the role is missing in users_roles table. User with uid=1 is an admin. I want to write the following query in Drupal DB API:

SELECT
        uid
FROM
        users
WHERE
        NOT EXISTS(
SELECT
        NULL
FROM
        users_roles
WHERE
        users_roles.uid=users.uid
)

I tried with this code, but don't know, how to write the query for notExists condition.

$query = db_select('users');

$query->addField('users', 'uid');

$query_exists = db_select('users_roles');
$query_exists->addExpression('NULL');
$query_exists->condition("users_roles.uid=users.uid"); //<- how to do this. Doesn't work.

$query->notExists($query_exists);
$result = $query->execute();
foreach ($result as $record) {
        var_dump($result);
}


texts: Create user after node created and assign node entity reference to it

texts:
I have a content type with name hotel it have entity reference field that referenced to users entity, I want when admin create a node automatically created a user according to hotel email field and then set  user entity reference field with that new created user.How can I do it automatically?

I create a rule with below structure but not work

{ "rules_create_user_based_on_hotel" : {
    "LABEL" : "create user based on hotel",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert--hotel" : { "bundle" : "hotel" } },
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "user",
            "param_name" : "[node:field_hotel_users]",
            "param_mail" : "[node:field_mail_hotel]"
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : { "data" : [ "node:field-user-ref" ], "value" : [ "entity-created" ] } }
    ]
  }
}


texts: I want to define a hover color in the style sheet

texts: I designed a page with the corporateclean theme on http://www.athleticedgefitness.com/. I used nice menus for the drop down. Now I would like to color all my links #E3007B on hover, but I'm not exactly sure how I can get this accomplished. Any help would be appreciated!


texts:
i'm using drupal 7
How to disable the title field in a content type?


texts: Count total number votes a user has gained

texts:
I am using rate module where users can plus or minus the articles created by an author. Now, in the profile page of the author, I want to display the total number of votes he/she has got from all his articles. Is there any way to do this without using db_query ?
Thank you.


texts: My page is like a game, my users (role player) should choose a character, like a Mario character or something like that , but I don't know how can I do it. Drupal 7.


texts: How do I get the absolute path of the file?

texts:
I have created a custom form using (drupal form API),
Is it possible to get the absolute file of the file which will be selected in the file upload field ?

like if user chooses to upload file from "/home/user2/Desktop/something.jpg"

How do I grab that absolute path of the file?

here is my code below,

function example_form($form, &$form_state) {
  $form = array();

  // Use the #managed_file FAPI element to upload a file.
  $form['file_fid'] = array(
    '#title' => t('File'),
    '#type' => 'managed_file',
    '#description' => t('The uploaded file will be processed.'),
    '#default_value' => variable_get('file_fid', ''),
    '#upload_validators' => array(
    'file_validate_extensions' => array('mp3'),
    ),
  '#upload_location' => 'public://songs/',
  '#process' => array('example_my_file_element_process')
);

  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Import'),
  );

  return $form;
}

/* It disables the default upload button that comes with this #managed_file form */
function example_my_file_element_process($element, &$form_state, $form) {
  $element = file_managed_file_process($element, $form_state, $form);
  $element['upload_button']['#access'] = FALSE;

return $element;
}

function example_form_submit(&$form, &$form_state) {
  // Load the file.
  $file = file_load($form_state['values']['file_fid']);
  $url = file_create_url($file->uri); //here I can get the URI for file
}

I am using Drupal 7 on UBUNTU 12.04


texts:
Maintainer of Custom Publishing Options here... trying to figure out how to port to 8 in a clean way.

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

I have config entities working, so I can define custom publish options in the admin.

From here, I would like to add these options on the Node form(s), but they also need to be stored in node_field_data table. Previously hook_schema_alter / entity_info_alter was used to do this, example below:

D7:

/**
 * Implements hook_schema_alter().
 */
function custom_pub_schema_alter(&$schema) {
  $types = variable_get('custom_pub_types', array());
  foreach ($types as $type) {
    $schema['node']['fields'][$type['type']] = array(
      'description' => t('Custom publishing option @name', array('@name' => $type['name'])),
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
    );
  }
}

D8:

function custom_pub_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'node') {
    $fields = [];

    foreach (Drupal::entityTypeManager()->getStorage('custom_publishing_option')->loadMultiple() as $machine_name => $publish_option) {
      $fields['cpo_' . $publish_option->id()] = BaseFieldDefinition::create('boolean')
        ->setLabel(t('!label', ['!label' => $publish_option->label()]))
        ->setDescription(t('A status added by custom publishing options.'))
        ->setRevisionable(TRUE)
        ->setTranslatable(TRUE)
        ->setDefaultValue(FALSE)
        ->setDisplayConfigurable('form', TRUE);
    }

    return $fields;
  }
}

$fields looks good here, and no errors are thrown - yet, I do not see any change to the data in the database. I would expect fields to be added to the node_field_data table, what is missing here? hook_schema_alter() has been removed, is there a way to trigger this to update that I don't see?

The purpose of this module is to let admins define their own statuses to use with the default node statuses, which from there they can combine them for different Views/Rules/Action capabilities. Being set on the node similar to status/promote/sticky made it fairly quick.


texts: How do I populate an address field programmatically if it is an autocomplete widget?

texts:
I have a content type that is using the addressfield_autocomplete module so that I can use the map widget. The issue is, I need to be able to create nodes programmatically with the address field but also retain the autocomplete ability if nodes are manually created.

I get this:
Fatal error: Call to a member function getCentroid() on a non-object

I'm including the country and all the addressfield default values.

It works fine if I turn off the autocomplete.

Any Ideas?


texts: How to show a menu for everybody but one role?

texts:
I'd like to add, in a custom module, a hook menu that adds a menu only if

the user is logged in
the user has the role "immat"

I'm trying to use the hook_menu() hook but it's never called when the page displays the "Navigation" menu.
Where should I look / which hook should I use?

Thank you very much!


texts: Cannot redeclare MyClass - but it's only declared once

texts:
I'm trying to port an image effect from D7 to D8.

I've got Drupal to list the plugin, but when I try to use it I get a WSOD with "Fatal error:  Cannot redeclare class Drupal\image\Plugin\ImageEffect\EffectMagic".

I've checked and there is no other declaration of this class anywhere.

My file is in mymod/src/Plugin/ImageEffect/EffectMagic.php
and it looks like this (nb. content of functions is removed)

/**
 * @file
 * Contains \Drupal\image\Plugin\ImageEffect\EffectMagic.
 */

namespace Drupal\image\Plugin\ImageEffect;

use Drupal\Core\Image\ImageInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\image\ConfigurableImageEffectBase;

/**
 * Scales and crops an image resource.
 *
 * @ImageEffect(
 *   id = "image_effect_magic",
 *   label = @Translation("Effect Magic"),
 *   description = @Translation("Use ImageMagic command line to process images.")
 * )
 */
class EffectMagic extends ConfigurableImageEffectBase {
  public function buildConfigurationForm(array $form, FormStateInterface $form_state)
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state)
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state)
  public function applyEffect(ImageInterface $image)
  public function transformDimensions(array &$dimensions, $uri)
  public function getSummary()
  public function defaultConfiguration()
}


texts: Omega 4 drush install after omega 3 removal: could not locate Gemfile libraries not installed, drush omega-guard fails

texts:
I unsinstalled Omega 3 , and then installed omega 4 (by drush) and created the subtheme (drush omega-wizard).
Everything seems to work, but the js  libraries like csspie are not present.
Also, when I try to run drush omega-guard, i get the error message There was no Gemfile at sites/all/themes/xxx
It's a single site installation, and omega drush commands work. Changing to the theme directory (as per Drush Omega Guard - "command could not be found" or "could not locate Gemfile") did not alter the results.
Running linux (ubuntu 14.04 with the  LAMPP from the official repositories )
I have another site on that server (my local dev machine) with Omega 4 and everyting works well there.


texts: How to replace authentication links with custom routes?

texts:
I am working on a custom Drupal 8 module that has its own authentication form.

For this, I created a Drupal page with the custom authentication form, i.e. I have a route at drupalsite.com/custom-signup

What I am not able to figure out is how can I replace Drupal's default Register and Login links which are scattered everywhere on the website to point to above route. I don't want to redirect from /user/login page to /custom-signup as I still want to allow admin to login. For all other users except admins should be redirected to \custom-signup.

I could use jquery to brute-force my way to replace the links, but is there an efficient way to achieve this?

TL;DR: I need to replace following default Drupal links using my module.

Update:

Following the first solution, I added the routing files as follows, the links are redirecting me to my custom form.

However, when I try to enter user/login manually in the URL, I get page not found message on the website.


texts: Creating testing local site from online production site

texts:
I have tried to perform this action several times, only to find that I can never login to the previously created database when I setup my local environment. I have recently picked up the practice to have two sites: development and production, sometimes a third one in between.

Here is my process, maybe I am ommiting a step or two:

Create fresh local Database (same name as online) with PHPMyAdmin
Install Drupal 6 using this database
Setup Drupal installation
Import online Database backup onto new local installation
And here is where I get stuck everytime, with the dreaded:

  Access denied for user 'admin'@'localhost' (using password: YES)*

I have edited settings.php file to work from local to online, so I thought I understood how to do this process in reverse, but apparently I don't.

As a last resource, I have even changed admin's and other user's passwords directly in the database via PHPMyAdmin, and used these in settings.php so I might log in, but it just won't happen.


texts: Content type field with term reference or users

texts:
I have "People" content type that has some fields; one of those is "field1," which is a term reference, and uses an autocomplete widget.

How can I display only "Users" registered with particular roles in the term reference with the autocomplete?

I need to display it on http://example.com/sitename/admin/config/people/accounts/fields.

I am displaying any view or content here; this is where administrator users add the fields to the user accounts and in the "field1". How can I display or list only ["username" with respective to "roles"] or ["username"]?


texts: Force views to write exposed form block info to {block} table during install profile

texts:
In a D7 install profile, I am trying to modify the location of a exposed filter block with db_update(), where the view is defined by a module's hook_views_default_views().

At this point it doesn't seem views has collected the views from hook_views_default_views() or the view block does not exist (or db_update cannot address it) in the {block} table until I actually bootstrap Drupal after installation is complete. I have attempted:

Invalidating the views cache via views_invalidate_cache()
Loading the view with views_get_view(NAME)
Triggering drupal_cron_run()

Before issuing the db_update() with no success. I am not versed enough in views to understand at what point views writes the exposed filter blocks to the block table, or how to force it to do so.

I am employing 'cache' => DRUPAL_NO_CACHE, during my db_update() call.

Update : doing a views_get_view() cannot actually load the view. It appears that install profiles do not have access to views provided by hook_default_views.

Thanks.


texts:
My goal was to create a taxonomy reference field in Drupal 8.2.

Consider these to field definitions on an entity.

    // #1
    $fields[$field] = BaseFieldDefinition::create('entity_reference')
        ->setTargetEntityTypeId('taxonomy_term')

    // #2
    $fields[$field] = BaseFieldDefinition::create('entity_reference')
        ->setSetting('target_type', 'taxonomy_term')

Here is how #1 is documented:

  /**
   * Sets the ID of the type of the entity this field is attached to.
   *
   * @param string $entity_type_id
   *   The name of the target entity type to set.
   *
   * @return $this
   */
  public function setTargetEntityTypeId($entity_type_id) {

Looking at the description both should produce the same result - set target entity type.

The #1 creates me an input with autocomplete from page names and page types.

The #2 creates n input with autocomplete from taxonomy terms.

Why does this happen and what is #1 is meant to do?


texts: What was killed after the installation and enabling of Devel with Drush 7?

texts:
I am not a Dev so I don't have a clue where would this come from.

I've installed and enabled the famous Devel module in my Drupal 7 site via Drush 7 on my CentOS online server after connecting with SSH.

After installing and enabling the module I got the message "Killed", not more not less.

My only question is - What was killed?... I've installed modules with Drush many times, on both Druapl 7&8, and both online and locally, and never had this message before. The install and enabling seem to have been successful.

Material I've found in Google and here deals with Drupal 6 and other commands.


texts: Populate drop down fields according to other fields in Drupal 7

texts:
Let's say I have a content type car with content fields brand and model. Now I want to populate the field model according to the value of brand that the user will select. So for example if have:

BMW

series 1
series 3

mercedes

a class
b class

So if a user chooses BMW as a brand the model field should be populated with series 1 and series 3.


texts: How to delete taxonomy terms created with entity_generate process plugin?

texts:
I have this json.
    {
      "ProductKey": "145.1",
      "Product": {
        "Title": "Product title",
        "StartDate": null,
        "EndDate": null,
        "ProductKeywords": [{
          "Name": "keyword 1"
        },
        {
          "Name": "keyword 2"
        },
        {
          "Name": "keyword 3"
        }],
      },
   }

So in this case I can't create a separate migration file for the taxonomy terms because the ProductKeywords is an array and have multiple taxonomy terms.
So I have done it in a single migration file with entity_generate plugin for the taxonomy term entity reference field.
keywords:
    - plugin: sub_process
      source: keyword
      process:
        value: Name
    - plugin: entity_generate
      value_key: name
      bundle_key: vid
      bundle: keyword
      entity_type: taxonomy_term
      ignore_case: true

But the taxonomy terms created with entity_generate do not gets deleted with rollback.
I know there is a postRollback migration event, where we can execute some code after rollback. But I don't know how I can know which taxonomy terms needs to be deleted on the rollback.
Is there any example or hint available?


texts: How to change the e-mail output of a Entity type field in a webform

texts:
I have a content type Agenda. In this content type I can create paragaphs of the type Date. This paragraph has a field date and a field location.
Now people can attend to agenda items by submitting a webform (using the webform module).
In this webform use a Entity type field together with views to make a reference to date paragraphs. This reference works perfectly and creates a select with options showing the name of the name together with date and location. But in the e-mail confirmation I don't see the paragraph fields. Only the name of the node. I want to be able to manage how the output looks in the email confirmations.
At the moment I use [webform_submission:values:agenda] to get the value from the submission.
The way it looks now is:
Node:title > Content type [NID]  But I want to be able to see something like:
Node:title | Paragraph:Date | Paragraph Location
How or where can I change this output?


texts:
I've just started learning Drupal, and the devel module is great and everything but I had a couple of questions about it:

Is it possible to change the output text when generating article or basic page content? For example, instead of using Latin Lorem Ipsum filler text, I'd like to be able to use something that puts out actual English words, like Candy Ipsum.
I noticed that when generating article content, it will also generate a small image to go with it, but the images are not of a uniform size. Is there any way to set it to use a fixed resolution?
This is more of a personal preference, but the user names it generates are a little hard to work around. Back when I worked with Django, I had whipped up a script that put together random user names using common first and last names I had compiled into a text file. Is it possible to do something like that here?

Any suggestions on how I could go about doing these things? Is there perhaps another module(s) I could use to get these functions?


texts: Search API - search string with "0" prefix

texts:
I have a problem with search api. I'm using database search + search api views integration in my website.
Everything works fine, but i noticed that when i submit the search form with a query like "0012" the "0" character is ignored and therefor the results are not correct.
It seems that something is converting the string into integer, stripping the 0 characters.

Any suggestions?


texts:
I created a content type "test", and I want to overwrite the add "test" content page (http://www.example.com/node/add/test); for example, I want to show something on the right part of the page. How can I do it?

the following is i want to do:

i used garland theme as my site's admin theme and my custommed theme company as my site's template. i created a content type named "hello" this content type is used for anonymous to submit content, the page's layout is (header, left, right, footer) some static content and the site navigation locate on the header. the left part is the form which is used by the anonymous to submit content. the right part will be put into some blocks which are generated by the views module. now the default create hello content page for the anonymous is garland theme's create content page. how to change the page shows like the above layout as what i said. thank you.


texts: How to execute a custom code when a plugin instance is deleted?

texts:
I have a custom plugin that implement a context reaction like this:

namespace Drupal\mymodule\Plugin\ContextReaction;

/**
 * Provides a context reaction.
 *
 * @ContextReaction(
 *   id = "banner",
 *   label = @Translation("Banner image")
 * )
 */
class MyReaction extends ContextReactionPluginBase implements ContainerFactoryPluginInterface {...}

The plugin configuration form has a managed file field, and I add the file usage on submission.

When a plugin instance is deleted, I must remove that file usage. How can I do it?


texts:
I have a menu like this:

The sidebar on the left is the Main Menu with links. The first link is STOCKLIJST, that will link to the page stocklijst/aangeboden. As you can see in the second sidebar (this is a menu in a block that will only be visible when page starts with stocklijst/*) the link is active.

But when I click on the second link in the second sidebar the 'STOCKLIJST' in the first sidebar won't be selected anymore.

Why? : Because this is a link to the first link in the second sidebar ... .

How should I could make sure that the first link is active on multiple pages? Or is the easiest way to for this with JavaScript or PHP?

UPDATE:

I've tried the menu position and added a trigger like this:

But that doesn't do much. Something I do wrong?


texts: Checking if a field is empty fails, on a node template file

texts:
Trying to use empty() on a "longtext" field in a custom node template, the field is always reported not to be empty (whatever the field is empty or not).

<?php if (!empty($content['field_myfield'])): ?>

additional content

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

Why doesn't it work?  How else could I test for empty fields in the template file for a node?


texts:
I need to create a permission to allow users to see the content overview page (/admin/content) only during business hours (9 AM to 5 PM).

Drupal core comes with the "Access the Content overview page" permission; but I need "Access the Content overview page during work hours".

I know how to create a permission and how to test that the user has the permission. What I don't understand is how to assign some logic to a permission itself (for example, within business hours).

I can do this in mymodule.permissions.yml.

access content overview within business hours:
  title: 'Access the Content overview page within business hours'
  restrict access: TRUE

I can check the user has the permission with \Drupal::currentUser()->hasPermission('access content overview within business hours').

How can I make the permission return TRUE only during business hours?
How can I check the permission only when the users visits the content overview page?

I can foresee multiple use cases for needing some logic implementation within the permission itself, for example when allowing/restricting access to certain pages depending on whether the environment is development or production, or allowing/restricting access depending on the value of some fields.

- EDIT -

As suggested in the comments, I've started by creating the following three files on my module; but it doesn't work. The CustomAccessChecks::access never gets called.

File: custom_access.services.yml

services:
  custom_access.route_subscriber:
    class: Drupal\custom_access\Routing\AdminRouteSubscriber
    tags:
      - { name: event_subscriber }
  custom_access.access_checker:
    class: Drupal\custom_access\Access\CustomAccessChecks
    tags:
      - { name: access_check }

File: src/Access/CustomAccessChecks.php

<?php

namespace Drupal\custom_access\Access;

use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResultAllowed;
use Symfony\Component\Routing\Route;
use Drupal\Core\Routing\RouteMatchInterface;

class CustomAccessChecks implements AccessInterface {

  /**
   * A custom access check.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   Run access checks for this account.
   */
  public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account) {
    return AccessResultAllowed::allowedIf((int) $account->id() === 1);
  }
}

File: AdminRouteSubscriber.php

<?php

namespace Drupal\custom_access\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

class AdminRouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  public function alterRoutes(RouteCollection $collection) {

    if ($route = $collection->get('system.admin_content')) {
      $route->setRequirement('_custom_access', '\Drupal\custom_access\Access\CustomAccessChecks::access');
    }
  }
}

As expected, visiting '/admin/content' as the main administrator $account->id() === 1 works, but when visiting as another authenticated user, I still can access the page.

What I'm missing?


texts: AutoSKU and Commerce Kickstart 2.0 or Commerce backoffice

texts:
I would like to use the AutoSKU module with the functionality provided by commerce backoffice.  Right now what I have done is installed the module commerce_backoffice with my commerce module which is the functionality from Commerce Kickstart 2.0 from my understanding.

I then installed the AutoSKU module.  However, since the software design has changed there are no longer product types, there are product variation types.  It doesn't seem that AutoSKU works with the new functionality.

Has anyone ported AutoSKU to work with Commerce Kickstart 2.0?


texts: Duplicating "Content: Title" field in Views and modifying them separately in hook_views_pre_render

texts:
I'm creating a View (Views 3.x) which has the "Content: Title" ($node->title) field entered in the fields twice (+ more fields). Let's call them title and title_1.

title is set to "Exclude from display" and is being used as a replacement token on a different views field.

title_1 is set to display as normal.

I'm trying to use hook_views_pre_render to make title all lowercase, and replace the spaces with dashes (basically turning it into a url-friendly format). But when I inspect the results array of the view, I only get a single value for the node title. And modifying that single value changes both title and title_1 instances

I could add a "dummy" field into my view, and dump the converted title in there, and use that dummy field in the rewrite, but that feels so dirty.

Is there a good way to manipulate duplicated node titles without having to resort to such techniques? Maybe I'm using a wrong hook, or maybe I should look into doing it through views field templates?


texts:
I'm trying to do a minor security upgrade to Drupal 8.1.7  When I load update.php it gives me a blank page (no errors).

I upgraded all of the software with the exception of the root .htaccess and robots.txt files.

I'm getting this error:

  PHP Parse error:  syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/energy/public_html/index.php on line 11

The line causing the error is the following one.

use Drupal\Core\DrupalKernel;


texts: Set the site display language based on browser's default language

texts: I have my site in two languages i.e. English and French, I want that whenever a user visits the site, it must be displayed in the browser's default language. How to do it ?


texts: Is there a way to export or import individual display views?

texts:
I am looking for a way to import and export individual Views displays and found this issue on drupal.org, Export/Import individual display views [#1470318].

Has such a functionality available been developed, even through a module?


texts:
I have a Views table that simply shows a list of Entities.

Now at the moment, field 'status' just outputs the raw data 0 or 1.

I want this to be rewritten as 'Pending' or 'Approved' respectively.

I've looked at rewrite behaviour but this seems to be limited and my requirements out of the scope. Everywhere people say that adding PHP through the UI is bad practice.

So how do people normally deal with select boxes stored as integers, when displaying the data using Views?

(Maybe there is a hook to create a function in my module that will always rewrite this field wherever it displays in the Drupal system?)


texts: Display members with same taxonomy using Views

texts:
Users have a "school" term reference field. When user visits his own user page, I want him to see his classmates listed.
For example, imagine that I have 3 students from the same school. When student A id:4 visits user/4, I want all student B and student C listed.
I can do this on term's page, term/10, but I could not figure out how to do it on user's page.
I believe it would have to be configured through contextual filter but I could not find a way yet.
Any help will be greatly appreciated!!


texts: How can I create two blocks at once from the same custom module?

texts:
I have figured out how to create a block from a custom module, by creating a ./src/Plugin/Block folder, then creating a PHP script inside it, with the following code:

<?php
namespace Drupal\MY_MODULE_NAME\Plugin\Block;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;

/**
 * Provides a block with a simple text.
 *
 * @Block(
 *   id = "BLOCK_MACHINE_NAME",
 *   admin_label = @Translation("BLOCK_DISPLAY_TITLE"),
 * )
 */
class MyBlock extends BlockBase {
  /**
   * {@inheritdoc}
   */
  public function build() {

    $html = "MY_BLOCK_CONTENTS_HERE";
    return [
      '#markup' => $this->t( $html ),
    ];
  }

  /**
   * {@inheritdoc}
   */
  protected function blockAccess(AccountInterface $account) {
    return AccessResult::allowedIfHasPermission($account, 'access content');
  }

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
    $config = $this->getConfiguration();
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function blockSubmit($form, FormStateInterface $form_state) {
    $this->configuration['my_block_settings'] = $form_state->getValue('my_block_settings');
  }
}

My question is, if I want my Custom Module to create a second block, how would I do that?

Do I just create a second script under ./src/Plugin/Block using this same format, and change the BLOCK_MACHINE_NAME and BLOCK_DISPLAY_NAME values?

If I change the line:

class MyBlock extends BlockBase { ... }

to

class MySecondBlock extends BlockBase { ... }

... can I keep all the functions under it the same, eg:

class MySecondBlock extends BlockBase {
    public function build() { ... }
    protected function blockAccess() { ... }
    public function blockForm() { ... }
    public function blockSubmit() { ... }
}

Or is it more complicated than that? Do I need to try and build both Blocks from within the same script, and a single set of functions?

Any advice is greatly appreciated, thanks!


texts: Solution for setting additional custom options on nodes (In Drupal 8)

texts:
In Drupal 7 I had a field collection with a few dozen fields that were used to set theme related options on a node. A few examples on what these node fields could do:

Change color of header
Change width of layout
Add a background image to the page
Exclude certain regions from the page (page title, footer etc)

Most of these options actually override theme settings, but some settings are unique to this node options feature.

For these node options to take effect, a lot of custom preprocessing code was written in the theme layer. It also generates a large amount of database tables, since each field has its own tables. It's not an efficient solution.

Does anyone know of a Drupal 8 solution that could be a more efficient way to add settings to the node form? Just asking here before writing something custom to avoid doing duplicate work.


texts: CSS3pie - styles not being picked up in IE. How to reference the path?

texts:
I've downloaded and enabled the css3pie and libraries modules, and downloaded and extracted the PIE Library to sites/all/libraries/PIE
I initially tried adding the css selectors to admin/config/user-interface/css3pie but because that wasn't working I've now added them in my mysite.info:
settings[css3pie][selectors][] = "#block-block-1"
settings[css3pie][selectors][] = "#block-block-8"
In my css file C:\Projects\mysite\sites\all\themes\mysite\css\layout.css
I've put the following:
block-block-1, #block-block-8 {
background: red;
padding: 2em;
-moz-border-radius: 1em;
-webkit-border-radius: 1em;
border-radius: 1em;
behavior: url(C:/Projects/mysite/sites/all/libraries/PIE/PIE.htc);

}
The PIE libraries is here:
C:\Projects\mysite\sites\all\libraries\PIE\PIE.htc
What am I missing and doing wrong?
I have a feeling I've got the path wrong :(
Of course you will need to adjust the path to match where you uploaded PIE.htc in step 2. Note: this path is relative to the HTML file being viewed, not the CSS file it is called from.
How do I reference the path correctly?


texts: Create user profile using content type or add additional fields to the default registration form

texts:
I am good enough to build an entire drupal 7 website but my problem goes below:

I am in the process of building a very simple drupal website for all volunteers in my country.
So every volunteer will have a profile page on the website where volunteers can search for each other, send emails to each others and even send sms to each other in addition to other basic features.

And so to create such website there is two way that i am little bit confuse which one to use: (any suggestion please)

Method 1:
Add any additional field such as city ,district, bio, age, birtbday, phone number, profile picture, blood type, education degree, languages spoken.... directly inside the registration form by going to account settings in configuration page.
And so i will use the "User" entity to pull out the information required for the creation of blocks, views....

Method 2:
Let the volunteer register to the website by using the default registration form where only email address and password are required.
And after completion of registration the user will be redirected to create a node of content type "Volunteer" where all the required fields mentioned above will be available.
Also i will use the node limit module to limit the creation of 1 node per content type per user.
And so i will use the "Volunteer" content type to pull out the information requited for the creation of blocks, views....

Which one is the best to go with ?
Are there any limitation for any of the above method in case i need to expand the website in the futur ?

Please note that i know how to do everything mentioned above, only i need suggestion about what method is the best and why ?

Thank you,


texts: get drupal instant changes for android service

texts:
i m building services for android in which i wanna achieve something like following,

=> when user is added/deleted/updated i need to send push notification on android device saying user has been added or whatever... is there any module or method available in drupal 7 by which i can get the latest changes..

=> wanna achieve same as above for node, comments....

plz help ...


texts: I have a background audio module running on a site I am building. (I know WHY? but the client wanted it).  Anyway I need to know if it is possible to stop the footer from reloading every time they click to another page on the site because the song starts over.


texts: Copy site to another domain - XML SiteMap wrong and Theme Settings not the same

texts:
I copied my productive site from www.mydomain.com to a testsite www.mytestsite.com on the same server. I did it this way:
On productive server:

Set productive site to offline
Disabled Clean URL
Emptied Cache
created backup with the "backup and migrate" tool. All tables are backuped exept all cache-table and watchdog
Copy all files

On target test server:

Create new empty DB
Import SQL script via MySQLAdmin from provider
Copy all files
change settings.php
Login as Admin, set online, enable clean url, empty cache

Now I should have an identical site. But I have two differences (maybe more, which I cannot see):

XML Sitemap: Takes still the old domain name ("www.mydomain.com"). I can delete it and rebuild, no change. Why? This means that somewhere in a file the domain name must be written
The colors of hyperlinks are blue instead green as in the original site. When I go to "Theme settings" and simply press "save", then all is ok. Also here: Why is there wrong information about theme settings? Is this not saved in the DB?

Any help appreciated, thanks


texts: JavaScript not executed before PDF gets generated

texts:
Using Entity Print 8x-2.1, I've got everything working great (thanks to the developoers of that module) except it does not appear to support loading the javascript portion of attached libraries. CSS is loading and rendering as expected from my print_styling library, but the custom.js below is not only not executing, it doesn't even appear to be loaded when I check "sources" under chrome's developer tools from the entity print /debug page.  When I look in the code, it doesn't appear to even try loading js assets.  Am I right that entity print is punting on loading js, or is it possibly just an issue with the base url? If js support is not yet implemented in entity_print, is just a matter of needing someone to develop it, or is there a fundamental limitation that prevents using js with wkhtmlpdf and entity_print? It appears so from my reading of the wkhtmltopdf docs that it could support js, though it needs a config setting for the javascript-delay to make sure execution completes before the pdf is generated.

print_styling:
  css:
    theme:
      css/print2.css: {}
  js:
    js/custom.js: {}


texts: How do I modify the URL to a taxonomy term?

texts:
I have a vocabulary called Industry with four terms. I have edited the terms to keep the URL to be automatically generated. They are following this convention:

industry/term1, industry/term2, etc...

I want the convention to be (without the "industry/"):

term1, term2, etc...

I configured the URL alias patterns like so for Taxonomy Term paths:

Default pattern:
[term:vocabulary]/[term:name]

Pattern for all Industry paths:
[term:name]

However, when I navigate to the URL (i.e. /term1), I get this message:

The requested page "/term1" could not be found.

On top of that, I have a view for a block that generates this vocabulary as a list with the links so users can click on them and go to the taxonomy page. I have the option selected for each term:name that we need to "Link this field to its taxonomy term page". When that block is rendered, it generates a URL like so:

[term:vocabulary]/[term:name]

This is not what I expected. I expected the URL to be [term:name].
I am new to Drupal and still learning things about it. What am I doing wrong?


texts: How can I clone all field values when creating a node translation (entity_translation) programmatically?

texts:
I use entity_translation and have an en node currently without translations. Assume it has fields field_foo and field_bar so currently they are:

$node->field_foo['en'][0]['value'] = 'foo';
$node->field_bar['en'][0]['value'] = 'bar';

I want to programmatically add anfr translation but only translate field_foo so I do:

$node->field_foo['fr'][0]['value'] = 'foo FR';

entity_translation_get_handler('node', $node)->setTranslation(array(
  'translate' => 0,
  'language' => 'fr',
  'source' => 'en'
), $node);
field_attach_update('node', $node);

This works but now if I edit (or devel) the fr node, field_bar is empty. On the frontend it does show "bar" which is the en value, but I've noticed that if I create the translation via the Drupal UI then the field_bar is not empty and contains a copy of the en value.

So, does anyone know of a way that the API will copy all values upon translation creation? Or should I be doing that myself manually via the code?


texts:
I have a challenging task of making an HTML List into a View within Drupal.

The original list is alphabetical EXCEPT for the first 40 entries which are organized essentially in chronological order as well as most popular items on top.

I believe i took care of the most popular items (5 of them) buy utilizing the sticky option within Drupal.

The next 35 items... 30 of them need to be organized by the release date, in this case a "special event #" in the node title is what is used to signify its chronological order.

Example:

 Cool Party - Special Event 1
 Fun Shindig - Special Event 2
 Quiet Gathering - Special Event 3
 Funny Picnic - Special Event 4

I want to know how i can sort the list within Views to get the special event listings in order from 1-30 at the top of my list (just after the sticky top 5)


texts:
I'm asked to build a website which allows visitors to select both a language and a region, together, so it's a set of combined choices (eg. one choice would be "Switzerland French", another would be "Switzerland German", and so on). (Right now it's a combination of two countries and two languages, but it may be extended to other countries or languages in the future.)

This choice then accompany the visitor everywhere on the site, until of course she decides to change it. (The selector will be visible on all pages.)

Based on this choice:

a language is set (the site will be localized),
some contents (based on Views) will be ordered differently, and some will be filtered out,
some contents (blocks or pages) will be made visible or not,
the rest of the contents remain accessible and basically unchanged (but localized).

I'm not completely new to Drupal, but I'm no Drupal guru either. And I have no idea on how to implement that.

Can you advise me on how to approach this?


texts: Adding content of products based on subtype

texts:
I have type (eg. women in clothes) and sub type (eg. jeans in women category). Now i need to add product but the product properties are decided by type(women) and sub type(jeans) and product is itself custom content type. I know in eCommerce website, this is basic situation but my project(drupal 7) is not eCommerce. I need to create this manually.

I have created the category and sub category as custom content type and mapped subcategory to category using entity reference. Now i have created new content type "product feature" and mapped to subcategory using entity reference. Now i need to add those product feature as field to the product when admin add the product. I need help in that.


texts: Language code and country code on the URL

texts:
I've been trying to achieve this:

I have a multilingual site with 8 languages (en, fr, es, de, etc) and I want to make all those language available for all countries.

I want Drupal to understand that:

/en-CO alias of /en
/en-FR alias of /en
/es-US alias of /es
/es-AR alias of /es
/fr-CO alias of /fr
/de-US alias of /de

And so on... (They share the exact same content)

If I add all those custom languages is easy, but I don't want because more than 1600 combinations are posible.

Do you know if there is a way to achieve that programmatically or with a module ?

I'm currently looking into PathProcessor, but no result for now.

Any help would be greatly appreciated.


texts: Easy way to create author account on node creation?

texts: Is there an easy way to add a field that will automatically create an account for the author with the specified email address if that address doesn't exist? I have to enter information for new and old users on occasion and it would help if I could just type the e-mail address each time, instead of creating an account manually first.


texts: print child's of the current term with hierarchy

texts:
just terms. No nodes...

For example

we have this structure:

Fruits

-yellow

--banana

-red

--apple

--strawberry

Vegetables

-green

-red

-orange

But, if user now in term page Fruits -> Yellow, need to print only child's for yellow


texts: Hooks vs Events vs Extension - when to use what?

texts:
Im writing a module. One thing it will do is alter the menu edit form.

I've been looking at core code and examples on the internet and can't really figure out when to extend Drupals core classes, use a hook or an event listener. I get event listeners can access a lot more stuff that the hooks provided by core.

Do Any of you pro drupalerz have preferences/feelings about this?

Any patterns you see?

Have you experienced friction by extending Drupals core Form or Controller classes (my preference) vs using hooks or an event listener?


texts: I have created products and its pricing attributes with drupal 7 commerce pricing attributes. When I select the product's pricing attributes with various values (product custom option) in the select box, then the value not update with cart price, please check this product link http://www.smtresearch.ca/dev_smt/products/wireless-co2-datalogger-0 please give me a solution. Thanks in advance.


texts: Adding a product field to cart summary in views

texts:
I have a product image and product description as fields in the product entity. I want to add them to the cart summary displayed in the checkout, specifically it's the view "Shopping cart summary"

I added a relationship to the view: (Line items referenced by commerce_line_items) Commerce Line item: Product

And I added the two fields to the view.

When I preview it with an order number it works perfectly. the 2 fields are displayed as expected. But on the checkout page, the cart summary is blank...

What am I missing? How can i possibly debug this situation?


texts: redirecting to url that will never complate

texts:
i used this code to redirect page to another

$path=$_SERVER['QUERY_STRING'];
$new_path= 'http://localhost/mysite/print/194?0=' . $path;
drupal_goto($new_path);

but when requesting that page this error show up:

and the url in the address bar is:
http://localhost/mysite/print/194?0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=0=f1=All&f2[value][year]=&f2[value][month]=
but when i print the $new_path using drupal_set_message the url looks like correct one
Can you help me to solved it? thanks.


texts:
I've installed Barcode module and Commerce Barcode Scanner module. The first is for generete barcodes to products. The second is supposed to read barcode labels. I couldn't test Commerce Barcode Scanner yet because I don't have a Barcode Scanner by now.

But I've been searched how Commerce Barcode Scanner works and I don't find anything.

Do I have to position cursor in a specific field from front-end or back-end of my site or is really only necessary to stay in some page of my site to Commerce Barcode scanner redirect to the Product Display (as that is the behavior setted up by default in rules)?


texts: New product variation form for a new user

texts:
I want to display a new product variation form for an existing product to a new user where that user can create a new product variation for an existing product and the user will not be able to see the variations created by other users for that product. I want that "Add Product Variation" button for a new user who has not created the product.

I try to find a way to get this done with inline entity form module functionality as the product variation field is generated by inline entity form module.

Please suggest.


texts: Are old nodes automatically archived over time?

texts:
I just went to a site that I haven't touch in a while and I see this on the homepage:
The requested page "/" could not be found.

I went into Administration » Configuration » System
and saw that the Default front page was set as: /node/1
When I tried to pull up that node, I got a page not found error:
The requested page "/node/1" could not be found

I suppose it's possible that someone else who has access to the site deleted this node accidentally, but I'm just wondering if it may have been auto-archived or something instead.

Are there hackers that gain access to sites and then just delete their front page? Or should I be pointing the finger at the other people who have access to the site?


texts: get least row weight item or top row of draggable views

texts:
I have a requirement in my project adding draggable feature using custom module and i have impemented it but the problem is getting least row weight item after user has reordered the item ie top item of the view.
Please provide me the solution for this.
Any help will be appreciated!
Thanks


texts: Write a boolean function in template that determines if the logged user is either the node author or admin

texts:
How do I write a function to determine if the user is either the node author or admin?

if ( logged user is author || admin ) {
  // …
}

It is for the node template.


texts: Dynamically change widget type in node edit form

texts:
I have a content type with a geofield. I'm using an Openlayers Map as the input Widget. The map allows the user to place a marker and it populates the geofield with the lon/lat coordinate. In some cases, however, it would be preferred to input the lon/lat manually as opposed to using the map.

How would you provide an option in the node edit form to dynamically switch the display widget for the geofield from the Openlayers map to lon/lat, or from lon/lat to a map?


texts: im creating community event site where i have city and events in that city. i would like to give option for user to select which cities he would like to see the events for. whats the best way to do this? i have created content type of city and events, and using entity referrence to tie events to the city, now im kinda stuck on how do i give a user ability to chose which city/cities he wants to view events for. thanks in advance


texts: I could not find good quality of tutorials on Internet for learning Relation module . Could anyone suggest some links for good documentation/tutorial for relation module ? Thank you .


texts: How To Embed a video in a body field like facebook does

texts:
Do you know please?

Instead of having to click on a button
to embed a video.

Is there a module that hides the embed code in the body field

http://www.youtube.com/watch?v=-cUWFLBZU5I&list=PL15BE2E8313A4E809&feature=share

So when you add the youtube link

<iframe width="560" height="315" src="VIDEO LINK" frameborder="0" allowfullscreen></iframe>

It fill in the src link

Many Thanks for your help


texts: How can I create an alias to point to an uploaded file?

texts:
Users uploading a file within content create a name like
my_site.com/sites/default/files/import/CrazyLongNamefile.pdf
They would like to alias it for referencing in other media (print) like
my_site.com/GoodName.pdf
URL alias works fine for other things, but not files (that I can determine)
The File (Field) module looks like it would probably do what I want, but it hasn't been touched for Drupal 8 in a while.
Is there a way (module, custom code) to provide an alternative path to a file that I can make available to content creators?


texts:
I need to have two levels of form error setting, for example 100% error and 50% error. 50% wrong is still an error but not at the same level of the 100% one.
I'm doing this for an educational Drupal 7 website.
My research got me to drupal_set_message(). I'm perfectly fine to use form_set_error() which in turn calls drupal_set_message($message, 'error');. However, I need to visually show a difference, in the error message, for example a different icon.
I tried using drupal_set_message($message, 'warning');, but then the form gets submitted, and it shouldn't be the case because it is still an error.
I also tried to call drupal_set_message($message, 'warning');
and drupal_set_message($message, 'error'); but this shows two messages.
How can I trigger an error in the form and have two different images for the error message depending on how wrong the answer is?


texts: How to create User Account Registration form with Webform?

texts:
I am using Drupal 7. I have Webform with 6 fields:

Your name
User name
password
Email
phone number
Website

If we submit it will store in database, but here I need username & password should store in "User Account Registration" form also.

We can add fields from Configuration -> People -> Account settings for other fields, but it doesn't work in this situation. I need to store the User name & password values to "User Account Form" and then to login with that username and password.


texts: Dump-dir specified in aliases.drushrc.php; not seen by drush?

texts:
The remote and local directories I've specified in my aliases files exist and are owned by my user (drush is run under my user).

$aliases['dev'] = array(
 'parent' => '@parent',
 'site' => 'mysite',
 'env' => 'dev',
 //[user, host, ssh options, etc.]
 'path-aliases' => array(
    '%files' => 'sites/default/disk',
    '%dump-dir' => '/home/joe/drush-backups/mysite_dev',
    ),
);

$aliases['local'] = array(
 'parent' => '@parent',
 'site' => 'mysite',
 //[root]
 'path-aliases' => array(
     '%files' => 'sites/default/files',
     '%dump-dir' => '/Users/joe/Sites/mysite/tmp',
    ),
);

Yet I get a warning on sql-sync:

  drush -v sql-sync @dev @local Loaded alias @local from file
  /Users/joe/.drush/soa.aliases.drushrc.php
  [notice] Loaded alias @dev from file
  /Users/joe/.drush/soa.aliases.drushrc.php
  [notice] Local sql cache file does not exist.
  [notice] ssh -i "/Users/joe/.ssh/id_rsa" -p "6421"
  joe@arch-web-p01.its.utexas.edu 'drush  --backend=2
  --root=/var/www/html/dev  sql-query '\''SHOW TABLES'\'' 2>&1' 2>&1                                                                                [notice] WARNING:  Using temporary files to store and transfer
  sql-dump.  It is recommended that you specify --source-dump and
  --target-dump options on the command line, or set '%dump' or '%dump-dir' in the path-aliases section of your site alias records.
  This facilitates fast file transfer via rsync.

  You will destroy data in drupal_test and replace with data from
  server/mysite_dev.

  You might want to make a backup first, using the sql-dump command.

And if I continue, I get an error that indicates drush was trying to write to a different directory.

  Do you really want to continue? (y/n): y Calling system(ssh -i
  "/Users/joe/.ssh/id_rsa" -p "6421" joe@server 'mysqldump --result-file
  /private/var/folders/mr/c99kf6c11_bdsr62m242c59c0000gq/T/mysite_dev1WyWuk
  --no-autocommit --single-transaction --opt -Q  mysite_dev --host=myhost --user=mysite_dev --password='\''[pw]'\'' --skip-extended-insert --order-by-primary  2>&1'); mysqldump: Can't create/write to file
  '/private/var/folders/mr/c99kf6c11_bdsr62m242c59c0000gq/T/mysite_dev1WyWuk'
  (Errcode: 2) Database dump failed
  [error] Command dispatch complete
  [notice]

I've got all my drush commands working between remote directories run on the site. I am able to rsync between local and remote directories since specifying files path aliases in aliases.drushrc.php.

What am I missing?  I have the latest version of drush in both places, so I don't think I need the patch pointed to at How do I set the drush tmp directory?...


texts: How to change a node field when the output of a View changes?

texts:
I have a View Top 3 that displays the 3 nodes with the highest average voting scores (I use Fivestar via comments on the nodes for voting). Every node has a field Highest ranking, that - as the name suggests - should store the highest ranking ever obtained in Top 3.

Now, the View Top 3 also filters nodes that were created less than 5 days ago. I'm wondering how I can change the Highest ranking fields of the nodes in the top 3 when the top 3 changes. The above explanation should make clear that this can happen when

a new comment with a vote has been created;
an existing comment with a vote has been changed;
a node is older than 5 days and is therefore banned from the top 3.

Which hooks can I use for this?


texts:
I have an interesting question regarding Views, Taxonomy and Contextual Filters AND Views->Filters

I have a content type Basic Page with additional field -> industry category (term reference, taxonomy).

There are multiple Basic Pages on the website but only 5 with industry category field filled in.

I have second content type Industry Page (Page Title, Body with additional field -> *industry categor*y (term reference, taxonomy), pointing towards the same vocabulary.

I have a view should display nodes of type industry page depending on the page you are in (The “basic page” with the additional field-> industry category.)

I need to do something with contextual filter to display all nodes of type “industry page” where the basic page->field industry category = “industry page”->industry category.

Can you help me with it, since I am a bit stuck.

Regards

Oleg


texts: How to format multi value field as a grid?

texts: I created content type "photo gallery" that have multi-value field of images - for user convenience. I would like to create a view, that would show all that kind of galleries with their titles on one page, formatted as grid. How is this possible?


texts: I am using the form API to create forms. How can I validate the email address without needing any separate module? I am just looking for out of the box functionality.


texts: Integration with Single Page Application (React)

texts:
I have a specific scenario to integrate a single page application (react based) with Drupal (I use version 7) in order to achieve the following:

Utilize the CMS capabilities of drupal and provide static content some of it will be public some will be private to authorized users only.

Create a totally separate single page application with specific functionality, with react framework and will communicate with a different backend system. I want this app to expose it through drupal, as a page by selecting it from the menu. Only authorized users will be able to enter this section of the drupal app.

Being able to pass user details to my single page application, in order to use them to the communication with the backend (for authorization and other operations)

I'm fairly new to Drupal, as far as I understand I will need to develop a module and/or a theme to do that? Additionally, drupal and my application should have a common authentication mechanism,I use OAuth2 server which is provided as a separate instance from drupal and my single page application.
From my research I haven't found any concrete example/documentation on how to achieve this. What I have managed to achieve so far is to be able to utilize my OAuth2 server with the help of OAuth2 Authentication module.
My second part is now missing to integrate my single page application and pass some user details information to it.


texts:
I'm using Media module to insert inline images in the nodes body through the wysiwyg.

I'm trying to make an Views slideshow to list all these images and I've been banging my head at Views interface for the past hours, trying to find the related field which should be included but I can't find anything.

Is this simply not possible? If that's the case is there any Views plugin/add-on that can do the job?

Regards


texts: Apple-like button style carousels in Drupal 7?

texts:
I would like to build a carousel which supports Apple-like scrolling, like at http://www.apple.com/displays/
So you would have a carousel with small "buttons" at the bottom which allow for easy navigation. The jcarousel module seems the preferred module for carousels, however it does not seem to support this type of carousel? I can not find a way to get links to all images/nodes/... to realise this via a different jcarousel template.
I did not find alternatives to carousel implementations in Drupal 7, but I might be mistaken of course :-)


texts: Change the size of the form element for content title

texts: I could have sworn that when we created our content type, we could select the size of the textfield for the title. I am unable to find that now as I'm in "Manage Fields" and the edit link that's available for other fields is not there for the title field. It says only in field type "Node module element". I even tried looking through our database to see if there was a place where this was set and I couldn't find anything. Am I missing something simple?


texts: Disable caching for custom block for anonymous users

texts:
I have created a custom Block that extends BlockBase. I don't want the content to be cached for anonymous users (also not for authenticated users). To be more precise, caching would be fine but depending on some url query argument. In my case the url contains a parameter 'mode' (?mode=1 or ?mode=2 and so on). Depending on the parameter the content of the block varies.

I added the following function:

 public function getCacheContexts() {
    return Cache::mergeContexts(parent::getCacheContexts(), array('url.query_args:mode'));
  }

Still the block content seems to be cached. Is it neccessary to disable the internal page cache module? Actually I don't want to globally disable caching, I just want my block to be cached correctly depending on the url parameter mode.