texts: How do I link drush to my drupal site thats hosted via localhost?

texts:
I have installed drush via terminal, but how do I link it to my 2 local drupal sites? When I do drush status I get this:

PHP configuration      :  /etc/php/7.0/cli/php.ini
 PHP OS                 :  Linux
 Drush script           :  /usr/local/bin/drush
 Drush version          :  8.1.2
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :

So how do I now link the drush to my two virtual host drupal sites? I looked online for a tutorial or guide, but I don't quite understand the ones I found on how to link them.


texts: False (in a very strange way) result of db_query()

texts:
The context
I'm developing a custom module which includes a simple logging functionality.
Here is the very reduced set of records I first created for test.
Table: bizaudit_logging (custom)

Table: taxonomy_term_data (Drupal core)

The query
Here is a query to get the list of the logging contents, with only one notable feature: the event resulting field is got from the event_id real field through a join to some taxonomy terms.
Nothing more simple than that, isn'it?
SELECT LOG.`created`, LOG.`actor_id`, LOG.`client_id`, LOG.`service_id`,
    LOG.`value`, LOG.`other`, TTD.`name` AS "event"
FROM `bizaudit_logging` AS LOG
LEFT OUTER JOIN `taxonomy_term_data` AS TTD ON TTD.`tid` = LOG.`event_id`
ORDER BY `created`

Executing it with phpMyAdmin I get the expected result:

In the context of my module, I'm using db_query(), so to be compliant with the Drupal rules the submitted query is slightly different:
SELECT LOG.`created`, LOG.`actor_id`, LOG.`client_id`, LOG.`service_id`,
    LOG.`value`, LOG.`other`, TTD.`name` AS "event"
FROM {bizaudit_logging} AS LOG
LEFT OUTER JOIN {taxonomy_term_data} AS TTD ON TTD.`vid` = LOG.`event_id`
ORDER BY `created`

As you can check (and unless I'm keeping blind against something obvious), the only difference is that the table names are wrapped in {}.
But here is the result I get (it's transmitted through Ajax hence the format below):

There is a double kink:

The third record appears twice (#2 and #3)
The event field of records #1 to #3 show a false value, which is the one of each previous record (#0 to #2)

Interestingly I noticed that dropping the JOIN clause (and indeed the TTD.name in the fields list) gives the expected correct result.
So the problem seems to be related to this clause.
But I can't at all imagine how this may happen!

EDIT (in response to a comment).
Here is the final part of the Drupal code I'm using:
  try {
    foreach (db_query($query, $args, ['fetch' => PDO::FETCH_ASSOC]) as $row) {
      if (isset($row[$key_field])) {
        $key = $row[$key_field];
        unset($row[$key_field]);
        $result[$key] = $row;
      } else {
        $result[] = $row;
      }
    }
  } catch(PDOException $exception) {
    $result['_error'] = $exception->getMessage();
  }
  return $result;

It comes after a lot of stuff to make the final $query and $args content.
In the current case:

$query is what I exposed above.
$args is an empty array

Also note that the 1st branch of if (isset($row[$key_field])) is not involved now: only $result[] = $row; is executed, hence the result format showed above.


texts: How do I add tags to the taxonomy data via node and the fields?

texts:
I need to store the tags which newly created in the taxonomy_term_data table, and also in the node field. I created the node field as field_beaches_tags (term reference) using "Select list" as widget.

I need to store the value in this and also in the taxonomy term data table with reference vid as the tags. I have the location name field in the form; when I submit the form the location, I must store the tags in the taxonomy table and also in the node field.

 function My_beaches_create_submit($form, &$form_state) {
    $node = new stdClass();
    $node->language = LANGUAGE_NONE;
    $node->promote = 0;
    $node->uid = 1;
    $node->type = 'content_type';
    $node->taxonomy[1] = $values['location_name'];
}

1 is the vid of the tags in the taxonomy, but I am able to store the value in the database table.


texts: Place a link at top AND bottom of each node

texts:
I made some code to put a button/link at the bottom of a node. But it would be nice to place this link also at the top of the node. Would this be possible?

This is the code that places a button at the bottom of each node:

function hook_node_view($node, $view_mode, $langcode) {
    $node->content['links']['job'] = array(
        '#links' => array(
            array(
                'title' => t('Apply'),
                'href' => 'jobs/apply',
            ),
        ),
    );
}


texts: Rendering a twig template without using hook_theme()

texts:
I've found twig templates an attractive way to display long text descriptions in Drupal 8, since they can be translated using the {%trans%} and {%endtrans%} tags, and they are much easier to maintain than long lines of text declared in t() functions, where you need to quote special characters.

The drawback of this is that it's not very flexible.  The way I'm doing it now works as follows.

I implement a mymodule module, and create a templates/ directory under the module directory.
I create my my_description.html.twig file, and put it in the templates/ directory.
I expose the twig template by using hook_theme():

  function mymodule_theme() {
    return [
      'my_description' => [
         'variables' => [
           'admin_link' => NULL,
         ],
       ],
    ];
  }

* I create the page controller as usual, with a router to a member function, say, description():

public function description() {
  $link = ...;

  return [
    '#theme' => 'my_description',
    '#admin_link' => $link,
  ];
}

This is more code than I'd like the write, if I could get away with it. And I can't figure out how to override the the original my_description.html.twig file. What I'd really like to do is something more like this:

public function description() {
  $variables = [
    'admin_link' => ...,
  ];
  $twig_service = \Drupal::service('some_service_name');
  return $twig_service->someRenderFunc($path_to_template, $variables);
}

The advantage here is it would be much easier to write a general module for this specific purpose.  The theme system isn't really the right thing to use here, especially since I'd rather implement a simple class that other modules can override.  Template overrides AFAIK is not something a module can do, and I don't want to do this with a theme, where you can do template overrides. Using hook_theme() does not let me flexibly specify where the templates are, since the theme system wants twig files to live in one and only one place.

Is this a complete abuse of Twig in Drupal 8? I actually did this successfully in Drupal 7 (!), by integrating Twig directly using composer_manager. It would be nice to do this simply in Drupal 8 as well.


texts:
I use quicktabs on D8. When choosing the formater "quicktabs" the tabs do not look like tabs at all, they are just shown as normal links. They have no outlines and so are hardly recognizable as tabs at all. Should they not look like the "normal drupal tabs"? (When I choose to show the tab title, it is also not formated, just plain text, I guess it should be formatted as a header?)

I tried different themes, does not make a change, of course the site looks different, but the tabs still have no outlines. Currently I use Bootstrap default theme.

I am quite new to drupal, just building the site structures now, not having any idea of theming yet. I was already searching a lot, no clues, and all pictures I find of quicktabs on D8 look like tabs, not like the "linklist" I see.

Any hints appreciated :) I am absolutely willing to read / learn more, so if anyone could tell me, where to find more information, that would be great!

(EDIT)
Looks like Quicktabs in D8 are causing several problems. Suddenly all context filters are no longer working for views inside quicktabs (they are working fine outside). And when I add a new quicktabs instance I have to clear the cache to make it show as an available block in the block layout page. Looks like I have to find a layout without tabs... :/

Is anyone using Quicktabs in D8 working as expected?


texts: Cannot create release for my contributed module

texts:
I am trying to create a release for my contributed module

https://www.drupal.org/project/taxonomy_facets

I created a tag an that seemed to get trough OK:

git push origin tag 8.x-1.0-RC1

Total 0 (delta 0), reused 0 (delta 0)

To git.drupal.org:project/taxonomy_facets.git

 * [new tag]         8.x-1.0-RC1 -> 8.x-1.0-RC1

I am on the right branch:

git branch

  7.x-3.x

8.x-1.x

But when I go to "Add new release" page:

https://www.drupal.org/node/add/project-release/1334080

In the select "Git release tag or branch" I do not see my release, I only see 7.x branch?

Is there a Drupal git suport email, I tried IRC but no luck, I also tried Drupa forums
https://www.drupal.org/forum/support/module-development-and-code-questions/2017-12-08/cannot-create-release-for-my


texts: Run callback after Views exposed filter AJAX

texts:
I feel like I'm doing something really wrong here. I have a View block which has an exposed filter. Since it is in a block I have to use Ajax. I'm trying to run some JS on the views result but can't get anything to happen when the ajax call completes.

To try and keep this as simple as possible I have created a test.js file with only the following code:

(function ($) {
  $(document).ajaxComplete(function (e, xhr, settings) {
    console.log('test');
  });
})(jQuery);

I add this with my theme's template.php file but when I filter my view and the results update with ajax, this code does not seem to run. I can't work out why not.

EDIT: I managed to get this to work by moving the code inside my_view.tpl.php but I'd be keen to know why it doesn't work in an external file.


texts:
I added a views adn feed type display for news. I want to customize the rss page. Currently it displaying like this :

<channel>
    <title> </title>
    <link> </link>
    <description></description>
    <language> </language>
          <item>
    <title> </title>
    <link> </link>
    <description> </description>
     <pubDate> </pubDate>
 <dc:creator> </dc:creator>
 <guid isPermaLink="false"> </guid>
  </item>
</channel>
</rss>

When i check it in firebug it includes in <pre> tag. But i want to customize it by css how to do that? How to remove <pre> tag?


texts: Why is my Rules page redirection based on data comparison not working?

texts:
I have to redirect to specific page for article content based on the its entity reference field value
Eg : article content having field_test2(field_name) reference to sample / 10164( taxonomy reference field value ) should be redirect to events
I have done this in rules. But the page redirection is not working. I have printed all the variables in article twig all are same but redirection not working.
status: true
dependencies: {  }
id: test_workflow_rules
label: 'Test Workflow rules'
events:
  -
    event_name: 'rules_entity_view:node--article'
description: ''
tags: {  }
config_version: '3'
expression:
  id: rules_rule
  uuid: 48cf31fd-db17-4f6a-ad75-71e9ea7b6b06
  weight: 0
  conditions:
    id: rules_and
    uuid: 3c51e865-1f88-429d-b363-bd7ed62a018f
    weight: 0
    conditions:
      -
        id: rules_condition
        uuid: 45c0f11a-34a3-487d-9e1c-30b3300ee9bf
        weight: 0
        context_values:
          type: article
          bundle: article
        context_mapping:
          entity: node
        context_processors:
          type:
            rules_tokens: {  }
          bundle:
            rules_tokens: {  }
        provides_mapping: {  }
        condition_id: rules_entity_is_of_bundle
        negate: false
      -
        id: rules_condition
        uuid: 647b13df-27ec-4c53-88fb-aa010c9e0021
        weight: 0
        context_values:
          operation: '=='
          value: '10164'
        context_mapping:
          data: node.field_test2.entity.tid.value
        context_processors:
          operation:
            rules_tokens: {  }
          value:
            rules_tokens: {  }
        provides_mapping: {  }
        condition_id: rules_data_comparison
        negate: false
  actions:
    id: rules_action_set
    uuid: 2f6d63e8-fb96-4014-b504-900d4763aa08
    weight: 0
    actions:
      -
        id: rules_action
        uuid: 48790fb3-7658-45df-8a8d-ecc6e0f83ff0
        weight: 0
        context_values:
          url: /events
        context_mapping: {  }
        context_processors:
          url:
            rules_tokens: {  }
        provides_mapping: {  }
        action_id: rules_page_redirect

The module version - 8.x-3.x-dev
Removing the data comparison and entity is of bundle , the redirection works.


texts: Is it possible to alter the behavior of the Ajax pager?

texts:
I have a problem with the way the Drupal 7 Ajax pager works on my website: when looking into the code, it creates links, then when one clicks on one of these links, the ajax.js catches this event and replaces "going to another page" with "loading a block with Ajax-retrieved content".

This causes an SEO problem. In fact, as the links for the Pager are declared like following:

1

... it is therefore understood by crawlers as links to another page, even though they're not; during SEO analysis of my website, I get a Duplicate content between page "A" and page "A?page=1" notice.

Is there is a way to alter this behavior?
For example, how could I replace these links with elements that would have a dedicated attribute? I thought of replacing "a href=" with "span data-target=", for example, but I have no clue how to do this and didn't find any easy solution yet.

Would the amount of work be worth the gain in SEO?

~Stéphane


texts: How to use the value element to pass values internally from $form to $form_state['value']

texts:
I have a form and i want to pass some values without user see them.

At the beginning i was using the default values:

$form['field_devis_lien_fiche']['und'][0]['value']["#default_value"] = t("@path",array("@path" => $path));

It was working fine but it's not the behavior i wanted because all the user could see the value.

So i buy "pro drupal 7 developpment" and at page 283, he describe the element value and i think this is what i have to use.

$form['title'] = array(
 "#type" => 'value',
 "#value" => $titre,
);
$form['field_devis_lien_fiche'] = array(
 "#type" => 'value',
 "#value" => $path,
);

The $form['title'] works fine but all my other fields trigger an error.

Warning: array_values() [function.array-values]: The argument should be an array in _field_filter_items() (line 517 of ***/modules/field/field.module).
Warning: Invalid argument supplied for foreach() in text_field_validate() (line 119 of ***/modules/field/modules/text/text.module).
Notice: Undefined index: #language in locale_field_node_form_submit() (line 405 of ***/modules/locale/locale.module).

When i want to edit my content type, my value doesn't exist.

So i tried another solution with the hidden element:

$form['title'] = array(
 "#type" => 'hidden',
 "#value" => $titre,
);
$form['field_devis_lien_fiche'] = array(
 "#type" => 'hidden',
 "#value" => $path,
);

In spit of the fact that my hidden fields are created when i inspect the form, i have the same error again (with array_value problem)

i don't understand why it's works for the title field and why it's not working for my other field. And i don't understand too, why i have an error with the hidden field as they appears well when i inspect element with firefox.

Do i have to create a validation function because of my element value? Maybe i have forgotten a step...

Thanks for the help.


texts: How do I get the field label from a node object?

texts:
I've tried guessing

$node->field_name->fieldDefinition->label
$node->field_name->fieldDefinition->label()

and

$node->field_name->label
$node->field_name->label()

but it did not work.


texts:
I have a View set up for blog post content in Drupal 8. The blog posts were all posted at the same time but have different "year" tags attached to them based on when the post is relevant to the company, and I am trying to sort them starting with most recent year (2019 to 2014. I can't seem to get them to filter in the correct order based on the tags.

These are the steps I have already taken:

Added a relationship with "Taxonomy: Terms on node". Selected the tags vocabulary.

Added a sort criteria for taxonomy term - year (which is in the tags)

Tagged all blog posts with the correct year (ranging from 2014-2019)

But the posts are still in a completely random order. Am I missing a step somewhere?


texts:
This is all fairly new to me so I hope i've worded the question correctly.

So I have created a view which outputs a list of news posts, which you can then click on a news post and view the contents of that post. However I've modified the styling of the listings page using the different fields etc. Now I would like to modify the content of the selected news post.

I've created a new template in my templates directory called 'views-views.tpl.php' but that seems to override the content for the listing view landing page as well as the content.

Do I need to use a different template?

If someone could point me in the right direction it would be mostly appreciated.

Thanks.


texts:
I want to retrieve a list of products from an external oracle database and show it in my drupal site as a catalog.
But the problem is that, how can I make the connection to oracle db from a drupal 7 site.
Please any suggestion on how to perform this operation is highly welcome.
Thanks!


texts: Custom module and template.tpl.php files

texts:
I am just getting started with custom modules for my test site on my localhost. Is there a simple demonstration online where there is an example of using a mymodule.tpl.php files to render my content?

At the moment I have create a hook_menu() function also a function for the page call, all it does is return some text.


texts: Using base_path and directory variables in twig template

texts:
I'm creating a Drupal 8 theme. I have overriden the menu.html.twig... and I need to add an image to the first menu item.

In the page.html.twig I have used {{ base_path ~ directory }} to get the url of image like this:

But I'm trying to insert an image in themes/(my_theme)/templates/menu.html.twig like this:

But is in this file, I can't print these variables:

{{ directory }}
{{ base_path }}

or

{{ base_path ~ directory }}

How can I print the base URL for use in my image?


texts: Access a 'global: custom text' field in fieldpluginbase render()

texts:
I'm trying to get more familiar with FieldPluginBase to create a new custom field for views. As an example I implemented a new field called 'dropdown list' that "wraps" other view-fields the user selects. Therefore I implemented a form in buildOptionsForm() that shows all currently displayed view fields and let's the user select multiple via checkboxes (kind of similar to the dropbutton behavior).

This works well and in render() I can see which fields the user checked via $this->options['field_types'].

Next I want to add the user-chosen fields to a renderarray and display them as an item list ('#theme' => 'item_list') to later add some custom css classes and style them. However, I have currently no way of accessing all fields that are shown in the view, only the entity fields via $entity->get('field_name')->getValue(). That gives me the standard entity fields like title, body, nid ... But I do have a Global: Custom text (id='nothing_2') that I need to access (that is excluded from display and output as a custom link). I found no way of accessing the value of such fields that do not directly belong to the entity (I tried $this->view->field[...] and $this->displayHandler->getValue(...) without success).

Any idea if what I'm trying to do is possible and what I'm missing ?

class DropDownList extends FieldPluginBase {

  public function query() {

  }

  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['field_types'] = ['default' => []];
    return $options;
  }
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {

    $fields = $this->displayHandler->getFieldLabels(TRUE);
    $pos = array_search('dropdown_list', $fields);
    unset($fields[$pos]);

    $form['field_types'] = array(
      '#title' => $this->t('Which fields should be included?'),
      '#type' => 'checkboxes',
      '#options' => $fields,
      '#default_value' => $this->options['field_types'],
    );
    parent::buildOptionsForm($form, $form_state);
  }

  public function render(ResultRow $values) {
    $items = [];
    if ($entity = $this->getEntity($values)) {
      // Dummy loop to show how I wanted to approach this
      // Checkboxes results are available like this (in this output
      // the user only checked the custom text 'nothing_2'):
      // nothing_2=>nothing_2 nid=>0 title=>0 body=>0 uid=>0
      foreach($this->options['field_types'] as $key=>$value) {
        if ( $value != '0') {
          // There is no field 'nothing_2'
          $items[] = $entity->get('field_name')->getValue();
        }
      }
    }
  $build['theme_element'] = [
      '#theme' => 'item_list',
      '#title' => $this->t(''),
      '#items' => $items,
    ];
    return $build;
  }
}

UPDATE

Using $this->view->field['nothing_2']->getValue($values) as also suggested by 4k4 returns an empty string, although I know that nothing_2 contains a link: Edit but it does not seem to be directly contained in getValue()


texts: Programatically render a view in twig template

texts:
I want to render a particular view like Who's new,Recent content present in the core in my the twig template.Any suggestion on how to do it? I was thinking of using views_embed_view() because in Drupal 7 it used to work with php but I don't know how to do it Drupal 8. Thanks.
 For recent I tried following code:

function template_preprocess_module(&$variables) {
  $variables['view_output']=views_embed_view("Recent content");
}

and then in the twig template did this:

{{ view_output}}


texts: Change Quantity of multiple products and add it to cart

texts: I've been looking a while for a good solution to add 2 products with the same quantity to the cart with rules. In my case a customer can buy a basic product and if he wants an additional product he can get it only with the same quantity. Is this possible with rules? I didn't find any dynamic solution for this.


texts: Search for content by title or add edit link to node

texts:
I have a Drupal 7 installation with a lot of content and it seems quite limiting that I cannot filter the content in the content administration screen by title. Is there a plugin that will add a filter to the title? I haven't found one so far after a lot of searching.

Alternatively the ability to add an edit link (near the nodequeue add/remove links) would be very useful. Is there a way to do that?


texts: How to Reduce/Increase module's weight on the module install process?

texts:
I'm developing one custom module and I want to increase my module weight when the module is installed.

How can I achieve this? Otherwise, does anyone know in which table the module's weight is stored?


texts: I've installed the Internationalization module in order to make a multilingual site, I've set italian as default language, but there's a problem, the front page is always in english. I've checked the base URL and I've noticed that there's a language prefix, is it possible remove?


texts: How to skip the ReferenceAccess constraint on a file upload by an anonymous user?

texts:
I have a contact form for job applications with a file field on it so users can upload their CV. Because of privacy / security, the uploaded CV's must be stored in the private filesystem.

Unfortunately, a problem occurs when an anonymous user tries to add a CV and submit the form. Since the anonymous user does not have access to the uploaded file, the file field's ReferenceAccess constraint (\Drupal\Core\Entity\Plugin\Validation\Constraint\ReferenceAccessConstraint) kicks in and throws a validation error: You do not have access to the referenced entity (file: 1). As a consequence, the user is not allowed to submit the form.

Is there a way to tell Drupal to skip the ReferenceAccess constraint when anonymous users reference a file that they just uploaded themselves?

Update: I came to realize that this does not happen when using the core  file field, only with the File Entity module.


texts: Support integer or float values as an attribute on a Drupal Commerce "Add to Cart" form

texts:
I have created a product type which has integer and float fields. I would like to store my data as the correct data type and allow users to make decisions about which product to buy based on those fields. These are ineligible to become part of the commerce "Add to Cart" as defined by the following commerce function:

function commerce_cart_field_attribute_eligible($field) {
  // Returns TRUE if the field is single value (i.e. has a cardinality of 1) and
  // is defined by a module implementing hook_options_list() to provide an array
  // of allowed values structured as human-readable option names keyed by value.
  return $field['cardinality'] == 1 && function_exists($field['module'] . '_options_list');
}

It looks like the concept of implementing hook_options_list is hardcoded into a few places, including the field config forms:

if ( ... && function_exists($form['#field']['module'] . '_options_list')) {
  // Enable this field to function as an attribute field on Add to Cart forms.
}

By looking at how this has been setup, it seems reasonable that if you want commerce to cooperate with a field type, it must implement the hook.

I have considered implementing this hook for the "number" module and returning the entire dataset of values defined on the website for the specific field (this seems to work without any issues from what I can tell with 5 products).

I'm not sure if this will cause issues with Commerce or core down the track, perhaps with:

Too much data grinding things to halt.
The core "options" module not playing nicely with float/int fields.
Other modules assuming the field is a list of data?
The weirdness around implementing another modules hook.

Looking for some advice on the best way to move forward with the problem.


texts: In a typical multisite D7 installation, I would like to set up apple touch icons. So that, when an agent requests http://example-1.com/apple-touch-icon.png then he receives the image appropriate for site example-1. And for site example-2, it should be a different image with the same name (and unfortunately at the exact same url, which is the multisite root directory). How can this be solved?


texts: How to output all taxonomy field values on a node in views?

texts:
How can I display all field values that are on the taxonomy terms that are applied to a given node?

So say I have the following Vocab defined:

Vocab name:Fruit Description:Fruit Categories w/ codes Field: fruit_code

And I add the following terms:

tname:Apple fruit_code:appl
tname:Orange fruit_code:orng
tname:Pine Apple fruit_code:pin_appl

Now.. I can apply a field to my view that will output all the tax termnames associated with the nodes that are returned: ie. "Apple, Orange, Pine Apple"..

But when I add the relationship for tid to the view and then try outputting the fruit_code field.. I get duplicate nodes returned, one for each term applied to the node.  How can I get the fruit_code to oupt in the same manner as the termnames in my view w/o having duplicate nodes displayed??


texts:
While adding article, I am having an option to enter summary for article. But this summary is not displaying in node view. I wanted summary to be displayed in full node view.

Any ideas how can I show summary in full node view?

-- Many thanks for your time.


texts: How to offset an EntityFieldQuery when using pager?

texts:
Is there some way to easily offset an EntityFieldQuery when using pager(), i.e. skip the first 3 nodes? range(3, NULL) doesn't work as the second value must be set, and range() also doesn't work when also using pager() which is a requirement.

Is there a substitute for something similar to this:

$query
  ->range(3, NULL) // <- Wishful thinking..
  ->pager(10)
;

Thanks,


texts: Let the site administrator edit content at page

texts:
I'm using views (outputing fields) to display the content of a page and that's working fine for the end user (the visitors). I have 2 questions about the administration for this page.

Is it possible to let the administrators edit the content type(s) within the view from the page that´s being displayed? Like the way you do when you edit articles (click edit in the right corner)? Views can do that when you list content but not fields? See my screenshot where i try to explain it.

2.Is it possible to organize the content (and the different content types) in a structured an hierachial order that's meaningful for the site administrators? For example I would love to first list the page on level 1 and then display the different content types below the page on level 2. See my second screenshot where I try to explain this.


texts: Choose one or another URL (node content) depending on the parameters

texts: I have a site, www.example.com. I have chosen that the Home page is a custom one, which uses a page-custom_home_page.tpl.php. Now I have this new URL: www.example.com/products/*, where * means different parameters (even numerical IDs, etc). I link the URL products with a new node with a different template and everything works perfect. The problem is when I have this URL: www.example.com/*, in which the parameters are after the URL associated to the home page, and I want to use a completely new template. How I do that without module? I am trying to get an exception in template.tpl.php but I am not succeeding and I wonder if there is something I am missing in the concept...


texts: How to convert emphasis to italic tinymce?

texts: I use wysiwyg with tinymce (Version 3.5.11) and I would like to convert emphasis to italic. How to do that?


texts: Services 3 - how to create a file in the private files directory

texts: Is there a way to save files to the file endpoint but to the private folder rather than the public.


texts: How can I order the rendered output of a term reference field?

texts: I have a simple term reference displaying on a node, the term items are weighted accordingly, but they are not rendering in order according to weight. I'm not sure where else I can check to discover which values are being used in the rendering order.


texts: Loading a form from a form include file in a module

texts:
I have an external form that needs to be loaded inside a template file, used by a block. Right now, i'm a bit confused as to how to load this .inc. Looking at the API docs point to module_load_include() which I've tried with no luck (see example 1, from the template file):

module_load_include('inc', 'example2');
print(render(drupal_get_form("example2_form"))); //Form method in inc file is called "example2_form();

The actual form method is just a few settings for now, once I prove this works...

function example2_form($form, $form_state) {
  $form['fname'] = array(
    '#type' => 'textfield',
    "#attributes" => array(
      'placeholder' => t("First Name"),
    ),
  );

  $form['#validate'][] = "example2_form_validate";
  $form['#submit'][] = "example2_form_submit";

  return $form;
}

I figure the cleanest approach (besides figuring out what could cause the .inc to not load here) is to just drop the form code into the .module, and load the Form array in the blocks hook_block_view(). However, I like to keep stuff clean, so if there's something I'm overlooking here, or how to best do this, it would be cool to know.

File name for the form include is example2.form.inc.


texts:
I have seen similar questions to this before but they do not solve my problem. This is Drupal 8.

Today the watchdog table on one of our sites exploded to 12GB in size. No other table in the DB is above a few dozen MBs if that.

Logging was only set to record the last 1000 events. I then turned even that down to 100 and ran cron a few times.

It dropped back down to 1GB... then up to 5.9GB in about 30min. When I try to inspect it with brush wd-show --count=1000 or something like that it only shows about 100 entries.

What is all the size coming from?

Additionally, the mysql database is still showing a disk as reported by du of 12GB...

I've also tried flushing and clearing the cache query in mysql and restarting mysql.

I only have 20GB of space on this server and it is not a very big site, what is going on and how can I stop it? If this goes on it will crash the site.

I was messing around with a view that used a contextual filter to a taxonomy term name with multiple values. Ok, I could see that using up some cache or throwing some errors... but 12GB!

EDIT: Ok the size on disk after deletion can be fixed by Optimizing the table: OPTIMIZE TABLE sitedb.watchdog. However, I still would like to know if there is someway to stop watchdog growing out of control this way? I had already limited the entries so I do not understand how it could get so big...


texts:
How do I alter the output of an existing views handler?

I want to alter views_handler_field_user_picture() to get the link to the user profile, not the themed picture.

See alter existing handlers (handler overrides). I expect a link like this http://cdn.sstatic.net/drupal/img/logo.png.

function mymodule_views_data_alter(&$data) {
  $data['users']['picture']['field']['handler'] = 'my_custom_handler';
}

module .info

files[] = user_picture_formatter.inc

and user_picture_formatter.inc is like this

<?php
class my_custom_handler extends views_handler_field_user_picture {
  function render($values) {
    if ($picture_fid = $this->get_value($values)) {
      $picture = file_load($picture_fid);
      $picture_filepath = $picture->uri;
    }
    else {
      $picture_filepath = variable_get('user_picture_default', '');
    }
    return $picture_filepath;
  }
}
?>


texts: Linking entities using EntityFieldQuery?

texts:
I have several entities (content types) using node references to relate the content together.

I need to write queries which relate two or more nodes together through their node reference fields, then apply conditions based on fields from each of the entities and returning at the very least the nids that meet those conditions.

An example:
Engagement attaches to Event via node reference. I need to query for Engagement entities within a certain date range. The date field is defined in the Event CT. So what I want is to link the Engagement 'entity' with the Event 'entity', apply the date range condition to the Event entity, and return the nids of the Engagement entities meeting the condition.

This is one somewhat simple example, and there are other relationships which will require similar queries...

So far it seems I may need to extend the EntityFieldQuery class, but I'm not sure that this will get me what I want.

This effort is going towards converting a site I built in D6 into D7. I wrote a custom query builder to accomplish these queries by just manually building the queries. I'm attempting to convert these queries to use D7's query building architecture.

It may also be possible to write these queries using db_select and manually linking in the necessary tables (basically what I did for D6).

I'm at a bit of a crossroads. I'm going to need to make this happen. Any help at this point would be quite helpful. Does anyone have any experience with this type of problem or extending the EntityFieldQuery class?


texts: How to manage multiple drupal 7/8 sites with multiple drush versions

texts:
We manage a bunch of Drupal 7 sites and a few Drupal 8 sites. I have been trying to workout the change to Drush 9 on the Drupal 8 sites and I have hit a roadblock.

For some reason when I try to use a local drush alias to contact the site it fails. If fails slightly differently for all the different contexts.

Locally, I have Drush 8.1.15 installed globally with composer, Drush 9.2.1 in my drupal site. I have a yaml alias and a php alias both local and remote.

On the dev server Drush 8.1.10 was installed with the phar download.

$ ./vendor/drush/drush/drush @project-client.dev st
Missing argument 2 for Drush\Sql\SqlBase::__construct() SqlBase.php:34                                                                            [warning]
#0  Drush\Drush::getContainer() called at [/mnt/www/project-client.dev.example.net/repo/vendor/drush/drush/src/Drush.php:193]
#1  Drush\Drush::service(config) called at [/mnt/www/project-client.dev.example.net/repo/vendor/drush/drush/src/Drush.php:238]
#2  Drush\Drush::config() called at [/mnt/www/project-client.dev.example.net/repo/vendor/drush/drush/src/Drush.php:274]
#3  Drush\Drush::simulate() called at [/mnt/www/project-client.dev.example.net/repo/vendor/drush/drush/src/Sql/SqlBase.php:221]
#4  Drush\Sql\SqlBase->query(SELECT 1;) called at [phar:///usr/local/bin/drush/includes/environment.inc:393]
#5  drush_valid_db_credentials() called at [phar:///usr/local/bin/drush/lib/Drush/Boot/DrupalBoot.php:462]
#6  Drush\Boot\DrupalBoot->bootstrap_drupal_database_validate() called at [phar:///usr/local/bin/drush/lib/Drush/Boot/DrupalBoot8.php:111]
#7  Drush\Boot\DrupalBoot8->bootstrap_drupal_database_validate() called at [phar:///usr/local/bin/drush/includes/bootstrap.inc:430]
#8  drush_bootstrap_validate(4) called at [phar:///usr/local/bin/drush/includes/bootstrap.inc:507]
#9  drush_bootstrap_max() called at [phar:///usr/local/bin/drush/includes/bootstrap.inc:456]
#10 drush_bootstrap_to_phase(-2) called at [phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php:59]
#11 Drush\Boot\BaseBoot->bootstrap_and_dispatch() called at [phar:///usr/local/bin/drush/includes/preflight.inc:66]
#12 drush_main() called at [phar:///usr/local/bin/drush/includes/startup.inc:458]
#13 drush_run_main(, /, Phar detected. Proceeding to drush_main().) called at [phar:///usr/local/bin/drush/includes/startup.inc:365]
#14 drush_startup(Array ([0] => /usr/local/bin/drush,[1] => --alias-path=/Users/fanderson/.drush/sites,[2] => --root=/var/www/project-client.dev.example.net/current/web/public,[3] => --uri=project-client.dev.example.net,[4] => st)) called at [phar:///usr/local/bin/drush/drush:114]
#15 require(phar:///usr/local/bin/drush/drush) called at [/usr/local/bin/drush:10]
PHP Fatal error:  Declaration of Drush\Command\DrushInputAdapter::hasParameterOption() must be compatible with Symfony\Component\Console\Input\InputInterface::hasParameterOption($values, $onlyParams = false) in phar:///usr/local/bin/drush/lib/Drush/Command/DrushInputAdapter.php on line 27
Drush command terminated abnormally due to an unrecoverable error.                                                                                [error]
Error: Declaration of Drush\Command\DrushInputAdapter::hasParameterOption() must be compatible with
Symfony\Component\Console\Input\InputInterface::hasParameterOption($values, $onlyParams = false) in
phar:///usr/local/bin/drush/lib/Drush/Command/DrushInputAdapter.php, line 27
Connection to project-client.dev.example.net closed.

It looks to me as though it is attempting to run the global drush. How do I stop that? There are Drupal 7 sites on this dev server as well.


texts: After migration the login form no longer submits, why?

texts:
I have been working on a Drupal 7 site on localhost (via WAMP) for some time now. Recently I wanted to migrate this website onto a new machine and continue working on it there. The steps I took:

I exported the MySQL database (SQL file)
I did a copy of the entire website (everything in the "www" directory)
I installed WAMP on the new machine
I pasted the entire website into the new "www" directory
I imported the previous database through PHPMyAdmin

Now when I go to localhost the website appears as per on the old machine, but when I try to log in using the previous user accounts it does not work. Specifically, when I type the username and password into the login form and hit the login button, nothing seems to happen. The loading icon appears in the tab but then the fields simply get emptied; there is no message saying incorrect log in details or anything, even if I use login details that I know aren't correct.

In the database the user accounts are clearly there, along with all of the other content. If I click on any links to the previous content I get taken to the content without any issues. Any suggestions on what could be going wrong here?


texts: What is the correct way to setup Drupal file permissions on a VPS?

texts:
I am testing a Drupal site on Google Compute Engine. I have a problem with file permissions.

I would like to be able to access and edit my files trough SFTP and still have Drupal functioning as it's supposed to.

Letts say my user for SFTP is 'user'. If I do sudo chown user:www-data -R /var/www/ I can edit files via SFTP. But then I can not make changes or add files in Drupal (for example add a new module trough Drupal, even clearing caches doesn't seem to work).

If I do sudo chown www-data:www-data -R /var/www/ evrything in Drupal works, but I can not make changes to files trough SFTP.

I have tried adding both users ('user' and 'www-data') to a group called 'drupal' and running the command sudo chgrp drupal -R /var/www/ but this doesn't fix the problem.


texts: If a vocabulary and a view have the same machine name, will they conflict when exporting to a same feature?

texts: In other word, does the machine name of every type of Drupal object has its own scope? Do we need use some prefix?


texts: How can I skip the current password validation on the user form?

texts:
My site requires that I turn off the current password validation on the Account Edit Form when changing / specifying a new password.

In D7 I accomplished this via a hook_form_alter implementation.  With Drupal 8's new form api I am unsure of how I can make this alteration.  hook_form_alter still exists, but the values in the form[#validation] seems to be used differently.

I see in the existing form code that a 'password reset' does exactly what I would like to do, but it's unclear how I can make this modification outside the actual AccountForm Class, or the ProtectedUserFieldConstraintValidator implementation of ConstraintValidator.

Thanks


texts: How to display or make the cities selectable in address module?

texts:
I'd like to set for users on Drupal 9-Website on the registration form and for some content-types a new field "Address". I did activate module "address" and added new field to user profile. Now, on the registration page the user can choose from select-list his country, after that will be displayed the dependent locality, wich the user can choose too from the select list, but the "City"- and "Post code" -fields are just the input-fields, so they are not pre-defined select-lists and the user(s) have to put in this fields the city name and post code manually.
I tried to use the other module "https://www.drupal.org/project/country_state_city", but there was a some error by import the cities, so it's not clear if it usable.
But anyway, what is the problem to make dependent list of cities today? There are many databases of all countries and locations.
Thanks


texts: How do I get a custom block's creation date in the block bundle template file?

texts: I have created a custom block type in Drupal 8, and now I want to fetch block creation/publish date in block bundle twig file. I tried fetching it using content.revision_created but can't get it. I can get title and other custom fields but not date. may be because of the reason it's protected. How do I get the block creation date?


texts:
Possible to get the current URL then grab the term id from it.

com/fishing-report/lakename

lakename being the term. Can i get the Term ID?


texts:
I have added a file attachment field to my basic pages.

Now for instance I want to delete a certain file from a page, how should I approach this?

I know deleting it from the file system isn't the correct way to go as it would still keep a database record of it.

However, if I remove it on the basic page 'Edit' page, it will also keep a record in the database.

How do I clean-up the database for files that don't exist or aren't used anymore?

I am using Drupal 8, the Media and File entity browser modules.


texts: Custom node add/edit form - How to leave value of undisplayed field as set?

texts:
I have a person node. There are some internal fields only the admin can change (e.g. Internal person code). Some other fields users with certain roles can change (e.g. first name...).

I have built a custom page using panels for this; I added the desired fields for normal users to the panel and Then I added a selection rule to the variant, enabling the variant for the normal users.

When a normal user opens the form and saves it, the internal fields, which only should be edited by the admin are set to NULL, because they were not submitted of course.

Is there any setting I missed? I don't want to add all the internal fields.

Thanks.


texts: How to show logout link at the top right corner for non admin user

texts: I want to show the logout link at top right of all pages, just like when we login as admin we could see logout link at the top right corner of the all pages, but problem is when I login as normal user [non admin] the logout link showing some where in the bottom, but I want to show it in the top right corner of all the pages please help me if anyone know!!


texts:
I've created a multilingual drupal page (English as default and german).
On the english page the title works correctly, but on the german page the title is still Drupal (I changed it in the settings and it works in my browser tab header)

How can I make it work?

supermew


texts:
I was recently developed a drupal site for a client who lives in HongKong. The site worked perfectly (is still functional when I access it)
But after deploying it for demo, the client compalained that the site wasnt working and constantly getting a 504 Gateway timeout error.
Apparently the client was on a proxy server (and I'm guessing the problem is due to that factor).
Does anyone know of such problem?? And, of course, the way to fix it?

P.S.

The site is built on Drupal 7.14

This is a screenshot that the client sent me

(The server, while acting as a gateway or a proxy, did not receive a time response from the upstream server it accessed in attempting to complete the request)

Update::

On further investigating with the client, He told me that

The site first worked fine until he logged in as admin and added content.
The timeout error showed when submitting the content form.
After the error, no other page of the site would open.
The site did function when he tried after waiting for a while (he did not account the time he waited)

UPDATE ::

ON checking the error log on the server, I found a bunch of "Page not found errors". But the weird thing is it was looking for a 406 page (for unacceptable header). Any idea why??

[Mon Sep 30 16:45:30 2013] [error] [client 110.44.113.254] File does not exist: /home/ekmauka/public_html/404.shtml
[Mon Sep 30 16:45:30 2013] [error] [client 110.44.113.254] File does not exist: /home/ekmauka/public_html/favicon.ico
[Mon Sep 30 16:45:29 2013] [error] [client 110.44.113.254] File does not exist: /home/ekmauka/public_html/404.shtml
[Mon Sep 30 16:45:29 2013] [error] [client 110.44.113.254] File does not exist: /home/ekmauka/public_html/demo
[Mon Sep 30 16:31:17 2013] [error] [client 110.44.113.254] File does not exist: /home/ekmauka/public_html/406.shtml, referer: http://ekmauka.com/ekmauka/
[Mon Sep 30 16:20:40 2013] [error] [client 110.44.113.254] File does not exist: /home/ekmauka/public_html/406.shtml, referer: http://ekmauka.com/ekmauka/content/mongolian-heart-live-hongkong-2012
[Mon Sep 30 16:20:13 2013] [error] [client 110.44.113.254] File does not exist: /home/ekmauka/public_html/406.shtml, referer: http://ekmauka.com/ekmauka/node/22/edit


texts: How can I auto-populate fields with Ajax?

texts:
How do I autopopulate fields in a node form in drupal 8?

Basically, what I'm trying to do is create an ajax callback to autopopulate fields based on a call to a 3rd party service.

So I'm using hook_form_alter and a custom validate function, and I'm trying to update form values.

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

  $form_state->setValue('title', [['value' => 'testing 123']]);

  $form_state->setRebuild();

}

But this doesn't update the node title.

What's the correct way to alter values in a node form in an ajax callback?


texts: Under what circumstances should a site be placed into maintenance mode

texts:
I was recently ask to deploy a set of changes to a production server. The changes included Drupal core and contrib module updates, as well as, updated custom theme related code.

In preparation for deployment, I placed the site into maintenance mode. Then took a database backup (using drush sql-dump).  I then pulled in the latest changes with git and updated the database (using drush updatedb). In this case there were several updates which were executed.  Finally I took the site out of maintenance mode.

The site owner was not so keen on the fact that the site was placed into maintenance mode for this procedure.  He mentioned that in general they don't use maintenance mode when updating a site.

This got me wondering under what circumstances, when updating a site, should one use maintenance mode? Are there any situations when one could get away with updating a site without using maintenance mode?


texts:
In a normal production webiste, there are many tasks that need to be done via crontab, but lets say you dont want all of these tasks to run on every cron.

For example, i would love to have:

A cron that run once a day, for the 'normal' maintenance (updates checks, for example)
B cron that runs every 15 minutes, to send newsletters (from simplenews)
C cron that run twice a day, that pull data from a view (json view) and write down a json file on the server (for a geomapping service with lots of data that doenst need a real-time sincronyzation).

Actually, i have a unique cron that do the A, B and C tasks on every run, every 15 minutes; so i created 2 php scripts that bootstrap drupal, one send the emails, and the other one cache the geomapping file.. it works, but is pretty a manual  way that i dont like too much.

What is the best practice to set different crons, get all the modules hook_cron, and assign them only to a specific cron?


texts: How can I implement a flag module with caches but won't affect cache the flagging nodes?

texts: According to a post here, I have installed flag module to implement product comparison. However I found that the CPU usage is very high 80-90%, then I tried to install boost and Views content cache to improve the performance. The result is good, CPU usage drop to around 10%, but when I flag(add) or unflag(remove) the node from the views, it not work.


texts: Form API-built form only emails Array, not the form results

texts:
I am having a special moment here:
I need to send an email with form results. These form results are in two fieldsets. This should be the easiest part of building this, but I'm having a brain freeze. How can I use a foreach loop or something similar to print my form results to the email being sent? Here's what I wrote, which just says 1 instead of the full results array:

     $uppgifter = $form_state['values']['dina_uppgifter'];
     foreach($uppgifter as $key=>$value) {
        if ($value > 0) {
            $params['message'][] .= "
" . $key . ": " . $value . "

";
        }
    }


texts: Getting the uid from user name for a view argument

texts:
I'm loading content from a third party system to Drupal using the Feeds and Data modules. Drupal will be used as an intranet, the users will be able to log in and see their account records (the data I'm getting into Drupal). One of the fields has the user name (not the user id), so in the external system a record can be referenced to each user.

In views is posible use the uid as an argument and show content that references to that uid. Is there a way that I can use the user name as an argument and show the content if that user is logged in or viewing his/her user profile?

Data module does not allow relationships when creating a view.

I suppose I can insert PHP code, use the user name then load de uid, and use de uid as validator in views, I'm not a PHP expert and I'm not sure if that is the correct way to do it.

Thanks in advance for your advices.


texts: How to get the form field label of a multi-value field

texts:
In hook_form_user_form_alter I need to get the title of each field. When I dump a normal (single-value) field #title is an array value, like this:

array (size=13)
  '#title' => string 'Name' (length=13)
  '#title_display' => string 'before' (length=6)

but for fields that can contain more than one value, #title is an object that looks like this:

array (size=13)
  '#title' =>
    object(Drupal\Core\StringTranslation\TranslatableMarkup)[1544]
      protected 'translatedMarkup' => null
      protected 'options' =>
        array (size=0)
          empty
      protected 'stringTranslation' =>
        object(Drupal\Core\StringTranslation\TranslationManager)[285]
          protected 'translators' =>
            array (size=1)
              ...
          protected 'sortedTranslators' =>
            array (size=1)
              ...
          protected 'defaultLangcode' => string 'en' (length=2)
          public '_serviceId' => string 'string_translation' (length=18)
      protected 'string' => string '@title (value @number)' (length=22)
      protected 'arguments' =>
        array (size=2)
          '@title' => string 'Name' (length=19)
          '@number' => int 1
  '#title_display' => string 'invisible' (length=9)
  '#description' => string '' (length=0)
  '#field_parents' =>
    array (size=0)
      empty
  '#required' => boolean false
  '#delta' => int 0
  '#weight' => int 0
  '#type' => string 'textfield' (length=9)
  '#default_value' => string 'John Doe' (length=8)
  '#size' => int 60
  '#placeholder' => string '' (length=0)
  '#maxlength' => int 255
  '#attributes' =>
    array (size=1)
      'class' =>
        array (size=2)
          0 => string 'js-text-full' (length=12)
          1 => string 'text-full' (length=9)

If I just refer to #title, for the multi-value field I end up with:

Name (value 1)

What is the proper way of obtaining the title, and what causes the difference?


texts: How could i pass some variable into twig from a form?

texts:
I have a template for a block and i need some configuration in it.  is there a way for me to take some value from a field in the form and put it in a variable for a twig template?

{##}

{##}


texts: Auto-collapsing fieldsets on user_profile_form

texts:
I am following these guides:
Customize the User Edit page in Drupal 7: https://www.drupal.org/node/2279959
Collapsing default fieldsets (Drupal 6): https://www.drupal.org/node/733198

Basically, I just want to make all of the fieldsets on the user_profile_form (e.g. /user/1/edit) collapsed by default.

Here is what I've got so far, but it doesn't work - page never finishes loading (I have changed THEMENAME to the name of my theme).  This still doesn't work however...

function THEMENAME_theme() {
  return array(
    // The form ID.
    'user_profile_form' => array(
      // Forms always take the form argument.
      'arguments' => array('form' => NULL),
      'render element' => 'form',
    ),
  );
}

function THEMENAME_user_profile_form($form) {
  //Create array to return
  $form_elements = element_children($form);
  foreach ($form_elements as $element) {
    //Identify fieldsets and collapse them
    if ($form[$element]['#type'] == 'fieldset') {
      $form[$element]['#collapsible'] = TRUE;
      $form[$element]['#collapsed']   = TRUE;
    }
  }
  return drupal_render($form);
}

I have a feeling that there is something that I am missing regarding converting this Drupal 6 code to work with Drupal 7 but I am lost.  I have about 30 tabs open and have searched extensively on stackexchange, drupal.org, etc. to no avail.  Please help!

EDIT: here is the code for a small custom module I wrote to easily test this (no need to clear the cache every time like with template.php)

function collapse_form_alter(&$form, &$form_state, $form_id)
{
    if ($form_id == "user_profile_form")
    {
        $form['edit-picture']['#collapsible'] = true;
        $form['edit-picture']['#collapsed'] = true;
       $form['edit-timezone']['#collapsible'] = true;
        $form['edit-timezone']['#collapsed'] = true;
        // test to make sure module and hook_form_alter is working
        $form['#attributes']['class'][] = 'foo7';
    }
}

I should add that I've tried dashes and underscores, e.g. edit_picture and edit-picture.


texts:
I have a configuration form that if it wasn't previousely configured should be the only thing that the user is able to see.

I would like to hijack the response for the current page and display the form, no matter what url the user is currently on. I could do a redirect but I would rather learn how to do it this way.

I presume this is done via EventSubscriber, I'm just not exactly sure how. Do I have to render the form and set is as response? Or can I just alter the controller for active route? Which would seem more DX friendly to me.

*I am not looking for contrib module to do this.

--

I was looking at the kernel events but the only viable events were

request - which already had the route "loaded"
controller - which is fine but in most cases it requires DI stuff so I cannot swap it so easily, and
response - too late, creating a new repsonse is not good for performance


texts: Where is a resource for theming drupal 7 views?

texts:
I needed to theme a view in drupal 7 for example the slider in this site:
http://fourkitchens.com/

What file must i create to costumize a view slider and the relative button?
In drupal 6 there were theme information and i could create a new "view-example.tpl.php" and costumize it very well but in drupal 7 ?
Thank you you are great,Drupal Answers!!


texts: Commerce Kickstart Review Overrides Error

texts:
I want to upgrade Commerce Kickstart (commerce_kickstart-7.x-2.53) to the latest 2.54. Following the upgrade instructions I went to the Structure Features menu to check for overrides and found these are overriden.

Commerce Kickstart Blog
Commerce Kickstart Lite Product
Commerce Kickstart Merchandising
Commerce Kickstart Slideshow
Commerce Kickstart User

But when I go to Review Overrides, I get these errors.

Notice: Array to string conversion in features_override_features_export_render_addition() (line 428 of /home/-----/public_html/sw/profiles/commerce_kickstart/modules/contrib/features_override/features_override.export.inc).
Notice: Array to string conversion in features_override_features_export_render_addition() (line 428 of /home/-----/public_html/sw/profiles/commerce_kickstart/modules/contrib/features_override/features_override.export.inc).
Error: Call to a member function stateVariables() on string in RulesPlugin->availableVariables() (line 740 of /home/-----/public_html/sw/profiles/commerce_kickstart/modules/contrib/rules/includes/rules.core.inc).

First, is there a fix for these errors?
If not, is there any way to know what overrides are actually in place?
In any case, can I proceed with the Commerce Kickstart (commerce_kickstart-7.x-2.54) upgrade?

FYI: Running Drupal 7.58 and PHP Version 7.1.16

Thanks


texts: Is Filter Contains all words working well?

texts:
I have a View and a filter, with "Contains all words". I see that the SQL contains the expression

'%word1%' AND '%word2%',

but this is making that if I write "angular", just when I start writing the "a", also words which have the character a and not necessarily start with a will appear, for example "matter".

Shouldn't the placeholder % be only in one place, this way:

LIKE ( 'word1%' AND ' word2%' ) AND (' word1%' OR 'word2%')  ... [other combinations]

I am hurrying on the suggestion, but that way, it will look for a beggining of string as one of the two (or more) words, and the other words must have an empty space before them if they are not at the beginning.


texts: Hierarchical Views Catalog using Taxonomy in Drupal 8

texts:
I have the following Taxonomy vocabulary named Product Catagories:

Categorie1

Sub categorie1
Sub categorie1

Categorie2

Sub categorie2
Sub categorie2

If the user click on e.g. Categorie1 I want to show the child-terms of Categorie1 in a view.

I followed this tutorial and configured all steps. But in Drupal 8 I cant't find this step:

  Default validation criteria" for "Taxonomy term" and choose "Convert
  taxonomy name to ID

Where is a similar option like Convert taxonomy name to ID in Drupal 8?


texts: Restrict access for a specific forum to a specific user role

texts:
I am using Drupal 8 and the core Forum module.

I have several forums on a site.

I wish to restrict access for some of the forums based on the role of the user.

eg:

Forum A: 'Moderator' and 'Role A' can access ('Role B cannot access')
Forum B: 'Moderator' and 'Role B' can access ('Role A cannot access')

I cannot seem to find a way to do this and am having trouble finding a straight answer about how to do it online.


texts: Correct image path to use in template files of custom themes

texts:
I'm creating a custom theme. Under my theme's folder, there is an images folder where I've put some pictures. I want to use these images in my various template (.tpl.php) files using HTML <img> tag... but the problem is how do i get correct path for these images (the src attribute)?

I've searched for a while but didn't get any solutions. Please help.

EDIT: I'm using nice urls (http://mydrupalsite.com/a/b/c/d) - type URLs. So, if the image src begins with / (or any relative path) it would break.


texts:
I have the following code.
$main_image = glob('main*.{jpeg,gif,png,jpg,JPEG,JPG,PNG}', GLOB_BRACE);
if (count($main_image) != 1)
    die("Could not find main picture !");

$file_path = drupal_realpath($main_image[0]);
$file = (object) array(
            'uid' => $userID,
            'uri' => $file_path,
            'filemime' => file_get_mimetype($file_path),
            'display' => 1,
            'filename' => $main_image[0]
);
// copy the file in the correct folder
$destination = "public://galerii_imagini/" . $file->filename;
 if ($file = file_copy($file, $destination, FILE_EXISTS_REPLACE)) {} else {
    die("Could not copy " . $file_path . " in " . $destination);
}

Is there something wrong with my code? I always get the message from die command inside the last if statement.
Any help will be appreciated.
Edit: Thanks to Stanislav Agapov, I found the logs from drupal.
The message is:

File ..../main_ROSE2106.JPG
could not be copied, because the destination directory
public://galerii_imagini is not configured correctly.

What should I do to configure it correctly? I have set in /admin/config/media/file-system the path sites/default/files as public files.
Is there something else to set?
Edit #2:
I set 777 for the whole /sites/default/files tree.


texts: How do I generate a list of "standard" clean URLs?

texts: Is there a way to generate a list of "standard" clean URLs, like /user/login, `/admin/content/comment', '/comment/NN' ? Perhaps for core modules, or for a specified set of modules?


texts: What difference between declaration of an ajax callback function with $this and without it?

texts:
There is a form working with AJAX Framework. And there is a form element having the callback function named "myFunction", which is a public method of the form class.
The callback can be declared as

'callback' => [$this, 'myFunction']

And it also can be declared as

'callback' =>  '::myFunction'

Could you clarify me, what functional difference between these declarations ?


texts: I need to use a list of taxonomy terms in a form

texts:
I would like to bring in terms (just parents) from one taxonomy vocabulary to use as options in a form but I can't seem to pull them in. I thought taxonomy_vocabulary_machine_name_load would work but I can't seem to get the terms to show up.
  $topic_options = array();
  $name = 'web_topics';
  $myvoc = taxonomy_vocabulary_machine_name_load() as $name => $vocabulary;
  $tree = taxonomy_get_tree($myvoc->vid);
  foreach ($tree as $term) {
    $topic_options[$name] = $vocabulary->name;
  }


texts: Dynamic local tasks to the same route with slug

texts:
I have a route set up with a slug accepting taxonomy terms (routing.yml):

example.column:
  path: '/column/{taxonomy_term}'

I would like to add (secondary, although that's not important) local task tabs on a page, one for each possible term of the vocabulary used (links.task.yml):

example.column_list:
  deriver: 'Drupal\example\Plugin\Derivative\ColumnTasks'
  parent_id: example.parent

The deriver is pretty straightforward and simple and mentioned in a few docs on drupal.org, the relevant part is:

foreach ($columns as $column) {
  $route_name = 'example.column';
  $this->derivatives[$route_name] = [
    'title' => $column->getName(),
    'route_name' => $route_name,
    'route_parameters' => ['taxonomy_term' => $column->id()],
    'parent_id' => 'example.parent',
  ] + $base_plugin_definition;
}

The problem is that this code, obviously, doesn't generate more than one tab because all go to the same $route_name. But I'm not allowed to use any other route name (suffixing it with the term, for instance) because it complains about a non-existent route then.

Do I have any other solution than to generate all the routes separately, using a _route_callback? This would somehow feel wrong, going against the reason for the existence of slugs in the first place.


texts: How to migrate multi role to an user using migrate csv plugin

texts:
I have migrated bunch of users using the Migrate Source CSV and am succeeded in it, But I want multi-roles to be defined for single user.

Here is my config file,

Here is my following cases that I have tried out in a CSV file and it failed,

Is there is anything am missing out?


texts:
I have a views-view-unformatted--viewsname--attachment.tpl.php. I want to print region in this file.

I added

function mytheme_preprocess_views_view(&$vars) {
   if ($blocks = block_get_blocks_by_region('regionname')) {
      $vars['region'] = $blocks;
  }
}

to template.php.

and added

echo render($region);

to views-view-unformatted--viewsname--attachment.tpl.php but print nothing.

What is wrong? How can I print region in views.tpl.php?

i tested this with mytheme_preprocess_html and html.tpl.php and it worked.


texts:
Hi I have 2 fairly complex webforms, one with 2 pages and the other with 4. This error shows up often, but not consistently - when saving drafts or moving between pages. I used the Webform Template module to make a copy of the 4 page form and then deleted the last 2 pages for the 2 page form as the first 2 pages are the same.

Any idea what could be causing this?
Reloading the pages will most times fix, occasionally it will show twice in a row.

PHP 5.6, Drupal 7.39, Webform 7.x-4.11, Webform Template 7.x-4.0, Webform Validation 7.x-1.10, WebForm 2 PDF 7.x-4.0

Thanks!


texts: Having trouble selecting elements in jQuery with JS added on the form

texts:
I have a form with a file element and a button.  When I click the button it is supposed to run some JS.  I have tried three separate ways to get this to work but each way gives me a different result.

The first way actually works.  The problem, though, is obvious.  I do not want inline JS here.  It's messy and annoying to work with.

Method 1: Inline JS; Works but is awful.

function carousel_npd_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'article_node_form') {
    $form['carousel_data']['add_slide_button'] = array(
      '#type' => 'button',
      '#name' => 'carousel_add_slide',
      '#value' => t('Add Slide'),
      '#executes_submit_callback' => FALSE,
      '#attributes' => array(
        'onclick' => 'javascript:
          event.preventDefault();
          alert(\'test\'); // escape EVERY single quote.  This method is no good.
        ',
      ),
    );
  }
}

Method 2: Adding the JS file to the #attached property of the form array; JS included in the page source, but, from what I can tell, before the form is loaded in the DOM, so the button click function is ineffective.

Form:

function carousel_npd_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'article_node_form') {
    $form['carousel_data']['add_slide_button'] = array(
      '#type' => 'button',
      '#name' => 'carousel_add_slide',
      '#id' => 'add-slide-button',
      '#value' => t('Add Slide'),
      '#executes_submit_callback' => FALSE,
    );
    // Using 'attached' shows the .js file is added in the source, but when I
    // click the button it submits, ignore preventDefault, and no alert.
    $form['#attached']['js'][] = drupal_get_path('module', 'carousel_npd') . '/add_slide.js';
    $form['#validate'][] = 'carousel_npd_carousel_data_validate';
    $form['#submit'][] = 'carousel_npd_carousel_data_submit';
  }
}

JS:

var c = 0;
(function ($) {
  $('#add-slide-button').click(function(e) {
    e.preventDefault();
    alert('test');
    console.log(c);
  });
})(jQuery);

Method 3: Using the '#after_build' property to run a function to add the JS to the page after the form is loaded into the DOM; The form refuses to load.  The rest of Drupal loads fine, just not the form.

PHP:

function carousel_npd_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'article_node_form') {
    $form['carousel_data']['add_slide_button'] = array(
      '#type' => 'button',
      '#name' => 'carousel_add_slide',
      '#id' => 'add-slide-button',
      '#value' => t('Add Slide'),
      '#executes_submit_callback' => FALSE,
    );

    $form['#after_build'][] = 'carousel_npd_add_slide';
    $form['#validate'][] = 'carousel_npd_carousel_data_validate';
    $form['#submit'][] = 'carousel_npd_carousel_data_submit';

  }
}

function carousel_npd_add_slide() {
  drupal_add_js(drupal_get_path('module', 'carousel_npd') . '/add_slide.js');
}

JS:

var c = 0;
(function ($) {
  $('#add-slide-button').click(function(e) {
    e.preventDefault();
    alert('test');
    console.log(c);
  });
})(jQuery);

I think method 3 would be the most appropriate, but it's the one that causes the form to not load at all.  As soon as I uncomment the '#after_build' property the form loads without an issue.  I should not that it's important that jQuery is available for this JS code, hence the jQuery wrappers in the JS file.  In the inline method, I have to use (jQuery) in place of every $, which is another downside to using that method in addition to escaping every single quote.


texts: "Warning: array_filter() expects parameter 1 to be array, string given in user_user_presave()"

texts:
I get the following warning when executing my module:

  Warning: array_filter() expects parameter 1 to be array, string given in user_user_presave() (line 1278 of C:\xampp\htdocs\mysite\modules\user\user.module).

Line 1278 is the following one.

$edit['roles'] = array_filter($edit['roles']);

The function containing it is the following one.

function user_user_presave(&$edit, $account, $category) {
  if ($category == 'account' || $category == 'register') {
    if (!empty($edit['picture_upload'])) {
      $edit['picture'] = $edit['picture_upload'];
    }
    // Delete picture if requested, and if no replacement picture was given.
    elseif (!empty($edit['picture_delete'])) {
      $edit['picture'] = NULL;
    }
    // Prepare user roles.
    if (isset($edit['roles'])) {
      $edit['roles'] = array_filter($edit['roles']);
    }
  }

  // Move account cancellation information into $user->data.
  foreach (array('user_cancel_method', 'user_cancel_notify') as $key) {
    if (isset($edit[$key])) {
      $edit['data'][$key] = $edit[$key];
    }
  }
}

Where I've used this in my custom module:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  global $base_url;
  //replace roles checkboxes in registration form with select field
  if ($form_id == 'user_register_form') {
    $form['account']['roles']['#type'] = 'select';
    $form['account']['roles']['#required'] = TRUE;
    $form['account']['roles']['#multiple'] = FALSE;
    $form['account']['notify']['#default_value'] = 1;
    $custom_submit_handler = array('_mymodule_user_presave_roles');
    $form['#submit'] = array_merge($custom_submit_handler, $form['#submit']);
    $form['actions']['submit']['#submit'][0] = '_mymodule_user_presave_roles';
    $form['actions']['submit']['#submit'][1] = 'user_register_submit';
  }
}

function _mymodule_user_presave_roles($form, &$form_state) {
  global $user;
  if (isset($user->roles[3])) {
    $_SESSION['presave_roles'] = $form_state['input']['roles'];
  }
  else {
    foreach ($form_state['user']->roles as $key => $value) {
      if($key != 2) {
        $_SESSION['presave_roles'] = $key;
      }
    }
  }
}

function mymodule_user_update(&$edit, $account, $category) {
  if(!empty($_SESSION['presave_roles'])) {
    db_delete('users_roles')->condition('uid',$account->uid)->execute();
    db_insert('users_roles')->fields(array('uid'=>$account->uid,'rid'=>$_SESSION['presave_roles']))->execute();
    unset($_SESSION['presave_roles']);
  }
}

function mymodule_user_insert(&$edit, $account, $category) {
  if(!empty($_SESSION['presave_roles'])) {
    db_delete('users_roles')->condition('uid',$account->uid)->execute();
    db_insert('users_roles')->fields(array('uid'=>$account->uid,'rid'=>$_SESSION['presave_roles']))->execute();
    unset($_SESSION['presave_roles']);
  }
}

function _mymodule_user_roles($membersonly = FALSE, $permission = NULL) {
  $query = db_select('role', 'r');
  $query->addTag('translatable');
  $query->fields('r', array('rid', 'name'));
  $query->orderBy('weight');
  $query->orderBy('name');
  if (!empty($permission)) {
    $query->innerJoin('role_permission', 'p', 'r.rid = p.rid');
    $query->condition('p.permission', $permission);
  }
  $result = $query->execute();
  $roles = array();
  foreach ($result as $role) {
    switch ($role->rid) {
      // We only translate the built in role names
      case DRUPAL_ANONYMOUS_RID:
        if (!$membersonly) {
          $roles[$role->rid] = t($role->name);
        }
        break;
      case DRUPAL_AUTHENTICATED_RID:
        //$roles[$role->rid] = t($role->name);
        break;
      default:
        $roles[$role->rid] = $role->name;
    }
  }
  return $roles;
}

Note: The above implementation I've made, since I want to provide one and only one role per user in Drupal.


texts: In the Features module, what does "Recreate" do?

texts: What does it mean to "recreate" a feature? How does this affect the database?  How does it affect the files, if at all?


texts: What would the next step in debugging a site that loads very slowly be?

texts:
I'm having a problem for a site to be very slow (10s page load). I'm trying to figure out what to problem could be but I'm out of ideas so hopefully you can help me with my next step. What I did:

Cache is enabled (core and views)
I'm using Redis caching
Database is optimized
Hosting has 4 cores and 6GB Memory

To find out what the problem could be I used Devel to show the queries. And it doesn't show anything near 10s loading time.
I also comment out all the code that is on my html page, so no content or views are loaded and I still have a loading time of 10 seconds.
Update
Looking at the Network tab as suggested by @prkos I see that there is one item taking 8.5s to load. Its the document it self. When I look deeper in to this I see that the TTFB is the problem:

So we are one step further..ready for the next step.
If you need additional information please let me know.
What could my next step be?


texts:
How may I be able to limit a webform component visibility by logged user role? In Drupal 7, this was possible with webform_component_roles module but there is no version for Drupal 8.

Thank you.


texts: Add permission to taxonomy programmatically

texts:
I have certain content type .. when node is save it create: user,vocabulary
I used hook_user_save and taxonomy_vocabulary_save..
Which the vocabulary name is $node->title ..
All I need now.. How i give the NEW USER permission for NEW vocabulary?

permission for EDIT and DELETE the new vocabulary


texts: Change the description for username field in user registration

texts:
I would like to disable the spaces in the usernames. For that I installed a rules module and i applied a rule. Everything is fine but now the label is still saying : "Spaces are allowed; punctuation is not allowed except for periods, hyphens, apostrophes, and underscores."

How can i change that label ? I looked everywhere and i didn't find a thing.

I am new to drupal.
I use drupal 7.

Thanks in advance for you responses.


texts:
I am using the form validation in hook_form_alter() as follows.

$form['#validate'][] = '\Drupal\module_name\Controller\MyController::_field_p_servicename_validate';

In the controller I am defining it as follows.

public function _field_p_servicename_validate(&$form, FormStateInterface $form_state) {}

It throws the following exception.

  Strict warning: call_user_func_array() expects parameter 1 to be a valid callback, non-static method Drupal\module_name\Controller\MyController::_field_p_servicename_validate() should not be called statically in Drupal\Core\Form\FormValidator->executeValidateHandlers() (line 88 of core/lib/Drupal/Core/Form/FormValidator.php)

What does it mean? How can I fix it?


texts: How to show directions on a map when using the Geolocation Field module

texts:
I installed the Get Directions and the Geolocation Field modules.

The Geolocation Field module displays a map, but I also want directions.

How do I get the directions shown on a map? Do I need another module?


texts: Make a view content only appear when user is logged in

texts:
In Drupal 7, I need to create a view of member-only nodes. They're all of a certain type. This type—and I've already set that up with role-based access control—can only be seen by logged in users.

Now, I can create a view called Member Area that shows these nodes, and make it accessible only to logged in users (through the View access control), but when I create a menu entry for that view, the link obviously disappears when the user isn't logged in.

What I need is a link that points to a "please log in" text (could be on a static page, whatever) when the user isn't logged in. If the user then logs in, I want to display the view which shows only the restricted content.

Giving a specific example, I currently have this. The block is conditionally shown in the sidebar only on the page called Member Area. The page displays the static You are not logged in… text.

Once the user logs in, I want to show them the view of restricted content:

The horrible kludge that I use now is that I link the user to another view in the user menu, but that's really bad UX.

Can I set this up somehow?


texts: Drupal 7 Views 3 exposed filter preselected

texts:
I'm having a bit of a hard time configuring a preselected exposed filter on views.

I have a View (mysite.com/view-path) with an exposed filter as a select list with options:

Option 1
Option 2
Option 3

I want to be able to access the view with a preselected option in the exposed filter from another page (mysite.com/page) with a link like so (mysite.com/view-path?option=1)

Right now i've made a form alter on the exposed view filter with this:

if (!empty($_GET['option'])) {
   $form_state['input']['field_option_tid'] = $_GET['option'];
}

The problem is that this works, but when i try to click the select list and change the value to Option 2 for example, it will revert back to Option 1.


texts: How to show a menu link that is hidden because the role has no permission to see the linked page?

texts:
I need show a menu link that links to /node/add/article for anonymous users but they don't have access to that page.

I have seen solutions like:

Using an absolute URL (that way Drupal does not check user access).
Alter the menu access callback but I do not really want to give them access just to print the link.

Are there any other solutions?


texts:
I'm altering the "Edit menu link" form

function module_name_form_menu_edit_item_alter(&$form, &$form_state, $form_id) {
    $form['html_content'] = array(
        '#type' => 'textarea',
        '#title' => t('HTML Content'),
        '#maxlength' => 180,
        '#required' => FALSE,
        '#description' => 'Put here the HTML code of the menu'
    );
}

The text area is showing fine, but it's not saving the information I put into.
How can I solve that?


texts: How do I print the help text description above the field for all textareas?

texts:
For all textareas, I want to print the help text description above the field input.

By default, it looks like this:

Field Label
Field Input
Help Description

I want to arrange it like this:

Field Label
Help Description
Field Input

This was actually a hidden configuration option added to Drupal 8.0  So, the basic idea is that I have to set '#description_display' => 'before' for every textarea.

To do that, I tried to use template_preprocess_textarea().

I added the following code to mytheme/mytheme.theme:

function MYTHEME_preprocess_textarea(&$variables) {
  $variables['#description_display'] = 'before';
}

I checked to make sure this code is called with kint() but it doesn't change the positioning of the help descriptions on the forms.  I checked my theme (Bootstrap's) templates and they have logic for handling before and after.  So what is the right way to call this to adjust the position of the help text on all textareas?


texts: Why is my theme function not called (not in template file)?

texts:
I have a simple theme and everything is by documentation/examples:

function activit_theme() {

  return array(

      'activit_package_teaser' => array(
          'arguments' => array('node' => NULL),
          'type' => 'module'
      ),

  );
}

+

function theme_activit_package_teaser($node) {

  $output = '

      package

  ';

  return $output;
}

and

function activit_packages_block() {

  $nids = db_select('node', 'n')->fields('n', array('nid', 'status'));
  $nids->join('field_data_field_important', 'f', 'f.entity_id = n.nid');
  $nids->fields('f', array('field_important_value', 'entity_id'));
  $nids->condition('n.status', 1)->condition('f.field_important_value', 1);
  $nids = $nids->execute()->fetchCol();

  $nodes = node_load_multiple($nids);

  $packages = '';
  foreach($nodes as $node) {
    $packages .= theme('activit_package_teaser', array('node' => $node));
  }

  return '

'.t('Important packages').'

        '.$packages.'

  ';

}

there are 4 nodes, but my theme is not called at all and nothing is inserted into

. No error in "recent log messages".  Why it does not work?

UPDATE: When the template is in activit_package_teaser.tpl file it works:

  'activit_package_teaser' => array(
      'arguments' => array('node' => NULL),
      'template' => 'activit_package_teaser',
      'path' => drupal_get_path('theme', 'activit') . '/templates/',
  ),

But why it does not work as a theme function?


texts: module_load_include not working including inc file

texts:
I am trying to make it work, but it seems simply not working in Drupal 6. Maybe this is the issue, it does not work on D6?

This is the code:

// $file_path = module_load_include('inc', 'MYMODULE.inc', 'includes/MYMODULE.inc');
$file_path = module_load_include('MYMODULE', 'MYMODULE.inc');

// Testing.
if ($file_path === FALSE) {
  dpm('Failed to include: ' . $filename);
}
else {
  dpm('Successfully included: ' . $file_path);
}

I have tried also adding a drupal_load before and some other things, like changing params, moving the inc file to the root module folder and so, but I allways get the same:

Failed to include: sites/all/modules/MYCOMPANY/MYMODULE/MYMODULE.module

any idea of what am I doing wrong?

Thanks a log.


texts: Cleaning a Drupal database from anything which is not nodes, taxonomy and other regularities?

texts:
Assuming we have an all-core Drupal site; Is there a utility or even a Drush/Dconsole command to "clean" the database of anything which is not a node, or a taxonomy or any regular core-based data of all sorts ?

In other words, a utility or command to clean from the DB anything which is, for example, a remnant of a module that we installed and then deleted that is now stuck on the DB in several places and removing it manually can be sisiphyc and or tiresome (especially when you have several cases at once).


texts: Inserting images and preventing the layout from breaking

texts: The client has asked for an auto resize of images (when inserting via the ckeditor) so to avoid the breaking of the layout, and including images that are just too big. Is there a way to automate this process? Do you normally offer this? Or do you just make the client aware of the width and height settings in the image properties window?


texts: commerce 2.x server error when trying to add store

texts:
Via Composer I have added and enabled commerce 2.x to an existing site. I first added a currency. But when I try and add a store I get a 500 server error. So I then added items I was able to access like order type, order, product variation, etc. But I am still not able to add a store. However, I was finally able to get to the add store screen via the promotion page. Once I added a store I again got a 500 server error. The best I can determine from the server log files is a missing piece.
"....No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive."


texts: how to make unique fields in profile type in drupal 7

texts: I am using drupal 7 and want to save unique mobile number for users. I have created a profile type field of phone number type.I have installed unique field module but not getting any option to make it unique while editing the phone number type field. I want make it a unique so there will be one mobile number for only one user.So how can we make a unique field in a profile types? Or will we have to make a unique field in a database itself??


texts:
I am new to Drupal and I try viewing it as an HTML/CSS website. What I would like to do is have multiple sections(containers) with different backgrounds and content one after the other.
Something similar to this example:  https://figopetinsurance.com/new-figo-pet-cloud-mobile-app.
Or just image 3 containers with different backgrounds and content from each-other that have their CSS class for styling.

Problem is that I am not sure exactly how to achieve that. I have created a basic website with a theme and tried creating a block and styling the theme from CSS. Even though it works it is not practical because for every page I have to create a new block.


texts:
I'm trying to have my D8 site use Memcache for the lock service backend instead of using MySQL which is the default.

In core.services.yml we have the lock defintions:

  lock:
    class: Drupal\Core\Lock\DatabaseLockBackend
    arguments: ['@database']
    tags:
      - { name: backend_overridable }
    lazy: true
  lock.persistent:
    class: Drupal\Core\Lock\PersistentDatabaseLockBackend
    arguments: ['@database']
    tags:
      - { name: backend_overridable }
    lazy: true

In my site's default.services.yml I have this:

services:
  # Replaces the default lock backend with a memcache implementation.
  lock:
    class: Drupal\Core\Lock\LockBackendInterface
    factory: ['@memcache.lock.factory', get]

But when I obtain the lock service via \Drupal::service('lock');, I get a class Drupal\Core\ProxyClass\Lock\DatabaseLockBackend returned instead of an instance of Drupal\memcache\Lock\MemcacheLockBackend. So my override did not work.

Unfortunately there's no documentation in the D8 memcache module for doing this, I'm just kind of winging it.

Perhaps it has something to do with the fact that the original service is lazy loaded?


texts: views_get_view_result in template.php? I want global variables using view results

texts:
I can't seem to get this to work..

function mytheme_preprocess(&$variables) {
    global $user;
    // Classes of logged in User
    $view_result = views_get_view_result(
        'profile_page_flagged_pages',
        'panel_pane_1',
        $user->uid
    );
    // Create array
    $class_array = [];
    foreach($view_result as $item_class) {
        $class_array[] = $item_class->nid;
    }
    // Count Classes
    $class_count = sizeof($class_array);
    $variables['classes'] = $class_count;
}

If I set string values, it's fine. But trying the view gives a 500 error. This code works fine in a tpl file.


texts: Facebook Style 'Read More' instead of standard Pager in QuickTabs?

texts:
I am using Quicktabs to display a few views (grid style). At the bottom I am using the standard Pager that comes with QuickTabs. Is it possible to replace that with a 'Show More' link (ajax style?) Example would be at the bottom of a Facebook Wall, or here- http://gdgt.com/answers/

Thanks for the help!


texts: How to override default page.tpl from a module, for a specific page?

texts:
I am coding a module which contains a "please wait" page.

On this page I need to override the default page.tpl template so I can render the "please wait" message alone without all the other regions and "site chrome".

How do I tell drupal not to use the default page.tpl and use my page-special.tpl for the specific "please wait" page ?

EDIT

Please note that I am coding a module, not a theme. So everything should be done from inside the module.


texts: Exclude from display "Re geocode" and "Delete" checkboxes

texts:
I would like to totally exclude from rendering "Re geocode" and "Delete" checkboxes of the "Location" module:
 - I searched for an option in the configuration sections of my installation of Drupal and I did not find anything;
 - I tried to intercept the creation of the form with hook_form_organisation_node_form_alter(), but I did not find the checkboxes in the $form and $form_state variables.

For the moment I hide the two 'divs' containing the HTML code, but I would like not to send the code to the web browser. I would prefer a clean solution, so is there any way to do it? A hook function I don't know can help me?


texts: Group content by taxonomy term, but then also list all terms in each row

texts:
I'm looking for help with creating a view.

I have a content type, Thing. Thing has a field on it where you can select multiple terms in a taxonomy, Category. I want my view to look like this:

Category 1

Thing 1

Category 1
Category 2

Thing 2

Category 1
Category 3

Category 2

Thing 1

Category 1
Category 2

So basically, I want to group by the terms and then list out all terms underneath each Thing. I also don't want groups to end up with headers of "Category 1, Category 2," and I want to make sure each of the terms is listed under each instance of the Thing in the view.

Thanks for any help!


texts:
I'm attempting to debug a site with intermittent slowness, and I've managed to track it down to a long series of file_usage queries which appear to be coming from a search_index rebuild.

SELECT base.fid AS fid, base.uid AS uid, base.filename AS filename, base.uri AS uri, base.filemime AS filemime, base.filesize AS filesize, base.status AS status, base.timestamp AS timestamp
FROM
file_managed base
WHERE  (base.fid IN  ('50545'))

And

SELECT f.module AS module, f.type AS type, f.id AS id, f.count AS count
FROM
file_usage f
WHERE  (fid = '22638') AND (count > '0')

These queries appear to be triggered on random page loads, and they continue until they are killed, or the page times out.

I thought it might have something to do with rebuilding the search index, so I've added

$conf['search_cron_limit'] = '0';

To settings.php to no avail. There are a whole lot of modules on this site, so I don't really know where to start.


texts: How to use nested select queries in Drupal 7

texts:
How can I write the following query in a Drupal-friendly way?

select max(cnt) from
(select COUNT(*) as cnt from Det a,
dbo.Mem b where a.no=b.no
group by b.no) X
go


texts: What is the process to upload custom drupal themes to Drupal.org? What is relevance of "PayWithPaytm"?

texts:
I am new to this community, so apologies in advance for some ignorance.

I know there are forums, chat channels, ect, so I also apologize if this is the wrong medium for such questions.

Basically, I want join the community by building my own Drupal Theme and eventually upload it to Drupal.org for other users to download and use if they wish.

I went to my dashboard on Drupal.org where there are tabs for "Your Projects" and "Your Commits" and such, but commits is just a blank page, and projects is empty but with a message "To learn about projects, see Contributing code on Drupal.org.".

Clicking this hyperlink goes to this page: https://www.drupal.org/contribute-projects .

So my confusion starts here. What does this e-commerce payment gateway plugin have to do with contributing code? I downloaded it, the readme mentions nothing. Under the download option, there begins the info I need (like how to create a sandbox project and eventually

So what does that PayWithPaytm plugin have to do with anything? Do users need to pay Drupal to create a project or something? Why does the "learn about contributing" link go to an e-commerce plugin?

Below is a screenshot of my dashboard and the link to PayWithPaytm.


texts: How to use location distance / proximity filter with facet search api

texts:
I am using location, gmap, facet api modules and I have created search page for node with facet api. I want to use distance / proximity filter for facet search but I didn't get distance / proximity fields in facet search.

I used another modules like geofield and address field, but I get all fields like address, country, zip code except distance / proximity field.

I did searched lots of solution but I didn't get right solution.
When we create normal view with content type then distance / proximity filter shows in fields and filter criteria.

regards
Arvind


texts: Is it possible to alter the data passed into a Rule?

texts:
I have a bunch of Rules and some things require a bit more complex logic than usual. What I want to do is use a hook that runs when a particular rule fires, access the data that's passed in to it and manipulate it accordingly so when the rule executes it does it with the manipulated data. I looked through the Rules API and tried some of the function but none seem to have what I want. Is there such a function, or this there a better way?

A simple example: For a rule that sends an email, I want to hook in to it, check some stuff with code and then change the email address it sends to.


texts:
Trying to build an exposed filter for a drupal views table that will allow me to select from a list of values that are found in a specific field. I've created my own views module to allow me to build this view from a custom table that I've created in my db.

For the more visual:

I'd like the filter to populate from the values in the Counselor field and allow this user to select from this list so any time a new Counselor is added to the db they will be included for this filter.  Is this possible?

I'm using D7.


texts: Creating REST service to get complex node type

texts:
I'd like some advice as I don't know if I'm doing this the correct way...

I'd like to create a web service to get a specific node type. I don't need create/update/delete functionality, just being able to retreive the data is enough. It also shouldn't contain any authentication (the data is public).

This node type contains several field collections. Each field collection could occur multiple times in the node. (for example, there's the node type "Car" which contains the field collections "Audi", "BMW", "Skoda". Each of these can occur multiple times in the node).

The JSON I'd like to return should look like this:

{"cars": {
    "title": "newest cars",
    "image": "http://www.example.com/image.jpg",
    "audi": [
       {
        "title": "A1",
        "price": "expensive"
       },
       { "title": "A6",
         "price": "very expensive"
       }
    ],
   "BMW": [
       // multiple BMW's
    ],
}}

It's possible that zero cars of a specific brand are returned.

I've been looking how to do this in Drupal. I don't have much Drupal experience, so I'm sorry if this is a very easy thing.

I'm currently using the services module. I've had a look at this tutorial:
http://pingv.com/blog/an-introduction-drupal-7-restful-services

It looks pretty easy, however, the field collection module adds all fields in a different database table. With all fields I have, I'd have to join more than 20 tables in the query and the Drupal database can get pretty confusing this way.

I'm wondering if there's a much easier way to do this. I've already looked at other modules like "Services Views", but these don't seem to do the things I want:

Return specific node (and specific node id) which contains field
collections
Return image url
Return only the fields I want
Return easy, readable names
Accept certain parameters in the URL (which I'd like to define myself) to filter

Is there an easy way to do this or is the only way creating the very complex query?

Thanks!


texts: How do I programmatically modify the body field's markup/render after it's filtered "Allowed HTML tags" from "Content Authoring"?

texts:
I need to modify what is being rendered from the BODY field of a node.  However, the filter for 'Limiting allowed HTML tags and correct faculty HTML' needs to be left ON.

There is a certain tag I don't want added by a user but I want it to be added programmatically.  The FILTER for limiting allowed HTML keeps removing this tag even if I added it programmatically.  I assume this is because of the order of where I am programmatically adding this into.

I am trying to add it via a custom module and I would like to keep it that way if all possible and not modify at a higher level. If I cannot do it on a module, how DO I do update the BODY value after the "limited" allowed HTML tag?

Thanks in advance