texts:
A disclaimer first: I am a professional medievalist, not a programmer or a front-ender. I have some front-end knowledge, but not a lot. So, please, be easy on me.
Now, I am customizing a Bootstrap 4 sub-theme and there is a particular layout that I need to achieve that I, for the life of me, cannot get to work. Thus, I turn to you, good and kind people of stack exchange, for aid, counsel and favor.
I am attaching the pictures and the code. The first picture is the original Bootstrap 4 region layout. The picture 2 is the region layout that I need.

The second picture is what I need it to be. Basically, the body of the page should be container-fluid, but the content inside the body should be just container. In that way, the sidebar first and sidebar second would be all the way on the margins. I have read a lot of contradictory advice on nesting a container inside the container-fluid, but whatever I try, it simply does not produce the desired effect.

This is the content of the template file.

  {# link is in html.html.twig #}

  {%
  set sidebar_first_classes = (page.sidebar_first and page.sidebar_second) ? 'col-12 col-sm-6 col-lg-3' : 'col-12 col-lg-3'
  %}

  {%
  set sidebar_second_classes = (page.sidebar_first and page.sidebar_second) ? 'col-12 col-sm-6 col-lg-3' : 'col-12 col-lg-3'
  %}

  {%
  set content_classes = (page.sidebar_first and page.sidebar_second) ? 'col-12 col-lg-6' : ((page.sidebar_first or page.sidebar_second) ? 'col-12 col-lg-9' : 'col-12' )
   %}

    {% if page.breadcrumb %}
      {{ page.breadcrumb }}
    {% endif %}

      {% if page.sidebar_first %}

          {{ page.sidebar_first }}

      {% endif %}

        {{ page.content }}

      {% if page.sidebar_second %}

          {{ page.sidebar_second }}

      {% endif %}

Also, I have no clue what the b4_top_container does; I couldn't find the explanation anywhere.
Any help would be massively appreciated.


texts: Pass variables from custom module to its template?

texts:
I'm trying to query my DB, and return those values as variables, then print those variables on my custom module's custom template and I can't get it to work.

If I put this into my theme layer it works fine.

$name=db_result(db_query('SELECT name FROM {users} WHERE id = %d', 2));
print $name;

I'd rather keep my queries in the .module file and only have to print the variable on my template. So far I haven't been successful.
Also, since I'm planning on having many variables used in many places (like display tables, or as values in calculations) I'd rather be able to print variables where I need them, and not tie them to an $output, or $content variable.

I referenced this post but I couldn't get the example to work.

I'm really new at this, my experience so far as only to take form info and save it to the DB, not bringing it back. so I'd appreciate any help.


texts: Select organic group on the user registration form

texts:
There's a post already on the post installation forum, but I'm not sure if this is a OG bug. http://drupal.org/node/1108884

I am using Drupal 7 and OG 7.x-2.1 version. There is no "Group Audience" in the manage fields page and I think it is replaced with "Group membership", the field type is "Entity Reference" and the widget is "OG Reference". Also there is no input type in the field setting page and I can not find any field that has a "Always show other groups" option. I have checked the option "Show on registration form of that field, but the combo box on the registration form does not have any option. Any suggestion?


texts: What's the event triggered after an autocomplete has run and how to retrieve the value selected

texts:
I have a node add form with a term reference that uses autocomplete widget.

I want the "tid" of the filled term by the user using the autocomplete widget.


texts: hook to change image styles before rendering nodes

texts:
I need to change the image style (or effects of the style) saved in the field display option from page manager when the page rendered to the user based on other fields values in the same node.

HOOK_NODE_VIEW() gives the style saved with the field from the field display option not the one that I created by panels.

I wonder how panels override that value for the style and HOOK_NODE_VIEW() didn't catch it.

so which hook should i look for.It may be related to panels module ,but really I need help because it took so much time and I reach to nothing.


texts: autocomplete on a multi value - custom field

texts:
I have a field organizations on the user profile(the field can accept multiple values). I would like to add a autocomplete to this field. My code for this is

<?php
/**
 * Implementation of hook_menu()
 */
function org_ac_menu() {
  $items = array();
  $items['org_ac/autocomplete'] = array(
    'page callback' => 'org_ac_autocomplete',
    'access callback' => TRUE,
    'access arguments' => array('access dbpedia autocomplete'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Implementation of hook_form_alter()
 */
function org_ac_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_profile_form') {
    //$form['field_organization']['#autocomplete_path'] = 'org_ac/autocomplete';
    $form['field_organization']['und'][0]['value']['#autocomplete_path'] = 'org_ac/autocomplete'; **/* This works but only on the first input field! */**
  }
}

/**
 * Check for possibilities in dbpedia
 */
function org_ac_autocomplete($string = '') {
  $found = array();

  $url = 'http://lookup.dbpedia.org/api/search.asmx/PrefixSearch?QueryString='.urlencode($string).'&MaxHits=5';
  $result = file_get_contents($url);
  $data = simplexml_load_string($result);

  foreach($data->Result as $res_temp)
  {
      $found[check_plain($res_temp->Label)] = check_plain($res_temp->Label);
  }

  drupal_json_output($found);
}

The code works when I reference this element on the form, ->

$form['field_organization']['und'][0]['value']['#autocomplete_path'] = 'org_ac/autocomplete';

But since it can accept multiple values, the autocomplete doesn't work on the remaining elements ->$form['field_organization']['und'][1]  &  $form['field_organization']['und'][2]['value']['value']

How can I make it work on all the input elements for the organization field ?

Thanks


texts: Add extra field on check out page of Drupal 7

texts:
All we want is for the customer to have to tell us how they heard about us at checkout page even when they did not make an account.

How do I add this extra field?

We are running Drupal 7 and below are the new modules installed to accomplish this new task:

addressfield-7.x-1.0-beta2.zip
commerce-7.x-1.0.zip
commerce_extra_panes-7.x-1.x-dev.zip
commerce_fieldgroup_panes-7.x-1.0-rc2.zip
field_group-7.x-1.1.zip


texts:
I have upgraded a website to drupal 8 that I found a field created and I need to delete that field as it became useless.

The field is locked, and this prevents me delete it from the interface.
I tried to delete it using field_purge_field(), but it didn't work either.

The answer for How to properly delete fields, programmatically? didn't work for me.

Edit:
I tried that piece of code but didn't do any thing

$field = \Drupal::entityManager()->getStorage('field_config')->load($entity_type.$bundle_name.$field_machine_name);
field_purge_field($field);

How do I delete fields that result locked? How do I unlock them before deleting them?


texts:
I have created folder structure like below:

Main Drupal: www_d8multisite_com

Subsite1: www_d8multisite_com/sites/default/ms1
Subsite2: www_d8multisite_com/sites/default/ms2

And put the sites.php inside

www_d8multisite_com/sites/sites.php

and defined my multisite like below:

$sites['www.d8ms1.com'] = 'ms1';
$sites['www.d8ms1.com'] = 'ms2';

And put the settings.php in both subsite folders like below:

Subsite1: www_d8multisite_com/sites/default/ms1/settings.php
Subsite2: www_d8multisite_com/sites/default/ms2/settings.php

Then I setup my virtual host like below:

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "H:/wamp/www/www_d8multisite_com"
    ServerName www.d8ms1.com
    ServerAlias www.d8ms1.com
    ErrorLog "logs/www.d8ms1.com.error.log"
    CustomLog "logs/www.d8ms1.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "H:/wamp/www/www_d8multisite_com"
    ServerName www.d8ms2.com
    ServerAlias www.d8ms2.com
    ErrorLog "logs/www.d8ms2.com.error.log"
    CustomLog "logs/www.d8ms2.com-access.log" common
</VirtualHost>

Still my multiste is not working. If I'm trying to access any of the subsites(www.d8ms1.com or www.d8ms2.com) it only pointing to base site. I mean site is still loading from base www_d8multisite_com. not from sub folders.

Am I doing something wrong in the configuration? or I missed any step?


texts: Calling Module function from jQuery and Ajax

texts:
With every drupal site I make, I usually create a custom module that I use to hold different php functions and other things custom to the site I am working on. It usually only consists of a module_name.module and module_name.info. Additionally, I always have .js file in the theme to do any javascripts I might need. Pretty standard right? But I have now run into a situation where I need the two to talk to one another.

I know you can call a .php file and pass it data using .ajax in jquery. How would I envoke a function written in my custom module from the js file in my theme?


texts: How to make [uc_order] token globally available?

texts:
In admin/config/people/accounts , I want user password in welcome mail.

Currently it is

username: [user:name]
password: Your password

I want this

username: [user:name]
password: [uc_order:new-password] // this token is already available in order setting page admin/store/settings/checkout

Now question is is there anyway to make uc_order token available in user account setting page?


texts:
We have a twig template, node--page.html.twig where we want to display the custom variable ns-custom-template. The variable is created from a custom module, mymodule with the following code below.

How can I create a variable, populate it using the ns-custom-template variable, and display it in the node--page.html.twig template?

Here is what I tried, but when using kint(test_var) I get NULL returned.

mymodule.module

function mymodule_theme($existing, $type, $theme, $path) {
  return [
    'ns_custom_template' => [
      'variables' => [
        'test_var' => NULL,
      ],
    ],
  ];
}

Inside mymodule's template folder is ns-custom-template.html.twig

<p> Testing my variable {{ test_var }} </p>

MyModuleController class

class MyModuleController extends ControllerBase {
  public function content() {
    $config = $this->config('mymodule.settings');
    $config_value = $config->get('my_config_value');
    return [
      '#theme' => 'ns_custom_template',
      '#test_var' => $config_value,
    ]
  }
}

mymodule's routing file:

mymodule.module_controller_content:
  path: '/mymodule/content'
  defaults:
    _controller: '\Drupal\mymodule\Controller\MyModuleController:content'
    _title: 'content'
  requirements:
    _permission: 'access content'

MyModuleForm

class MyModuleForm extends ConfigFormBase {
  protected function getEditableConfigName() {
    return [
      'mymodule.setting',
    ],
  }

  public function getFormId() {
    return 'mymodule_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('mymodule.setting');
    $form['my_config_value'] = [
      '#type' => 'textarea',
      '#title' => $this->t('My config value'),
      '#description' => $this->t('Enter some value'),
      '#default_value' => $config->get('my_config_value'),
    ];
    return parent::buildForm($form, $form_state);
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);

    $this->config('mymodule.setting')
      ->set('my_config_value', $form_state->getValue('my_config_value'))
      ->save();
  }
}

node--page.html.twig

<article>
  {{ ns_custom_template }} {# returns null #}
  {{ kint(ns_custom_template }} {# returns null #}
</article>

For reference, I am trying to emulate the steps on Define a custom template for module output page.


texts: How can i create a view of all drupal commerce products with the orders they appear in?

texts:
I try to create an administrative view which lists all products in my drupal commerce installation, where some cols should contain data from the orders in which they appear:

PROD | PRICE | ORDERED
----------------------
one  | 12.-  | -
----------------------
two  | 10.-  | Pete P.
     |       | Anna D.
-----------------------
three ...

But as far as i can see, if i start a view of products, i have no relation to referencing line-items.

If i would start with line-items, i could not have products in my list, which appear in no orders...


texts: How to reorganize drupal sites/all/modules structure without symbolic links?

texts:
Context:

As the number of modules used increases, I try to reorganize modules in /***/sites/all
into

sites/all/modules/contrib
sites/all/modules/custom
sites/all/modules/dev

subfolders as it is described here (1) and now I use a solution similar to what was answered here (2)

Question:
Is possible to use path variable or another solution instead of creating symlinks for each contrib module?

I don't want to create so many symbolic links for each of contrib modules separately.

How to explain to Drupal the sites/all/modules structure the way I don't get bootstrap.inc errors such as:

Error: require_once(): Failed opening required
'/***/sites/all/modules/entity/includes/entity.inc'
(include_path='.:/usr/local/php5/lib/php') in
/***/includes/bootstrap.inc, line 2935


texts: How can I lock out non-authenticated users from a whole taxonomy

texts:
I have a taxonomy hooking together different content types, everything is working as expected. However, I never want non-Admins to see the taxonomy pages, just names or other related fields in views on other pages. How can hide all of this taxonomies pages from non-authenticated users?

Specific example:

Sales Contact (Node Type) - Sales contact name, address, phone, etc.
Products (Node Type) - All sorts of assorted Product Details
Sales Classifications (Taxonomy) - Types of contracts we have with Sales Contacts, and what products they cover.

Product pages and Sales Contact pages are public, but a Sales Classification page makes no sense to show end users. That said, on Product detail pages I'd like to show some of the Sales Classification fields to end users.

Taxonomy Access Control looked promising, but you can ether lock down the whole term (including related nodes) OR set it to do node permissions separately.

Any recommendations would be appreciated.

thanks


texts: What sort of test do I need to validate my form alter?

texts:
I have written a hook_form_alter and added a custom validation callback for the term edit form.
Then I have added custom validation to taxonomy term name length. This is the callback code:

/**
 * Validation callback function.
 */
function max_length_error_message($form, FormState $oFormState) {
  foreach ($form as $field) {
    $field_name = $field['widget']['#field_name'];
    if($field_name == 'name'){
      $value = $oFormState->getValues()[$field_name][0]['value'];
      $strLength = strlen($value);
      if($strLength > 60) {
        $oFormState->setErrorByName('name', t('@fieldname cannot be greater than: "@maxlength" characters.',
          ['@fieldname' => 'Practice Space name ', '@maxlength' => 60]));
      }
    }
  }
}

Now, can I write a test case around this code or do I need to wrap my code inside a class first and then write the test case?


texts: Changes not saved when using paragraph in paragraph

texts:
The project is in Drupal 9.0.2
Recovery steps:

I created a content type,

Inside it there is an entity reference field of paragraph.

Inside this paragraph there is an entity reference field which is also a paragraph.

For the first time when I save the contents of the fields of the inner paragraph the contents are saved in DB,

But in a second time update onwards the field changes are not saved.

There is no any error on the screen and without any error in the LOG files.

Can someone help me understand where am I wrong?


texts: How can I create a view which includes all parent terms of a taxonomy term?

texts:
I am creating a view which takes a tid as an argument. I then want to generate the full list of tids which includes the one directly referenced plus all those above it in its taxonomy.

How could I do this?


texts:
I would like to add a CSS class to fields in a view. The view in the screenshot takes the title, the summary, the date and the tags of articles that are published to the frontpage. I know how to add a class to the whole article in the GUI, but I want to add a class to fields on the article in the view.

I have made changes to existing CSS classes, but they appear on other parts of the site.


texts: How to remove View/edit option of a node in admin menu?

texts:
Drupal 7 node edit and view are showing in admin menu. How do I show it under node title?

Actually when the node is loading, the view edit options of the node is showing under the node title but when fully loaded, the view/edit options of that node is showing in the admin menu.
When I checked it with the firebug, it's under admin menu css.

How do I show the view/edit options under the node title?


texts: Clickable preview of a youtube video in a Lightbox?

texts:
So I have been trying for a month now to get a nice gallery view working. It's a view displaying items of a custom "Gallery element" content type, that can contain either an image or a youtube video.

I want to have my gallery displayed as a 4x3 grid of thumbnails, that you can click on and get a lightbox output of the media file, wether it is an image or a video.

I managed to get the images working using the Lightbox2 module, but somehow the youtube videos need a little bit more working... So far I haven't managed to even see these videos in a lightbox. Either only an unclickable thumbnail appears in the gallery, or the full sized video if I remove the "Youtube Preview Image" display from the manage file display panel of File types in the configuration.

I do have checked the "Enable video support" checkbox in the Lightbox2 configuration, yet I cannot seem to find a way to display a video in those! One thing I wonder, is why don't I get the same field format "Lightbox2" options as for images?


texts: How to override default theme to custom module path theme

texts:
Is it possible to create template file for custom module created page that override default page theme only when the path is visited?

The code i tried so far is displaying my custom module result inside default page theme content area. I want to display result in my self created template file content area. Is it possible?

function mymodule_menu(){
    $items = array();
    $items['mymodule'] = array(
        'title' => 'Mymodule title',
        'description' => 'Mymodule description',
        'page callback' => 'mymodule_page',
        'page arguments' => array(),
        'access callback' => TRUE,
        'type' => MENU_LOCAL_TASK,
    );
    return $items;
}

function mymodule_theme() {
    return array(
        'mymodule_theme_page' => array(
            'arguments' => array('mymodule' => NULL),
            'template' => 'page-mymodule',
            'path' => drupal_get_path('module', 'mymodule').'/template',
        )
    );
}

function mymodule_page(){
    $mymodule = array('key'=>'Hello World');

    $output = theme('mymodule_theme_page', $mymodule);
    return $output;
}


texts: Overwrite field description in an image widget

texts:
I have an image field (multiple).

In the node form, the ImageWiget has a process method that adds previews and form fields for images that have already been uploaded.

The description for the title tag is hard-coded on line 278: '#description' => t('The title is used as a tool tip when the user hovers the mouse over the image.'). We are actually showing the title as a caption and not a tooltip.

How can I override the description?


texts: Is there a fast way to see a site without the drupal admin elements?

texts:
Once in a while various Drupal elements can be a real pain:

The context menu covers the search menu & prevents me from clicking into the text field
A co-worker is worried that the user is seeing things like 'Available Updates' notifications
View/Edit tabs and action links are present in screenshots

The easy answer is to log out and view the page again, but that's a pain when you just want to do a very quick thing.

What is a quick, easy way to jump in/out of Drupal?


texts: Drupal 7, Faceted results from Search Form

texts:
I hope this is not a duplicate of something as I've been searching for hours and I'm pretty confused.

So what I need to do is to have a Search Form/Block like the one the core uses (I've already themed it so if I can use the same one would be splendid, if not, no problem), who's results will be organized in a faceted sort of way kinda like this:

Results:
All(100)
Cakes(43)
Wrappings(12)
Random Stuff(25)
Misc(25)

Cakes, Wrappings, Random Stuff and Misc would be Content Types, and clicking on them (links) should display in a view next to them the appropriate results (as thumbnails).

Since my Content isn't that much I'd like to avoid Solr if possible.

Any hints?

EDIT: In case this wasn't clear, the results are yielded according to given keywords, I don't want a simple sitemap.


texts: My view's 'more' link needs to go to a page with exposed filters already selected

texts:
I have a view that is a list of a certain content. The more link for the view needs to link to a page I have set up that has exposed filters for sorting the content.

So let's say the view I have is of baseball-related content. The more link will go to another page that contains all sports, but in this case it will link there but already have the baseball filter selected. Confused?

What I had been trying was to use the Custom URL field in the view, but no tokens can be used. Maybe this isn't even the right way to go about it. I'd love to know what is.

Any ideas?


texts:
On Drupal 8 there is by default a user_picture field for the user's photo. When I started my site several months ago, I deleted this field because I did not use it.

Today I need this field, so I created an image type field.

MY PROBLEM : I installed some modules that use the user's photo, but it can not be found because the user_picture is the default

If I create a user_picture field it automatically adds field_ in front of the machine name.

Is it possible to restore the default field with the correct machine name ?


texts:
I have read different SE posts and Drupal.org posts about applying patches using git but I am getting an error message whenever I try any of the following methods. the error is:

  error: modules/callbacks.inc: No such file or directory

I tried:

curl https://www.drupal.org/files/issues/op_update_should_be_create-2807275-2.patch | git apply -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   668  100   668    0     0   2278      0 --:--:-- --:--:-- --:--:--  2279
error: modules/callbacks.inc: No such file or directory

Also, I downloaded the patch into Drupal root and tried:

git apply -v op_update_should_be_create-2807275-2.patch

The backstory:
I was getting the following errors on my website, which I found this discussion explaining that it was because of Entity API, and I was trying to apply the patch in #2.

  Notice: Undefined property: stdClass::$custom in
  block_block_list_alter() (line 794 of
  /Applications/AMPPS/www/example/docroot/modules/block/block.module).
  Notice: Undefined property: stdClass::$visibility in
  block_block_list_alter() (line 807 of
  /Applications/AMPPS/www/example/docroot/modules/block/block.module).
  Notice: Undefined property: stdClass::$pages in
  block_block_list_alter() (line 817 of
  /Applications/AMPPS/www/example/docroot/modules/block/block.module).

This is my first time trying to apply a patch.


texts: How to add custom price for custom line items added using commerce customizable products?

texts:
I have created custom line items using "commerce customizable products" module by following the steps provided in this screencast. I want to add custom price for each added custom line item and it would be great if i could add/specify the price while creating that line item. Is there any way to do it? If not I will be glad to help to do so, All I need is proper guidance. This is a well known issue and solving it would be an awesome addition to this module.

Thank you in advance.


texts: Trying to use Replace to change the output of value on a view using custom text

texts:
I'm trying to figure out how I can replace underscores and a specific text using Replace on a Drupal 8 view custom text. In a template, I could use the following code to replace specific text.

{{ items.entity.getType|replace({'_': " ", "2": ""}) }}

what can I use on a view on custom text? I tried using {{ type|replace({'_': " ", "2": ""}) }} but it seems to show the text as plain text, not HTML markup.


texts: How do I remove a menu item on a module?

texts:
So there's the course module for Drupal, and I want to remove one of the form items, $form['course']['duration'].

It's setup like this.

$form['course']['duration'] = array(
    '#title' => t('Duration'),
    '#type' => 'textfield',
    '#description' => t('Length of time in seconds that a user can remain in the course. Leave blank for unlimited.<br/>For a better experience, install the !link module.', array('!link' => l('Time period', 'http://drupal.org/project/timeperiod'))),
  );

  if (module_exists('timeperiod')) {
    $form['course']['duration']['#type'] = 'timeperiod_select';
    $form['course']['duration']['#units'] = array(
      '86400' => array('max' => 30, 'step size' => 1),
      '3600' => array('max' => 24, 'step size' => 1),
      '60' => array('max' => 60, 'step size' => 1),
    );
    $form['course']['duration']['#description'] = t('Length of time that a user can remain in the course.');
  }

How could I remove this from the module? I don't want non-admin users to be able to modify this. I obviously don't want to hack the core of the module.

Would I just rewrite the function? Is there anyway to do this?


texts: No content types showing under 'Add content'

texts:
When I click "Add content," I get the following message:

  You have not created any content types yet. Go to the content type creation page to add a new content type.

However, under content types it lists all my content types (page, article, blog, etc). What could be causing this sort of miscommunication? The only change I made recently was moving the "Add content" link from one menu to another, but that shouldn't have affected the actual behaviour of node/add. (I did it using the admin interface as well; I didn't do any PHP editing of any sort.)

This is my recent log messages since the last content I added (edited out repeats and page not found errors):

cron    12/29/2011 - 13:02  Cron run completed. Anonymous (not verified)
php 12/29/2011 - 10:42  Notice: Undefined index: path in menu_edit_item...  admin
php 12/29/2011 - 10:42  Notice: Undefined index: path in menu_edit_item...  admin
user    12/29/2011 - 10:35  Session opened for admin.   admin
cron    12/29/2011 - 10:02  Cron run completed. Anonymous (not verified)
cron    12/29/2011 - 01:20  Cron run completed. Anonymous (not verified)
content 12/29/2011 - 00:37  page: updated Mentoring Program.    admin
content 12/29/2011 - 00:34  page: added Mentoring Program.  admin

Only change to any files was a small change to pages.tpl.php regarding rendering of page titles; and I haven't installed any modules since it last worked.


texts: Exposing New Vocabulary As Filter Drupal 7

texts:
If I create a new vocabulary with a few items (categories), how can I expose it as a filter on one of  my views?

To be more particular, I have an existing view with some filters already exposed. I would like to add a couple of new vocabularies to it as well as swap an existing vocabulary for a new one.

If it is relevant, I am currently using BEF (Better Exposed Filters) module to expose the current filters.


texts: Drupal 7 & OpenLayers - Can see sample map under OpenLayers Admin: Preview but NOT under Views: Preview

texts:
I'm stumped and seeking some direction.

I'm seeking to create a dynamic map using OpenLayers, Drupal 7, Views and Custom Content Type. I've read all the documentation I can find and so far I've been able to:

successfully create a content type (using "Geolocation Field" to
store geodata instead of GeoField),
create an OpenLayers Overlay in Views, and
create a custom map (clone of Google Map example) in OpenLayers Admin.

In OpenLayers Admin I can view the sample map ('MySample Map") under OpenLayers Admin: Maps: Edit Map: Preview.  This map successfully shows data points from content in the database.

However when I create a new View of format OpenLayer with style = MySample Map nothing shows - no datapoints and no map, only the title.

Any recommendations for debugging/resolving this problem?  Thanks in advance.


texts: How can I adjust the css within fusion theme based on the size of the screen?

texts:
I'm using the Fusion theme for its responsive components but there are some things I want to tweak on the different layouts based on the screen size of the device viewing.

How can I apply style changes to say the phone layout, but not change the desktop and tablet layouts?

As a working example, lets say I wanted to accomplish the following:

/* Desktop + Tablet */
h1 {
  color: red;
}

/* Phones */
h1 {
  color: blue;
}

Are there selectors I should be using to accomplish this type of fine tuning?


texts: How do I alter the output of a field using a views handler

texts:
Currently I'm uning Views PHP to reformat some fields in a view. in the documentation of views it says

  While this module allows you to directly use PHP inside views which may be useful for quick and easy solutions, it is highly advisable to use regular handlers and plugins when available (or even to create one yourself).

In my particular use case, I'm trying to re-format the output of a field that is being loaded by relationship. How would I create a views handler, or a views plugin that does this?


texts: Is it possible to disable cache on certain fields?

texts:
I am working on a site where i'm implementing my own cookie bar module.
For this module i have made it possible to write something in the CKeditor like:

Where everything between the {cookie} tags is only visible when cookies are accepted. This works fine on my dev environment, but when I deployed it to the test server where cache is enabled it won't show any change when you enable/disable cookies because the page is already cached.

Is there a way to disable cache on the text field or better yet, everything between the cookie tag?


texts:
In Drupal 7, I have a content type with revisioning turned on.

Is it possible to create a view that shows only nodes that have had the title changed?

Newest Title | Previous Title | Updated Date


texts: Fatal error: Call to a member function extractFormValues() : Drupal 8 beta 14

texts:
I created a module with Drupal 8 beta11 which defines an content entity and a form (contentEntityForm) with custom submit callback.When I tried using the same module with Drupal 8 beta 14 it raise the following error.

  Fatal error: Call to a member function extractFormValues() on null in C:\xampp\htdocs\drupalbeta14\core\lib\Drupal\Core\Entity\ContentEntityForm.php on line 219

Form definition are like this:

public function buildForm(array $form, FormStateInterface $form_state) {

        $form['employee']['first_name'] = array(
            '#type' => 'textfield',
            '#title' => 'First Name',
        '#required' => true,

        );
     $form['employee']['last_name'] = array(
            '#type' => 'textfield',
            '#title' => 'Last Name',
        '#required' => true,

        );
  $form['submit'] = array(
        '#type' => 'submit',
        '#value' => 'Submit',
        '#name' => 'employee-data',
        '#submit' => array('::submitEmployeeData')

    );
return $form
}
// callback

public function submitEmployeeData(array $form, FormStateInterface $form_state){
     /some code here
}

After form submission it raises the error mentioned above.

I checked the contentEntityForm.php also on both beta11 and beta 14 and seems to have similar function definition for extractFormValues() function.


texts: Associating a user with a particular form submit/click

texts:
In my web site i have created a custom content type Challenge which contains a list of tasks that the user has to do. I have created the custom content type from the CMS itself through admin/structure/content type. I have created a custom form, , and when the user clicks submit i have made a query which insures that the node id of that challenge and the user id is associated in a Challenge table (the code is below). It works fine. Now i need to create a view which shows the challenges accepted by the user, i.e., when the user logs in and clicks on a tab(i am using quicktab) then a view appears which shows the challenges undertaken by the user. Here my code for the query:

function my_module_menu() {
  $items = array();
  $items['my_module/form'] = array(
    'title' => t('My form'),
    'page callback' => 'my_module_form',
    'access arguments' => array('access content'),
    'description' => t('My form'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function my_module_my_form($form_state) {

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Accept Challenge',
    '#submit' => array('my_module_action'),
    );

  return $form;
}

function my_module_action($form, &$form_state) {

 if ($node = menu_get_object()) {
  // Get the nid
   $nid = $node->nid;
    }
 global $user;
 if ( $user->uid ) {
 $query = db_insert('challenges')
    ->fields(array(
    'cid' =>$node->nid,
    'uid' => $user->uid
    ))
    ->execute();
}

Well, thats it then. Now how do i create a view to show a user their accepted challenge.

Thanks


texts: Disable autofill username & password on drupal

texts: How can tell the browser not to save drupal usrrname and password? I am newbie. So having difficulty understand many functions. Any easy way to configure drupal for this? Thanks


texts: How to completely disable 'further instructions sent to email' message after sign up

texts:
How to completely turn off/remove message 'Further instructions have been sent to your e-mail address.' that appears after registration? I'm using logintobogan module and I can see some customization than can be made to registration confirmation page, but none of these settings direct this particular message. It appears every time, also if I use redirection to completely custom thank you page?

Any idea?


texts: X-Frame-Options and Strict-Transport-Security are prohbiting me from uploading any images via ajax error due to self signed cert (on a dev box)

texts:
When trying to upload an image in a Node Edit form, I'm getting an Ajax error in the main browser window. The browser console is displaying complaints surrounding Strict Transport and X-Frame options.

  Strict-Transport-Security: The connection to the site is
  untrustworthy, so the specified header was ignored.[Learn More]
  form-VHZcgnXwba2plRQ9nE0JQPqgblsvmrgYHtOtCywfYmo

And

  Load denied by
  X-Frame-Options:
  https://server.ext/file/ajax/field_module_images/und/0/form-VHZcgnXwba2plRQ9nE0JQPqgblsvmrgYHtOtCywfYmo
  does not permit framing

We're I'm at now:
I've followed guildlines in Securing file permissions and ownership. I've not run into this issue with other sites. The only difference in this site and others we run is that this is our first on RHEL 7.  I've read other reports about playing with jQuery Update with little luck.

Potential issue:
Could this be because I'm on a dev server with a self signed certificate?

What I've tried:

I've tried adding the follwing inside /etc/httpd/conf.d/Xframe.conf

<Location /var/www/html>
        Header always append X-Frame-Options SAMEORIGIN
</Location>

This seems to have had to impact after a service restart.


texts: How to use templates of existing sub theme into new theme?

texts: I have Adaptive Theme in my Drupal Site, also some custom template. How can I use Existing template into my new theme (i.e. Bootstrap Theme)?


texts:
Setting up a view and displaying it as a reference method for an entity reference field is pretty straight forward in D8. (a very good tutorial in case anyone needs)

In a few easy steps you can configure the few to your liking with search fields and inline fields. In my case it is a content view and the sample output I get in the views configuration page is:

Title / Field1 / Field2

which is perfectly how it should look like.

The problem is, in content form, I only get the Title listed. The search fields work very well but only the title is displayed in the entity reference field option list. I tried Select list (Chosen enabled or not), Autocomplete, Checkboxes/radio buttons. Also tried to rewrite results on various fields.

What am I missing here?


texts:
What does dynamic permission mean, in Drupal 8?
When should I use this?


texts:
I am using drupal 7, I want to add users having role 'R' to a OG group 'G'.

Is it possible to do that?


texts: AWS RDS and Multiple Database Installation

texts:
Does anyone have experience with setting up a Drupal Multi-Site with multiple Databases onto one RDS instance in AWS?

I was looking into this link below but I was not familiar with the exact formatting: https://www.drupal.org/node/18429

Here is my format:

$databases = array (
'default' =>  // main drupal db starts from here
array (
'default' =>
array (
  'database' => 'PubDB',
  'username' => 'PubUser',
  'password' => 'PASSWORD',
  'host' => 'pubtest.amazonaws.com',
  'port' => '3306',
  'driver' => 'mysql',
  'prefix' => '',
),
),'careers' =>  // additional database starts here
array (
'default' =>
array (
  'database' => 'careers', // additional database name
  'username' => 'PubUser', // additional database username
  'password' => 'PASSWORD', // additional database password
  'host' => 'pubtest.amazonaws.com',
  'port' => '3306',
  'driver' => 'sql', //the file is in sql format
  'prefix' => '',
)
),
);

And on my database.inc file I have:

function db_set_active($key = 'careers') {
return Database::setActiveConnection($key);
}
db_set_active();


texts: How and when are commerce licenses created, and when does the state change to "active"?

texts:
I'm working on a module that attempts to tie commerce_license in with the ACL (Access Control Lists) module.

I am attempting to sell access to an individual node. I have a product type, product, and product display which does this. I have a node reference field which allows an admin to select which node to license on product creation, and this reference field is being correctly referenced in my license class (the one in plugins/license_type/ which extends CommerceLicenseBase).

In my save() function, I'm checking to see if the status is COMMERCE_LICENSE_ACTIVE before I add the license owner to the acl, but it appears that the license never gets in this state. I have gone through the checkout process, and even manually completed the order, but I don't ever see the license get to the "active" state.

I've also noticed that the license seems to be created (the save() function is called) when a product that is associated with a license is added to the cart, and NOT on checkout, as is stated in the documentation.

I think the real issue is in my lack of understanding of how the commerce license module works (and possibly how the ACL module works, but that's a different discussion). I've read through the documentation, watched a few tutorials, and looked through the example code, the commerce_license_role module, as well as the commerce_license_og and commerce_file modules, and I'm still not sure what I'm doing wrong - I'm beginning to suspect that my error is not in the code itself, but rather in configuration.

Here is my code:

<?php

  public function save() {

    if ($this->uid && $this->product_id) {

      // Get the entity referenced
      // (this works fine - field is defined in the .module file)
      $node = $this->wrapper->product->commerce_license_acl_node->value();
      $acl_name = 'ACL_' . $this->product_id . '_' . $node->nid;

      // Get the acl associated with this node and product ID
      $acl_id = acl_get_id_by_name('commerce_license_acl', $acl_name);

      // If the ACL doesn't already exist, create it
      if(empty($acl_id)){

        // Create ACL if one is not already associated with this license
        $acl_id = acl_create_acl('commerce_license_acl', $acl_name);

        // Grant ACL users read access to this node
        $read   = TRUE;
        $update = FALSE;
        $delete = FALSE;
        acl_node_add_acl($nid, $acl_id, $read, $update, $delete, 0);

      }

      $owner = $this->wrapper->owner->value();

      // I realize a lot of this is redundant. I'm covering all the cases here for my benefit
      // in trying to understand what is going on.
      switch($this->status){
        case COMMERCE_LICENSE_ACTIVE:
          // *** This case is never true
          acl_add_user($acl_id, $owner->uid);
          drupal_set_message('license_acl set to active');
          break;
        case COMMERCE_LICENSE_CREATED:
          // **** This is the state that it always seems to be in
          drupal_set_message('license_acl created');
          break;
        case COMMERCE_LICENSE_PENDING:
           drupal_set_message('license_acl set to pending');
         break;
        case COMMERCE_LICENSE_EXPIRED:
          acl_remove_user($acl_id, $owner->uid);
          drupal_set_message('license_acl set to expired');
          break;
        case COMMERCE_LICENSE_SUSPENDED:
          acl_remove_user($acl_id, $owner->uid);
          drupal_set_message('license_acl set to suspended');
          break;
        case COMMERCE_LICENSE_REVOKED:
          acl_remove_user($acl_id, $owner->uid);
          drupal_set_message('license_acl set to revoked');
          break;

    }

    parent::save();

  }
  ?>

Is there any documentation out there which goes into depth explaining the workflow of commerce license creation and statuses? Thanks in advance.


texts: Searching for a user details (including custom fields) in People Administration Page

texts:
I want to search people on my people page in admin. I searched around and found this great plugin :-

User search to People Admin - This helps me search user through their email, usernames perfectly.

The only problem is that I want to search users through additional User fields I added later into the admin. As an example, each person has a Full Name as a custom field but this module is unable to search through it.

Any idea how I can achieve that?

Thanks


texts: How to make text responsive inside a WYSIWYG editor?

texts:
I have some node fields(text areas with WYSIWYG) presented as tabs(using Panels and Panel tabs).
What I want is the text that is inside the WYSIWYG editor to be responsive like the tabs.How can I make this?
thanks


texts: How do I enable modules in a Simpletest-Selenium test (Selenium module)?

texts:
I am using the Selenium module for Drupal, which is integrated with SimpleTest.

One thing I have not been able to do is to enable modules for the test cases. I am able to enable them on SimpleTest tests (using setUp()).

How do I enable modules in the Selenium Tests?


texts: How can you price attribute options in drupal commerce properly?

texts:
Currently I am creating a site for a repair shop. Say I am repairing a laptop motherboard:

Motherboard Repair = $100

As with a motherboard repair, it could consist of a power slot repair, cpu replacement, memory replacement, or video card replacement. I charge $100 for any of those repairs, but I consider them as a Motherboard repair. I want to create a page where they can select one of those, but not create a SKU for it. How can this be done?

In Ubercart, it would just be 1 product and 1 attribute with those 4 options. Since they aren't tangible products they don't need an SKU. Its more of a reference for the business owner to know what to repair which is selected by the customer on checkout.

Now say if I did have varying prices for each of those options. How can that be done too?


texts: How do I create and call a custom named function?

texts:
Brand new to Drupal and I need to figure out how to create a custom function and call the custom function in the twig file.
I need to build a news releases function that reads a directory and pulls the PDF files for a corresponding year. (This should be easy enough in PHP.)
The missing key is where and how to create a custom function and how to call this custom function in the template file.
A few hours of searching lead me to create this.
<MY_CUSTOM_THEME_NAME>.theme
function <MY_CUSTOM_THEME_NAME>_preprocess(&$variables, $hook) {
  $x = "hello world";
  $variables['helloworld'] = $x;
}

news-releases.html.twig

{{ helloworld }}

Lorem ipsum...

Result

hello world

Sifting through all the searches and YouTube videos, nobody has explained or shown documentation for Drupal 9 on how to create a custom named function. Is this even possible?
This is the desired result.
Any file
function hello_world($year) {
  $directory = "/news/releases/" . $year;
  $scan_directory = array_diff(scandir($directory), array('..', '.'));
}

Any template file

  {% for newsrelease in newsreleases %}

{{ newsrelease }}

  {% endfor %}

I am not sure on how I can pass a variable back into the custom function so the correct directory will be scanned. Not sure if I would have to just create 5 separate functions for each year and call the correct year like the twig snippet.
I've been googling "Drupal 9 custom modules" and dug up nothing to further my quest. If the answer does happen to be "create a custom module" then how do I include the custom module as apart of my existing custom theme?
I am using Drupal 9.1.x and I have read https://api.drupal.org/api/drupal/core%21core.api.php/group/hooks/9.1.x already.


texts: Drupal 6 - Using node_view and display comments

texts:
i'm using node_view to print nodes in a custom page. But the problem is that i need also the comments and the form comment to be shown under the node view.

How can i achieve this?


texts: How can I show 4 latest articles in ascending order?

texts:
Lets say I have 10 articles, tenth being the last one created.
I want my view block to show 4 latest articles, but in ASCENDING order.

7,8,9,10 - something like this.

Can I somehow filter out the exact number of latest articles?


texts: List outline of books related to another book by a node reference field

texts:
I am using the book module with four content types: A, B,C and D.

A is the content type for child pages and the rest are allowed in book outlines.

I also have a node reference field in A that allows users to select nodes of type A related to the one they are creating.

I am trying to use views to display all the nodes that are related to a certain type A node and also display the outline of these related nodes.

E.g. viewing Book A.1 related topics and their outline:

Book A.1

Book A.2

Page A.2.1
Page A.2.2

Book A.3

Page A.3.1
Page B.3.2
Page C.2.2

I have gotten as far as displaying all the related nodes to a certain node but I am not being able to display their outline.

Any help/critics appreciated.


texts: Turkmenistan Manat is missing from Drupal Commerce list - how to add it to 7.x?


texts: Webform 4.10 Does Not Support 'Excel' Format

texts: I recently installed (Webform 7.x-4.10) to my Drupal site. It works fine but it doesn't have Microsoft Excel as Export format. The only option available is Delimited text (*.tsv), & it doesn't fit my requirements. So, I need back the MS Excel format.


texts:
I installed Drush with Composer and I get well the Drush version.
drush cache-clear drush works too, but drush webform-libraries-make returns me the following error.

  The drush command 'webform-libraries-make' could not be found.
  Run drush cache-clear drush to clear the command file cache if you have installed new extensions.
  Drush was not able to start (bootstrap) the Drupal database.
  Hint: This may occur when Drush is trying to:

  bootstrap a site that has not been installed or does not have a configured database. In this case you can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command line. See drush topic docs-aliases for details.
  connect the database through a socket. The socket file may be
  wrong or the php-cli may have no access to it in a jailed shell. See
  http://drupal.org/node/1428638 for details.

  Drush was attempting to connect to:

Drupal version         :  8.4.1
Site URI               :  http://default
Database driver        :  mysql
Database hostname      :  127.0.0.1
Database port          :  3306
Database username      :  root
Database name          :  fta
PHP configuration      :  C:\wamp64\bin\php\php7.0.10\php.ini
PHP OS                 :  WINNT
Drush script           :  C:/Users/s.guyennon/AppData/Roaming/Composer/vendor/drush/drush/drush.php
Drush version          :  8.1.15
Drush temp directory   :  C:\Users\SCF60~1.GUY\AppData\Local\Temp
Drush configuration    :
Drush alias files      :
Drupal root            :  C:\wamp64\www\fta
Drupal Settings File   :  sites/default/settings.php
Site path              :  sites/default
Sync config path       :  sites/default/files/config_W7qQCKUh0SQJFJycX-Sl2-8Z4HSD33GszbC2yt0gl7Zi1KnhgtWfXBy4SYyOCWKImrhB7xVSpQ/sync


texts: Redirect to login page if login block fails

texts: If you fail to log in correctly from a login block, I would like the user to be directed to the login page to log in from there.  How can this be accomplished?


texts:
I've been searching all morning and cannot find the solution I need. I am sure I am overlooking something.

I want to disable the quick links menu on each block on my drupal 7.23 site when I'm logged in as an Administrator. I don't use them, and they are blocking the links on some small blocks.

How do I turn these off?

Thanks,
Brian


texts: Most user friendly way to organise this content?

texts:
We're trying to work out how best to organise this content: https://international.permaculture.org.uk/for-organisations

It should be one column layout but with text and image aligned next to each other which will then be responsive (i.e. image moves to below paragraph associated with it)

It was suggested that the responsiveness could be detailed in within the text editor source for each pane, by giving the text and image separate div tags and assigning them some css, but I think the administrators who are going to use these sites would not feel happy with that approach.

I am wondering if using Nodequeue module is a good idea? Or if there is another way? Content order needs to be felxible so I don't think using a view is best way.


texts: How to limit form submission per user per day and week?

texts:
The goal is very straightforward. I need a form to limit each user to 1 submission per day and 3 per week.

What I found:

Webform:
The "Form settings" in webform has the "Per user submission limit" setting. It does not allow me to make more than 1 validation. I'm not able to have both per day and per week in the same form.

Entityform:
I found people use hook function on node limit on Drupal 8. This may work on Drupal 7 Entityform but I don't know how to write that syntax.

Rule:
It may possible to use Rule module but I don't see any connection with period of time validation.

//////
PS: My question is about the limit on Webform(or Entityform) submission for authenticated users.


texts: Group Module: Join & Remove users from user account/profile 2?

texts:
I added an entityreference to the user's Account so users can select what group they want to join (checkboxes). They check it and via a rule, it automatically adds them to that group. I did this for multiple Group Types.

Now i need it to remove user (unsubscribe) from group if "unchecked". Right now users keep on getting added if they select a new checkbox, but they are not removed from the previous group.

How can the we remove them from the now unchecked group and add them to the newly checked rule?

I found how to delete all group subscriptions on one rule. However, it removes all subscriptions, even those not found in this entityreference. How can we limit to add/remove users from only these group types?

Willing to pay for support on this issue.

Thank you.


texts:
My guess is that many ppl like me make Drupal websites just by using modules and simple CSS. Several content types, taxonomies, views, panels or DS to get results fast and more/less nice looking. Maybe add forum to all that.

When it comes to caching there are many options and i have no idea which ones to use. All my websites are on shared hosting (most popular ones).

In "performance" i always enable everything.
Minimum cache lifetime and expiration of cached pages are options i always gaze at for several minutes and in the end choose "1 day". No idea if thats good.
All other check boxes are clicked of course.

Views 3 are cached by default, nice, if i remember good i had to enable that in previous versions.

Now the fun part is picking modules from drupal.org for caching.

On this page Caching: Modules that make Drupal scale (updated 2014-07-09) we have 15 modules for D7. How many to use ? Which ones are "best" ? Which one you reccomend for shared hosting ? Should i for example disable default caching in performance and in views if i use those ?

So the final question would be: For nondevelopers who use shared hosting, what are the easiest/best modules - plugnplay.


texts: I have a list of email addresses that I would like not be able to submit in webforms. I can't seem to find a setting for this? Is this currently possible or do I need to make a custom module to implement this?


texts: View shows duplicate records when the article has multiple images

texts:
In my article content type, I set the image filed as multiple images. However when I try to use the view to display the content. The article with one image will be displayed only one, but the article with multiple images will be displayed more than once.

For example, I have a article with 2 images, then in the view, this article will be load twice, these 2 article are the same except the image is different

it is a wired problem, in the view I even set the Distinct in the Query settings, but it doesn't work out


texts: Navigate to next page / previous page based on entity reference field instead of Book module

texts:
I am trying to create next/previous page links like the Book module.

I have two content types, Chapter and Page.

The Chapter content type contains an entity reference field (unlimited) for pages.

So, each chapter contains an arbitrary number of pages in the entity reference field Pages in Chapter, and these are re-ordered to determine the order of the pages.

Now, on each Page, I want to make links to the previous and next pages based on the values of the parent Chapter's entity reference field Pages in Chapter.

Specifically, using a view or block or similar on the Page, I need to get the Chapter that references the current Page, iterate through the values of the entity reference field Pages in Chapter, find the Page that is immediately before and the Page that is immediately after the current Page, and then output this as a simple unordered list.

I can code a little but I'm not very good so I'm having trouble finding an approach to implement this.

What I tried

I tried to build this in Views.  The problem I encountered was that it is very difficult to iterate through the subdivision entity reference field and filter out the previous and next links.

This is a similar question for Drupal 7 but since Drupal 8 includes so much more in core (Views and Entity References, for example), I think it's fair to ask the question again.

Why not just use the Book module?

I only need the next/previous page functionality, and ideally it would be based on my entity reference field Pages in Chapter.  The book module navigation in Drupal 8 doesn't follow the same patterns as the rest of core (it's not a block, and it's not a menu).  I spent a couple hours this afternoon going through the Book issue queue and cleaning up old issues, and it seemed there is very little effort to "modernize" the module, so I thought it would be better to try to implement this feature on my own.


texts: Drupal 7 CKEditor-CKFinder remove "Browse Server"

texts:
I have a multi-domain site setup with domain access module. In each domain users are allowed to post their own contents with media upload settings. I am using CKEditor and CKFinder together.

Now, I want to disable the "Browse Server" Button but the local Browse button will be there.

I am unable to find the settings(which I think not in Drupal admin) or the code to edit to fixup this.
https://stackoverflow.com/questions/3610041/ckeditor-with-ckfinder-disable-filebrowser-keep-upload-functionality
This one didn't helped my either.
Any help on this?


texts:
Shouldn't the form generating function get executed every time the form is rendered? Because I need to update some field suffixes based on the $form_state values and I don't know how to do this.

I have something like this:

function xxxx_some_form($form, &$form_state){
  $form["some_field"] = array(
    "#type" => "textfield",
    "#required" => true,
    // bla bla bla
  );
  drupal_set_message("whatever");
  $form["actions"]["do_action"] = array(
    "#type" => "submit",
    "#value" => t("Do action"),
  );
  return $form;
}

When I submit the form, the validation messages are displayed ( Eg: X field is required ) but the message from drupal_set_message("whatever") is not displayed.

Also, no other logic is executed there.


texts: How to setup 'headers' cache context by value?

texts:
I try to set a headers cache context (/core/lib/Drupal/Core/Cache/Context/HeadersCacheContext.php) by the value of a custom HTTP header.

My web server sends a custom HTTP header X-My-Custom-Header. Its value can be foo or bar. I want to cache the page for both variants. As I understand the documentation right, that should work with Drupal's headers cache context.

I set the cache context in the preprocess hook:

function mymodule_preprocess_html(array &$variables) {
  $variables['#cache']['contexts'][] = 'headers:X-My-Custom-Header';
}

The cache context is set correctly: [headers:X-My-Custom-Header]=foo

But if the value of the custom HTTP header changes to bar, the page is still loaded from cache. In my opinion Drupal should render the page and add it to the cache with context [headers:X-My-Custom-Header]=bar

How to set this up correctly?

Thanks for you suggestions or answers! :)


texts: Why are my search results not showing when I input any body text?

texts:
Why my search result not showing when I input any body text ?

Are search results based on node title only?

I am creating a multilingual site with French and English languages.

Users should be able to search results by entering any text of a node whether its body text, taxonomy, subtitle and so on.


texts:
I have a view with arguments in the page and attachment displays.

When I go to the view page, I see a list of arguments (links) because in "Action to take if argument is not present" I selected  "Summary, sorted ascending."

How do I sort arguments (in this case is term) by weight? I don't see any option to do this. Where can I change the query "ORDER BY term ASC" to "ORDER BY weight ASC" in code?

When I click an argument, I have another page with a list of arguments again, because I have an attachment. How do I only show the argument name I have clicked?


texts: how to check if the image field is empty or have uploaded image?

texts:
<?php
  $nid = arg(1);
  $path = arg(0);
  $node = node_load($nid);
  if(isset($nid) && is_numeric($nid) && isset($path) && $path == 'node' && isset($node) && $node->type == 'page') {
    $theme_img = file_create_url($node->field_page_cover_image[$node->language][0]['uri']); //origional image path
    if($theme_img) {
        //image having style
        print theme('image_style', array('path' => $node->field_page_cover_image[$node->language][0]['uri'], 'style_name' => 'page_theme'));
    }
   }
?>

I've loaded the above code in page.tpl.php. It is to load the uploaded styled image from individual pages.
I am getting error in line no. 6 ($theme_img), for pages which have empty image field. It is working fine in pages which have image uploaded. How to know if this field is empty or have image uploaded.


texts: Using drupal behaviors for a Bootstrap carousel

texts:
I created a custom front page using page--front.tpl.php, and I added a Bootstrap carousel on it which works fine, but the javascript I have (carou.js which is in mysubtheme'/js/carou.js') is not called. This is the Drupal behavior code.

(function ($) {
Drupal.behaviors.carou = {
    attach: function(context, settings) {
        $('#myCarousel').carousel({
            pause: false,
            interval: 3000,
        });
    }
}
})(jQuery);

I added it using the following code in the template.php file.

function bootstrap_subtheme_preprocess_page($vars) {
  if (drupal_is_front_page()) {
     drupal_add_css(drupal_get_path('theme', 'bootstrap_subtheme') . "/css/frontpage.css");
   //adding carou.js to front page
     drupal_add_js(drupal_get_path('theme', 'bootstrap_subtheme') . '/js/carou.js', 'file');
   }
}

I want to control the carousel options of pause: false interval:3000 but I was not able to do so. This makes me think the JavaScript code is not being called, and I don't know what is not right in the code. I am not also very well versed with Drupal behaviors.

What is wrong in my code?


texts:
I have installed HybridAuth module. I can login from my website using LinkedIn. But my question is, how can I login automatically into LinkedIn when I login from my website using LinkedIn login?

I have gone though various APIs but could not get proper information.


texts: Form Alter: How to check if a node has a Field Type

texts:
My module provides a field. In hook_form_alter() I need to change only those nodes that have this field set up. (I can't operate use hook_field_form_alter() because it does operates changes for other things than my own field.)

How can check if my field belongs to the node?
Is there an easy function to check if the field type exists in $form?

Otherwise, if I need to look at $form the problem is that I can't know the machine name used for the field by the admin/drupal as it looks like something like $form['my_field_namedbyuser'].


texts:
I am trying to create a header block that I can use for multiple page.tpl.php files so I created a new block, set it to be displayed in the header region and copied the HTML from my non-drupal version of the site.

Muse

     <?php
        if ($main_menu){
            print theme('links__system_main_menu', array(
              'links' => $main_menu,
              'attributes' => array(
                'class' => array('registerLnk'),
              )
            )); //#main-menu -->
            }
        ?>

However drupal stripes out all of my divs and classes and replaces them with a bunch of crap I didn't ask it to add.

Header

  Configure

      Configure block

Muse

As you can see the code that drupal outputs is nothing like the code I told it to output, and therefor does not render even close to correctly. How do I make drupal do what I told it to and render the html I provided instead of that crap it's rendering?


texts: I want to save and view the node content in the same page without page refresh using content types

texts:
I have to create content type as CELL. CELL content type have some fields. I want to show the fields in the node create page.

How to save the data without page refresh. How to view the saved content also using views. Anyone guide to me?

I have created it cell view block and show to only node/add/cell page.

But i want to save the data without page refresh and also get the data from db without page refresh. Please anyone guide to me.

Thanks in advance.


texts:
Presuming I have zen-7.x-3.x + a sub-theme, how do I go about uprading to zen-7.x-5.x? Perhaps using drush?

I am in awe of the people who wrote these pages:

https://www.drupal.org/node/219527
https://www.drupal.org/node/1588244


texts: How to show specific rows within an unlimited field group?

texts:
I am trying to assign value to unlimited field group on load of content using form alter hook. Value get assign successfully for all rows. But when form get loaded it display only one row. On click of "Add Another Item", it display second row with value assigned in form alter hook.

Is there any way to display number of rows as required? Can I handle this in form alter hook?


texts: How can I notify an admin when a user is contacted?

texts: On my Drupal 7 site, I have a user contact form.  How can I alter the form so that an admin is notified when the form is submitted?


texts: How do I check if the form is an add/edit/delete form?

texts:
I need to check if the form is for creating, editing, or deleting a node.

Currently, the below snippet allows me to check if the form is for adding or editing a node. How do I check if the form is for deleting a node?

    if (!isset($node->nid) || isset($node->is_new)) {
      // The form is for creating a new node.
    }
    else {
      // The form is for editing the node.
    }


texts: Migrate date time field using migrate source csv

texts:
I am trying to migrate a datetime field from csv file but only few are being migrating and other are being failed.I am using migrate
I have created two datetime fields called as Activation Date and Expiry Date in article content type. Attached field type images for reference.
I am writing a custom migration yml file to migrate data from csv file. But only the date values from id 6-10 are being imported but not the date values from 1-5 .
While import I am getting error stating article_csv_import Migration - 5 failed.
I have included sample data and yml file for reference.
Can anyone please let me know what causing the first 5 dates import failing ? Any pointers for a way to debug migration process is greatly appreciated.
migration_examples/migrations/article_csv_import.yml
id: article_csv_import
label: Import Articles
migration_group: default
migration_tags:
  - Article CSV Migration

source:
  plugin: 'csv'
  # Full path to the file.
  path: public://subscription-list-small-copy.csv
  # Column delimiter. Comma (,) by default.
  delimiter: ','
  enclosure: '"'
  header_offset: 0
  ids:
    - id
  fields:
    0:
      name: id
      label: 'Id'
    1:
      name: title
      label: 'Title'
    2:
      name: body
      label: 'Post body'
    3:
      name: field_activation_date
      label: 'Activation Date'
    4:
      name: field_expiry_date
      label: 'Expiry Date'
process:
  title: title
  body: body
  #activation date of the account.
  field_activation_date:
    -
      plugin: format_date
      from_format: Y-m-d H:i:s
      to_format: 'Y-m-d\TH:i:s'
      from_timezone: 'America/Managua'
      to_timezone: 'UTC'
      source: field_activation_date
  # expiry date of the account.
  field_expiry_date:
    -
      plugin: format_date
      from_format: Y-m-d H:i:s
      to_format: 'Y-m-d\TH:i:s'
      from_timezone: 'America/Managua'
      to_timezone: 'UTC'
      source: field_expiry_date
  type:
    plugin: default_value
    default_value: article

destination:
  plugin: entity:node

Sample CSV Data : subscription-list-small-copy.csv
id,title,body,field_activation_date,field_expiry_date
1,Title 1,Body 1,2012-12-22 2:36:03,2013-01-03 0:00:00
2,Title 2,Body 2,2013-08-16 0:00:00,2013-09-15 0:00:00
3,Title 3,Body 3,2013-09-14 0:00:00,2013-10-14 0:00:00
4,Title 4,Body 4,2014-04-08 0:00:00,2014-04-07 23:59:59
5,Title 5,Body 5,2014-09-30 0:00:00,2015-03-29 11:00:00
6,Title 6,Body 6,2014-12-09 12:29:00,2015-01-09 12:29:00
7,Title 7,Body 7,2014-12-31 11:08:00,2015-06-26 23:59:59
8,Title 8,Body 8,2015-02-25 19:12:00,2015-08-10 23:59:59
9,Title 9,Body 9,2015-03-01 11:19:00,2015-02-28 23:59:59
10,Title 10,Body 10,2015-03-02 18:01:00,2015-08-20 23:59:59

image-1 image-2


texts: Alter menu structure when using Superfish menu

texts:
I am using Superfish menus. I wanted to add a  tag before each  tag for menu links. I tried the following code:

function mytheme_menu_link($variables) {
    $element = $variables['element'];
    $sub_menu = '';
    if (empty($element['localized_options'])) {
        $element['localized_options'] = array();
    }
    $element['localized_options']['html'] = TRUE; //let l function know that our link title includes html
    $output = l($element['#title'], $element['#href'], $element['#localized_options']);
    return '
' . $output . "
\n";
}

but it did not take any effect. Since I am using Superfish menus do I need to write any other code?


texts:
We've setup that english language points to an english domain, and for spanish we have a language.

The spanish one is simply a symlink to the english code base. When translating nodes, I am being redirected to the Spanish domain when changing a spanish node, and have to login on that domain to be able to work.

How can I make sure; that either I'm logged in, or that I can stay on the same domain when editing content?


texts:
I am moving my site from Ubercart to Commerce. I currently have some products set up with attributes that can be selected by a customer, please see this URL for an example http://www.wild-sage.co.uk/products/soap-box

How would I go about setting this up using Commerce?


texts: Use single values added by field-collection module in Views?

texts:
I've already found this question, but it doesn't really help me out, maybe I just don't understand it (I've got the latest version of the module). How to integrate Field collection module in Views?

I have my own content type called "Gallery", for this, I created a field-collection which consists of an image and caption. Now I try to create my own view, first one, only to show the thumbs, and then one, showing the big image and the caption.

But how can I access only one field of the field-collection? I can find this field:
Content: Gallery and caption
or this one:
Content: Gallery and caption:delta (Gallery and caption (field_gallery_and_caption:delta))

but how do I access only the image field? and which type of display should I select?


texts: non admin can't view 'rewrite results' in lightbox

texts:
I created a view to display thumbnails and what i'm trying to accomplish is:

when you click on the thumbnail, it opens the node content in lightbox. I get it to work perfectly when i'm logged in as admin, but as soon as I logout and click on the image thumbnail, lightbox opens, but it's blank white. If i inspect the lightbox, the content isn't being pulled in for some reason (but it's only when i'm logged out as admin). permissions are set for anonymous users to see content. odd thing is...if i just linkthe image to a larger image using imagecache and lightbox, anonymous users can see it just fine. it's the rewrite results that they can't see. It's driving me crazy. i can't find any answers online anywhere that would cause this.. i'm using D7

Any ideas?


texts: Node Update not showing to anonymous user even after clear cache

texts:
I have a live site , when i update any node, it is not reflected for anonymous user.Even I clear the cache.This domain has SSL certification but we use it only for few pages.But if we use https for the updated content for anonymous user, It show the updated content.
  We have used cache for bloack and anonymous user and minimum cache lifetime and cache expiration is 1 hour.


texts: How to restrict node access based on user roles?

texts:
How can I allow only specific nodes to be displayed based on user roles?

Basically, I do not want to allow nodes to be accessed by users of some specific role.


texts: How predefine templates for webform email templates?

texts: I need to have a bunch of different webform e-mail templates with different text - how do I create those with code in Drupal 7?


texts: How can I have a custom module checked for deprecated functions?

texts:
I created a custom module in Drupal 8 for a specific purpose.

How can I find out if it contains any deprecated functions?


texts: Views automatically adds = inside link when output as link

texts:
I am trying to create a view of the latest posts from a vbulletin forum through external.php.

As external.php can publish both in RSS and XML format, I have installed views_xml_backend in order to show a view of the content.

it works perfectly when the link is shown as normal text and if you copy the URL into your browser it would redirect to the latest post of the thread.
Example:
http://foo.com/showthread.php?topic-name&goto=newpost

However, when i want to parse the result as a link it automatically inserts a = right before  &, which means that the link does not work.
So the  looks like this:
link text

I have tried in so many ways to fix this, but i have no idea what to do.
Perhaps a small snippet could do it?

Modules:
views 3x-3.10
views_xml_backend 7x-1.0-alpha4


texts: Views 3: display "block" doesn't show full node

texts:
I would like to show full node including comments in views. Everything is ok if I choose display "page" but in case of "block" all comments disappear from the view only content and link "add comment". What is wrong in my case and how to correct it? I need a block with full node content including comments.

My parameters in views:

Format:
Format: Slideshow
Show: Content; All (I also cheked "show comments" and "show links")

Thanks in advance


texts: Reoccurring weekly billing that only a user can see, based on a schedule in another node

texts: I need to setup a timed event, weekly, that will create a node or "billable event" based on a given pricing schedule (values on another node) and based on a date in another field on a different content type.  And now if that wasn't confusing enough, I need for only the specific user to be able to see it.  I'm open to any ideas as I really have no idea where to begin.


texts: Views with taxonomy contextual filter not working in Russian language in Drupal 7

texts:
I have a View which works perfectly in English.
It has a contextual filter, with options
Content: Has taxonomy term ID ,
filters by taxonomy term with term name converted to term Id.

But when I put in the URL the term in Russian, Раздел, it does not show the content.
When I check the SQL, to my surprise and dismay, this is what I find: search_index.word = 'razdel'.

Clearly there has been a transliteration. Maybe this is why it does not work. I do not really what to do.


texts:
How can I remove the Member for information from appearing on accounts?
I know I can hide the field, but the problem is that Ubercart order link appears in the history field, so I can't hide the field. I have tried using CSS to hide the details, but failed as hiding the dl tag hides the whole field.


texts: How to create a rule which after several updates in 5 minutes of a node sends 1 message?

texts:
When a node is being updated I have a trigger for this in the rules engine.
I want a notification of this in the email.

The node is however updated several times in 5 minutes.

I only need 1 notification of this.

I first had the idea to compare the node:changedate with site:current-time with 300 seconds diff in a php rule, but then all email is not send as the first email is also within the 300 seconds.

Any suggestion how to solve this?


texts: I'm attempting to sort the form table generated by IEF by the value of a specific field - but running into a stumbling block (in other words - it's not working). Has anyone else used the hook_inline_entity_form_table_alter and sorted by a field value successfully?


texts:
What does it mean when someone says Drupal API? Does that phrase include drupal hooks, theme functions and every other drupal term or is it used as a synonym for api.drupal.org

I am really confused please define it for me to understand it easily.

Many thanks


texts: How to show/hide a block at some content types using PHP filter?

texts:
I want to show/hide my block at some content types so I'm using PHP filter. My code in block configuration is:

<?php
if(arg(0)=='eshop') { return true; }
if(arg(0)=='node' && is_numeric(arg(1)) {
  return false;
}
return false;
?>

With this code the block is visible at every page even if it returns false, even if arg(0) is 'node' and arg(1) is 170. But if I use only:

<?php
if(arg(0)=='eshop') { return true; }
?>

It will show the block corectly only at /eshop page.

What is this, a GIANT Drupal bug?


texts:
We have a Drupal 7 setup where the same URL was used for both viewing content and logging in, in the usual way. Now, the original URL is used for viewing content, but you can't log in if you're accessing the site from that URL. You can now only log in if you're accessing a site from a new URL.

To clarify, the different URLs are used for:

Public hostname: content viewing by the public, and you can't login from this URL
Private hostname: logging in by our staff, for adding content

Appropriate mappings were added to the sites.php file.

After making this change, when new content is created the host component of the URL that it generates when viewed via either hostname changed to the one it's logged in from. When I say host component, I mean 'www.example.com' of 'www.example.com/path/to/page' - the URL component displayed before the text field at /admin/config/system/site-information when it asks you to specify your front page.

$base_url in settings.php has not and never has been set.

Why has this changed, and how can I change it back/to an arbitrary value of my choosing?

Excerpt of sites.php file as requested:

$sites['stage-drupal.example.com'] = 'default';
$sites['drupal-cms-en'] = 'default';
$sites['drupal-cms-en.example.com'] = 'default';
$sites['stage-drupal-cms-en.example.com'] = 'default';
$sites['aws-drupal-en'] = 'default';

$sites['stage-drupal.example.de'] =  'drupal.example.de';
$sites['drupal-de.example.com'] =  'drupal.example.de';
$sites['drupal-cms-de'] = 'drupal.example.de';
$sites['drupal-cms-de.example.com'] = 'drupal.example.de';
$sites['stage-drupal-cms-de.example.com'] = 'drupal.example.de';
$sites['aws-drupal-de'] = 'drupal.example.de';


texts: Trying to change the body in presave nodeapi - not working

texts:
I'm trying to make a small modification in the body a node when it's saved:

function radicalislam_utils_nodeapi(&$node, $op) {
      if ($op == 'presave')
             $node->body = 'test';
}

but what I'm getting is strange. when I view the node, i really see only "test" as the body. but when i go edit the post, i see all that previously on the body and "test" appended in the end...

Why is that?


texts: Rest Export: Get rid of no result fields

texts:
I have a rest export that exports various content types. However I am running into the problem of the export giving me empty no result attributes. Here is an example.

  {
     "title": "Acme Porter Image",
     "body": "",
      "field_image": "http://192.241.172.112/sites/default/files/2016-02/beer-batter-is-better_1_2.jpg",
      "field_videosour": ""
    },
    {
      "title": "Acme Porter Description",
      "body": "This thing has more hops than Michael Jordan. It is dark and has hints of chocolate",
      "field_image": "",
      "field_videosour": ""
    },
    {
      "title": "Acme Porter Video Review",
      "body": "",
      "field_image": "",
      "field_videosour": "https://www.youtube.com/watch?v=JCpLerLKD2k"
    }

Does anyone know how to get rid of the no result elements from the response?

Thanks,
Emmanuel


texts: custom template for entity as referenced entity

texts:
I have a node type for which I have a custom tpl. OK.

But this node type I also have as a referenced entity in another nodetype. And in this case I need another custom tpl.

Is it possible to have another tpl and if yes: how do I name this file?


texts:
When I installed Drupal, I put it in a subfolder /drupal. Got everything set up and then moved everything into my root folder. When I went to the site I got this error:

Failed opening required '/home3/XXXX/public_html/drupal/modules/field/field.crud.inc'
(include_path='.:/usr/lib/php:/usr/local/lib/php') in
/home3/XXXX/public_html/drupal/modules/modules/field/field.module on line 20

Then I moved everything back to /drupal and still get the same error.

Can anyone tell me where I should be looking for the issue?

I looked in my settings.php file and didn't see anything about a directory listing. I looked in /sites/default/settings.php and couldn't find anything to do with directories.

Thanks for the help!


texts:
I'm working on migration from an old Drupal 8 site to new Drupal 9 site:
I developed a source plugin to get data from D8 database:
My migration works, but it doesn’t migrate all my contents and get this error:

Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '8a7e1ba8-9b75-4813-80d6-99104c82efa5' for key 'node_field__uuid__value': INSERT INTO {node} ("vid", "type", "uuid", "langcode") VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array

When I debug the issue and I have found that there is some translated nodes have the same nid vid only langcode is different like the example bellow.

I added the langcode as id in my source plugin but it doesn't help:
  public function getIds() {
    return [
      'nid' => [
        'type' => 'integer',
        'alias' => 'n',
      ],
      'langcode' => [
        'type' => 'string',
        'alias' => 'n',
      ],
    ];
  }

How can i migrate those nodes ?
Used modules: Migrate/ Migrate plus / Migrate Tools .
Drupal Version : 9.0.3


texts:
While i checked the markup of my drupal-7 site in http://validator.w3.org/check
it shows me a error:

error Details:
Attribute about not allowed on element article at this point.

I have checked my markup as well as all the functionality that are running properly. Why i am getting this error?


texts: How to remove unwanted form state values before validation

texts:
What is the good way of validating a form in Drupal 8 ?

I have a bunch of fields which are supposed to be filled by a positive numeric value (and that's all, no other input types, just positive int).

public function validateForm(array &$form, FormStateInterface $form_state) {
$values = $form_state->getValues();

foreach ($values as $method => $fee) {
  if ($method != 'Free order') {
    if (!is_numeric($fee) || floatval($fee) < 0) {
      $form_state->setErrorByName($method, t('Value must be a positive integer.'));
    }
  }
}

}

The issue is when using $form_state->getValues() it also returns "submit", "form_token", "form_build", "form_id", "op" which is quite boring as those infos are not needed for performing validation.

So what I did is removing those four unwanted values with :

$values = array_splice($values, count($values) - 5, 5);

But it's really annoying, am I doing something wrong, or is just as it ? Because I think those values are really not necessary in the validation process.


texts: Views & custom exposed filters : where do I start?

texts:
I've got this module which makes an additional field available when you base the view on Users. The field is made available through hook_views_data().

I've created a filter for this field, and it should be exposed to users. However, what I would really like to do is to create a custom filter. That is, a very custom form with some specialised options which the user can choose between.

How do I go about doing this?  How do I tell Views that I've got this custom exposed filter. I know hook_views_plugins has something to do with this, but I can't find any place which describes the general picture of how things interact. Does anyone have any experience with this; and how things work together and which pieces I need to solve the "puzzle"?

Any input appreciated!


texts: Most classes are instantiated using create($container) and __construct(...$services) in conjunction, it seems that the more efficient workflow would be to simply pass the container to the constructor __construct($container) and not have the create method at all. Is this inherited from Symfony? What purpose does it serve?


texts: Adding View to Content Type already existing to combine fields

texts:
I have a content type that is loaded with 1000's of records. These are not shown through any custom view as of right now. I have multiple fields I would like to combine into a single field.

For example:

field_one, field_two, field_three

...combine above into single field:

field_combined

I don't need to do any calculations, I would just like to combine them into one field when the content type page is displayed.


texts:
There is no problem with a node creation with filled in title/body/custom text field fields using REST API. We just need to send a post request with the following body:

{
  "_links": {
    "type": {
          "href": "http://localhost/drupal/rest/type/node/page"
    }
  },
  "title": {"value": "Does it work?"},
  "body": {"value": "node body"},
  "field_test": {"value":"hello"}
}

Where "field_test" is a plant text field.

But how to create a node with filled in tags field?

I've tried to post a node using the following post request body:

{
  "_links": {
    "type": {
          "href": "http://localhost/drupal/rest/type/node/page"
    }
  },
  "title": {"value": "Does it work?"},
  "body": {"value": "node body"},
  "field_tags": {"value":"tag1"}
}

It creates the node, but without tags ("field_tabgs") value.
Any help?


texts: Is there a way to make sure an autocomplete field as an actual match?

texts:
I have an entity reference field in a content type in D7 set with an autocomplete widget. This is a required field, however if you type in something that doesn't have a match, it will still submit and save anyway.

Is there a way to make sure an actual match is found before allowing it to save?


texts: How to add a filepath to a file uploaded in form API

texts:
Problem

I have a custom form which creates a node. It's based off this link and uses the entity metadata wrapper to create the node.

The node created has an image field and you can use the form to upload an image on creation.

How can I set an upload directory for the image that's uploaded? At the moment they just default to my public folder.

Set-Up

There's more to this form, but these are the important parts. I declare a file field.

function postajob_form($form, &$form_state){
   ....
   $form['file'] = array(
     '#type' => 'file',
     '#title' => t('Thumbnail/Advert Picture.'),
     '#size' => 5,
   );
 }

I then submit that file using an entity metadata wrapper.

function postajob_form_submit($form, &$form_state) {

  global $user;

  $values = array(
    'type' => 'job_advert',
    'uid' => $user->uid,
    'status' => 1,
    'comment' => 1,
    'promote' => 0,
  );
  $entity = entity_create('node', $values);

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

  if (array_key_exists('storage', $form_state)) {
      //if is required incase no image is uploaded.
      $ewrapper->field_req_thumbnail_school->file = $form_state['storage']['file'];
      //field is unset now it's no longer needed.
      unset($form_state['storage']['file']);
   }
}

I tried changing the URI inside the form_state, however this had no effect.

 if (array_key_exists('storage', $form_state)) {
      //altering the uri where the files are uploaded too
      $imagefilename = $form_state['storage']['file']->filename;
      $form_state['storage']['file']->uri = "public://user-upload/job-advert/$imagefilename";
      //save the file
      $ewrapper->field_req_thumbnail_school->file = $form_state['storage']['file'];

   }

But this didn't effect anything.


texts: Programmatically create a taxonomy and attach a field to it

texts:
I created a vocabulary using the following code.
$vocab = entity_create('taxonomy_vocabulary', array(
  'name' => 'vocab_name',
  'vid' => 'vocab_id',
  'description' => 'description'
));
$vocab->save();

I need to attach a custom field to it. I created the field with BaseFieldDefinition::create('string'), bu I couldn't figure out how to attach the created field to $vocab.
How can I achieve it?


texts: The website encountered an unexpected error. Please try again later( Olivero subtheme)

texts:
Tried to make an Olivero subtheme. Followed drupal tutorials and after several unsuccessfull attempts ended in error "The website encountered an unexpected error. Please try again later" on both backend and frontend now I don't get the error anymore on the backend but I still can't access the frontend.
Error in drupal log looks like this
Drupal\Core\Asset\Exception\InvalidLibraryFileException: Invalid library definition in themes/mysubtheme/mysubtheme.libraries.yml: A colon cannot be used in an unquoted mapping value at line 1 (near "global-styling: version: 1.x "). in Drupal\Core\Asset\LibraryDiscoveryParser->parseLibraryInfo() (line 348 of /home/admin/web/mysite.com/public_html/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php).

mysubtheme.info.yml looks like this
type: theme
base theme: olivero
description: My custom theme based on the core Olivero theme. It's meant for customization.
package: Custom
libraries:
  - mysubtheme/css
  - mysubtheme/js

regions:
  header: Header
  primary_menu: 'Primary menu'
  secondary_menu: 'Secondary menu'
  hero: 'Hero (full width)'
  highlighted: Highlighted
  breadcrumb: Breadcrumb
  social: Social Bar
  content_above: Content Above
  content: Content
  sidebar: 'Sidebar'
  content_below: 'Content Below (Flex Layout)'
  footer_top: 'Footer Top (Flex Layout)'
  footer_bottom: 'Footer Bottom'

core: '8.x'
core_version_requirement: ^8 || ^9

and mysubtheme.libraries.yml like this
 version: VERSION
 css:
   theme:
     css/custom.css: {}

global-scripts:
 version: VERSION
 dependencies:
   - core/jquery
   - core/drupal
   - core/drupalSettings
 js:
     js/custom.js: {}

Thank you for any help.


texts: How to use a between operator in an entity field query?

texts:
I wanna use a between operator. Can anyone tell how to use this? I am using it like this

$query->propertyCondition('nid', array(4, 3), 'between');

But it is also including node id 4 and 3, and I want to show only "2", which falls in between. How can this be done?


texts:
I have a portfolio View. As we are expecting: The portfolio displays all the nodes of the content type of the portfolio in a grid. Based on the selected term of the tags above we can see the associated content in images and titles and some description.

I'm adding the view block of the portfolio in the Tags page (taxonomy-term.tpl.php) (so i can get the term from the url).

What I want to know is: How can I get the term from the url and then make the view get only the terms children of that term, so I can only see the portfolio of the selected terms.

Thanks in advance.


texts:
When I go to node/add. I see the message showing there is no content type:

But, when I go to admin/structure/types. I see three content types I have :

What could that be the problem ?
I'm using Drupal 7.14.


texts:
I have  this error with my css, what drush commands I can use to fix this? is it a permissions fix?
please guide me step by step


texts: Always keep admin UI in English when translating content

texts:
How can I prevent the admin UI switching to a foreign language every time I translate a piece of content?

i.e. I'm editing a Menu item and I've clicked the Translate tab.
I click 'Add' in the German row to add a translation.

However the link always begins /de, which means all the UI labels change as well - to get back to English I have to manually remove it from the address bar and (it seems) do so every single time.

Is there any way to turn this off?

I tried going to Detection and Selection  (/admin/config/regional/language/detection) and checking 'Account Administation pages', or checking 'User' and promoting it to the top of the list, but this didn't seem to make any difference to the button URL or the form output.


texts: How to add existing nodes/contents to a book page?

texts:
This is my scenario:

  I have several nodes of different content types in my drupal site. I want to create a book page and add these existing contents to book page as child pages rather then creating child pages.

Already looked at Outline designer and Book made simple  module, but i think none of these modules has this functionality. Is there any module available for that or i need to build a custom module?


texts: How to show a view each 5 rows in another view

texts:
I'd like to create a complex view which combines several views.
I'm using Views Infinite Scroll

The view logic:

view A row-1
view A row-2
view A row-3
view A row-4
view B Block 1
view A row-5
view A row-6
view A row-7
view A row-8
view B Block 2

The difference between view B Block 1 and view B Block 2 is that Block 2 has offset from view B Block 1

Ok the adequate minimum is to insert view B Block 1 to each n row of the view A.

I tried to insert block in the view template but vainly.

Please help!


texts: How do I grant to roles dynamically created permissions?

texts:
In my module, I am dynamically creating user permissions for vocabularies. I would like to also grant all roles the view permission, but I cannot figure out a proper way where to do it.

I cannot use a config yml, because these are dynamic permissions created within permission callback and both the hook_install and hook_modules_installed are run before the permission callback, so the roles don't pick up the permissions.

This is how I tried to grant the permissions in hook_install() and hook_modules_installed().

$vocabularies = \Drupal::entityTypeManager()
  ->getStorage('taxonomy_vocabulary')
  ->loadMultiple();

if (!empty($vocabularies)) {
  foreach ($vocabularies as $vocabulary) {
    $permission = 'view name defined in the callback ' . $vocabulary->id();
    $anonymous_rid = RoleInterface::ANONYMOUS_ID;
    $authenticated_rid = RoleInterface::AUTHENTICATED_ID;

    if ($anonymous_role = Role::load($anonymous_rid)) {
      $anonymous_role->grantPermission($permission);
    }
    if ($authenticated_role = Role::load($authenticated_rid)) {
      $authenticated_role->grantPermission($permission);
    }
  }
}

Where should I grant these permissions within my module?


texts: Best practice when testing module updates

texts:
A problem I face on a regular basis is trying to test sites that have recently had a lot of module updates. My usual process is to take each module on a case by case basis and test site features related to that module.

For instance, if the wysiwyg module is updated, I'll find a node that implements it in a field and do exploratory testing. But the reality is that the issues can be more subtle - perhaps certain user roles have lost permissions, allowing them to embed media when they were previously restricted.

Sometimes there are so many factors to bear in mind it is impossible to test them all, and invariably the client, at UAT phase, discovers major issues that I may have been blind to for various reasons.

I would be interested to hear of any advice or approaches towards testing sites that have had comprehensive module updates - what can I do to ensure quality, and even, what kind of line should I take with our clients to prepare them for issues that do invariably arise?


texts: Send Billing Information from Address Field to PayPal site using WPS

texts:
Referring to the solution here posted by Fnik, I'm trying to implement it on my own custom module.  But I thing our two sites are configured differently, and since I'm not too familiar with php, I don't get how to adapt his code for my project.

I use Address Field module for customers billing and shipping address.  This doc page explains how it stores its subfields.  So I need to access these subfields with the hook Fnik pointed.

My code doesn't do it correctly on checkout. Although syntax seems ok, I get errors (specified bellow) when the function is called.  Here is my code:

function my_module_commerce_paypal_wps_order_form_data_alter(&$data, $order) {
$profile = user_load($order->uid);
$data['first_name'] = $profile->field_commerce_customer_shipping->commerce_customer_address->first_name['und'][0]['value'];
$data['last_name'] = $profile->field_commerce_customer_shipping->commerce_customer_address->last_name['und'][0]['value'];
$data['address1'] = $profile->field_commerce_customer_shipping->commerce_customer_address->thoroughfare['und'][0]['value'];
}

Some context:

commerce_paypal_wps_order_form_data_alter is a hook from commerce_paypal_wps.module
field_commerce_customer_shipping is a Customer profile reference in Order type order entity.

commerce_customer_address is a Postal address field type in Shipping information Profile type entity.

Erros, 3 different errors for each $data line:

Undefined property: stdClass::$field_commerce_customer_shipping in my_module_commerce_paypal_wps_order_form_data_alter() (line 27 of ...)
Trying to get property of non-object in my_module_commerce_paypal_wps_order_form_data_alter() (line 27 of ...)
Trying to get property of non-object in my_module_commerce_paypal_wps_order_form_data_alter() (line 27 of ...)

Is is the $profile variable declaration that is wrong right in the beginning, or is it the way to refer to fields and subfields?

Thanks in advanced.


texts: Updating throws an error which effects the site theme

texts:
I tried to update Drupal Commerce, before updating core to 8.6.0, with composer update drupal/commerce --with-dependencies.

Now I get the following error for each page.

  Fatal error: Declaration of Drupal\commerce_price\Repository\CurrencyRepository::get($currency_code, $locale = NULL) must be compatible with CommerceGuys\Intl\Currency\CurrencyRepositoryInterface::get($currencyCode, $locale = NULL, $fallbackLocale = NULL) in C:...\modules\contrib\commerce\modules\price\src\Repository\CurrencyRepository.php on line 20


texts:
I want create an advanced and complete search, like the one on http://www.lib.muohio.edu.

I want to enable search in my CCK fields.
I don't know what module this site use; please help me to know that module(s) used in this site.

Help me to style my site like this site.