texts: An issue with multiple routes with its own twig template of custom module

texts:
First time I am creating a custom module in Drupal 8. I have some pages having only HTML markup and JS code.

Assume I have 3 pages flow and user goes to 1st page (next button) -> 2nd page (next button) -> 3rd page.

To achieve it I have created a custom module as below. My custom module requires multiple routes with its own separate twig/view template.

The name of my module is custom_demo and it is created at /web/modules/custom/custom_demo with necessary artefacts as below.

The issue is first 2 pages work, the moment I click on next button to go on 3rd page, it does not work and shows The requested page could not be found. message.

Working

http://mysite.dd:8083/mypage/page1

http://mysite.dd:8083/mypage/page2

Not Working

http://mysite.dd:8083/mypage/page3

custom_demo.info.yml

name: Demo
type: module
description: 'Demo Description'
package: Custom
core: 8.x

custom_demo.routing.yml

custom_demo.page1:
   path: '/mypage/page1'
   defaults:
      _controller:
        '\Drupal\custom_demo\Controller\DemoController::page1'
     _title: 'test title1'
   requirements:
   _permission: 'access content'

custom_demo.page2:
   path: '/mypage/page2'
   defaults:
     _controller: '\Drupal\custom_demo\Controller\DemoController::page2'
     _title: 'test title2'
  requirements:
    _permission: 'access content'

custom_demo.page3:
  path: '/mypage/page3'
  defaults:
    _controller: '\Drupal\custom_demo\Controller\DemoController::page3'
    _title: 'test title3'
  requirements:
    _permission: 'access content'

custom_demo.module

<?php

function custom_demo_theme($existing, $type, $theme, $path) {
return array(
  'demo_page1' => array(
    'variables' => array('title' => NULL),
    'template' => 'demo-page1',
  ),
  'demo_page2' => array(
    'variables' => array('title' => NULL),
    'template' => 'demo-page2',
  ),
  'demo_page3' => array(
    'variables' => array('title' => NULL),
    'template' => 'demo-page3',
  ),
);
}

/src/Controller/DemoController.php

<?php

 namespace Drupal\custom_demo\Controller;

 use Drupal\Core\Controller\ControllerBase;

 class DemoController extends ControllerBase {

public function page1() {
    return array(
        '#theme' => 'demo_page1',
        '#title' => 'test title1',
    );
}

public function page2() {
    return array(
        '#theme' => 'demo_page2',
        '#title' => 'test title2',
    );
}

public function page3() {
    return array(
        '#theme' => 'demo_page3',
        '#title' => 'test title3',
    );
 }
}

Twig templates

Under custom module folder I created the folder /templates and created following 3 files with some test content.

demo-page1.html.twig
demo-page2.html.twig
demo-page3.html.twig

Can someone please help, why the http://mysite.dd:8083/mypage/page3 is not woking?

Thanks - Hitesh


texts: LoginToBoggan & OneAll Social Login: one-time-login token email sent withoud need

texts:
When you have installed LoginToBoggan AND the OneAll Social Login modules (to enable login via Facebook, Google etc.) - they seem to work not nicely together.
LoginToBoggan provides a nice one-time-login token and Drupal sends out an email for every user to confirm the email address after signup.
But: when you signup with a e.g. Google Account, LoginToBoggan assumes that this email address is already confirmed and does NOT put the user in the pre-authenticated role - the user is authenticated at once...

There would be no problem with that, if the user did not get an email that asks him to confirm his mail address with a one-time link. And if the user clicks on that link, he gets a message on the page that this link is not valid, as the token "can only be used once" - as if it was already used.

When signing up just in Drupal (without Google, Facebook etc. SocialAll module), this email makes perfectly sense and the token works. It just does not work when signing up via SocialMedia.

Does anyone have a hint here? can I disable this mail under the circumstance that the account was created using the OneAll Social plugin? Where do I have to put that code in?

Any help appreciated.


texts: Drupal 8 Customize CKEditor Format Options

texts:
Drupal 8.4.x

I am trying to add custom formats to the ckeditor dropdown.

Having the Geshi Filter module installed it would be nice to have the tags associated with the different languages available as a format option for users.

Following a reply here: https://drupal.stackexchange.com/a/244331/79805, I have success adding the "div" tag, but seem unable to add anything else like a "css" tag or even a "span" tag.

Is it possible to add custom tags to the format list?

This is the function running right now from user @rémy:

function ckeditor_add_format_tags_editor_js_settings_alter(array &$settings) {

    foreach (array_keys($settings['editor']['formats']) as $text_format_id) {
        if ($settings['editor']['formats'][$text_format_id]['editor'] === 'ckeditor') {
            $settings['editor']['formats'][$text_format_id]['editorSettings']['format_tags'] .= ";div";
        }
    }

}


texts: Better way to associate ticket quantities with event dates?

texts:
I'm fairly new to events in Drupal 7 but I have at least spent a few days now investigating strategies for my use case. Unfortunately, I haven't found a single relevant piece of info.

I have some recurring events that need to have a remaining tickets number associated with each event date. Some of these events are literally movies in a museum and teachers need to be able to see how many tickets are available for each show time when selecting dates and times for their field trips. Thus, movie show times is a useful (and accurate) model for this issue.

Within a single event node it's simple enough to create multiple date fields and multiple remaining tickets fields for the event. However, I've not been able to figure out how to associate a given remaining tickets number with a specific event date. So far, I only have lists of unrelated dates and numbers.

The alternate "solution" I've come up with is to have an event description node and numerous distinct event date (show time) nodes. The event date (show time) nodes would contain the event date and the tickets remaining for that date. However, I can't think of a way of explicitly connecting the event date nodes to the relevant event description node other than also including the node id in the event date nodes (which, for other reasons, is far from ideal).

Does anyone more experienced with events know whether this explicit connection is even likely to be needed? Even better, can anyone point me in a less cumbersome direction (e.g., associating the tickets required numbers with the right dates, all in one node, instead of creating separate event date nodes)?

Thanks so much for any and all assistance you're able to give!!!
James Baker


texts: How to create a main menu with dropdown?

texts:
I want to create a main menu with dropdown. There will be collapsed links in each menu heading. When the user hovers over one heading, links accompanied by that header will be displayed in a box.

I first tried to add node and give them parent nodes. For example, I have created a node with title called "Lorem" and created another with title called "Ipsum". I have provided both of them a menu link. I have set the "Lorem" node as the parent node of "Ipsum". But it seems like "Ipsum" doesn't appear in "Lorem"'s content of its menu link.

Is there any way to look up the links' child elements? For example:

dpm($main_menu);

This doesn't yeild me neither the link that connected to "Ipsum" or the "Lorem"'s child links. How can I see the "Lorem"'s child link? Or where it is?

If I can find it, I can override the theme_links and create dropdowns.


texts: View listing A filtering on B with a reference B -> A

texts:
Here's my problem : I have a view that lists nodes of type A (A = tips). In my Drupal, I have another content type B (B = vegetables), which has a multiple node reference with A.

So, what I want is a filter in my view, which is a select on all the nodes B. When the user select a B node, the view should display all the nodes A which are related to B, depending on the field multilple node reference in B.

I tried with relations, exposed form alter and query alter, but I can't achieve that, and I'm getting a little bit confused with that...

How could I do that ?
Thanks.

EDIT: more informations !
I don't think it can works with relations, because when I print the SQL request of the view, I can see that it's doing it the wrong way. For example, I add a relation in my view on the field "Preparation tips" in B (= vegetables). Here's the left join the views does :

SELECT node.title AS node_title, node.nid AS nid, node.language AS node_language, node.created AS node_created, 'node' AS field_data_field_tip_main_picture_node_entity_type
FROM
{node} node
LEFT JOIN {field_data_field_vegetable_preparation_tips} field_data_field_vegetable_preparation_tips ON node.nid = field_data_field_vegetable_preparation_tips.entity_id AND (field_data_field_vegetable_preparation_tips.entity_type = 'node' AND field_data_field_vegetable_preparation_tips.deleted = '0')
LEFT JOIN {node} node_field_data_field_vegetable_preparation_tips ON field_data_field_vegetable_preparation_tips.field_vegetable_preparation_tips_nid = node_field_data_field_vegetable_preparation_tips.nid
WHERE (( (node.status = '1') AND (node.type IN  ('tip')) ))
ORDER BY node_created DESC
LIMIT 10 OFFSET 0

That's why it doesn't work : ON node.nid = field_data_field_vegetable_preparation_tips.entity_id. field_data_field_vegetable_preparation_tips.entity_id contains Vegetables ids, not Tips ids. Maybe I don't set the good relation in my view ? I don't know...


texts: Autopopulate a different field if node reference autocomplete doesn't have a matching candidate?

texts:
I've got a form for non logged in users to submit an event, which then goes in to a moderation queue via rules. At the moment, when an authenticated user adds an event, they've got the option to either pick a venue from a list of already populated nodes (field_venue), or specify a venue in plain text if the venue isn't a node (field_venuetext).

I'd like to make this a bit easier for non-authenticated users and just provide one field which is a node reference autocomplete field. If the user just types a venue and doesn't select from the autocomplete, it will populate the plain text field (field_venuetext). Looking at the nodereference.module source, I can see the function I'd like to change (nodereference_autocomplete_validate), and I guess, I'd do something like this:

function nodereference_autocomplete_validate($element, &$form_state) {
  $field_name = $element['#field_name'];
  $type_name = $element['#type_name'];
  $field = content_fields($field_name, $type_name);
  $field_key  = $element['#columns'][0];
  $delta = $element['#delta'];
  $value = $element['#value'][$field_key];
  $nid = NULL;
  if (!empty($value)) {
    preg_match('/^(?:\s*|(.*) )?\[\s*nid\s*:\s*(\d+)\s*\]$/', $value, $matches);
    if (!empty($matches)) {
      // Explicit [nid:n].
      list(, $title, $nid) = $matches;
      if (!empty($title) && ($n = node_load($nid)) && trim($title) != trim($n->title)) {
        form_error($element[$field_key], t('%name: title mismatch. Please check your selection.', array('%name' => t($field['widget']['label']))));
      }
    }
    else {
      // No explicit nid.
      $reference = _nodereference_potential_references($field, $value, 'equals', NULL, 1);
      if (empty($reference)) {
        // *** CHANGE *** At the moment, this generates an error, but I would like to populate the field 'field_venuetext'
        form_error($element[$field_key], t('%name: found no valid post with that title.', array('%name' => t($field['widget']['label']))));
      }
      else {
        // TODO:
        // the best thing would be to present the user with an additional form,
        // allowing the user to choose between valid candidates with the same title
        // ATM, we pick the first matching candidate...
        $nid = key($reference);
      }
    }
  }
  form_set_value($element, $nid, $form_state);
}

However I'm not sure how I'd override it, or indeed how I'd populate the field field_venuetext. I'm new to Drupal, so not 100% sure where to go next. Any ideas?


texts: How can I find all the listeners or subscribers to the KernelEvents:REQUEST event?

texts:
More specifically, how could I find the subscribers performing the routing system for Drupal?

We tried using ddebug_backtrace(), but I couldn't get anything.


texts: When adding media to content, how can I search for the media by tag or term?

texts:
In Drupal 8, I created a new Media type "PDF Files." I have imported almost 30,000 of them, each complete with Title (Name), file, and the taxonomy that categorizes them.

On the content type (Let's say the default Article, for example) I've added an entity reference field and the ability to locate a file via the Entity File Browser project (https://www.drupal.org/project/entity_browser).

This is working well enough, but it searched via the Name field only by default.

How can I accomplish the same thing but searching by comma separated tags?

So, each file has a tag structure TAG1, TAG2, TAG3.

In the search field for the file while in the content type, if I type in TAG1, TAG3 then all the files with that combination of tags should come up.

Before I dive into a custom script or extending the entity browser, wanted to make sure this isn't something simple I'm overlooking. (Just now getting into D8 after a long D7 background).

UPDATES:

So as has been suggested in the comments, use a view as a reference. It seems that choosing a view reference requires that the view be an Entity Reference (instead of type Page, Block, etc.) But, it seems that Media doesn't have the ability to search by tag. This Drupal project seems to try to address that - https://www.drupal.org/project/media_taxonomy_filter but no luck.

Also, another hurdle I seem to have hit is that when creating a View of type Media, there is no taxonomy field filter. This seems odd in that Media now can be categorized with taxonomy. Is that right? Like, for the admin media page which is powered by a view, can I not filter that by taxonomy?


texts: Invalidate a specific cache tag on any saved taxonomy term

texts:
I would like to clear cache tag of a particular bundle when any taxonomy terms are update/ saved.

I know the default node tag is saved like node:1, node:2, but I'm confused on how to invalidate a particular bundle.


texts: Set Views page title based on content being viewed via contextual filter

texts:
I have a view page that shows a single node based on a contextual filter that looks at an aliased path version of the title. For example my URL might be
http://www.tacoland.com/resources/npr-story-about-tacos
and I want to set the page title to be NPR Story About Tacos (the node title).
I see how I can change the title with the value from the URL within the contextual filter settings, but I want it to be the proper node title.
My issue is basically like this one, but for D8: Views Page Title Based on URL


texts:
I am trying to embed a timeline of tweets to my website's sidebar. I am using Drupal 8. The module "Twitter Block" requires a widget ID but Twitter has stopped providing widget ids and only generates html code but I don't know at which file should I embed this code to. Is there any other way? Any suggestions?
Thank you.


texts: no description and image title in insert module

texts:
I am using insert module in drupal 6.

How come I have no description and image title just like this https://www.drupal.org/files/images/insert-module.png


texts:
I've attempted to move the footer structure of a theme from page.tpl to html.tpl so the footer elements can occur outside of internal width specific layout.

In doing so I receive an error:

  Fatal error: Only variables can be passed by reference in....

One of the many lines in question is:

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

Can someone explain what exactly the issue is here and how I can best solve it ? Muchly appreciated!


texts:
I'm trying to display values of the scheduler module fields publish_on and unpublish_on. Does anybody know where to find them? I cannot find them in /admin/structure/types/manage/article/fields.
I was also trying to find them using twig {{ }}, but it was unsuccessfull too.
Thanks in advance for any help!


texts: Can I prevent Administrators from Updating Modules?

texts:
So I had an issue yesterday where a module was updated on one of my sites that I wasn't ready for it to be updated on.  It caused some issues, but I was eventually able to get the previous version back from my test server and it is working normally again.

My guess is that someone with administrative rights (but not User-1) was able to update the module from the web interface.  Is there a way to prevent anyone from updating modules except User-1?


texts: Where should I store 3rd Party external js libraries?

texts:
This is a follow up to Define JavaScript library in Drupal 8

I have a third party library that I don't want to bundle with a module. In Drupal 7 I could just ask the user to extract to sites/all/libraries what is the best practice in Drupal 8?


texts:
I am new to Drupal, I sub-themed a contributed theme and it works fine. From mytheme.info, I added my css stylesheets[all][] = css/style.css and it works fine.

Right now my admin account is logged in Firefox. From Firefox I created a basic page that contains the following:

/* Content of my Basic page, Text Format is Full HTML*/
<div class="test">
Hello
</div>

/* From my css file */
.test {
    width: 100px;
    height: 10px;
    border: 1px solid black;
}

When I saved it and look at the preview, my <div> doesn't have the border property, but when I checked it using other browser (Chrome, Safari & IE) the border for div was there.

What happened? Please help!


texts: How to populate an autocomplete using a web service?

texts:
I want to populate a form field, an autocomplete widget, with values from an external REST web service without actually importing the data to my database first (on-the-fly).

How do I do that? Is there a module for that or do I need to create one myself?


texts: Modify URLs generated by CKEditor Link for specific node type

texts:
How do you alter the URL generated by CKEditor Link, for a specific content type.

For example I have book_section content type. If a content editor links to a node with type of book_section I want to step in and link to a fragment/anchor within the parent node instead. The convention of my anchor ids are <a id="/node-alias" />

As per documentation provided by the CKEditor Link module author I've used hook_ckeditor_link_types and hook_ckeditor_link_TYPE_url in a custom module to make the following modifications.

/**
 * Implements hook_ckeditor_link_types
 */
function ajf_ckeditor_link_types() {
    return array('book_section');
}

/**
 * Implements hook_ckeditor_link_TYPE_url
 *
 */
function ajf_ckeditor_link_book_section_url( $path, $langcode ) {
    if (!preg_match('`^node/(\d+)$`', $path, $matches)) {
        return;
    }

    $nid = $matches[1];
    $node = node_load( $nid );

    if ( 'book_section' != $node->type ) {
        return;
    }

    $parent = menu_link_load( $node->book['plid'] );
    $options = array( 'fragment' => '/'. $node->path['alias'] );
    $url = ckeditor_link_url( $parent['link_path'], $langcode, $options );
    return $url;
}

When viewing a page with links to book_section nodes I'm getting an empty response from the server. I'm thinking the repeated node_load calls is exceeding the servers resources.

Appreciate advice you may have.


texts: How to make a Custom Field available as View Relationship?

texts:
I'm trying to match the data of a field to a contextual value but I cannot find my desired field in the relationships list.

Do I have to something special to this field to get it to show up under relationships?


texts:
Drupal7, how to make nice rss news (self updating) feed with Mayo?

exemple: http://www.pawsdogdaycare.com/ look" dog news


texts: I'm on drupal 8.3, I have do the same for the view block and it's ok just for the admin user, but for authenticated users, the block does not appear, what should I do?


texts:
I've just used panels to display child terms on taxonomy pages. For example If my heirarchy is like this...

Catalogue
--Category 1
----Sub Cat 1 (contains nodes)
----Sub Cat 2 (contains nodes)
----Sub Cat 3 (contains nodes)
--Category 2
--- Sub Cat 4 (contains nodes)

...the 'Category 1' page shows links to Sub cats 1, 2 and 3. That's working fine.

The problem is that once you get to one of the sub categories that contain nodes, the node teasers are not displaying. Is there a way of making these display?


texts: How to create a fieldset in a node form, that expands with ajax

texts:
I have a (view of a ) tasks list on a page, and also a form block where users can add a new tasks.
I want to increase page load time by hiding some fields in the tasks form block, which can expand using ajax by clicking on "task details" link (the fieldset label)

Is this is possible without programming?


texts: Path breadcrumbs Link title for webform submission

texts:
I have one Webform field call "Name". I use views to retrieve Webform result and edit link. I am using Path breadcrumbs module.

Example:

UserA - Edit
UserB - Edit
UserC - Edit

User A, B, and C had submitted the form. When I click edit, it will goes to their submission form where they can edit the info again.

When I click on the link, I hope breadcrumb will display "Name"

Example:

home > UserA
instead of
home > webform

home > UserB
instead of
home > webform

home > UserC
instead of
home > webform

Name is text. Link is not needed.

Can I add it to breadcrumb link title? How to do that?


texts: Ubercart: Store configuration for role based user

texts:
I want these options such as show orders, sales report, product reports, customer reports,sales tax report which are available in store configuration of ubercart to be available for seller login(seller Role).

But for seller I want to show his orders alone like wise only related to his products all options. Is there a way for that?


texts: (Newbie question) Something goes wrong here with db_add_field

texts:
I'm trying to adapt that D6 module to D7.
I'm on the "add afield" part of .install

Here's my code :

function node_statistics_install() {
    db_add_field('accesslog', 'nid', array(
    'description' => 'Field added by node_statistics',
    'type' => 'int',
    'not null' => TRUE,
    'unsigned' => TRUE,
    'length' => 11,
    'default' => 0,
  ));

but nothing happens in the database on install, no errors in drupal logs...
Am I missing something?


texts: Drupal Commerce : Shipping Calculator for Shipping Service

texts:
In my Product Add page, Seller can select Shipping service. I am using FedEx, USPS and UPS for my website.
Here there would be a link for shipping cost calculation.
By clicking on that link, it would open up a Shipping Calculator window from where Seller can add product dimensions and weight and select from available shipping services. By clicking on submit button, window would be closed and Selected Shipping Service and it's cost would be added into Textbox.

Is there any Shipping Cost calculator available in Drupal ?


texts: How do I configure Apache and Varnish with both HTTP and HTTPS access and prevent mixed content error?

texts:
I have Drupal 7 installed on Ubuntu server with apache2 and varnish. I was asked to provide both http and https access to the site.

To utilize Varnish I setup apache reverse proxy to redirect all https traffic to varnish(http). Now I can access my site via http/https protocols fine.

However, when I load any https page with images in it, all images are served via http, thus making browsers issue a warning about mixed content. I would like to suppress that.

To suppress that, I changed $base_url to https:// in site/default/settings.conf and that worked fine for all https pages.

However, I experienced the same mixed content error while loading normal http pages (images were served via https this time.) Then, I created an if statement trying to differentiate between http and https and assigning different $base_url values accordingly.

I have tried using $_SERVER['']  array variables as well as $is_https, and nothing seems to be working.

I also used $GLOBALS[''] variable to make sure variables are defined. I would clear the Drupal cache as well as browsers before each testing. However, when I access https version of a site, all is rendered ok and everuthing is fine. But when I access http, all images are served with https. I would clear cache again, and try accessing http first, and everything would be fine. But when I access https after that, images would be served with http. So, the logic within settings.conf is fine, but possibly caching makes browsers/Drupal to serve images with the protocol they were first accessed (be it http OR https).

My question: is there a way to assign $base_url dynamically based on the protocol used?

Some of the settings I have tried:

-----------------------------------
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
        $_SERVER['HTTPS']='on';
        $base_url = 'https://';
        }
else {
         $_SERVER['HTTPS']='';
         $base_url = 'http://';
}
-------------------------------------
#if (isset($GLOBALS['$is_https'])) {
#       $_SERVER['HTTPS']='on';
#       $base_url = 'https://example';
#       }
#else {
#        $_SERVER['HTTPS']='';
#        $base_url = 'http://example';
#}
---------------------------------------
$base_url = '//example'
---------------------------------------
$base_url = '';
---------------------------------------


texts: How to use user wildcard in a custom path?

texts:
I have configured my user path alias pattern as consultant/[user:name]. Now I need to have one custom path from my custom module as consultant/[user:name]/job. Here is my  code in hook_menu.

 $items['user/%user/job'] = array(
'title' => 'Apply for job',
'page callback' => 'job_application_page',
'access arguments' => array('access content'),
'file' => 'job.pages.inc',
'type' => MENU_CALLBACK,

);

I want the url as follows

For user Joan the path should be consultant/joan/job. But this is not working, giving an 404 error page

Do I miss something? Please advise.


texts: Get blank value if field value is not available

texts:
I have following query on my D7 project

$query = db_select('payment_logs', 'p');
$query->join('field_data_field_frequency', 'd', 'd.entity_id = p.nid');
$query->join('field_data_field_maid_id', 'm', 'm.entity_id = p.nid');
$query->join('field_data_field_coupon_code', 'c', 'c.entity_id = p.nid');
$query->join('field_data_field_tip_amount', 't', 't.entity_id = p.nid');
$query->fields('p');
$query->fields('d', array('field_frequency_tid'));
$query->fields('m', array('field_maid_id_uid'));
$query->fields('c', array('field_coupon_code_value'));
$query->fields('t', array('field_tip_amount_value'));
$query->condition('p.section','booking','=');
$result = $query->execute();
$res = $result->fetchAll();
return $res;

this query returns data where field_tip_amount_value and field_coupon_code_value are available. I want to get all data with blank field values if not available. these two fields are optional other fields will be there always. so if tip or coupon is not there data must return blank for this field.

I was doing it with separate queries before but it was taking too much time with multiple loops. is there a way to get it done with join ?


texts:
I am using Ck-editor in drupal sites. If i add the image from ck-editor through URL, it automatically assign the height and width value. I need the width and height field but the value should not be assign after paste the URL on URL field..
How can i achieve this.


texts: Moderate five star ratings given by users

texts:
I want to create an admin interface to moderate the ratings given by site users.

I am using fivestar (d7) module for rating users.

I tried with creating views with editable rating fields, but its not giving the expected results.

How can this be achieved?


texts: How to programmatically hide field from display?

texts:
I want to reproduce programmatically hiding of a field that can be obtain by Manage Display -> Format -> (hidden)

URL: admin/config/people/accounts/fields.

Field I want to hide is added by OG module. Probably. Machine name: og_user_user.

I found one solution based on hook_field_access but I need to find other.

This solution doesn't help me too.


texts: How can I mock a class during a functional request that is called from within a controller?

texts:
I am working on a custom module that from a controller calls Elastic search and returns a search result.  I am trying to write a simple Functional Php Unit test just to make sure the results are displaying correctly.

Here is a simplified version of my funtional php unit test code:

public function testSearchResulsShowUp() {
  $account = $this->drupalCreateUser(['access content']);
  $this->drupalLogin($account);
  $this->drupalGet('/search/term1');
  $this->assertResponse(200);
  $this->assertText('Term 1');
}

Here is a simplified version of my controller:

/**
 * Search controller.
 */
class SearchController extends ControllerBase {

  public function getContent(search) {
    $client = Client::getClient();

    // Client connects to Elastic search and then returns
    // a result.

    ...
    ...

    // Will return Term 1
  }

}

Here is a simplified version of my Client class:

/**
 * Class Client.
 */
class Client {

  /**
   * Get client.
   */
  public static function getClient() {
    $cluster_id = \Drupal::state()->get('elasticsearch_connector_get_default_connector');
    $elasticsearchCluster = \Drupal::entityManager()->getStorage('elasticsearch_cluster')->load($cluster_id);
    $clientManager = \Drupal::service('elasticsearch_connector.client_manager');
    $client = $clientManager->getClientForCluster($elasticsearchCluster);
    return $client;
  }
}

I would like to be able to somehow mock my getClient method so when it is called in the Controller or anywhere going forward it would call the mock instead of the original method.  I know that if this was a true Unit test we would be able to do it but since it is a functional test I am not sure how to do it.


texts: How to avoid "header already sent" warning when loading a pdf

texts:
In drupal 7, when I load a pdf page in a new tab, and after reloading the initial page, I have this warning:

Warning : Cannot modify header information - headers already sent in invoices_callback() (line 1093 in C:\xampp\htdocs\drupal\sites\all\modules\custom_profile\custom_profile.module).
Warning : Cannot modify header information - headers already sent in drupal_send_headers() (line 1221 in C:\xampp\htdocs\drupal\includes\bootstrap.inc).

Actually, I have a link in my initial page (named 'my-account/invoices') which redirects to a PDF page named 'my-account/invoices/%invoice_number'.
This last one is loaded by a 'page callback' function :

function invoices_callback($var){
require_once('sites/all/libraries/dompdf/dompdf_config.inc.php');

$filename = 'Invoice n°' . $var . '.pdf';
$dompdf = new DOMPDF();
    $dompdf->load_html('
Test n° : ' . $var . '
');
    $dompdf->render();
    $dompdf->stream($filename, array('Attachment'=>0));
    header('Content-type: application/pdf');

}

As you see, I didn't use a pdf module, like printer, which is too heavy. I use a custom module which implement a page callback function, and inside I use dompdf library.
The pdf is displayed normally, but when I come back to initial page I have these warnings.

I have tried several things:

I removed the header function. Effect: the first warning is gone but I still have the second. It seems like the stream method of DOMPDF class wants to sent a header...
I have added a charset utf-8 to the header function
I used ob_start() and ob_end_flush() functions at the beginning and at the end of the code. Surprisingly doesn't work.
I lastly use drupal_add_http_header function. Doesn't remove warnings.

What i can do is to call a script in an external link, because my test work when i call a php script located elsewhere. But for the UX, i try to have all my scripts managed by drupal, and i want the invoices to be called by a simple alias url (my-account/invoices/%invoice_number).

So my question is simple: How to avoid these warnings without moving my script to an external location?


texts: Turning page titles to links using hook_page_alter()

texts:
I'm trying to use a hook_page_alter() to change make the title of certain pages a link to another page.

This is the code I would like to alter.

function mashavumodule_page_alter(&$page) {
  // get the user id of the patient
  $user_id = $page['content']['system_main']['nodes'][$nid]['field_user_id']['#items'][0]['value'];

  drupal_set_message(l("View Patient Profile", "user/{$user_id}" ));
}

Currently, I have the link outputting as a system message.

Also as a side note, if there is a more elegant way to get the value of the field_user_id, I'd love to know because typing

$page['content']['system_main']['nodes'][$nid]['field_user_id']['#items'][0]['value']

just doesn't seem right.


texts: How to allow node authors to mark the best comment and to promote this comment on the top of list

texts: In my project comments are prices so its important that commenters see author's choice. I want to allow authors to choose the best comment that would get this comment promoted on the top of a comments list. Can I do it with Rules or some other ways?


texts: How do I use an entity reference field as a sidebar navigation on a view?

texts:
I have 2 content types: category and project. On project, I have a reference field to category.

I would like to list all my nodes from project in a view and then use all the category nodes as links for filtering this list.

I know it is possible with a taxonomy term, but I'm trying to achieve it with a reference field. Is it possible with the view UI?

I'm using Drupal 8.8.2.


texts: Apachesolr search results Facet Filter by date range

texts:
I am using apache solr search with my drupal 6 website and seek a modification in the facets being displayed.

Instead of the yearly facets like this:

to somewhat like this:

last hour
last 24 hours
last week
last month
last year

I found http://searchhub.org/dev/2012/02/23/date-math-now-and-filter-queries/  saying that i can use fq=date:[NOW/DAY-7DAYS TO NOW/DAY+1DAY] in a custom module of my own to do this.

I tried this in my own module and figured out that its the $fq variable of apachesolr.module that should be overriden to achieve this.

I dont think I was able to use it successfully.

Can someone please tell me the exact function and variable to override.


texts:
In this code i want to incerment the value by 4 and not by one .
How Can i do it ?

    select_id' => array(
          'description' => 'TODO: please describe this field!',
          'type' => 'serial',
          'not null' => TRUE,
       ),


texts:
My site is now using a SSL certificate but i have about 300k pages with insecure urls (http) - What is the best and most efficient way of fixing this problem?

The problem is the dynamic content is referencing HTTP content. The site is already forcing SSL.


texts: More Node Access Product (nap.module) Problems

texts:
I have a client who cannot launch his website because of continuing problems with the Node access product module.

After a customer makes a purchase, they are prompted to login. Upon attempting to login they receive a white screen with the following message -

  "Fatal error: Cannot use object of type stdClass as array in
  home/mysite/public_html/sites/all/modules/nap/nap.module on line 824"

Have already looked everywhere for a solution. Any suggestions?


texts: Page refreshes and content is not created

texts:
I have a website in Drupal and I restored site using drush from the backup files of the site.

After restoring the site, I can't create content and even I can't do a cache clear through the admin interface.

I am getting 403 error when creating content and clearing cache.


texts:
I would like to add a specific class to specific menu item, so that the menu item would show an image on hover.

Basically I want to implement this in a menu item link:

Some_name

I have tried Menu Attributes module but I couldn't specified a class I wanted to add. Is there any other way how to do it please?


texts: Preventing Authors from entering pre-formatted text into filtered html field

texts:
I have a form for my authors to use when entering records. The form has a 'filtered text' description field that also use WYSIWYG.

I'm noticing that some of my authors enter 'bad' text. What I mean is the text they are entering looks like it's been formatted with weird spans and divs from some other text editor (probably word), so that it breaks the formatting of the record when its published.

Anyone know of a way to auto-strip extraneous html when someone inputs a record, or is it just a matter of educating them?

They really don't know anything about HTML at all so a technical solution would be best sadly.


texts: How to get 'switch to plain text editor' to work?

texts:
I have designed a website on Drupal. It was working fine but now when I tried to update a link (by adding any name under any option) it does not show the rich text editor. Instead it shows the plain html body.

This way :

<ul> Assignemnt UID </ul>

I mean switch to plain text editor is not working. This way I am not able to update any file or link.

How I can make this to work?

I am still stuck with the same problem. CKeditor does not work, instead the plain text editor gets opened. I tried everything from re-installing CKeditor to updating Drupal to newer version. When I open any heading and try to open the edit option, it runs very slow. Then when it gets open the data is visible in the form of plain text(no CKeditor). I checked the console it shows this error:

  Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience in drupal

Any help?


texts: Add a condition to show menu link in YML

texts:
how should I do if I need to show to a link menu based on a condition ?

This is my YML for my menu link :

double_vue_klesia.backuserswitch:
  title: 'Retour user précédent'
  menu_name: navigation-principale
  description: 'Switch back to your user account.'
  route_name: double_vue_klesia.backuser.switch
  weight: 1

I want to show this link only :

if (\Drupal::service('userswitch')->isSwitchUser())

This is in PHP, but I need this to be on YML (unless there a way to intercept it in php and hide it ?).

If my isSwtichUser is true (from my service), I want to show the link. But I can find a way to do it.

EDIT :

I'm using this module : https://www.drupal.org/project/userswitch

I "just" need to display a link to go back to the original user (link accessible from my frontend)


texts: Cannot run drush rsync - PHP Fatal error in sitealias.inc

texts:
drush rsync @ dev @stage

  PHP Fatal error:  Unsupported operand types in
  /usr/local/share/drush/includes/sitealias.inc on line 1468

Drush command terminated abnormally due to an unrecoverable
Error:

  Unsupported operand types in
  /usr/local/share/drush/includes/sitealias.inc, line 1468


texts: Custom Submit Button On Inline Entity Form Triggers Gives Wrong Triggering Element

texts:
I have implemented hook_field_widget_form_alter() to add a new #process array item.
E.g.
 hook_field_widget_form_alter() {
   $element['#process'][] = ['custom_process_function'];
 }

This part works fine to add in a new submit button that will save the contents of the current form send the user off to another page.
E.g.\
custom_process_function(&$element) {
  $element['new_button'] = [
      '#type'                   => 'submit',
      '#value'                  => t('Upload new'),
      '#submit'                 => [
        [
          "Drupal\inline_entity_form\ElementSubmit",
          "trigger",
        ],
        [
          AddNewSubmitHandler::class,
          'handle',
        ],
      ],
      '#trigger'                => $this->fieldName,
      '#name'                   => $this->fieldName . '_add_new' . '_' . md5(json_encode($this->fieldParents)),
      '#ief_submit_trigger'     => TRUE,
      '#ief_submit_trigger_all' => TRUE,
      '#referenceType'          => $this->fieldReferenceType,
      '#referenceBundles'       => $this->fieldReferenceBundles,
      '#referenceEntityType'    => $this->entityType,
      '#referenceEntityBundle'  => $this->bundle,
      '#allowedFileTypes'       => $this->allowedFileTypes,
      '#validate'               => ['_custom_validate_function'],
    ];
}

However, the problem lies when it is loaded into Inline Entity Form field and then an ajax event is triggered.
In my case, I am using an Entity Browser field within this form and when I click the Remove button and then click my custom button, the $formState->getTriggeringElement() is set to the next submit button that was on the original form, not even the next one in the Inline Entity Form.
Can anyone shed any light on why this is happening or how to fix it?


texts: Aegir+ Ubercart + Freetrial + ARB. Not working

texts:
I'm trying to set an automated approach to do the following:

Customer signs up for a 30-day trial. Enters CC#, but is not charged for 30-days until free trial converts.
CC# is verified (but not charged) on initial registration.
CC# is NOT stored in cleartext in my database (need PCI compliance).
IF account is active (i.e. I don't manually delete account), the account will automatically recur a monthly transaction every 30-days .

I have Aegir and store Admin set up with Authorize.net. I just signed up for Auth.net ARB, but I'm unsure how I set this up to accomplish what I'm describing above. As you can see in the screenshot below, I can manually charge the CC through the Admin interface, but that would imply that I would need to go in and charge the CC# in 30-days, and then manually every 30days thereafter.... That will become unmanageable quickly... As I said, I signed up for Auth.net's ARB, but the documentation on setting this up with Drupal is pretty poor.
http://screencast.com/t/kB0xixRAerIo

Secondly, and perhaps a bigger problem with Drupal, is the fact that as the admin, I can see the customer's full CC# right there in cleartext when I click "view card details". Yikes. There must be a big mistake in all this, but don't know where.
http://screencast.com/t/Kj46n17spnRq

Should I sign up for Auth.net's CIM to capture/store/hold customer's CC# throughout free-trial period, and then charge and and convert to ARB for automated monthly charges? If so, I'm stumped on how to set this up.

And... lastly the primary issue I have is that orders are being rejected due to no Bill-to address being populated with Auth.net. The order page shows no bill-to data was recorded, but when I look at the registration side, I can see that the bill-to address info was indeed captured.
There seems to be some missing link where the bill-to address data recorded at registration is not being passed through to Auth.net (but CC# and name is being passed through). So it's the missing Bill-to data that is causing the rejection on Auth.net side. Any thoughts on why this address data is not being populated on Auth.net's side?

Thoughts/leads? we have a couple SyAd guys stumped on this. Thanks!


texts: Duplicates b/c of Node References, Views "Group By" not helping

texts:
I have a view that displays all 'parent' nodes referenced from 'child' nodes. I just want to list the titles of the referenced nodes, but because there can be multiple 'child' nodes referencing the parent nodes, my view displays the 'parent' node titles multiple times (depending on how many child nodes refer to the parent).

I was trying to use Views 3.x's new 'Grouping' feature to group all nodes by nid, but that didn't seem to make a difference. I tried using an nid that was grouped in the filters section, and an nid that was grouped in the fields section, but it didn't matter.

I could do a views_pre_render and just remove the duplicates manually, but that's messy, and would also screw up the pager. (See here for something along those lines: http://capellic.com/blog/cure-duplicate-nodes-in-a-view).

Is there a better way to do this, or something I'm overlooking?

I also tried using the following hook_views_query_alter() hook:

/**
 * Implements hook_views_query_alter().
 */
function custom_views_query_alter(&$view, &$query) {
  if ($view->name == 'my_subscriptions' && $view->current_display == 'my_networks') {
    $query->groupby[] = 'node_field_data_field_list_network_nid';
  }
}

But still no dice...

Here's the query being generated by views:

SELECT DISTINCT node_field_data_field_list_network.nid AS node_field_data_field_list_network_nid, node_field_data_field_list_network.title AS node_field_data_field_list_network_title, node.title AS node_title, node.nid AS nid
FROM
{node} node
INNER JOIN {flag_content} flag_content_node ON node.nid = flag_content_node.content_id AND (flag_content_node.fid = :views_join_condition_0 AND flag_content_node.uid = :views_join_condition_1)
LEFT JOIN {field_data_field_list_network} field_data_field_list_network ON node.nid = field_data_field_list_network.entity_id AND (field_data_field_list_network.entity_type = :views_join_condition_2 AND field_data_field_list_network.deleted = :views_join_condition_3)
INNER JOIN {node} node_field_data_field_list_network ON field_data_field_list_network.field_list_network_nid = node_field_data_field_list_network.nid
INNER JOIN {users} users ON node.uid = users.uid
WHERE (( (node.status = '1') AND (node_field_data_field_list_network.type IN  ('network')) AND (users.uid = '1' ) ))
ORDER BY node_title DESC
LIMIT 3 OFFSET 0


texts: How to build a specific administrable page layout?

texts:
I have a HTML layout provided from a template and I need to make an administrative page to fill the template with a content.
The page layout looks like this:

I want to have an admin page where can I (the user) preferably change all the blocks at once. Also there can be arbitrary many of those small blocks at the bottom, so there must be an option to add the bottom block in the admin page.
Also the page requires some custom HTML markup.
I know how to do this with 2 custom content types and 2 views (one for the frontend, one for the admin backend). But is there an easier or more drupal-way to solve this?


texts:
Using Drupal 7 and Clean theme. And my main module is Views. And i want, create template tpl.php file for every page.

I know node id method but don't know how create tpl file for views pages.

Please help, thank you.


texts: How to display fetched data in the form of html table?

texts:
I have created a custom module & used below code to display data from Database. But I want to show that data in the form of html table. Please help.

<?php
function custom_table_menu(){
 $items = array();
 $items['custom_table'] = array(
  'title' => 'Custom Table',
  'page callback' => 'custom_table_page_display',
  'access callback' => TRUE,
);
 return $items;
}

function custom_table_page_display() {
$result = db_query('SELECT * FROM {users}');
  $records = $result->fetchAll();

  $content = '<pre>' . print_r($records, TRUE) . '</pre>';

  return $content;
}
?>


texts: Require v8 only contrib module with v9 patch

texts:
Given I have Drupal 9 composer installation with composer-patches plugin
and given a contrib module with a stable v8 release, but no v9 release (not even dev branch)
and given that contrib module has a working v9 patch in the issue queue

is there any method to install that module + patch in composer? Even if I manually add both, the package and patch, to my composer.json, I still can't require or update this module with composer due conflicting versions. I really want to avoid duplicating /contrib code into my project's /custom codebase. My current workaround is:

forking that module to my own, private git repo
applying patch there
creating a new composer.json in my private git, and changing the package vendor to my custom_private_vendor
adding my private git as VCS repo in the D9 project's composer.json
and then composer require custom_private_vendor/contrib_module

This fulfills my goal of not duplicating the contrib module in my project's custom codebase, but every time I do this I feel the urge to wash my dirty hands.
Is there something more elegant like composer require drupal/contrib_module --apply-patch-first or can I somehow target drupal.org's git with a specific patch included?


texts: How can I assign an icon to users depending on their gender?

texts:
I'd like comments on my website to look like this:

Every comment has to be preceded by an image, depending on the gender of the user who wrote the comment. Users can choose Male/Female as their gender when they register, so the icon can't be changed: it's only related to the gender. How can I achieve this?


texts:
I want to create a views that termId passed from url to it  and then show parent and parent's siblings(uncle aunt) of that term,,I can handle that show parent term id ,but I don't any idea that how can I get parent's siblings,I can handle it finally with php_views but first ask here maybe somebody has better solution.

tnx for your attetions


texts: How to open product detail when user click on product image?

texts:
I am new in Drupal and I am working on one commerce website using drupal commerce module.

The problem is arise in my website is-->

I am used views for display products with product image,title, price etc fields.

But I want to know that when user click on product image the new page will open and in that page display 3 related images of that product with detail information.

I want to give link for product image to open that clicked image product with detail.

Please help me to solved this problem...!


texts: hide result on same node in block (view)

texts: I have 3 pages, vacation1, vacation2, vacation3. Under each page there is a block-view with fields (title, image, summary) that links to the other pages. I want to have on vacation1 links to vacation2 and vacation3, but my views show all the results. I wan't to filter out the result of the current node. How can I set the filter for this?


texts: How to programmatically render a view pager?

texts:
I'm trying to figure out how to render a view's pager programmatically. I'm renderering my view programmatically as follows:

$viewname = 'example_view';
$viewdisplay = 'block';

// get the view machine id
$view = Views::getView($viewname);
// set the display machine id
$view->setDisplay($viewdisplay);
$view->render();

$renderer = $view->rowPlugin;
foreach ($view->result as $index => $row) {
  $view->row_index = $index;
  $vars['content']['view_results'][$index] = $renderer->render($row);
}

So now I need to render the pager, but not having any luck. I've tried something like:

$pagerrenderer = $view->pager;
$vars['content']['view_pager'] = $pagerrenderer->render($view->pager);

but then end up with the following error:

  Recoverable fatal error: Argument 1 passed to pager_query_add_page()
  must be of the type array, object given, called in
  /www/projectname/docroot/core/includes/pager.inc on line 246 and defined
  in pager_query_add_page() (line 311 of core/includes/pager.inc).

Can anyone point me in the right direction?


texts: Are there any hooks for the event when an user navigates the verification URL?

texts:
I'm looking for a way to modify an event (from my own module) when an user navigates to the account activation URL that they get in their mails. Are there any such hooks ready for me to use?

Also I would potentially need the $account-> mail variable if it's passed as an argument by any chance.

I've used this but it doesn't work as intended -

function my_module_form_alter(&$form, &$form_state, $form_id)
{
    // Trigger when at password reset form
    if ($form_id == 'user_pass_reset') {}
}

But the problem is I cannot seem to access the $account variable that way. What should I do?


texts: JSON:API How to retrieve multiple values in a CONTAINS condition?

texts:
I'm using JSON:API module (in core since v8.7), and works well for a simple query like:

  Retrieve all articles with title that contains "MyKeyValue" or subtitle that contains "MyKeyValue"

That, translated in jsonapi query, is:

fields[node--article]=title,field_subtitle
filter[or-group][group][conjunction]=OR
filter[status][value]=1
filter[title-filter][condition][path]=title
filter[title-filter][condition][operator]=CONTAINS
filter[title-filter][condition][value]=MyKeyValue
filter[title-filter][condition][memberOf]=or-group
filter[subtitle-filter][condition][path]=field_subtitle
filter[subtitle-filter][condition][operator]=CONTAINS
filter[subtitle-filter][condition][value]=MyKeyValue
filter[subtitle-filter][condition][memberOf]=or-group

But HOW to manage multivalues within the CONTAINS condition? I mean: how to accomplish a query like:

  Retrieve all articles with title that contains ("MyKeyValue" AND "AnotherKeyValue") or subtitle that contains ("MyKeyValue" AND "AnotherKeyValue")

I tried to pass multiple values in this way:

...
filter[title-filter][condition][operator]=CONTAINS
filter[title-filter][condition][value][]=MyKeyValue
filter[title-filter][condition][value][]=AnotherKeyValue
...
filter[subtitle-filter][condition][operator]=CONTAINS
filter[subtitle-filter][condition][value][]=MyKeyValue
filter[subtitle-filter][condition][value][]=AnotherKeyValue
...

But does not work.


texts: Remove row from system table with hook_update_N

texts: I've run into some trouble writing a hook_update_N function that will remove a row from the system table. Can anyone point me in the right direction? Finding little documentation..


texts: How to add a dynamic select field to a content type form?

texts:
I would like to add a dynamic select field where options change from time to time. New options will be added along with old options in future. I know i can add form element using hook_form_alter and save values using node api in custom table created using install file of a module.

Is there any inbuilt mechanism where i can create a field and avoid dealing with schema and schema related queries ? My only concern is field should support dynamic options in future... Something like select field values will be pulled using a query.

PS: I hope above questions is not primarily opinion based. I believe many Drupalers might have faced above situation :-) Please do add a comment if form alter approach is the right one !


texts: How/Where do I place my System Message in my Rule so it only appears when needed

texts:
I have created a RULE, after add product to cart, check the quantity of the items in the cart, if you run into the same item that has a quantity of 1, do not add the new item to the cart.

This seems to be working, but now,  no matter what, it always displays the message "duplicate item has been removed."

So if I add 5 unique items to the cart, they are all placed in the cart, but the duplicate message appears.

When I try to add a duplicate item, the item is not placed in the cart and the duplicate message is displayed.

I only want this message to appear when it actually runs into a dup and did not add the item to the cart. I know the issue is that I have the message on "after add item to cart"

Where should I place this message?


texts: Extending an existing Plugin class results in Class not Found PHP Fatal Error

texts:
I am trying to create my own Plugin that extends an existing Plugin class.
I can extend the base class and everything is fine.
However, if I extend a existing Plugin class, I get a Class not Found error.

e.g.

<?php

namespace Drupal\my_module\Plugin;

use Drupal\contrib_module\Plugin\ClassA;

class MyClass extends ClassA {
  public function implement() {}
}

The error I am getting would be
Class 'Drupal\contrib_module\Plugin\ClassA' not found in /var/www/project/web/modules/custom/my_module/src/Plugin/MyClass.php on line 7

Any Thoughts guys?


texts: Is there any way to run hook_form_alter based on a form ’s class instead of it’s ID?

texts:
Is there any way to run a hook_form_alter based on a form ’s class instead of it’s ID?

I have a class of commerce products and am needing to do form alterations on their add to cart forms. There are too many of them to do this using their form id’s.

Pseudo code might be:

function  theme_form_alter(&$form, &$form_state, $form_class) {
    //code goes here
    }


texts:
I have a custom module which is supposed to change a user's profile picture.

When you are logged in as a super-admin, the module works fine. Problems arise, however, when you log in as a regular user.

I believe that entity_load() is causing infinite recursion, either crashing PHP (due to an xdebug limitation) or running to the PHP memory limit.

I located something similar here, but that's from 2009! Surely it's been integrated into Drupal's core by now, yes? Also, I tried to apply the last green patch using Git, but it appears that the directory structure is different than my install? common.inc is definitely in my includes folder, but there's no node folder in my includes folder, so I'm not quite sure how to apply it..

The full stack trace can be found here

If anyone could help me figure out what I need to do to fix this, I'd be very appreciative.


texts:
I created a taxonomy with the same name as a content type. Now the list shows with no content type on the nodes with that type. I have since renamed the taxonomy, but there is still an issue.
When trying to edit the node from the admin menu I get the following error:

Notice: Undefined index: case_studies_node_form in drupal_retrieve_form() (line 750 of C:\wamp\www\ppi\includes\form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'case_studies_node_form' not found or invalid function name in drupal_retrieve_form() (line 785 of C:\wamp\www\ppi\includes\form.inc).

I checked the database and the nodes have the correct type in the content table, and the content types table still has the "Case Studies" type.


texts: Generate Install Scripts from current Nodes, Views, Fields in Drupal

texts:
I have theme with custom content types, views, etc. and i would like to package into a custom module so it can be easy installed in another Drupal instance via MODULE_install().

Currently, Module_install() looks something like this:

function MODULE_install(){
    $t = get_t();
    foreach (_jobs_installed_fields() as $field) {
        field_create_field($field);
        drupal_set_message($t('Field type: '.$field['field_name'] . ' created'));
    }

    foreach (_jobs_installed_field_instances() as $field) {
        field_create_instance($field);
        drupal_set_message($t('Field instance: '.$field['label'].' initiated and added to User Profile'));
    }

    drupal_set_message($t('Finished adding fields to User profile'));
}

function _jobs_installed_fields() {
    return array(
        'field_name' => array(
           ...
        ),
        'field_name2' => array(
           ...
        ),
     );
}

function _jobs_installed_field_instances() {
    return array(
        'field_name' => array(
           ...
        ),
        'field_name2' => array(
           ...
        ),
     );
}

The content of _jobs_installed_field_instances and _jobs_installed_fields functions is generated via PHP Execute Script Dev module block from the current instance content and then copy/paste in the install script.

$entity_type = 'user';
$field_name = 'field_name';
$bundle_name = 'user';

$info_config = field_info_field($field_name);
$info_instance = field_info_instance($entity_type, $field_name, $bundle_name);
unset($info_config['id']);
unset($info_instance['id'], $info_instance['field_id']);
include_once DRUPAL_ROOT . '/includes/utility.inc';
$output = "field_create_field(" . drupal_var_export($info_config) . ");\n";
$output .= "field_create_instance(" . drupal_var_export($info_instance) . ");";
drupal_set_message("<textarea rows=30 style=\"width: 100%;\">" . $output . '</textarea>')

This can be lot of work for larger Themes and i cannot rerun it later once the change is introduced. I was thinking creating some Php scripts that would generate me the install script from the current nodes, views, etc so i can rerun as like in future. Is there anything like this already available? What would be your approach to this problem? Thank you


texts: How to use Views/Contextual Filters with a referenced entity

texts:
So, I have a site with two content types:

Sermon Series
Sermon

The sermon content type has an entity reference field selecting a sermon series that it relates to.

On the page for a sermon series, I am attaching a view to list all the sermons that have the "Sermon Series" field set to that particular series.

Ideally, I'd like to only create one view that will work for every sermon/sermon series.

I know that I need to use contextual filters to do this, but I'm having an exceptionally difficult time wrapping my mind around what settings I need to use, and spending several hours trying stuff out has been to no avail.

Could someone please explain the process to me?

For bonus points- I'd also like to use a view on the sermon page to display an image from the referenced sermon series. I am also not exactly sure how to set this up.

To help clarify, here's the workflow that I want to end up with:

User creates a new "Sermon Series" with a title and an image.
User creates a new "Sermon", and they can select which "Sermon Series" it belongs to.
The new sermon shows up in a list on the corresponding "Sermon Series" page.
The image related to the "Sermon Series" shows up on the "Sermon" page.


texts: Get the draft data in the webform hook_form_FORM_ID_alter()

texts:
I'm building a multi page webform in Drupal 8 as shown below

(1) Consent to ask questions >>> (2) Chekcing eligiblity >>> (3) Consent to Participate >>> (4) Base line info >>> (5) Complete

multipage webform

In the 2nd page (Checking eligibility) as soon as the user clicks on Next Page > button, I need to validate the submitted values (which contains several radio buttons) and assess the user whether he is eligible to participate in a survey or not.

/*
 * hook_form_FORM_ID_alter()
 */
function webform_form_webform_submission_registration_content_node_77_form_alter(&$form, FormStateInterface $form_state, $form_id) {
    ...
    if($form_id == 'webform_submission_registration_content_node_77_form')
    {
        $form['#submit'][] = 'webform_webform_submit_handler';

    }

}

function webform_webform_submit_handler($form, &$form_state) {
    /* This is not displaying any submited values mostly because I haven't clicked on Sumbit button yet */
       dpm($form_state['values']);
}

src: https://www.drupal.org/node/2634266

Is there any way to get the Form's draft values before submission?
Any better approach to process the values within the page(form) itself?
Any help much appreciated.


texts:
In one of my Drupal installations I suddenly noticed I can no longer drag and sort the order of my blocks. The image shows on the left the admin with now drag handles and a screenshot of another admin with the handles.

What could have happened? I think its AJAX/JavaScript related.


texts: How to attach custom CSS to a Views output?

texts:
I created a View to list a custom entity content.
I'd like to add my custom CSS file to the generated page.
I tried to use a Text Area in the footer with {{ attach_library('amap/yyy') }} where amap is my custom module and yyy is my custom library.
And of course, the CSS is not loaded...
Any idea why?


texts:
Can someone show me a proper example of how to create a new content type in a module's hook_install method?

I'd also like to know if/what I should do during hook_uninstall to clean up my mess; I read there is some debate about simply removing the content.

I haven't been able to find an example of the proper method of accomplishing this task, any help would be appreciated!


texts: how to prevent node revision update when node is updated?

texts:
I noticed that every time a node is updated, a timestamp column in node_revisions table is also updated for this node. I would like to change this behavior for "forum" content type and disable updating of the revisions table when forum node is edited. I don't use any modules that impact revisions. How do I achieve it (probably via my own custom module?)

[Edit]

The suggested duplicate  solution ("How to disable the revision feature completely?" ) is quite a big thing. I don't want to disable revisions functionality so deeply, only in particular "forum" node type case and only prevent timestamp change, nothing else. The reason I need this is that the advanced forum module sorts topics by revision timestamp. There is a question how to change this behavior, but there is no answer, so it may be difficult and I also tried to figure it out myself but was lost - this module uses views handlers etc in code, hard to change anything.

I will try maybe to write a hook mymodule_node_save or mymodule_node_insert which is called after the revision table update (as visible in node_save function) and then just reverse this timestamp column back to node creation timestamp.

If it doesn't work then I'll try to deal with the node_save overwriting.


texts: Views filter with per-user black tag list

texts:
I want to implement such a scheme: each material on the site has a field with one or more tags, and user profiles has fields "white tag list" and "black tag list" with zero of more tags. A material must be shown to user only if it has at least one tag from user's individual white list and has not tags from user's black list.

I want to create a view with these filters. But I cannot implement black list logic. I tried to do it with relations and contextual filters. I tried to make some PHP code in contextual filter. I googled examples for two weeks and now I am totally puzzled.


texts: Search block not showing if not logged in

texts: When I am logged in I can see the the search form block, however when logged out I can not see it, I'm guessing its some sort of user config, but I can't seem to find anything


texts: Reasons for using a webform node rather than just linking directly to the webform

texts: Other than reuse, is there any reason why I should not link directly to a form in Drupal 8? I mean linking directly to the webform rather than to a node that incorporates the webform?


texts: I need to add title of specific nodes in a select box

texts: I would like to have the title field of specific Nodes from a Content Type show up in a Select Box on a Webform.  Technically, it should not grab all of the nodes titles of that content type, it should only grab specific ones (that I'll need to mark somehow), so am thinking I'll need to create a vocabulary and assign this to the nodes somehow, but than I'd like to be able to use this taxonomy term to grab the titles of these nodes only.  Is this even possible?  Is there a module that ties into the webform that can do something like this?  Or perhaps a better way to go about doing this?


texts:
I have created a module, and I am trying to use the following code:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_state['view']->name == 'album1') {
    // ...
  }
  // ...
}

The line that causes the error is the following one:

if ($form_state['view']->name == 'album1') {

The error I get is the following one:

  Notice: Trying to get property of non-object in mymodule_form_alter() (line 15 of C:\xampp\htdocs\drupal\sites\all\modules\mymodule\mymodule.module).


texts: How to pass negative values to config-set

texts:
It seems that we can't set negative values with config-set:

drush cset block.block.myblock_name weight '-1' --format=string -y

doesn't work


texts: How to add a button "Add More" with ajax for adding multiple fields?

texts:
I want to add a button "Add More" with ajax for adding multiple fields
I have writed this code, I don't understand why when I click to "add more" nothing work, there is an solution?

this is my code:

function produits_add($form, &$form_submit){

        if(!isset($form_state['num_names'])){
            $form_state['num_names']=1;
        }

        // Create wrapper for ajax
        $form['#prefix'] = '
';
        $form['#suffix'] = '
';

        for ($i = 0; $i < $form_state['num_names']; $i++) {

            $form['name_' . $i] = array(
                '#type' => 'textfield',
                '#title' => t('Name')

            );
        }

        $form['add_button']= array(
            '#type' => 'button',
            '#value'=> 'Add more',
            '#ajax' => array(
                'callback' => 'ajax_add_col',
                'method' => 'replace',
                'effect' => 'fade',
                'wrapper' => 'form-wrapper',
            ),
        );

        $form['submit'] = array(
            '#type' => 'submit',
            '#value' => 'Submit',
            '#submit' => array('produits_add_submit'),
        );

        return $form;
    }

    function ajax_add_col($form, &$form_state){

        $form_state['num_names']++;

        // rebuild whole form with new values
        $form_state['rebuild'] = true;
    }

function produits_add_submit($form, &$form_state){

// Some code
}


texts: Having trouble with ckeditor toolbar buttons

texts:
I cant figure out how the full toolbar can be view. I tried to toggle collapsed toolbar of and on however I am unable to see the either advanced toolbar or full (only some buttons I haven't selected at all). Meanwhile I can create the basic toolbar.

Can anybody help me get the full toolbar?


texts: File upload only allowing one upload at a time

texts:
I'm having a problem with the File widget. I have created a content type with a file field that allows unlimited values. When I upload a file I am expecting to be able to immediately upload another file.

but what actually happens is the upload box disappears, meaning I have to save the node and re-edit it in order to upload another file

both these example have exactly the same content type settings, both running the same version of Drupal. I'm not getting any JS errors or anything. Any ideas on why this is happening?


texts: Use a 3rd part library when uninstalling a module

texts:
my module uses several third part PHP libraries, loaded by using the library module supported by the x_autoload (several third part libraries are based on composer, so this support directly pointing to the composer file).

Just to provide you with an example:

function mymodule_libraries_info() {
  $libraries = array();
  ...
  $libraries['mongo-php-library'] = array(
      'name' => 'mongo-php-library',
      'vendor url' => 'https://github.com/mongodb/mongo-php-library',
      'download url' => 'https://github.com/mongodb/mongo-php-library/releases',
      'path' => 'src',
      'version arguments' => array(
          'file' => 'RELEASE-1.0',
          'pattern' => '/RELEASE (\d+\.\d+\.\d+).*/',
          'lines' => 1,
      ),
      'versions' => array("1.0.4"=>array()),
      'xautoload' => function($adapter) {
        $adapter->composerJson('composer.json');
      },
  );
  ...
  return $libraries;
}

Everithing works fine (I can use this library in my working code) except for the "uninstall" part.

In fact, I need that the hook_uninstall() can access to this library in order to perform several operations, but I receive a WD php: Error: Class 'MongoDB\Client' not found error.

I guess this is related to a specific problem: when I try to uninstall the module, it has already been disabled, so its libraries are no loger available when I call the "uninstall".

How can I deal with this problem?


texts: How to use composer for installation profile?

texts:
I have a Drupal 8 installation profile with custom modules and themes and I am wondering how should I use composer so that I can run it and drupal core and other dependencies(like contrib modules) would get properly downloaded(and also Drupal's cusom composer stuff would get properly applied as well)?

Is this possible at this time or the composer approach is still not complete?


texts: Using migrate module to import to a list_boolean field

texts:
I'm trying to use the migrate module to import data from a mysql table to Drupal 7. I've created a content type with a field type of boolean and used "single on/off checkbox" as the widget. So in the migration destinations the field is (list_boolean).

The data in the database is integer (0/1).

I set the field mapping:
$this->addFieldMapping('field_my_event', 'my_event');

However, none of the 1's get stored as 1 in the field_my_event table when migrated.

I tried also forcing the value to a boolean value of TRUE/FALSE in the prepareRow hook, but that didn't make a difference.

versions I'm working with: Drupal 7.33 and Migrate 7.x-2.6-rc1

Can someone steer me in the right direction?


texts: Zen subtheme region templates not being used?

texts:
In a subtheme of Zen, I've got a templates folder that has region.tpl.php and region--footer.tpl.php that are copied from the main Zen theme. However, the custom region file is not being used for the regions of my theme; I even changed the contents of the region--footer.tpl.php file to just be <?php exit("Hi!"); to see if it's being called at all, and it appears to not be.

I've cleared the theme cache (it's set to clear every page load); what am I missing to get that custom region template to actually apply?


texts: How to set a theme for a 403 access denied?

texts: When a user clicks a link to a Drupal site and are denied access because they need to login, they get a 403 access denied screen inviting them to login. I want to set a responsive theme because some users will be using phones.  I've tried to use the Themekey module to set something other than the admin theme (which is Seven) setting path:node_alias to the redirection which is user/login?destination=whatever  However this doesn't work. Any ideas please?  I'd much prefer a non coding solution, if possible!  Thanks - using Drupal 7.


texts: I use Smart IP module to track user location with option IPInfoDB.com. But as I understand Smart IP does not store by default user location in database. Is there any option to configure this or I need to make own module? Ultimately I need to show user who is in the same city or region.


texts: Cron error: LogicException : Render context is empty

texts:
In a custom module (sel), I have this code:

function sel_cron()
{
  $accountSwitcher = Drupal::service('account_switcher');
  $account = \Drupal\user\Entity\User::load(1);
  $accountSwitcher->switchTo($account);

  $query = \Drupal::entityQuery('service_category');
  $dLastExtractionDate = strftime("%Y-%m-%d", strtotime("- 1 week", strtotime(\Drupal::state()->get('sel.NextEmailForNewServices'))));
  $view = views_embed_view('sel_services', 'embed_2', $dLastExtractionDate);
  $view = \Drupal::service('renderer')->render($view);   <--------------------- problem here

  $accountSwitcher->switchBack();
}

The expected result of the view is a table but when the result is empty (because of the value of the contextual filter), an unfiltered text ("Nothing to display today. Too bad!") should be displayed instead.
But in this case, I get this error logged:

  LogicException: Render context is empty, because render() was called
  outside of a renderRoot() or renderPlain() call. Use
  renderPlain()/renderRoot() or #lazy_builder/#pre_render instead. in
  Drupal\Core\Render\Renderer->doRender() (line 243 of
  /Users/efalzon/Sites/JdP8/web/core/lib/Drupal/Core/Render/Renderer.php).

How to fix that?


texts:
I have installed CAPTCHA module. In CAPTCHA module I need to give the machine name of a form of another module called Printer, e-mail and PDF versions. How do I find the machine_name of this from.

If I could list all the machine names somewhere, I will probably figure out the machine name of that form.


texts:
How do you achieve the highlighted 'node' alias when using the Drupal 7 database abstraction language?

This is the original query produced by the view

SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created, **'node' AS field_data_field_reference_code_node_entity_type, 'node' AS field_data_field_employer_node_entity_type, 'node' AS field_data_field_contract_type_node_entity_type, 'node' AS field_data_field_display_location_node_entity_type, 'node' AS field_data_field_salary_description_node_entity_type**
FROM
{node} node
INNER JOIN {field_data_field_locations} field_data_field_locations ON node.nid = field_data_field_locations.entity_id AND (field_data_field_locations.entity_type = 'node' AND field_data_field_locations.deleted = '0')
LEFT JOIN {workflow_node_history} workflow_node_current ON (  SELECT max(hid) FROM {workflow_node_history} where nid = node.nid and sid != old_sid ) = workflow_node_current.hid
WHERE (( (node.type IN  ('job')) AND (field_data_field_locations.field_locations_tid = '56') AND (workflow_node_current.sid =  '3') ))
ORDER BY node_created DESC
LIMIT 10 OFFSET 0;

Here my current code, which produces the query but cant recreate the aliases in bold with the addfield method. Tried to escape the quotes around 'node' but drupal stripes it out.

$result = db_select('node','node');

    $join = $result->innerJoin('field_data_field_locations','field_data_field_locations',"node.nid = field_data_field_locations.entity_id AND field_data_field_locations.entity_type = 'node' AND field_data_field_locations.deleted = '0'");

    $result->leftJoin('workflow_node_history','workflow_node_current',"(SELECT max(hid) FROM {workflow_node_history} where nid = node.nid and sid != old_sid ) = workflow_node_current.hid");

    $result->addField('','node')
    $result->addField('node','title','node_title');
    $result->addField('node','created','node_created');
    $result->addField('node','nid','nid');
    $result->condition('node.type',array('job'),'IN');
    $result->condition('field_data_field_locations.field_locations_tid','56','=');
    $result->condition('workflow_node_current.sid','3','=');
    $result->orderby('node.created','desc');


texts: How do you populate existing entities with the default value for a newly added field?

texts:
Let's say I have a content type, Article, with several fields. I already have hundreds of Article nodes created, but now I want to add a new field. After I set a default value for this field, how can I make it so that all existing Articles have this new field populated with this value? In other words, I don't want all my existing Articles to have a blank value for this new field.

This seems like it should be a simple task, but I can't find anything when searching for this issue online.


texts: How do I translate "Please fill out this field." on the user registration form?

texts:
Obviously users need to add an email address to register an account.

I'm using the Bartik theme. In Firefox and Chrome, if I don't enter a value for the email address and press submit, the form is not sent; instead, I get a JS popup, "Please fill out this field."

When I search the translation UI, I can't find this string ("Please fill out this field.")

I also can't find the string when I grep for it over the entire D8 git repository.

How do I translate this string?


texts: URL for a Drupal Web File Manager file by path and name

texts:
Once a file is uploaded using the Drupal Web File Manager, it can be referenced using a URL which has a number for identifying the file, like:

  https://intranet.example.com/drupal/webfm_send/389

Given that there is a path and name associated with the file such as:

  IT/Documentation/Projects/SomeProject/AFile.pdf

is there a URL that uses this path and name? Something like:

  https://intranet.example.com/drupal/BYNAME/Documentation/Projects/SomeProject/AFile.pdf

If so what is the BYNAME part of the URL?


texts: How to add a META tag in head conditionally to entity content

texts:
I need to put a meta NOINDEX tag in head conditionally to a CCK field value ("visibility=private") in one specific content type ("projects").

I read about drupal_add_html_head($data = NULL, $key = NULL) but I'm not sure where to put it.

If I could put the tag in body I would just use a computed_field, but as I need it to be in head, should I put it on my own module (but on which hook?) or should I copy/insert it  in html.tpl.php ?

My problems are (a) that if html.tpl.php will change then I'll have to change also the copy I overridden; (b) then I'm also not sure I have access to $entity inside the template (I never used them) and, finally, (c) that being a matter of logic rather than presentation a module maybe is more indicated than a template.
For all this reasons I would prefer a custom module. Would it be possible ?


texts: How to redirect back to the previous page after form submission using its cancel link?

texts:
I have created a form using Drupal 7 Form API. For this I have a cancel link to redirect back to that page from where it comes. This works fine until I do not submit the form: after form submission the cancel link is redirecting me to the same form.

<?php print render($form['name']); ?>

<?php print render($form['email']); ?>

<?php print render($form['quantity']); ?>

<?php print render($form['comments']); ?>

<?php print render($form['submit']);?>
<?php print render($form['buttons']);?>
<?php if($form):
print drupal_render_children($form);
endif;
$node_url= $_POST['node_url'];
print "
Cancel
";


texts: How do I calculate outstanding balance for product inventory?

texts:
I have two content types, Product In and Product Out.
Content types Product In has the title as Product Code, and a field as Model.
The content type Product Out has a node reference (Product Code) to Product In, and a field as Customer Name.

I have a view, Product Inventory, with aggregation on. I have two fields:

Total Product In (By counting Content types Product In's title)
Total Product Out (By counting Content types Product Out's title)

How can I get the outstanding balance which I have inside my inventory?


texts: Content profile fields on registration form by role

texts:
I have two main users roles: authenticated and agent.

First role uses content profile fields on registration form.

Users with the agent role can only be created by admins but agent doesn't need content profile fields.

In user_add_form the content profile fields is added as well so the admin must fill them.

How can I disable those fields when an admin want to create user with the agent role?


texts: How to use glossary contextetual filter?

texts: I created a user type view and add a contextual filter of User:Name. I enabled the glossary mod add character limit to 1. Same setting as glossary view. But still it not showing the filter (A|B|C). Am I missing any setting?


texts:
i build a macro that contains a function. The function basically crop a text without catting words. My problem is how to call that twig macro if it is in different folder. if it is i same folder its easy. i just import the twig name. {% import 'croptext.twig' as cropText %}
But since this file contains a useful function all templates will call it so its better to put it in special folder like "tool" or "filter". But i still have any way to call it any help ?

{% macro crop_text(text, len) %}
  {% if text | length < len %}
    {{ text }}
  {% else %}
    {% set break = false %}
    {% set croppedParagraph = '' %}
    {% set paragraph = text | split(' ') %}
    {% set totalLength = 0 %}
    {% for word in paragraph  if not break %}
        {% if totalLength >= len %}
          {% set break = true %}
        {% else %}
          {% set totalLength = totalLength + 1 +  word | length %}
          {% set croppedParagraph = croppedParagraph ~ ' ' ~  word %}
       {% endif %}
    {% endfor %}
    {{ croppedParagraph ~ ' ...' }}
 {% endif %}

{% endmacro %}

The function is working. I think its better to share more code to have a better idea about what i am doing. this is my project structure.


texts: How to obtain Drupal session cookie via an XMLRPC request?

texts:
I would like to implement single sign-on to Drupal and other site (not PHP) via xmlrpc.

Is there a way to make an xmlrpc call with user name & password and in return obtain information on success of authentication and the session cookie - so that we could set the cookie and log in to both sites at once?


texts: Is it possible to completely hide the admin menu for a role, while still grant it some admin permissions?

texts:
I need to create a 'Demo' role that can completely hide the admin menu toolbar, but can still access some admin pages to, well, demonstrate stuff.

What would be the best way to do this in drupal 8? Is there some kind of built in functionality to do this?


texts:
I want to show a message when a module is being enabled. I used hook_modules_enabled and it shows me the message while enabling a new module.

Now I need the currently enabled module machine name in the hooks argument.
But hook_modules_enabled($modules) returns an array of modules in the argument.

Eg:

When views is enabled, I need to set a message as:

  "Views Module is enabled"

Here I need "views" (i.e. the module name) as argument in hook_modules_enabled in order to print it in message but it returns me an array.

How can I achieve this. Is there any other hook for this?


texts:
I am using EU Cookie Compliance module.  During module installation, permission has been set to admin also. I need to revoke that permission which is assigned to Admin as cookie pop-up is coming-up for admin also.
In Permissions, it is grayed-out. So I can't able to disable that permission.

When I used below code, it is revoking permission for all other roles but not working for Admin.

user_role_revoke_permissions('administrator', [
      'display eu cookie compliance popup',
    ]);

Please suggest me a solution how to revoke that permission for admin.


texts:
How would I go about adding a progress indicator to my multi page form?

So for example, I would like to have a Heading at the top of each of the form pages/stages. I would like them all to be displayed at all times, but with a "status box" or something similar next to each status, which changes once a certain stage has been completed (all the mandatory fields have been populated).

Any advice on how to achieve this?


texts: hook_theme_suggestions_page() provide default template file inside module folder

texts:
I am using hook_theme_suggestions_HOOK() to implement a custom template file in my drupal 8 website like below.

/**
 * Implements hook_theme_suggestions_HOOK().
 */
function mymodule_theme_suggestions_page(array $variables) {
  $template_suggestions = array();
  // This is used to display only $content.
  if (isset($_GET['ajax']) && $_GET['ajax'] == 1) {
    $template_suggestions[] = 'page__ajax';
  }
  return $template_suggestions;
}

Above code is working fine and I can add template page--ajax.html.twig inside my current active theme and changes in template is reflecting in page.

But when I put that file inside my module itself file is not detecting and changes not reflecting in page and taking default page.html.twg template file.

How can I provide default template file within my module itself?


texts:
Currently I have a Date/Time field that outputs in a Block View as:

Friday, April 25, 2014 - 4:00pm to 6:00pm

But i would like to output it as something like this:

Friday, April 25th from 4pm to 6pm

I was hoping that I would be able to do this by changing the way that the field outputs in the Rewrite Output option, but I did not find a way to get the the right machine names of the field I need to parse everything out as planned.

Does anybody have any other better ideas that would possibly work for this? Thank you!


texts: Views - create relationship on relationship?

texts:
I'm confused with Views' query altering and adding joins. Need help (or at least a comprehensible documentation with code samples, because I've never found one).

Here is what I'm trying to do: I have 2 node types, Writers and Books. I use taxonomy to group Books by Writers. I've created a field in my taxonomy terms that references respective Writer articles. It looks like this:

Books by Writers (dictionary)

Books by Isaac Asimov (taxonomy term, WriterId = 1 - references Isaac Asimov node)

I, Robot (Book node)

Books by Harry Harrison (taxonomy term, WriterId = 2 - references
Harry Harrison node)

West of Eden (Book node)

Now I'm trying to build a view that looks like this:

Isaac Asimov (Writer node title)

I, Robot (Book node title)

Harry Harrison (Writer node title)

West of Eden (Book node title)

All in all, I need something like Book Nodes join Taxonomy Terms join Writer Nodes. In Views UI I'm able to display Book titles and add a relation to Taxonomy so that I can display all Taxonomy term fields. It looks like this:

1 (WriterId from taxonomy term)

I, Robot

2 (WriterId from taxonomy term)

West of Eden

How do I join Taxonomy and Writers to get access to Writer node titles?


texts: Can you use drush to update to a different module version?

texts:
I know you can download a specific version.

Example: drush dl webform-7.x-3.24

According to "drush up" the webform module is up to date. Thats fine but now I want to update the webform module to use version 4.

Is there such a thing as drush up webform-7.x-4.12, or is it still a manual process?

EDIT:

Doing drush dl webform-7.x-4.12 returns
"Install location /var/www/_public/xxxxxx/sites/all/modules/webform already exists. Do you want to overwrite it? (y/n):"


texts: Various View-panes with arguments from url in the same panel-page. It is possible?

texts:
I'm making a web about football and this is the situation of my problem:

I have a content-type called 'player stats' taxonomized with the vocabularies 'season' & 'day' and another content-type called 'chronicle' with the same tag-system of the 'player stats' content-type.

I want to have my custom node-template for all the content of type 'Chronicle', but including in any content-pane a Views-pane with content from the 'player stats' for a given 'season' and a given 'day'. My url structure is: example.com/chronicle/season-x/day-y and I tried to get arguments from url but the internal path node/% impossibilite it (as far I know)...

My second option is to create a Panel page, and try to insert content (using views pane's with contextual filters) from both content-types 'chronicle' and 'player stats' to make a chronicle with complete stats of the players in the same page. But my problem is that I only get visible ONE View-pane, the other ones seems not to work an I can't see any more view-panes that compose my panel-page. (please, see attached snapshots)

I am doing anything wrong? I'll glad to read you suggestions and your help.
(sorry for my bad english, I'm catalonian from Barcelona). Thanks.

Attached files::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

It's my first time posting here, so I have not enough privilieges to attach more than 2 links. But snapshots & export-files are available in the original post, at drupal.org:

http://drupal.org/node/1392700


texts: How do I check that the private file system is setup correctly from hook_requirements()?

texts: I'm working on a module that will need to place files in the private file directory.  I'd like to check that the private file system is working from within hook_requirements() so I can provide both an install requirement and a status check.


texts:
I am trying to make an installation profile that inherits the commerce kickstart distribution. In order to get this to work, I need to apply a bunch of patches through drush make.

First I have to apply a drupal core patch: http://drupal.org/node/1356276#comment-6654100

However the libraries module also needs to be made aware of the parent installation profile. So it needs to be patched as well.

My make file looks like this:

api = 2
core = 7.x

projects[drupal][type] = core
projects[drupal][patch][] = http://drupal.org/files/1356276-base-profile-d7-38-do-not-test.patch

projects[commerce_kickstart][type] = profile
projects[libraries][patch] =  patches/libraries-from-inherited-profiles.patch

The problem is that with this makefile drush will download the libraries module again to sites/all/modules and patch it there instead of just patching it in its original download location at profiles/commerce_kickstart/modules/contrib/libraries, thus I end up with the libraries module existing twice within one drupal installation.

The patch file for the libraries module looks like this:

diff --git a/libraries.module b/libraries.module
old mode 100644
new mode 100755
index 687fa29..bcf8824
--- a/libraries.module
+++ b/libraries.module
@@ -66,7 +66,6 @@
  */
 function libraries_get_libraries() {
   $searchdir = array();
-  $profile = drupal_get_path('profile', drupal_get_profile());
   $config = conf_path();

   // Similar to 'modules' and 'themes' directories in the root directory,
@@ -77,7 +76,8 @@
   // Similar to 'modules' and 'themes' directories inside an installation
   // profile, installation profiles may want to place libraries into a
   // 'libraries' directory.
-  $searchdir[] = "$profile/libraries";
+  foreach (drupal_get_profiles(drupal_get_profile()) as $profile)
+   $searchdir[] =  drupal_get_path('profile', $profile) . '/libraries';

   // Always search sites/all/libraries.
   $searchdir[] = 'sites/all/libraries';

How do I tell drush to simply patch libraries within the commerce kickstart directory and not download it again into sites/all?


texts:
I've got a Drupal 7 site, and I'm working with regions. It seems that no matter what theme I use, /modules/system/region.tpl.php will never be used / applied. It seems that any hook_preprocess_region will not be invoked either.

Is there anything particular about hooking into how regions are themed?


texts: Is there an installation package builder for Drupal?

texts: Does anybody know of any websites that provide a service that allows you to select which modules you want, and download a pre-assembled installation package with the selected modules already in the /modules/ folder?


texts: display newly added field value of account settings

texts:
I added a new field(First name) in Account settings under Configuration & its machine name is 'field_first_name'
I am trying to load this value in home page like this

<?php print $user->field_first_name ?>

But the above code is not working. Please help. I debug $user and found that this value isn't there. What should I do to show the value of the newly added field in home page.

I've added screenshot.


texts: Displaying all values of a List (text) field, whether checked or unchecked

texts:
[Drupal 8]

I have a List (text) field that allows multiple values, displayed as a check box list when editing. But when viewing the node, only the checked values are displayed.

How can I display all values, with an indicator which ones are checked/unchecked? Is this possible with theming?

What I found so far:

For Boolean fields, I can select something like this under "Output format" (e.g., "✔ / ✖"), but this doesn’t seem to be possible for List (text) fields. I guess the workaround would be to use multiple Boolean fields, but this makes Views Exposed Filters harder to use.
For Drupal 7, there is the module Selected and unselected values formatter (via the question How to display all values of List (text) instead of just the selected ones?)
I could imagine (but didn’t try) it would be possible to create a View and display it instead of the field, but then quick-editing would no longer work for this field, as far as I know.


texts: Entity with custom field, how to get these field in template?

texts:
I have created a Slider entity with the drupal console, with the website interface I create some fields to this entity (field_image, field_title, field_subtitle), but I can't manage to get these fields in my template.

I'm new to Drupal 8 and I don't understand how to get these values, all the answer I saw on the web start with the node object but I don't have a node object :/

So I created a block, in the build function I get all the Slider entity to show them in a carousel :

/**
 * Slider homepage
 *
 * @Block(
 *   id = "slider_block",
 *   admin_label = @Translation("Slider (HP)"),
 * )
 */
class SliderBlock extends BlockBase
{

    /**
     * {@inheritdoc}
     */
    public function build()
    {
        $view_builder = \Drupal::entityTypeManager()->getViewBuilder('slider');

        $ids = \Drupal::entityQuery('slider')
            ->condition('status', 1);
        $pids = $ids->execute();
        $slides = Slider::loadMultiple($pids);

        $build = [
            '#theme' => 'carousel_slider',
            '#slides' => $view_builder->viewMultiple($slides, 'full'),
            '#attributes' => ['class' => ['owl-carousel-wrapper'], 'id' => 'owl-carousel-hp'],
            '#attached' => [
                'library' => ['web_core/owl-carousel'],
                'drupalSettings' => [
                    'owl-carousel-hp' => [
                        'singleItem' => true,
                    ]
                ],
            ]
        ];

        return $build;
    }

}

And what I want is to get the values of these fields in my template, this is the template for one slide, and I use this rendered markup in the carousel_slider template after.

{{ slide['slide']['#slider'] }}

I've tried some way to achieve this but I can't manage to find how to access my values...


texts:
I have a paragragh which has 3 font colors throughout it, however every time I try to add the spans inside the paragraph CKEditor takes it upon it's self to remove them on me. How do I get the spans to stay inside the paragraph?

I save this:

Have TROUBLING SYMPTOMS and health concerns taken over your life? Muse can help.

but it turns into this:

Have TROUBLING SYMPTOMS and health concerns taken over your life? Muse can help.