texts: Get 404 for url specified in module.routing.yml

texts:
I am new to Drupal and I got stuck with the problem that I don't know how to debug even:
I have made a simple module 'final', its structure:

Applications/MAMP/htdocs/drupal_dir_1/modules/final > ls
final.info.yml    final.routing.yml src

/Applications/MAMP/htdocs/drupal_dir_1/modules/final > ls src/Controller/
ExampleController.php

Files contents:

> cat final.info.yml
name: Final
type: module
description: This is an final module
core: 8.x⏎

> cat final.routing.yml
final.content:
  path: '/final'
  defaults:
    _controller: '\Drupal\final\Controller\ExampleController::content'
    _title: 'Hello world bitch!'
  requirements:
    _permission: 'access content'

> cat src/Controller/ExampleController.php
<?php
namespace Drupal\final\Controller;
use Drupal\Core\Controller\ControllerBase;
class ExampleController extends ControllerBase {
  public function content() {
    $build = [
      '#markup' => $this->t('Hello World, bitch!'),
    ];
return $build;
  }
}


texts: How to register multiple member in one civicrm membership sign up form?

texts:
I have a special promotion price set for member: Register 1 new member is USD 500, register 2 new members in one-time is USD 800.

In my membership sign up form (created using contribution page), I would like the user to enter 2 member details during sign up.

I found this function in event page, where user can register multiple participants in one event, and make payment. But, the payment can't extend the membership period and can't create new membership.

I tried to adjust my price set setting by changing "used for" option, but it shows error of "If you plan on using this price set for membership signup and renewal, you can not also use it for Events or Contribution."

By selecting it using for membership, I can choose the price option to have different number of terms. But, this can't be used in event page which allow multiple registration of participant / member.

Is there any way I can register multiple member in one membership sign up form?


texts: How to programmatically create a product display(node) with reference to the product?

texts:
I want to programmatically create a product display, product and link them.

How can I do it?


texts: Hide publishing options in hook_form_alter without unpublishing node?

texts:
I'm trying to create a very slimmed down node edit page for a content type. One of the things I'm doing is hiding the additional_settings section with #access = false.

This is what I'm using:

$form['additional_settings']['#access'] = FALSE;
$form['options']['status']['#default_value'] = TRUE;

With #access = false, when I save the node after editing, it set to unpublished.

I've tried using $form_state['values']['status'] = TRUE; in a form submission handler, but that doesn't help.


texts:
In a Drupal 8 site, I want to add menu items with "no link", I was thinking that nolink is allowed but when I entered this, I got error

  Manually entered paths should start with /, ? or #.

Is there a way for adding menu items not clickable without adding "#" because "#" add attribute [data-drupal-link-system-path=""] and [class="is-active"]


texts: How do I add a Javascript library to a field formatter?

texts:
I'm trying to include a Javascript gallery (jQuery lightGallery) on my new Drupal 8 site and wrote a field formatter for this purpose.

Now I need to add the jQuery lightGallery to pages using this field formatter and call the library when the page is ready. I am confused about how I am supposed to do this, though.

I defined the library in the module containing my field formatter, but I'm not sure how I attach it only on sites that contain the field.

The documentation of the library uses the jQuery $(document).ready function to call the libary, how would that work inside a Drupal module?


texts: How to make Language Switcher Block work with unpublished nodes?

texts:
On a multilingual Drupal 7 site, the Language Switcher Block used to work for both published and unpublished nodes.

Example:
node/1: English, alias=map, published
node/2: German, alias=karte, published
node/3: English, alias=table, unpublished
node/4: German, alias=tabelle, unpublished

On /node/1 or /map, the Language Switcher shows the link to German and it correctly links to /de/karte. This works also the other way around.
However, on /node/3 or /table, the block does show a link to German version, but it links to /de/node/3 instead of /de/tabelle. On the German version at /de/tabelle (or /de/node/4) the block links to /node/4 instead of /table.

As far as I know, this change was introduced between Drupal 7.24 and 7.28 and might even not be a Core issue. However, I couldn't find the source of this behaviour.

Does anyone know, if it is related to some Security Issue with unpublished nodes or where I could start looking further? I tried to find it inside core modules locale/translation and language.inc and also in i18n to no avail.


texts:
I'd like to add a button to every of my article pages, that would open a box containing an iframe code embedding for example the title, the content and the image of the article in another page.
Does it already exist a module doing this? I tried Iframe and Entity Iframe, couldn't get what I want though.

Thanks for your help.


texts: menu_tree_output() not returning full menu array

texts:
I'm building a function that takes a drupal rendered menu and removes the classes from it so that I can pass it to a jQuery function that'll build a menu from it.

The code i'm using for that is:-

<?php
     $tree = menu_tree_all_data("devel-frus");
     $menu = drupal_render(menu_tree_output($tree));
     $nocss = preg_replace('/class=".*?"/', '', $menu);
     echo($nocss);
?>

However menu_tree_output() seems to be only returning the first level of a six level menu when it should be returning the complete menu.

I've tried dsm()'ing $tree to see if all of the menu items are being returned by menu_tree_all_data() and that's fine, however when I dsm() the output of the menu_tree_output() function only the root and first level are returned in the array.

Am I doing something really obviously wrong here?


texts: How to organize webforms on (admin/content/webform) into groups

texts:
Goal: I want to be able to organize the list of webforms on the admin/content/webform page, which is in a View to my understanding, in groups. Either via visual groups (using some header or box) or add a filter to the page so that I can specifically look up a term ID that is associated with one or multiple webforms (like you can on the admin/content page).

So for example: if I had several webforms about housing, I would like to be able to create the header 'Housing' and have associated webforms underneath. Or be able to select the Vocab or TID associated with one or multiple webforms and filter the results.

I'm a very new user to Drupal (couple months experience on the job only). I've spent the last ~4 days searching the internet to find info to help me and have found some promising things but haven't gotten anything to work. Many things are over my head.

The best two things I've tried are the following:

1) I've tried editing the Webform View. I've tried adding a TID field but that's not listed as an option to add. My plan was to add a Contextual Filter for TIDs.

2) I've tried adding a Term Reference field and Node Reference field to a Webform. This seemed promising until I realized they became Select List options on the actual webform presented to the user. Obviously this will not do what I want to do on the developer side of things.

I've heard about creating custom admin pages with views but I was hoping for a simpler way to accomplish this. If that is the only way to do so, so be it.

I'm using Webforms 7.x-4.4 fyi.

Thanks for any help! Sorry this is long and probably newbish.


texts:
I activated aggregate CSS on my local development and on a remote testing environment without any problems. Now on staging the aggregation of CSS files causes trouble: on some pages the styling looks correct but on random pages it is completely broken. The HTML sometimes shows:

<link rel="stylesheet" href="/?p0upgh" media="all" />
<link rel="stylesheet" href="/?p0upgh" media="all" />
<link rel="stylesheet" href="/?p0upgh" media="print" />

Sometimes some of the aggregated files seems not to be inserted via HTML meaning: there are no  Tags or just one - some of the stylesheets are missing.

I checked folder permissions: sites/default/files and sites/default/files/css have 777 as chmod values. The owner and the group of the folders and files belong to the correct folder and CSS are aggregated in sites/default/files/css.

Does anyone has some hint for me what my cause this problem?


texts: How do I trigger an "on change" event of another select element?

texts:
I have two select elements. one for a property and one for a category. When I select property it goes to a function through ajax and return an array to other select elements (category) #option. I need to do is,
when I select a property, the category elements first option should be selected and trigger that elements on change event.

Form

public function buildForm(
    array $form,
    FormStateInterface $form_state,
    $properties = [],
    $categories = [],
    $propertyContent = [],
    $isCorporate = false,
    $propertyId = null
) {
    $propertyKey = null;

    if (!empty($form_state->getValue('property'))) {
        $propertyKey = $form_state->getValue('property');
    } else {
        $propertyKey = key($properties);
    }

    $form['property'] = [
        '#type'          => 'select',
        '#id'            => 'property',
        '#attributes'    => ['class' => ['form-control']],
        '#title'         => $this->t('Hotel'),
        '#options'       => $properties,
        '#default_value' => $propertyKey,
        '#ajax'          => [
            'callback'  => 'create_category_list',
            'event'     => 'change',
            'wrapper'   => 'category-type',
            'method'    => 'html'
        ],
        '#required'  => true,
        '#validated' => true,
    ];

    $form['category'] = [
        '#type'         => 'select',
        '#id'           => 'category',
        '#attributes'   => ['class' => ['form-control']],
        '#title'        => $this->t('Category'),
        '#options'      => $categoryList,
        '#ajax'         => [
            'callback'  => 'show_gallery_ajax',
            'event'     => 'change',
            'wrapper'   => 'gallery-images',
            'method'    => 'html',
            'progress'  => [
                'type'    => 'throbber',
                'message' => t('Loading gallery !'),
            ],
        ],
        '#prefix'        => '
',
        '#suffix'        => '
',
        '#default_value' => $defaultCategory,
        '#required'      => false,
        '#validated'     => true,
    ];

    return $form;
}


texts:
Preamble

We currently have a Drupal 8 site that has subsites (accessed via subdomains).

On the main site (non-subdomain) we have a main navigation menu defined (this is presenting correctly on the main site).

On each sub site we have a domain specific main navigation menu defined (these are presenting correctly on each subsite).

We have a footer menu that is used as a placeholder, defining only top level navigation items (no children). This footer menu is used both on the main site and each sub site.

The footer navigation child items are cloned from the main navigation (if on the main site, the child links are cloned from the main navigation as defined, if on a sub site, the child items are cloned from the sub site main navigation as defined). This is working.

We also do some clean up to remove top level footer items that arent present in the main/sub sites navigation menu.

Problem

If we clear the cache & load the main site, we get the expected footer items shown.

If we clear the cache & load a sub site, we get the expected footer items shown.

If we clear the cache & load the main site, and then load a sub site without clearing the cache again, we get the main sites footer items presented, not the desired sub sites footer items.

We have put in place caching directives for url.site which we believe should be recognising that the sub site and main site have different url's and should be caching these footer menu's separately.

Code

// Implements hook_rebuild().

function modulename_rebuild() {
  Menu::load('main')->addCacheContexts(['url.site']);
  Menu::load('footer')->addCacheContexts(['url.site']);
}

// Implements hook_menu_local_tasks_alter().

function modulename_menu_local_tasks_alter(&$data, $route_name, &$cacheability) {
  $cacheability->addCacheContexts(['url.site']);
}

// Implements hook_menu_links_discovered_alter().

function modulename_menu_links_discovered_alter(&$links) {
  $subdomain = CustomDomainModule::getSubdomain();
  $menu_name = 'main';

  if (!empty($subdomain)) {
    $menu_name = 'main_navigation_' . $subdomain;
  }

  $parameters = \Drupal::menuTree()->getCurrentRouteMenuTreeParameters($menu_name);
  $parameters->setMinDepth(0)->setMaxDepth(2)->onlyEnabledLinks();

  $navMenuItems = \Drupal::menuTree()->load($menu_name, $parameters);

  // Get all top level links for the footer menu.
  $parameters->setMaxDepth(1);
  $footerMenuItems = \Drupal::menuTree()->load('footer', $parameters);
  $count = 0;

  // Enumerate links for the footer menu.
  foreach ($footerMenuItems as $key => $value) {
    foreach ($navMenuItems as $item) {
      // if we have found the matching parent
      if ($item->link->getTitle() === $value->link->getTitle()) {
        if ($item->hasChildren) {
          foreach ($item->subtree as $subItem) {
            $subItemLink = $subItem->link;

            $link = [
              'title' => $subItemLink->getTitle(),
              'description' => $subItemLink->getDescription(),
              'parent' => $key,
              'weight' => $subItemLink->getWeight(),
              'options' => $subItemLink->getOptions(),
            ];

            // Get the route name from the original main nav.
            $originalLink = $subItemLink->getUrlObject();

            if ($originalLink->isRouted()) {
              // Add route properties if there was a route defined on the main nav.
              $link['route_name'] = $originalLink->getRouteName();
              $link['route_parameters'] = $originalLink->getRouteParameters();
            } else {
              $link['url'] = $originalLink->getUri();
            }

            $id = $key . '_alternate_' . $count;
            $links[$id] = $link;

            $count++;
          }
        }
      }
    }
  }
}


texts:
I've installed domain access module and all its submodules.
I have two domains (both set already) and I would like to assign node to one of these domain only.

I set the proper domain in node edit form, but it really doesn't affect the anonymous user permissions, because ALL users can view this node from all domains.

Devel node access displays on the node page something like below:

I checked user permissions as well and everything looks pretty good there.

How do I configure this module to access node only from the right domain?

--- edit ---

after change suggested in one answer it looks like


texts: How to show only content created by the user in the find content (administrative) page

texts: I've got some users who are allowed to create content. In the administrative interface, they actually see a list of all contents in the site but edit/delete only the content created by them. Is it possible to show in this page only the content they created and do not show content created by other users?


texts:
I'm looking for a menu module which would show a menu tree like:

Menu level 1 (Container)
    |-------Menu level 2
    |-------Menu level 2
    |-------Menu level 2
    |-------Menu level 2
    |-------Menu level 2
Menu level 1 (container)
    |-------Menu level 2
    |-------Menu level 2
Menu level 1
Menu level 1 (container)
    |-------Menu level 2
    |-------Menu level 2
    |-------Menu level 2
Menu level 1

It'd be the best if it would be dynamic, but that doesn't really a must.
So anyone knows a Drupal 7 module which is capable of doing this?


texts: How to change default file system path in D8?

texts:
In D8, where to change the Public File System Path to be :

sites/default/files/[nodeID]/

Do I need write a module?


texts:
I can't display the default value of the $date_debut in form. Dpm shows me that the right values are there and I can display $date_debut in #title but not on #default_value.
any idea why ?

$timestamp_debut = variable_get('variable_1');
$date_debut = date('d-m-Y',$timestamp_debut);
$form['definition_de_la_période_de_modification']['date_de_debut'] = array(
  '#type' => 'date_popup',
  '#date_format' => 'd-m-Y',
  '#title' => t('Date de début'),
  '#default_value' => $date_debut,
  '#required' => FALSE,
);


texts: Replacing a 'Teaser'-themed node in a View its it's 'Full Content'-theme using ajax in Drupal 7

texts:
So, basicly, I have a Drupal 7 view that's displaying Teasers of Nodes.

WHen a user clicks this teaser, I want the node to load it's "Full Content"-content instead, and I would like this to be done using Ajax.

I've looked around a lot but I can only find solutions for Drupal 6, and many good solutions at that, but I'd love some help with figuring this out in D7!

Thank you!


texts: Reset View result counter after changing page (manually or with Twig)

texts:
Drupal 8

I have a View that uses the View result counter starting at '0'. It works great, except for the fact that when you change to Next page the counter doesn't start off at '0' again, but rather continues on.

I tried using Twig modulus to get a circular-list (always reset back to 0), the reason I use 10 is because my pager displays 10 items.

{{ counter % 10 }}

It doesn't work, it always prints 0 for some reason. But if I do {{ 11 % 7 }} it prints the correct result which is '4'.

Does anyone know either of these:

Can I force view to restart counter at '0' when it goes to other pages int he pager?
Why is Twig not printing the proper math result of {{ counter % 10}} ? (Keep in mind that doing things like {{ counter + 1 }} don't work either. For some reason it only works when you use only numbers like {{ 1 + 3 }}  )

Thanks.


texts:
The theme I'm using (AT Panels Everywhere subtheme for Adaptivetheme) has the following skip navigation link:

Skip to main content

but that link goes nowhere when I hit Enter when that div becomes focused as I tab through on the keyboard.

I tried adding the "content" anchor tag like this:

<?php print $content; ?>

but it still doesn't work. I'm still forced to tab through every link on the page.

What am I doing wrong?


texts: How to use (reference) the uploaded file to a media(video) type?

texts:
I have read https://www.drupal.org/node/2941420 and I can upload a image file then use it in article.

But I can not use it as video field after I upload a video file.

My Drupal version is 8.6.0-beta2.

I use the media type ( Drupal 8 core module) for my video field, this is a Entity reference.

When I use

POST  http://www.myhots.com/file/upload/media/video/field_media_video_file?_fo...

I get the response as the end shows (the fid =47)

{
    "message":"Unprocessable Entity: validation failed.
field_user_video.0.target_id: The referenced entity (media: 47) does not exist.
"
}

Then I use it :

curl -X PATCH -H 'Content-Type: application/json' -H 'X-CSRF-Token:YYYYYYYYYYYYYYYYYYYY' -H 'Authorization: Basic XXXXXXXXXXX=' -i 'http://www.myhost.com/node/5?_format=json' --data '{

"type":[
    {
        "target_id":"user_video",
        "target_type":"node_type"
    }
],
"field_user_video":[
    {
        "target_id":47,
        "target_type":"media"
    }
]

}

The response is as follows:

{
    "message":"Unprocessable Entity: validation failed.
field_user_video.0.target_id: The referenced entity (media: 47) does not exist.
"
}

Which information should I use to patch it? It seems that the "fid" is not correct.

Maybe I need  "target_id " of "media“， but there is no response after I upload a video file, any suggestion?

"field_user_video": [{
  "target_id": 3,
  "target_type": "media",
  "url": "\/d86\/media\/3"
}]

'

{
"fid":[
    {
        "value":47
    }
],
"uuid":[
    {
        "value":"cf69fac4-5ba2-4861-9cce-a959dee3c480"
    }
],
"langcode":[
    {
        "value":"en"
    }
],
"uid":[
    {
        "target_id":1,
        "target_type":"user",
        "target_uuid":"c2b09ff8-345a-43fa-b9ae-68af0c9cd3ea",
        "url":"/d86/user/1"
    }
],
"filename":[
    {
        "value":"example2.mp4"
    }
],
"uri":[
    {
        "value":"public://2018-08/example2.mp4",
        "url":"/d86/sites/default/files/2018-08/example2.mp4"
    }
],
"filemime":[
    {
        "value":"video/mp4"
    }
],
"filesize":[
    {
        "value":6320348
    }
],
"status":[
    {
        "value":false
    }
],
"created":[
    {
        "value":"2018-08-31T03:04:20+00:00",
        "format":"Y-m-d\TH:i:sP"
    }
],
"changed":[
    {
        "value":"2018-08-31T03:04:20+00:00",
        "format":"Y-m-d\TH:i:sP"
    }
]
}


texts: Add class to Bootstrap login form button

texts:
I want to add a class to a button in my login form. I have searched through all the template files and I cannot find where to do this. I found the following code that best matches the form in modules/user/user.module

function user_login_block($form) {
$form['#action'] = url(current_path(), array('query' => drupal_get_destination(), 'external' => FALSE));
$form['#id'] = 'user-login-form';
$form['#validate'] = user_login_default_validators();
$form['#submit'][] = 'user_login_submit';

The HTML for the button is below. My aim is to change btn-default to btn-primary

<button class="btn btn-default form-submit" id="edit-submit" name="op" value="Log in" type="submit">Log in</button>

Please help!


texts:
I'm having a problem with views and caching. Within a custom module, i do changes on my database, which is working fine, but my view won't show that changes until I clear all caches.

I tried to deactivate views-caching here "admin/structure/views/settings/advanced"
Caching in the view is deactivated too
And the whole caching is deactivated here "admin/config/development/performance"

But I still have to clear all caches on every change I make to see what I did. Is there a chance to stop caching for that view by code in the module? Or any other possibility?

EDIT: I now tried a module called "CacheExclude" and

$GLOBALS['conf']['cache'] = 0;
drupal_page_is_cacheable(FALSE);
$conf['cache'] = FALSE;

but no change :(

EDIT 2:
Here is the code where I change the field in the database:

foreach($books as $book) {
    $query = db_update('field_data_field_zuordnung')
        ->fields(array(
            'field_zuordnung_value' => 'verkauft',
            ))
        ->condition('entity_id', $book->product_id, '=')
        ->execute();
}

The change is done in the DB, but it isn't shown in the view. After that, I use drupal_goto to move to a "you're done site".


texts: Adding wysiwyg (ckeditor) to textarea on node edit form

texts:
I'm trying to add wysiwyg to a textarea added through CCK.

In my hook_form_alter I can alter the properties of the field no problem. Using this it seems like it should be possible to add 'format' to the element and then use filter_format, it's adds the filter select information but seems to break the body implementation of wysiwyg.

Documentation seems to be pretty sparse on this topic, does anyone know the correct way of implementing this or any complete documentation?


texts: Get field names of view from within module

texts: After using views_get_view($view_name) how do I get the names of the fields?  The list of field names (arranged correctly) is going to be pushed onto an array following which will be all the results.  I can see in the return value from views_get_view() the field array, but how do I get them as they would be displayed in a table, that is, correct capitalization, spaces instead of underscores, etc.?


texts:
Here my query is that, I have created one field in product type "Time(Interval)" and another field created in Line item types "(Default Time)" field.
My requirement is when user saves a new commerce order, Product type (Time(Interval) field) value auto saves in Line item field (Default Time) value.
how we can do this, any idea.


texts: host static files (images) to 3rd party host such as Amazon Cloud. Any modules can facilitate this?

texts:
I want host all images files to the cloud, such as amazon s3.

For example, when creating the node, uploaded automatically upload the files to the cloud, and all images path automatically point to the image stored in the cloud.

Any modules facilitate the CDN transition?

Thanks.


texts: How to make values of fields of newly created node available in Rules

texts:
I have a rule which is triggered upon Event: 'After saving new content'.

My Action involves executing custom php code. Please how can i make the values of the fields of my new node available in my php code.

Thanks.


texts: How to install a specific version of a project with drush

texts:
I observed that by default "drush dl module_name" installs the latest version possible may it be dev version available.

How can we install a specific version of a project with Drush?


texts: Rule to fire only on first time publish of node

texts:
We are using workflow moderation for some content types and sent out emails to the author once a node has been published.

Sometimes we have the case that an author changes a node after he has been published. When this revision gets published we want to send out a different email.

I have tried many different things but I haven't been able to find a way how to determine if this was the first time the node is published or a subsequent publish. Can someone please point me in the right direction how this can be achieved?

Thanks


texts: Access field value in template_preprocess_views_view_field function?

texts:
I have a client with a Drupal 8 site who prefers curly quotes to straight quotes. I have successfully made this change for node titles using a regex replacement in template_preprocess_page_title. Now I am trying to accomplish the same thing for a different text field that is rendered by a view, using template_preprocess_views_view_field or template_preprocess_views_view_fields, but for the life of me I cannot figure out how to get individual field values using this function. Am I even trying the correct preprocess functions?

I have also tried rewriting the output of the field by accessing the variable in a custom twig template, with poor results.


texts: osx 10.7.5 built-in apache 403 forbidden for sites/default/files/styles

texts:
this really drives me crazy .. BTW here is a really nice tutorial i tried - everything. believe me ...
from adding users to groups, running apache as different user, chALOT -R (even chmod a+rwx), copying the original httpd.conf back, enabled UserDir, added attributes like

sudo chmod -R +a "group:_www allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit" Sites

but .. i'm not an expirienced sys admin // ---

i try to use both - WebServer and User location as Document root

setup
/etc/apache2/http.conf

setup
/etc/apache2/users/me.conf

and actually all seems to work fine. so AllowOverride and FollowSymLinks set

except: sites/default/files/styles/

image styles do not work i get 403 for requests like

sites/default/files/styles/fancy/public/animage.jpg

original images show up ..

maybe related to the 7.20 issue ?!

how can i properly debug this ?


texts: How do I create a dynamic query that filters on month and day?

texts:
I want to get the list of the nodes, whose content type is Donors, where the date in the field_data_field_donor_date_of_birth matches today (except the year).

How can I achieve it using a dynamic query or the EntityFieldQuery class?

This is the code I tried so far.

$query = db_select('node', 'node');
$query->fields('node', ['nid','title'])
  ->condition('node.status', 1)
  ->condition('node.type', 'CONTENT_TYPE_DONOR');

$query->innerJoin('field_data_field_donor_date_of_birth',
 'field_donor_date_of_birth'
, 'field_donor_date_of_birth.entity_id = node.nid');
$query->condition('field_donor_date_of_birth.field_donor_date_of_birth_value', $birth_date, '=');

$result = $query->execute();


texts: Site logo, utility menu and search box. Template or all css?

texts:
In the header, I would like to have a site logo on the left, utility menu in the middle and a search box on the right.

Should I just insert the utility menu as a block and style the rest via css? Or should I add regions or anything to the page template first and then style using css?


texts: drush migrate:status comes back with SQLSTATE [hy000] [2002] No such file or directory

texts:
Using drush on my macOS. Using Nginx and MYSQL through brew. Website is running fine. The other drush commands work fine, drush cr, drush cc, etc. But running drush migrate:status or drush ms results in

 error SQLSTATE [hy000] [2002] No such file or directory

in terminal. same for all migrate drush commands.

Running Drupal 8.8.5 Lightning Distro.

My settings.php is set up 127.0.0.1 but still no luck.


texts: Extra fields for edit form as opposed to front end

texts:
hook_entity_extra_field_info() allows adding arbitrary elements to the Manage display tab that also appear on the rendered node.

I want to add some section headings that appear on the node edit form and can be re-ordered on the Manage form display tab.

Is there a hook like hook_entity_extra_field_info() but that adds an element to the edit form as opposed to the front end?

I realise that I could achieve something like this with field group but would rather use a lighter approach with less overhead.


texts: Commerce Feeds - Taxonomy term processor Issue

texts:
Using Commerce Feeds version: 7.x-1.3

I am running the "taxonomy term processor". I have tried every available combination for "Update existing terms" (Do not update existing terms, Replace existing terms, Update existing terms . . . even Skip hash check - 'checked' and Skip hash check - 'unchecked').

No matter what I do, the csv import file that I am uploading just adds to what I have already imported. If I am uploading the same file and have added additional terms, I would think there would be a way of JUST adding the new terms, not duplicating everything again.

Am I missing something or is this a bug?

Thank you!

Tom


texts:
I am trying to adapt some code I have written in javascript outside Drupal to a Drupal module:

(function($) {
  Drupal.behaviors.myModule = {
    $(config.targetElement).html(config.template).promise().done(function(){
      initialize($(config.targetElement).attr('data-region'));
    });

    var initialize = function (region) {
      if (region in config.regions) {
        //Calls the API
        $.ajax({
          url: config.apiUrl + config.regions[region]
        }).then(function(data) {
          //Build a regional weather object and render it to the UI
          renderUI(buildRegionalWeather(data));
        });
      }
    };
  }
})(jQuery);

This code was working before I wrapped it in the Drupal behavior, but now it is broken. initialize() can't be referenced from within the promise callback.

I assume it has something to do with the intricacies of closures which to be honest I'm not that familiar with.

I had a similar problem with some other code where I ended up Doing like this:

(function($) {
  Drupal.behavior.myModule = {
    //Document ready code here...
  }
  Drupal.myModule = {
    doStuff: function() {
      //Some public function here...
    },
    doMoreStuff: function() {
      //Yet another public function...
    }
  }
})(jQuery);

Which works, but exposes every single function I write. In the above case it is not so much of a problem, but there are many other functions in the javascript-file I am trying to adapt which should not be exposed like that.

How should I be implementing this?


texts: How to change the default mail template for subscriptions module

texts:
It's probably a silly question but I just can't find the answer: Where can I change the default email template for the Subscriptions email? I'm using Drupal 7 and installed the module Subscriptions.

I would expect to change the mail templates at http://[mydomain]/admin/config/system/mail-edit. However at this location I only can add language translations for 4 languages which I've enabled but not the default email templates.

Can anybody point me to the right direction?


texts: Assign Fields programatically to custom node defined by custom module

texts:
Trying to convert a module from Drupal 6 to Drupal 7 which defines its own node type in hook_node_info.

Even though hook_node_info defines has_title and has_body to TRUE, how I can get these fields to appear on the node form? Previously, I used hook_form():

function mymodule_form(&$node, $form_state) {
  $type = node_get_types('type', $node);

  if ($type->has_title) {
    $form['title'] = array(
        '#type' => 'textfield',
        '#title' => check_plain($type->title_label),
        '#required' => TRUE,
        '#default_value' => $node->title,
        '#weight' => -25,
    );
  }

  if ($type->has_body) {
    $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
    $form['body_field']['body']['#rows'] = 5;
    $form['body_field']['body']['#description'] = 'Enter a short message to present to the user.';
  }

  return $form;
}

In D6, this worked fine for me. In Drupal 7, hook_form has changed, and I am not quite following the documentation of it.

How can I utilize the Body and Title Field in core and assign them to this node type when the module is activated?

Furthermore, how can I define a new Field type to mimic Body (Long text with summary) to something of my choosing?


texts:
When creating a content type, you have the option of adding a "file upload" field. How can I extend the functionality of this upload file to allow for the option of simply entering a URL instead of manually downloading the file and uploading it again? I basically want another field, called URL, where I enter the URL of the image. Drupal must then grab the URL as if though I uploaded it. Which means I must be able to "press upload" and actually see the thumbnail as per normal functionality.

I have a site from which we often grab images, but every time I first have to download it. It would save me a lot of trouble if I could just provide the URL and let Drupal do its thing.


texts: menu page callback cache expiration, headers

texts:
Drupal 7, custom module to output data in JSON format.

Task: create cacheable page that prints string in JSON format.

function examplemod_menu() {
  $items['json'] = [
      'page callback' => 'examplemod_json',
      'access callback' => TRUE
  ];
  return $items;
}

function examplemod_json($type='node', $id=0){
  header('Content-Type: application/json');
  print Examplemod::getResults('json', $type, $id);
  return null;
}

It works nice, page loads in ~200ms.

Then i enabled "Cache pages for anonymous users" with 1 minute "minimum cache lifetime" just for test.

Page loads in ~50ms. It looks perfect but...

Problems:

My custom page not updating after 1 minute. For example, all default pages node/* and etc. are updated after 1 minute delay.
Example: i visit some node page, it not loading from cache, then cache saved, and if i will refresh page again - it will load from cache. But if i will wait 1 minute or more and refresh page - it will not be loaded from cache.

So, i can't understand why my custom page every time are loaded form cache. I can wait 1 minute or more - refresh page, even multiple times - no difference - i see old version of my page loaded from cache. I didn't found any documentation about configuring menu page callback caching options. I think i'm doing something wrong.

When cache for my custom page is turned off, header "Content-Type:application/json" successfully sending, but if page loading from cache - header is "Content-Type:text/html; charset=utf-8". Can it be changed for cached pages?

Yes, i can turn off cache for this page with drupal_page_is_cacheable(false), but page will load slower...


texts: Drupal Crumbs can't get first "level" to show breadcrumb?

texts:
I seem to be having a problem with Crumbs and I can't seem to figure it out. I have it setup to show

crumbs.home_title
path
menu.hierarchy.main-menu
*

But it doesn't seem to show anything for the very first level, anything under that shows fine. I can't seem to figure out what is going on. At least it should show the Home title?


texts: Using a View's exposed Sort Criteria redirects to home page

texts:
I'm using the Content: Title Sort Criteria as part of a View and I've exposed that so that site visitors can sort results.

However, when (on the front end) I hit the Sort Criteria's "Apply" button I get redirected to the home page.

The URL does retain the sort critieria information, eg: mysite.com/?sort_by=changed&sort_order=ASC

It's just is missing the rest of the URL - the page name. It should be mysite.com/listing-page?sort_by=changed&sort_order=ASC.

Looking at the filter form's action attribute, I see it is set to action="/".

Would anyone know how to fix this?


texts: drupal_find_theme_functions called on every page - is our theme registry being rebuilt?

texts:
Our new D7 site was running very slowly so I did some profiling with devel/xhprof and found that D7 was doing millions of preg_grep function calls within drupal_find_theme_functions() in theme.inc. This happened on every page load.

It's my understanding that the drupal_find_theme_functions function should only be called when the theme registry is being rebuilt - am I correct in that?

I made sure that "rebuild theme registry" was off in devel, and then disabled devel entirely. However, I'm still seeing those millions of function calls to preg_grep in drupal_find_theme_functions on every page load (I added a piece of code to theme.inc to log when the function was called).

We're using a theme based on Omega and if we are rebuilding the theme registry each time I'm not seeing how/why it's happening. We're turning off as many contrib modules as we can in the meantime. Any help/advice would be MUCH appreciated!!


texts: 22762 rows in my session table. What does this mean for the site, and what should I do about it?

texts:
Ok so the title is pretty self explanatory. There's thousands of rows in the session table. I see that the Persistent Login module is enabled. I don't know if this affects how the sessions are stored. Also, I note that 100+ users are quoted as being visitors at any one time, which seems very excessive for the user base and niche content of this site.

Please can someone advise the best course of action here? I assume I can truncate this table locally, but what's the long term action plan look like?


texts: #default_value for select form elements does not work

texts:
<?php
namespace Drupal\dishes_dropdown\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Drupal\Component\Utility\UrlHelper;

/**
 * Desarrollo de un formulario en drupal 8
 *
 */
class DishesDropdownForm extends FormBase {

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

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

        $maxlength = 250;

        $tax_terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree('dish_type', $parent=0, $max_depth=NULL, $load_entities=FALSE);
        $taxs = array();
        foreach ($tax_terms as $tax_term) {
            $taxs[$tax_term->tid] = $tax_term->name;
        }

        $form['dish_dropdown'] = array(
            '#type' => 'select',
            '#options' => $taxs,
            '#chosen' => true,
            '#multiple' => false,
            '#maxlength' => $maxlength,
            '#default_value' => $form_state->hasValue('dish_dropdown') ? $form_state->getValue('dish_dropdown') : '' ,

        $form['submit'] = [
            '#type'  => 'submit',
            '#value' => $this->t('Ir al tipo de plato'),
            '#weight' => 50,
        ];
        return $form;
    }

    /**
     * {@inheritdoc}
     */
    public function submitForm(array &$form, FormStateInterface $form_state) {
        // Display result.
        $id = reset($form_state-> getValues('dish_dropdown'));
        $aliasManager = \Drupal::service('path.alias_manager');
        // The second argument to getAliasByPath is a language code such as "en" or LanguageInterface::DEFAULT_LANGUAGE.
        $alias = $aliasManager->getAliasByPath('/taxonomy/term/' . $id);

        $url = new TrustedRedirectResponse($alias);
        if (isset($url)) {
            $form_state-> setResponse($url);
        }

        return;

    }
}

I do not load the "default_value" in select. I have tried a thousand ways in the "build" but there is no way. I want a blank default value but without forcing it load it. It's like if you read the "default_value".


texts: How do you export forum topics from one drupal installation to another?

texts: I have tried to export a list of forum topics and/or containers from my development environment to production using features, strongarm, migrate, node_export and bulk_export. So far none have worked. Am I doing something wrong or is this not possible via contrib modules?


texts: How do I modify default labels of the location module?

texts:
How can I modify the field names of the location widget that I use to collect addresses and phone numbers. I am using Drupal 7 with the Location Module: https://drupal.org/project/location

Below a screenshot of the fields I would like to rename ('Street Location' to 'Address Line 1' as an example).

Thanks!


texts: Need advice on remote storage for load balanced drupal site

texts:
Not quite sure if this is the correct thread to be posting this in, so please feel free to move it if its not.

Background:

Our developers have nearly finished developing our Drupal 7 based web application and as with any start up, I am assuming the role of the sys admin, financial controller and everything else under the sun! My experience with Linux is limited to what i've been able to learn through the internet i.e - install and configure apache, mysql, php, memcache, varnish etc.

Current set up:

After having spent the best part of 4 weeks stress / load testing various cloud service providers we ended up with Google Cloud.

2x web servers (8 cores + 7.5gb ram each) running:
- Ubuntu 14.04 LTS
- Apache 2.4 (mpm_event + PHP_FPM)
- Memcache 3.0

1x database server (4 cores + 26GB ram) running:
- MySQL 5.6

1x Load balancer for the two web servers

Problem:

I'm now at the part where I need to decide how / where to run the filesystem for our load balanced Drupal application. As you all know, Drupal stores assets by default on the local disk /sites/default/files. Now, obviously this isn't going to work with a load balanced solution since files that are written to server 1 will not be available to be served from server2.

Potential solutions?

These are the following potential solutions I have thought of:

1) Use the Amazon S3 module for Drupal which allows the application to both write and read from an S3 bucket. This seems to be the easiest solution, but i'm a bit reluctant after having spent a lot of time configuring my servers for speed and performance. That extra bit of time its going to take Drupal to write to S3 is what worries me and the fact that I have less control over the situation.

2) This is where my inexperience in terms of implementation lacks, but the second option would be to spin up another instance, mount it to the servers (is it possible to mount another server to both web servers??). Then change Drupal so that it writes to that mounted filesystem. (This seems more performant, but not sure whether possible and certainly a more complex task).

3) Use rsync between the two web servers. Again, my experience with rsync is very limited and i'm not sure whether it would be able to read / write fast enough.

So, that is my current dilemma. And any input whatsoever would be greatly appreciated.

Thank you!


texts: reseting the hook_update_n status of a module

texts:
I'm extending a module I've previously written and it needs some schema changes which I implement in hook_update_N.

I've updated the module's version from 7.x-1.0 to 7.x-1.1 and implemented the foo_update_7100 and it works fine.

The problem is that I've made a mistake inside foo_update_7100 and now that I've fixed it I cannot rerun the 7100 update. I need to create a 7101 one but that doesn't make sense because all my changes are not committed yet.

I've tried reseting the status of the hook_update_n via:

update system set schema_version=-1 where name='foo';

> Query OK, 1 row affected (0.01 sec)
> Rows matched: 1  Changed: 1  Warnings: 0

Then I do drush cc all but drush updatedb -y still gives me "No database updates required".

How can I solve this instead of simply incrementing the hook_update_N number?


texts: I would like to redirect users after they log in. Is it possible to use hook_user_login() to make the redirection? How do I add the parameter for the redirection?


texts: How can I improve as a site builder for dealing with errors I don't know how to handle?

texts:
As a relatively new Site Builder, I understand some of what is going on under the hood. But when things go wrong .…

Without an intimate knowledge of module code and inner workings, the error messages often simply tell me something went wrong.

Furthermore, I don’t know if a particular message occurred from the action I just executed, or if I have simply not been to a specific page in a while (or never before), in which case any number of actions could have broken it.

In any case, I have no idea what messages like this one mean:

'Notice: Undefined index: var_name in _some_method_some_where() (line 35 .…'

This are the steps I typically perform (my workflow) to resolve an error:

Check the module's issue queue for known bugs –  Occasionally I find a known problem.
Google the error – Normally this doesn’t help as the same error could happen for so many reasons, but occasionally it leads me to a fix.
Ask a developer if possible – They often have no idea about my problems …
Ignore the error and keep working.
If my site is really broken, I try to reset (ugh) or give up on the module altogether and do something else (sigh).

As a site builder, I really don't want to dive into the code every time.

How can I improve my workflow? Like what other steps, resources, approaches, etc would you recommend to a site builder when such kind of things go wrong?


texts: drupal_render($form) not rendering a form

texts:
I wonder if anyone has found a solution to the problem I'm seeing.  I've built a very simple "beginner's form" in drupal.

function simple_nameform() {
    $form = array(
        '#method'           => 'post',
        '#prefix'           => '
',
        '#suffix'           => '
',
        'your_name'         => array(
            '#title'        => t('Your Name'),
            '#type'         => 'textfield',
            '#description'  => t('Please enter your name')
        ),
        'submit'            => array(
            '#type'         => 'submit',
            '#value'        => t('submit')
        )
    );
    return $form;
}

I've put this form in a module, with info, I've enabled the block in admin.  When I'm on the main page render I run the commands

Send to a Friend

    <?php
        $output = drupal_get_form('simple_nameform');
        drupal_render($output);
    ?>

<?php // debug purposes only
          print_r($output);
    ?>

The form does not appear to render from the "drupal_render" line, however, the $output variable is most definitely full of something that looks very much like it might be a drupal form.

(it's a huge array filled with my form elements.  at parts it even manages to render some of the elements to page correctly).

Anyone with an idea of what I've missed?


texts: How can i pass JavaScript variables back to PHP Controller in Drupal 8

texts:
I have a custom module which uses a Javascript library called Bootstrap Table. Among other things, this library allows me to create tables with clickable rows. Currently, I can pass variables from the PHP Controller into the Javascript library. These variables are used to feed the fields in the table.

What I want to do next, is to define an event (when a row is clicked) which would then return the value of the row and pass it back to the PHP controller.

The controller would use this returned variable to perform some specific action and update the information displayed in the table.

As far as I know, I should use AJAX, but so far I have not been able to accomplish what I want.

This is some of the info I have found.

https://www.drupal.org/node/2833416

How do I pass JavaScript variables back to PHP?

controller function use with ajax


texts:
Since two weeks I have replaced my optical hard drive with an SSD for my OS and all my applications while I kept my hard drive for data. So I've installed MAMP on my SSD and my Drupal directory (workspace within Eclipse) is on the Macintosh HD.

So,
Path to MAMP: /SSD/Applications/MAMP
Path to Drupal: /Macintosh\ HD/Users/me/Documents/workspace/drupal

I've put the drush folder /Macintosh\ HD/Users/me/Documents/workspace/drush and drush is working just fine, but for some reason, whenever I download a module by using drush, the module ends up in my homefolder while it should be using my Drupal folder I think, right?

How can I fix this and make drush work with my Drupal directory?


texts: Changing the link title in a view for generic file

texts:
I have a bunch of files that are displayed in a view; i'm using 'generic files' setting to display them; the problem is that some files have really ugly names like '1002-32-eda.pdf' i'd like to change the name to 'download' but keep the 'mime' detection (small icon on the left side; like pdf, word etc).

Any example on how to change this ?


texts: error: Fatal error: Class 'Drupal\syslog\Logger\SysLog' not found in /lib/Drupal/Component/DependencyInjection/Container.php on line 272

texts: I just activated the module syslog in an almost fresh D8 install and now it has crashed. =( How do I deactivate a core module like this manually or fix the issue?


texts: Create a menu block based on path using views

texts:
I'm trying to use views 3 to create a view that I can place in a block that is based on the url path

For example

example.com/student/
example.com/student/page1
example.com/student/page2
example.com/student/page3

All 4 pages are in the menu along with other pages
Students
   page1
   page2
   page3

I want to create a view that will display (dynamically) on pages with the following url pattern example.com/student/*
I want the view to only return child menu items that have Student as a parent.

I'm working with menu view, but I can not get the contextual filter and relationship to work correctly.  Any tips. Or an alternate way to accomplish


texts:
While sending registration success e-mail in Drupal system, I want to update "from" element.

Ex:
My admin e-mail is "hello@gmail.com".
While sending e-mail to user, I want to change it as "Myname <(hello@gmail.com)>"

Can we do it through hook_mail_alter?

I have tried below code. But din't work as expected.

function mymodule_mail_alter(&$message) {
 print_r($message); // I din't get any response here
}

Want to append Name before email ID.

Edit: hook_mail_alter its not triggering neither module nor template.php. Module is enabled. I have cleared cache too.

Existing comment : https://api.drupal.org/comment/59119#comment-59119


texts: Full archive configuration export doesn't work

texts:
When I go to /admin/config/development/configuration/full/export and want to export the full archive, the site loads for a while and then just goes completely blank and the URL bar shows /admin/config/development/configuration/full/export-download.

There is no error in the server log files and no entry in the Drupal reports.

In the sync directory sites\default\files\config_[...]\sync there is no file except for the .htaccess.

And when I try drush cex or drush cex sync this error occurs:

PHP Fatal error:  Declaration of Drush\Command\DrushInputAdapter::hasParameterOption($values) must be compatible with Symfony\Component\Console\Input\InputInterface::hasParameterOption($values, $onlyParams = false) in C:\Program Files (x86)\DevDesktop\tools\vendor\drush\drush\lib\Drush\Command\DrushInputAdapter.php on line 27

I've tried everything with the settings.local.php enabled and disabled. But the export just doesn't work. What can I do?


texts: Page not found - Even after I implemented Hook_Menu()

texts:
I have implemented hook_menu() & called a function, but if I am trying to browse the page URL it's giving me "Page not found" error...

This is the code --

function user_type_registration_menu(){
  $items = array();
    $items['paypal/payment/ipn'] = array(
          'title' => t('Paypal Payment IPN'),
          'description' => t('Paypal Payment IPN'),
          'type' => MENU_CALLBACK,
          'page callback' => 'paypal_payment_paypal_ipn_callback',
          'access callback' => TRUE,
        );
      return $items;
}
function paypal_payment_paypal_ipn_callback(){
  dpm("here");
}

I have cleared the cahche too..so cahche can't be the problem...


texts:
I'm having trouble attaching a library using the new #attached mechanism in Drupal 8. Is there an easy way to debug and see which libraries Drupal is trying to load, and possibly, what goes wrong?

Motivation

In a form class, I'm returning a large render array. One of the elements has an #attached property:

$form['contact'] = array(
    '#type' => 'fieldset',
    '#title' => t('Contact'),
);
$form['contact']['#attached']['library'][] = 'my_module/contact';

In file my_module.libraries.yml:

contact:
  version: 1.x
  css:
    theme:
      css/contact.css: {}

I'm suspecting that contact.css is either not found, not loaded, or altogether ignored. Therefore I'd like to follow the process in which Drupal loads the library and integrates it into the page.


texts:
Basically I need to redirect this page

http://website/?q=user
to
https://website/?q=user

I tried adding a redirect rule to the .htaccess file in /var/www/html/ but that didn't work. From what I know ?q=user is more of an argument then a page. How can I achieve this?

Any help would be greatly appreciated.


texts:
I am using Drupal 7.43, and I want to read my data from an external database every 15 minutes. My site is hosted on an Ubuntu server.

I am using Feeds importer with SQL parser. From import/feed_from_feed_db, all data is correctly imported; so, the importer runs correctly.

How can I set the feed importer to automatically run every 15 minutes?


texts: Make a picture display images if a CCK checkbox is checked

texts:
I am creating a website in which, there is a view that displays content, and then several icons. theses icons tell the user weather something is available, for example, the icons on this site show you that there is no sound available to listen to, but there is a video to watch. the icons are as follows:

The "find it" and the video buttons are black, but the rest of the buttons are grayed out. (They are actually displaying two different images depending on weather or not there is something to link to.) The reason that they are grayed out is that there is nothing available for them to link to.

What I want is something very similar; I want several icons that will be either grayed out or black, depending on weather or not a checkbox in one of my CCK fields is checked.

How would I go about doing this? Can I do it with a view? Is there a script that I can use?


texts: String Override limited to certain pages?

texts:
I'm using the Fivestar module on different areas of the site. It displays "x votes" below the rating widget.

On some areas on the site it would like to change "votes" to "reviews". How could I do that?


texts: Adding "onclick" event to links in text areas

texts:
I need some help getting and "onclick" event onto some links in a couple drupal pages.

I've got 2 pages, each with a text entry field set to "full HTML", within which I've added my a tags.
the links work great in this format, however when I try to add my onclick event (which contains jquery info for analytics tracking), the only thing I see when I inspect element is the text "onclick" and nothing after it. Not even the " =" ", which would suggest a script error.

When that didn't work I added a class to the A tags and tried to use jquery to append the onclick attribute with these jquery functions:
setAttribute
attr
click

While it sounds simple none of what I've tried has worked (I had used both setAttribute and click successfully on other links), so now I'm looking for a new method.
the module Menu attributes doesn't work since it doesn't deal with "onclick" and my links are not menu items, they are just links in text.

I'm using Drupal 6.19 and jquery update.

If anyone has advice or suggestions, please let me know,

Thanks
Steph


texts: Unable to import date from csv with Feeds module

texts:
I have a simple csv file I'm trying to import with feeds.  Most of the fields are going in just fine, but the dates are failing.  And after following the process through in a debugger, I cannot see why this fails - the date exists when Feeds saves the node, so why does this fail?.

Above: This screenshot of my debugger shows that entity has date information immediately after entitySaved is called.  I cannot detect anything unusual about the object format - looks kosher.  The date was added as the field_deadline_proposals:end. A date can be a range, so I assume this is the proper way to save a single date (non-range).

Above: This is a screenshot of the database table for field_deadline_proposals immediately after node save.  Node 258 does not have the information I expect.

This is the relevant excerpt from my csv doc, with headers:

id,rfp_num,description,title,published,rfp_filename,response_deadline,QA_deadline,mod_date,create_date
4,034-009  Robinson Pkwy,"Robinson Pkwy -Walkthru 6/22/09  9:30am.  Log onto the website for more information. Due date has been moved to 7/6/09  11:00am",TRUE,RFP_034-009  Robinson Pkwy_034-009_doc.pdf,7-6-2009 11:00,29-06-2009 13:00,7-1-2009 13:50,19-06-2009 9:29

My dates are currently in d-m-yyyy hh:mm format, which seems to work just fine and was recommended in this related post.  Frankly, I don't think the date format it much of an issue - I have had success with other formats, including using feeds_tamper to convert the date to UNIX timestamps.  In all cases, though, the save fails, so I suspect some other issue :-/


texts: What Causes DatabaseTransactionOutOfOrderException and how do I fix this?

texts:
I am working on plugin to Drupal Commerce, and I started getting this error:

DatabaseTransactionOutOfOrderException: in DatabaseConnection->rollback() (line 1058 of /Library/WebServer/Documents/includes/database/database.inc).

Can anyone shed some light on what this error means? If I install a fresh drupal and reinstall my plugin, is that likely to clear things up?

Any advice?

Thanks!


texts: Query condition that needs to return true no longer working

texts:
I'm working on updating our sites to D9. One of our custom modules stopped working and I narrowed it down to this bit of code that modifies some query conditions for a view filter. It's trying to set a condition that always returns true (i.e. 1 = 1).
function views_taxonomy_filter_process_query_conditions(array &$conditions, $field) {
  foreach (Element::children($conditions) as $key) {
    if ($conditions[$key]['field'] instanceof ConditionInterface) {
      $child = & $conditions[$key]['field']->conditions();
      views_taxonomy_filter_process_query_conditions($child, $field);
    }
    elseif (strpos($conditions[$key]['field'], $field) !== FALSE) {
      // We cannot just unset the condition, because this action might create
      // incorrect query. Let's replace it with 1 = 1 condition.
      $conditions[$key] = [
        'field' => 1,
        'value' => 1,
        'operator' => '=',
      ];
    }
  }
}

This worked fine in D8. However I'm now getting this error as it seems to be looking for a column called 1 instead of evaluating that condition:
Drupal\Core\Database\DatabaseExceptionWrapper:
SQLSTATE[42S22]: Column not found: 1054 Unknown column '1' in 'where clause'

How can I change this to restore the old functionality? Thank you!


texts: How to redirect a newly registered user to a custom URL after signing up?

texts:
By default after a new user signs up, a redirect to the home page happens.

But in such case I want to redirect such user to another page like node/35.

In this node/35 I then want to display some content.


texts:
I have a custom module where I need to create a file and download it on form submission. So far, I managed to created the file and save it in public folder, but I cannot find a way to download it to client. This is the code I wrote so far.

public function submitForm(array &$form, FormStateInterface $form_state) {
  $file_name = $date.'-event.ics';
  $cal_file = file_unmanaged_save_data('file content',"public://cal/$file_name",FILE_EXISTS_RENAME);
  return new RedirectResponse(file_create_url("public://cal/211443-event.ics"));
}


texts: Use custom forms instead of web-form and content type in Maestro drupal

texts:
There is a requirement that we can't use content type and webforms with maestro, and have to use a custom form module (a newly created module having a simple form).

Normally maestro module uses content type, so first we create a content type and then we can use it in  content type task, if we go content type task->edit->select a content type for this task, we can see the list of all created content types here.
Similarly, if we don't want to use content type we have another option,that is to use web form, for that we will be needed another module called maestro_webform_task,here first we need to create a web form using webform module and then we will create a web form task  in template, if we follow the same path  i.e. web form task->edit->select a webform to use for this task, we will see the list of all webforms in select list.

here in 2. nid of created webform is passed to intermediate module maestro_webform_task and it's job is to make the webform available to select in select list of webform task.

As discussed instead of content type and webform I have a custom module(it contains a simple form ) and i want to use the form of that module to be available in the webform task select list.

How can I achieve this, or is there a module in Druapl 7 which allow me to do this?


texts: How to setup Drush core development environment?

texts:
I would like to create a PR against Drush, so one of the core commands has additional options. But I'm not really sure, how should I setup my development environment, so I'm not losing my time moving code between my site-specific Drush and master branch I checked out elsewhere.

I see that Drush contains docker compose file (https://github.com/drush-ops/drush/blob/master/docker-compose.yml),  but the wodby/php image apparently doesn't contain Drupal Core. I wasn't able to find any tutorial about this.


texts: Custom checkout pane for order comments not saving

texts:
I've created a custom checkout pane for commerce 2.x, Drupal version 8.7.x. I've added a textfield called field_order_notes on the order entity. The pane works, and I can run
$this->order->set('field_order_notes', $values) in my pane's submit handler, and I can debug the order object and see the value's set. But when i finish the order,  field_order_notes is empty on the order. Not sure what I'm missing here.

 /**
 * Adds a section for order notes.
 *
 * @CommerceCheckoutPane(
 *   id = "order_notes",
 *   label = @Translation("Order notes"),
 *   default_step = "order_information",
 * )
 */
class OrderNotes extends CheckoutPaneBase implements CheckoutPaneInterface {
  /**
   * The inline form manager.
   *
   * @var \Drupal\commerce\InlineFormManager
   */
  protected $inlineFormManager;
  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, CheckoutFlowInterface $checkout_flow, EntityTypeManagerInterface $entity_type_manager) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $checkout_flow, $entity_type_manager);
  }
  /**
   * {@inheritdoc}
   */
  public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
    $pane_form['order_notes'] = [
      '#type' => 'textarea',
      '#title' => $this->t('Order notes'),
      '#default_value' => $this->order->get('field_order_notes')->getString(),
      '#required' => FALSE,
    ];
    return $pane_form;
  }
  /**
   * {@inheritdoc}
   */
  public function submitPaneForm(array &$pane_form, FormStateInterface $form_state, array &$complete_form) {
    $values = $form_state->getValue($pane_form['#parents']);
    $this->order->set('field_order_notes', $values);
  }
}


texts: How to add additional "items" on a webform in Drupal 7

texts:
I would like to provide the option of creating additional text fields under the same Label, if necessary. In the form of an "Add another" button. So when this button is pressed, an additional textfield will appear underneath. So, much like adding unlimited attachments to a node for example.

Is this possible using the Webform module?


texts:
I created a secondary navigation that I display with $secondary_menu in page.tpl.php. It seems to work fine, however, it displays on every page now and I of course don't want that, it should only show on a specific page (where I have a secondary navigation). Now in order to achieve this, am I creating a special page template for the page where I want to show the links or can I somehow set on which pages my secondary navigation should show up?

Thanks!


texts: Migration from one domain to other domain

texts:
I have build a D8 website on domain www.example.com/abc and now wants to copy this site to www.example.com/xyz

Hosting is same

What I did is:
1) copied all files from abc to xyz.
2) Exported Database from abc and imported it to xyz.
3) Assigned new Database name, Username and Password to xyz in settings.php.

When I go to www.example.com/xyz Homepage looks perfect but when I go to inner pages it takes me back to domain www.example.com/abc.

How should I update the URLs?


texts:
I'm building a mobile website with Drupal 7 and I need to filter articles displayed using Views by visitors mobile OS. If visitor is using Android phone - I would like display only articles with "Android" tag, etc. Visitors with "other" mobile OS'es will get "no results" message.
What is the best approach to accomplish this task?


texts: Passing Node Variables to Content and Blocks

texts:
I'm really struggling with how to get variables created in page.tpl.php and node.tpl.php in rendered content and blocks. I hope I'm just missing something simple.

Basically, I'm trying to have a unique ID number passed around the site. To do that (as far as I know) I need to add it to all the links, IE /?a_uid=123456.

I'm generating the random ID in success_preprocess_page (full code is below).

function success_preprocess_page(&$variables, $hook) {
  //echo '
'; print_r($variables); echo '
';\

        if (isset($_GET['utm_campaign']))
            $adkey = $_GET['utm_campaign'];
        elseif (isset($_POST['utm_campaign']))
            $adkey = $_POST['utm_campaign'];
        else
            $adkey = NULL;

        if (isset($_GET['a_uid']))
            $a_uid = $_GET['a_uid'];
        elseif (isset($_POST['a_uid']))
            $a_uid = $_POST['a_uid'];
        else
            $a_uid = NULL;

    if ($adkey != NULL)
    {
        $a_uid = "123456";
    }
    $variables['adkey'] = $adkey;
    $variables['a_uid'] = $a_uid;

   if(isset($variables['a_uid'])){
    // add the flag to the node to say it's been set and there is only a single node to display
       if(isset($variables["page"]["content"]["system_main"]["nodes"]) && count($variables["page"]["content"]["system_main"]["nodes"]) == 2){
            $keys = array_keys($variables["page"]["content"]["system_main"]["nodes"]);
           // Set a new variable called sidebar_first equal to true on the node.tpl level
           $variables["page"]["content"]["system_main"]["nodes"][$keys[0]]['#node']->a_uid = $a_uid;
      }
    }
}

Any links that are in page.tpl.php, ex:

<a href="programs/?a_uid=<?php echo $a_uid; ?>">Programs

Display the correct $a_uid variable result of 123456.

And if I try to echo $a_uid in node.tpl.php, ex:

<?php $a_uid = $node->a_uid; ?>
<?php //echo 'A_UID: '.$a_uid.'

'; ?>

Also displays 123456 fine.

But if I try anything like this in my content pages (even with them set as PHP Code Text Format, which correctly processes other PHP code), everything result is blank.

For instance, I currently have a content page that has this in it, trying to hit all the marks I can think of:

<?php echo $a_uid; ?>
<?php print $a_uid; ?>
<?php echo $node->a_uid; ?>
<?php echo $content->a_uid; ?>
<?php print $node->a_uid; ?>
<?php print $content->a_uid; ?>
<?php print ($page['a_uid']); ?>
<?php print ($node['a_uid']); ?>

Not a single one of those displays anything.

As far as I can tell it seems like the variable is just not getting passed to the content? I just don't understand why, or how to fix it.

I assume this is standard, but this is how my content is being called in node.tpl.php:

print render($content);

I am also having the same problems in my header and footer blocks. Those are being called from page.tpl.php as:

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

Any help with this would be greatly appreciated. Thanks! Oh and 123456 is just a placeholder in here for my random unique ID generator code :)


texts:
I am unable to run cron on a Drupal 6.25 web site.

Running cron using both the run cron option from administration menu and the run cron manually link from status report page results in the following message:

Caches flushed.

The warning message next to the cron maintenance tasks entry on the status report persists and cron hasn't run.

I recently upgraded to latest version of Drupal. This issue also affects development copy of web site.

As always, I ran update.php after upgrade - no errors reported.

Tried changing number of items at /admin/settings/search to 10.

Can anyone advise how to fix the problem?


texts: Is it normal that a site changes to maintenance mode during a module update?

texts:
I have created a custom module with a .install file, which includes some hook_update_N() hooks, used to update existing nodes.
Whenever I run drush updb, the site automatically enters maintenance mode (anonymous requests get a 503), and if the update is successful, the site goes back online, all by itself.
I couldn't find any resource on the web about this situation.
Is it normal? Is there a way to disable this behavior?


texts:
I want to allow my site users to create stores,, in which each store can contain content.
so the store is basically a page which contain specific content.

what's the best way to implement this in Drupal?


texts:
I have an entity reference inside node. How can I retrieve the parent node?

I tried with the following code, where $node is my entity reference, but it doesn't work.

$entity_ids = $query
    ->condition('type', 'user')
    ->condition('status', 1)
    ->condition('field_product_document', $node->getTitle(),'CONTAINS');

What is wrong in the code? What code should I use?


texts: User cannot view their Orders in Ubercart

texts:
For Drupal (v7.22) I have a basic install of Ubercart (v7.x-3.4) and have set the permissions to allow an authenticated user to 'View own orders' and View own invoices'. But if an authenticated user visits an order page (for an order they made) they get the error:
page: example.com/user/user_name/orders/1

Access denied
You are not authorized to access this page.

I've been though all of the settings and googled this but cannot see what I've missed. Does anyone know if I've missed a permission/setting somewhere?


texts: So a site in production wants certain aliases to be redone. If there's another way to do this other than Home » Administration » Configuration » Search and metadata » URL aliases > Delete aliases, please let me know. I dont want to run that if it's going to break the site since it is in production. I can always rebuild using Bulk Update > Content Paths after Delete aliases . Please advise. Thanks.


texts: In hook_form_alter(), how can I access the entity that is being flagged?

texts:
In hook_form_alter(), I want to load the entity being flagged so that I can do some processing based on the field values of that entity.
However, I can't find an entity object using kint($form).  I know it must be there somewhere because the flag is correctly attached to the entity.
function MYMODULE_form_flagging_MYFLAG_add_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  kint($form);
  kint($form_state);
  // Where is the flagged entity object id?
}

On the flagging object, after the flagged has been saved, the entity id can be accessed like this:
    $flagged_entity_id = $flagging->get('entity_id')->value;

However, in hook_form_alter(), when the flag has not yet been saved for the first time, I can't find the entity_id in $form.
I thought it might be in $form_state, but I got a NULL result for $form_state->get('entity_id').


texts: Is there a trick to deploying Commerce Kickstart 2

texts:
When I deploy my commerce kickstart 2.0 site, it doesn't display correctly.  Namely, it doesn't seem to be using the themes.  But really, I am not sure what is going on.  I have done development using Acquia Dev.  I exported my database using the Backup and Migrate module.

This is the site
http://twelvebasketstech.com

I can't even log in, but it is accessing the database because I see some of my product categories.

I am using PHP 5.4.  The server is running the following: Server version: Apache/2.4.12 (Unix)
Server version: 5.5.42-cll MySQL Community Server (GPL)

I have set the sites/default/files folder to chmod -R 775


texts: Configuring Drupal 7 settings.php with both Memcache and Varnish

texts:
I am noob to using both Varnish and Memcached. I have been following some copy and paste install guides.

I have both servers installed and running. Memcached seems to be working fine. Varnish is serving pages but there are a lot of cache misses. I am trying to enable the Drupal module to make Varnish aware to cache the pages, the css etc.

However, when I copy the settings.php snippet from the README.txt file in the Varnish module to my own settings.php I get a white page and this message in the Apache error log:

PHP Fatal error:  Class 'MemCacheDrupal' not found in /var/www/myhost/includes/cache.inc on line 31

Here is the cache section added to my settings.php. The Varnish part is commented out because it causes the above error with MemCached.

# Memcache
$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
// The 'cache_form' bin must be assigned no non-volatile storage.
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['memcache_key_prefix'] = 'myhost';
# Varnish
// Add Varnish as the page cache handler.
#$conf['cache_backends'][] = array('sites/all/modules/contrib/varnish/varnish.cache.inc');
#$conf['cache_class_cache_page'] = 'VarnishCache';
// Drupal 7 does not cache pages when we invoke hooks during bootstrap.
// This needs to be disabled.
#$conf['page_cache_invoke_hooks'] = FALSE;

What is wrong with the Varnish snippet or with my setup in general?

I tried re-ordering to put the Varnish lines before the Memcached lines and I got this error:

PHP Fatal error:  require_once(): Failed opening required '/var/www/myhost/Array' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/myhost/includes/bootstrap.inc on line 2308


texts: How do I declare my custom entities as non-multilingual?

texts:
I have written a custom module providing two custom config entities holding data, that is not language-specific. But I can't seem to find a way to tell Drupal, that there is no need to "translate" these entities - in fact, I get this action offered on every entity listing.

Even all core entities I found so far implement translation, but some provide their own translation handler. (Is this maybe a way to do it? Implementing a custom translation handler that tells Drupal not to translate anything? But how?)

Is someone out there who can point me in the right direction please?

My actual annotation look like this (please notice the "translatable" option, which is not working):

@ConfigEntityType(
  id = "ad_tag",
  label = @Translation("Advertisement tag"),
  module = "field_vimeo",
  config_prefix = "field_vimeo.ad_tag",
  admin_permission = "administer site configuration",
  translatable = FALSE,
  handlers = {
    "storage" = "Drupal\field_vimeo\AdTagStorage",
    "list_builder" = "Drupal\field_vimeo\AdTagListBuilder",
    "form" = {
      "default" = "Drupal\field_vimeo\Form\AdTagForm",
      "delete" = "Drupal\field_vimeo\Form\AdTagDeleteForm"
    }
  },
  links = {
    "edit-form" = "/admin/structure/field_vimeo/ad_tags/manage/{ad_tag}",
    "delete-form" = "/admin/structure/field_vimeo/ad_tags/manage/{ad_tag}/delete"
  },
  entity_keys = {
    "id" = "id",
    "type" = "type",
    "label" = "label"
  },
  config_export = {
    "id" = "id",
    "type" = "type",
    "label" = "label",
    "data" = "data"
  }
)


texts: Search Api, fulltext and string for search bar and facets

texts:
I'm trying to figure out how to make and indexed field (City) play nice with fulltext search exposed filter and a facet term.

As of right now, a fulltext option works with the search bar, but splits 2 word cities into separate facets. And string combines multi-word cities into one facet, but then breaks the search bar.

What setting will work for both?


texts: How do I create or modify a custom filter?

texts:
I'm following the docs here to create a custom filter.

The first sentence says:

  Go to Custom Filters (/admin/settings/customfilter) (6.x & 7.x)

However, that link just redirects me to the overall admin menu page (looks the same as if I go to /admin). What am I doing wrong?


texts: Custom Path Alias with Initial Letter as Token

texts:
For various reasons, I need to change my custom path alias for a taxonomy type as follows...

FROM:
/composers/aardvark

TO:
composers/a/aardvark

So I'm looking at either creating a custom token, or a computed field to figure out the first letter of the term and feed into the pathauto module...

I'm having trouble figuring out either... Could anyone suggest the correct code to use for either of these? Most of the examples I am finding are node specific, and not taxonomy term specific...

The reason I'm looking to do this, is to provide a contextual filter to a views block... But if anyone could suggest a good way to pass 'a' from 'aardvark' into the block - so that both of these paths passes the same contextual filter, that would be equally good!

/composers/a

/composers/aardvark

Thanks in advance for your help!


texts: HTML special characters changed to foreign characters

texts:
We have a Drupal 6 website and are using tinymce for the editor. Many of our pages included the pound (£) sign as well as other special characters. All of these have now been changed into foreign symbols. The pound sign now appears as Â£ and other strange symbols such as â€“.

I've checked the source code and the original characters have been changed into the strange new characters. It seems like the only way to fix it is to manually edit all the pages. I checked the character encoding tag and this is set to utf-8.

Can anyone help with why this might have happened in one go? The only thing I can attribute it to is possibly running update.php. Also, is there an easier way to convert then all back again?

Many thanks,

Ben


texts: javascript code does not execute for authenticated users

texts:
Maybe someone of you has already encountered this weird problem that I am having. I have javascript code that runs fine when you are an anonymous user and no longer works when authenticating. The library is loaded, but the code does not execute. Does this speak to anyone?
My drupal version is 8.9.2 and the code in question :
(function ($, Drupal) {
Drupal.behaviors.toto = {
attach(context, settings) {
  $('.block--toto ul', context).once('toto-behavior').each(function() {

      let toto = $('.block--toto ul');
    let istotoActive = toto.find('li.is-active');

    toto
      .wrap('

')
      .closest('.dropdown')
      .prepend('<button href="#toto" class="dropdown-toggle" data-toggle="dropdown">' + istotoActive.attr('hreflang') + '</button>');

    toto
      .addClass('dropdown-menu')
      .find('li').addClass('dropdown-item')
      .find('a').addClass('dropdown-link');
    $('.block--toto li').each(function () {
      $(this).on('click', function () {
        $(this).closest('.dropdown')
          .find('.dropdown-toggle').text($(this).text())
      })
    })

  });
}

};
})(jQuery, Drupal);
Thanks for help


texts: Backup & Migrate scheduled backup silently fail

texts:
I've tried to use backup & migrate for backups on my omega8 based aegir server.

Although I've defined a schedule, and setup cron interval to 1 hour, it doesn't work - no backups are generated. Scheduled backup silently fail.

Attached is a screenshot of the current schedule:

Notes:

Module's permissions are default (all marked V for admin).
Backup profile is the default as well.
I'm using Drupal 7. Module's version is 7.x-2.7

Any idea?


texts: is it ok to manually remove menu_links entries from db?

texts:
To my surprise, I removed one menu item from the main menu, and it correctly dissapeared from the admin ui, but there still is an entry in the table called menu_links. There is nothing unusual about the entry. How does drupal know it should not be used ? Can I manually remove it ?

The problem is, I use custom code that traverses the menu_links table to generate an alternative menu. This custom code just sees the menu item and keeps on displaying it in the alternative menu. So, is that approach wrong ?


texts: Attach JavaScript and CSS assets when render entity using Web Sockets

texts:
Goal:

Attach all the necessary JavaScript and CSS files to the page, when a rendered entity is delivered on a Web Socket event.

Given:

I have a Web Socket with an event when a new entity is created (Via pusher.com but nevermind).
The Web Socket delivers JSON with some meta-data(entity id, created date, title, etc.) and HTML of a single rendered entity.
I catch the event in and render the entity (I do it in JavaScript, client is the same Drupal website).

Problem:

JavaScript and CSS files, needed for rendering, are not attached on the page. (E.g. scripts for display of an image gallery, lazy-loading of images).

My ideas:

I think that I should list all the necessary JavaScript and CSS files (or something like ajax commands, which can attach assets) in the JSON, when I push the event. To achieve this I might need to rendered the entity via some Drupal-AJAX-Renderer.

Afterwards (when I receive the JSON from Web Socket) there should be some way on a Drupal website to attach these files by executing some JavaScript method in Drupal.ajax.

Currently I haven't figured out how to achieve this. Could you give some advice?


texts:
How to display the entire $page array like shown below?
I have devel module installed and have tried "dsm($page)" but that just shows the word "Array".


texts: Views: filter by the highest (max) field value of all items

texts:
In this case, ‘Volume’ is a text field of type integer. Using the Views module, I want to display only those articles which have the highest value in the volume field.

I am able to do it using contextual filter but I have to provide a default value like 6. Please see the attached screenshot.

Is there any way in views, to detect the highest value of the field and use that as a filter?


texts: Why doesn't "Allow multiple values" in Views' Contextual Filter work?

texts:
I'll try to explain this as simply as possible...

I'm using the Views Datasource plugin to create a JSON view to output a restaurant list.

We need to be able to filter the list via several fields - We'll just use "Cuisine" as an example.

I setup a contextual filter and when I browse to the view with "/sushi" at the end of the URL, I get only the results with Sushi in the Cuisine field. This is working correctly.

However, the Cuisine field can hold several types, such as "asian," or "carryout," or whatever.

Now, when I select "Allow multiple values," I SHOULD be able to browse to the view with "/sushi+asian" and get anything with either Sushi or Asian in the cuisine.

Instead, I get NO results.

I'm running out of hair to pull out - Anyone got any ideas? I'm at a total loss.

-- UPDATE --

Here's some SQL Query stuff - I've stripped everything but the WHERE clause as this is the only place where anything changes.

### WITHOUT MULTIPLE VALUES CHECKED ###

// Ran "/restaurants/all/$/all"
WHERE (( (field_data_field_price_0.field_price_0_value = '$' ) )AND(( (node.status = '1') AND (node.type IN  ('franchise')) )))

// Ran "restaurants/all/$+$$/all"
WHERE (( (field_data_field_price_0.field_price_0_value = '$+$$' ) )AND(( (node.status = '1') AND (node.type IN  ('franchise')) )))

### WITH MULTIPLE VALUES CHECKED ###

// Ran "restaurants/all/$/all"
WHERE (( (field_data_field_price_0.field_price_0_value = '$' ) )AND(( (node.status = '1') AND (node.type IN  ('franchise')) )))

// Ran "restaurants/all/$+$$/all"
WHERE (( (field_data_field_price_0.field_price_0_value = '$+$$' ) )AND(( (node.status = '1') AND (node.type IN  ('franchise')) )))

Obviously the query isn't changing regardless of whether I tell it to allow multiple values - How do I get this to take values separated by a + and make them ('$', '$$')?


texts: How can I "form alter" fields in a nested Paragraph, depending on where the field is used

texts:
I have these entity types:

A node type: nodepage
A Paragraph type: pg_a
A Paragraph type: pg_b
A Paragraph type: pg_child

I have a content model which is:

nodepage
  ->field_a
    Referenced bundles: pg_a
      ->field_child
        Referenced bundles: pg_child
  ->field_b
    Referenced bundles: pg_b
      ->field_child
        Referenced bundles: pg_child

You can see that pg_a and pg_b both have a field called field_child which allows a reference to pg_child. This has great semantic meaning to the site architecture.

Now something I would like to do is form alter pg_child, but only when it is referenced from pg_a and not from pg_b.

In hook_field_widget_form_alter, where I think I should be doing my alters, I can do the following:

$field_definition = $context['items']->getFieldDefinition();

// Get the current field widget being built, eg `field_child_thing`.
$name = $field_definition->getName();

// Get the bundle, ie. `pg_child`
$targetBundle = $field_definition->getTargetBundle();

// Get the bundle that $targetBundle is attached to in this instance...
$instance = ???

I thought I could look further into the $context variable, but so far this has alluded me. The best candidate so far is #parents in the form, but when I only find a reference to field_child which is ambiguous.

I now suspect I can inject more $context from somewhere, maybe in the parent build.


texts: How do I programatically generate multiple "add to cart" forms on product display?

texts:
I've got a matrix of 12 products, which can be added to the cart by users after selecting different term reference fields, which then select the appropriate product. This is shown on a product display.

However, I'd like to have multiple add-to-cart forms, each with a different line item selected on the product display field.

Basically, I've got a field collection, and I'd like to iterate through each of the field collection entities and display an add to cart form, with my full 12-product matrix of options, for each of these field collection items.

It would seem that I could get the add to cart field, all formatted, using

field_default_view($entity_type, $entity, $field, $instance, $langcode, $items, $display)

But I am currently on the node.tpl.php file, and I can't quite work out which entity objects are which to pass to this function. Nothing really resembles what I'm seeing passed to commerce_cart_field_formatter_view.

Am I thinking about this wrong? Is there a better way to accomplish this?


texts: Get webform values in page which is action for this webform

texts:
I have created a form using webform in Drupal 6. I have set a action URL like node/15 a new node. When form is submitted it will be redirect this node. I want to display all values which are filled by user at this page. Please help.

Thank you


texts: How do I add a new condition in Rules 2?

texts:
I can't get my new Rules' condition to work.

I wrote the (simple) code below in includes/MYMODULE.rules.inc, and nothing appears in the condition list.

/**
 * Implementation of hook_rules_condition_info().
 */
function MYMODULE_rules_condition_info() {
    return array(
        'MYMODULE_rules_condition_MYCONDITION' => array(
            'label' => t('My label'),
            'group' => 'My very own group',
        )
    );
}

/**
 * Condition
 */
function MYMODULE_rules_condition_MYCONDITION() {
    // logic
    return TRUE;
}

I have already tried to flush the Drupal cache (as it seems to me that Rules uses a cache system).


texts: How to use one field with different settings

texts:
I have a field that determines which category my content belongs to, stored in a taxonomy vocabulary. The field is used in both the content type and the user profile. Users may select a category, but they can select only one and definitely not more. The content however can belong to more categories, in my case 2. So the field settings should be different, but that is impossible when using a single field. Whenever i change the maximum number of values in useraccounts to 1, the field in the nodetype changes to 1 also.

I use the same field to be able to make some views (starting from a user's perspective) to display content based on the users choice.

I see three possible solutions:

Somehow use a field alias, enabling me to define the same field in 2 different ways. But i haven't found a mod for field aliases;
Define two seperate fields with seperate settings. But i can't filter my output in a View based on the value of another field. Also, using a contextual filter won't work because there is no value to pass in the URL;
Set the max value to 1 and add the same node twice, one for each category. Which is not the way to go, obviously.

Any clues to avoid option #3 ? I use D7 btw.

Thanx,
Cas


texts: Output array data on drush error when showing stack trace

texts: I'm trying to install a module, but its giving me errors during a drush enable. It shows the stack trace log and I can see it has something to do with the flag_lists_type during the install process. I can see there is an array in the output, but how do you print_r() this so I can get more debugging information?


texts: Creating a custom 'compound' form element and setting its values

texts:
I want to create a form element that takes 5 inputs (though for brevity, let's pretend its two) and then combines them into a single class for the output.
I'm having trouble getting the values and defaults to work correctly.
Here's the basic idea :
processElement() {

  // Setup default values for each text field.

}

preRenderElement() {

  // this gives me a list of the names to use.
  $field_names = static::createNames($element['#name']);

  foreach ($field_names as $key => $value) {
    $element[$key] = [
      '#type' => 'textfield',
      '#title' => $value['title'],
      '#attributes' => [
        'name' => $value['name'],
      ],
      '#required' => $element['#required'],
    ];
  }

  return $element;

}

This element takes an object as a default value, breaks it into parts to make into 5 fields, then should take those 5 inputs and combine them back into a new object to give back to the form state.
I've been trying to figure out how the return and default values should work.
I've tried adding a '#default_value' => $x inside the pre render and through xdebug I can see that the values are added correctly, they are not displayed on the page.
There seems to be other ways of adding the values such as seen here but they did not seem to work (perhaps I did not implement them correctly).
I know I will need to implement valueCallback to create the object but so far I cannot get the values to work right so I am unsure what the $input of valueCallback is.
I could not find many examples I could read through online or in core about making something like this.


texts: In my view I have 4 fields including an image. I want to link a field other than image field to the content but there is no such option as for the image field i.e "Link to". How can I get this option?Or is there any other way to do this?


texts: How to specify PHP block visibility settings for content types AND loads of urls?

texts:
I wrote lately some instruction to display a block in two different cases:

when the content type is [my-content-1] or [my-content-2]
when the url is /my_page1 or /my_page2

I found how to do it in Block visible for Specific Content Type AND Specific URL.

<?php
$match = FALSE;
$types = array('content-petites_annonces' => 1);
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' => $nid));
  $type = $node->type;
  if (isset($types[$type])) {
    $match = TRUE;
  }
}

if (substr($_SERVER["REQUEST_URI"], 0, 10) == '/petitesan')
{ $match = TRUE;}

if (substr($_SERVER["REQUEST_URI"], 0) == "/node/add/content-petites_annonces
")
{ $match = TRUE;}

return $match;
?>

It works fine, I could declare several content types in the first array (I've got 6).
But as for the urls, it only works if I repeat the same line every time (and there are loads of them).

if (substr($_SERVER["REQUEST_URI"], 0) == "/my_page1
        ")
    { $match = TRUE;}
if (substr($_SERVER["REQUEST_URI"], 0) == "/my_page2
    ")
    { $match = TRUE;}
...

I am certain there is a more mutualized way to do it.
Is there also a mean to get it working regardless of the pagination, i.e. whithout having to notify every time

 if (substr($_SERVER["REQUEST_URI"], 0) == "/my_page?page=X
            ")
            { $match = TRUE;}

Is the answer hidden in the 0, 10 in the precision about the request URI? I didn't even used that line.


texts: Is there a way to protect Drupal files from being accessible by the file path (putting http://www.domain.com/files/image.jpg) in the browser URL from users poking around?


texts: Why does my chart created with Easychart not display a chart if number of points are more than 1000?

texts:
I installed Easychart module 7.x-3.7 in my Drupal 7.51 site. I'm using Highcharts 4.2.7 in libraries 7.x-2.3.

In the example contenttype easychart_ex, I tried uploading a data.csv file with number points more than 1000. When trying to do so, my chart display portion displays "no data to display" before and after save/view. Here is a screenprint of it:

However if the same file has number of points less than or equal to 1000, it displays the chart without problem. Here is a screenprint of it:

My question: Is there any configuration settings I need to review to display all the points without any restriction?

However, when I chose scatter plot, it displayed all the points as in this screenprint.

If I am able to do the same thing as in scatter plot with a reduced dot size and line joining dots, it will be great!


texts: Assign textfield to each checked option in a checkboxes field

texts:
Lets say I have a checkboxes field and when I check one of the options, I would like a textfield to appear so I can assign a number (quantity) to it. Every option I check would have its own textfield.

For example, I have a "Fruits" field and I want to be able to say how many of each fruit I have. So it would be something like that:

[x] Apple (3)
[] Grape
[x] Orange (2)

Is there any module that does something similar to that?

Edit:

Another thing that would do the work for me would be a select list of numbers for each option. So by default the options are like that:

[0] Apple
[0] Grape
[0] Orange

So I can simply change the number of fruits in each option by selecting in the dropdown.


texts: Redirect all subpages back to the front page

texts:
I am trying to redirect everything that is under example.com/pictures back to the front page (i.e. I am hiding picture nodes to be directly viewable).

Neither the Pathauto module nor the Global Redirect module allows me to do this (or I am overlooking something). I cannot simply block users from viewing that particular node type.

Is it possible doing this with a module? Should I hack something up? Would an .htaccess rewrite help me?

I am interested in an answer for Drupal 7.


texts:
I've just got Views Send to work. I have a custom node type, with two email fields. One field contains a~single email address, the second field can contain more email addresses. Using Views Send, I can send mail to either field (even when one field can contain more email addresses).

The question is, can I use Views Send to send an email to both fields at the same time? Now I can only select one field containing emails. Sometimes it is necessary to send the same mail to both fields.

Yves


texts: How to programmatically list member entities of an Organic Group?

texts:
How can I programmatically get a list of member entities of an Organic Group?

(I know how to get a list of group members using Views — I'd prefer to do this using the Organic Groups API, but haven't been able to find the right method.)