texts:
I have a Drupal 8 Multisite setup with the following Folder structure:

themes

custom_theme

main_custom_theme

sites

site1

themes

subtheme1

site 2

So I want both sites to use main_custom_theme, but site1 needs to override one template (page.html.twig) with subtheme1. subtheme1 folder contains a subtheme1.info.yml as follows:

name: subtheme1
description: "Custom sub-theme"
core: 8.x
type: theme
base theme: main_custom_theme

I rebuilt all caches (Backend and drush cr, but drush cr might not clean caches of subsites?) but cannot select the new subtheme in Backend of site1.
What am I missing?

This is the Twig Debug output after using leymannx answer, subsites path is "leistungen"

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'page' -->
<!-- FILE NAME SUGGESTIONS:
   * page--leistungen.html.twig
   * page--node--560.html.twig
   * page--node--%.html.twig
   * page--node--article.html.twig
   * page--node.html.twig
   x page.html.twig
-->
<!-- BEGIN OUTPUT from 'themes/custom/my_custom_theme/templates/main/page.html.twig' -->

I have a question that builds on this one... I published it appearently with a different user, without wanting to. Still new to not only reading stackexchange :)

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

How can I do that?

Thanx in advance!!


texts: Template page--node--.tpl.php not working

texts:
I've created a page node for an about page. I've checked the node id of the node which is 11.
I've created a file named page--node--11.tpl.php in my theme directory containing some test html but it's not overriding the standard page.tpl.php file.
I've also tried using the following file names:
page-node-11.tpl.php
page-node--11.tpl.php

I've cleared the cache but still no luck.

What am I missing?


texts: Change default text on exposed filter select option

texts:
I have a layout builder inline block that I use to pass variables to exposed filters in a twig tweak view embed.
...
{{ drupal_view('events_group_content', 'filtered_events', event_type, center_id, samhsa) }}

I need to change the text on the default selection from "- None -" to "- All-" but can't get a hold of the fields in hook_form_alter because Layout Builder adds some random numbers to the field ID. Is there a way around this?

I also cannot figure out how to pass how many items to display via a custom field (not shown). I can't pass that to a contextual filter and therefore can't pass it as an argument.
Any help would be greatly appreciated.


texts:
I have an view that uses the Unformatted list format and Show: fields.

I've added the fields to it and the view has _Content type: my_content_type_ filter.

I want to write a template file for the fields in that view, with the following code.

{% if field_name == 'field_photo' %}
    ...
{% elseif field_name == 'field_something_else' %}
<div class="something">
    {% for item in items %}
        {{ item.content }}
    {% endfor %}
</div><!-- .something -->

I don't know which name to use for the template file.

I've tried the following names, but they don't work. MY_CUSTOM_TYPE stays for the content type I have set in filter for that view.

field--MY_CUSTOM_TYPE.html.twig
field--node--MY_CUSTOM_TYPE.html.twig

What is the correct filename for the template file I am trying to use?


texts: Why do both Text- and Data comparison seem to not work in my Rules conditions?

texts:
I’m using Drupal 7.56, the Rules module 7.x-2.11, and CiviCRM 4.6.31.

I've been using the Text comparison and Data comparison conditions.

Using the Text comparison condition, the condition is always met, so the action is always executed, despite the value of the data.

Why does this condition always evaluate to TRUE, for all the possible values, even when the text of the data is different to the matching text?

This is the log entry.

  The condition text_matches evaluated to TRUE.

This is the export of the rule.

{ "rules_create_a_drupal_account_for_a_civicrm_contact" : {
    "LABEL" : "Create a Drupal account for a CiviCRM contact",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "civicrm", "rules", "devel" ],
    "ON" : { "civicrm_membership_create" : [] },
    "IF" : [
      { "NOT civicrm_entity_user_exists" : { "civicrm_contact" : [ "civicrm-membership:contact-id-contact" ] } },
      { "AND" : [
          { "NOT data_is_empty" : { "data" : [ "civicrm-membership:contact-id-contact:contact-sub-type" ] } },
          { "AND" : [
              { "text_matches" : {
                  "text" : [ "civicrm-membership:contact-id-contact:contact-sub-type" ],
                  "match" : "Parent"
                }
              }
            ]
          }
        ]
      }
    ],
    "DO" : [
      { "devel_debug" : { "value" : [ "civicrm-membership:contact-id-contact:contact-sub-type" ] } },
      { "civicrm_entity_action_create_user" : {
          "USING" : {
            "civicrm_contact" : [ "civicrm-membership:contact-id-contact" ],
            "is_active" : "1",
            "notify" : "0",
            "signin" : "0",
            "username_format" : "email"
          },
          "PROVIDE" : { "civicrm_user" : { "civicrm_user" : "Created Drupal User" } }
        }
      },
      { "user_add_role" : { "account" : [ "civicrm-user" ], "roles" : { "value" : { "5" : "5" } } } }
    ]
  }
}

Using the Data comparison condition, the condition is never met and the action is never executed, despite the data to compare.

Why does this condition always evaluate to FALSE, for all the data, even when it is the same to the value to compare?

This is the log entry.

  The condition data_is evaluated to FALSE.

This is the export of the rule.

{ "rules_create_a_drupal_user_account2" : {
    "LABEL" : "Create a Drupal User Account2",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "civicrm", "rules" ],
    "ON" : { "civicrm_membership_create" : [] },
    "IF" : [
      { "NOT civicrm_entity_user_exists" : { "civicrm_contact" : [ "civicrm-membership:contact-id-contact" ] } },
      { "AND" : [] },
      { "data_is" : {
          "data" : [ "civicrm-membership:contact-id-contact:contact-sub-type" ],
          "value" : "Parent"
        }
      }
    ],
    "DO" : [
      { "civicrm_entity_action_create_user" : {
          "USING" : {
            "civicrm_contact" : [ "civicrm-membership:contact-id-contact" ],
            "is_active" : "1",
            "notify" : "0",
            "signin" : "0",
            "username_format" : "email"
          },
          "PROVIDE" : { "civicrm_user" : { "civicrm_user" : "Created Drupal User" } }
        }
      }
    ]
  }
}

Any clue about what might be happening?


texts: Behat, Selenium and Chromedriver CI errors

texts:
I am working on a Behat setup with Selenium and Chromedriver for running Behat tests for a Drupal 7 setup.

I am getting:

  exception ‘WebDriver\Exception\UnknownError’ with message 'Timed out
  waiting for driver server to start.

Above this error, i am also seeing:

  21:46:42.198 INFO [ActiveSessionFactory.apply] - Capabilities are:
  Capabilities {browser: firefox, browserName: chrome,
  ignoreZoomSetting: false, name: Behat feature suite, tags:
  [railsonfire_5e8a4d2e-8ba4-4…, PHP 5.6.34]} 21:46:42.199 INFO
  [ActiveSessionFactory.lambda$apply$11] - Matched factory
  org.openqa.selenium.remote.server.ServicedSession$Factory (provider:
  org.openqa.selenium.chrome.ChromeDriverService)
  /home/rof/src/bitbucket.org/myorganisation/myproject/chromedriver: 1:
  /home/rof/src/bitbucket.org/myorganisation/myproject/chromedriver:
  Syntax error: “(” unexpected 21:47:02.201 ERROR
  [OsProcess.checkForError] - org.apache.commons.exec.ExecuteException:
  Process exited with an error: 2 (Exit value: 2)

I am running:

java -Dwebdriver.chrome.driver=./chromedriver -jar selenium-server-standalone-3.10.0.jar 2>&1 &

to start selenium with chromedriver in my pipeline.

I am downloading and unzipping chromedriver like so:

  –2018-03-19 20:39:43--
  http://chromedriver.storage.googleapis.com/2.35/chromedriver_mac64.zip
  Resolving chromedriver.storage.googleapis.com
  (chromedriver.storage.googleapis.com)… 172.217.7.176,
  2607:f8b0:4004:80c::2010 Connecting to
  chromedriver.storage.googleapis.com
  (chromedriver.storage.googleapis.com)|172.217.7.176|:80… connected.
  HTTP request sent, awaiting response… 200 OK Length: 5508030 (5.3M)
  [application/zip] Saving to: chromedriver_mac64.zip

  100%[======================================>] 5,508,030 --.-K/s in
  0.04s

  2018-03-19 20:39:44 (120 MB/s) - chromedriver_mac64.zip saved
  [5508030/5508030]

  Archive: chromedriver_mac64.zip inflating:
  /home/rof/src/bitbucket.org/myorganisation/myproject/chromedriver

My behat.yml file used for CI

default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
     filters:
      tags: "~@wip"
  extensions:
    Behat\MinkExtension:
      goutte: ~
      javascript_session: 'selenium2'
      browser_name: 'chrome'
      selenium2:
      wd_host: 'http://127.0.0.1:4444/wd/hub'
    # Should be removed once
    https://github.com/Behat/MinkExtension/pull/311 gets into a release.
      capabilities:
        marionette: null
    # Remove STOP
    base_url: 'http://127.0.0.1:8080'
  Drupal\DrupalExtension:
    blackbox: ~
    api_driver: 'drupal'
    drupal:
      drupal_root: '${project.basedir}'
    text:
      username_field: 'Gebruikersnaam'
      password_field: 'Wachtwoord'
      log_in: 'Log in'
      log_out: 'Uitloggen'

Please ignore the ${project.basedir}, this gets replaced with the phing build target.

Ps: Also note that locally all behat tests run perfectly fine.

All suggestions welcome!


texts:
Have content type Article.
Content type Article has a field, called "Need Further Review", of boolean type.
This field is not required, default value FALSE.
The articles has value TRUE, FALSE, NULL for this field.
TRUE: select true
FALSE: select false
NULL: the previous articles still have no value for this field.
Have a view to list articles.
It uses SOLR search.
A filter criteria is this field "Need Further Review", and is exposed.
It has options: Any, TRUE, FALSE.
When users select TRUE, it will list articles with TRUE value of this field.
When users select FALSE, it usually lists articles with FALSE value of this field.
Now I want to list articles with FALSE and NULL value of this field when selecting FALSE.
How to use SOLR search hook_search_api_solr_query_alter to do it?


texts:
I am still new to all the Symfony semantics. What would be the easiest way to change node canonical urls to be /article/[node-title] instead of /node/[node-id]?
Following this documentation I tried the code (which I expected to produce at least a url structure like /article/[node-id])

<?php
/**
 * @file
 * Contains \Drupal\example\Routing\ExampleRoutes.
 */

namespace Drupal\example\Routing;
use Symfony\Component\Routing\Route;
/**
 * Defines dynamic routes.
 */
class ExampleRoutes {

  /**
   * {@inheritdoc}
   */
  public function routes() {
    $routes = array();
    // Declares a single route under the name 'example.content'.
    // Returns an array of Route objects.
    $routes['entity.node.canonical'] = new Route(
      // Path to attach this route to:
      '/article/{node}',
      // Route defaults:
      array(
        '_controller' => '\Drupal\node\Controller\NodeViewController::view',
        '_title' => 'Hello'
      ),
      // Route requirements:
      array(
        '_permission'  => 'access content',
      )
    );
    return $routes;
  }

}
?>

But unfortunately it is not changing anything…


texts: How to properly cache AJAX request responses with the controller from my custom module?

texts:
I've got an drupal 8 project with an custom module. There I have an controller which returns specific data we need there. In my js file, I have 7 AJAX requests which are called when someone visits the page. The code for the AJAX requests is the same, just the url is different:

$.ajax({
  url: someUrl,
  dataType: 'json',
  type: 'get',
  data: {
    lang: docLang
  }
});

The urls are also some custom ones which are created in our routing.yml file.
When I visit the page, all my AJAX requests are done correctly and the result is as expected. But for some reason, it doesn't cache the response so it always takes a while to load the page.
In my controller function I collect some data and put it into an array, for example:

$output = [];
foreach ($nodes as $node) {
  $entry = [];
  // do some stuff, collect the data in $entry
  $output['entries'][] = $entry;
}

After it is done with collecting data and fill them into $output['entries'], I create a CacheableJsonResponse and return it to my js:

$response = new CacheableJsonResponse($output);
return $response;

Like this, it doesn't cache the response, so I thought that I probably need to pass some cache data to it. I've changed the code to the following:

$data['#cache'] = array(
  'max-age' => 2592000,
  'contexts' => array(
    'route',
    'user.roles'
  ),
  'tags' => array(
    'node_type:some_type',
    'taxonomy_term_list',
  ),
);

$response = new CacheableJsonResponse($output);
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));

return $response;

It returns everything correctly, but it still doesn't cache the response.
I already took a look at the response headers and the following things are written there:

Cache-Control: must-revalidate, no-cache, private
Connection: Keep-Alive
Content-language: de
Content-Type: application/json
Date: Thu, 07 Jun 2018 06:34:25 GMT
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Keep-Alive: timeout=5, max=99
Server: Apache/2.2.32 (Unix) mod_wsgi/3.5 Python/2.7.13 PHP/7.1.8 mod_ssl/2.2.32 OpenSSL/1.0.2j DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.24.0
Transfer-Encoding: chunked
Vary:
X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Generator: Drupal 8 (https://www.drupal.org)
X-Powered-By: PHP/7.1.8
X-UA-Compatible: IE=edge

For example the response headers from a cached file:

Accept-Ranges: bytes
Cache-Control: max-age=1209600
Content-Length: 9026
Content-Type: image/jpeg
Date: Thu, 07 Jun 2018 09:14:11 GMT
ETag: "2bc823-2342-553b62ce65880"
Expires: Thu, 21 Jun 2018 09:14:11 GMT
Last-Modified: Fri, 07 Jul 2017 08:39:46 GMT
Server: Apache/2.2.32 (Unix) mod_wsgi/3.5 Python/2.7.13 PHP/7.1.8 mod_ssl/2.2.32 OpenSSL/1.0.2j DAV/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 Perl/v5.24.0
X-Content-Type-Options: nosniff

I don't think that it is correct with the Cache-Control and Expires in the response headers and I guess this is causing the problem.
I also tried to change these headers, I did the following tries:

1. $response->headers->set('Cache-Control', 'public');
// This just puts the Cache-Control headers out of the response, which still doesn't cache it.
2. $response->setExpires($tomorrow);
// Here I pass the DateTime for tomorrow, but it just ends in an error for my page. Also the functions setPublic() and stuff do not work for it.
3. $reponse->headers->addCacheControlDirective('public');
   $response->headers->removeCacheControllDirective('private');
// Also calling this stuff directly wont change anything.

None of these things seems to work.

My Questions:
How can I cache the responses from my AJAX requests the drupal way? Is it even possible, to cache these responses via drupal? Would you recommend another way to cache it?


texts:
My Drupal website has a sub-domain. there is a  theme that is in the sub-domain folder. the settings.php in the sub-domain folder is same as the one that is in the /default folder so they both display the same web page. the problem is after a few hours this theme is automatically disabled and I have to enable it again.

why such thing happens?


texts: How do I modify a node's body (or any field) on display as `hook_node_view`?

texts:
So I am trying to upgrade my modules from Drupal 7 to 8 and some things have been pretty straightforward so far, but I'm stuck at a particular function that I just can't figure out how to implement on Drupal 8. Figuring out exactly how to make these changes on 7 was difficult enough, involving a lot of playing around with print_r. Maybe my approach last time was not the right way and therefore I'm already on the wrong track for Drupal 8. Anyway, I was trying to do a find and replace on node body text to change a pattern into a node URL. The code is below:

 function textreplace_node_view($node, $view_mode, $langcode){
   if($node->type == "article"){
     if(empty($node->content['body'])) return $node;
     $text = $node->content['body'][0]['#markup'];
     $offset = 0;
     $m = array();
     while ( preg_match('/\{\{nodeurl-([0-9]+)\}\}/', $text, $m, PREG_OFFSET_CAPTURE, $offset) ) {
       $offset = $m[0][1] + strlen($m[0][0]);
       $nod = (explode("-", str_replace("{{","",str_replace("}}","",$m[0][0]))));
       $nod = $nod[1];
       $thenode = node_load($nod);
       $text = str_replace($m[0][0], l($thenode->title, 'node/' . $nod), $text);
     }
     $node->content['body'][0]['#markup'] = $text;
     return $node;
   }
 }

I tried looking at how it was implemented in the Book module and the parameters started giving me errors when I changed them to what I saw in the Book module:

function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {

I was getting an error along the lines of $node must be of type EntityInterface...

Any help?


texts:
I am using Drupal 7 with wysiwyg (7.x-2.0)module and CK editor 3.5.3.6655. I added an image in  a block with link and the CK editor code is

     [[{"type":"media","view_mode":"media_original","fid":"751","attributes":{"alt":"contact","class":"media-image","typeof":"foaf:Image"}}]]

But Drupal is adding some divs around the img tag and the resulting code is

Then I got the W3C error document type does not allow element "div" here; missing one of "button", "map", "object", "ins", "del", "noscript" start-tag as div is not allowed inside p and a. How can I solve this?

I added div instead of p but no use.


texts:
I'm looking for the simplest solution to allow a custom CSS page to load per role. I have to the CSS pages done, but just need to load them and ensure they are only loaded based on user role.

I'm guessing it should be about three lines of PHP to go at the bottom of the template.php, but not sure what the code should be. Any advice?

Thanks.

With relation to the answer and my comment below, tried the beneath code unsuccessfully using the bamboo theme

function bamboo_preprocess_page(&$variables) {
  global $user;

  if (in_array('testtest', $user->roles)) {
    drupal_add_css(drupal_get_path('theme', 'bamboo') . '/roleedits.css');
  }
}

If my code wrong or is it a problem with the theme?

(for the record I did create a role called testtest.)

The error I get is:

Fatal error: Cannot redeclare bamboo_preprocess_page() (previously declared in E:\Test\sites\all\themes\bamboo\template.php:231) in E:\Test\sites\all\themes\bamboo\template.php on line 385

NOTE: Both the solution below work. I just accepted the one I used. However both have been tested and work fine, just the second solution offered me more flexibility to call roles again in future.


texts:
I am using the Droupon theme of Drupal. I am facing problem while changing the sidebar from right to left. Using CSS I can change it. But I want to know if I can change the position of the sidebar from admin panel without any modification in the CSS.

Thanks
Subha.


texts: Replace node add/edit form with a custom form

texts:
I have this custom form I made in my module which is responsible for adding/editing a specific node type. I was not able to alter the built-in add/edit form to meet my requirements so I decided to make my own forms using the form API.

The forms are doing good but I need drupal to use my custom forms whenever a user tries to add/edit a node from that specific node type instead of the original drupal's standard forms.

It should be a matter of routing/path. I already tried menu hook but it did not work. So how can I make drupal to replace the content add/edit form for that specific node type with the one I want?


texts:
Drupal 7.21
For some reason I can't edit/add permissions for certain content to ANY roles anymore.
I first noticed this with one role and that had certain permissions missing.
Added the missing permissions and tried to save, but it always reverted back to before save.
I deleted the entire role and  it doesn't take any permission.
Other roles the same issue, can't add any additional permissions for create content even for r administrator (User1)


texts: Use ajax to render a view - pagination not working

texts:
I'm trying to render a view using Ajax, but I can't get the ajax pagination to work. I've found the following code which works, apart from the pagination:

            $.ajax({
                url: '/views/ajax',
                type: 'post',
                data: {
                    view_name: 'stores',
                    view_display_id: 'default',
                    view_args: {},
                },
                dataType: 'json',
                success: function (response) {
                    if (response[1] !== undefined) {
                        $('.store-locator-view-wrap').html(response[1].data);
                        Drupal.attachBehaviors(); // Thought this would do it, but nope
                    }
                }
            });

The links go to /views/ajax?page=1 with the following json:

[{"command":"settings","settings":{"basePath":"\/","pathPrefix":"","ajaxPageState":{"theme":"rhm_starter","theme_token":"dRce3KwWhWs1ZpnNe6KVUu31mLX8pdVoZ5XixJo8SVI"}},"merge":true}]
::1


texts: using ajaxComplete with drupal quicktabs

texts:
I am trying to use .ajaxComplete() on my quicktabs but i cant seem to get it to hit. Would anyone have any ideas?

jQuery('#quicktabs-tab-find_a_doctor-1').click(function(){
  console.log('CLICKED');
  jQuery('#quicktabs-tab-find_a_doctor-1').css({
      "float":"left",
      "padding-right":"5px"
    });
  jQuery('#quicktabs-tab-find_a_doctor-1').parent().append('

');

  //jQuery('#loading-icon').ajaxComplete(function(){
     // jQuery(this).hide();
    //});

  Drupal.behaviors.LoadingIcon = {
    attach: function() {
      jQuery('#loading-icon').ajaxComplete(function() {
        jQuery(this).hide();
      });
    }
  }
});

I have tried both ideas, but i still cant get it to hit. Any help would be much appreciated!


texts: Is there a way to add taxonomy terms to a node based on the values of an Entity Reference field?

texts:
Title says it all.  I have a content type that is using entity reference for taxonomy terms + entity connect to allow users to create new references on the fly.  I am wondering how I can read the term values (id's?) from the entity reference field, and programmatically add the corresponding terms to the node.  The terms would not be displayed, but rather linked to via the result of the entity reference field.

I'm thinking it would be possible to hook into node_save and read the values of the entity reference field, then programatically add the corresponding tags to the node.  But that said, I am unsure where to start.


texts: Programatically save node fields if fields is autocomplete?

texts:
I have created a content type with 3 fields and my one field is node_refrence in this filed I am filling title of other node using node_refrence.

I am using this code.

> $node = new stdClass();
 $node->type = 'application';
> node_object_prepare($node);
> $node->title = "test title";
 $node->language = LANGUAGE_NONE;
> $node->field_application_school[$node->language][]['target_id']  =
> 1373;
> $node->field_application_school[$node->language][]['target_type'] =
"node";
 node_save($node);

I need to  fill the entry  for $node->field_application_school[$node->language][]['target_id'], its not working.


texts:
I'm wondering what the best solution is to mark a node as read per user.

The below scenario is what I am trying to achieve:

Admin creates a node which requires to be read and confirmed and flags user a+b.
User a+b receives an email staying there is a new content that requires them to read it.
User a goes to the page and reads the content and clicks "I confirm I have read this" which cannot be reversed by user a.
When admin views the page they can see that user a has confirmed read but user b hasn't.

My first initial thoughts was to use a combination of Flag, Views and Rules.

Any suggestions?


texts: Search API Solr fulltext search improve results

texts:
I use Search_api_solr module with drupal. I have a node with "Sony W800a TV" when I search w800 there is no result but when I search w800a I see this node in results.

How Can I Fix this?

Thanks


texts:
i jquery applied to a exposed filter to force the look of a drop down with checkboxes which works fine until the ajax reloads the content and cause the slideToggle to open and close immediately. i switched it to just css height and the box wont open after ajax reload. Anyone have any ideas or options that might work after ajax reload.
 just css option

boxes1.css({"display" : "none", "background": "#f2f2f2", "border" : "1px solid #ccc", "padding":"5px", "margin-top" : "25px","position":"absolute","overflow" : "hidden"});
    title.live("click",function(){
        if(boxes1.is(":hidden")){
            boxes1.css({"height" : "300", "display" : "block"});
        }
        else {
            boxes1.css({"display" : "none"});
        }
    });

slideToggle option

boxes1.css({"display" : "none", "background": "#f2f2f2", "border" : "1px solid #ccc", "padding":"5px", "margin-top" : "25px","position":"absolute","overflow" : "hidden"});
    title.live("click",function(){
            boxes1.slideToggle('slow');
    });


texts:
Is there any way to keep the redirect logic of the homepage uncached but to keep the page itself cached?

I have a "location by ip" redirect on the "/". This logic then redirects to the correct homepage. "/de", "/en", "/es" and so on.

public function onRespond(FilterResponseEvent $event) {

    if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
        return;
    }

    $response = $event->getResponse();

    $is_front = \Drupal::service('path.matcher')->isFrontPage();

    //REAL DOMAIN HOMEPAGE <front> *.com - before redirect
    if($is_front && $response->getStatusCode() == "301" ){

        // IP LOCATION
        $geo_locator = \Drupal::service('geoip.geolocation');
        $ip_address = \Drupal::request()->getClientIp();
        $user_address = strtolower($geo_locator->geolocate($ip_address));

        if($user_address == "de"){
            $response_new = new RedirectResponse('/de');
            $response_new->send();

        }
...

Page Caching:

function ca_cache_preprocess_page(&$variables){
   $is_front = \Drupal::service('path.matcher')->isFrontPage();
   $current_uri = \Drupal::request()->getRequestUri();
   if($is_front){
    $variables['page']['#cache']['max-age'] = 0;
   }
}

This to function correctly the logic can't be cached of course. But is the only solution to make the homepage not being cached at all?

This seems wrong to me.


texts: Show related nodes of category selected in current node (using static select list)

texts:
I created a content type containing a select list field (ie Fruit, Food, Jewelery etc).

I am not using any node reference nor any taxonomy vocabulary.

I have added a static select list. I want to show related nodes under the current node. I.e if I visit a node containing the fruit category, then all the other nodes containing fruit category should be shown below the current node.


texts: get all parent terms of a term using php - Notice: Array to string conversion

texts:
I have term with tid=9 (sublevel 3). It is nested under 2 other terms. I use following code to get names of its parent terms:

    <?php
//term id of term that you are checking for top parent
$term_tid = '9';
//this will be your top parent term if any was found
$top_parent_terms = array();

$parent_terms = taxonomy_get_parents_all($term_tid);

//top parent term has no parents so find it out by checking if it has parents
foreach($parent_terms as $parent) {
  $parent_parents = taxonomy_get_parents_all($parent->tid);
  if ($parent_parents != false) {
    //this is top parent term
    $top_parent_term[] = $parent;
  }
return $top_parent_term;
}
?>

Problem: As a result I am getting "array" with error: "Notice: Array to string conversion in php_eval() " instead of terms names.
I tried bunch of other solutions but none of them work or I get same error (for example here https://api.drupal.org/comment/59421#comment-59421)


texts: What is the proper format for the flag service calls?

texts: I'm running Drupal 7 with the Services 3 and the Flag Service modules installed. I'm having trouble trying to figure out how to format the the call in REST format.  Can someone provide a short example?


texts: Add soft hyphen () in titles (in views) or other method to break words in a language-sensitive way

texts:
I have an Austrian site here (and the German language loves compound nouns).

A view produces a raster of 6 article teasers, but some titles exist of one single word of more than 30 characters - and no, it cannot be shortened because it is a proper name.

I'd like to be able to manually add  tags into these titles, as everything else will not be language-sensitive. CSS word-wrap or word-breaks are no options (not breaking at syllable boundaries).
Also, adding an ellipsis is also not an option.

This is Drupal 8, so no "HTML Title" modules available.

The theme does a simple

{% if title %}
  <h1>{{ title }}</h1>
{% endif %}

I am aware of possible security implications and only want to allow this one tag. Alternatively, I am open to other suggestions fulfilling the stated need!


texts: Navigation buttons move around in responsive design

texts:
This is kinda strange, I'm using flexslider module in which my navigation (previous & next) buttons on 1320.css, 960.css are centered fine on the slider. When I get to the 720.css and mobile.css versions, that is when the navigation buttons start moving around. Ether they are above or below the slider in which it's pointless to even display on :hover by ~50px. Lastly, I noticed that I cannot replicate on a desktop/laptop browser, it only gets introduced when using a mobile browser of any type of phone.

Below is a snippet from the Flexslider.css that pertains to the navigation:

.flex-direction-nav a {width: 30px; height: 30px; margin: -20px 0 0; display: block; background: url(images/bg_direction_nav.png) no-repeat 0 0; position: absolute; top: 50%; z-index: 10; cursor: pointer; text-indent: -9999px; opacity: 0; -webkit-transition: all .3s ease;}

Any ideas?  I noticed that 'top: 50%;' moves them  but again a can't figure out a way to get them to always be centered. Also I should mention that I'm running alpha 2 but it occurs in both alpha 3 and alpha 2 versions of Flexslider.


texts: Use 'Contains' in better exposed filters?

texts:
I have a taxonomy of Office departments that I am using to filter my contacts which are brought into drupal with Ldap to search people by department. Some contacts have more info in their dept field when brought in from Ldap.
For example 'Credit - London' instead of just credit. Is the a way to filter by contains 'Credit'?
There are no options on the expose filter


texts: Can I safely delete auto-created Postgres Indexes?

texts:
Running Drupal 7.X with a Postgres 9.3 database.

When adding new fields, 8 database indexes appear to be created for each new field. Running the query "select * from pg_stat_all_indexes;" shows that only 2-3 out of the 8 indexes are actually getting used ... primarily field_data_field_XXXXX_entity_id_idx and field_data_field_XXXXX_pkey. All the other indexes (e.g., ...bundle_idx, ... deleted_idx, ... language_idx, etc.) show 0 for idx_scan, idx_tup_read, and idx_tup_fetch.

Is it safe to delete those indexes that show 0? Once deleted, is there an easy way to recreate the indexes if needed?

The reason for wanting to delete those indexes is that hard drive space is limited. Deleting those indexes would recover significant amounts of hard drive space.


texts: Adding alt/title attributes to uploaded images

texts:
I've created a galley using fields and views thanks to this tutorial: http://jamestombs.co.uk/2011-05-26/create-album-based-image-gallery-drupal-7-using-fields-and-views

But now I can't figure how to add the usual ALT and TITLE attributes to the gallery images. The only option available is to delete the images.

Thank you.


texts:
I don't know how to setup the outh module right. I found also the question How do I configure the Services OAuth sub-module? but that answer is very old and ends with a "To be continued..." statement.

So far I get out that I need to generate a context (http://example.org/admin/config/services/oauth/contexts) and a oauth connector (http://example.org/admin/structure/oauthconnector). So I think I setted them correctly but I cannot see where the user may access that.

Could you point me to a tutorial or something like that? I'm not able to find the right words to google that myself. Sorry for that!


texts: How can I dynamically change the field descriptions in Drupal when another field changes?

texts:
Is there a module or does Drupal 7 have this already built in? Or can someone please explain how one can do this?

If you take a look at Yelp's add business page you can see the description fields change when the user selects a different country. How can I do this with Drupal 7 on the node edit/add page?


texts:
Is there a way to import a Excel file into CCK nodes?

Each Excel file contains only a single sheet
First row of there sheet is header
Data are only strings, numbers, and decimal numbers
It's a daily task which will be performed by a user


texts:
E.g. My site have two subdomains : domain_a and domain_b.

I create a path: "custom/a".

I hope:

domain_a can visit the path.

domain_b visit the path, get 404.

Except according to the golbal $domain in the code, does anyone have other solution?


texts: How to use exchange rate from Currency Api in a field?

texts:
I've installed Currency Api Module + Yahoo! Finance currency converter and
made with "Currency Filter" a new field (using Markup module) in my content named "latest_exchange_rate" with the value of latest USD-EUR exchange rate coming from Yahoo!Finance;
in the same content, there is a decimal field named "usd_value" filled with a value during content creation;
additionally I created also a Computed field named "eur_value" which is a multiplication = "latest_exchange_rate * usd_value";

The problem is that the computed field seems not able to read the value of "latest_exchange_rate" field, and the result is always 0.00.

I am not a coder, can you please help me to solve this problem?
If my approach is not correct, how can I use an exchange value from Currency API to make conversions between different currencies?

Thank you in advance for attention, Francesco in Cina


texts: How do I make a view of taxonomy terms with no spaces between lines (no Views HTML)?

texts:
I want to make a view to list 100 taxonomy terms like this:

Term 1, Term 2, Term 3, Term 4, ... Term 100

I made a view of taxonomy terms.

Here are the settings:

Format: Unformatted list
Settings: Add views row classes *unchecked*

Fields: Taxonomy term: Name
Formatter: Plain text
Link to the Taxonomy term *unchecked*

Style settings
Customize field HTML *checked* (none)
Customize label HTML *checked* (none)
Customize field and label wrapper HTML *checked* (none)
Create a CSS class *unchecked*
Add default class *unchecked*
Use field template *unchecked*

Rewrite results
Override the output of this field *checked*
Text: {{ name }},

However, the output looks like this:

Term 1,

Term 2,

This div puts all of the terms on new lines.  Is there a way to get rid of it within the Views settings?  Running Drupal 8.3.5.


texts: How can I customize the registration form in D7 Organic Groups?

texts:
I am using Drupal 7 and Organic Groups 7.x-2.0-beta1. I have created a custom membership type to act as a custom registration form, but I can't seem to override the default membership type with the one I created.

I have one group type, but each group may have it's own registration form. I need the ability to load the custom registration form for each group. I'm assuming that with a custom module I could make this happen with Organic Groups' membership types.

I have added an Entity Reference to the membership types on the group content type, so I can access a specified membership type based on the group id.

Any idea of what function I could hook into to make a change? Any other ideas about how to implement a custom registration form for organic groups?


texts: Zen subtheme, superfish menu etc - invalid CSS

texts:
I created a sub theme and based it on Zen.

I just validated the CSS locally and there are 66 errors. Any tips on how to use existing modules and themes but reduce the number of css errors?

2653    ul li.expanded  Parse Error *list-style-image: url(../images/menu-expanded.png);

2658        Parse Error [: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHAQMAAAD+nMWQAAAABlBMVEX///8AAABVwtN+AAAAAXRSTlMAQObYZgAAABJJREFUeJxj+MdQw2DBIMAABgAUsAHD3c3BpwAAAABJRU5ErkJggg=='); list-style-type: circle; } ul li.collapsed]

2665    ul li.leaf  Parse Error *list-style-image: url(../images/menu-leaf.png);

2674        Parse Error [: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHBAMAAAA2fErgAAAAD1BMVEX///+/v7+Li4sAAADAwMBFvsw8AAAAAXRSTlMAQObYZgAAAB1JREFUCFtjYAADYwMGBmYVZSDhKAwkFJWhYiAAAB2+Aa/9ugeaAAAAAElFTkSuQmCC'); list-style-type: square; } /* * The active item in a Drupal menu */ li a.active]

3012    a.button    Property appearance doesn't exist : button


texts: Problems overriding poll-bar.tpl.php using Omega subtheme

texts:
I am trying to theme the Poll results. I decided to overwrite poll-bar.tpl.php by copying it inside my custom Omega theme directory. However, the changes are not visible after flushing cache nor after copying the template to templates directory.

What could be the problem?


texts: How do I re-name my zone--content.tpl.php file for a separate front page layout?

texts:
I am using Omega 3.x along with Delta and contexts for creating a drupal theme for my site. I have experience with using D6 themes like Zen but I am still learning my way around Omega.

I want to know how I can create and name a separate template for my zone called content for the front page. I wouldn't mind a hard coded or a Delta+context solution or for that matter any other method to achieve my goal as long as Omega is used.


texts: Is there a way to resolve a list of references in a view without cloning entire rows of data?

texts:
I'm playing around with the drupal views and reference relationships. I have an entity of type A that has a reference to entity of type B, and a list of references to entities of type C. Reached this point thanks to : this question

Using views -> advanced -> relationships I can create a relationship to B and then add the fields that I want from B in the view of A. However, when doing the same thing for the list of C, I am seeing the same entity of type A repeated as many times as there are references to the entity of type C.

Is there a way to have the list of C entities without the duplication behavior?


texts:
I have a Drupal module where I want to separate the html from the logic by placing it in a template file. You'd think this would be easy but I can't figure out how it's supposed to work within Drupal. When I google it I come upon massive guides on making Drupal themes or articles on focusing on a single aspect of the templating process. I downloaded and installed the Examples for Developers module which has a section for templating, but even that does not do exactly what I want and breaks as soon as I make any significant change.

I made a simple module called blob to try to get this to work.
I have the following template file called blob-stuff.tpl.php:

<div class="container-inline">
    Hi <?php  print $myname; ?>
</div>

In blob.module I have

function blob_menu() {
  $items['blob1'] = array(
    'title' => 'Blob1',
    'page callback'    => 'blob_stuff',
    'access arguments' => array('access content'),
  );
  return $items;
}

function blob_theme() {
  return array(
    'blob_stuff'  => array(
      'template' => 'blob-stuff',
    ),
  );
}

function template_preprocess_blob_stuff(&$variables) {
  $variables['myname']='Bob';
}

function blob_stuff(){
  return 'Bob';
}

Which of course doesn't work, because at this point I'm just guessing.

Can anyone give me a simple, working example of this, following Drupal best practices?


texts: How can one run drush from project root when using multiple site configurations?

texts:
I have projects configured with multisite configuration, with folder structure as follows: sites/local.domain,sites/staging.domain.com, sites/domain.com.

All is well, except for one detail: I cannot run drush from project root directory anymore.  I need to cd up to the current configuration folder.

Is there a  way around this?


texts: Simpletest fails to create the field_config table

texts:
I'm only just getting into TDD with Drupal and unfortunately run into trouble right away. For some reason the simpletest####field_config table isn't being created, and I don't get why; many other tables do get created. The (seemingly) relevant part of the error I get is:

  Base table or view not found: 1146 Table 'mcdonalds.simpletest405637field_config&#039

coming from /modules/field/field.crud.inc (that is the project's root modules folder, NOT the modules folder in any theme or something).

I'm a bit stuck here, so I hope someone can tell me how to debug this, or even how to solve, that would be great of course;) Thanks!


texts:
I am using the Mail system and the Swift mailer* modules to send HTML emails. I then implemented a custom module to send HTML newsletters to users, and I noticed the emails didn't look as expected: Many styles kept broking randomly.

After digging, I discovered the problem was with the string of email randomly being broken by new lines: If a new line came in a critical position in the string, the whole mail would be broken. I needed to know where these strange new lines were coming from.

It turned out I am not doing anything to string expect this.

$body = 'some html code without new lines';
$body .= 'some more html code without new lines';
$body .= 'some more and some more html code without new lines';

$params['body'] = Markup::create($body);
$language = $recipient['lang'];
$to = $recipient['mail'];
$params['to'] = $to;
$result = $mailManager->mail('custom_newsletter_mail', 'newsletter', $to, $language, $params, $from, $send_bool);

I don't know what Markup::create($body) does, so I tried removing it. The email was delivered with no new lines, but the HTML was not rendered.

In mail system configuration, I set swiftmailer as FORMATTER and default PHP mailer as SENDER.

This is the custom module's .module file.

function custom_newsletter_mail_mail($key, &$message, $params) {
  $message['body'] = [];
  $message['subject'] = [];
  $message['format'] = 'text/html';
  $message['subject'] = $params['title'];
  $message['body'][] = $params['body'];
  $message['headers'] = array(
    'content-type' => 'text/html',
    'charset' => 'UTF-8',
    'format' => 'flowed',
    'delsp' => 'yes',
    'from' => $params['from']
  );
}

I found out that my testing environment send emails with no new lines (Email looks as expected), while my production environment doesn't. I double checked every setting; both are identical as far as I can tell.

I tried using mime mail instead of swift mailer and it WORKED!! there is no newlines or spaces (The HTML mail actually looks good), BUT mime mail only reaches live mails. It doesn't work with yahoo or gmail for some reason.

I need to fix this. I need to remove those annoying new lines in the email body, which I feel it's a swift mailer issue.


texts: How to control the display of a user account connected via entity reference

texts:
My searches have turned up nothing, I'm sure it is something simple but I can't figure it out.

To give a simple version of my set up:  I have a content type for publications, that publication has a paragraph field for authors.  That paragraph field accepts either a user linked by entity reference, or a non-user author (a set of text fields).  My end goal is to display them in proper order like so:

Authors: Staff Author 1, Non-Staff Author 1, Non-Staff Author 2, Staff Author 2, Staff Author 3

Replacing the text there with actual author names.  The order needs to be the order in which they were entered, which is the reason I am using paragraphs (I can mix types and keep the order)

Unfortunately the view options for the entity reference that work for the Users seem to be: Entity ID or Rendered Entity.  Entity ID just gives me a number (which I'm sure I could then use in a preprocess function to load the user info and display it as desired -- if that is the best approach, please give me some guidance on where to start), Rendered Entity gives me a User Account full display including photo.  I only want the name linked.

In How can I change a rendered user display to a combination of fields linking to the user? I got the answer about how to change user links, but how can I get this reference to show as a user link?


texts:
I have a view with 4 exposed filters and I need them to work independent from each other without combining their values in url.

The view should only filter by the last clicked filter.

I've been trying grouping filters with AND or OR operators but no luck yet.

How can I force that behavior?


texts:
I'm a little bit confused with hide() documentation.
It says:

  The first time render() or drupal_render() is called on an element
  tree, as each element in the tree is rendered, it is marked with a
  "#printed" flag and the rendered children of the element are cached. Subsequent calls to render() or drupal_render() will not traverse the
  child tree of this element again: they will just use the cached
  children. So if you want to hide an element, be sure to call hide() on
  the element before its parent tree is rendered for the first time, as
  it will have no effect on subsequent renderings of the parent tree.

First of all, I want to say I understand that hide() allow to avoid rendering of a specific element.

But documentation says more :

By talking about caching element as it is the default behaviour. For me, if #cache property is not defined for an element, when rendering the element will be not be cached.
And for me also, subsequent calls to drupal_render() will not use the cached element, because #printed property will be checked before trying to get the cached element (#printed=TRUE means return '';) .

I want to get your explanation about this.


texts:
Drupal 6 website.

I need to embed a drawing tool into a webform to allow a visitor to sketch a diagram and have it sent as an attachment to the email from the WebForm.

Been looking around but have not found a solution for Drupal 6.

Any ideas?


texts: How to catch twig errors and display custom 500 error page?

texts:
I have a patch to add some custom handling of 500 errors that run through the code in errors.inc, so that it returns a themed page in those cases.

This works well in certain conditions, but I have an error that occurred with a misnamed twig template, so I got

Twig_Error_Loader: Template "@mytheme/search-result/search-result--event.twig" is not defined (Drupal\Core\Template\Loader\ThemeRegistryLoader: Unable to find template "@mytheme/search-result/search-result--event.twig" in the Drupal theme registry.) in "themes/custom/mytheme/templates/node/node--admissions-event--search-result.html.twig" at line 1. in Twig_Loader_Chain->getCacheKey() (line 129 of /var/www/mytheme-qa/site/vendor/twig/twig/lib/Twig/Loader/Chain.php).

After some digging I see that this error is generated here:
/core/lib/Drupal/Core/Template/Loader/ThemeRegistryLoader.php

if ($throw) {
  throw new \Twig_Error_Loader(sprintf('Unable to find template "%s" in the Drupal theme registry.', $name));
}

The problem is this type of error isn't handled by Drupal.  It's a Twig engine error.  So an exception subscriber doesn't catch this.

Any suggestions on how to return a themed 500 page in fatal error cases like this at the theme layer?


texts: Drush migrate --idlist error: Migration failed with source plugin exception

texts:
When running drush migrate-import with --idlist option I got this error:

$ drush mi BeersMigration --update --idlist='1001' -d
...
Importing 'BeersMigration' migration [1.2 sec, 30.83 MB]                                                                                [notice]
Migration failed with source plugin exception: Invalid argument supplied for foreach()                                                                     [error]
File .../sites/all/modules/contrib/migrate/plugins/sources/xml.inc, line 718 [8.31 sec, 32.55 MB]

(Drush Version   :  6.2.0)

Code and source

Migrate class

class BeersMigration extends XMLMigration {
  public function __construct($arguments) {
    parent::__construct($arguments);

    $fields = array(
      'id' => t('Beer ID'),
      'name' => t('Title'),
      );

    $xml_folder = DRUPAL_ROOT . '/' .
    drupal_get_path('module', 'migrate_beers') . '/xml/';
    $urls= array();
    foreach (glob($xml_folder."/*.xml") as $filename) {
      array_push($urls, $filename);
    }

    $item_xpath = '/catalog/beerList/beer';
    $item_ID_xpath = '@beerID';

    $items_class = new MigrateItemsXML($urls, $item_xpath, $item_ID_xpath);
    $this->source = new MigrateSourceMultiItems($items_class, $fields);

    $this->destination = new MigrateDestinationNode('node', array('text_format' => 'full_html'));

    $this->map = new MigrateSQLMap($this->machineName,
      array(
        'sourceid' => array(
          'type' => 'varchar',
          'length' => 255,
          ),
        ),
      MigrateDestinationNode::getKeySchema()
      );

    $this->addFieldMapping('field_source_id', 'id')
    ->xpath('@beerID');
    $this->addFieldMapping('title', 'name')
    ->xpath('beerName');
  }
}

Source xml

<?xml version="1.0" encoding="utf-8"?>
<catalog>
  <beerList>
    <beer beerID="1001" lastModified="2013-12-30 11:03:51">
      <beerName>Legado de yuste</beerName>
      <beerDates>
        <beerDate date="10/02/2014" time="10:00" dateEnd="10/02/2014" timeEnd="12:00"/>
      </beerDates>
    </beer>
    <beer beerID="1002" lastModified="2013-12-1 12:03:51">
      <beerName>Estrella Galicia</beerName>
      <beerDates>
        <beerDate date="10/02/2014" time="10:00" dateEnd="10/02/2014" timeEnd="12:00"/>
        <beerDate date="12/02/2014" time="10:00" dateEnd="12/02/2014" timeEnd="13:00"/>
      </beerDates>
    </beer>
  </beerList>
</catalog>

I only got this error when using the drush option --idlist. If I run the migration without --idlist option everything works fine.

I want to migrate an specific item for debugging. Using the source id and the --idlist option always gave me this error. I review the code, however even with the simply code above  it shows me the same error.


texts:
I'm using the modules domain and domain_alias on Drupal 8.

I need to load all the aliases of a given domain.

I have tried the following without success:

$aliases = \Drupal::service('entity_type.manager')->getStorage('domain_alias')->loadByHostname('my.domain.com');

$aliases = \Drupal::entityTypeManager()->getStorage('domain_alias')->loadByProperties(['hostname' => 'my.domain.com']);


texts:
If a contrib module's info.yml contains core: 8.x and not core_version_requirement: ^8.8 || ^9, how can a site be upgraded to Drupal 9 using composer?
composer update downloads modules in "require": { which needs to be before "patches": { because there needs to be a module before it can be patched. Assume the patch patches the info.yml file with core_version_requirement: ^8.8 || ^9.
So composer update can't resolve to an installable set of packages and throws errors like this:
- Root composer.json requires drupal/entity_jump_menu 1.1 -> satisfiable by drupal/entity_jump_menu[1.1.0].
- drupal/entity_jump_menu 1.1.0 requires drupal/core ~8.0 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev] but it conflicts with your root composer.json require (^9.1).

It looked like the answer was changing drupal/core and drupal/core-dev to a value of "^8.8||^9.1". composer update will now run, except the site is still building in version 8.9.13.

Following the suggestions on the mediacurrent blog post, I changed composer.json to the following
  "repositories": [
      {
          "type": "composer",
          "url": "https://packages.drupal.org/8",
          "exclude": ["drupal/entity_jump_menu"]
      },
      {
          "type": "git",
          "url": "git@git.drupal.org:issue/entity_jump_menu-3130218.git"
      }
  ],
  "require": {
      ...
      "drupal/entity_jump_menu": "dev-3130218-drupal-9-deprecated",
      ...
  },

Which downloads the fork of the module, into vendor/drupal/entity_jump_menu. Unfortunately Drupal and/or Drush don't see the module in that directory.
I'm going to try the computerminds solution next.

The solution from computerminds adds the fork of the module to the modules/contrib directory. Here's the code.
"repositories": [
    {
        "type": "package",
        "package": {
            "name": "drupal/entity_jump_menu",
            "type": "drupal-module",
            "version": "dev-3130218-drupal-9-deprecated",
            "source": {
                "type": "git",
                "url": "git@git.drupal.org:issue/entity_jump_menu-3130218.git",
                "reference": "268adc649cfb4ad716751a8643e60f5df4dbb80d"
            }
        }
    },
    {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
    }
],
"require": {
    ...
    "drupal/entity_jump_menu": "dev-3130218-drupal-9-deprecated",
    ...
},

Thanks for pointing me in the right direction.


texts:
CKEditor is now part of Drupal (which is great).  It is now possible to deliver Drupal to clients that are frightened when they see HTML-markup!

However, some clients of this type are in love with Microsoft Word. They use MS Word as their only authoring tool, and just want to paste the result into the web-page to publish on their company web-site.

As everybody knows: When pasting text from Microsoft Word into CKedior (using the default Ctrl+V keystroke), you get a lot of garbage as part of the package. I know there are ways to clean this up (e.g. Paste Format and similar modules) by removing blank lines and inline styles. This is not a problem.

However, if your MS Word document is set up with multi-level headings, these are transformed into list items by the standard Ctrl+V keystroke to paste. This means that a level one heading in Word that appear to the user as this:

7 Chapter

becomes a list:

Chapter

Worse, lower level headings, such as:

7.1 Sub-section

become HTML nested lists.

However, Adobe's Dreamweaver is capable of preserving this type of multi-level heading if you paste using its Insert Document dialog box. What you get if you do this in DreamWeaver, is HTML that is very similar to what you get when you use “Save as” in MS Word and “Save as type: Web page, filtered”. I.e. MS Word multi-level headings is preserved as HTML-headings. The two examples above become:

7 Chapter

7.1 Sub-section

Extending Paste Format, etc. to undo this damage is not possible, as it is not possible to tell the difference between multi-level headings transformed into multi-level lists, and actual multi-level lists.

My question is: Is there a way to preserve multi-level heading tags when pasting from MS Word into CKeditor? Or: Is there a way to use “Paste special” or some other Microsoft magic to get the right type of HTML when you paste from MS Word into CKEditor?

PS:
I understand that a work-around would be to take the round trip via MS Word's “Save as type: Web page, filtered”, and paste the resulting file (via Notepad) into CKeditor in its “Source” mode. However, the client is unhappy about this detour via the file system and wants paste from MS Word into CKEditor to work “just as seamless as it does in Dreamweaver”. Is this possible?


texts: Commerce Create Cart/Order without product

texts:
function create_init_order() {
  global $user;

  $order = commerce_cart_order_load($user->uid);

  if(!$order) {

    $new_order = commerce_order_new($user->uid, 'pending');

    // just consider i have generateEmail() and randomName($len) functions

    $new_order->order_number = $order_number = randomName(10);
    $new_order->mail = generateEmail();
    $new_order->hostname = randomName(10);

    commerce_order_save($new_order);
    unset($new_order);

    $order = commerce_cart_order_load($user->uid);
    $order->data['suburbs'] = $_REQUEST['suburb'];
    $order->data['truck'] = $_REQUEST['truck_size'];
    commerce_order_save($order);

  }
}

Hi guys this is for anonymous user creation of order if not existing yet, anything I missed why is not working well.

Specifically this part:

    $order = commerce_cart_order_load($user->uid);
    $order->data['suburbs'] = $_REQUEST['suburb'];
    $order->data['truck'] = $_REQUEST['truck_size'];
    commerce_order_save($order);

As i need suburbs and truck data before adding the line item.

Thank you in advanced.


texts: Alter a form based on where it is called from

texts:
I am using something on the lines of

  $view = views_get_current_view();
  $build = drupal_get_form("comment_node_contenttype_form",
  (object) array('nid' => $view-> args[0]));
  print render($build);

to print a comment form in my views.

My challenge is I am using the same code in two different displays. I need to make a few fields in the comment form required only when it is getting called from a particular display.


texts:
I have a glossary view, which is just the one that comes with Views. I want to allow users to filter the results by taxonomy terms (dropdown) and also by title (search field). The problem I'm running into is that when I click on a glossary letter (e.g. X) then I try to type in a search term that begins with something other than X (e.g. Cat) I get no results. The title search filter is basically just searching within the selected letter in the Glossary. So if I'm on the X page and I search for Cat nothing is found. If I would search for X-ray then that would appear.

Is there any way to make the title filter relatable to the entire view result and not just things that begin with the glossary letter than I have selected?

In the attachment of the view I've tried turning on the "Inherit exposed filters" option but that does not help.


texts:
I've created two taxonomy vocabularies e.g. "One" and "Two" and I've added 5 terms by these vocabularies.

Then I created two taxonomy category template files, but I have one big problem.

Example: term named "Apples" from vocabulary "One" list all nodes that have this term.

I'm trying to get url and node name, trimmed body text and pager so this term page it shows 10 nodes and there is a pager at the bottom.

I created view block, but it's huge job to create blocks for each terms etc..

So how I can list all nodes on these term pages?


texts:
I am creating a Rules Action that will update the node title after it is created.

Here is my code, but when I try to create new content using Postman, it keeps loading. I dont get response in Drupal logs.

...
class ContentTitle extends RulesActionBase {

  protected function doExecute(EntityInterface $entity) {

    $entity_id = $entity->id(); // Getting dynamic entity ID
    $controller = \Drupal::entityManager()->getStorage('node');
    $node = $controller->load($entity_id);

    $title = $entity->label();
    $item = $node->get('field_xyz')->value;
    $new_title = "Title is " . $title . $item;

    \Drupal::logger('custom_rules')->notice('new_title: ' . $new_title);

    $data = array(
      'type' => 'custom_content',
      'title' => [
        'value' => $new_title,
      ]
    );
    $node = Drupal::entityManager()
      ->getStorage('node')
      ->create($data);
    $node->save();
  }
}

Im getting the expected output in the logger.

I dont think I am setting the title in $data properly. Any suggestion is greatly appreciated. Thanks!


texts: Programmatically append multiple paragraphs to entity reference field on node

texts:
I have a paragraph type that contains a text field and a text format field.
I also have a content type that takes an unlimited number of paragraphs of this type.

The paragraph type is called 'questions_and_answers' and the two fields are 'field_question' and 'field_answer'. I'd like to be able to programmatically append 'questions_and_answers' paragraphs to a content type.

In the example below I'm grabbing the content from a 'double' field and importing them into the paragraph reference field.
Here's my code so far.

    $nids = \Drupal::entityQuery('node')
        ->condition('type', 'faq')
        ->execute();
    foreach ($nids as $nid) {
        $node      = \Drupal\node\Entity\NODE::load($nid);
        $questions = $node->field_questions_and_answers->getValue();
        foreach ($questions as $question) {
            $q         = $question['first'];
            $a         = $question['second'];
            $paragraph = Paragraph::create([
                    'title'          => $q,
                    'type'           => 'questions_and_answers',
                    'field_question' => $q,
                    'field_answer'   => $a,
                ]);
            $paragraph->save();
            $node->field_qs_and_as[] = $paragraph->id();
        }
        $node->save();
    }

However when I perform this action the node gets a number of question paragraphs added but they're completely empty and they can't even be deleted. What am I missing? How do you append multiple paragraphs you created to an entity reference field on a node?


texts: Converting and save images as JPG in IMCE module during uploading?

texts:
How to convert PNG to JPG when user upload images with IMCE ?
This is neccessary for disk space optimization. If it is possible to convert with any module or to execute Image Style tell me please.


texts:
I have created a block-custom.tpl.php, the following is the code inside:

Hello World

Subject:<?php print $block->subject ?>

Content:<?php print $block->content ?>

My custom module code:

        function custom_block_info() {
          $blocks['my-block-id'] = array(
            'info' => t('Block Name'),
          );
          return $blocks;
        }

        /**
         * Implementation of hook_block_view().
         */
        function custom_block_view($delta='') {
          $block = array();
          switch ($delta) {
            case 'my-block-id':
              $block['subject'] = t('Block Name');
              $block['content'] = custom_contents();
              break;
          }
          return $block;
        }

        /**
         * custom html block
         * @return string
         */
        function custom_contents() {
          return '

              Hello World, this is a example custom Block

          ';
        }

I placed the tpl file in /module/block/ directory

I followed the tutorial of the following web page (I know it is for Drupal 6)
http://eureka.ykyuen.info/2010/11/11/drupal-customize-block-template-file/

Of course, the result is nothing, anything I am missing? How to override the block.tpl.php?


texts: Payment Gateway integration on selecting user profiles

texts:
I am working on a project where human resource agents can view a list of job applicants. On each job applicant profiles theres a Confirm job applicant link visible only to human resource agents.
Once the HR agent clicks on Confirm job applicant link, the control should go to a payment gateway and after the HR successfully does the payment, the job applicant should get confirmed by that HR agent.

I was thinking to use ubercart module to handle all the payment transaction, but is ubercart the best choice for this type of workflow as theres no product shopping cart model here.

Is there any other module which can be used for the above workflow?


texts:
I need to track user logins so I know how often "UserA" is logging into my site.
Can anyone recommend a method to do this? Module or code?


texts: Breadcrumbs stopped going to third level

texts:
I'm still learning Drupal, so have a basic understanding, and have been assigned to fix our breadcrumbs.  Apparently it used to go to the 3rd level on this page (https://ccom.unh.edu/theme/auvs), but it no longer does, only to the 2nd level.  It should say Home>Research>AUVs, but it only says Home>Research.

The Crumbs module wasn't installed.  I've been looking through our modules to try to figure out what is doing the breadcrumbs, but I don't see anything.  If I install the Crumbs module I can't even find instructions on how to implement it.  Can someone give me some guidance here please?  Thanks!


texts: How to optimize the unserialization of "variables" cache value

texts:
As we all know, the whole variable table is being cached in the drupal cache system and is being extracted into global $conf variable in each invoke. In one of our production site with the domain module, we are having hard time to keep up with the memory requirement of PHP for the unserialization of this variable from the cache. At this moment, we've assigned 768mb memory to each PHP thread so that the value can be unserialized.

We are doing the following to fight this:

First of all, we have installed the memcache module to move the cache storage from DB to memory
We have edited memcache module's cache_get and cache_set functions like below to store/retrieve individual items from the variables array and split/join them when requested. This should require a small memory limit as there is no huge unserialize operation going on.
Is this a sustainable solution? Are there any better solution for this problem?

Looking forward to knowing your views!

sites/all/modules/contrib/memcache/memcache.inc

function memcache_is_special_cache_item($cid) {
    $specials = array('variables', 'strongarm');
    return in_array($cid, $specials);
}

function cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = NULL) {
  // Handle database fallback first.
  $bins = variable_get('memcache_bins', array());
  if (!is_null($table) && isset($bins[$table]) && $bins[$table] == 'database') {
    return _cache_set($cid, $data, $table, $expire, $headers);
  }

  // In case of special cache items, we keep the individual items as
  // separate cache items. Later in the retrieval time, we join them
  // together.
  if (memcache_is_special_cache_item($cid)) {

    $keys = array_keys($data);
    foreach ($keys as $key) {
      cache_set($cid . '_' . $key, $data[$key]);
    }

    cache_set($cid . '_keys', $keys);
    return true;

  }

  // remaining part of the function
}

function cache_get($cid, $table = 'cache') {
  // Handle excluded bins first.
  $bins = variable_get('memcache_bins', array());
  if (!is_null($table) && isset($bins[$table]) && $bins[$table] == 'database') {
    return _cache_get($cid, $table);
  }

  // The special cache item was previously saved as individual items,
  // so now we have to retrieve them separately and join them together
  // and send as one item.
  if (memcache_is_special_cache_item($cid)) {

    $keys = cache_get($cid . '_keys');
    if (is_null($keys->data)) {
      return false;
    }

    $data = array();
    foreach ($keys->data as $key) {
      $data[$key] = cache_get($cid . '_' . $key);
    }

    return $data;
  }

  // remaining part of the function
}


texts: Add state permissions and allow state changes

texts: I'm using Workflow module. I want to give permission to a specific role to edit the content moderation state. I found these on permissions page but it's not working. After I update the role permission, he got "Access Denied"


texts: Use taxonomy path for a node's path alias

texts:
Is it possible to use a token to reference the alias of a taxonomy term in the pattern of an automatic alias for a node type where that term has been selected, in Drupal 8? (Let's assume a single taxonomy term is selected.)

For example: If one has a taxonomy of Names where the values are James, Margaret, Daniel and each name has a path assigned to it (/news/jim, /news/peggy, /news/dan) is it possible to construct an automatic path for "News" node types where the pattern is something like [taxonomy:Names:path]/[node:title] so that if one selects "Margaret" from the Names list and gives the node a title of "Summer Vacation 2017," it will result in the automatic node path of /news/peggy/summer-vacation-2017?

All the references to path aliases based on taxonomy that I have found use the entity value of the term, which I don't want. I don't want /news/margaret/summer-vacation-2017 as the result of the above example.


texts: What can I use as a unique identifier between a node and its translation now that the "tnid" field is no longer available?

texts:
We are upgrading our site from D7 to D8 and a part of this includes sending data out to another resource, specifically, Nodes. When we send data to the 3rd party resource, it's expecting something like
[
  {
    "drupalId": 1,
    "title": "English Node",
    "tnid": 1
  },
  {
    "drupalId": 2,
    "title": "Translated Node",
    "tnid": 1

  }
}

This allows the 3rd party resource to store 2 separate nodes and then links them together using the tnid, and in this 3rd party resource, the Drupal Id is suppose to be unique. However, in D8, it appears that a node and it's translation has the same Drupal Node Id and there does not exist a 'tnid' value, like it was in D7. I assume this is just the change in how translations work in Drupal 8 now, which brings me to my issue:
What can I use as a unique identifier between a node and its translation now?
In D7, the Node Id was a unique identifier and the tnid was a "link" between a node and its translation. In D8, the Node Id is the "link" between a node and its translation, but what could I use to distinguish a Node from its Translation?


texts:
We're having a problem with caching that is affecting anonymous users.

We have a form in a block that when the user fills out the form, they are able to download a PDF. We hide the block on pages where we don't want this PDF download form to appear. Ideally the block is hidden, if no PDF is available for a particular page, but the block is being cached and displayed regardless the of the actual page. This only is a problem for anonymous users. Logged in users do not have the problem of the seemingly cached PDF download blocks appearing on the wrong pages.

For example after clearing the cache, somebody first visits page A with a PDF available, then that PDF download form block is being cached and the cached version is also displayed for page B which does not have a PDF download.

Same vice versa, if you visit Page B first, than the block is being cached with it's attribute display:none, and it will not be displayed for Page A either
Basically, we need the visibility to be re-evaluated on each page load.

We're fairly certain it's a cache issue as when we inspect the live rendered code we can see the block IDs being mixed up on the page.
For example: we'll see a body-tag includes a class "node-164", it's node 164 and the Download the PDF includes a class "PDF-node-205", so it's the cached version for node 205, it also includes the filename as a CSS classname, it's clearly the block for a different page node.

We've tried disabling the page cache, dynamic cache, and the twig cache and we're still having the same problem. And again it is only happens for anonymous users, logged in users do not see these cached blocks appearing on the wrong pages.

Has anyone run into this or know of another caching method that Drupal may be using that we're not aware of?


texts: WSOD while sending headers, probably Cache-related

texts:
I have a very strange problem with a fresh Drupal install: On some pages, I receive a WSOD with ERR_EMPTY_RESPONSE:

It happens for instance when on admin/config/development/performance I click Clear all caches. (But also other pages are affected – for instance the Layout Builder page of a Node type.)

Interestingly, I could isolate the bug down here: If in vendor/symfony/http-foundation/Response.php::sendHeaders() I tweak the code so that it unsets a lot of the headers to be sent (actually, all of them but X-Generator and X-Frame-Options), the error disappears.

...
$headers = $this->headers->allPreserveCaseWithoutCookies();
unset($headers['Cache-Control']);
unset($headers['Content-language']);
unset($headers['Date']);
unset($headers['X-Drupal-Dynamic-Cache']);
unset($headers['X-UA-Compatible']);
unset($headers['X-Content-Type-Options']);
unset($headers['Expires']);
unset($headers['Vary']);
foreach ($headers as $name => $values) {
  ...

Based on the headers I unset, it seems that it is a caching-related problem. (However, Caching is switched off, Browser and proxy cache maximum age is set to <no caching>.)

My setup:

installed Drupal 8.7.5 via composer
on my local machine, a MacBook Pro with macOS High Sierra
installed via Homebrew

PHP 7.3
Apache 2.4
MySQL 5.7.24

Any idea what the problem might be?

Edit: Regarding Apache error logs: I first had no entries there but now I debugged again and saw such one:

[core:notice] [pid 92592] AH00052: child pid 98466 exit signal Bus error (10)

Googling gave the suggestion to apc_clear_cache(); but it's not available in PHP7. So I ran opcache-reset().

Result: Problem is still there, now already when opening the page admin/config/development/performance.

Now the error logs say:

 [core:notice] [pid 7428] AH00052: child pid 7446 exit signal Segmentation fault

Google suggests this is likely  caused by a syntax error in php.ini or some included extension there. Thus I have taken out all extensions, including

zend_extension=/usr/local/opt/php/lib/php/20180731/opcache.so

but the problem remains.

Edit 2: Here's the output of my php -i (It uses the same php.ini file as phpinfo() in localhost). https://pastebin.com/ppvCpPA6


texts: How do I debug my Feeds import not importing a field

texts:
I have a Feeds import set up to import products into Drupal Commerce (from csv). My product type has a number of term reference fields that also need to be assigned a value by import. Most of these work fine (e.g.: field_product_unit, field_product_discount_category), except one: field_product_group. I'm searching the taxonomy term by term name.

Importing the product group used to work at some point, but for some reason or other, it stopped working. Not a single value gets imported. I can't pinpoint when it quit on me. I don't see an obvious difference between the fields that do work, and the one that doesn't. The only slight difference is that product groups are hierarchical, and the other taxonomy lists don't use hierarchy.

I don't get any error messages or "I can't find this term" notices.

I've tried the following:

checked and double-checked the names of the terms matching the csv values: they do.
importing my taxonomy term name into a text field (to make sure it could find the input field): works fine.
my taxonomy lists all use multilingual names and descriptions. To avoid a mix-up there, I reset it to a single language: no difference

How do I proceed now? How can I figure out what's going wrong?


texts: How to alter a custom text field in a block with AJAX

texts:
We have a block on a basic form listing several items and each item has a number of PDF files on the server to show by a users request.
Each item has an Id (nnn) which is displayed in a text field wrapped as
item nnn

the object is when a user clicks the link, the div should be replaced by a list showing the links to the corresponding PDF files to download.
There are lots of Ajax examples that create their own form, but none so far that comes close to our application in replacing a div in a block.  We could do the Ajax request in a direct way but prefer to use the Drupal api's for stability and manageability, the only question remains is how to..  so examples or ideas are appreciated.


texts: Disable default site and only use multisite

texts:
On my server I have drupal with a multisite sub-directory set up (example.com/www.site1.com), and do not use default for anything. However, when i go to default (example.com), I am sent to the default install.php (example.com/install.php).

How could I best prevent this from happening, and for example, show a custom index.html page when a user lands on just example.com?


texts: Which module can I use to visualize Drupal log data in the format of a chart?

texts: I installed Better Statistics and Syslog Access. I wonder if there is a module that can take this data and visualize it like a graph, pie chart, etc? I found one but it's a service, any suggestions?


texts: Is there any hook_node_pre_submit() like hook?

texts:
I have a Drupal 6 site where I am using the  Webform module. There are business validations written in JavaScript, but users can bypass them by disabling JavaScript.

Is there any hook_node_pre_submit() kind of hook in Drupal 6 that doesn't allows users to submit the form if the validation fails?


texts:
I am developing a module in Drupal 7.56 that is going to rely on jQuery UI 1.12.1. I want my module to check to see if that version is installed on the site, if it is not I am going to use drupal_add_js() to add the correct version. I don't want to just add the js file if it already exists in the system.

I do not have access to the site the module is going to be installed on. I want this module to be used on many different sites and don't want the module to add the js if it is already there.

What is the best way to do this?


texts: "The service 'serializer' has a dependency on a non-existent service 'entity.manager'"

texts:
I have a multidomain site and recently I update from D8 to D9.
In my multidomain site I have 2 websites, sharing core and modules, but with different DB.
One of them after update works correctly but the other one not.
I got this error:

The service "serializer" has a dependency on a non-existent service "entity.manager"

In this last 2 days I search and tried some fixes but no luck.
What I tried:

uninstall contrib modules
disable views
uninstall/delete paragraphs
tried a couple of patches

If I return to D8 everything works good.
My modules list:

Dind't find anything related with theses modules and current error.
Any thouths about this migration error?
Thanks in advance :)


texts:
I have a webform node and I want to export it (via node export) to other sites - the issue is when the node id is already assigned drupal assigns a new id.

<?php
$block = module_invoke('webform','block_view','client-block-5');
print $block['content'];
?>
<?php print render(block_get_blocks_by_region(''));?>

So the code does not work as the id is client-block-9, apart from creating a region for this block is there a work around?


texts: How can I preprocess a node field value to make it accessible in the template level beneath field level (video template inside file field)

texts:
I am using the Video.js (HTML5 Video Player) module and I would like to add an image for the poster by loading the URL of another image field in the same node (without modifying the module itself).

How can I preprocess that URL to get it inside the module template?

I tried to get the URL variable as {{ poster }} into the template file videojs.html.twig, by adding following preprocess function in the theme-file:

function templatename_preprocess_videojs(&$variables, $hook) {
  if ($variables['element']['#field_name'] == 'field_image_poster') {
      $variables['poster'] = $variables['element']['#object']->getURL();
  }
}

PS: Thank you for the suggested solution. This would work if I would have expressed myself correctly. But it's not the field level were I do not get the variable, its one level deeper (the video template beneath the file field level).


texts:
I am trying to manually create a menu link item in the User Menu that contains a wildcard, But I cant make it work.  I can get it to work if I have a static path, but I cant get it to work with wildcards args

function hook_menu() {
  $items['user/%user/bookmarks'] = array(
    'title' => 'My Bookmarks',
    'description' => 'Link to My Bookmarks',
    'page arguments' => array(1),
    'access callback' => 'user_is_logged_in',
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'user-menu'
  );

  return $items;
}


texts:
When I construct unattended installation using for instance:

drush site-install my_inst_profile \
  --account-mail='helpdesk@acme.com' \
  --account-name='siteadm' \
  --account-pass='sitepass' \
  --db-su='dbadm' \
  --db-su-pw='dbpass' \
  --db-url='mysql://drupal:drupal@mysqldb/drupal' \
  --locale='pl' \
  --site-mail='site@acme.com' \
  --site-name='MY Site' \
  --yes

and even the simplest possible installation profile my_inst_profile.info.yml, my_inst_profile.install and my_inst_profile.profile taken directly from How to write a Drupal 8 installation profile, the resulted installation is malfunctioning.

The symptoms are as follows:

Lack of the middle part of the GUI

No administrator role in the resulted system
Stark theme used as a default one even if info.yml file indicates any other theme.

It is relatively easy to handle 2 and 3 using:

drush role-create 'administrator'
drush config-set user.role.administrator is_admin true

and

drush pm-enable seven --yes
drush config-set system.theme admin seven --yes

respectively.
But the first one exceeds my Drupal capabilities.

There is some discussion and an issue queued on the net (see Adding translations to installation profile upon installation), but the proposals are no longer valid, as there is no /includes/locale.inc and even locale_add_language(), in Drupal 8.

Does anybody have any hints, on how to bring together ambition to use custom distribution with necessity to build localized site?

Addendum 1

Here is my_inst_profile.info.yml

name: my_inst_profile
type: profile
description: 'Installation profile dedicated for ACME company.'
core: 8.x

distribution:
  name: ACME Installation Profile

# Required modules
dependencies:
  - node
  - history
  - block
  - block_content
  - breakpoint
  - color
  - config
  - comment
  - contextual
  - contact
  - quickedit
  - help
  - image
  - options
  - path
  - taxonomy
  - dblog
  - search
  - shortcut
  - toolbar
  - field_ui
  - file
  - rdf
  - views
  - views_ui
  - editor
  - ckeditor

themes:
#  - bartik
  - seven
#  - stark

Here is my_inst_profile.install

<?php
/**
 * @file
 * Install, update and uninstall functions for the profilename install profile.
 */

/**
 * Implements hook_install().
 *
 * Perform actions to set up the site for this profile.
 *
 * @see system_install()
 */
function my_inst_profile_install() {
  // First, do everything in standard profile.
  include_once DRUPAL_ROOT . '/core/profiles/standard/standard.install';
  standard_install();

  // Can add code in here to make nodes, terms, etc.
}

Here is my_inst_profile.profile

<?php
/**
 * @file
 * Enables modules and site configuration for a standard site installation.
 */

use Drupal\Core\Form\FormStateInterface;

function my_inst_profile_form_install_configure_form_alter(&$form, FormStateInterface $form_state) {

  $form['site_information']['site_name']['#default_value'] = 'MY Site';
  $form['site_information']['site_mail']['#default_value'] = 'helpdesk@acme.com';
  $form['admin_account']['account']['name']['#default_value'] = 'siteadm';
  $form['admin_account']['account']['mail']['#default_value'] = 'helpdesk@acme.com';
  $form['regional_settings']['site_default_country']['#default_value'] = 'PL';
  $form['regional_settings']['date_default_timezone']['#default_value'] = 'Europe/Warsaw';

}

// Add any further custom code here like hook implementations.

As I mentioned at the beginning, this is just a starting point for further installation profile development.


texts:
Just to be sure, which solution is better when I export / import DB ?

just exclude Users table from my dump export ?
keep exporting users
table but exclude users table content from my dump export ?

Because I would to to have different access code between production and developpment websites.
Thanks

EDIT: to @sanzante
just a test on a dev website, and I get an error:

drush @pfdevd6mg sql-sanitize --sanitize-password=newpassword
PHP Warning:  Module 'curl' already loaded in Unknown on line 0

The following operations will be done on the target database:
 * Reset passwords and email addresses in users table
 * Truncate Drupal's sessions table

Do you really want to sanitize the current database? (y/n): y
Sanitize query failed.

does alias aren't possible ?


texts: How add CVV's custom validation before order review in Ubercart

texts:
I'm developing a Gateway Payment module for Ubercart. It is necessary to validate that the User does not digit three ceros -000- (bank policy) before the order review form. I've seen that Ubercart does the CCV's validation in the uc_credit.module

      if (variable_get('uc_credit_cvv_enabled', TRUE) && !_valid_cvv($cc_data['cc_cvv'])) {
        if (!$silent) {
          drupal_set_message(t('You have entered an invalid CVV number.'), 'error');
        }
      $return = FALSE;
      }

How could I add my validation without hacking Ubercart modules.

Thanks in advance.


texts: how can I make a welcome popup window upon visiting the website

texts:
Some clients I have may want a popup when a user visits the site if they have special events going on, and display maybe a flyer in a popup.

How can I force a popup upon a user visiting the site? Is there a module that can accomplish this? If not, what kind of edits am I looking at doing?


texts: Ajax Callback Function in Submit Button Doesnt Work

texts:
I have a submit button in my form and I want to implement it using ajax:

function myid_user_page_form(){

   drupal_add_library('system', 'drupal.ajax');

   $form = array();

   $form['id'] = array(
       '#type' => 'fieldset',
       '#title' => t('ID Information'),
       '#prefix' => '
',
       '#suffix' => '
'
   );

   $form['submit'] = array(
      '#type' => 'button',
      '#value' => 'Save',
      '#ajax' => array(
         'event' => 'click',
         'callback' => 'myid_user_page_form_ajax_submit',
         'wrapper' => 'myid_search_id_number_wrapper'
      ),
      '#attributes' => array(
        'id' => 'myid_save',
    ),
);

function myid_user_page_form_ajax_submit($form, &$form_state) {
    watchdog('Wow','Wow');
}

After executing the code above, the page still has it's refresh after it's clickfunctionality. The ajax doesnt work and no Wow message log in my watchdog table from my database, which means the ajax callback function isn't called. Where am I missing?


texts: Load published nodes of certain content type

texts:
I have to load nodes of certain content type that are published.

Any built in function already available for this purpose?


texts: Is there a way to run drush updb without going to maintenance mode

texts: I have a live site which runs on drupal 8. I am using drush 8.5.3 with the installation. Whenever I run drush updb the site automatically goes to maintenance mode. Is there a way to do this without going to maintenance mode. In simple words, can I use drush updb with my site running?


texts: How To Wrap Multiple Content Field Items In Li Tag

texts:
I've got an issue with a field called Track Listing. As the title states it is a Text(plain) type with unlimited possible values so that I can input as many as I'd like. The machine name is: track_listing

As it stands I'm outputting the label and items using: {{ content.field_track_listing }} which gives me this:

But I'd like to be able to wrap the field in an ol tag in addition to every track with a li tag to be able to get a nice ordered numbered list. Using twig templates I've wrapped it accordingly but find it only targets the first value which is in this case the label as seen here:

I feel that I should be using a for/if loop in order to get the right values since removing the label only wraps the first item as well. If anyone has an article I can check out to point myself in the right direction I would appreciate it, thank you.


texts:
Using Drupal 7, I'm working on a module and want to have it so when the module is installed it will set a new node type called "project" When a user is adding/editing a $note->type="project" I want to bring up a custom editor for my module that is for that node type. I have been looking for tutorials for nodes and editors for nodes but I wasn't able to find any good examples of making a custom node type and making and assigning a custom editor for a node type.

I also don't know what hooks I need to use to target the node editor. As of right now I'm following the steps from the following tutorial. http://www.sitepoint.com/creating-a-new-drupal-node-type/


texts: IMCE buttons are missing and cannot delete files

texts:
I'm using the latest version of Filefield Sources and IMCE.

I've set up the profile we're using to be able to do everything they should need to be able to do:

However, when I try to manage any of the files there I cannot do anything other than upload a new file.

What am I missing?


texts: Can a Calendar, based on two different content types, output different html based on content type

texts: I built a calendar based on two different content type, let's call them A and B. For each type I output the Title field and, along with it, I'd like to have a link to the node if the Title field belongs to type A and just plain text if it belongs to type B. Is there a way to do this?


texts:
I would like to create a sidebar in node.tpl.php that prints the parent menu items of the current page with a depth that follows the current page's depth by one level.

So if I have a menu structure like:

A
B
C
--C1
--C2
--C3
D

... and I am on page B, I would see in the sidebar:

A
B
C
D

... or if I am on page C2 I would see in the sidebar:

C1
C2
C3


texts: Custom form throws 'Cannot unset string offsets' error

texts:
I'm trying to build a form for my custom entity and so far the form is looking pretty good. However, when I press the Save button I get this error:

The website encountered an unexpected error. Please try again later.
Error: Cannot unset string offsets in Drupal\Core\Field\WidgetBase->extractFormValues() (line 367 of core/lib/Drupal/Core/Field/WidgetBase.php).

Drupal\Core\Field\WidgetBase->extractFormValues(Object, Array, Object) (Line: 231)
Drupal\Core\Entity\Entity\EntityFormDisplay->extractFormValues(Object, Array, Object) (Line: 338)
Drupal\Core\Entity\ContentEntityForm->copyFormValuesToEntity(Object, Array, Object) (Line: 304)
Drupal\Core\Entity\EntityForm->buildEntity(Array, Object) (Line: 159)
Drupal\Core\Entity\ContentEntityForm->buildEntity(Array, Object) (Line: 190)
Drupal\Core\Entity\ContentEntityForm->validateForm(Array, Object) (Line: 139)
Drupal\worklog\Form\WorklogForm->validateForm(Array, Object)

This is the code for the form:

public function buildForm(array $form, FormStateInterface $form_state) {
    if (!$form_state->has('entity_form_initialized')) {
      $this->init($form_state);
    }

    /* @var \Drupal\worklog\Entity\WorklogInterface $entity */
    $entity = $this->entity;

//    $form = parent::buildForm($form, $form_state);
//
//    return $form;

    $form['customer'] = [
      '#type' => 'entity_autocomplete',
      '#target_type' => 'node',
      '#selection_handler' => 'worklog',
      '#selection_settings' => [
        'target_bundles' => 'klant',
      ],
      '#title' => $this->t('Customer'),
      '#default_value' => $entity->getCustomer(),
      '#weight' => 5,
    ];

    $form['date'] = [
      '#type' => 'date',
      '#title'=> $this->t('Date'),
      '#default_value' => $entity->getDate()->format('Y-m-d'),
      '#weight' => 10,
    ];

    $form['hours_worked'] = [
      '#type' => 'number',
      '#title' => $this->t('Hours worked'),
      '#default_value' => '',
      '#weight' => 15,
    ];

    $form['description'] = [
      '#type' => 'textarea',
      '#title' => $this->t('Work description'),
      '#default_value' => $entity->getDescription(),
      '#weight' => 20,
    ];

    $form['actions'] = [
      '#type' => 'actions',
      'submit' => [
        '#type' => 'submit',
        '#value' => $this->t('Save')
      ]
    ];

    return $form;
  }

As far as i can tell I'm not doing any weird things inside this code. The code also only seems to have a problem when it encounters the 'hours_worked' field which doesn't make sense to me.

This seems like a very specific issue and I haven't been able to find any solutions to this, so I hope anyone knows what to do. Thanks


texts:
let say i have two tags in my website.

one is football and the other is basketball.

and let say that i have 3 articles tagged with football and 10 tagged with basketball.

and the total comments and views on all 3 football tagged articles = 9 comments + 100 views.

while the 10 basketball tagged articles = 3 comments + 90 views.

now i want a block that lists this tags by activity

and that would be like that :

Most popular tags :

1- football (beacause 3 articles + 9 comments + 100 views = 112)

2- basketball.(beacause 10 articles + 3 comments + 90 views = 103 < 112)

thank you very much.


texts: Overriding exposed filters: Twig has no effect

texts:
I want to change the HTML output for exposed filters of given view, on fresh new installation of Drupal 8 (no modules were added to it).

I tried to override views-ui-expose-filter-form.html.twig inside my theme's /templates folder, but it doesn't replace the default implementation. The theme itself works fine; for example, I can override the front page.

The file's description is here: https://api.drupal.org/api/drupal/core%21modules%21views_ui%21templates%21views-ui-expose-filter-form.html.twig/8.2.x.

What am I doing incorrectly? Should I override another template file, or turn something on in the system for it to work, or the filename is wrong?


texts: How do you embed addtional RSS feeds into the  section of your theme

texts: I have 5 RSS feeds I am looking to embed into the <head> section of the page. What is the best way to accomplish this on drupal 7?


texts:
I'm trying to develop a module that creates a form and a view that displays that page.

In my module I used hook_menu() and hook_form().
Also I saw some tutorials 1 & 2

What I cannot understand where & how to add my form to the view?


texts: How to get Node IDs of nodes whose titles contain a certain string?

texts:
I'm trying to get a list of nodes whose titles contain a given string, in this case the term name of a term attached to another node.

Based on other answers I've found online, I've thought this could work:

$sql = 'SELECT title FROM {node} WHERE title LIKE :title';
$result = db_query($sql, array(':title' => '%' . db_like($term->name)));

That's giving me a response but it's all empty, which makes no sense.

Here's what the response looks like:

DatabaseStatementBase Object
(
[dbh] => DatabaseConnection_mysql Object
    (
        [needsCleanup:protected] =>
        [target:protected] => default
        [key:protected] => default
        [logger:protected] =>
        [transactionLayers:protected] => Array
            (
            )

        [driverClasses:protected] => Array
            (
                [SelectQuery] => SelectQuery
                [MergeQuery] => MergeQuery
                [UpdateQuery] => UpdateQuery
                [DatabaseSchema] => DatabaseSchema_mysql
            )

        [statementClass:protected] => DatabaseStatementBase
        [transactionSupport:protected] => 1
        [transactionalDDLSupport:protected] =>
        [temporaryNameIndex:protected] => 0
        [connectionOptions:protected] => Array
            (
                STUFF
                    (
                        [default] =>
                    )

            )

        [schema:protected] => DatabaseSchema_mysql Object
            (
                [connection:protected] => DatabaseConnection_mysql Object
*RECURSION*
                [placeholder:protected] => 0
                [defaultSchema:protected] => public
                [uniqueIdentifier:protected] => 5670ef6385b8e5.94304345
            )

        [prefixes:protected] => Array
            (
                [default] =>
            )

        [prefixSearch:protected] => Array
            (
                [0] => {
                [1] => }
            )

        [prefixReplace:protected] => Array
            (
                [0] =>
                [1] =>
            )

    )

[queryString] => SELECT * FROM node WHERE title LIKE :title
)

Do I need to do something like this using CONTAINS instead?

$sql = 'SELECT title FROM {node} WHERE CONTAINS(title, :title)';
$result = db_query($sql, array(':title' => '%' . db_like($term->name)));


texts:
I have a custom content type that has a date field.
I have created a view with a exposed filter. The issue i have is that the exposed filter is in the form Y-M-D and i wan it to be just M-D. I have altered the exposed form, setup the #format to M-D and now the Y field is hidden. But it's still trying to validate it. and nothing shows up when you select values in the filter.