texts: Geolocation: How do I set conditional markers on the Leaflet view?

texts:
I'm using Geolocation to list about 20 pubs / restaurants, but I'd like the user to be able to know if the address is a restaurant or a pub just by seeing the icon.

When I created my content type, I added a boolean (radio type) to let the admin choose between "restaurant" and "pub". The issue now is that I don't really know how I should proceed. I found this module but it's limited to Drupal 7.

I guess I'd need to create a hook, but the documentation about how I should do this is rather light, and after digging for a bit, I discovered that the markers seem can be edited as whole, not each of them individually:

With this code:

function my_theme_views_post_render (ViewExecutable $view, &$ouput)
{
  if ($view->id() === 'my_view') {
    dump($ouput['#rows']['#settings']);
  }
}

I get the following:

As you can see, the marker_icon_path key has an empty value. Also, when parsing each $view->result, I don't see anything that would allow me to change its marker.

Is there a way to change each marker individually?

Thank you in advance


texts: How to manually use Drupal 7's admin Overlay?

texts: I am thinking of using Drupal's built-in admin overlay jQuery script to overlay my own contents. Is it possible?


texts: How to add a custom class or id to a custom display suite

texts:
I've created my custom display suite field and i it works ok, but i would like to add a custom div class or a custom div id,

here is my code

<?php

namespace Drupal\breadcrumbs\Plugin\DsField;

use Drupal\ds\Plugin\DsField\DsFieldBase;
use Drupal\taxonomy\Entity\Term;

/**
 *
 * @DsField(
 *   id = "breadcrumbsDS",
 *   title = @Translation("breadcrumbs"),
 *   entity_type = "node",
 *   provider = "breadcrumbs",
 *   ui_limit = {"article|*"}
 * )
 */
class breadcrumbsDS extends DsFieldBase {
  /**
   * {@inheritdoc}
   */
  public function build(){
    $node = \Drupal::routeMatch()->getParameter('node');
    if ($node instanceof \Drupal\node\NodeInterface) {
      $nid = $node->id();
      $term = Term::load($node->get('field_secciones')->target_id);
      $name = $term->getName();
      $breadcrumbs = '

Home

'.$name.'

';
    }
    return array(
      '#markup' => $breadcrumbs,
      '#wrapper_attributes' => ['class' => ['custom-css-class']]
    );
  }
}

Could you please help me?
regards.


texts:
On a project I'm working on, we'd like to give users the ability to search for nodes via a View with exposed fields, and then have them able to select specific nodes to be added to a list.

We've thought about doing this via taxonomy terms and Views Bulk Operations, but that's not very streamlined (I'd have to set the action to "Modify entity data," selecting the taxonomy field -- but then there'd be a bunch of options on the next page and the default behaviour is to overwrite all the terms attached to a node.).

Any ideas how one can create a simple cherry-picked list, ideally from Views result content?


texts: How can user select attributes for a product when clicking on an add-to-cart link?

texts:
I'm trying to work out the best way of displaying an attribute selection form when a user clicks on an add to cart link (not on a product node). Ideally display a form in a shadowbox with attribute selection and quantity fields and a submit button. I feel like this option must exist somewhere, but I haven't found it.

Any pointers for me?


texts: Why does dpm() sometimes fail and krumo() works

texts:
They both dump variables in the same format & style. From some articles or documentation that I'd read, it seems krumo() calls dpm().

The problem is that sometimes I call dpm($var) and nothing happens, but krumo($var) on the same script works fine. I think I'd had the same problem in the reverse circumstance(ie: krumo($var) does not work, dpm($var) works). Why is this so? Is there some structure that needs to be available on the particular page or script that either of these functions uses for it's display? Maybe some region or block?


texts: Get current region name in node template Drupal 7

texts:
I need to find out what region the node block is appearing in within the node template. I am using node block module to display nodes as blocks but need to know what region the node blocks are appearing in within the node.tpl. In Drupal 6 there was a template preprocess function where you could set a global var to accomplish this but that function is not available in D7.
Thanks for any help.

It won't let me answer my question yet so I will put it here.

If anyone else runs into this and wants to know what region the node is being displayed in within the node template using the node block module or something like it. You can use the template_preprocess_node($vars) function and add the region to the content so that it will be in the content array in the node template like this.

$vars['content']['region']=$vars['elements']['#block']->region;


texts: Basic custom module installation error - "...Controller does not exist in ReflectionMethod"

texts:
I was following this tutorial to create an most simple custom module.

I have created files inside /modules/elevator_search:

And in the /src/Controller I've placed:

The /modules/elevator_search/evelator_search.info.yml:

name: Elevator Search
description: Moduł wyszukiwarki wind
package: Custom
type: module
version: 1.0
core: 8.x

The /modules/elevator_search/evelator_search.module is empty.

The /modules/elevator_search/evelator_search.routing.yml:

elevator_search.content:
  path: '/elevator_search'
  defaults:
    _controller: 'Drupal\elevator_search\Controller\EvelatorController::content'
    _title: 'Hello world'
  requirements:
    _permission: 'access content'

The /modules/elevator_search/src/Controller/ElevatorController.php:

<?php
/**
@file
Contains \Drupal\elevator_search\Controller\ElevatorController.
 */

namespace Drupal\elevator_search\Controller;

use Drupal\Core\Controller\ControllerBase;

class EvelatorController extends ControllerBase {
  public function content() {
      return array(
          //'#type' => 'markup',
          '#markup' => t('Hello world'),
        );
  }
};

It did show up under /admin/modules:

But when I try to install it I get an error:

  ReflectionException: Class Drupal\elevator_search\Controller\EvelatorController does not exist in ReflectionMethod->__construct() (line 123 of core/lib/Drupal/Core/Entity/EntityResolverManager.php).


texts: How do I package a distribution on Drupal.org?

texts:
I am getting some old and mixed documentation issues with building a release for a Drupal 8-based distribution Drupal.org.

The main documentation is How to package a distribution on Drupal.org, which says to use drush make to create a drupal-org.make file. However, when I try to run this command on my site, I get the following error message.

  Make has been removed, in favor of Composer. Use the make-convert command in Drush 8 to quickly upgrade your build to Composer.

That's fine, since I am already using Composer for the project! But how do I actually then publish these dependencies on Drupal.org? Drupal.org is definitely not reading the composer.json file, and building the zip files.

Do I just have to manually make a git tag which includes all the files in the *vendoré directory, so that Drupal.org knows to build this?

I am running Drush version 9.5.2.


texts: How do I install the latest release of Drupal with Composer

texts:
Instructions on Drupal.org for installing Drupal with composer provides the following example:

composer create-project drupal/drupal my_site_name 8.3.*@dev --no-dev

This provides me with the latest DEV version of Drupal. How do I get the lasted stable release?


texts:
I am building a module that requires me to get the $head_title variable in the hook_node_view for some processing...I have found info about that variable in relation to themes and around core, but not getting it in a module...I have successfully used drupal_get_title(), and variable_get() to get info, but I can not figure out how to get $head_title...

Any help?


texts: Need help with AJAX callback function for text field validation in form_alter

texts:
I have an existing form with a User field $txn_user for capturing the User by name using the standard autocomplete. So I guess that's a User object, right?

We have many thousands of users and the data entry people would like to -also- be able to enter just the UID (which they have memorised in many cases). So I need a UID field which has an ajax validation to lookup the user by UID and then, update the UserName field.

So in MYMODULE_myform_alter()...

 $form['container'] = array(
  '#prefix' => '
',
    '#suffix' => '
',
  );

  $form ['#validate'][] = '_validate_add_userpoints_userid';

  $form['txn_userid'] = array(
            '#type' => 'textfield',
            '#title' => 'UID',
            '#size' => 4,
            '#maxlength' => 4,
            '#default_value' => isset($txn_user) ? $txn_user->uid : '',
            '#description' => 'The User ID',
            '#required' => TRUE,
            '#weight' => -15,
            '#disabled' => FALSE,
            '#ajax' => array(
              'callback' => 'validate_uid_ajax_callback',
              'wrapper' => 'example_form_wrapper',
                ),

    );

...and then the field validation callback function

function validate_uid_ajax_callback(&$form, &$form_state) {
    $values = $form_state['values'];
    if( $values['txn_userid'] ) {
        $newuser = user_load($values['txn_userid']);
        if( ! $newuser) {
          form_set_error('txn_userid', 'You have entered an invalid UID. Either leave this blank and select a Username or enter a valid UID');
    }
    else {
        $form['txn_user']['#value'] = $newuser->name;
        $form_state['values']['txn_user'] = $newuser;
        $form_state['input']['txn_user'] = $newuser->name;
    }
  }
}

So the ajax spinner goes off and $form gets updated. $form_state does not.

But I can't figure out how do I set the value of the txn_user and txn_user->uid (the fields in the form so they update dynamically)?

Now... if this helps, here is my $form validate function. This -works-. So the only issue is that users (reasonably) expect that when they update the UID field, the User name will update.

function _validate_add_userpoints_userid(&$form, &$form_state) {
    $values = $form_state['values'];
    if( $values['txn_userid'] ) {
        $newuser = user_load($values['txn_userid']);
        if( ! $newuser) {
          form_set_error('txn_userid', 'You have entered an invalid UID. Either leave this blank and select a Username or enter a valid UID');
    }
    else {
        $form['txn_user']['#value'] = $newuser->name;
        $form_state['values']['txn_user'] = $newuser;
        $form_state['input']['txn_user'] = $newuser->name;
    }
  }
}

TIA,


texts:
I have this module enabled

http://drupal.org/project/contact_form_blocks

but I only have one contact form block, which is set to global.  How would I make another contact form block?  Thank you!


texts: Drupal.behaviors, attach and origin of it

texts:
The structure of Drupal.behaviors is rather similar in Drupal 7 and Drupal 8. Where do attach() and detach() come from?
Thid code is from drupal.js , still wondering where attach method in this.attach is defined?

Drupal.attachBehaviors = function (context, settings) {
  context = context || document;
  settings = settings || Drupal.settings;
  // Execute all of them.
  $.each(Drupal.behaviors, function () {
    if ($.isFunction(this.attach)) {
      this.attach(context, settings);
    }
  });
};


texts: Using Display Suite how can I remove HTML tags from the teaser?

texts:
I'm trying to learn Display Suite and its very powerful.

My teaser summaries contain HTML inside the field and I need to remove that and display only plain text.

How can I do that with Display Suite?


texts: File upload functionality on node display page

texts:
I want to provide an upload button on a node display page. By clicking a button, it should be possible to upload files. Here is what I'm thinking of:

For this I am changing the node.tpl file.

 <?php //code added
     if($node->title=='Course Materials'){?>
        <form action="" name="uploadform" >
            <input type="submit" value="upload" name="upload"/>
        </form>
    <?php  }
    if(isset($_REQUEST['upload'])){ ?>
    <form  method="post" action="" enctype="multipart/form-data">
        <input type="file" name="file"  />
        <input type="submit" name="submit"  />
    </form>
     <?php //end
     }?>

And to save the files:

  if(isset($_REQUEST['submit'])){
    if(isset($_FILES['file']) && $_FILES['file']['error'] == 0){

   //$file = $_FILES['file']['tmp_name'];
   move_uploaded_file($_FILES["file"]["tmp_name"], "C:/xampp/htdocs/drupal6upload/sites/default/files/".$_FILES["file"]["name"]);
    $node = node_load($node->nid);

        // Build the file object
        $file_obj = new stdClass();
        $file_obj->filename = $_FILES['file']['name'];
        **$file_obj->filepath = "C:/xampp/htdocs/drupal6upload/sites/default/files/".$_FILES["file"]["name"];**
        $file_obj->filesize = $_FILES['file']['size'];
        $file_obj->uid = 1;
        $file_obj->status = FILE_STATUS_TEMPORARY;
        $file_obj->timestamp = time();
        $file_obj->list = 1;
        $file_obj->new = true;

        // Save file to files table
        drupal_write_record('files', $file_obj);

        // change file status to permanent
        file_set_status($file_obj,1);

        $node->field_test1[] = (array)$file_obj;
        node_save($node);

        drupal_goto('node/'.$node->nid);
    }
}

But I am facing some problem to set the filepath and file_copy instead of move_uploaded_file.

Any suggestions?


texts: How can I change a file before save in programmatically?

texts:
I want to upload an audio file on Drupal, trim it, and save it in sites/default/files/audio/. I know how I trim the audio file; I only want to set my audio-trim-library in Drupal when the file is uploaded, and not when saved.

How can I do it?


texts: I have created views to display images. Clicking on the image takes to content. View displays the image but when clicking on image it takes to content where image is not displaying. Please help me.


texts:
View search results gives node list based on exposed filters applied when making the search.

After user picks a result (node) and reads it there is no easy way to get him back to search results.

Exposed filters are "remembered", but the option to click back in browser does not seem user friendly, so i am looking for a module to do this. Is there any ?


texts: Where can I get a list of all the Views handler properties when building my own Views handler?

texts:
I'm learning about Views handlers and need some clarification on how its built.

Looking through the Views Bulk Operations module as seen below. There are 2 IF statements that checks for base table name and revision table. Now my questions are:

When it says table, are they referencing to a table name in the database?
title, group, help, etc... where can I find a list of other parameters for this as seen below in the screen shot?
These fields show up when you click on the "add field" button in the View, but what dictates if it shows up in a content type or user type view?


texts:
I have created 2 content types :

Team (Fields: Title, Logo (Image Field)
Game (Date, Team "A", Team "B")

Created a Reference Field at Game content type to pull the logo of each team.

However, when I create a new View table format, everything displays fine, but at the frontpage where I get this message:

  Strict warning: Only variables should be passed by reference in >field_reference_field_formatter_view() (line 316 of >/Users/*/sites/all/modules/field_reference/field_reference.module).

This is line 316 of views.module

$field_entity = !empty($item['entity_id']) ?

I can see that there's something about the fact that the Field Reference is pulling a .JPG file but there's no proper formatter in Views (default, teaser, etc),

Don't know how to correct this,(not a developer) any ideas?


texts: Error embedding drupal views to twig template

texts:
I'm getting an error Twig_Error_Syntax: Unknown "drupal_view" function when I try embedding my views to my twig template {{ drupal_view('newsdesk', 'block_1') }}.

I have already installed twig_tweak, twig_extensions and also installed twig_extensions via composer.

I'm not sure what else I'm missing, I've already also cleared the cache during installation


texts: How to compare two fields for filter criteria in view

texts:
I want to compare this field value with another field value

How can I do that?

Thank you very much!


texts:
I'm looking for a way to inject a feature flag variable so that it is accessible in all Twig templates, but I can't figure out how to do it. I've tried adding variables in preprocessing hooks in my .theme file, but this doesn't seem to do to the trick. For example:

function mytheme_preprocess_page(&$variables) {
  $variables['some_feature_flag'] = 'test_value';
}

function mytheme_preprocess_html(&$variables) {
  $variables['some_feature_flag'] = 'test_value;
}

My template for the node contains {{dump(some_feature_flag)}}, which evaluates to NULL. I can't find a way to get this working.


texts: How can I conditionally show a field in the node/add page?

texts: When users are in node/add/page, I want to show the body field when the title is not empty. How can I achieve this?


texts:
Initially, I have installed the Token module and created a Views block containing years.

I want to filter out the current year from the block (it should not show the current year).

In filter criteria, I have changed content:year ([current-date:custom:Y]), but it is not filtering the current year, and it is showing as follows:

2013(3)
2014(5)
2015(6)
2016(2)

I am expecting the output to be as follows:

2013(3)
2014(5)
2015(6)

How can I achieve this? Any help is greatly appreciated.


texts: How do I render this code in block/node page?

texts:
print render($page['content']['system_main']['nodes'][$nid]['rc_core_item_avail_form']);

I tried putting this into a node in the Omega theme and also in a block directly but nothing at all. Can anyone help?


texts: I installed Drupal 8.1.0 and created a view, but I don't have the option of choosing the node ID (as a contextual filter, for example) but I can select the content ID. If it isn't the same thing, why would the node ID be missing as an option?


texts: Close commenting after X comments have been posted

texts:
I would like to ask if anyone knows how I can set a limit to the number of comments that can be made on a node with Drupal 7.

Perhaps what I'm asking isn't the best solution for what I'm trying to achieve.
I have created a content type (Event); each event will have a guest list which people can sign up to on a first-come-first-served basis. I would like each event to have a limit (ranging from 10 - 100) to the number of people who can register for the guest list position.

Any advice would be much appreciated.


texts:
i installed the module Fbconnect in my drupal 7 site

the fbconnect button starts appearing now but the window which opens upon clicking the button, gives the error ,"An error occured, try again later."

Anyone please help


texts:
In our business we assign tasks to users based on the last digit of a company ID. When I created the view for these users, it was simple to create a "Formula" field and use RIGHT(field name, 1) to get this value.

I'd like to make an exposed filter that will allow users to only see companies ending in, say, 5 (for example).

Question: Is using the "Sort" function the best way to do this, or is there another way to add filtering to a table created by a view? It would be wonderful to add text search filters to each column, but I'm not sure if this is possible.

Question: How do I create a new field and make it available in the "add field" interface?

Thanks! Rich (who isn't the normal drupal developer and was left to learn on his own)


texts: Remove "Language Undefined" from content with Multilingual module

texts:
Using Multilingual - Internationalization module, now all my pages show:

  Language
  Undefined

At the bottem. How do I remove this text? I'm using the language switcher, and I have already disabled "Hide content translation links" in the module, but I guess that isn't it.


texts:
How can I get count of deleted rows after db_delete?

db_delete('node')
  ->condition('uid', 1)
  ->execute();

something like

$count = db_delete('node')
  ->condition('uid', 1)
  ->execute()->columnCount();

doesn't work


texts:
When a user resets his password he/she gets an email with a link which adds a message to the website and a hyperlink which it redirects him to the /user/[uid]/edit?token=... page.

How can i alter this link ?


texts: How do I add a CSS class to a form label?

texts:
I want to add a CSS class to a label on a page that is using Drupal 8 Form API.  I have been unable to find a reference online on how to apply that.
I have used the following workaround, but it produces some strange results.

public function buildForm(array $form, FormStateInterface $form_state)
{
    $form['label1']  = array(
        '#type' => 'label',
        '#title' => $this->t('QUESTIONNAIRE'),
        '#id'         => 'lbl1',
        '#prefix'     => '
',
        '#suffix'     => '
',
    ) ;

and the HTML rendered is:

QUESTIONNAIRE

Not only is the div statement in the wrong place but it is rendered twice.

I had found postings from several years ago that show this was not possible, but I am hoping that since then, and with D8, it has been fixed.
I do not want to do it with prefix/suffix, but as a separate array element.

PS: this site is Drupal 8.0.0-rc2


texts: Anchor links to views grouping field titles

texts: I want to make a table of content block where I link to the grouping field titles on a view. The problem is that the grouping field is only a h3 without any class or id. Is there a way to nest the h3 in a div with an unique ID so I can create an anchor link for it?


texts: How to display form element and label inline

texts:
This must be simple, but I cannot find the answer.

I want the label and the textfield on the same line. I tried this:

'odt-filter' => array(
  '#type' => 'textfield',
  '#title' => 'Filtra',
  '#attributes' => array(
    'id' => array(
      'odt-filter',
      ),
    'class' => array(
      'container-inline',
    ),
  ),
) ,

but then the class is applied to the input element, not to the item that contains both it and the label:

  Filtra
  <input id="odt-filter" class="container-inline form-text" data-drupal-selector="edit-odt-filter" name="odt-filter" value="" size="60" maxlength="128" type="text">

so that the class has not the desired effect. I can (and I actually did, somewhere else) enclose the form element in a container which I can apply the class to, but since a container is already provided by default, I guess there should be a way to add a class to it... isn't there?


texts:
In drupal 7 there is a field which displays the node`s language.

I have a multi-site installation and plenty of content types on each of sites. I don`t want to click for hours hiding this field. By default it is generated  with "form-item form-type-item" classes.

How could i add a class to this field to be able to hide it in css?

Thanks


texts:
Is there a specific module or a definied mechanism to connect a given external data base to a view?

settings.php

$databases = array (
  'default' => array (
    'default' => array (
      'database' => 'd3js',
      'username' => 'root',
      'password' => '',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),

  'NewDataBase' => array (
    'default' => array (
      'database' => 'NewDataBase',
      'username' => 'username',
      'password' => 'password',
      'host' => '131.188.76.40',
      'port' => '3306',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

This is the module that is related to the view.

 /**
  * @file
  * D3 views module file.
  */

 /**
  * Implements hook_views_api().
  */
  function d3_views_views_api() {
   return array(
   'api' => 3,
   'path' => drupal_get_path('module', 'd3_views') . '/views',
  );
 }

 /**
  * Implements hook_theme().
  */
function d3_views_theme() {

   return array(
   'views_ui_style_d3_options_form' => array(
   'render element' => 'form',
   ),
 );

}

/**
 * Implements template_preprocess_views_ui_style_d3_options_form().
 */
 function d3_preprocess_views_ui_style_d3_options_form(&$vars) {
   drupal_add_css(drupal_get_path('module', 'd3_views') . '/css/views_ui_style_options_form.css');
 }

/**
 * Theme the form for the table style plugin.
 */
 //declarition of the variables related to form (tree)
 function theme_views_ui_style_d3_options_form($variables) {
 $form = $variables['form'];

 $output = drupal_render($form['library']);

 $header = array(
 t('Field'),
 t('Display'),
 t('Aggregation'),
 t('Data type'),
);
 $rows = array();
 foreach (element_children($form['columns']) as $id) {
 $row = array();
 $row[] = drupal_render($form['columns'][$id]['name']);
 $row[] = drupal_render($form['columns'][$id]['display']);
 $row[] = drupal_render($form['columns'][$id]['aggregate']);
 $row[] = drupal_render($form['columns'][$id]['type']);

 $rows[] = $row;
 }

 $output .= '<fieldset><legend>Data</legend>' . theme('table', array('header' => $header, 'rows' => $rows)) . '</fieldset>';

 $output .= drupal_render_children($form);
 return $output;
}

This module also has and I didn't know exactly where to connect to the database.


texts: How do I get the path of the favicon in a multisite?

texts:
I have a multisite website with multiple themes,each contains favicon.
I have to show the favicon from the active theme in website.

Admin page shown the favicon from admin theme or if favicon is not set its shows the default icon (misc/favicon.co) whereas the website foranonymous users doesnot show the favicon.

With reference to the existing issues in Drupal exchange it can be managed by the following code in a custom module.

/*
 * Implements hook_html_head_alter
 *//*
function mymod_html_head_alter(&$head_elements) {
   global $base_url;
   $default_favicon_element = 'drupal_add_html_head_link:shortcut icon:' . $base_url . '/misc/favicon.ico';
   unset($head_elements[$default_favicon_element]);
}

function mymod_init() {
  global $base_url;
  $favicon_uri = $base_url .'/'. drupal_get_path('theme',$GLOBALS['theme']).'/favicon.ico';
  if (!file_exists($uri)) {
    $favicon_uri = $base_url .'/'.drupal_get_path('theme', 'mytheme100').'/favicon.ico';
  }
  // Specify new favicon location
  $element = array(
    'rel' => 'shortcut icon',
    'href' => $favicon_uri,
  );
  drupal_add_html_head_link($element);
}

But since I have used hook_init its not a better method.I have tried out the same in theme's template.php file with hook_html_head_alter()

    // Search the head elements for the Favicon
global $base_url;
   $favicon_uri = $base_url .'/'. drupal_get_path('theme',$GLOBALS['theme']).'/favicon.ico';
  if (file_exists($favicon_uri)) {print"<br>iff";
    $favicon_uri = $base_url .'/'.drupal_get_path('theme', 'mytheme100').'/favicon.ico';
  }

  foreach ($head_elements as $key => $element) {
    if (!empty($element['#attributes'])) {
      if (array_key_exists('href', $element['#attributes'])) {
        if (strpos($element['#attributes']['href'], 'misc/favicon.ico') > 0)
        {
          // Change the URL
          $head_elements[$key]['#attributes']['href'] = $favicon_uri;

          // Or, delete the favicon link entirely
          //unset($head_elements[$key]);
        }
      }
    }
  }

This code didn't show the favicon.
Any help will be appreciated.


texts: Why do so few code examples use the ::load($id) method for loading entities?

texts:
Over at How to get term name from a tid? the accepted answer for "how do I get the name for a Term" is this:

use Drupal\taxonomy\Entity\Term;
...
$term = Term::load($tid);
...

That's really nice, easy to read code (and very easy to remember). It's also, as it turns out, applicable to all entity types in Drupal (just substitute the Term class for the type of entity you want).

Why then, do the overwhelming majority of the code examples and tutorials published around the place seem to advocate this monstrosity? ...

$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($tid);

That approach bakes in one of my [many] grievances with PHP in general - it's full of magic strings! How the hell am I supposed to know at "compile time" whether 'taxonomy_term' is the right argument to getStorage()?? There's not a PHP IDE in the land that'll catch me sticking 'taxonomy' in there instead.

Looking at the contents of that ::load method (which is defined in \Drupal\Core\Entity\Entity and shared by all Drupal entities), it's got all the dependency-injection cleverness of that second-approach - plus it fills in the right argument to getStorage() for you automatically!

So why does more of the Drupal community not use it? Is there something I'm missing? Or is it just to teach us "first principles" so that we can write shared code that works with any entity type? (you'd need the long-hand way in a hook that was intended to work across all entity types).


texts: Omega theme conflicts with CSS of Seven administration theme, how to resolve?

texts:
Not sure exactly where my problem stems from but here goes: I am developing a site with an Omega4 subtheme. Something in the css rules is conflicting with the CSS for the Div: Views-ajax-popup and overwriting the default white back ground to none. This makes the UI visually hard to use, and while I can get by with highlighting the text, but my other site users are not so adept.

The issue is I have no idea what's causing the conflict, or where to address it. In chrome inspector, setting the background to white corrects what I want. The css for the body seems to be the issue, it's getting it's styles Media=screen, and I can see that the default CSS is white, but it being overwritten but again no idea from where.

So, what's causing my css conflict with the admin theme and how do I fix it?


texts:
In my site when a user logs in he is redirected to the profile page(profile2 module). But when returns to the site(and is already logged in), he is taken to the user account page. How do I override this redirect and see to that he is take to profile page?

UPDATE:
The user must be redirected from the site frontpage which contains the user login form


texts: Whats the difference between "Content Type" and "Content Types" on a block configuration form?

texts: Whats the difference between these two tabs? There is no help text here. One has "negate" the condition but the other does not.


texts:
I've been playing around with D8 and have managed to break a few things I can't figure out how to fix. Most recently, after installing (via manually adding the module code to the modules folder) the Name Field module and subsequently enabling it in the Admin panel, my Drupal 8 instance started throwing fatal PHP errors. No problem, I thought, apparently the module has a bug and I'll just remove it for now. Not so easy. I removed the module folder from my instance, but the errors are persisting.

Not that the specific error matters as this question is not about troubleshooting the module, but here's an example of something I get after removing the module code:

  Uncaught PHP Exception Drupal\Component\Plugin\Exception\PluginException: "Plugin (name) instance class "Drupal\name\Element\Name" does not exist." at /srv/http/drupal.protestan.org/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php line 87

Is there a way to disable a malfunctioning module without being able to load the control panel? I've looked around but all the hacks for D6/D7 including tweaking the database manually don't seem to apply any more. At the very least the layout has changed and I was unable to find the corresponding bit to toggle. Likewise  the current version of drush does not seem to be able to cope with D8 yet.

Is my whole database borked? Is there a secret URL or other way to load the Admin panel with no modules enabled (i.e. some sort of safe mode)?


texts:
I'm trying to set a custom 404 page but is not working.
What I tried:

configuration - system - basic site settings and set node path on 404 page -> didn't work
add page--404.html.twig to my custom theme -> didn't work
in my custom-theme.theme added _theme_suggestions_page_alter function -> didn't work

Always show default 404 page, not my custom page.
I clear cache on every attempt.
Is there something I am missing?
Thanks in advance

Edited
Tried on local and cloud acquia server
I check with another websites that I build and all of them give me this 404 page (default)

But with this specific website I get this 404 page

It seems this website 404 error is handle by browser and not by drupal 8(?)

Edited 2
Another thing I notice is when I type a wrong URL appear on "log messages"

But on current website (the one I can't set custom 404) I don't have any error on "log messages".
Is there any code/config to enable/disable this?
Maybe this is same problem?


texts: Need Separator image for views ticker content?

texts: I am using Views Ticker module for display the news in my site. It's perfectly worked for me. I want separator image for one content to another content.


texts:
After have read some link i'm still confused about the difference between service and plugin.

I am not speaking about plugin like block or Field formater etc...

i would like to take an example :

I have create a module for add paiement feature to my site.

The question is why use service and not plugin ?

SERVICE

This module has an interface, every paiement type has a setPaiement method.

This is my module :

As you can see i have the interface, and every paiement Type like Paybox, Paypal class implement this interface.

  paiement.service.yml

services:
  paybox_services:
    class: Drupal\paiement\Paybox
    arguments: ['@config.factory','@request_stack','@phpmailer_services']

  paypal_services:
    class: Drupal\paiement\Paypal
    arguments: ['@config.factory']

  stripe_services:
    class: Drupal\paiement\Stripe
    arguments: ['@config.factory','@request_stack','@phpmailer_services','@current_user']

PLUGIN

With the plugin method, i ll do the same, but the implementation ll change on the architecture folder.

The main difference is when i call the service or the plugin :

  For the service

i ll inject it in the construct where i need it.

  For the plugin

i ll use the plugin.manager.archiver where i need it.

So what is the good way to add feature like this ? Plugin or Service ?

Or maybe i miss something.


texts: How to join a path to a file in code, "windows safe"

texts:
Given a hook (e.g. hook_theme()) and a path where something has to be looked up (e.g. templates), what is the cleanest way to deal with this?

I have the following directory structure:

sites/all/modules/mymodule

mymodule.module
templates

mymodule.tpl.php

When I define that path in code, I use the following code.

function mymodule_theme($existing, $type, $theme, $path) {
  return array(
    "mymodule"  => array(
    "variables" => array(),
    "path"      => $path . "/templates",
    "template"  => "mymodule"
  );
}

I want this code to work on Windows too, without having to do checks for OS inside that function.


texts:
I want to add custom button on node page.

I tried with hook_node_view but it didn't show up.

like this:

function mymodule_node_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {

$build['mybutton'] = [
  '#type'       => 'button',
  '#name'       => 'mybutton_name',
  '#value'      => t('Click Here'),
  '#attributes' => [ 'class' => 'button button--primary'],
  '#weight'     => -11,
];

}

What am I doing wrong?

EDIT:

Here is the template

{#
/**
 * @file
 * Display Suite 2 column stacked template.
 *
 * Available variables:
 * - outer_wrapper: outer wrapper element
 * - header_wrapper: wrapper element around header region
 * - left_wrapper: wrapper element around left region
 * - right_wrapper: wrapper element around right region
 * - footer_wrapper: wrapper element around footer region
 * - attributes: layout attributes
 * - header_attributes: attributes for header region
 * - left_attributes: attributes for left region
 * - right_attributes: attributes for right region
 * - footer_attributes: attributes for footer region
 * - header: content of header region
 * - left: content of left region
 * - right: content of right region
 * - footer: content of footer region
 */
#}

<{{ outer_wrapper }}{{ attributes.addClass('ds-2col-stacked', 'clearfix') }}>

  {{ title_suffix.contextual_links }}

  <{{ header_wrapper }}{{ header_attributes.addClass('group-header') }}>
    {{ header }}
  </{{ header_wrapper }}>

  <{{ left_wrapper }}{{ left_attributes.addClass('group-left') }}>
    {{ left }}
  </{{ left_wrapper }}>

  <{{ right_wrapper }}{{ right_attributes.addClass('group-right') }}>
    {{ right }}
  </{{ right_wrapper }}>

  <{{ footer_wrapper }}{{ footer_attributes.addClass('group-footer') }}>
    {{ footer }}
  </{{ footer_wrapper }}>

</{{ outer_wrapper }}>


texts: How to create a better (more userfriendly) admin interface for non-technical "admin user"?

texts:
I'm trying to make Drupal admin interface easier for non-technical users.
Actually, I'm trying to "create" a new interface for these kind of users. I'm using Views, VBO, Rules etc. to make a better admin interface experience without scaring them with a complex structure.
Easily;

edit, enable/disable blocks,
edit-rearrange main menu,
manage users,
manage contents,
manage files, images etc. uploaded via Drupal interface,

What should be done to increase user experience of this admin interface?
Is there any must-use module you suggest?


texts: Multiple user-selected front page layouts

texts: I would like my site builders to be able to select from three unique front page layouts.  The selection can be made either through config or through theme settings, but not require any coding.  The three pages have different pieces of content consisting mostly of fields.  I've looked at panels but I would prefer to use something a little lighter as panels seems like a lot for this one piece of functionality.  Has anyone here solved a similar problem?


texts: Is there a module for user level permissions?

texts: I know that permissions are controlled by admins. I want regular users to control a different set of permissions, for example my users will have pictures, friends list, personal information in there profile. I want them to be able to create groups and limit access so certain groups can see certain content. Is there a module for this or do I need to put on by big boy paints and start coding?


texts: Get all fields for a content type using REST

texts:
Is there any way to get all fields attached to an entity in D8 (including widget types), using REST services? I've tried the following endpoints, but none of them had the list of fields:

/entity/node_type/{node_type}
/entity/entity_form_display/{entity_form_display}
/entity/entity_form_mode/{entity_form_mode}

I need this if for an app that will generate dynamic forms, based on what's defined in the Drupal backend.


texts:
I am trying to make textfields clickable so it would appear as link. What would be the best solution for this? I tried Link module, but it is not what I am looking for. This is how I got my textfield written:

$form['element4']['link4'] = array(
        '#type' => 'textfield',
        '#title' => t('link for 4th div'),
        '#description' => t('your link'),
    );

I need for it to stay textfield as user can input his value, but I want it to be displayed lets say in blue color and so that you could click on it. How could I do this in the most simple way?


texts: Filtering date fields in Views - How can I test for NULL

texts:
When I add a date field to the filter criteria, I get a choice of operators "Is less than", "Is less than or equal to" etc, but no way to test is or is not NULL.

How do I test for these conditions?


texts: A better way to show a node-based field in a region outside of the node itself

texts:
I'm using the 'AddThis' sharing module with Facebook and Twitter so that when a user is on a page of the site they will be able to share it with others. This would include the front page.

The problem I'm discovering is that to use this module you have to add it as a field for a content type...so I can basically add it to all pages EXCEPT the home page.

Putting aside the issue with the front page for a moment, I'd like the sharing buttons to actually appear in the footer, not in the node body itself. The footer is a totally different region. Would this entail me using my .tpl files to change where this specific field appears (ie. hiding it and then showing it again but in the footer for the node)?

Or is there a better way to handle this?


texts: How to make hook in custom module to execute only on condition

texts:
How to make contributed module hook execute only if conditions are met. Those functions seem to get automatically invoked. Environment is a custom module.

examples:
1.

if ($condition) {

   function mymodule_modulename_alter ($parameters) {
     //altering code here
   }

}

2.

    if ($condition) {
           //if condition is met, i call the function included in this custom module
           mymodule_modulename_alter ($parameters)
      }

  function mymodule_modulename_alter ($parameters) {
         //but this function will get auto-invoked! I want it run only if $condition is met.
       }

Thanks


texts: How to set menu items on mobile as stacked full-width items?

texts:
I am using Superfish, and my menu is perfect for normal displays.  However, for small smartphone displays, I want my menu items stacked and spanned the width of the display.  Also, when an item is clicked with child items, the top level items go away and display the child items.

I can't figure out how to do this from the SF documentation or searching on the web.


texts: Entity Reference and Views to allow a nested structure

texts:
I'm trying to implement a nested structure in such a  way as to get a table (within a view?) similar to this:

Parent      Child       Grandchild      Age     Sex
John                                    56      M
            Lisa                        29      F
                        Jim             4       M
                        Louis           6       M
            Mark                        24      M
            Sanda                       21      F
Marcela                                 45      F
            Sam                         21      M
            Andy                        18      M
...

For this I defined the following content types:

Parent:
+Title (name)
+Age
+Sex
+Child [entity reference]

Child:
+Title (name)
+Age
+Sex
+Grandchild [entity reference]

Grandchild:
+Title (name)
+Age
+Sex

The +Age and +Sex attributes are shared between the content types, and the nested structure is implemented with entity reference fields.

I tried using Views, but I couldn't find a way to achieve this.

Any hint ?

Note:

With Views I managed to get the following table:

Title       Age     Sex     Children
John        56      M       Lisa, Mark, Sanda
Marcela     45      F       Sam, Andy

which is a basic use of Views...

Actually I cannot manage to relate Grandchild to Parent entity, through Parent > Child > Grandchild structure.


texts: my urls are not replacing spaces with hyphens

texts: I have url aliasing and clean urls. They are making the content have good urls, but for some reason it's not always rendering with hyphens. It leaves the spaces and breaks pages.


texts: Drupal Commerce, behaviour when you disable order status

texts:
There is possibility do disable order statuses with "hook_commerce_order_status_info_alter"
but I am wondering what happens then. Example is. Alipay has many pending statuses. I would summarize them into few or just one. But wondering what would happen then when Alipay returns some status which is not available or disabled?


texts: How to avoid rendering of same node in two different view blocks on same page ?

texts:
One of my page shows two different view blocks. Suppose View-block-1 and view-block-2.
Both renders and display nodes from same content type, say products. Node display Limit is set to 1 in both view and ordered by random.

Products:

Product 1

Product 2

Case 1

View-block-1  |   View-block-2

Product 1     |  Product 2

Case 2

View-block-1  |   View-block-2

Product 1    |    Product 1

Problem is that (case 2) sometimes both block shows same node since ordering is set to random.

Is there any way to ensure that both view do not show same node ?


texts: How to show a specific date format in an English view?

texts:
I have multi-language web site. I have a date field with a specific format in a view, and I want to display the date in English format.

How can I do this?


texts: Is there an alternative to themegarden.org - one that has Drupal 7 themes?

texts: I like themegarden.org and I think it'll be a useful tool to help me explain to clients and colleagues how content and presentation can and should be separated. It looks like Theme Garden only caters for Drupal 4.7, 5 and 6. Does anyone know of a D7-compatible site where I can browse themes as easily?


texts: Including call to drupal_get_form('user_login') causes seemingly endless loop in Firefox

texts:
One of the features that I've tried to include in my Drupal site is a persistent login form in the page's footer. After doing some searching around, I found that the best way to call the login in Drupal 7 is the following:

print drupal_render(drupal_get_form('user_login'));

So, I put this in a simple if/then statement that looks like this:

<?php
global $user;

    if ( $user->uid ) {
        echo "Go to Admin area.";
    }
    else {
        print drupal_render(drupal_get_form('user_login'));
    }
?>

I then tucked this away in a jQuery accordion, and it was working just wonderfully in Chrome.

Then came Firefox. It loaded fine the first time, but then once I clicked on the accordion to view the login, it never loaded correctly again. I know that this is the culprit, because once commented out, the page loads fine in Firefox. Am I doing this call wrong?


texts: Drupal 8: Node "options" does not exist for Node "Drupal\Core\Template\TwigNodeTrans" error after update

texts:
after updating Drupal 8 from 8.6.14 to 8.6.15 (twig v1.40.1) I suddenly get this kind of fatal errors:

 Uncaught PHP Exception Twig\Error\SyntaxError: "An exception has been thrown during the compilation of a template ("Node "options" does not exist for Node "Drupal\Core\Template\TwigNodeTrans".")

It happens in my custom theme, but also in core/themes/classy/templates/views/views-mini-pager.html.twig

Do you know how to solve this or what the origin is?


texts: Best method to clean up database table orphaned data in Drupal 7?

texts: Currently my files and images table has over 100k entries, but I know for a fact that alot of them are orphaned and the files do not exist anymore. What is a best method to cross-reference this data to see if the file exist so i can delete them?


texts:
I have built a site using drupal 7.41. I have added the login form by adding this line in my page.tpl.php "print render($page['login_container']);".

When user click on the login button I want to show a popup with options "yes" and "no". only when the user choose "yes" he/she should be logged in. I need change the style of this pop up, that's why I cannot use jquery window.confirm function.

I went through drupal documentations and found about the function confirm_form.
this is what I am trying to do, but not able to.

I created a hook menu and then called the confirm_form fucntion.
But I am not able to call this from the login submit button.


texts: How to pass value from form to url parameter

texts:
in my sidebar i have block with a form where users add name of restaurant and when they cick Submit they are supposed to be redirected to a page where my webform is.

I need url like this /add-your-restaurant?key=value-from-text-field but im not sure how to pass that value in url with my form.

I have already %get[key] as default value for my Name field in webform.

This is my html form:

<form name="addres" id="addres" method="post" action="">
<span>
<input type="text" name="addresfield" class="resfield" value="Enter your Restaurant name"/>
</span>
<input type="button" class="btn"/>
</form>


texts: Template Suggestions Causing Undefined Variable

texts:
I am developing a Drupal theme from scratch, and I have run into some trouble with template suggestions. Using the solutions discussed on Drupal support, I created a template.php file and included this code:

function stronger_preprocess_page(&$vars) {

  if (isset($vars['node'])) {

    $vars['theme_hook_suggestion'] = 'page__'.$vars['node']->type; //
  }
}

This has allowed me to successfully use page--nodetype.tpl.php template files, but I am also randomly seeing errors such as:

  Notice: Undefined variable: node in include() (line 24 of /Applications/MAMP/htdocs/strong-local-final/sites/all/themes/stronger/page.tpl.php).

I have read elsewhere that the node variable needs to be re-declared, but I am unsure of how or where to do this. Any help or references would be greatly appreciated!


texts: Is there anything inherently wrong with mutually reliant custom modules?

texts:
The custom modules on the main site I work on evolve.   I try to separate their functions and write multiple modules based on discrete needs but sometimes they grow into each other once written.

Now I have two modules that are inextricably linked to each other to the point where each of their .info files have dependencies[] = theothermodule in them to remind future site admins of this fact.

Of course I can undo this and separate the functions out, but thinking about it made me wonder why I should do it, and that advice on this topic might be useful here.


texts: Show only comment textarea, if entered something show required fields for anonymous user

texts:
I want to make commenting easy for anonymous users. "Anonymous posters must leave their contact information." is enabled.

What I want to do is to show only the comment text field at first and if the user enter some text (more than 20 characters etc) then show the other fields (name, e-mail, homepage).

I think it will be better not to show 3-4 empty fields instead of one text area to comment. First, focus on the comment (content) and then the required fields.

Is there any out of the box solution for this or if anybody did that before?


texts: Submission of dynamically generated input fields

texts:
I have created data entry form using Drupal 8 Webform (Yaml forms),
Part of the form is table field which hosts dynamically generted textfields using jquery shown below:

 $(document).ready(function(){
    var input="";
    var column="";
    $(".add-row").click(function(){
    var new_row =jQuery('<tr>');
    input= jQuery('<input>').attr({type: 'text',name:'names[]'});
    column=jQuery('<td>').append(input);
    input= jQuery('<input>').attr({type: 'text',email:'emails[]'});
    column=jQuery('<td>').append(input);
    new_row.append(column);
        $("table tbody").append(new_row);
    });
});

However, to my surprise when I hit submit button of the form all other fields are submitted except the fields
which have been generated dynamically on the table field.It seems Drupal 8 can not recognize the dynamically generated input
fields

So my question how can I make Drupal 8 recognize my dynamically generated input fields. I want to see the data in these fields in
the database. Please help. Your assistance will be greatly appreciated


texts: Allow to change site logo without giving too many privileges

texts:
I want to allow a certain role to change the site logo, but I don't want to give the 'administer site configuration' permission to that role.

At first I was hiding some form elements from the theme settings forms using hook_form_alter() and $element['#access'] = FALSE, leaving only the options related to uploading a new site logo; after that I noticed the user would need the 'administer site configuration' permission to access that form.

Do you have any idea?


texts: Webform api - using the included hooks to change email destination?

texts:
I am looking to have a webform posted to specific destination depending on submitted values.

I thought this could be done through the webform api, webform.api.php line 209 has this hook defined:

/**
 * Alter the display of a Webform submission.
 *
 * This function applies to both e-mails sent by Webform and normal display of
 * submissions when viewing through the adminsitrative interface.
 *
 * @param $renderable
 *   The Webform submission in a renderable array, similar to FormAPI's
 *   structure. This variable must be passed in by-reference. Important
 *   properties of this array include #node, #submission, #email, and #format,
 *   which can be used to find the context of the submission that is being
 *   rendered.
 */
function hook_webform_submission_render_alter(&$renderable) {
  // Remove page breaks from sent e-mails.
  if (isset($renderable['#email'])) {
    foreach (element_children($renderable) as $key) {
      if ($renderable[$key]['#component']['type'] == 'pagebreak') {
        unset($renderable[$key]);
      }
    }
  }
}

So I set out to use it with the following ina custom module:

// Implements hook_webform_submission_render_alter
function formHelper_webform_submission_render_alter(&$renderable) {
  // Just a dump to confirm hook was invoked...
  kpr($renderable);
  dpm($renderable);
}

However, it seems the hook is not being called. Am I missing something in here to use webform api? Is this even a regular hook? it seems I could get away with just calling the api's function but I would like to be sure of the Drupal way to go.


texts: Which drupal function can you use to invoke a function stored in contrib module (e.g. in an .inc file)?


texts: How to run a batch process in regular interval

texts:
I need  to Unpublish the nodes which are all not Updated for more than some specified time.

I'm having the query to fetch nodes and by using a batch process I will Unpublish those nodes one by one.

Now I want to schedule this operation to be run every day. How can I achieve that? using drush or something.

I have cron running at regular intervals. I need to run these scripts apart from the cron job i.e as a separate one.


texts: How to pre-generate image styles after image is uploaded

texts: Is there  a quick way in Drupal 7 to generate image styles straight after the image is added to the image field?


texts: Force redirect if a valid taxonomy term is not at the start of the URL?

texts:
As a follow on from this question I am trying to prepend all URLs on the site with a taxonomy term.

The term itself is handled by a custom module for the most part, however elements of the site such as the calendar modules page view don't allow for me to intervene and theme the link accordingly. If a user goes to the following URL:

site.com/calendar

Then they should be redirected to:

site.com/city/calendar

The city itself would be acquired from a cookie set when they hit the front page of the site, or defaults to 'all-cities'.

My vision for such a system was to check in hook_boot against a predefined array for offending patterns (such as calendar) and if they are found, then it forces a redirect to the same page but prepends the city.

My gut feeling is that this is a bad approach and possibly un-Drupal. Please let me know if there is a standardized method I should be following for such things.

O’ Salvation, Deliver Me From Evil!


texts: why my custom jquery code stopped working on a multipage webform after upgrade to WF x6

texts:
I have a long questionnaire as multi-page webform and I do many mostly simple counting and addclass using jquery done via a custom module I made for the purpose. This was perfectly working before on Drupal 8 with WF x5 but not anymore after upgrading to Webform x6 (dev) on latest Drupal 9.02.
The below sample code only works if I move the related form to be on first page while it doesn't load on later pages!
(function($, load) {
    $('input.countme').change(function(){
        var a =  $("input.countme:checked").length // count all checked checkboxes with the css class "countme"
        $(".cm_score").val(a)  //update the value of the textfield that has the class ".cm_score"
    });
})(jQuery);

Below is myModule.libraries.yml
wfcount:
  version: VERSION
  css:
    theme:
      css/webform.css: { preprocess: false }
  js:
    js/wfCount.js: { preprocess: false }
  dependencies:
    - core/jquery


texts: How to display default image in Drupal 8

texts:
I have an image field that has a default image if no image is uploaded. In mytheme.theme file I am trying to get the default image and display it. Here is the code that I am using:

$field = $entity->get($fieldName); // Loading from field definition
if ($field) {
  $default_image = $field->getSetting('default_image');
  if ($default_image && $default_image['uuid']) {
    $entityrepository = Drupal::service('entity.repository');
    $defaultImageFile = $entityrepository->loadEntityByUuid('file', $default_image['uuid']);
    if ($defaultImageFile) {
      $image_uri = $defaultImageFile->getFileUri();
    }
  }
}

The issue is that the $default_image['uuid'] is empty. I am not sure how that can be if the default image is set. Since the image uuid is empty, the image cannot be loaded and now I am stuck.

What is wrong with the code that I am using? Or is there another way to accomplish this that works?


texts:
In D7 I'm creating a form for a custom module.  I would like one of the form fields to provide a wysiwyg editor (these work and render properly elsewhere around the site).  In my custom form though, the text_format field doesn't render.  If I change the type to 'textarea' it shows up, but as text_format, it's just non-existent in the rendered output.

My code is like this:

function mymodule_menu() {
  $items = array();
  $items['admin/mymodule'] = array(
    'title' => 'My Module Form',
    'page callback' => 'mymodule_form',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function mymodule_form($form_state) {
  $form = array(
    'field1' => array(
        '#type' => 'textfield',
        '#title' => t('Field 1'),
        '$required' => true,
    ),
    'field2' => array(
        '#type' => 'text_format',
        '#title' => 'Filed 2',
        '#default_value' => "",
        '#format' => 'filtered_html',
    ),
  );
  return $form;
}

Can anyone spot a problem with this?  What else should I be looking for to understand why the field doesn't render when the type is 'text_format'?


texts: Why is config for my view going to config/local?

texts:
We use config_split to slice off parts of the site config to other config folders (local, dev, stage, etc). This more or less works as expected.
I have one view which always exports to config/local even though there is nothing I can see in the config_split configuration which is suggesting it do this.
Any ideas why it fails to export to the correct folder (config/sync)?


texts: Get the raw URL of an image in views-view-table.html.twig

texts:
In the views-view-table.html.twig template, I can get the raw values of fields by repeating on rows and accessing the view object. For example:

    {{ view.field.title.value(view.result[i]) }}   {# the title of the node in this row #}
    {{ view.field.field_link.value(view.result[i]) }}   {# the URL in the link field #}

With Formatter for an image field set to URL to image in the view, I can test to see if an image exists in the field by doing:

    {% if view.field.field_image.value(view.result[i]) %}

QUESTION: How can I get the raw URL for the image? If I use:

    {{ view.field.field_image.value(view.result[i]) }}

I get a number as output. I have tried:

    {{ view.field.field_image.value(view.result[i]).entity.uri.value }}   {# I get nothing #}

and various combinations of things, but haven't hit the right one.

I know I don't have to use the raw values. For example, I can use

    {{ row.columns.field_image.content|render|striptags|trim }}

to get the URL, but this seems like a lot of processing to get something that must be available in the raw result.


texts:
How do I get the product ID when I submit the form?

I have http://localhost/drupalcart/product/7?v=7 as URL. I need to get that 7 when I click on Add to cart.

(The form doesn't come from a third-party, but it's something I made.)


texts: What is the correct way to update my cached block when a node of a given type is saved or updated?

texts:
I have a custom module with a block plugin:

SliderBlock.php

class SliderBlock extends BlockBase {
  public function build() {
    $build = [];
    $build['#theme'] = 'slider_block';

    return $build;
  }
}

I want to render a list of nodes of type 'slides' in the block (it will eventually be a custom slider feature)

mymodule.module

function mymodule_theme() {
  return [
    'slides_block' => [
      'variables' => [
        'slides' => get_slides(),
      ],
    ],
  ];
}

function get_slides() {
  // Load all slides nodes.
  $nids = \Drupal::entityQuery('node')
    ->condition('type','slides')
    ->condition('status','1') // Only published slides nodes.
    ->execute();
  $nodes =  \Drupal\node\Entity\Node::loadMultiple($nids);

  return $nodes;
}

and I loop over each in the template to get the markup I need:

slider-block.html.twig

{# markup for slider here #}
{% for slide in slides %}
  <p>{{ slide.label }}</p>
{% endfor %}

The above template shows me the title field for each Slides node, which is what I expect. The problem is that if I un-publish a Slides node, the markup is not updated unless I clear caches.

Alright, this sounds like a cache issue, so I dove into a google search mission and discovered a series of ways to disable caching for the block. None of which seem to work, for anonymous users or otherwise:

// Unsuccessful:
public function getCacheMaxAge() {
  return 0;
}

// Unsuccessful:
$build['#cache'] = [
  'max-age' => 0,
];

I looked at cache contexts, as far as I could tell, there was no 'node' based cache context. If I understood them correctly, cache tags wouldn't help, since I don't know the ids of any given node of type 'Slides'.

I 'only want to' disable caching for this block. This block will be rendered only on a specific page, so I could disable caching on that page using the modules route yml file (am I right?), but it feels wrong to disable that whole page for the sake of one block.

What is the right way to solve this, and what's the methodology in reaching that conclusion?

Note: I could use views to collect the nodes, but to customise the view markup is more  challenging.


texts: Change Field Label depending on View Mode

texts:
Which way should I go, if I want to change the label of a field depending on a view mode?

Option 1:
Add a themefunction that checks the view mode and then change the label depending on it (would need some help doing this)

Option 2:
Edit it via jQuery

Option 3:
Use Display Suite, but I think this would be a bit of a overkill, just to change a label


texts:
Is it possible to create a multidimensional tableselect (table with checkboxes)?
Why? I would like to show a tableselect of all menu links to delete one or more but a nested tableselect.

So if they want to delete a link, all child-links will be selected to. I know i can just delete all children with a query, but for the user I want to visualise which part of the tree will be deleted.

Output ex.:
=> CB = checkbox

CB link1

CB  link 2
CB  link 3

CB  link 4

CB  link 5

CB link 6
CB link 7

CB  link 8

... and so on.


texts:
I try to theme a custom form in my block.

Here my code :

  boutique.module

/**
 * Implements hook_theme().
 */
function boutique_theme() {

  return array(
        'ajout_panier_form'=> array(
            'render element' => 'form',
            'variables'=> array(
                'form'=> NULL,
            )
  )
  );
}

  AjoutPanierForm.php

/**
 * Class AjoutBlockForm.
 *
 * @package Drupal\boutique\Form
 */
class AjoutPanierForm extends FormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'ajout_panier_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

        $form['#attributes']['oninput']='showPoids.value = poids.value';

        $form['poids'] = array(
            '#type' => 'range',
            '#title' => $this->t('Poids en gramme'),
            '#min' => 500,
            '#max' => 20000,
            '#default_value' => 500,
            '#step' => 100,
            '#attributes'=>array('id'=>array('poids')),
            '#description' => $this->t(""),
            '#required' => TRUE,
        );

        $form['showPoids']=array(
            '#type'=>'markup',
            '#markup'=>'<output id="showPoids" for="poids">500</output>'

        );

      $form['ajouter'] = array(
          '#type' => 'submit',
          '#value' => $this->t('Ajouter'),

      );

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
drupal_set_message('ok');

  }

  AjoutPanierBlock.php

/**
 * Provides a 'AjoutPanierBlock' block.
 *
 * @Block(
 *  id = "ajout_panier_block",
 *  admin_label = @Translation("Block Ajout panier"),
 * )
 */
class AjoutPanierBlock extends BlockBase {

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

    $form = \Drupal::formBuilder()->getForm('Drupal\boutique\Form\AjoutPanierForm');

    $build = [
        '#theme' => 'ajout_panier_form',
        '#form' => $form,
  ];
    return $build;

  }

}

And my template :

  ajout-panier-form.html.twig

<form{{ attributes }}>
    {{ form.poids }} {{ form.showPoids }}
    {{ form.form_build_id }} {# required #}
    {{ form.form_id }} {# required #}
    {{ form.ajouter }}
    {{ children }}
</form>

My block call my template and my form is display.
But my submit doesn't call my method in my form controller where i put a

drupal_set_message('ok');

How add the actions form into template ?
i have put {{ children }} but he doesn't work like the balise {{ form }} alone.


texts: How to render a specific page as if the currently logged in user is not logged in?

texts:
Anyone know how to do this, or have an idea on how to do it?

I want to render a specific page exactly as it looks when the user is not logged in. But the trick is, the user is in fact logged in.


texts: Are there specific cache tags which get reset on user login?

texts:
Scenario

I'd like to invalidate a set of caches based on user id upon user login. I'd like to avoid creating new tags, and limit new code as much as possible. Presumably the way to do this is with cache tags.

The specific use case is to cache a user-specific web service response, per user, for the duration of a user session.

Are there any existing cache tags (or something to similar effect) which are invalidated upon successful user login, so that I don't have to implement hook_user_login() to manually invalidate the cache?


texts: Using CCK Date with Date Repeat on Calendar

texts:
I have a content type named Event.  It has a field name Date, which uses the jQuery pop-up with Repeat options.  It uses the To and From date, both of which are required.  The time zone conversion uses the Site time zone.

On the Calendar view, I've modified it to use as the Argument, the Date field from the Event content type.  This is also added to the Fields, as it's required to match the Argument.  On Filters, I've got Node Type=Event and Published=Yes.

Now, I create an Event and set the Date field for 3/17/2011 03:00 pm to 3/17/2011 05:00pm.  I then put on the Repeat a repeat for Every Day until March 20, 2011, with no exceptions or anything else.

Immediately after submitting it, I see that the node display only has repeats for March 17, March 18, and March 19.  This is also reflected on the Calendar.  But, then when I open the node in edit mode, it says the Repeat Until is set to March 21 now.  If I save it now, March 20 shows up on the node display, but now the edit form shows March 22.

Any ideas what might be going on?  I've tried playing with the time zone settings, and no luck.  Any help would be appreciated!


texts: Translate dynamic variable that is an array in twig or using t()

texts:
How do I translate this in twig? I have this variable in twig that is an array:
$array = [
  ['number' => 7, 'name' => 'foo'],
  ['number' => 8, 'name' => 'bar'],
  ['number' => 10, 'name' => 'baz'],
  // ... and so on and so forth
]

Would like it to be something like this:

The variables are 7 times for foo, 8 times for bar, and 10 times for baz.

Or

The variables are 7 times for foo and 10 times for baz.

Or

The variable is 7 times for foo.

Tried with something like this:
    {% set last = array|last %}
    {% set array = array|slice(0, array.length - 1) %}

    {% trans %}

The variables are
        {% for i in array %}
          {{ i.number }} times {{ i.name }},
        {% endfor %}
        , and {{ last.number }} number of {{ last.name }}
      .

    {% endtrans %}

The error I am getting is:

The text to be translated with "trans" can only contain references to simple variables

Could also use t() although I'm not sure how as well. Also tried with something like this:
{% for i in array %}
    {% trans %}{{ i.number }} times {{ i.name }},{% endtrans %}
{% endfor %}
{% trans %}, and {{ last.number }} number of {{ last.name }}{% endtrans %}

Although it doesn't look good from the "User interface translation" page as you would have to translate them separately.
Thanks!


texts: Adding form elements via ajax; input not stored in $form_state['values']

texts:
I am trying to add a date, start time, end time to a form - the user can add as many 'rows' as necessary.  The form fields are being added to the form correctly, and the $form_state['input'] is showing the correct values that were input on the form. However, the $form_state['values'] is only showing the last one, e.g. if I add three (bringing the total to 4) it only includes the last value.

Relevant code in the form builder:

$num_dates = !isset($form_state['num_dates']) ? 1 : $form_state['num_dates'];
$form_state['num_dates'] = $num_dates;
$form['date']['#prefix'] = '
';
$form['date']['#suffix'] = '
';
for ($i = 1; $i <= $num_dates; $i ++)
{
  $form['date']['calendar_date' . $num_dates] = array(
    '#title' => 'Date',
      '#type' => 'textfield',
      '#maxlength' => 15,
      '#attributes' => array('class' => array('calendar-date')),
      '#prefix' => '
',
  );
  $form['date']['event_start_time' . $num_dates] = array(
  '#title' => 'Start Time',
      '#type' => 'select',
      '#options' => drupal_map_assoc(array(t('9:00 AM'), t('9:15 AM'))),
      '#attributes' => array('class' => array('calendar-date-times')),
  );
  $form['date']['event_end_time' . $num_dates] = array(
  '#title' => 'End Time',
      '#type' => 'select',
      '#options' => drupal_map_assoc(array(t('9:00 AM'), t('9:15 AM'))),
      '#suffix' => '
 ',
      '#attributes' => array('class' => array('calendar-date-times')),
  );
}
$form['add_another_date_time'] = array(
  '#type' => 'submit',
    '#title' => 'Add Another Date/Time',
    '#value' => 'Add Another Date/Time',
    '#limit_validation_errors' => array(),
    '#attributes' => array('class' => array('look-like-text-button')),
    '#submit' => array('exhibitorevents_form_add_date_time_submit'),
    '#ajax' => array(
      'callback' => 'exhibitorevents_form_add_date_time',
        'wrapper' => 'form-date-wrapper',
        'method' => 'append',
        'effect' => 'fade',
    ),
);
    $form['submit'] = array(
  '#title' => 'Submit',
  '#type' => 'submit',
  '#value' => 'submit',
  '#weight' => 100,
);

And the callback functions:

/**
 * Ajax callback for add more dates/times
 */
function exhibitorevents_form_add_date_time($form, $form_state) {
  return $form['date'];
}
/**
 * Submit handler for add more dates/times button
 *
 * Increments num_dates +1
 */
 function exhibitorevents_form_add_date_time_submit($form, &$form_state) {
   $form_state['num_dates']++;
   $form_state['rebuild'] = TRUE;
 }

I have added the $form_state['input'] & $form_state['values'] array here: http://pastebin.com/nL3DWHm8 for reference.  This particular example, I added one date 'row', making 2 total.


texts: How do I send an email to all users with a particular role?

texts:
This was quite straightforward in Drupal 7 as I recall but, with Drupal 8  there's a lot of info I don't understand as a site builder that I am being asked to provide when creating a new rule.

I'd be very grateful for some step by step help.

I want to send an email to all users with the role of "Officer" when a node of type "Agenda" has been updated.

Right now (Feb 10 2018) I have:

"drupal/core": "8.4.4"
"drupal/mailsystem": "4.1"
"drupal/swiftmailer": "1.x-dev"
"drupal/rules": "3.x-dev"
"drupal/typed_data": "1.x-dev"


texts:
I have a political website, and I expect attacks anytime. Yesterday, someone told me on my Facebook page that he will hacker me; I blocked him immediately.

Today, when I tried to create a user on the site, I noticed that a default username was used every time I tried creating a new user account.

What can I do to fix this?


texts: Drupal Commerce: Authorize.net payment from manual order

texts:
I would like to handle manual phone orders from my Drupal Commerce site.  But the Authorize.Net rule does not appear in the Payment tab for admin/manually created orders.  It even disclaims this for the SIM/DPM rule I'm using.

So what do I do?  I sense this has something to do with a requirement of SIM/DPM being that credit cards aren't stored locally.  That's ok with me, I just need to run the credit card they gave me on the phone, I don't need it stored.

I really just need to be on the payment step of the checkout form for them.  What is it about the SIM/DPM limitation that prevents me doing that step from the admin page?


texts:
I would like to add a "Jump to navigation link" to the Utility menu at the top.

Setting the path to "#main-content" doesn't seem to work.

The path '' is either invalid or you do not have access to it.

If I view the source of my page the anchor is there:

Jump to navigation

Why can't I link to #main-content?


texts: How to print "rendered node" version of Node Reference field in template?

texts: I have two content types: Type A and Type B. I have a Node Reference field on content Type A (using References module) that is set to be displayed using the "Rendered Node" version of that referenced node. It references nodes of content Type B. How can I print the content of that field as a rendered node in a custom template file for content Type A?


texts: How do I make a page available via only a single URL?

texts:
Is there a way to make the front page available via only a single URL?

The normal method is to use a <link rel="canonical"> meta tag, but this is not good for SEO.


texts: How to print the URL path of a referenced node using paragraphs?

texts:
I'm trying to print out the url path of a node from a referenced entity paragraph field in my twig template however have not had any success so far. I have tried various common twig functions but with no luck.

Any ideas?


texts: FileField Permissions- How can I allow users to upload a file without giving them the ability to remove files that have been uploaded?

texts:
I want to be able to upload a file into an article but without the ability to remove other files uploaded from other users to the same article.

Is it possible?

I tried the Field Permissions module; I can edit, but I cannot upload.


texts: Increase the Length of the block title field

texts:
How to increase the length of the block title of a block?. By default its length is set to 64 characters. Please Help.

Thanks


texts: How to override Entity Autocomplete required validation error message?

texts:
I have entity reference autocomplete field (which is term reference field )

users are not allowed to create new terms while node creation.

The validation error shows like below on form submit :

  There are no entities matching "newterm".

I need to override this message with something like "No new terms are allowed please select from existing terms"

When I tried to find code from where it is working it looks from this :

core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php and function where message is there : https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21Element%21EntityAutocomplete.php/function/EntityAutocomplete%3A%3AmatchEntityByTitle/8.0.x

Please suggest how I can override this. I tried searching lot but was not able to find right direction and have tried overriding status message as well but sure how to proceed with this.

Thanks!


texts:
I used user_save to update the field.
However, whenever I run this function and I log out and try to log back the password doesn't work anymore.I think it cause a change in the password. can anyone help me to get the actual password back?

$existingUser1 = user_load($uid1);
$existingUser1->field_group_id[LANGUAGE_NONE][0]['value'] = $g_id;
user_save((object) array('uid' => $existingUser1->uid), (array) $existingUser1);


texts:
A client has asked us to look at extracting information from an MS Access DB to designate where his products have most recently been delivered.

The end result is to output a variety of maps based on the last known delivery date, from which we can then specify what colour to designate each location marker on the map, based on the date they were last delivered to.

The other variable would be locations that they know are always stocked (regulars).

We can format the data from MS Access either at the point of origin, from our server or in Drupal. This DB will not change in its structure for a long time I expect, so we're happy treating this as a data 'Stub' to work with.

What we've also established is that the frequency of this data update isn't too critical, but since we're going to link our VPS to their system and then into Drupal, we think that regular updates (e.g. on each cron run) would be a good thing to offer.

Can anyone point us in the right direction for how to achieve this?

Its right on the cusp of our knowledge and we're a little bewildered by what approach to take.

Thanks!


texts:
My online site gives "server encountered an unexpected error" and the shared hosting site (1and1) gives no log access. So I am trying to recreate my site at home.
I started with a clean install of D8.5, and installed my theme, which works. Then I replaced the database with the SQL dump I made on the host when my site was working. I also copied the modules directory to my site, and carefully copied sites/default/files, but just my image files.
But now my local version wants to reinstall from the start. How do I manage to recreate my site properly?
I could never use backup/restore on my host site--it had an error and would not activate.


texts: Failure getting nodes from terms via the rest api

texts:
I have added a REST web service in Drupal and all content is tagged with taxonomy. I'm now trying to acquire all related nodes to the terms.

First I'm calling taxonomy_vocabulary/getTree along with the vid and I'll get all the terms for a specific vocabulary, that works just fine. The problem comes when I've gotten all the term-id's I need to go through. When I create a request it fails to find the nodes that should be connected to the term. I'll get a 404 response on each request.

This is how I call the selectNodes.
I'm creating a POST request and pass along with the tid, the endpoint is called http://myhostname/api/taxonomy_term/selectNodes

Have someone else experienced this? Do I need to pass more arguments with the POST call?

EDIT: After a quick look in wireshark it also returns the error string: "String value: No nodes were found with tid 15". Does this mean that there aren't any relation between the terms and the nodes by default?


texts: Back button gets stuck in a loop after submitting a new comment

texts:
I have a comment form shown below the comments list on a node page. I'm using pathauto for urls.

When I visit the page with the my-node-page#new link and then submit a comment it loads the node with a my-node-page#comment-1234. When I click the back button to get to the previous page I get to my-node-page#new. I click back again and get to my-node-page#comment-1234 and so on ...

I'll probably use Ajax Comments soon to avoid the page reload. Any ideas what I can do in the meantime? Looks like a bug in Drupal to me?


texts: Mailing content to a list/group of email addresses

texts:
What kind of module should I use to send content to a list of emails?

I need to create a groups with list of emails.
I need to send it to one or a few of these groups.
I need for admins to be able to look at the email addresses which will receive the emails.

I am thinking about using mailchimp, but it does not fulfill all of my needs. Also simplenews_roles can be a good decision, but whre is no version on drupal-7. Is there another option available?


texts: Apache Solr Framework with Views (for Facet Search)

texts:
What I want

I want to use the Apache Solr Search to:
1. built a Global Search with a customized Search Results Display
2. built a Facet Search for specific content types

Problems

Currently I'm trying to use the Apache Solr Framework Module:
https://drupal.org/project/ApacheSolr

So my first question: As far as I can see, this module has no native integration with views, right?

As a result I installed the "Apache Solr Views Integration" Module:
https://drupal.org/project/apachesolr_views

But when I create a view of the new typ "Apache Solr .." I am experiencing different problems:
1. Not all fields are available (for the facet search I only need to display specific fields)
2. It is not possible to filter the Content Type (needed for the facet search)
3. It is not possible to set the ouput to "rendered entity" (needed for the global search!)

Does anybody know to achieve the result that I want? What are your expieriences with the Apache Solr Framework? How do you integrate this with views?


texts: custom module js loaded before the module which it depends, Drupal.behaviors

texts:
The "Drupal.behaviors" doesn't behave as "document.ready", if I use a document.ready I will have the correct map but if I do a Drupal.behaviors, there will be an error related to the openlayers library function which is not found :(

After check, the OpenLayers.js is loaded after my module js.
Is it possible to make it load after another one ?
I though adding a dependency on another module would make him load before the other one.

If I use a setTimeout it's working but it's not the best solution !

Do you have any idea how I can do that ?

Thank you guys

(function ($) {
Drupal.OL_lat_long = Drupal.OL_lat_long || {};
    Drupal.behaviors.OL_lat_long = {
         attach: function (context, settings) {
                setTimeout(function(){
                    var map = $('#openlayers-map').data('openlayers').openlayers;
                    var pointLayer= map.layers[1];
                    console.log(pointLayer);
                    proj4326 = new OpenLayers.Projection("EPSG:4326");
                    proj900913 = new OpenLayers.Projection("EPSG:900913");
                    Drupal.OL_lat_long.dragPoint();
                    Drupal.OL_lat_long.actualizeLatLong();
                    Drupal.OL_lat_long.clickMap();
                    $('#redrawPoint').click(function(){
                        Drupal.OL_lat_long.redrawPointOnMap();
                        Drupal.OL_lat_long.actualizeLatLong();

                    });
            },200);
        //  });
        }
    }
}(jQuery));


texts: Route not found error when using webform_rest to upload files

texts:
I want to upload a file using webform_rest API as described here. #2899902. But it gives me 415 Unsupported Media Type error as you can see in the screenshot.

Here is my code

  methods: {
    addImage() {
      this.dropFiles = event.target.files[0];
    },

    submitResume() {
      const formData = new FormData();
      formData.append("image", this.dropFiles, this.dropFiles.name);

      axios
        .get("https://example.com/rest/session/token")
        .then(tokenResponce => {
          this.formToken = tokenResponce.data;
        });

      axios
        .post(
          "https://example.com/webform_rest/job_applications/upload/resume?_format=json",
          formData,
          {
            headers: {
              Accept: "json",
              "Content-Type": "application/hal+json",
              "Content-Disposition": "file; filename = full.pdf",
              "X-CSRF-Token": this.formToken
            }
          }
        )
        .then(response => {
          this.submitForm(response);
        });
    },

    async submitForm(response) {
      if (this.page === "singlejob") {
        var position = this.jobs.title;
      } else {
        var position = this.position;
      }

      let config = {
        headers: {
          Accept: "json",
          "Content-Type": "application/hal+json"
        }
      };

      this.isLoading = true;

      axios
        .post(
          `https://example.com/webform_rest/submit?_format=json`,
          {
            webform_id: "job_applications",
            name: this.name,
            email: this.email,
            position: position,
            resume: response.data.fid[0].value
          },
          config
        )
        .then(response => {
          this.isLoading = false;
          if (response.data.sid) {
            this.$router.push({
              path: "/thank-you"
            });
          }
        })
        .catch(error => (this.isLoading = false));
    }
  }

Need help here.
Thanks


texts: Webform show result table on webform node tpl

texts:
I am trying to display results of a certain content type (webform: event)

So my idea is that i would embed the table into the the tpl (node--event.tpl.php)
I tried many different ways and the closest i can get is the following code

module_load_include('inc','webform','includes/webform.submissions');
$submissions = webform_get_submissions(array('nid'=> 4));

foreach ($submissions as $submission){
    foreach ($submission->data as $row=>$data){
        print '
';print_r($row);print '
';
        print '
';print_r($data);print '
';
    }
}

This works but just for a single node, in this case node 4, I would like to show this of the current node.


texts: display submitted variable - where does it originate

texts:
The following code appears in node.tpl.php and file_entity.tpl.php, but strangely enough not in comment.tpl.php.

  <?php if ($display_submitted): ?>
    <div class="submitted">
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>

In node.tpl.php $display_submitted it true, but in file_entity.tpl.php it is false. I am using Zen 5.x theme.

Why is it different? I would assume it is some theme setting but I can't find it.

Where is this variable initialized? And do I just set it to true in preprocess_file_entity?


texts:
I remember in Drupal 6 there was a module that did text substitution easily (from text that appeared anywhere in the interface). Does that exist in Drupal 7? I just want to remove the word "From" everywhere it appears on this Drupal commerce site:
http://hum.homedns.org:8888/acmefilterbags2/product-category/featured-kits
thx!

UPDATE: I tried String Overrides, thought that would do it, but did not. Any ideas?


texts:
I want to make use of the entity_export function for data migration. I see on the doc page http://drupalcontrib.org/api/drupal/contributions!entity!entity.module/function/entity_export/7 that

Note: Currently, this only works for entity types provided with the entity CRUD API.

How would I know if a module fits this criteria? Is it simply if it has the entity module as a dependency?


texts: Is the "size" field in file_managed used for anything?

texts:
I'm having to import videos and video thumbnails manually to the file_managed table since there is no migrate support for it yet.

I'm wondering if the size is really used for anything?


texts: Why doesn't my form submission handler work?

texts:
I am new to drupal and require help from Gurus.

I am adding some form elements in the status share form by using hook_form_alter(). These elements are getting displayed in the form, but my submission handler is not working. I am using $form['#submit'][] = 'my_module_form_submit'; to add it to the form.

function my_module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == "statuses_box") {
    $form['tech2'] = array(
      '#type'=>'select',
      '#title' => '',
      '#attributes' => array('class' => array('tech2')),
      '#options' => array('All'=>'All','New'=>'New',),
      '#multiple' => false,
    );

    $form['#submit'][] = 'my_module_form_submit';
  }
}

function my_module_form_submit($form, &$form_state) {
  // Do something here.
}

The issue I am getting is my_module_form_submit is not getting called. The debugger break-point is not getting hit in this function
I am not getting error message neither on page nor in admin/reports/dblog
What I want is to add a new row in my custom data table, which this code is supposed to create.
Default form handling is running perfectly.


texts: How to get form values in URL as keys of an array

texts:
I have a custom form with min and max price value:

    $form['price']['min'] = [
      '#type'          => 'hidden',
      '#default_value' => isset($_GET['price']['min']) ? $_GET['price']['min'] : '',
      '#attributes'    => ['id' => 'price-min'],
    ];

    $form['price']['max'] = [
     '#type'          => 'hidden',
     '#default_value' => isset($_GET['price']['max']) ? $_GET['price']['max'] : '',
     '#attributes'    => ['id' => 'price-max'],
    ];

and I would like the URL after the form is submitted to look like this:

/search?price%5Bmin%5D=5000&price%5Bmax%5D=10000

but actually it's coming out like this:

/search?min=5000&max=10000

How can I get the form values to appear in the URL in the required format?


texts: Views 'Search terms' exposed filter not working as expected

texts:
I have a view that displays a list of people. I want to allow the list to be filtered by its search terms, so I've added a 'Search terms' exposed filter. I'm using hook_form_alter() to override this exposed filter so the user can select from a list of countries, so they can "Search by country". This just passes a country name in as the exposed filter value. I've added a second 'Search terms' exposed filter so a user can further filter by keyword.

This doesn't seem to work as expected. When I choose 'Australia' from the first filter, I get 39 results, which is correct. When I then enter 'Astronomy' into the second filter, I get no results. I expected to get back 1 result, a user whose node contains both 'Australia' and 'Astronomy'. If I leave one filter blank and enter 'Australia Astronomy' into the other, I get the correct user result.

Is there a way to make this work the way I want to? The first exposed filter has to be filtering on a node's indexed content (find country mentioned anywhere in the node), so I can't filter on a single field here. Thanks in advance!


texts: How to call up the argument passed to the View?

texts:
I have a view that reads the argument from panel url.

How can I call up the passed argument inside the "no result case" with html code?

Thanks!


texts: How can I use the unapproved comments list as a block?

texts:
The unapproved comments list (available at /admin/content/comment/approval) allows me to perform bulk operations on comments such as deletion (which also gives me the option of reporting to Mollom) and publishing. I'd really like to have this on the dashboard itself — is there a way to replicate this admin page as a block so I can do so?

This is under Drupal 7.12.


texts: Create an admin menu in a MENU_LOCAL_TASK

texts:
I have added a MENU_LOCAL_TASK to a node. Within that local task I want to display an admin menu block using system_admin_menu_block_page() however I always get You do not have any administrative items. I have no trouble getting admin menu pages to work as MENU_NORMAL_ITEMS. Any ideas what I am doing wrong? Code below.

function my_module_menu() {
  $items = array();
  $items['node/%node/settings'] = array(
    'title' => 'Account settings',
    'description' => 'Manage your account settings.',
    'page callback' => 'system_admin_menu_block_page',
    'page arguments' => array(1),
    'access arguments' => array(1),
    'access callback' => 'my_module_access_account_settings',
    'type' => MENU_LOCAL_TASK,
    'file path' => drupal_get_path('module', 'system'),
    'file' => 'system.admin.inc',
    'weight' => 1000,
  );
  $items['node/%node/settings/upgrade'] = array(
    'title' => 'Upgrade your account',
    'description' => 'Use this form to upgrade your account.',
    'page callback' => 'my_module_upgrade_account',
    'page arguments' => array(1),
    'access arguments' => array(1),
    'access callback' => 'my_module_access_account_settings',
    'type' => MENU_NORMAL_ITEM,
  );
  $items['node/%node/settings/cancel'] = array(
    'title' => 'Cancel your account',
    'description' => 'Click here to cancel your account and remove all your data.',
    'page callback' => 'my_module_cancel_account',
    'page arguments' => array(1),
    'access arguments' => array(1),
    'access callback' => 'my_module_access_account_settings',
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

function my_module_access_account_settings($node) {
  if ($node->type == 'my_node_type') {
    return TRUE;
  }
  return FALSE;
}


texts: Menu token. Problem with [current-user: name]

texts: I saw this question, but how to make that anonymous user does not see this menu link "anonymous"?


texts: How can I make a block that holds all the information about an articles author?

texts: I would like to add a block into the side bar of all article nodes that contains a mini profile of the user who authored the article. I was wondering if there is an easy way to do this. Thanks


texts: Commerce - adding programmatically a product in cart remove previous products from cart

texts:
I have been trying to add multiple products in my cart in PHP, but the cart only shows the last product added.
It's like each time I try to add a new product, the previous one is removed, or a new cart is created and the previous one is removed?
I don't know really.
I haven't found anything on Google so I ended up here.

All the products are created correctly and I can see them in admin/commerce/products.

Thanks for anyone wanting to save me :)

Here's my code:

// Create custom product (type = ticket)
  $order_id = commerce_cart_order_id($uid);

  $sku = 'ticket_'.$order_id;

  // product exists ?
  $product = commerce_product_load_by_sku($sku);
  if ($product != false) {
    $product_id = $product->product_id;
    commerce_product_delete($product_id);
  }

  $product = commerce_product_new('ticket');
  $product->sku = $sku;
  $product->title = "Delegate Everything order for ".$event_short_name;
  $product->language = LANGUAGE_NONE;
  $product->uid = 1;
  $product->commerce_price[LANGUAGE_NONE][0] = array(
      'amount' => $total_price * 100,
      'currency_code' => "GBP",
  );
  commerce_product_save($product);

  $new_product = commerce_product_load_by_sku($sku);
  $product_id = $new_product->product_id;

  $line_item = commerce_product_line_item_new(commerce_product_load($product_id));
  commerce_cart_product_add($uid, $line_item);

  $i = 1;

  foreach($ticket_options as $ticket_option){
      $load_ticket_options = mysql_query("SELECT * FROM ticket_options WHERE ticket_option_id='$ticket_option'");
      while($load_ticket_option = mysql_fetch_array($load_ticket_options)) {
          echo $ticket_option_price = $load_ticket_option['option_price'];
          echo $ticket_option_title = $load_ticket_option['option_title'];

          $option_sku = 'option'.$i.'_'.$order_id;

          // product exists ?
          $option_product = commerce_product_load_by_sku($option_sku);
          if ($option_product != false) {
              $option_product_id = $option_product->product_id;
              commerce_product_delete($option_product_id);
          }

          $option_product = commerce_product_new('option');
          $option_product->sku = $option_sku;
          $option_product->title = "Option - ".$ticket_option_title;
          $option_product->language = LANGUAGE_NONE;
          $option_product->uid = 1;
          $option_product->commerce_price[LANGUAGE_NONE][0] = array(
              'amount' => $ticket_option_price * 100, // $10
              'currency_code' => "GBP",
          );
          commerce_product_save($option_product);

          $new_product = commerce_product_load_by_sku($option_sku);
          $option_product_id = $new_product->product_id;
          $option_line_item = commerce_product_line_item_new(commerce_product_load($option_product_id), 1, $order_id);
          commerce_cart_product_add($uid, $option_line_item);

      }
      $i++;
  }


texts: How to delete/remove Views display programmatically?

texts:
Any idea how can I remove or delete Views display programmatically?

I have a Views that has 5 displays and I want to delete one of them. For the sake of avoiding manual intervention I want to do it automatically via code. Is there a way to do that?


texts: How to prevent "drush up" from destroying my git repo

texts:
I just updated Drupal to 7.39 using Drush, in particular the command drush up and all related steps as explained here: https://www.drupal.org/node/2550801.
During the update I have noticed this extremely worrying line, saying that Drush is messing with my .git directory:

and indeed after the update:

So I got back the .git folder from the backup created by the Drush updater, committed and pushed.

The problem is that Drush, without any warning, not only corrupted the .git directory but also messed with my .gitignore file, deleting several lines.

As a result I pushed a very large number of cache and temporary files to my company's git repo and had to later fix it and apologise to my colleagues.

My question is: is there a way to update Drupal programmatically (no admin or manually moving files) without Drush trying to destroy my git repo?