texts: Variables injected or set in a Twig file are undefined after the first position of an entity reference field

texts:
I have a Paragraph setup that has an entity reference field allowing an editor to select multiple nodes to use in a display.

Based on the count of nodes, I want to trigger a class. I figured a way to do this was with hook_preprocess_node() in the theme:

$referringItem = $node->_referringItem;
    if (!empty($referringItem)) {
      $referringEntity = $referringItem->getEntity();

      if (
        !empty($referringEntity)
        && ($referringEntity instanceof NodeInterface || $referringEntity instanceof Paragraph)
       ) {
        $referringEntityType = $referringEntity->getType();
        $referringEntityTypeId = $referringEntity->getEntityTypeId();
      }
    }

if ($referringEntityType == 'homepage_feature') {
        $count = $referringEntity->get('field_items')->count();

        // Default.
        $variables['top_image'] = FALSE;
        $variables['right_image'] = FALSE;

        // Should this be count is only 1 AND it is the first delta item in field_feature?
        // If not, any single item Homepage Feature will get top-image which may not be
        // desired.
        if ($count == 1) {
          $variables['top_image'] = TRUE;
        }
      }

The logic above might be too involved. Basically I am looking back to see what paragraph type was used, so I can pass new variables to the template.

What I noticed is that even though the code is hit for every node listed, the variables only exist in the first node. I dumped them in the template and it is correct there, but they are undefined in the other nodes.

In Twig, I tried dumping the variable at the top of the template:

{{ top_image }}

I can see it in the first record 1 above the markup, and then it never shows again.

How can I ensure the variables are passed to the template, correctly, every time?

Edit:

Looks like using the same node with the same view mode in different paragraphs or entity references on the same page can cause this to happen.

Is the solution then to add cache tags/context to the node being rendered to account for what parent is outputting it?


texts: Access A Referenced Node's Fields - Field Level Templating

texts:
I have a content type with a reference field to another content type. This allows an unlimited amount of entries.

I've created a template for this field:
field--node--field-my-fields.html.twig

I want to be able to access the fields of my referenced node. Usually you can do this by accessing the entity, but I can't seem to do this.

{% for item in items %}
  {{ kint(item.content) }}
{% endfor %}

I feel like this should be really simple, but I just can't find a way to get access to the fields!

Thanks in advance for any answers.


texts: Programmatically add field automatically to all new bundles

texts:
I have a module with a bundleable content entity that has been deployed to an existing site.  On the site, a bundle was created and a date field was manually added to it via the UI.
Now the date field needs to be automatically added to each new bundle created but I'm not sure how to go about doing this.  So far, I have exported the field storage YML file to 'config/install/field.storage.mymodule.field_date.yml' and created a 'hook_entity_bundle_create' function but am not sure how to load the field and add it to each new bundle created or even if this is the right approach.


texts: Context is not being applied in Drupal 7

texts:
I searched for my problem so please forgive me, when this is duplicate as I'm newbie and the drupal specific terminology isn't my native tounge :)

I set up a delta "delta_theme" for a theme I'm using.

Then I created a simple context "test" with condition "path: node/1" and reaction "delta: delta_theme".

But whenever I visit localhost/node/1 the theme for this node does not change.

What am I doing wrong?

Do you need more info? Just ask.

Thanks in advance!


texts: How to put multiple conditions on a field, using Views 3?

texts:
I am trying to make multiple conditions on a field in Views.

I found Views Conditional that allows only one condition.

I also found Views Custom Conditions, which I still don't really find how to use (very few documentation and the one left is very confusing to me).

So I'd like to find out How to put multiple conditions on one field, using Views 3.


texts:
I using drupal 7 for my website. I created one feedback form using  webform and Internationalization for both English and Japan version.

It works fine, but the error message for Feedback is required. is showing 「ご意見・ご感想」は必須項目です。 where translation for Feedback is ご意見・ご感想. Here I need to show the error message 「本文メッセージ」は必須項目です。.

How can I do this? Is there any way to do this? Please help me.


texts: What is the purpose of the user_data table?

texts: I'm using Drupal 8 and I wonder what the purpose is of the user_data table? How can I can store custom data in that table? In my site, the content of that table is the following.


texts: How to add any plugin to ckeditor manually?

texts:
I'm trying to add a new plugin ckwebspeech in ckeditor module. Here is the plugin which I want to add.

So, that the final editor will look like mentioned in screenshot. Is there any way to add this manually?


texts: Why Are we getting "WD view: View name 'XXX' is already taken" when running Drush; and how can it be fixed?

texts:
We are getting the following output whenever we run the drush script. This is problematic in logs when the drush cron is run. What is causing this and how do we fix it?

This started showing up recently after implementing a responsive design.

Here is an example of the output we get when running a drush command:

WD view: View name 'uft_admin_content' is already taken      [error]
WD view: View name 'uft_calendar' is already taken           [error]
WD view: View name 'contract_navigation' is already taken    [error]
WD view: View name 'faq' is already taken                    [error]
WD view: View name 'forms' is already taken                  [error]
WD view: View name 'reports' is already taken                [error]
WD view: View name 'news' is already taken                   [error]
WD view: View name 'upcoming_events' is already taken        [error]
WD view: View name 'chapter_news' is already taken           [error]
WD view: View name 'education_labor_news' is already taken   [error]


texts: External anchor link or map for attached images

texts:
I'm looking to wrap the attached images (part of the content type) in an anchor. Typically we are putting together pages that are cross promotions so they go out to other non-Drupal sites

For now we are putting the images in via HTML with the a and img tags on the ones we need external links for. Now we are using views to have a grid page, block, views slideshow but these manually input images are not visually promoted in these new views.

Some had suggested having the link below the image in text (using the link module) but that solution is confusing users who see our standard 'click here to book' and 'book now' phrases on the image.

Simply how can I wrap the image with a link? (with or without the link module, which doesn't wrap)


texts: Views contextual filter to a number of product variations

texts:
I am having real trouble with this and would appreciate any help.

I have a view block that needs to display all variations of a product that have the same sku with an increment at the end.

Example:

Product name is: 4 jembi avenue

This produces a url of /4jembiavenue

All product variation skus are based on this, so every product variation will now have sku

4jembiavenue0
4jembiavenue1
4jembiavenue2

so on so forth.

What I need is views to display ALL product variations in the view.

I can achieve this by using a filter and setting it to Contains: 4jembiavenue. However as I am intending to have many products displayed like this I do not want to do it like this as each new product would have to have a new block and a new view.

I can use a contextual filter to get the value (4jembiavenue) from the URL and it works fine, but of course it only displays 1 product variation where I am going to need up to 60.

So my question is this:

How can I use a contextual filter with a "contains" operator to find and display all of the product variations?

If you know of any other way I can achieve this I would gladly try this too.

Thanks in advance for any help!


texts: form auto complete how to restrict results by previous drop down

texts:
Hi I have a select field on a form which contains countries. The next field is a text box  which is driven by an autocomplete function. The autocomplete function returns cities from a database table.

I want to restrict the cities that the autocomplete will return based on the country value selected in the dropdown. How do I do this?

if it helps here is my form

 $country_list = _get_country_list();
    $form['country'] = array(
            '#type'=>'select',
            '#title'=>'Select Country',
            '#description'=>'Select the country where you want to collect the car',
            '#options'=>$country_list,
    );
$form['officename'] = array(
    '#type'=>'textfield',
    '#title'=> t('Location'),
    '#default_value'=>$form_state['officename'],
    '#size'=>20,
    '#maxlength' => 50,
    '#description' => t('Select the country where you want to pick up the car'),
    '#attributes' => null,
    '#required' => TRUE,
            '#autocomplete_path'=>'location-autocomplete'
);

$form['submit'] = array(
'#type'=>'submit',
'#value'=>'Search Now',
'#submit'=>array('HolidayAutosXML_carsearch_form_submit'),
);

and here is my autocomplete function. I want to restrict the sql with a where country = {country selected in Drop Down List}

function location_autocomplete($string){
$matches = array();
$result = db_query("select officename from {holidayautos_country_list} where officename like :keyword limit 0, 10", array(':keyword'=>"%" . db_like($string) . "%"));
 foreach($result as $row) {
    $matches[$row->officename] = check_plain($row->officename);
  }
drupal_json_output($matches);
}

Many Thanks
Simon


texts: Drupal.behaviors function can't detect Views object when user is Anonymous

texts:
Goals:
1. have a button in a View that refreshes that View via AJAX on click event.
2. Load refresh script only on pages that have View named "my_view".

I was able to achieve both of the following with the code shown below.

template.php

function mytheme_preprocess_views_view(&$variables) {
  $view = &$variables['view'];
  // Make sure it's the correct view
  if ($view->name == 'products_left_in_stock') {  //EDITED
    // add needed javascript
    drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/views-refresh.js');
  }
}

viewsrefresh.js

(function ($) {
    Drupal.behaviors.myViewsRefresh = {
    attach: function( context , settings) {

        var viewName = 'products_left_in_stock';

        // View is Ajax enabled,
        // and is available as a property of the Drupal object
        // like so...
        var instances = Drupal.views.instances;
        var targetedView;

        // iterate thru the various
        // views instances name to find your views
        $.each( instances , function getInstance( index, element){
                    if(element.settings.view_name == viewName ){
                            targetedView = '.view-dom-id-' + element.settings.view_dom_id;
                    }
        });

        // Define your button click here...
        $('.viewsrefreshbtn').click( function(){
                if(typeof targetedView !== 'undefined'){
                    $(targetedView).trigger('RefreshView');
                    console.log ('Clicked refresh btn on view. View Refreshed');
                }
                else {console.log ('Can\'t find viewName on this page');}
        });
    }
}
})(jQuery);

refresh button added to Views footer in Global Text

refresh

ISSUE IS: Refresh button works only for logged in users. When Anonymous user clicks Refresh button - following line from viewsrefresh.js executes

else {console.log ('Can\'t find viewName on this page');}

and nothing else happens.
Targeted View is present on a page and markup generated for that view is exactly the same as for logged in users. Seems like my function can not find the view when user is not logged in.

QUESTION: How can I make this function to detect targeted view when the user is not logged in? Am I missing something fundamental?

I understand this is a lengthy question. Greatly appreciate any insight on this if anybody has time to spare. thanks


texts:
I have created a pseudo field with this code:

/**
 * Implements hook_entity_extra_field_info().
 */
function MYMODULE_entity_extra_field_info() {

  $extra['node']['my_bundle']['display']['my_pseudo_field'] = [
    'label'       => t('Pseudo Label'),
    'description' => t('Pseudo description'),
    'weight'      => 100,
    'visible'     => TRUE,
  ];

  return $extra;
}

/**
 * Implements hook_ENTITY_TYPE_view().
 */
function MYMODULE_node_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode, $langcode = 'fr') {

  if ($display->getComponent('my_pseudo_field')) {

    $build['my_pseudo_field'] = [
      '#markup' => 'This is my pseudo content',
    ];
  }
}

Everything is working fine, except that I couldn't add it in a view.


texts: Change default value on core node/add forms after submit

texts:
I'm using the core node/add/ url to create content in my site. I have a date field that defaults to now. I'm also using the add another module.

Is it possible to change the default value to the last one submitted when the user chooses the option to submit and add another?

So, if a user creates a content with date=2019/01/12, when he clicks submit and add another, the form should show with the same date value.


texts: Translation for node references not working properly

texts:
I have two content types: product feature and product. Both can be translated. If I create English product and assign many product features (by node reference inside field collection) and then create translation (ex. French) for this I have rewritted product features. Then I can select Product features translated previously to French. English product have English product features and French product (translated) have French product features (also translated).

PROBLEM:
When I modify French node (change product features to French) my English node is also changed (product features are French).

Did I missed something?


texts: Import configuration in CI/CD script does not work

texts:
I have a Drupal 8.9.13.
I wanted to install a new module, for example the google_tag. But in my case I do that in my CI/CD process. So to do that I did the following actions:

edit the composer.json in a way to contain the new module
the composer.lock is updated for the same reason (by enabling the module using drush)
updated the core.extension.yml in a way to contain a line
generated the *.settings.yml by exporting the configuration.

During the deployment, first of all the code source is get from the git repo and then a 'composer install' is called.
After that a "./vendor/bin/drush config-import -y" is called to import the configuration of the new module (event the module wasn't configured, there is a default config).
And here I have the following error:
Unable to install the google_tag module since it does not exist.
Does someone have any idea what might be the problem?
I saw also that in Drupal's database in the table config for the value of core.extension I have a value which usually describes the activated modules and the one I am trying to activate is not there.


texts: In Drupal 7 how do you output array objects to be view able in watchdog error reports?

texts: For some reason I couldn't use devel to debug output object arrays. Is there a way to output the array data to watchdog error reporting? This would also solve the issue of having to install or enable another module.


texts: How to increase priority of my custom CSS?

texts:
I have this View:

The empty rows have a distrib0 class that should make the background red.
For that I have a custom CSS (amap.css) with tr.distrib0 {BACKGROUND-COLOR:#FF0000;} in it.
I have this amap.libraries.yml containing

amap:
  version: 1.x
  css:
    theme:
      css/amap.css: {}
  js:
      js/amap.js: {}
  dependencies:
    - core/drupalSettings

and finally, I attach the CSS with

function amap_views_pre_render(ViewExecutable $view) {
  if($view->id() == 'calendrier_des_distributions' && $view->current_display == 'page_1') {
    $view->element['#attached']['library'][] = 'amap/amap';
  }
}

As you can see in the screen capture, my CSS is there but after color.css which is part of the current theme.
And of course my background is not red!
What can I do (besides adding tr.distrib0 in tr.distrib0 to color.csswhich I'd prefer to avoid)?


texts: Drupal Installation modules leftovers cleanup

texts:
I have some questions that more experienced Drupalers might know.

When you have been developing a Drupal site, installing, uninstalling and testing various modules for different set of functionalities, when the launch day comes how do you clean up leftovers of the modules? To be more specific.

How do you remove folders that are not needed anymore from the sites/all/modules folder?
How do you remove leftover database tables?
Is there a contrib module that can actually do that? Cleanup a Drupal Installation?

Thanks in advance.


texts:
In my custom module I'm creating a logic with two fields.

The first field is an image and the second is date field.
When I choose past date from the date field, the image field should be hidden. If the date value is present or made in future, the image will be visible.

It's working great on hook_node_view, but I can't figure out how to do this on views.

Here's my code:

<?php
function custom_alter_node_view($node, $view_mode, $langcode) {
 if ($node->type == 'hot_offers') {
    $c = strtotime($node->field_hot_offers_new_date['und'][0]['value']);
    $current_time = date("m/d/Y H:i:s");
    $d = strtotime($current_time);
    if ($c < $d) {
    $node->content['field_hot_offers_new_image']['#access'] = FALSE;
    }
  }
}

I know there's a hook_views_pre_render, but how do I create the same logic, so the image will be visible only if the date field value will be present or in future?


texts:
I am downloading a dev version of the Drush Search & Replace module via

drush dl sar-7.x-2.x-dev

And then trying to enable it

drush en sar

But returns contradicting options. First it says the project was not found, and then asks to overwrite the project that was downloaded previously

drush en sar
sar was not found.                                                                                [warning]
The following projects provide some or all of the extensions not found:                                                              [ok]
sar
Would you like to download them? (y/n): y
Install location /home/ubuntu/.drush/sar already exists. Do you want to overwrite it? (y/n):

Using drush 5.10.0


texts: How to override "Who's online" block theme without any change to "Who's new" theme

texts: In user module, "Who's online" and "Who's new" blocks both use the user_list theme function. How can I change the markup of Who's online without any effect on Who's new's block markup?


texts:
i need to do a configuration file wich allow an admin to select a lot of terms from a vocabulary. Then i want to make a form with 2 select field : Vocabulary and Terms. So, i can select the vocabulary i want and a lot of terms of a vocabulary but i don't know to show all terms of the selected vocabulary.

My code :

/*
 * ==================================
 * CONFIGURATION MODULE
 * ==================================
 */
function food_truck_form_admin() {
  $form = array();
  $form['vocabulary'] = array(
      '#title' => 'Vocabulary',
      '#type' => 'select',
      '#options' => food_truck_form_vocabularies()
  );
  $form['terms'] = array(
      '#title' => 'Terms',
      '#type' => 'select',
      '#multiple' => TRUE,
      '#options' => food_truck_form_terms('marqueurs')
  );

  return system_settings_form($form);
}

/**
 * Implementation of hook_menu()
 */
function food_truck_form_menu() {
  $items = array();
  $items['admin/settings/food_truck_form'] = array(
      'title' => 'Food-Truck Configuration',
      'description' => 'Global configurations',
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
          'food_truck_form_admin'
      ),
      'access arguments' => array(
          'administer food_truck_form settings'
      ),
      'type' => MENU_NORMAL_ITEM
  );

  return $items;
}

/*
 * ==================================
 * OTHER FUNCTIONS
 * ==================================
 */

/*
 * Return a term list of a vocabulary by it's machine name or null
 */
function food_truck_form_terms($machine_name) {
  if (! empty($machine_name)) {
    $vid = taxonomy_vocabulary_machine_name_load($machine_name)->vid;
    $terms = taxonomy_get_tree($vid);
    foreach ($terms as $data) {
      $output[$data->tid] = $data->name;
    }
    return $output;
  }
  return NULL;
}
/*
 * Retur a vocabulary list or null
 */
function food_truck_form_vocabularies() {
  $vocabulary = taxonomy_get_vocabularies();
  if (count((array) $vocabulary) != 0) {
    foreach ($vocabulary as $data) {
      $output[$data->vid] = $data->name;
    }
    return $output;
  }

  return NULL;
}


texts: How to programmatically change settings of input filters and activate them?

texts:
I'm looking for a way to programmatically change the settings of an input filter and activate it in Drupal 7. Let's take the Footnotes module as an example: It adds a new input filter that can be activated on input formats. I can navigate to admin/config/content/formats/2 to edit my "Full HTML" input format and there activate the Footnote filter and configure it. But how can I achieve that programmatically?

My first guess was to load the input format using filter_format_load(), change some values and then do a filter_format_save(). But in the object that I get from filter_format_load(), there are no input filters, i.e. $format->filters doesn't exist.

I can get all available filters using filter_list_format() and I believe I could change some values there. But then again, I can't find a way to save those settings.


texts: How to set different themes for multiple domains

texts:
I am developing a multi-domain site with same code base and single data base.
I am trying to set themes for multi domains which was previously supported by domains theme module in Drupal 7.
  Don't know how to achieve solution for this. Please help me for this.


texts: Creating mobile-applications (like Android applications) with Drupal?

texts:
First, sorry if the question seems a bit basic to veteran programmers here - I'm just a newbie student for JS programming and not that of a big user of smartphone applications in general, at least not yet :) . I'm also not experienced in PHP programming (have yet to actually try that) and just in my first steps to getting to know this whole world now.

I want to know if it's possible, or at least practical to create smartphone (and maybe even web) applications with Drupal, at least with Drupal 8. Please give the most basic and general detailing you can.

Thanks,


texts: How to combine block form submit result with on fly created content together in Drupal 8

texts:
I write a custom module in Drupal 8.

Have my custom block defined:

class MyBlock extends BlockBase {
    /**
     * {@inheritdoc}
     */
    public function build(){
     $form = \Drupal::formBuilder()->getForm('Drupal\mymodule\Form\myform');
     $markup = bunch of html here;
     $content = data feed from 3rd party;
     return array(
      '#markup' => $form + $markup + $content,
     );
  }
}

What I want is, that after block build have both form and feed data in format html way show up.
Any suggestions will be appreciated.


texts: How do you change which content type a field is attached to (which one owns it?)

texts:
While exporting configuration for my site using the Features module, I noticed that one of the fields I use on many content types was initially created on the "news" content type instead of the "article" content type. This presents a problem, since it means all of the features that I export are now dependent on a completely unrelated module (news) to provide a common field (field_image).

What I'd like to do is change the entity that "owns" field_image to be article. This will let me export one base feature which provides a bunch of common fields, and have the rest of the features depend on that instead of having them all depend on news.

How can I change which content type owns field_image without breaking everything?


texts: How do I enable comments for forum like statuses module?

texts:
i used this module  project statuses  (drupal 7)
i want that write comment for forum like above module.
how can i do assign statuses style to comments forum?


texts:
I am experiencing problems with breadcrumb trails inconsistently not displaying correctly. I am using the core breadcrumb module, without any others installed. (I did have Custom Breadcrumbs installed but have since uninstalled and removed it.)

I have links to nodes nested in parent items in the main menu like this:
Home > Chapter > Topic > Subtopic.
Most nodes are displaying the breadcrumbs like that, which is what I want. However, a few are displaying like this:
Home > Subtopic (not showing the chapter and topic under which they are listed)

I believe I started getting this error when I changed the numerical weight of the menu items in structure > menu. I have since changed their depth, changed their parent menu item, flushed caches, nothing has worked. It is only a few nodes with the problem and they were originally working as expected. I cannot recreate this problem either. If I create new nodes they show the proper breadcrumb trail. The items in question are all as they should be in weight and parent menu item position they should be. If I install Custom Breadcrumbs I can force the breadcrumb trail to the desired state. Is there a table that I can flush in the database that will fix this problem? Is there a way to fix this without deleting the node and recreating it?

Edit: I found the problem. I have links to these nodes in two different menus on the same page. Drupal is using the other menu I created instead of the Main-Menu to make the breadcrumb trail.


texts: Passing values from text field to a javascript function in Drupal 8

texts:
i am new to Drupal and i am building a form (Drupal 8)that needs to calculate an amount based on the input in two text fields.
What i want to achieve is for the "calculate" button to be hidden until the two text fields have been filled but i'm not sure how to achieve this with behaviors.
Code example:

    $form['weight'] = array(
        '#type'  => 'number',
        '#title' => t('Weight:'),
        '#required' => TRUE,
        '#attributes' => array(
            'id' => 'weight',
            ),
    );
    $form['number'] = array(
        '#type'  => 'number',
        '#title' => t('Number:'),
        '#required' => TRUE,
        '#attributes' => array(
            'id' => 'number',
            ),

    );
   // Here if weight and number are not empty, show button

Thanks


texts: Issue with drupal_add_css, can do it by nid but not by alias

texts:
I am using the drupal_add_css function in my template.php file (Drupal 6) and this code works:

if (arg(0)=="node"&&arg(1)=="74" ) {
drupal_add_css(drupal_get_path('theme', 'mythemename') . '/css/slider.css', 'theme');
  }

However if I use this code, it does not work.

if (arg(0)=="web-portfolio") {
drupal_add_css(drupal_get_path('theme', 'mythemename') . '/css/slider.css', 'theme');
  }

I am wondering what I am doing wrong. (note "mythemename" is used in place of my actual theme name here and the actual aliased path is example.com/web-portfolio


texts: Website returning 404 and not 403 for forbidden pages

texts:
My site is returning a 404 error for users who have tried to access a restricted page. I understand that this can be seen as a useful security features, however, I would like to return a 403 error instead.

I note that drupal is recording "access denied" in the logs, but somehow this is getting converted to a 404 for the user.

I have tried changing theme to see if that helps, and had no success. I have also removed custom 404 and 403 pages but this did not help either.

Googling the problem found the following file, drupal/core/lib/Drupal/Core/Controller/ExceptionController.php. This does not seem to exist in my installation of drupal.

I am not confident (or competent!) at altering php files.

Any help that can be provided would be greatly appreciated, as I am at a loss on how to proceed.


texts:
When using the batch API, can I setup multiple batch jobs or can I only setup one batch with multiple operations? I ask because of a data migration I am doing.

Also, will it run the batches and operations in the order they are received or are they run concurrently? I need to have some items imported before others. So I am concerned about this.


texts: Creating an alternative login page other than /user/login

texts:
I have managed to do this in Drupal 7 with the following code:

function my_special_paths_menu() {

    $items['authenticate'] = array(
        'title' => 'Log in',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('user_login'),
        'access callback' => 'user_is_anonymous',
      );
     return $items;
    }

My question, is this code complete or is it missing some configuration in the menu item array? Is the code safe the way it is?


texts:
I am having an issue loading my custom icons for the Fivestar module; Here are the steps I am taking, I am hoping someone can point out what I am missing.

first I hook into the fivestar widget to add in my new theme.

function my_module_fivestar_widgets() {
  $module_path = drupal_get_path('module', 'my_module');
  $widgets = array(
    $module_path . '/images/bonestars/bonestar.css' => 'bone_stars',
  );

   return $widgets;
}

This bonestar.css is pretty much a complete copy of the basic theme. Inside the css I link to my images instead of basic, so everything so far seems safe.

Next I go to the views configuration and click under Fields, Field: Rating. I click the SHOWSTAR DISPLAY OPTIONS to select which star I want to use. I see my custom stars visually:

I select it and save it and apply to all.

So then I go to my view to check if the new star theme has been loaded, but it now loads basic. So I clear the cache as well, nothing.

I am obviously loading the images or something, but it doesn't translate to my view. What am I missing? I also test this on views, blocks, etc it never loads it on the actual site. Only in the settings as seen above.


texts: Horrible permissions bug, anonymous users can edit products

texts:
I have a Drupal Commerce site. I'm using Content Access to only allow users with the role "Vendor" to "Edit own product." Nobody else is allowed to edit any products. This is the only module I'm using afaik that controls permissions.

And yet.... everybody is able to edit all products! Even guests! This bug is horrifying.

I've tried

clearing all caches
emptying the node_access DB table
Rebuilding permissions from the status report
completely disabling editing products for anyone
disabling and uninstalling the Content Access module

Here is my access control for the Product content type (it was originally called Produce, hence the machine name being produce)

And yet when I go to view a product, even as an anonymous guest, it shows the "View" and "Edit" tabs. And when I click "Edit" I can actually change the content and save the node!

One node example is node id 78. If I look at the node_access table in the DB, it shows this:

nid   gid   realm   grant_view   grant_update   grant_delete
78    0     all     1            0              0

If rebuilding permissions doesn't work, disabling Content Access doesn't work, then.... I have no idea where to go from here.

Update

I've installed Devel and am checking which modules implement hook_node_access

$ drush fn-hook node_access
Enter the number of the hook implementation you wish to view.
 [0]  :  Cancel
 [1]  :  commerce_marketplace
 [2]  :  node
 [3]  :  features


texts: Cant install Media module with Lightning distro conflict

texts:
I am using lightning-8.x-2.10 and this distro comes with a few of the dependent modules already enabled. So I installed whatever needed modules did not come already with lightning. When I try to enable Media I first check the description next to the title and I see there are no missing module so I enable and save then I get this error. I do not get this error if I enable Media on a plain Drupal 8 site. This only happens when using Lightning.

Unable to install Media, core.entity_form_display.media.document.default, core.entity_form_display.media.image.default, core.entity_form_display.media.instagram.default, core.entity_form_display.media.tweet.default, core.entity_form_display.media.video.default, core.entity_view_display.media.document.default, core.entity_view_display.media.image.default, core.entity_view_display.media.instagram.default, core.entity_view_display.media.tweet.default, core.entity_view_display.media.video.default, field.field.media.document.field_document, field.field.media.document.field_media_in_library, field.field.media.image.field_media_in_library, field.field.media.instagram.field_media_in_library, field.field.media.tweet.field_media_in_library, field.field.media.video.field_media_in_library, field.storage.media.field_document, field.storage.media.field_media_in_library, media_entity.bundle.document, media_entity.bundle.image, media_entity.bundle.instagram, media_entity.bundle.tweet, media_entity.bundle.video already exist in active configuration.

I was able to fix this by going to the config sql table and deleting all of entities listed in the error:
core.entity_form_display.media.document.default
core.entity_form_display.media.image.default
,,,
,,,


texts: Create a wrapper div within field groups on node displays

texts:
For ease of formatting I would like to add an inner wrapper div inside of field groups displaying on content nodes and node forms. I'm using the Field Group module to display groups in div format.

Currently it's this:

…

Would like to output this:

 …


texts:
I have a very complicated view, and I can't change the existing field structure (it's an established and functioning site). This is a simplification of the problem, but it has to happen this way, I can't turn it the other way around...

There are two node types (Author and Book), the Book type has an entity reference pointing at the Author.

The view I want to create lists the authors and needs to display all the Book titles in a single column (one author per row, all the book titles in one cell together).

How do I create the entry in the view, so it does that?


texts: How do I pass variables into Twig template?

texts:
In my preprocess function I have variables with the route name and route parameters:

function my_theme_preprocess_node(&$variables){
  $variables['route_name'] = $route_name;
  $variables['route_parameters'] = $route_parameters;
}

How do I pass them to the following link function in my page.html.twig file:

{ Link to the object with $route_name and $route_parameters }

Is it at all possible?


texts: Passing an array of object from custom module to template in drupal 8

texts:
Follow this about passing an array to template. But my array is array of object so I'm getting some errors on the page, this is the one of them:

  User error: "0" is an invalid render array key in
  Drupal\Core\Render\Element::children() (line 97 of
  core/lib/Drupal/Core/Render/Element.php)

This is my code :

Controller

  public function content() {
      return array(
        '#theme' => 'my_page',
        '#text' => "Lorem Ipsum",
        '#myvariable' => array('key' => $myArrayofObjects),
      );
  }

mymodule.module

function my_page($existing, $type, $theme, $path) {
  return array(
    'my_page' => array(
        'variables' => array(
            'text' => NULL,
            'myvariable' => array(),
        ),
    ),
  );
}

my-page.html.twig

Test twig template!

{{text}}

{% for key, value in myvariable %}
  Key : {{ key }}
  Value : {{ value }}
{% endfor %}

This is the array :

Array
    (
        [0] => stdClass Object
            (
                [name] => User1
                [user_id] => 1
                [email] => user1@website.com
            )

        [1] => stdClass Object
            (
                [name] => User2
                [user_id] => 2
                [email] => user2@website.com
            )

        [2] => stdClass Object
            (
                [name] => User3
                [user_id] => 3
                [email] => user3@website.com
            )
     )

How the best way to pass an array of object from module to template and render or loop it using twig engine?


texts: Add class to form-tag in in views exposed form via template_preprocess_views_exposed_form()

texts:
I wonder how I can add a class to the form tag (of the _search_content_ view's) exposed form using template_preprocess_views_exposed_form() (or even better template_preprocess_views_exposed_form__search_content()). The form is exposed as block.

It works so far using the following code in MY_THEME.theme:

function MY_THEME_preprocess_form(&$variables) {
  if ($variables['element']['#form_id'] == 'views_exposed_form' && $variables['element']['#view_id'] == 'search_content') {
    $variables['attributes']['class'][] = 'row';
  }
}

But I can't get it work for:

function MY_THEME_preprocess_views_exposed_form__search_content(&$variables) {
  // I tried:
  // $variables['attributes']['class'][] = 'does-not-work';

  // and also:
  // $variables['attributes'] = new Attribute($variables['attributes']);
  // $variables['attributes']->addClass('does-not-work');

  // and also manipulating $variables['form'], but this didn't work either.
}

The function gets called, but it's not adding the class to the form tag. Is it possible to get it work with template_preprocess_views_exposed_form()?

Screenshot of kint($variables) output, for each function:

Is it possible to get it work with template_preprocess_views_exposed_form()?


texts: How to add a JS confirmation popup when clicking an #ajax button

texts:
I have a basic FAPI button input that is #ajax enabled and that's working fine, but I want to add a JS "Are you sure?" confirmation popup when clicking the button before the code actually runs, and I'm not sure how to do that because FAPI's JS seems to be eating the click before I can get to it no matter what I do.

I've tried adding an inline onclick handler, like so:

$form['search_filters']['channels']['channel_delete_' . $channel->nid] = array(
  '#type' => 'button',
  '#name' => 'channel_delete_' . $channel->nid,
  '#value' => 'Delete',
  '#attributes' => array(
    'class' => array('confirm'),
    'onclick' => "return confirm('Are you sure you want to delete that?')"
  ),
  '#button_type' => 'no-submit',
  '#ajax' => array(
    'callback' => 'delete_channel_callback',
    'wrapper' => 'channel_container_' . $channel->nid
  ),
);

...which doesn't help, and I've also tried adding:

$('.confirm').click(function(e) {
  e.preventDefault();
  alert('Is this recognized')? // never runs
});

in my module's JS which is also ignored.

Any other ideas? Is there a way to add a submit handler to the top of the stack which Drupal #ajax will recognize?


texts: How to create a views normal menu based on a contextual filter

texts:
In drupal7 I can create a views menu and path easily. What I would like to do is create an automatic path and normal menu based on a field [year] that is associated with a specific node type, using a date token.

Example:
url: /student/2012      with 2012 being the field that gets update automatically
menu undergrad/2012     main menu (unergrad) with sub-menu (2012) which is a field


texts: show results for a view with certain node reference

texts:
I have created two content types a home and a subdivision.  I have added a subdivision reference field in the home content type.

What i want to have is in each subdivision page, show a teaser of the homes that reference that particular subdivision.  I imagine that would be done using views, but I am not sure.

Any help on how to create this view block on the subdivision node would be appreciated.


texts: Forward Node to Translated Version with original friendly URL

texts:
Here is the use case:

Node/View 1's path is "about-us" and it has language set to English.
Node/View 2's path is "acerca-de-nuestra-historia" and the language is set to Spanish.

I need a solution that will forward "es/about-us" to "es/acerca-de-nuestra-historia" and vice versa.

Am I missing something obvious? I can't seem to find a setting that does this with the i18n module.


texts: What bundle and entity_type do I use in field_create_instance to add a field to a taxonomy vocab?

texts:
I have a vocab with the machine_name = the_bundle. This is my call to field_create_instance:

field_create_instance(array(
  'field_name' => 'category',
  'label' => 'Some label',
  'required' => true,
  'widget' => array('type' => 'autocomplete_deluxe_taxonomy'), // I've also tried options_buttons
  'entity_type' => 'taxonomy_vocabulary',
  'bundle' => 'the_bundle'
));

However when I use the drupal UI to manage the fields on the vocabulary, the instance does not exist. I have verified that the field I'm attempting to create an instance of does in fact exist. I'm also not getting any errors when I enable the module.

What am I doing wrong?


texts: How to change the author information for nodes?

texts:
Author information is disabled for all nodes (enter site). I was trying to enable it couldn't find the setting. I am currently using Drupal 7 and my theme is Omega.

I have given permissions to

  Execute Change the author of content

but still author information text box is disabled.

Please let me know how to change info.

Yes, I enabled the display of author and date information.


texts:
How can I apply patch for my Drupal 6 site which is working quite fine until now?

I've checked the patch in Drupal 7. It's using sanitize(). How do I add it in Drupal 6?

At the same time I'm working to have it upgraded to Drupal 8.


texts: Is there any way to know which theme hook or template is being used to output certain area of a page

texts:
Is there any way to know which theme hook or template is being used to output certain area of page? I am showing different menus on a page and i want to know which theme hook is being used to output particular menu and links of menu.

I tried dpm($variables) in function theme_menu_links($variables) in common.inc just to make sure if this theme hook is being used to output the links of menu but this theme hook is not being called and no output is printed. Then certainly this theme hook is overridden by other module or by theme.

Is it possible to know list of all available hooks and templates files for a particular are of a page like block, menu etc with the active theme hook used to output that area?


texts: What can I use to layout the content type form input when creating content?

texts:
I have created a content type with about 15 fields.

I'd like to improve the layout of the form for creating content of this content type.

Currently all the input fields are listed one after the other which means a lot of vertical scrolling and not everything can be seen on one page.

I looked at the Display Suite module ( http://drupal.org/project/ds ) but I could only see how to layout the resulting content not the input form used to create it. (UPDATED: answer below from Елин Й. says that display suite can actually layout the input form)

Another option would be to create a theme with form layout (good question - and answers here: How to a use a template file to theme a form? ). That's fine, but before I do that I wanted to look at other options available (don't wish to re-invent the wheel.)

Or should I use entities and EntityForm instead if that provides better layout options.

Finally, I'd prefer not to use webform module as EntityForms and ContentTypes provide better integration with built in Drupal features, so I've read.


texts: Calendar widget link to list a day's events

texts:
I am using the Calendar module to manage an events calendar on a new site. Currently when you click on a day in the widget it takes the user to the calendar page that shows a small list of the titles.

Is there a way to create a view that shows all of the days, and events for that day, in a single spread and bypasses the calendar completely?


texts: Show page with child terms when clicking parent term

texts:
I have a vocabulary with the following structure:

Vocabulary
Parent term 1
    Child term 1.1
        Node tagged with child term 1.1
    Child term 1.2
        Node tagged with child term 1.2
Parent term 2
    Child term 2.1
        Node tagged with child term 2.1
    Child term 2.2
        Node tagged with child term 2.2
Parent term 3 (no children)
    Node tagged with parent term 3
    Node tagged with parent term 3

With very limited knowledge I managed to create a view displaying the top-level terms. I would like to click on one of this terms and go to a page displaying either the child terms of the selected parent or, if there are no children, the nodes tagged with that term. After much trial and error all I get when clicking a parent term is a message of 'There is currently no content classified with this term' when I really want to display its children.

In a desperate attempt I created different vocabularies for the terms with child terms and the terms with just nodes underneath. Then I used Views to create different blocks based on the vocabulary name and placed those blocks using the Context module, but this seems like a long shot and I'm sure there's a more straightforward way to accomplish this. By now I have tried several combinations with Taxonomy Menu, Taxonomy Display, arguments and relationships in Views, etc. and I'm not any nearer.

I posted this at the Drupal forums but with no luck yet, I hope someone here can help me figure this out :)


texts:
I have just created a Feature that has about 10 module dependencies.
I installed the feature on the target Drupal instance, and discovered that the dependencies were not included in the feature tarball. Is there a way to tell features to package dependency modules into the feature so that they will get installed along with the feature?
Or am I misunderstanding what the features module is supposed to do?


texts: Drush Omega Guard - "command could not be found" or "could not locate Gemfile"

texts:
I have a multisite installation on Windows 7. I am now trying to execute the drush omega-guard command on an Omega sub-theme.

When I am in the theme folder (sites\all\themes\theme_name) I get the response "The drush command 'omega-guard' could not be found."

When I am in the site folder (sites\site_name.com) omega-guard prompts me with "Which theme do you want to run Guard for?" Once I choose the number for my sub-theme, it responds with "Could not locate Gemfile." I think the Gemfile should be in my theme directory.

What am I doing wrong?


texts: Defining functions in a module and calling them from a controller

texts:
I want to use a function in both a controller and a module. where should I define that function?

Can I call a function in module from a controller? How I can do that?


texts: Teasers/summaries don't show when body begins with picture

texts:
I have a blog content type which uses a WYSIWYG editor and allows media to be inserted.  Usually things work out fine, and the blog page shows a list of nice trimmed teasers and/or summaries.  But when the blog post begins with a picture, the teasers and/or summaries don't show up on the blog page.  Instead, there is just a --- where the text would normally be.

I tried deleting the  tags around the image, but it didn't help.

Any advice? (We have to continue using the WYSIWYG editor/media insert, so that part can't change, unfortunately.)


texts:
How can i change the langcode of all nodes? I have tried

UPDATE node SET langcode='und'

But it still sais 'English' on node edit.


texts:
I have content type which has text field. Each node has its own javascript code which is set in to the text field. Text field is PHP Code format.

When I add this field to Views block site load ONLY the javascript in that text field. Whole other drupal content is not loaded. When I remove this field from views then site works normally.

This script works on full node but not in the Views. What can cause this? What ways to fix it?

Script is from Tradedoubler (third party advert) :

<script type="text/javascript">
  var uri = 'http://url.com' + new String (Math.random()).substring (2, 11);
  document.write('<sc'+'ript type="text/javascript" src="'+uri+'" charset=""></sc'+'ript>');
</script>


texts: Drupal Front end Form with fields with option to add More Fields

texts:
I want to create a Form in the frontend, so user can able to add the data in the form and submit the data. Then i have to display all the data submitted by the user using that form. Just like a Internal Messaging system. I want a Add Reports Form and i want to list all the reports in a page ( View Reports). I planned to create a content type ( Reports), After that i will be able to add the fields. Upto this i know how to do. But i want to know how to have a row with three fields with add button, then if user click on the button,  i want to append a new row with same three fields. Just like Multiple Image upload. I have screenshot. In screen one, i have a add button above a row with three fields. In the screen two which is taken after clicking the "add button" , It displays the same add button with two rows with same three fields .

Screen 1 :

Screen 2 :

Any help would be greatly appreciated.


texts: Solr Search - Adding taxonomy to Search results

texts:
I'm using the 'Solr Search' module ( not Apache solr search ) .

What I need to do is return results that have a taxonomy term relationship.

In my search indexes 'fields'  I have the taxonomy I want 'Keywords'  selected. The type for this is 'Taxonomy term'  .  I have also added 'Keywords » Name' through 'Add Related Fields'  .  This is type 'Fulltext'  and after reindexing and saving this field appears in views/search/page / search ‘full text’ / Searched fields.

However when I search for a keyword through the exposed filter the results are not being returned. They can however been seen in Facets.

Any idea what I might be missing.


texts:
I've being using Feeds to import a medium sized amount of nodes in a daily basis.
I'm using Elysia cron in order to get fine tuning cron settings.

Here's my flow :

Every day at 02 am a cron task is triggered
This task loads a list of files from its settings, and for each of these files, it triggers a feeds import by calling :

$myFeed->startImport()

If you take a look at this startImport method, you will see something like this :

public function startImport() {
    module_invoke_all('feeds_before_import', $this);
    $config = $this->importer->getConfig();
    if ($config['process_in_background']) {
      $this->startBackgroundJob('import');
    }
    else {
      $this->startBatchAPIJob(t('Importing'), 'import');
    }
}

So, we have two ways of calling the Feeds importer, either using the Background JOB api (which I suppose to be this : https://drupal.org/project/background_process) or the Batch API (https://drupal.org/node/180528).

Since I'm starting the feeds importer from a cron task, which one is more appropriate for this scenario ?

Can we see the Background process as an enhancement of the Batch API ?


texts: Digit 2 Appended to Field Name on Column in Entity Field Query

texts:
I have an Entity Field Query that has fieldCondition for field_email

  ->fieldCondition('field_email', 'value', $email , '=');

I have verified that this is the name of the field and I have other entity queries that use this field correctly.  However, in this example, Drupal is adding the digit 2 on to the field name as I understand the error returned.

$dup_query1 = new EntityFieldQuery();
$dup_query1->entityCondition('entity_type', 'node') ->entityCondition('bundle', 'fair_participant')
 ->fieldCondition('field_last_name', 'value', $last_name , '=')
 ->fieldCondition('field_first_name', 'value', $first_name , '=')
 ->fieldCondition('field_email', 'value', $email , '=');

$fpmatch_fandl_email = $dup_query1->execute();

  SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'field_data_field_email2.field_email_value' in 'where clause'

Any help is greatly appreciated.

Thanks,
Josh


texts: Relate number of values to an integer field

texts:
I was wondering how to do this with drupal. You probably wonder why I don't just use the unlimited amount of values setting. That's because I want to require the user to fill in the amount of values related to the integer value.

For example, you want to create a group (node) for a specific category (node). A category which contains an integer field (field_members). Now lets say you also have a node reference field (field_category) at those group node its fields, which refers to a specific category (in this case field_members). Then the user must add the amount of users related to the category its field_members value.


texts: Drupal 8.2.2 kint output in template not working

texts:
We are trying to use the kint() or drump() debugging functions inside twig templates in Drupal 8 but both does not seem to be working even though we have tried all the approces to get them working available online.

I have renamed my default.services.yml file to services.yml and set twig.config debug, auto reload and cache to true, yet I can't get any output out from those functions; however, it does not fail with a non-existent function error either.

When I try to use the dsm() function in my controllers or other files outside twig templates, it works as expected.

Any idea where the problem might be?

Thanks a lot in advance.


texts: Regularly update an 'adopted' table with a local CSV file

texts: I need to regularly update a table from a CSV file located on my server. I'm using the data module to integrate it with views. I've researched the feeds module, and looks like it used to support a data processor, but it seems to have been dropped. The Data API from the data module looks promising, but not much documentation or support. What is the recommended way to achieve this?


texts: views_query_alter apply "%LIKE%" condition

texts:
Is there a way in which I can alter the view query so I can get items that contain a specified string in title?

For example something like this:

if (isset($_GET['query']) && (!empty($_GET['query']))) {
    $view->query->add_where('title', $_GET['query'], 'LIKE');
}


texts: CCK Nodereference individual imagefields

texts: Is there a way to use a nodereference field on each individual image in a node? The images are CCK imagefields.


texts: CKeditor not showing for authorized users

texts:
Drupal 8.5.3, all modules and themes up to date.

The CKEditor only shows up for administrator users when creating or editing nodes. The authorized users are listed as Roles for the Text Format "Basic HTML" which is the Text Format for the field in the Content Type too.

There is a javascript error being thrown in /core/modules/ckeditor/js/cheditor.js, line 134 saying "drupalSettings.ckeditor" is undefined.

Thanks,
Greg


texts: What is the correct way to use a Symfony bundle?

texts: I want to use https://github.com/KnpLabs/KnpSnappyBundle in a Drupal 8 project. How do I correctly use it?


texts: Menu link does not have all options by getOptions()

texts:
I am looping through all menu items to get their URL options as per getOptions()
For some reason some items don't have all options being returned although I have all the same settings.

I'm not sure why this is happening, as you can see, the last one misses things like "node_type" etc. Any help?


texts: Translation issues-How can we set admin in default English language in multilingual site

texts:
Possible Duplicate:
  Do not translate the admin area / How can I set the language of the admin area to English?

I have a problem with a multilingual website.I used English and Arabic as two languages .Done all the laguage settings.But when i tried to translate a basic page content to arabic ,the whole admin turned to arabic and showed rtl mode.I need to fix it asap.Please guide me.

NB: i have all the modules related to multilingual site at local and transferred the whole files and same database to server.At local it was working fine.But at live it won't!.please


texts: View AJAX Refresh causing multiple refreshes

texts:
In attempting an AJAX refresh on several views contained in separate blocks on a single page, I seem to be coming across a problem. This is running on D7.34

The idea is for the page to contain 4 blocks, each with a view sorting by random - then using a simple click() on the block title to
activate a refresh of any given view allowing the user to view a new random item.  I am using the common:

var selector = '.view-dom-id-' + dom_id;
jQuery(selector).triggerHandler('RefreshView');

to achieve this, which works perfectly.  The trouble I am having is in increasing multiples of refreshes:

clicking on one view refresh does refresh the view, but it seems to create a counter, when a different view
is refreshed, that second view refreshes twice. Then going back to the first, the view would refresh 3 times, and so on.
It doesn't happen if clicking on the same view multiple times - in this case it only refreshes once as expected, it only
occurs when switching between refreshing different views, however it continues to "count" these refreshes which then effect
the number of times a different view is refreshed when the other refresh is triggered.

I have confirmed that the selector is correct and obtains the unique dom_id for that view
I have confirmed that the call jQuery(selector).triggerHandler('RefreshView'); only occurs once per click
this occurs in Drupal.Behaviours, drupal_add_js, and straight JS added to a tpl file - they all "work" but with the same refresh issue
I have used once() in the call as well with no perceived effect

It seems like when the triggerHandler triggers the refresh, the view itself is refreshing multiple times for reasons I can't seem to
figure out.  I have tried dozens of permutations now without any change in behaviour.  I can't post of all the code from my attempts, but here
is the last attempt which "works" but still refreshes multiple times - this is a straight JS addition to page.tpl, layed out for easier reading:

<script>
  jQuery(document).ready(function()
  {
    jQuery('#block-views-random-cat-block h2').click(function()
    {
      jQuery.each(Drupal.views.instances, function(i, view)
      {
        if (view.settings.view_name == "random_cat")
        {
          var selector = '.view-dom-id-' + view.settings.view_dom_id;
          jQuery(selector).triggerHandler('RefreshView');
        }
      });
    });

    jQuery('#block-views-random-dog-block h2').click(function()
    {
      jQuery.each(Drupal.views.instances, function(i, view)
      {
        if (view.settings.view_name == "random_dog")
        {
          var selector = '.view-dom-id-' + view.settings.view_dom_id;
          jQuery(selector).triggerHandler('RefreshView');
        }
      });
    });
  });
</script>

If I limit the page to one view only, it seems to work fine - it's only in the fact that there are multiple views that I see this effect.


texts:
I saw your post about getting this error "Fatal error: Call to undefined function _system_default_theme_features() in /home/depot/public_html/drupal/includes/theme.inc" after doing a Drupal upgrade.

How can I fix the error? The function is in the system.module file.  Errors after attempt upgrade on Drupal 7.

Drupal version 7


texts: entity Reference with select list doesn't show results

texts:
i'v created a content type with a entity reference field - select list.
in the field settings i'v choose the desired content types for the select list. the preview select list was populated with all the wanted data.
when i create a new content of the above content type the select list of the entity reference is not populated. the only option i have is -none-.
any suggestions?


texts: How do I set the default values for creating a new content type?

texts:
This is a follow up to my question in Can I change the Display Settings by modifying the database? which was answered. Basically, I could not get to the 'display authoring and date information' checkbox because of a module installed. Running the command 'drush cedit node.type.article' as given in @4k4's answer allows me to change this setting.

However, when a new content type is created, the type has display_submitted: true set meaning I have to go in and change it whenever a new content type is created, which I sometimes cannot do.

Is there a way to change the default settings so that any new content type has display_submitted: false by default?


texts:
I have created a content type having two fields:

Title
Image (multiple image field)

Then I create a page view for the same. Added these two fields. Now I have to create an external theming in view so from view-Theme Information- Row Style output, I have created a view-tpl.php page in the templates folder.

I have given this design in this view:

So I want to fetch one by one image path to pass in src of images. I have tried this $fields['image']->content but it print images as an object. How can I get the paths of images to pass in src tag.


texts: Adding HTML class attributes to Entity Reference field links in View

texts:
I have a view ("Tasks") that pulls in Task nodes, complete with sorting and filtering. Each Task can have multiple nodes attached via the "Related Articles" field (field_related_articles). I am trying to loop through each node (which can be a Video, Document, Article, etc.) and assign each link a class name depending on the type.

For example, a "Document" node attached to a Task would display a hyperlink with the document class. Video nodes will be video, and so on.

Here is my preprocess that is targeting the specific field:

function mytheme_preprocess_field__node__field_related_articles(&$variables) {
  $items = $variables['items'];

  foreach ($items as $index => $item) {
    $content_type = $item['content']['#options']['entity']->type->entity->label();
    $class_name = slugify($content_type); // custom function

    $variables['items'][$index]['attributes']['class'] = [$class_name];
  }

}

When I inspect the $variables array, I see the following, which looks okay to me (but I can't be sure):

As you can see, the attributes object now has a class value for each items value (I have two). However, in the HTML, the classes do not show up:

Is there something I'm doing wrong?


texts: How does one create terms on hook_install if hook_taxonomy_default_vocabularies is used in the same module?

texts:
I'm attempting to create taxonomy terms in a module that provides the vocabulary needed to create these terms.

The issue I'm having is the vocabulary is not available upon install.

My module implements hook_taxonomy_default_vocabularies.
I would like to create these terms in hook_install.

What is the best way to create these terms?


texts: Changing numbers of render-blocking JavaScript and CSS

texts:
I have a drupal 7 site.
I use the Advanced CSS/JS Aggregation module

In the past I asked this question, and tried to improve performance and "Eliminate render-blocking JavaScript and CSS in above-the-fold content" as Google Page speed test suggested.

After I got answers to the question I changed the module configuration, and set the Target Number Of CSS & JS Bundles Per Page to be 4.

For some reason, now, when I am running speedtest, I see that I have "9 blocking script resources and 5 blocking CSS resources" instead of 4 clocking for CSS and 4 blocking for script.

Why is that happening?
How can I fix it, and make the advagg configuration work?


texts: Create a new personal page instance for each user

texts:
I have a content type named 'personal' and a node (page) also called 'personal' which is of that content type.

I want my users to have their own private 'personal' page on my website where every user can post their own private stuff. Like a blog page where the page layout is the same for everyone but each user has their own posts on their profile page.

I am trying to achieve something like  www.mywebsite.com/personal/username (or www.mywebsite.com/username/personal)

I am using the Rules module but each user is still getting re-directed to the one and only 'personal' page I have created.


texts: How do you programatically create decimal fields in Drupal forms?

texts:
I simply need to be able to have a text field and validate if input is a decimal number like 100.00, 0.1, 10.6, etc.

I'm using Drupal 7.

Updated question to indicate 'programatic' solution (using Form API).


texts: How can I autologin to my drupal commons site based on login to drupal 7 site?

texts:
How can I Autologin to my Drupal Commons Site when I logged in to my Drupal 7 Site?

I have following two web sites.

(1) Drupal 7 Site ( www.drupal7.com )
(2) Drupal Commons Site ( www.drupalcommons.com )

Edit:

Note:

  both sites are not sub-domain level. Both has different database and
  different source codes so, both are separate sites.

When I Login to Drupal 7 Site I want to automatic Logged in to Drupal Common Site.
Can any one suggest me what are the modules/Tutorials available which will provide the auto login functionality from Drupal Commons to Drupal 7 site.

I have heard about SSO ( Single Sign-on ) But not sure is it feasible or not.

Edit: Alternate Login Options Availble Using REST API Web Service of Drupal.

User login using REST API for Drupal for Other Instance of Drupal.
Installed Services 3.x Module
Enable REST
Create "rest" service and Enable "User" Resource.
Authentication Method: Session Authentication
User Resource has following:
Login
Logout
Register User
By using following I can Login to Site:

http://mysite.com/rest/user/login?username=myuser1&password=mypasswordformyuser1
It will give me in response SESSID and SessName Value.
When I am trying to logged in from Drupal 7 to Drupal Commons Site I will not be able to create cookie for second domain.

So, How can I Generate Cookie in second domain using PHP/CURL/Drupal HTTP POST Methods.

Thanks In Advance.


texts: How do I pass data between hooks that don't interact?

texts:
How do I pass data between hooks that don't interact between them, or between a menu callback and a hook?

In the case the two hooks have a parameter in common, and that parameter is passed by reference, that is easy. What do I do when the hooks, or the menu callback and the hook, don't get a common parameter?


texts: How to access the administration panel if you cannot login again?

texts:
I have created a custom theme. I have added the region user account menu in footer, but I forgot to add the region primary admin access.

Unfortunately I clicked on the logout button, and I am not able to log in again. The page at /user/login appears empty. Now how can I access the administration page?


texts: Is hook_translated_menu_link_alter() thought to be used only on translated menu links?

texts:
Could hook_translated_menu_link_alter() be implemented to simply alter a menu link before it is rendered?

Clearly, hook_translated_menu_link() is only invoked for menu items that have been flagged from hook_menu_link_alter() as altered; if a module uses hook_translated_menu_link() to alter a menu item before it is rendered, it needs to implement hook_menu_link_alter() too.


texts: Using integer with multiple values in Form API

texts:
I have an integer field on a node which can take two values. The nodes are created by the users by submitting a form. I can't work out how to do this for a multiple field text value.

How do I set-up a textfield form element to take multiple values?
How do I then submit it into the node using an entity wrapper?

This is the form element.

function createnode_form($form, &$form_state){
    $form['field_student_age'] = array(
      '#type' => 'textfield',
      '#title' => t('test'),
    ); .....

This is the code that creates the new node.

function postajob_form_submit($form, &$form_state) {

  $entity = entity_create('node', $values);
  $ewrapper = entity_metadata_wrapper('node', $entity);

  $ewrapper->field_salary->set($form_state['values']['field_salary']);

There is no multiple property for textfields. Do I need to open up a different path in the form variable (e.g. $form['field_student_age']['value1'])? I've tried various options but I can't work out what the path would be.

If I do that, can I then just submit it in the wrapper with the extended path?


texts: How to change operator in schema.xml and configure site for AND search

texts:
I am using Solr search with drupal.Its working fine on my site but the problem is
i needed the search to be a specific to the searched content.
If i searched for "assembly and key",the search result showing all results which is having the world assembly and key also.

But I needed the result like wherever this particular word is found not the separate.
when i search for "assembly and key" it is giving me around 55 results and when i am searching "assembly+and+key", it is giving only 1 result which is i want.
So please let me know how to do it.

I have tried to change solr/conf/schema.xml for AND operator also tried to add code in apachesolr module file for changing the mm parameter but it doesn't work.


texts: How to insert a hashed password into table users?

texts:
I'm using services module, but i've created my own resource 'login', I'm using $data to store username + password.

When i use postman, I put a text plain for password, and in my service code i've added the hash function (see my code please)

this is my resource declaration :

'user_connexion' => array(
  'actions'=> array(
    'login'=> array(
      'help'=> t('Permet de se connecter'),
      'file'=>array('type'=>'inc','module'=>'my_module','name'=>'my_module.resource'),
      'callback'=>'my_module_connexion_login',
      'access arguments' => array('connexion resource login'),
      'access arguments append' => FALSE,
      'args'=> array(
        array(
          'name' => 'username',
          'type' => 'string',
          'description' => 'username du client',
          'source' => array('data'=>'username'),
          'optional' => FALSE,
        ),
        array(
          'name' => 'password',
          'type' => 'string',
          'description' => 'password du client',
          'source' => array('data'=>'password'),
          'optional' => FALSE,
        ),

and this is the function callback :

function my_module_connexion_login($username, $password){
//hasher (pour le moment pour tester) password
module_load_include('inc', 'services', 'includes/password');
$password_h= user_hash_password(trim($password));
var_dump($password_h);
}

the var_dump result change every time i send a post request (example for the same password text plain i've got this) :

string(55) "$S$DV5cPYQpTqX94qlY9jiYSsCkMCE7AZldfHbXx7qm1ju1aA6AQxRv"
string(55) "$S$DMM2YDpjJ6R0q8.QxLTVjMrIw2dslnt.fBTRGUK6Q8RWEls.vEjy"..ect

this is the complete function :

function my_module_connexion_login($username, $password){
//hasher (pour le moment pour tester) password
module_load_include('inc', 'services', 'includes/password');
$password_h= user_hash_password(trim($password));
//var_dump($password_h);
$log = db_select('users','u');
$log->addfield('u','uid','id_user');
$log->addfield('u','name','username');
$log->condition('name',$username,'=');
$log->condition('pass',$password_h,'=');
$login = $log->execute();
$connexion = array();

foreach ($login as $co) {
    $connexion [] = array(
        'uid'=>$co->id_user,
        'username'=>$co->username
        );
}
if($connexion == null){
    $response = array(); // error, so no login
    return func_succes(3,$response);
}
else{

    $response = $connexion; //no error and login
    return func_succes(0,$response);
}
 }

If i create a valid user and i choose a password, there is no way to login with this password (using my custom resource) because my function that take text plain from postman as THE password and hash it with MY RESOURCE will not returns the same hashed password as the real drupal hashed password for the password i've created before

How to use my resource to login, with taking the username (works now) and a text password, hash it and have the same hashed password stored on users table, to be able to compare it ?

Thank you.


texts: Drupal 7.14 - grouping site links on search engines

texts:
I am trying to get my sites links, ie. about us, to appear as sublinks of the sites main page. For eg. When you google Drupal, the Downloand & Extend as well as Modules links appear grouped under the main Drupal.org link.

Is there a module that can do this? Thanks in advance.


texts: Views Exposed Filters: how to get functionality shown in this image?

texts:
I'm wondering how hard it would be to get the functionality shown in the image, and at the associated webpage, with Views Exposed Filters. How would you go about it? Thanks in advance!

I notice 3 main things:

Entering text in the autocomplete search box causes the select list options to filter. (The matching letters are also underlined, which is fancy but not necessary.)
Selecting an option causes it to fill the search box.
A number after each select list option tells the user how many pieces of content are available.

The actual search box can be seen on this webpage: https://properties.aplaceinthesun.com/AP1724897/Beautifully-Maintained-Four-Bedroom-Villa-For-Sale


texts:
I would like for users to be able to create new paragraph entities within the form of a custom block instead of going into the linked content type and adding the content.

In the past, I've always used the elements from this list but unfortunately it doesn't seem like there is an option for that.

Has anyone ever built anything similar to what I'm describing?

Thanks.


texts: How to set the default theme programmatically

texts:
I've tried to set a theme as default theme in drupal 8 using the following code

> $config = \Drupal::configFactory()->getEditable('system.theme');
> $config->set('default', 'test_theme')->save();

On installing the module the code is not setting the theme as the one I've entered.
The code is written in hook_install().


texts: How do you output taxonomy terms and the fields thats attached to it?

texts:
I have the following issue where I want to output a list of taxonomy terms and the fields it contains. I have a list of taxonomy terms as US States and each term has a field called city. How can I display the State and City in Drupal 7 Views 3?

I added the field All taxonomy terms and I dont' see any option to display its fields in anyway.


texts:
In drupal 7 it can be do like this. 7 - Reorder Content Types in ("/node/add") - Drupal Answers

How can I reorder Content Types with Drupal 8?


texts: how to delete modules which are alredy uninstall?

texts:
I have set of modules in my system but those modules are not properly un installed
from the file system i have removed all modules but name aad path of the module still remains
in system table

Any one please suggest me how to clear this garbage ?


texts: How to alter languageswitcher to display as select element

texts:
I am trying to get to grips with D8, and want to be able to use the language module's language switcher block. I am trying to alter the output to get it to display as a select element rather than a list.I tried creating block--languageswitcher.html.twig but couldn't see how to alter the list.

Looking into the module, I can see a function language_element_info_alter but cannot see how to use this to render a different output.

Do I need to use a block_alter or theme hook? In the LanguageBlock.php, the build() function returns an array with a #theme parameter set to links__language_block. Would this be what I need?


texts:
I installed ffmpeg according to the ffmpeg instructions I found on d.o.

When I do which ffmpeg it tells me /usr/local/bin/ffmpeg but when I search in Finder for it (installing with MAMP) it tells me it's at /Applications/MAMP/bin/php/php5.3.6/bin/ffmpeg/ffmpeg .

I've tried pasting both of those paths into the field in Video configuration that says "Absolute path to FFmpeg executable. When you install a new FFmpeg version, please clear the caches to let Drupal detect the updated codec support." but then I get FFmpeg not found at [either of those paths].

I have tried removing the extra copies, to no avail. I've tried setting the document root in settings.php, to no avail. I've tried installing and building it manually as well as with brew. No dice.


texts: How can I get Node tokens to be available for my fields

texts:
I am currently using Background Field module to set a background image and I want to set the css selector to incorporate node->nid. However it seems to not be available for me to use in my field but under the list of tokens available throughout my site I can see it there. I haven't been able to pinpoint how to do this. I've attached screenshots to help.

I am using Drupal 7.34 and Token 7.x-1.5.


texts: how can I use special Font awesome character in Twig link()?

texts:
How can I use a special Font awesome character instead of the text parameter with `link($text, $url, $attributes)?

I tried the following code for the Contact us button, but it doesn't show the envelope symbol properly. Instead, it shows #xf0e0;.

{{ link('&#xf0e0;', 'base:contact', { 'class':['fa', 'fa-lg'] }) }}`

Is there any way to output that symbol without using the fa-envelope CSS class?


texts: Can a taxonomy vocabulary entity be disabled or unpublished?

texts:
Vocabularies are config entities. I can see the delete link in the UI.
In the example vocabulary config yml -

taxonomy.vocabulary.blah.yml -

uuid: 16ebbc47-16ac-461c-0000-00000000
langcode: en
status: true
dependencies: {  }
name: 'Blah'
vid: blah
description: 'blahblah'
hierarchy: 0
weight: 0

There is a status property which is true by default. I tried changing this to false and imported the configs, but sadly the vocabulary still lists on the '/structure/taxonomy' page.

Is it possible to make a vocabulary entity disable ?

My use-case is to create a Migration plugin which deletes/ disables the existing vocabulary entities. Not sure how to achieve this, is there any existing migrate plugin which deletes the destination entity ?

Open for any other suggestions.
Thanks.


texts: Creating image derivatives with feeds and imagecache

texts:
I am using Drupal 6. I programmatically add nodes (with image field named field_kuva) into Drupal with feeds module (which I think uses drupal batch processing to add the nodes). After the batch job is ready I have to do smaller images with image cache module.

This is how I do the batching (code A):

$myFeed = feeds_source($feed_source);
  $config = array(
      'FeedsHTTPFetcher' => array(
          'source' => $url));
  $myFeed->addConfig($config);
  while (FEEDS_BATCH_COMPLETE != $myFeed->import());

After this I loop through all the nodes I added and use image cache module to do the derivatives of the original image like this (code B):

 $presets = imagecache_presets();

      $node = node_load($row->nid);
      if ($node) {
        foreach($presets as $preset) {

            foreach($node->field_kuva as $image) {
              $src = $image['filepath'];
              $dst = imagecache_create_path($preset['presetname'], $src);

              if (!file_exists($dst)) {
                imagecache_build_derivative($preset['actions'], $src, $dst);

              }
            }

        }

Now, if I run code A and code B during the same page load, the source image in $src doesn't yet exist and the derivatives are not created. If I run code A and then on separate page load run code B everything works and the derivatives are created.

What do I need to do to get both operations run during the same page load?


texts: Drupal Bootstrap THEME_menu_tree on new menu

texts:
I'm using Drupal 7 and the Bootstrap theme, in template.php I am successfully theming the primary menu (main menu) to enable extra list styles with

function MYTHEME_menu_tree__primary($variables) {
return '
' . $variables['tree'] . '
';
}

I would also like to theme a new menu called "Banner" (menu-banner) but can't access it as expected at

function MYTHEME_menu_tree__menu_banner($variables) {
return '
' . $variables['tree'] . '
';
}

The new menu is successfully defined in MYTHEME_preprocess_page in template.php

$menu = menu_navigation_links('menu-banner');
$vars['banner_nav'] = theme('links__menu_banner', array('links' => $menu));

And I'm able to call it as banner_nav in my page templates.

Is there something I'm missing or is there something specific to Bootstrap that I need to do that's different from the documentation at theme_menu_tree?


texts: hreflang links added to page source without translation

texts:
When Interface Translation module is enabled in Drupal 8, I get hreflang links to ALL languages on the site for every page view sourse, no matter if the content is translated or not.

If alternate hrefland is active on all of the pages, even untranslated ones, it creates some SEO problems.

I want to remove these links. Is any Drupal way to do this?


texts: Installed Boost Caching, but now my dynamic blocks and webforms are also cached

texts: I just installed Boost module for Drupal 7, but now my Webforms and dynamic blocks like commerce shopping cart block isn't working. It's most likely cached, but what are some methods of getting these dynamic blocks to work? I already added exclude paths for admin/*, user/* and checkout/* so it doesn't cache those pages.


texts:
How do I hide a language from anonymous users while I'm working on the translation?

I want the language only to be displayed in the language switcher block and the links to be active, while you are logged in as an administrator, so that they can check the translation while they are working on it.


texts: How to show "New" if the node author is registered within 4 weeks.

texts:
I would like to print "New" if the node author is registered within 4 weeks in a field of "node View" by using custom php with Views Custom Field. I tried the code below but didn't work. Am I missing something?

   <?php
      $four_weeks_ago = time() - (28 * 24 * 60 * 60);

      $user_created_time=$user->created;

    if ( $user_created_time >= $four_weeks_ago) {
        $this_user_is_new="new";
        print $this_user_is_new;
      }
    ?>


texts: How to create a list of similar nodes in Drupal 7/Views 3

texts:
I face a rather common problem of displaying a list of nodes similar to current one. Similar node is defined as one having at least one taxonomy term that current node has. There are few solutions available as modules, however most modules I've found are in beta stage for Drupal 7.

I've also found a couple of solutions based on Views and contextual filters (such as http://scito.ch/content/show-related-nodes-block-based-taxonomy-terms-views-3-and-drupal-7) or relations. I quite like this way as it saves me installing extra modules and with Views being actively developed and supported I'd prefer to use them rather than any custom solution. The problem I can't get around is how to sort "similar nodes" by the number of terms they share. For example, if I have "IPhone 4S" Node with Terms "Gadget", "Apple", and "Phone", I want similar nodes in the following order:

IPhone 3 (Apple, Gadget, Phone)
IPad (Apple, Gadget, Tablet)
Mac (Apple, Computer)
Bramley (Apple, Fruit, Tree)

How can I sort nodes in this view by the number of terms they share?


texts: I am using latest drupal 7 and views. I have created a vocabulary and i have created terms under it. Each term has 2 levels sub terms under it.  Using views i wanted to create a drop down of all the base level terms and when select the base level terms from drop down all the sub level terms must be listed .. is this possible in views??


texts: How to make Localization update believe that the translation of a local .po-file is not up to date?

texts:
I use a local development branch of a contributed project on several sites. The strings that need translation does not exist on https://localize.drupal.org/ (yet), so I cannot use it to translate the project.

Checking l10n update status produces:

$ drush l10n-update-status
…
my_project (7.x-1.x)   Up to date
…

Now, how do I convince Localization update that the translation of this file is not up to date?

So far I've tried:

Editing and saving (i.e. changing the last updated timestamp).
Editing the embedded timestamps POT-Creation-Date and PO-Revision-Date.
Clearing the cache.

But no joy. Localization update keeps insisting that translations from this file is up to date.


texts: How to get the list of values and keys for a given list field

texts:
I want to programmatically get the list of possible key values for a field, along with their labels. For example:

1 => red
2 => blue
3 => Yellow
...

and so on. How do I do that?


texts: Changing Commerce Credit Card option to read something else

texts:
I have two radio options in my form for payment: the first says 'credit card' and the second says 'cheque' (I'm using the PayPal wpp and Cheque modules). The Cheque option is easy enough to change to say something else ('send me an invoice') and I changed that in the store > config > cheque settings.

But, does anyone know how or where to change the text for the 'Credit Card' option. I want to add more information about how we process it to the label itself.


texts: Panels in-place editor won't show in panels even after setting renderer

texts:
My relevant specs are: Drupal 7, Jquery update 2.5.7 (set to 1.7), Ctools 1.7.7, and Panels 3.5.7.

The problem:

I've enabled "Panels in-place editor" to ease panels editing. I've set the renderer at Paenls>Settings` from "Standart" to "Panels in-place editor" and cleared cache - and yet, when standing at the Panel node I don't see it. reasons?

notes:

The site has only 1 user, me, the Admin so it's not a permissions
issue (also checked permissions).
My layout was taken from "Panels extra layouts" module, if it makes
any difference...


texts: How can I transfer node and comment records from Drupal 6 to Drupal 7?

texts: Is it possible to export particular nodes and comments in Drupal 6 and import them in Drupal 7? I do not want to copy the whole database and then upgrade it, but be able to move particular records.


texts: How to render specific form elements from the *.theme file

texts:
I am using Drupal 8 and would like to customize how form elements are being displayed. Specifically, I don't like how uneditable, populated textfields are displayed as plain text. I would have it being displayed as an editable textfield (or have the text look like it is in an uneditable textfield). I have looked at various hook functions to try and achieve this but nothing seems to work.

I figure the best way to go about this is if I can render the form fields individually myself and then create a twig file that displays the individual fields as I would like them to be displayed. Here is what I would like the twig field to look like:

  {{ form.mail }}

  {{ form.message }}

  {{ form.actions }}

This is what I came up with so far:

function theme_preprocess_form(&$variables) {

  $elements = $variables['element'];
  foreach($elements as $key => $element) {
    if (substr( $key, 0, 1 ) !== "#" ) {
      // $variables['form'][$key] = render[$element];
      // This is where I need the code to actually render the element
    }
  }

}

What is the function I need to call to return a fully rendered form element?

To clarify, I would like to accomplish this by only using they my_theme.theme file for my_theme.

Thanks.


texts: twig template to fetch details of linked nodes

texts:
I have a content page say content type "spl content" which has few related pages(added using field entity reference). when i create page in admin I can link multiple pages to my page using  entity reference which i call in this specific case as related pages.

I have custom template for content type "spl content", here I get all the node ids of related pages but I want to access further details of the related pages.

Is it possible in twig template having path themes/custom/{themename}/templates/node--spl-content.html.twig to fetch details of related node?

I do get node ids of related pages by looping node.field_related_pages

{% for item in node.field_related_pages %}

{{item.entity.id}}

{% endfor %}

item.entity.id prints the node id of every related page. I need to have body content and other field of related page in this twig.

Any help is appreciated.


texts:
I'm currently working on a portal site in D7 that allows access to several applications. I have created blocks that link to those applications and made them visible to certain Drupal-roles.

My users are maintained in an LDAP directory and access to the applications is determined by an objectClass, i.e. a user with access to application app1 and app2 will have:

ObjectClass: app1-user
ObjectClass: app2-user

How can I configure Drupal to map those objectclasses to roles?


texts:
In my Drupal 7 site, the date is stored in the database as 2020-08-10 00:00:00.
When I migrate those dates without any formatting (field_blog_post_date: field_blog_post_date), the date is migrated into the Drupal 8 table with the same exact formatting. However, it doesn't show when a node is viewed.
I tried to use a format_date plugin.
field_blog_post_date:
  plugin: format_date
  source: field_blog_post_date
  from_format: 'Y-m-d H:i:s'
  to_format: 'Y-m-d'

When I use it, it causes the following error.

DateTime::createFromFormat() expects parameter 2 to be string, array given
DateTimePlus.php:251


texts: All added links open as target, how to prevent it?

texts:
In my Drupal based website, all links that I added from CKeditor open as (target="_blank"

Link example: (Name)
After adding, example from html source: (Name)

As you see, the 'target="_blank" rel="nofollow"' added automatically.

How can I solve this problem?


texts: Controlling blocks displayed in domain access for each sub-domain

texts:
I'm a noob in Drupal and have been exploring the Domain Access module ( http://drupal.org/project/domain ) in my local environment and till now has been doing pretty well. But when it comes to configuring block content i'm a bit baffled.
Problem goes like this:
domain is localhost.com
Sub domains are:

one.localhost.com
two.localhost.com
three.localhost.com

When i enable a block in one of the sub-domains two.localhost, say enabling Search in Right Sidebar and saving the changes they are applied not only to two.localhost but to all the others too.

Note that I'm working in drupal 6.22 with Garland theme in all the sub domains.
Is there anything I'm missing from the functionalities provided by the module like Domain Theme? or does it have to be coded by me to make blocks also in domain specific manner...any suggestions/helps would be much appreciated.

Thanks and cheers!


texts: How to use third party settings to store an array of values

texts:
I'm making a module and almost complete, but I can't seem to get third party settings to save.

Here is my schema.yml:

editor.editor.*.third_party.ckeditor_styles:
  type: mapping
  label: 'CKEditor Styles'
  mapping:
    ckeditor_styles_stylesheets:
      type: sequence
      label: 'Stylesheets'
      sequence:
        type: string
        label: 'Stylesheet'

Form code:

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * @param $form
 * @param \Drupal\Core\Form\FormStateInterface $form_state
 */
function ckeditor_styles_form_filter_format_edit_form_alter(&$form, FormStateInterface $form_state) {
  $editor = $form_state->getFormObject()->getEntity();
  $stylesheets = $editor->getThirdPartySetting('ckeditor_styles', 'ckeditor_stylesheets');

  $form['ckeditor_styles'] = [
    '#type' => 'fieldset',
    '#open' => TRUE,
    '#title' => 'CKEditor CSS Styles',
    '#weight' => -5,
  ];

  $form['ckeditor_styles']['ckeditor_stylesheets'] = [
    '#type' => 'textarea',
    '#title' => 'Stylesheets',
    '#description' => 'Enter paths to custom CSS files you want to include when the editor is loaded. Example: themes/custom/mytheme/css/style.css. Seperate multiple files with a comma.',
    '#default_value' => '' // need to default to the values from the third party settings
  ];

  $form['actions']['submit']['#submit'][] = 'ckeditor_styles_form_submit';
}

/**
 * Submit handler to save stylesheets as third party settings for the Editor $editor entity.
 * @param $form
 * @param \Drupal\Core\Form\FormStateInterface $form_state
 */
function ckeditor_styles_form_submit($form, FormStateInterface $form_state) {
  $editor = $form_state->getFormObject()->getEntity();
  $stylesheets = $form_state->getValue(['ckeditor_styles', 'ckeditor_stylesheets']);

  if (isset($stylesheets)) {
    $stylesheets = explode(',', $stylesheets);

    foreach ($stylesheets as $stylesheet) {
      $editor->setThirdPartySetting('ckeditor_styles', 'stylesheets', trim($stylesheet));
    }
  }
}

Each iteration overwrites the previous value in the foreach, and no data is saved. Where am I going wrong?


texts: Field filter in Views, filter by TID, not name

texts:
I have a content type, books, with a field Category, based on a taxonomy.
I have a View of books, and can filter by author, date, and also by field category.
Everything works right, but when I try to add several subcategories (nested taxonomy), I have the problem that I cannot let the filter exactly as it is, as I can have two family names exactly equal, namely "offers". For example:

 http://www.example.com/books/science/offers
 http://www.example.com/books/sports/offers

As I am using arg(3) for retrieving "offers", I have the same name for two different taxonomies with different tid's.

How can I alter the SQL in ´MYMODULE_views_pre_view´ so I can filter by tid instead of name? I can programmaticaly get the tid from the URL and inject it directly into the SQL, but don't know how to alter this SQL accordingly.


texts:
I am looking for a way to customize 'edit', 'view', 'delete' links.

I use bootstrap theme, but i use bootstrap v4 styles for it. I want to add 'nav-link' class to each link.

And find a way to display somewhere, not just below post title.

I couldnt find a tutorial about it. Where should i look for this? template parts (twig) or themename.theme file?


texts:
I've installed the Captcha module and I need to remove it from the search button and form (just an unnecessary nuisance there). Captcha configuration allows me to turn it off for specific values of a "Form_ID". I tried that with "search", but I guess the form ID is more complicated than that. What Form_ID(s) do I need to use to get Captcha to stop showing up in search?

Thank you.


texts: How to implement Page not found (404) for unpublished content?

texts:
On my site, some nodes are unpublished forever instead of being deleted. I'd like to return Page not found (404) for anonymous trying to access unpublished node pages instead of Access denied (403). It's not about displaying a different message to the user, but rather about returning the 404 error code (important for bots).

So I've added the following to my module:

function mymodule_init() {
global $user;

  $normal_path = current_path();
  $parts=explode('/', $normal_path);
  $nid_part = $parts[1];
  $node = node_load($nid_part);
  if (!isset($node)) {
    return;
  }
  if (($node->status == 0) &&
    ($node->nid == $nid_part) &&
    ($user->uid == 0)) {
    drupal_not_found();
  }
}

But I still get Access denied as anonymous user on unpublished pages. How to implement it?


texts: Is there a module that provides payment processing but not a shopping cart?

texts:
I am building a website that allows users to "upgrade" their content. The user can choose a "premium" listing and once paid for their node will appear higher in a list of nodes.

I'm looking for a module that can do this, or a module that can at least provide the payment page so that I could customise the node editing process and direct them to this page, take their payment then update the node.

I know something like Ubercart can provide the payment processing but it has a very set payment checkout process that is more oriented to a shopping cart checkout process and would take a lot of time to customise for what I want.

Any recommendations on how to do this?

Im running Drupal 7.


texts: Source entity type and id in webform node

texts:
Im looking for a way to set the source entity type and id to a webform that is inside a webform content type (webform_node)

I followed the modal convention: the address of the webform is /webform/14?source_entity_type=node&source_entity_id=15
Now i would like this to work.

in QueryStringWebformSourceEntity class i see the notice

 // Note: We deliberately discard $ignored_types because through query string
 // any arbitrary entity can be injected as a source.

which makes sense.
what are my options then to add my source identity to the webform submission?

thank you!


texts: How to access boolean field in content node template?

texts:
I've created a content type (event) that has a boolean field (status). I've created a template in my theme called node--event.tpl.php and I've got just about everything working as intended, but I want part of the template to be conditional based on that boolean.

How can I access that boolean in the template so I can use it in an if/else statement?