texts: Altering menu item title results in access denied message

texts:
Problem:

When I try to overwrite the title of the edit link of a an entity built with ECK the page responds with an access denied message.

Background:

I have an entity built using ECK.
I am overwriting it's CRUD paths using hook_entity_info_alter().
I am overwriting the add link title in hook_menu_alter() with no issue.
I am rebuilding the menu.

This works:

function mymodule_menu_alter(&$items) {
  $items['myentity/add']['title'] = t('Add your Entity');
}

This causes the edit link to throw an 'access denied' error:

function mymodule_menu_alter(&$item) {
  $items['myentity/add']['title'] = t('Add your Entity'); // Still works.

  $items['myentity/%/edit']['title'] = t('Edit your Entity'); // Access Denied!
}

Has anyone else run into a similar issue and if so do you have a solution or work-around? Thanks.

Update

For fun I went into the database and manually changed the title of the menu items to see what would happen. If I just change the title directly in the database the updated title is displayed and the page works as expected.


texts: Attaching a view with exposed filters block to user profile in D7

texts:
Here's a riddle:

I want to create a user profile page that will display some user info at the top (from Profile2) and a tabbed view of that user's nodes.  Pretty similar to Twitter's profile page, with the only exception being that on the right side I want to put an exposed filter block so as to filter the contents of this view.

Sounds simple?  It was simple in D6, but in D7 it's a mystery.  In D7 in order to attach a view to user profile you have to use the EVA module, which does not allow for "Filters Exposed in Block" option. If you create an exposed filters block from the Master, it returns the default "all" argument even though you are on user/# page and theoretically passing the correct argument to the Views.

By contrast, exposing the filters inside EVA and placing them above the View works and passes the correct arguments, but then the profile page looks ugly.

So how does one resolve this riddle?  How can I have a View on user-profile page and have a functioning Exposed Filters Block on the side?


texts:
the drupal_get_messages() function is returning nothing when run from page--front.tpl in my custom theme. Do I have to add something to page.tpl.php to build this?

I have a print_r set up and it's always entirely empty even though in the admin panel I've got all types of messages


texts: Adding jQuery to Drupal 7 site: drupal_add_js() adds but doesn't call?

texts:
I'm using jQuery accordion effects to display some information. I include the libraries:

    drupal_add_js('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js', file);
    drupal_add_js('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js', file);

Those seem to work fine, since after including them I can paste

jQuery(".accordion").accordion({collapsible:true,active:false});

into scratchpad and I get the functionality I want.

However, if I try to add it to my function like so:

drupal_add_js('jQuery(".accordion").accordion({collapsible:true,active:false});', inline);

...nothing happens. I've tried some variations, such as

drupal_add_js('jQuery(document).ready((".accordion").accordion({collapsible:true,active:false}));');

as well as moving the drupal_add_js() call further downstream in my code, so it appears after the elements it acts on are created and rendered.

How do I get this little snippet of code to run on my page?


texts: Automatic username generation from name fields at registration

texts:
Drupal core 8.6.5

I am trying to change the user registration process to omit the username field and generate the username from the first name and last name.

Since I am new to Drupal and want to learn more I try to go without project modules for that task.

So far I set up a custom module and deactivated the username field.
Now I should set a default value for it.

How can I set the username built of first name and last name before the process is going on?
And strip some blanks, unallowed characters, ...

I was thinking of hooking into function user_validate_name
Is that possible?

My module so far:

<?php
use \Drupal\Core\Form\FormStateInterface;

/**
* Implements hook_form_FORM_ID_alter().
*/
function my_register_form_user_register_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
    $form['account']['name']['#access'] = FALSE;
    $form['account']['name']['#default_value'] ='tbd'; und
}

Thanks for your help!


texts: How to substitute values on a page, without PHP?

texts:
There are certain values that are liable to appear in many places on my site (corporate-owned stores, independent stores, # of brands carried, and so forth) that content authors and editors are not likely to keep up-to-date very well on every single page in which they appear.

I can put them in variables in (e.g.) settings.php, and then put PHP snippets in any nodes that need to use them, but that has obvious downsides:

content authors cannot update the values when they change
content authors cannot edit the text that contains the PHP snippets
unless of course I give them permission to do that, but that's probably not a great idea

I'm currently experimenting with using the Token Filter module to allow putting tokens like [node:field_corporate_stores] in content fields in a node.  This works just fine if that field is on the node that also has the body content in which it is being replaced.  But of course that would defeat the purpose: I want one node that contains the values, and to be able to use an indefinite number of other nodes that will consume the values.  But I don't see how to do that.

How do I define data_node for a token like [data_node:field_corporate_stores]???  (Without using any PHP snippets in the node.)


texts:
I'm using TB Megamenu on a D8 site. With a bit of tweaking all working fine.. However, when I try to have a third level of links I can't get this to show expanded. In the menu itself the level 2 item and all level 3 items have 'show as expanded' ticked on, to no avail.

In the TB toolbox it shows correct, I can have the level2 item function as header (group set to 'yes') and have the feel 3 links in one or more columns under level 2. But on the site I get a toggle arrow, and no leave three links. And clicking level 2 does not show the level 3 items underneath (I think they're rendered on the right, outside my 100% width submenu).

Structure wanted:
level 1 link | level 1 link | etc
level 2 nolink (group yes) | normal level 2 items
level 3 items always expanded as group | level 3 items

(when looking at mobile the level 3 does appear under there level 2, but again not expanded, only unfolding when clicking the level 2 item..)

I have a suspicion I could change the one of the twigs (tb-megamenu-submenu.html.twig? tb-megamenu-subnav.html.twig?) but don't know how..

All help massively appreciated!


texts: How to resolve error with drupal commerce 2 installation via composer

texts:
I am following the instructions at http://docs.drupalcommerce.org/v2/getting-started/install.html

After providing the  console command for a new installation, console starts to download the various requirements, but before completion, returns the following error.

  Failed to execute git checkout '879356bbf75608f86d8fb89d76a21dc1e99a39ae' -- && git reset --hard '879356bbf75608f86d8fb89d76a21dc1e99a39ae' --
    fatal: Not a git repository (or any of the parent directories): .git

I have read elsewhere that I need to initialise a git repo first? Not sure if I am missing something or whether the documentation is incomplete. I assumed it was a one line command.

What am I doing wrong and how do I resolve this?

I am not a very advanced user and intend to use Acquia Dev Desktop as working environment.

Further to the above, I went on to try creating the MYSITE directory first and then ran git init from within this folder. I then ran the composer commands for a full install, and then received another error as below.

  [InvalidArgumentException]
  Project directory commerce8/ is not empty.


texts:
I am working on Drupal 8 and I have migrated my Drupal 7 website to Drupal 8 using the Migrate Upgrade module, but none of the modules is imported from my previous Drupal 7 site.

How do I import modules from Drupal 7 to Drupal 8 without using Drush commands?  I'm not much familiar with Drush.

I have seen the article in which a process is given to import modules using  Drupal Module Upgrader, but it's based on Drush.

Is there any simple method to port Drupal 7 modules to Drupal 8?


texts:
I have created a form using webform module. Is there any way to create tpl file for this form?

webform-form-node_id.tpl.php is working fine. Here my problem is node_id will deffer on dev,qa and production etc server.

Please suggest so that a single tpl file can used for all instance.


texts: How can I place a  new  textfield in the tab vocabularies in a content type?

texts:
I want to place a new text field in the "Vocabularies" field set of a node; the text field is not tag.

I am using the Vertical Tabs module, and my fields in the content type are in group.

The following is the structure of my content type:

Title
Vocabularies (taxonomy) -> Here I want to place a field too.
fieldset1 (Fields:  field1, field2, and field3)
fieldset2 (Fields: field4, field5)


texts: Need a solution to search by sales person based on unique territory

texts:
I've been researching for hours for a solution, but I can't find a module or example of someone else needing this feature.

I have a list of 20-ish sales people, each person is assigned a range of zip codes. Some of them are entire states, but there are a few sales reps where the state is split between 2-3 people. I need a way for the user to enter in their own location and show which sales rep would be their point of contact.

Anyone have an idea of how I would go about doing that? Location module?

Thanks!


texts: Initiate file download and redirect to loged-in home page

texts: The users can share the file download URL and user with credentials can download the file. All the things working fine. Once the user paste the download url in address bar, it redirects to login page and after successful login the file downloads. But its not redirecting to the loged in home page. Need to happen both things (file download & redirect to loged-in homepage) on successful login. How can we achive this.


texts:
I'm trying to create content type which can be used to add Workouts. Content type has fields: Exercise, Set and Reps.

First user chooses Exercise (this is autocomplete field). Then he can add Set(s) to thise exercise (unlimited amount of sets can be added). Every Set should be added by clicking Add new row. For every set user can add reps.

Then User can add second Exercise and sets and reps to it. Etc.

See picture:

I have tried to use Multifield -module, but it does not allow multifield inside multifield.

Any suggestions how to achieve this kind of functionality?


texts:
I'm working on facebook like button for drupal 8. It's about to be done, but I've faced a trouble. Whenever I change the configuration of my module, I still need to clear all caches manually for the changes to take effect.

I'm adding the like button like this:

function fblikebutton_node_view(&$build, $node, $display, $type, $lang) {
  $build['fblikebutton'] = [
    '#theme' => 'fblikebutton',
    '#weight' => 100,
  ];
}

Are there any ways to prevent all nodes from caching or to clear cache programmatically after configuration is updated? Or I should just change the way I add the button to the page?


texts: Is there any way in Drupal 7 to view which user last made edits to a particular block, or who created the block?


texts:
I use Views module and I've got search to specify results.

In the search I've got filter for field cena. I set operator between so user can fill in min cena and max cena.

How can I change the appearance of that search? For and foremost I'd like to  remove "And" between inputs for min cena and max cena. If it's possible I also want to create placeholders in inputs for min cena and max cena.


texts: How to build a simple content approval workflow between an administrator and a user?

texts:
I have the following requirement on a Drupal site.

User interface (Authenticated user):

A simple form with some text fields
Radio buttons to select the content type
A submit button to submit the form

An authenticated user has to submit a form which will have few text fields and a content type selection.

User interface (Administrator):

A grid to see all the submissions.
A column with two buttons beside every submission "Review" and "Send back".

Once submitted the form, admin will be able to the submission, they may either review the content or send back the content to the user.

When clicked on review button, the page has to take to "Add content" page with title, description, attachment and other fields pre-filled.

When sent back, user will be notified and they may review the content and resubmit the form.

I achieved this requirement using Webform module which captures the user submission and written a custom module to fetch the webform submission content and creates a node based on the submission. I have yet to work on the "sent back to the user" part.

I'm wondering, if there is any simple way of doing this workflow.

P.S: I have already tried Workbench but I'm looking for a simple workflow where a non-technical guy (administrator) could easily get it.


texts: How can I translate config entity fields?

texts:
The question is fairly straight forward. I have several config entities with various fields.

I haven't found a way to translate config entity fields in the Drupal 8 documentation(or maybe I haven't looked hard enough, both are a strong possibility).


texts:
I'm flowing article to migration my data. Every fields is working fine. But field created doesn't working. Field created always insert time import.

I try replace field created with setting

created:
  plugin: default_value
  default_value: 1389312000

but same result. So how to migration time created of node?


texts: Validation error on date field even though submitted date is valid, and no validation rules are set

texts:
I'm having a strange problem with a date field on a webform.
I have it set, in the Element Settings, to a minimum date of "today" and a maximum date of +2 months. To my understanding, this should allow the viewer to select any date from the day they are submitting the form to two months later. Under Form Validation, nothing is checked — so to my understanding, it should not be performing any sort of validation.
But — when I test the form, no matter what value I set for the date, I get "The value in (the name of the webform): Date has to be greater than Thu, 12/17/2020 - 00:00." Even though the value IS greater than that. Even dates weeks in the future result in the same message.
I initially got a similar error for the time field that follows it, but that one disappeared when I switched the element from jQuery time picker to HTML5 time input. (I had initially used the jQuery time picker for both, but switched it to HTML5 because the jQuery picker was giving me other weird problems). But switching to HTML5 did not affect the validation issue with the date field.
So basically I have two questions: First, since I didn't set any rules under Form Validation, why is it trying to validate input anyway? The only date min/max I set was under Element Settings, which as far as I know should only affect what's displayed to the viewer.
Second, why is the unwanted validation insisting that the date has to be greater than today when the date IS greater than today?
I should add: Clientside Validation is installed, so the message is appearing as soon as I leave the field in question. But to my knowledge that just takes the validation errors Webform generates and displays them sooner, it doesn't create new ones. Although the error only seems to be appearing inline on the form — it doesn't give me an error message when I submit.


texts: Multiple Ubercart? Trying to do a multi-seller site.

texts:
Hello Drupal community. I'm trying to create a seller's site. This is what it needs to do:

A seller will have his own system in which customers can buy him directly.

The products that the seller will sell will be in common from all the sellers. But each seller will need to be able to set his own price.

I found ubercart (I found it amazing!!!), and it does much more than I'm asking for. I would like to know what should I do? Write a module from scratch? Extend Ubercart? Is there a multiple ubercart possibility?

Thanks for the replies!


texts: how can I find role of another user than logged in user?

texts:
I have user profile pages I want to filter if a user is "admin/anyother" role than "A" block show on its profile and that can see by any user
Give me any hint or how process how can I do it?
If you want more info than please type in comment box


texts: Change user field value to value of another user field

texts:
I manage a basketball league site with two main user roles, "commissioner" and "player". Every player on the site is assigned to both a Tuesday team (field_team) and a Friday team (field_team2) via a user field, which is editable by commissioners. Because of player absences and other variables, the teams are usually different by the end of the week, so there are also two additional fields, Tuesday default team (field_tuesday_default) and Friday default team (field_friday_default).

See below for an example of what my Tuesday games page looks like to commissioners:

We start each week with a clean slate, i.e., every player back with their default team. Currently, at the end of each week our commissioners have to manually edit every player's user account to get their Tuesday/Friday team values back to the default.

See below for what a player's edit account page looks like to commissioners:

The problem is that it takes a long time and it is very tedious for commissioners to manually edit every player's user account to make their team values equal to their default team values.

Is there a way to programmatically change every user in the "player" role's Tuesday team and Friday team field values to equal their Tuesday default team and Friday default team values? All my research thus far has come up empty and I'm really at a loss at this point. Ideally, I would like to put a nice, big reset button on the Tuesday/Friday games pages that will perform the reset. Any help would be appreciated! Thanks.


texts: How can I populate a node field based on a user field?

texts:
I have an "address" field among the user fields. Here users can specify several entries for their addresses.
They can create orders (these are custom content type nodes). The order node has a "shipping address" field. Users should be able to choose one address from their previously stored ones and use them on the order form.

How can I do this? What I have in mind is adding a custom js that makes an ajax call and fetches the addresses from the user fields. Is it a good idea or is there any simpler method?

It would be fine too if I can make a reference field to the user datas and users would see a combo box to choose their address from.


texts: Integrating websockets server to the database

texts:
I'm running a headless Drupal+Angular application where I want to run a server with some clients using WebSockets (and Ratchet). I managed to make a server script detached from Drupal sending messages to multiple Angular apps. Now I want to implement the server to Drupal in order to update an entity and pass the updated entity to all clients.
I'm struggling with the best architecture and what is possible.
Scenario I
Implement the server in a Drupal module in order to access the database directly to get and update the entity and then pass the entity to clients.
Scenario II
The server connects to the database directly, do custom queries and pass the entity to clients.
Scenario III
Create API's where the server can get and update the entity and pass the entity to clients.
For security reasons, I want to avoid Scenario II. Scenario I seem to be the nicest approach, but I'm unsure whether it's possible.


texts: Is there any way to display a taxonomy sorted by another taxonomy?

texts:
I'm working on a homepage for a student paper and I'm needing some way to display 3-4 arbitrary pieces of content from each section every week (I.e., top stories) in a panel for each section.

In order to do this, I'm thinking I'll use the Weight module to create a list of top stories for the week via that Taxonomy, which I would then like to group by another taxonomy term, "section".

How would I go about doing this?

Many thanks!


texts: Using computed field to format phone numbers?

texts:
I am trying to create a computer field that automatically formats phone numbers like so: xxx.xxx.xxxx

The numbers come from user input, and they will be displayed on each user page (I've added fields to Drupal's user profiles so that they include contact info)

How do I do that? Never used computed fields before, but I believe it's the solution to what I'm trying to do....


texts: How can I change the date format for user submitted data in confirmation emails

texts:
The confirmation emails sent by Webform (running under Drupal 8.9.7) on submission are in US format "m/d/Y" for all date fields that the user entered on the form (but not for system generated dates such as the time the form submission was made, which are in UK format).  I need to change them to UK format "d/m/Y" since that is what my users expect.
Web research tells me that Webform picks the date format for emails from the system's "default medium date".  Not so.  My system's default medium date format is "D d/m/Y - H:i".   What I get for the date fields that the user submitted is "D, m/d/Y - H:i" (note also the subtle difference - one doesn't have a comma, the other does).
I have varied the format of all the default date formats, but nothing changes.
Guidance on how to fix or on a workaround would be appreciated.


texts: How can I upload photos from iphone/Android to Drupal?

texts:
I know that I can build iphone/Android apps with frameworks like phonegap and titanium.

I wonder if there is an easier way? Aurigma Up seems like an interesting idea. Has anyone used this or similar apps?


texts:
Is there a simple way to add an array of images to a node page?

I would be using the file directory that I am using to upload my images to, using IMCE (sites/theme/files). The array would return all the images I have stored in that folder. I just need a very simple solution, being very new to PHP.


texts: Strategy for unit testing classes that interact with the Entity API

texts:
Sometimes I find that I end up having to do lots of mocking just to make the class testable, especially if it is interacting with the Entity API. For example, if I have code like this:

$taxonomy_term_storage = $this->entityTypeManager->getStorage('taxonomy_term');
$category = $taxonomy_term_storage->load($product_category_tid);
$category_atlas_key = $category->get('field_name_key')->getValue();

So now, to mock the return value of one field I need to do all of this:

$fieldItemListMock = $this->getMockBuilder('\Drupal\Core\Field\FieldItemListInterface')
  ->disableOriginalConstructor()
  ->getMock();

$fieldItemListMock->expects($this->any())
  ->method('getValue')
  ->willReturn('foo');

$fieldableEntityMock = $this->getMockBuilder('\Drupal\Core\Entity\FieldableEntityInterface')
  ->disableOriginalConstructor()
  ->getMock()

$fieldableEntityMock->expects($this->any())
  ->method('get')
  ->willReturn($fieldItemListMock);

$entityStorageMock = $this->getMockBuilder('\Drupal\Core\Entity\EntityStorageInterface')
  ->disableOriginalConstructor()
  ->getMock();

$entityStorageMock->expects($this->any())
  ->method('load')
  ->willReturn($fieldableEntityMock);

$this->entityTypeManagerMock->expects($this->any())
  ->method('getStorage')
  ->willReturn($entityStorageMock);

As far as I'm aware I've done everything as I'm supposed to, injecting external dependencies via the constructor but it still seems like way too much effort. The problem gets exponentially worse when I'm working with multiple fields or other people's code who haven't injected dependencies properly. So I end up having to create a partial mock of the class I'm testing.

Browsing through core and contrib modules I notice that there seem to be more Kernel tests than Unit tests, which seems contrary to the testing pyramid

Which makes it seem like they have also found unit tests too hard to set up.

So I'm wondering, is it better to just write Kernel tests / Browser tests for classes that interact with the Entity API or am I simply writing my code wrong, which is making it hard to unit test?


texts: Drupal 8: How to properly add a settings widget to a node add/edit form and save the value?

texts:
So I reviewed the code in the core book, menu_ui, and path modules, and they all seem to handle adding a settings widget in a vertical tab differently.

The book module uses a method called addFormElement(), which is called within a hook_form_BASE_FORM_ID_alter() hook.

The menu_ui module is similar, but uses hook_form_BASE_FORM_ID_alter() directly.

Path seems to use a method called formElement(), and I'm not even sure where/how this method is used at the moment.

The real question I have is, how does one actually process the form setting and save it to the database? I have tried to find an example, but I'm at a loss.

Is there a help page with examples like the ones I found for adding an admin settings page?

If not, is there a recommended approach to displaying/saving a value in a vertical tab on a node add/edit form?


texts: How to give a user the rights to "clear cache"

texts:
I need to give a user the ability to "clear cache" since he sometimes does some changes to the menus, etc...  How can I give him a right to do that, or can I just send him a URL or post something on his admin toolbar?  With the roles and rights I've given him so far he can only go to one thing on the Configuration page and that's "URL aliases."  I recall that I used to have a way to accomplish this for the authenticated users with a little block at the bottom of the footer, but I can't find it or remember how I did it..

Help please, and thanks in advance.

Dave N


texts: When should the dependency from a Drupal core module be explicit?

texts:
The Standard profile declares the Node module as one of the modules it requires, and so does the Minimal profile. That is not true for the History module, which is required from the former but not the latter.

When should I declare my module as depending from a Drupal core module? Should I assume the installation profile / distribution always requires the module from which my module depends?


texts:
I have these errors :

  Notice: Undefined index: #attributes in theme_container() (line 3251 of /Applications/MAMP/htdocs/drupal-7.22/includes/form.inc).
  Recoverable fatal error: Argument 1 passed to drupal_attributes() must be of the type array, null given, called in
  /Applications/MAMP/htdocs/drupal-7.22/includes/form.inc on line 3251
  and defined in drupal_attributes() (line 2374 of
  /Applications/MAMP/htdocs/drupal-7.22/includes/common.inc).

And I do not understand why since I checked on other similar posts and my code seems ok :

.module file :

function gestion_videos_menu() {
 $items = array();

 $items['admin/config/media/gestionvideos'] = array(
 'title' => 'Gestion vidéos',
 'description' => 'Configurer le plugin VOD Infomaniak',
 'page callback' => 'drupal_get_form',
 'page arguments' => array('gestionvideos_configuration'),
 'file' => 'gestion_videos.admin.inc',
 'access arguments' => array('administer site configuration'),
 'type' => MENU_NORMAL_ITEM,
 );
return $items;
}

and .admin.inc file:

function gestionvideos_configuration() {
  $form = array(
    '#submit' => array('gestionvideos_configuration_submit'),
  );
  $form['config'] = array(
    '#type' => 'fieldset',
    '#title' => t('Administration du plugin VOD'),
    '#description' => t('Pour fonctionner, le plugin a besoin de s\'interfacer avec votre compte VOD infomaniak.

                    Pour des raisons de securites, il est fortement conseille de creer un nouvel utilisateur dedie dans votre admin infomaniak avec uniquement des droits restreints sur l\'API.

                    Pour plus d\'information, veuillez vous rendre dans la partie "Configuration -> Api & Callback" de votre administration VOD.
                '),
  );
  return system_settings_form($form);
}

Do you have any idea how I could solve this ? Thanks a lot !


texts: file_delete not deleting a file it returns xml response

texts:
When I call file_delete($file) to delete a file, it does not delete a file rather it returns the following output:

<?xml version="1.0" encoding="utf-8"?>
<result><file><node is_array="true"><item>1</item></node></file></result>


texts: How to get media entity field value in twig?

texts:
Sometimes it is necessary to get the actual value of a field (not the formatted/rendered one), e.g. to check a boolean for true or false.

If I want to get a field value of a node or paragraph inside twig templates (node.html.twig / paragraph.html.twig) I can use node.field_my_boolean.value respectively paragraph.field_my_boolean.value.

How do I accomplish this in a media twig template? I've already tried media.field_my_boolean.value but it does not work.


texts:
I have the following response using kint. How can I correctly get the value of the title.

I tried stream.node_title[0]['#context'].output but getting null result.


texts: Field collection - Delete "Remove button" on line

texts:
I need to delete the "Remove button" on every edit field collection for specific role users. I have 3 roles (Admin, Project, Test). Just Admin and project can see the "delete" button and "add" button to remove lines or add a new line. The others roles are not allowed to delete or add new line in the field collection.

I tried to change some permissions (Administer field collections - Create and delete fields on field collections.) But it didn't work...

I need to use HOOK ? or maybe just JQuery ?

To complete my explication, here an example :

Thanks

PS : "Supprimer" = "Remove"


texts:
I installed Drush, but most of the commands doesn't work, I guess. I tried drush cc all and got the following output:

  Command cache-clear needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal environment to run this command.
  The drush command 'cc all' could not be executed.
  A Drupal installation directory could not be found

drush status outputs the following:

  PHP configuration     :  /etc/php5/cli/php.ini
  Drush version         :  4.5
  Drush configuration   :
  Drush alias files     :


texts: Using Drush how can you see the last user that logged in?

texts: Using drush, how can you see the last user that logged in? What about the last 5, 10, 20?


texts: How to make /user show registration form by default?

texts: When anonymous users go to /user, i would like to show the registration form instead of the login form, or just redirect to /user/register. I couldn't find anywhere how to do that...


texts:
I have a tpl file for file entities of type image: file--image.tpl.php.

In this file I use $file_url to get the url of the file. But I'm not sure if this is correct. This Drupal installation we have in a subfolder of the www-root. If the subfolder is http://ourserver/dev I get /dev/img_file_name.jpg as url for the image. But it should be only img_file_name.jpg.

How can I get the correct url of the image?

All other fields of the file entity are working as expected.


texts:
Im using D7 and UC3. A product is multiple levels down:.

product list = cat1/sub2/sub-sub1/

Now using pathauto i'm trying to make the path of the product cat1/sub2/sub-sub1/product1 however i cant find the right tokens to do this. Best is can get is sub-sub1/product1 loosing the first two steps. In the breadcrum i do see the other levels, so the product knows its nested like that.But i cant seem to get the url to correspond.


texts: Is there a view for top selling products, including product kits?

texts:
I'm looking for a view to list top selling Ubercart 3 products and product kits.
It would be a BIG plus if the view can include an image field and a taxonomy field.

I have checked this articles but didn't get what I'm looking for

http://drupal.org/node/1339910

Ubercart most selling product in drupal 7

Thanks


texts: How can I “Link to the Content” for teaser view mode of custom content type module?

texts:
I've created a module that's add a content type to my site and I now want to understand how can I Link a Plain text fields to the Content in Teaser view mode programmatically in my module?
I currently can Link to the Content any Plain text field in:

Home>Administration>Structure>Content types>Content types name>Manage
display

Teaser Manage display page, see below image:

and I want to understand how can I get access or implement this property (feature) in my module, I try to achieve this by adding below code to my module:
#core.entity_view_display.node.teaser
field_version:
  type: string
  weight: 2
  label: inline
  settings:
  third_party_settings: {  }

To no avail.
Thank you for any help.


texts: How do I reference another field properly?

texts: In Drupal 7, how can I properly reference another field with the Computed field module?


texts: Extract zip to server and upload the files to the node?

texts:
I allow users to upload zip files I extract, and look into them to see if they contain a .jpg file. I use that file to create a new node. The differences between the .jpg and the .zip file uploaded are that the first came as an object, while I don't know how I can take the second as an object.

I'm using the PclZip library.

This is part of the code I use when the uploaded file is a JPEG.

$file = $form_state['values']['file'];

$original_filename = $file->filename;
$original = file_unmanaged_copy($file->uri, 'public://work', FILE_EXISTS_REPLACE);
file_unmanaged_delete($file->uri);
list($file, $tfile) = some_fileprep($original_filename);

This is the code I use when the file is a .zip file.

include $pclzip_lib.'pclzip.lib.php';
$zip = new PclZip($file->uri);

for ($i=0; $i<$total_files; $i++) {
    $file_name = $list[$i]['filename'];
    list($f_name,$xt) = explode('.', $file_name);
    $xt=strtolower($xt);

    $regex = '/\.(' . preg_replace('/ +/', '|', preg_quote('png gif jpg jpeg tif tiff html')) . ')$/i';
    if (preg_match($regex, $xt) and ($list[$i]['size'] < 10000000)) {
        $error[] = "File with conflict: ".$file_name;
        if((($xt == 'png') or ($xt == 'gif') or ($xt == 'jpg') or ($xt == 'jpeg') or ($xt == 'tif') or ($xt == 'tiff')) and ($f_name == 'preview')){
            $file->filename = $f_name.".".$xt;
            $file->uri = $f_name.".".$xt;
            echo "Yes: ".$f_name.".".$xt;
            $preview = true;
        }
    }

    if(is_null($error))
    {
            $to_extract = $GLOBALS['_SERVER']['DOCUMENT_ROOT'] . '/' . drupal_get_path('module', 'some') . '/testing/';
            $ar = $zip->extract(PCLZIP_OPT_PATH, $to_extract);
            $file->filename = $ar->filename;
            $file->uri = $ar->filename;

        }
}


texts: Can I allow a user to create a Node using only an embeded rich text editor

texts:
In Drupal 7, I'd like to present the user with a single text box, that when submitted, creates a new node or entity.

I don't want them to have the standard node/add/type link and interface. Rather, I'd prefer a block that has a CKeditor and submit button. Upon submission, the content of this text box will become a new Node (or entity). The title will be auto-generated.

In some way I'm looking to replicate the functionality of Drupal 6's Facebook-style Statuses (Microblog) -- the same patterns now found on larger social sites: G+, Twitter, Facebook. However, instead of saving to a single database table, I'd like to Drupal to create a new node or entity from that content.

From comments below, I've been pointed towards Rules. However, I'm still having issue with how to go from submission of that single rich text area to triggering a Rule. Would the module Rules Forms Support be of help?


texts: Modify article body for one particular article to add data

texts:
How do I modify an article's body field before the end user sees it for one particular article?

Background: Currently the content editors are updating this data manually twice per week. We want to automatically update it every 8 hours with a cron job instead. We will get data from an external source, it comes to us in JSON format. We process the data into a render array.

When I'm ready to see some output on the page, how do I put it there?


texts: hide a DIV on node edit form, but display on node creation

texts:
I have a field that is part of a conditional related to several field collections. As such, it needs to be rendered when adding or editing a form. However, once the node has been created, I don't want users to be able to modify the value. So on the edit page, I want to hide the DIV surrounding it.

I thought I could trick it with CSS in Panels, but add and edit use the same page and the same CSS shows in each.


texts: Domain Access with URL Alias - same content, but with different automated aliases

texts:
I have a site running Domain Access with two domains - the primary domain and the sub-domain. Both domains share the same content in the database, but I would like the automated URL aliases for the sub-domain to be different from that of the primary domain's.

There are two tables in the database right now - the url_alias table and the domain_2_url_alias table (of which the latter is a copy of the original url_alias table).

I tried modifying the settings under /admin/build/path/pathauto and selected the sub-domain under the "Save settings for:" option, but that didn't seem to have any effect at all.

I can change the values in domain_2_url_alias manually for each node (which worked), but the site generates new content very often, that this wouldn't be a viable solution.

I appreciate any help I can get! Thanks in advance.


texts: Can I use hooks in a template for views?

texts:
I'm still not sure how hooks work.

I want to join a table to one of my views, but I have no idea where I'm supposed to put the hook for that. Do I just stick it in the template for the view? Or where does it go?


texts: Webform: request submitted values in all page breaks

texts:
I have multiple page breaks in a webform.
Can I get all the values submitted in all previous page break? Actually I can get only the values for one previous page break(the last one submitted).

For example if i'm in the page break 4 only can request the values submitted in page break 3 not in all the previous (2 and 1). The other values are not present.

I'm using the hook_form_alter.

Getting the info from $form_state["input"]["submitted"]

    function custom_module_form_alter(&$form, &$form_state, $form_id) {
      if(substr($form_id,0,20 ) == 'webform_client_form_') {
        dsm($form_state["input"]["submitted"]);
        //Only info from one page break(previous)
      }
    }


texts: How can I exclude certain routes from maintenance mode?

texts:
I am trying to make certain routes exempt from maintenance mode by adding the option _maintenance_access to the route and setting it to TRUE.
I think (although I'm not 100%) that this works because in Drupal\Core\Site\MaintenanceMode there is the following method which checks for the _maintenance_access option and returns false if it is present -
public function applies(RouteMatchInterface $route_match) {
  if (!$this->state->get('system.maintenance_mode')) {
    return FALSE;
  }

  if ($route = $route_match->getRouteObject()) {
    if ($route->getOption('_maintenance_access')) {
      return FALSE;
    }
  }

  return TRUE;
}

I have followed this guide on drupal.org on how to alter existing routes
Here is my mymodule.services.yml file
services:
  mymodule.route_subscriber:
    class: Drupal\mymodule\Routing\MaintenanceModeRouteSubscriber
    tags:
      - { name: event_subscriber }

Here is my MaintenanceModeRouteSubscriber class
<?php

namespace Drupal\mymodule\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

class MaintenanceModeRouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('entity.node.canonical')) {
      $route->addOptions(['_maintenance_access' => TRUE]);
    }
  }
}

But this is not working as when viewing this route (any node) it is still in maintenance mode.


texts: Ubercart 3 check the stock before adding to the cart

texts:
When a user enters in a quantity to add to their cart, I am trying to check that quantity against the stock level of that product, and when the stock is less than their quantity, it returns and error.  This is as far as I have gotten, and I am stuck.  Got any ideas?

function uc_check_stock_form_alter(&$form,&$form_state,$form_id) {
  if ($form_id == 'uc_product_add_to_cart_form_') {
    $form['#validate'][] = 'uc_check_stock_form_validate';
  }
  return $form;
}

function uc_check_stock_form_validate($form, &$form_state) {

  $stock = db_result(db_query("SELECT `stock` FROM `uc_product_stock` WHERE `nid` = '%d'", $form_state['values']['node']->nid));
  if (is_numeric($stock) && $stock < $form_state['values']['qty']) {
  form_set_error('qty', t('Quantity is greater than our available stock. Please adjust your quantity for the this item.'));
  }
}


texts: How do I change the date format of a date field?

texts:
How to change date format of date field? I'm using webform module. There is no date format field to set it. Also read somewhere that changing default date format of "short" format will do the job, so I changed "Default short date" format, but didn't help.
So how to change date format?


texts: Programmatically format integer field display

texts:
I am trying to programmatically format how an integer field displays. So far I have only been able to produce "1.00", and I am trying to get it like so: x.xx.x. The content type is "Project" and the field is "Drupal version".

Here is my code:

<!-- Display the drupal version with decimals -->
      <?php if (isset($node) && $node->type == 'project'): ?>
          <?php $drupal_version = field_view_field('node', $node, 'field_drupal_version', array('label'=>'default')); ?>

          <?php $formatted_drupal_version = number_format((float)$drupal_version, 2); ?>
          <?php echo "Drupal version: " . render($formatted_drupal_version); ?></span>
      <?php endif; ?>

output: Drupal version: 1.00

Does anyone know why this is the output, and how I can extend this function number_format to produce something in this format x.xx.x, for example "Drupal version: 7.41.1" ?

Thanks!


texts:
I've got a field called Name (Entity Reference) that sometimes has 2 values. It would require some kind of Rules I guess. Just not sure how it can be done. I created a taxonomy which has 3 values: "none", "backslash", "and".

So what I wan't to do is if there are 2 values and I've chosen "backslash" the output will be "Name1" / "Name2".

If there are 2 values and I've chosen "and" the output will be "Name1" & "Name2".

Am I on the right track here?


texts: Read contents of uploaded file before saving

texts:
I am using hook_node_presave() to build a module (which I am new to) in Drupal 7. I am able to reference fields via $node->field_foo[$node->language][0]['value'] (which I have seen mentioned several times here in Drupal Answers).

This particular content type I am working on has the ability to upload files. I am new to Drupal 7, but I noticed that:

First, the user uploads the file
Then, the user saves the node (with a reference to the file)

How do I access the content of that file after it has been uploaded, with hook_node_presave()?


texts: Reload page after applying commerce coupon

texts:
I'm quite obsessed on one page checkout using drupal commerce kickstart. I'm using commerce coupon(wonderful module) and we all know that there's a possibility that the order total price could be zero if you we apply a 100% coupon module. I see this post Commerce - how to set no payment for free orders when 100% coupon applied and I guess we are having the same problem. I did not see any way to ajax refresh the payment method pane, and my last work around is to reload the entire page after applying coupons.

Is there a way to reload the entire page after applying coupons?

Thanks.


texts: Updating a Node's FID from file_usage_list

texts:
Alright, so this is a bit of an abstract concept; however, I'll give it a shot in accurately depicting the scenario.

I am trying to automate content creation from a production environment down to a development environment in a continuous fashion using Feeds to import content from a REST server created through Services. The content portion is straight forward, and I have no trouble synchronizing and targeting updates via UUID as my guid; however, one problme I realized I will always face is the potential a user has uploaded images or files via the WYSIWYG.

This led me down the path of implementing the File webservice in the Services module, where all managed files in Drupal 7 are tracked by their FID and file object. Using the Drupal 7 API for file.inc, I was able to load and save files via file_save_data or file_save, but this is where I have encountered my issue:

Due to the autoincrementing primary key on the file_managed table, if I am creating a FID that already exists in the development environment, yet the file is not the same file path and is not an updated image, I can only grab the nodeID for which file references this FID through file_usage_list() with file_load(fid); however, there is no simple way to loop through the node_load() object based on that nodeID to find which array in the node contains the FID key matching the appropriate value? Or am I approaching this completely wrong and overthinking it?

If I just copy the file to the base directory, will Drupal handle the file object management on the Feeds import when it encounters the WYSIWYG html?

I should mention the thought process behind this is:

Check if the FID was in use
Compare the Target URI's to determine if it is a file update
If the FID's are not the same file and there is a conflict in the FID's from one environment mapping to different targets in the other, then grab the referenced node for the conflict, update its FID reference using file_save() or file_save_upload() and node_save(), and then proceed with the original creation of the imported file in the file_managed database table


texts: How to compare date from table with variable using db_query?

texts:
I am trying to retrieve all records from a specific date, given the variable $date. I am using db_select and ->condition (due to a lot of joins).

I like to do something like:

->condition("`tableName`.`field_date_value` )", $date)

That doesn't return anything. Perhaps due to different time because field_date_value has a time set and $date hasn't. I looked into using a SQL functions like DATEDIFF, but it doesn't work for me.

How do I do this?


texts: Module-heavy site quits without error on W7 dev machine

texts:
I have taken over development of a major Drupal 6 site (I'm not a Drupal newbie by any means) - I did quite a lot of the original work and never had the following problem, however there have been changes since then:

Any admin function which involves building large data structures from all modules causes the dev site to silently quit. There are no Apache or PHP errors, just:

Unable to load the webpage because the server sent no data.
Error code: ERR_EMPTY_RESPONSE

That's the result in Chrome, IE fails similarly. It's definitely happening in the code.

I can't rebuild menus, access the module page or enable the Update module. The rest of the site works fine.

I analysed the problem down to the point where I have established the crash definitely occurs when it's building big data structures. It has about 360 modules and when building the module page can get to 252 before it simply dies.

I running on WAMP over W7 with PHP 5.3.13 and Apache 2.2.22 Any ideas on what's causing it and if it's solvable?

(Any comment like "don't use windows" or "use fewer modules" are not very helpful at this point.)

EDIT: Additional data. I was wrong about the lack of Apache error messages, although it's not very helpful:

[Fri Aug 02 22:21:09 2013] [notice] Server built: May 13 2012 19:41:17
[Fri Aug 02 22:21:09 2013] [notice] Parent: Created child process 10076
[Fri Aug 02 22:21:09 2013] [notice] Child 10076: Child process is running
[Fri Aug 02 22:21:09 2013] [notice] Child 10076: Acquired the start mutex.
[Fri Aug 02 22:21:09 2013] [notice] Child 10076: Starting 64 worker threads.
[Fri Aug 02 22:21:09 2013] [notice] Child 10076: Starting thread to listen on port 80.
[Fri Aug 02 22:21:09 2013] [notice] Child 10076: Starting thread to listen on port 80.
>>>> ERROR MESSAGE NEXT
[Fri Aug 02 22:23:08 2013] [notice] Parent: child process exited with status 255 -- Restarting.
<<<<
[Fri Aug 02 22:23:08 2013] [notice] Apache/2.2.22 (Win64) PHP/5.3.13 configured -- resuming normal operations
[Fri Aug 02 22:23:08 2013] [notice] Server built: May 13 2012 19:41:17

Seems there are a multitude of possibilities for this and it may be related to this: What can cause Drupal to crash Apache?


texts:
In a custom module I have a block defined and the function that builds the block returns a render array. In that render array I am looking to create a pager for my content since it is a listing of items.

If I run pager_default_initialize during my query building like so this automatically adds a pager to the top of the block.

$total = $query->countQuery()
  ->execute()
  ->fetchField();

$page = pager_default_initialize($total, $per);

$query->extend('PagerDefault')
  ->limit($per)
  ->range($page * $per, $per);

I want to have more control over the pager, like adding it to the bottom of the block. If I remove the pager_default_initialize from the query building code like so, I can stop the pager from automatically being added.

$total = $query->countQuery()
  ->execute()
  ->fetchField();

$page = pager_find_page();

$query->extend('PagerDefault')
  ->limit($per)
  ->range($page * $per, $per);

So, the question is, how do I add the pager to my render array so it renders the pager at the bottom of the block?

My render array currently looks like this:

$content['results'] = array(
  '#type'       => 'container',
  '#attributes' => array(
    'class' => 'results',
  ),
);

if ($data->rowCount()) {
  foreach ($data as $record) {
    $content['results'][] = array(
      '#theme' => 'CUSTOM_NODE_THEME',
      '#node'   => node_load($record->nid),
    );
  }
  if ($per > 0) {
    $content['results']['pager'] = array(
      '#theme' => 'pager',
    );
  }
}

The theme_pager() is not being run when the block is rendered.

Any help would be awesome!


texts: Javascript does not work when signed in or when comments are open

texts:
This is my info.yml file.

name: tnt
description: Drupal 8 starter theme
type: theme
core: 8.x

libraries:
  - tnt/global-styling

regions:
  header: 'Header'
  primary_menu: 'Primary menu'
  breadcrumb: 'Breadcrumb'
  content: 'Content'
  sidebar_first: 'Sidebar first'
  footer_first: 'Footer first'

This is my libraries.yml file.

global-styling:
  version: VERSION
  css:
    theme:
      styles/style1.css: {}
  js:
    js/js1.js: {}
  dependencies:
   - core/jquery

This is my JavaScript file.

$(document).ready(function() {

  alert("Here I am");

});// end ready

This works fine unless one of these conditions is true.

User is signed in
User is on a page where comments are open

Obviously, I had much more complicated JavaScript code, but I reduced it to something simpler to illustrate the point.

I am currently using Drupal 8.1.10.

How do I get this to work when users are signed in and/or comments are open?

What am I doing wrong?


texts: "recommended-project" installs drupal into the /web subdirectory, but hosting solution directs traffic to webroot

texts:
Per https://www.drupal.org/node/3082474 the preferred document template, drupal/recommended-project, uses a "relocated document root" for security purposes. HOWEVER, many cPanel driven hosting services mandate that the website user lands in the hosting site's public_html web root directory. I can't make it work for a website vistor.
I have researched many ways to accommodate through the use of .htaccess files and settings.php; however, nothing I've tried actually works. For example, I can land on the page, but if I try to log-in, then it gets lost. Or /web shows up in the address bar. Or people write about security concerns that are worse than not doing the relocated document root in the first place. Or...
This solution is "STANDARD", so there must be a well-researched standard way for a web user to land on the public_html, but be redirected SECURELY to the /web subdirectory.
UPDATE: this is the best solution that I have found and it seems to work safely, per https://www.drupal.org/project/drupal/issues/2612160#comment-11767977. I inserted this snippet at the bottom of /web/sites/default/settings.php file:
if (isset($GLOBALS['request']) and
'/web/index.php' === $GLOBALS['request']->server->get('SCRIPT_NAME')) {
$GLOBALS['request']->server->set('SCRIPT_NAME', '/index.php');
}

(with /web/ being the name of the subdirectory below the web root).
I also had to add this to my .htaccess file at the webroot, public_html:
# https://www.inmotionhosting.com/support/domain-names/how-to-redirect-your-primary-domain-to-a-subdirectory/

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain_name.com$
RewriteCond %{REQUEST_URI} !^/web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /web/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain_name.com$
RewriteRule ^(/)?$ web/index.html [L]

(with /web/ being the name of the subdirectory below the web root). Substitute your domain_name in the two places above).


texts:
I am studying the new database layer, and I am glad it is changed to an OOP layer. I need to implement a query with db_select(). I found I can add a WHERE statement with $query->condition(), but by default the conditions are AND'ed together.

How can I OR the conditions together?

$query=db_select('users','u')->fields('u',array('uid','title','created','uid'));
$query->join('flag_content','fc' , 'u.uid = fc.content_id');
$query->condition('fc.fid', '5' , '=');
$query->condition('fc.uid', $uid , '=');
//…


texts: Best way to dynamically change only the href of a link in the main menu not the markup

texts:
I have been digging quite a bit for this and cannot believe that I am not finding way to do this as I didn't think it would be all that difficult. I would like to alter the href property of my main menu items (potentially) on each page load.

I am building a site that will take the state name in to consideration on most pages. The default main menu links do not contain the state names in the urls. I want to be able to check for the existence of a state name on a given page, and when present, append that to all the main menu items so that the state continues to be taken in to consideration on future pages.

I have seen solutions for theming links, but I do not wish to change the markup of my main menu in any way, I simply want to have the link go to a new location. I would much prefer to do this on the server side rather than using jquery to update them.

Here is what I thought would work:

function THEME_preprocess_page(&$variables) {

  foreach($variables['main_menu'] as $key => $item) {
    $variables['main_menu'][$key]['href'] = 'my_new_url';
  }
}

However, when I print the results, I see that the values in $variables are changed, but they are not reflected in the markup. Is there another simple way that I can do this without having to rewrite the markup of my menu with a theme_links__system_main_menu() call?


texts: I don't find something similar to drush field-create in Drush 9

texts:
I'm looking for a similar command drush field-create with Drush 9, I only find drush generate field but when I execut it I don't get nothing, also if I try drush generate field --help  I get:

Too many arguments, expected arguments "command" "command_name".

There is any way to get drush field-create running with Drush 9?

Thanks.


texts:
I have a form using "#states" (in the Relation module), and it works, but it kind of jumps around. A nice slideDown would be so much better.

How can I do that instead of just making it visible?


texts: All content types displaying in "Show only items where" search

texts:
When I log in as a user who doesn't have access to certain content types, I can still see a list of those content types in admin/content under the "Show only items where" search. Also, some of the content types don't have any nodes using those content types, yet they are still listed in the dropdown menu under "type".

Rather than confusing certain users, I would prefer only for the content types they have access to, to be listed here. Is this possible?


texts: Taxonomy terms and vocabulary in form selection

texts:
I 'm trying to insert vocabulary terms in my form

Only one term appears, but there are more of it.
Here is my code in .module file
<?php

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_alter().
 */

function bulk_taxonomy_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
  if ($form_id == 'views_exposed_form') {
    $vocabularies = taxonomy_vocabulary_get_names();
    foreach ($vocabularies as $vocabulary) {
      $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vocabulary);
      $term_data = [];
      foreach ($terms as $term) {
        $term_data['select'] = [
          'tid' => $term->tid,
          'name' => $term->name,
          'vid' => $term->vid,
        ];
        $select['vid'] = $term_data['select']['name'];
        $form[$vocabulary] = [
          '#title' => $vocabulary,
          '#type' => 'select',
          '#options' => [
            $select
          ]
        ];
      }
    }
  }
}


texts: Drupal: user directory shows blocked users

texts:
I have a simple user directory in drupal, but when I block certain user in the admin, they still show up in the directory, although clicking on the user gets you to "access denied" page for the user profile. Do I need to add something about the user status to make this work?

Here is the code:

$result = db_query('SELECT * FROM users_roles LEFT JOIN users ON users_roles.uid = users.uid left join node on users.uid = node.uid left join content_type_bio on node.vid = content_type_bio.vid WHERE users_roles.rid = 6 and node.type = "bio" ORDER BY users.name');

while ($data = db_fetch_object($result)) {
  // we're working off user names, so replace . with space and captitalize   $string = $data->name;   $pattern = '[\.]';   $replacement = ' ';   $name = preg_replace($pattern, $replacement, $string);   $name = ucwords($name);   $data->picture = 'http://example.com/' . $data->picture;   $image = $data->picture != "http://example.com/" ? theme_image($data->picture, $alt = $name, $title = $name, $attributes = array('class' =>'left'), $getsize = FALSE) : theme_image('http://example.com/files/pictures/default.jpg', $alt = $name, $title = $name, $attributes = array('class' =>'left'), $getsize = FALSE);
  $item[] = array('text' => $name, 'path' => 'user/'. $data->uid, 'avatar' => $image, 'title' => $data->field_occupation_value); //  $item[] = l($text = $name, $path = 'contact/'. $data->uid); //  $item[] = l($text = $name, $path = 'user/'. $data->uid .'/contact');   // this is an example of the url we're constructing   //http://example.com/user/27/contact
}


texts: When developing a module's theming functions, should you use "template_preprocess..." or "mymodulename_preprocess..."?

texts:
I got into a discussion with co-workers today after reviewing some code on a Drupal 6 project.

When creating a module, I tend to define all template preprocessor functions by including the module name

function mymodulename_preprocess_news_item(&$vars){ ... }

If another module/theme needs to override/expand this, I add the function definition with the new module/theme name.  This is how I've come to understand the theme layer to work.

My co-worker's mentioned that I should be using the following instead for custom preprocessor definitions:

function template_preprocess_news_item(&$vars){ ... }

According to the documentation on theme(), template_preprocess gets executed before anything else so I'm leaning towards agreeing with my co-workers since these are custom theme elements and the originating module should process the initial content.

I am curious if there are any best practices/opinions out there on this matter.


texts:
I want to scale my Drupal site and I was wondering how to approach it with Drupal and Amazon EC2. This is a bit related to How to use Drupal in the cloud with on demand instances.

With Amazon, I can monitor my server and if certain metrics are hit then it can launch a new instance that is load-balanced. My questions are then:

Does Drupal create specific files as users do stuff? Is everything on the database? (I have a separate database server that all my nodes point to.)
Are sessions local or is it on the database as well? I'm thinking of situations where user connects to server A and then gets moved to server B. Would the user lose anything?

If it helps, I'm using Drupal 6.


texts: I followed the Drupal documentation (https://api.drupal.org/api/views/theme%21views-more.tpl.php/6) and saved my views-more.tpl.php inside my theme folder. However, it does not work and seems like my website does not take my views-more.tpl.php. I cleared cache under /settings/performance and wonder what else I should do?


texts: Some URLs need a trailing slash or it redirects to the home page

texts:
I have cloned my production site to a dev environment. Both are Drupal 7.58 running on a WIMP stack if that matters.

Both are using clean URLs. In the dev site this url http://mysite/about-us redirects to the home page. However the address bar continues to show http://mysite/about-us. This is true of any url that has one "directoy" level like: http://mysite/xxxx

If I add a trailing slash to the url then it works, http://mysite/about-us/ does properly render the About Us page. The production site does not have this problem, it renders the correct page with or without the trailing slash.

Urls like http://mysite/about-us/team also work without issue on either production or dev and with or without the slash. The home page also works fine.

Any idea why http://mysite/xxxx is rendering the home page?


texts: Limit access to a view based on profile field

texts:
I'm trying to figure out the best way to limit access to a view based on a boolean field in the user profile. If the user checks the box for that field they will have access to the view, otherwise not.

I could use views_php for the access control of the view. Would that prevent the view from getting cached with views caching?

Or should I use a hook_form_alter() to check for the value each time the profile is saved and then add or remove from a special role?


texts: The website I am creating needs to import a medium sized database into my new Drupal system.  I will be able to do an SQL export on the old database but I am wondering if there is a good module that my facilitate this kind of transfer.  Also, I might like to make some changes to the structure of the database, for example one table I will need to import has 39 integer that I would like to move into one single vector, is this something I could do with an existing module or would I need to write some php code to handle this?


texts:
I want to count taxonomy terms for one (or per) vocabulary. I know, it can be done via views with aggregation but I wonder if there is another way to do this without using views.

There is a taxonomy vocabulary.
There are terms in this vocabulary.
I want to learn how many terms are there in this vocabulary.

Is there a method to show term counts as node count below?

<?php $counter = db_query("SELECT count(nid) FROM {node} WHERE node.type='page' AND node.status=1")->fetchField(); ?>


texts: How to attach a CSV file with the Google Chart API?

texts:
I have created a Google Chart based View and it is working nicely.
How to give the facility as the user should be able to upload a CSV file and the data comes accordingly?


texts: How do I get a field translated in Drupal 8

texts:
I have a multilingual site in Drupal 8, and several node, some translated and others not.
As I can programmatically get the translated field or by default they give it back from the original language.

I got this:

$service_entities = entity_load_multiple_by_properties('node', array('type' => 'service'));

$services = [];
foreach ($service_entities as $entity) {
  $services[] = [
    'title' => $entity->title->value,
  ];
}

This code work fine, but when the title is translated Drupal give back in the default language in which it was created.


texts: Problem with image file names containing utf-8 characters

texts:
I have a problem image file names containing utf-8 characters in my drupal website.
When drupal has to display a thumbnail (image style) that contains utf-8 characters on it's image file, it fails. All other images/image file names, work ok.

For example there's this image:

http://example.com/sites/default/files/styles/thumbnail/public/%CE%B8%CF%81%CE%B7%CF%83%CE%BA%CE%B5%CF%85%CF%84%CE%B9%CE%BA%CF%8C%CF%82%20_%CE%B3%CE%AC%CE%BC%CE%BF%CF%82.jpg

The actual image file really exists in default/files/styles/thumbnail/public/ directory, but it cannot be displayed in website.

Visiting the above image url, I can see the following message:

Error generating image.

but I should be able to see the actual image, because it exists on server directory, I can download it using FTP, and it's a normal thumbnail image file.

Why is this happening and what can I do to fix it?

UPDATE-----

htaccess.txt

sample image


texts: How to store css & js in separate file & call in custom 'tpl' files through variable in drupal 7?

texts:
I have created a custom module where I have define my page url's & contents are created through my custom tpl files.

I am applying some css & js on those custom contents/pages/tpl files.

What I want : I don't want to add path of those css & js in all pages. I want to define those css & js in separate file & I want to call that css & js in my custom pages through variable. Simply I want to create a header file which hold my css & js. And I want to call that header file in my custom pages.

Why I want to do this : Right now the path of the css & js is not fixed. So if am I add drupal_add_css() & drupal_add_js() in every tpl file then will change the path in every tpl file. So I want to create a header file where am I put the css & js path & if the path will change then I have to change the path in only header file.

How can I implement this?


texts: How to find backdoor that is adding code in my /includes/theme.inc file?

texts:
I got a "site may be hacked" warning from Google in one of my Drupal sites and while working to resolve this, I noticed that a hacker gained access to the /includes/theme.inc folder and added codes inside the template_process_html(&$variables) function

I commented out the part that was adding links on my site and kept it as it is. Now after 2 days I checked the site again and saw that another set of codes are inserted in the same function which now looks like this:

// Render page_top and page_bottom into top level variables.
  $variables['page_top'] = drupal_render($variables['page']['page_top']);
  $variables['page_bottom'] = drupal_render($variables['page']['page_bottom']);
  // Place the rendered HTML for the page body into a top level variable.
  $variables['page']              = $variables['page']['#children'];
  $variables['page_bottom'] .= drupal_get_js('footer');
  if($variables['classes_array'][1]=='front')
    $variables['page_bottom'] .= '
The beginning of the process you should find some nice bargains is the internet. You could possibly find a websites selling such designer shoes at much reduced prices. You will, therefore, need to observe a quantity of sites and compare prices before finally settling for the offer it is possible to comfortably have. However, you have to remember that you won\'t have the chance to try the shoe you want to purchase. Additionally you need always be wary from the online sale scams.Custom Cheap Jordans is genuine. There are 24 customized versions of Jordans. You can buy, Jordan, does not have any for good quality, very supportive shoes to wear while to the basketball judge. They come in various colors, market, they are generally have a great performance top basketball shoes, 72-10 11s for sale Michael Jordan famous. Women Air Jordan Shoes are designed with women\'s basketball players read more was formed. With superior quality materials and design ...... 100s of links here

  $variables['head']    = drupal_get_html_head();
  $variables['css']     = drupal_add_css();
  $variables['styles']  = drupal_get_css();
  $variables['scripts'] = drupal_get_js();

So now it is clear that site has a backdoor, I need to find that backdoor to keep my site clean and remove that warning from Google.


texts:
I need to set up a recurring payment on Drupal 8. I discovered these two possiblity :

https://stripe.com/us/billing
https://www.drupal.org/project/commerce_recurring

What is the difference between these two possiblity ?

The commerce reccuring module looks extremely complex to set up.


texts: How to set up a field to provide a publish/unpublish feature?

texts:
For layout reasons, I need a field providing a publish/unpublish feature.

We already have something very close with the Publish Content module.

Still, it looks like there's no option for setting it up as field.

Which alternative do we have here?


texts: Change shown fields in a grouped view depending on group

texts: I have a view that shows nodes and groups them by their taxonomy term. Is it possible to show less fields for a specific term? For example there are user profiles with names and pictures that are listed, but if they have a specific taxonomy term the picture field shall not be shown.


texts: Selecting field from all comments on a particular node

texts:
I have essentially hacked comments into reviews of a node, having a comment field of 'rating' with a fivestar widget. I was hoping it would be a trivial call to the voting API to fetch the rating of each 'review' so I could work out a nodes average rating.

However I notice that for some reason all the votes are getting saved in a database table of field_revision_field_product_rating, and this contains no direct foreign key to the node it is from, is there a 'Drupal' way of fetching the comments in manual SQL with some monster joins?

Just to confirm, review is actually a comment, and the fivestar 'rating' is a field on the comment.

Bonus points: Why, even though I'm using fivestar, are the votes not getting put into the votingAPI storage?


texts: If I using Ubercart and "PayPal Website Payments Pro", Can customer pay with credit card directly?

texts:
I'm not familiar with payment gateway. I'm building shopping cart selling physical product. Currently the website using: Drupal 6, Ubercart 6.x-2.4, with PayPal free account.

My client asked me to make credit card payment as simple as possible. Some customer don't know what is PayPal? When making ckeckout, they are redirected to PayPal account. After registration, they then asked to transfer from credit card to their PayPal account. They really confused and finally they refused to buy the product.

My question is: If I using Ubercart and "PayPal Website Payments Pro", Can customer pay with credit card directly without redirected to other website?

Read here why Authorize.net is not my choice


texts: What's the purpose of subfolders inside a theme's templates folder?

texts:
What is the purpose of folders inside the templates folder in a theme? Where is specified that when rendering a page the template should be taken from layout/page.html.twig? Or a single node template from content/node.html.twig?

I could see content, block, field, form etc. in the /templates folder. I am referring to the Zymphonies theme. When I check Twig Template naming conventions I could see there are naming conventions for Twig templates. But what is the difference in giving Twig plain twig templates inside the templates folder and by giving specific twig templates in specific folders inside templates folder?


texts: How to inspect outgoing email content during a SimpleTest?

texts:
I see that SimpleTest has a few built in mail functions to check for send success etc, but how can I send a message, assert its content and then click a link within that content during a test?

What is the standard or most common way to test unsubscribe, or account verification links in emails with SimpleTest?


texts: How do I know when Hooks are called and in what order?

texts:
I want to alter a HTTP header and I am looking for the appropriate hook to use.  I can tell a general time of when some hooks are called but not exactly when.  How do I know exactly when hooks are called, and what hook I should be using to change my header?

edit:  I have managed to change my HTTP header. But something else is adding to my header and that is taking precedent over my header portion.  Is there a way to know where this is coming from?


texts: What's the best way to create variables that are available to every single URL on my site, based on node id or taxonomy id?

texts:
On Drupal site A we have a bunch of links to non-Drupal site B. For marketing and tracking purposes all these links have a different URL variable appended to them, so that when a user registers on site B we can determine where on site A they came from.

At the moment I use page.tpl.php to create the variable ($forceCode) but it now transpires I need this variable to be available to node.tpl.php too, and I feel like there must be a less hacky and more universal way of doing this, probably using a preprocess function in template.php that right now seems beyond my comprehension level.

PLAIN LANGUAGE EXPLANATION

$specialPages is an array of node IDs that need a special code.
$specialFolders is an array of taxonomy IDs that need a special code.

If the current node ID matches any in the nid array, I set the variable accordingly.
If not then I get the category (taxonomy) of the current node, or if the current page is a taxonomy term itself then use its own tid.

Then using this taxonomy ID I get all other tids that are parents of that tid.
Then I look for matches of any of these taxonomy IDs in my array of special tids in order to set the variable.

If the current page has not matched any of my special nodes or taxonomies, the variable remains its default value.

ACTUAL CODE

// we later restrict our parent taxonomy search to certain types but it's not strictly necessary
$contentTypes = array("article","advpoll","event");

$specialFolders = array(
    276 => "events",
    292 => "free-dating",
    498 => "date-explorer"
);
$specialPages = array(
    22 => "reviews",
    86 => "texting"
);

$forceCode = "default";

// check for specific page first
if (@array_key_exists($node->nid,$specialPages)){
    $forceCode = $specialPages[$node->nid];
} else {
    // there was no entry for this nid, let's check parent terms
    $parentTerms = array();
    $hasParents = false;
    if (arg(0) == "taxonomy") $hasParents = arg(2);
    if (@in_array($node->type,$contentTypes)) {
        $category = field_view_field('node', node_load($node->nid), 'field_category');
        $hasParents = $category['#items'][0]['tid'];
    }
    if ($hasParents !== false) {
        $parents = taxonomy_get_parents_all($hasParents);
        foreach ($parents as $term){
            $parentTerms[] = $term->tid;
        }
    }

    foreach ($parentTerms as $tid){
        if (array_key_exists($tid,$specialFolders)){
            $forceCode = $specialFolders[$tid];
            continue;
        }
    }
}


texts: Multiple nodes in one slide using views slideshow or another module

texts:
I have a slideshow using views_slideshow which displays the latest post from 4 different content types, I need the slide to show multiple contents (from different content types) in one slide, when you click next there should be another slide containing 4 nodes.

This image might explain you the scenario!


texts: Using Commerce Feeds module, commerce file names are being changed when importing

texts:
I have an e-commerce site that sells albums. This product variation type of album has a field of type commerce file. It’s configured to have multiple files (mp3’s) attached, or bundled to it. I’m using the Feeds & Commerce Feeds module. Feeds uses csv files to create these products.

The Feeds importer works but the file names are being changed. It’s appending a ‘_0’ to the file name.

for example:
songname.mp3 -> songname_0.mp3 (see attached)

I’ve tried numerous different settings within the file sources option of the product variation type. I’ve checked and unchecked ‘File attach from server directory’ option

note - I have File Field Path module installed because the dirs. need to be different (dynamic) for each product. For example:

private://artists/artist_name/album_name/song_name.mp3

Utlimately what I want to do is create the dirs. and add the files to server myself and then have the Feeds importer simply reference files that are already there. I don’t want to copy or upload.

Any insight or help would be hugely appreciated!


texts:
I've created a block using hook_block_info and hook_block_theme and the like. But how can I theme it?

I have it working to return an array with the keys 'subject' and 'content'. But I created the markup directly in the hook_block_view() hook and that's not what I want.

In the docs it's said that content should preferably returned as renderable array and not as markup. But what is this renderable array? They say it should be data instead of markup, but all I see in the examples is that it's just used as a wrapper for markup, so nothing gained there.

I want to be able to have a block--MYMODULE--DELTA.tpl.php in my theme but how do I call it and how can I pass the data to the block?


texts:
I recently went through a Drupal site I'm helping manage, doing a batch delete on a bunch of spam tickets through Administer > Content > Edit.

As it turns out, though, the data for this content seems to still be stored in the database, and is shown on our ticket list. Taking a look at a database dump taken after the deletion took place, confirms that they are in fact still present in the node and node_revisions tables.

Trying to access any of the tickets gives a "Page not found", and they're not listed in the "Edit Content"-list. Clearing the cache has been tried, and didn't resolve the issue.

In case it's useful, the node types are ticket.

Any insight into what has gone wrong and how to fix it would be most appreciated.


texts: I need to know if a field type is used on a website in a content type. How can I know that with Drush or Drupal BO?


texts:
so I have a content-type called "Team Member" and I'd like to sort for the field "last_name".

I currently get all the nodes using:

nids = db_select('node', 'n')
->fields('n', array('nid', 'field_last_name'))
->condition('type', 'team_member')
->orderBy('n.title','ASC')
->execute()
->fetchCol();

So currently, they are sorted using the title. How can I now tell it to sort using "last_name" field? I just don't see what exactly db_select needs to know here.

Im on D7.


texts: Correct SQL Statement for Joining Taxonomy Terms

texts:
I have 2 different taxonomy vocabularies setup.

Courses (First Aid, H2S Alive, Air Monitoring, Gas Detection,
etc...)
Locations (Vancouver, Calgary, Toronto, Montreal)

I have a content type called Landing Page for each of the courses that has a taxonomy reference field so you can assign a course or multiple courses to that node.

I have a second content type for Courses which also has the 2 taxonomy vocabularies set as taxonomy reference fields on its nodes. These course nodes get displayed in a calendar format and is setup with the entity registration module.

WHAT I NEED HELP WITH:

Im looking for a way to output a set of buttons on the Landing Page nodes that will give me a the list of locations that have been assigned to any node that is based on the given Courses taxonomy term.

For example;

3 Different Courses nodes all have First Aid assigned to them. However, they have 3 different locations set to them.

I've created a landing page for the First Aid Course assigned it the First Aid taxonomy term. I need to display a set of locations that this course has courses offered at.


texts: Deploying block settings as an update script?

texts:
I need to add a block to an existing Drupal site and would like to if possible automate the process using hook_update_N or something similar.

Specifically I'm referring to the position and region of the block relative to adjacent and following blocks. Is there a Drupal standard method to this process or do I simply need to use SQL to achieve this.

Is there a way to force a block in between others with some trick with the weights, or will I need to actively increment the weight of blocks below this in the same region?

Thanks for any advice!


texts: Omega & delta: rendering node title in a block

texts: Is it possible to render node fields as blocks with the omega theme and delta module? If I build a complex layout with zones and regions there can be situations where I need just the node title for example to be rendered in a block and then I can place it in the correct region.


texts: How to display node's taxonomy child items in node using views for multiple parents

texts:
I have a vocabulary with child terms

term
-child_term
-child_term_1
-child_term_2
-term_1
-child_term
-child_term_1
-child_term_2

Nodes have multiple parent terms assigned.

The goal is to display all parent and child terms in the exact node using views field.

I tried to implement it using taxonomy tree view with contextual filter (taxonomy term ID from the URL), but it displays only child terms for the first (one) parent item of the node.

Even view's "Preview with contextual filters" does not understand multiple contextual filter values with a "/"

How can I do this?


texts: How do I print the {{messages}} variable?

texts:
In Drupal 7 I was able to do something like this:

<?php echo $messages; ?>

It seems this variable is no more in Drupal 8.

{{messages}} // This returns NULL on {{dump(messages)}}.

I basically have a page--user--login.html.twig where I output the page.content and above that I want the messages to be displayed, in case there are errors on the page and not the entire header.

// Not desirable
{% if page.header %}
   {% block header %}
     <div class="col-sm-12" role="heading">
         {{ page.header }}
      </div>
   {% endblock %}
{% endif %}

What is the correct variable name for <?php echo $messages ?> in Drupal 8?


texts: A way to have an unchecked "end date" input field?

texts:
The date module gives the possiblity to collect an end date.
The thing is, in the node creation form, 'Show end date' is checked by default and the date calendar popup field is displayed.

I would like to have the opposite scenario.
With the End date field hidden by default, and it would only appear if we check the 'Show end date' checkbox.

Thanks to anyone who can help with this


texts: Creating node-based photo galleries with prev/next links within each taxonomy (specific gallery)

texts:
I want to create a collection of photo galleries where each gallery has it's own main page with thumbnails, and clicking on each thumbnail takes you to the node for that thumbnail with the full-size version of the image as well as next/prev links to go to other node pages within that same gallery.  I don't want to use colorbox or lightbox, all node-based per image entry per gallery.

My current plan is to use taxonomy to specify the different galleries, use views to create the individual gallery homepage, and use a custom content type for each image's node.  I'm not sure how to get the next/previous links on the node page to only go to nodes within that specific gallery, and couldn't find a module upon my initial search.

I'll be using Drupal 7.  Are there any modules that would do this, or is there a better approach to achieving the result in a way other than what I'm planning?


texts: AJAX form submit error when sending form to twig in hook_preprocess_page

texts:
I have a simple AJAX form that I can't submit when the form is passed from module to the template in hook_preprocess_page.  The same form works fine if sent from controller, it's just that the layout is complicated and I prefer to write the HTML part in the twig file and integrate the form where it fits best.

The form class:

    <?php

namespace Drupal\mymodule\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class SubmissionForm extends FormBase {
  public function getFormId() {
    return 'mymodule_submission_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['#prefix'] = '
';
    $form['#suffix'] = '
';

    $form['mail'] = array(
      '#title' => 'E-mail',
      '#type' => 'textfield',
      '#required' => TRUE,
    );

    $form['actions'] = array(
      '#type' => 'actions'
    );

    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => 'Submit',
      '#attributes' => array(
        'class' => array(
          'btn',
          'btn-success',
          'use-ajax-submit'
        ),
      ),
      '#ajax' => array(
        'wrapper' => 'submission-form-wrapper',
      )
    );

    return $form;
  }

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

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

The preprocess function:

/**
 * Implements hook_preprocess_HOOK().
 */
function mymodule_preprocess_page(&$vars) {
  if (\Drupal::service('path.matcher')->isFrontPage()) {
    $vars['page']['submission_form'] = \Drupal::formBuilder()->getForm('Drupal\mymodule\Form\SubmissionForm');
  }
}

The error:

  TypeError: Argument 1 passed to
  Drupal\Core\Ajax\AjaxResponse::setAttachments() must be of the type
  array, null given, called in
  /Volumes/Work/Git/myproject/public_html/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php
  on line 56 in Drupal\Core\Ajax\AjaxResponse->setAttachments() (line 37
  of
  /Volumes/Work/Git/myproject/public_html/core/lib/Drupal/Core/Render/AttachmentsTrait.php).

it's a fresh Drupal 8.7.10
devel and kint as contrib modules enabled
core inline form errors enabled
the form has only one required textfield and the submit button

Any suggestions on how to fix this?

Thank you!


texts: How to insert custom markup in a drupal 7 main-menu?

texts:
In order to justify my menu items following what reported in this question, I have to achieve a menu-structure like the following one.

Menu item 1

Menu item 3

Menu item 2

This means that I have to insert an empty  at the end of
.

How can this be done? Can I do it in the template.php file?


texts:
I have problems with incoming emails. Which are sent from the module webform (and use SMTP Module)

Mail destination are those with "domain.com". I reported receiving a first email with all the data readable. But there comes a second email with the following:

op: insert, sid: 4, components: nombre: value: REMOVED,
component: nid: 17, cid: 1, pid: 0, form_key: nombre, name: Nombre, type:
textfield, value: , extra: title_display: inline, private: 0, disabled: 0,
unique: 0, conditional_operator: =, width: , maxlength: , field_prefix: ,
field_suffix: , description: , attributes: , conditional_component: ,
conditional_values: , mandatory: 1, weight: 0, page_num: 1, empresa: value:
inClouds Group, component: nid: 17, cid: 2, pid: 0, form_key: empresa, name:
Empresa, type: textfield, value: , extra: title_display: inline, private: 0,
disabled: 0, unique: 0, conditional_operator: =, width: , maxlength: ,
field_prefix: , field_suffix: , description: , attributes: ,
conditional_component: , conditional_values: , mandatory: 1, weight: 1,
page_num: 1, e_mail: value: user@domain.com, component: nid: 17,
cid: 3, pid: 0, form_key: e_mail, name: E-mail, type: email, value: , extra:
title_display: inline, private: 0, disabled: 0, unique: 0,
conditional_operator: =, width: , description: , attributes: ,
conditional_component: , conditional_values: , mandatory: 1, weight: 2,
page_num: 1, tipo_de_requerimiento: value: user@domain.com, component:
nid: 17, cid: 4, pid: 6, form_key: tipo_de_requerimiento, name: Tipo de requerimiento, type: select, value: , extra: items:
user@domain.com,user@domain.com|Servicios
user@domain.com,user@domain.com,user@domain.com|Integración
user@domain.com|Componentes
user@domain.com|Otros, multiple: 0, title_display: before, private:
0, aslist: 1, optrand: 0, conditional_operator: =, other_option: null,
other_text: Other..., description: , custom_keys: false, options_source: ,
conditional_component: , conditional_values: , mandatory: 1, weight: 4,
page_num: 1, contenido: value: ola k ace, component: nid: 17, cid: 5, pid: 0,
form_key: contenido, name: Contenido, type: textarea, value: , extra:
title_display: 0, private: 0, resizable: 0, disabled: 0,
conditional_operator: =, cols: , rows: , description: , attributes: ,
conditional_component: , conditional_values: , mandatory: 1, weight: 5,
page_num: 1

I have in my contact form component "Select / Option".
Which is formed in the following manner:

user@domain.com, user@domain.com | Area 1
user@domain.com, user@domain.com | Area 2
user@domain.com | Area 3

I do this because there are 3 areas and certain emails should go to different recipients.

Why this would be happening? Is module problem? Or is the problem of emails recipients?


texts: Is it possible to rate a page generated with Views using the fivestar module?

texts: Fivestar works well with nodes, but is it possible to rate a page generated by Views? I can add the widget in a template, but how do I save the results? In the project description page of fivestar, it states that in Drupal 7 you can use it on any entity, but I don't think a Views page is an entity, is it? I found an old issue on the issue queue about this, but it was never updated once the new API was written.


texts: hook_form_alter : Not authorized value in a view exposed filter

texts:
I am using Drupal 8.
I have a view that shows some public content and some group content.
I try to add a filter on group name as select list.
I would like to have in the select list an option to get all content
and one options by current user's group.

So I made a hook form alter

function btw_features_form_alter(&$form, &$form_state, $form_id) {

    if ($form_id == "views_exposed_form" && $form['#id'] == "views-exposed-form-all-events-page") {
      $form['filter-user-group']['#type'] = 'select';
      $form['filter-user-group']['#size'] = null;

      $groups = array('All' => t(''));

      $user= \Drupal::currentUser();
      $grp_membership_service = \Drupal::service('group.membership_loader');
      $grps = $grp_membership_service->loadByUser($user);
      foreach ($grps as $grp) {
        $grpLabel = $grp->getGroup()->label();
        $groups[$grpLabel] = t($grpLabel);
      }

      $form['filter-user-group']['#options']=$groups;
      $form['filter-user-group']['#default_value'] = $form['filter-user-group']['#options']['All'];
    }
}

I encountered the folowing error :

  An illegal choice has been detected. Please contact the site administrator.

What i made wrong ?

thanks


texts: PHP Segfault error when running a migration

texts:
I ran drush migrate-upgrade on a Drupal 8 fresh installed site, and it generated the migrations (from Drupal 7 to Drupal 8).
After that, I tried to run drush mim upgrade_d7_user (after roles and fields migration). I got an error with PHP Segfault.

1410/34583 4%
/usr/local/zend/bin/php: line 4: 6040 Segmentation fault
$ZCE_PREFIX/php/active/bin/php -c $ZCE_PREFIX/php/active/etc/php.ini "$@"

I tried running the Drush command with debug and verbose, but I didn't get anything useful.
More Info:
I'm trying to run the users migration from Drupal 7 to Drupal 8 using migrate_tools module.
To Reproduce
drush mim upgrade_d7_user -vvv (To import the users from D7 to D8, this migration got generated with drush migrate upgrade command)
Expected behavior
Migration completed/failed with a success/failure message.
Actual behavior
Drush command terminates and shows PHP Segfault error. (Migration status is left to importing and I have to change the status to idle to run it again.)
Workaround
Is there another way to do the desired action?
I can execute the migration from UI from /admin/structure/migrate/manage/migrate_drupal_7/migrations/upgrade_d7_user.
When I run this migration from UI, I don't see this error.
https://gist.github.com/amangrover90/bef2e9185b267b5d7ed13160aa360ffc


texts: How do I set the default value of an exposed filter to a value that is not "-Any-"?

texts:
I have a view with exposed filters, in Drupal 8. I need to set the default value of a filter to its title or custom text. I also need to unset/remove the - Any - option from the select list.

How can I achieve this?

Here is my code:

    function bootstrap_barrio_subtheme_form_alter(&$form, FormStateInterface
    $form_state, $form_id) {
        if ($form_state['view'] == 'office_locations_doctor_detail') {
            $form['field_doctor_reference_target_id_1']['#default_value'] =
            'Select Doctor';
        }
     }

Cleared the cache and reload the page but nothing changed.


texts: Form element title is not displaying translation

texts:
I have got my own module providing a form and there is one element called "Estimated time" defined like this:

$form['informacie_o_incidente']['field_incident_doba'] = array(
  '#title' => t('Estimated time'),
  '#markup' => '
Estimated time:
'.$doba.'

',
);

I have translated the text "Estimated field" via translation interface, cleared cache several times (both GUI and with drush cc all command). However, when I run this drush command:

drush ev "print t('Estimated time');"

I am getting correctly translated string. So why not on the form?


texts:
I am following this tutorial and I've already created my custom form as Drupal 8 module.

I wonder, how to add custom text/html in form? I mean when somebody goes to the path pointed in *.routing.yml, I would like to display not only form fields, but also some intro html/text.

I know the form building is here:

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

$form['name_surname'] = array(
  '#type' => 'textfield',
  '#title' => t('Name and surname:'),
  '#required' => TRUE,
);
...
}

But I don't know what kind of entry (or #type) should I insert to get just an custom html/text block between fields or above them all?


texts: Getting the role ID from the global $user

texts:
I'm very new to Drupal, so please bear with me if this is a dumb question. According to the globals API, the global $user object returns roles as an array:

[roles] => Array(
  [rid] => name
)

If I reference $user->roles, it gives me the role names.

Short of looping through like this:

foreach($user->roles as $key => $value){
    error_log("key: " . $key . " ; value: " . $value);
}

Is there any way to return the role ID (rid) instead of the role name? I need to do conditional processing based on roles, but some of our roles are company-specific, and contain special characters. It would be much easier to work with the ID instead.


texts: How can I use 'format_type' => 'custom' for a datetime field?

texts:
I have a custom entity with (among others) a field defined this way:

$fields['duedate'] = BaseFieldDefinition::create('datetime')
  ->setLabel(t('Due Date'))
  ->setSetting('datetime_type', 'date')
  ->setDefaultValue(array(0 => array(
    'default_date_type' => 'now',
    'default_date' => '2050-12-31',
  )))
  ->setDisplayOptions('view', [
  'type' => 'datetime_default',
  'settings' => [
    'format_type' => 'date_courte',
  ],
    'weight' => 5,
  ])
  ->setDisplayOptions('form', array(
    'weight' => 5,
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

'date_courte' is a custom date format I created to display date as 'dd/mm/yyyy'. And it works!
I'd like to have the same result without using 'date_courte' so I tried

  'settings' => [
    'format_type' => 'custom',
    'format' => 'd/m/Y',
  ],

instead of

  'settings' => [
    'format_type' => 'date_courte',
  ],

And it doesn't work!

I'm pretty sure of 'format_type' => 'custom'.
I think the problem comes from 'format' in 'format' => 'd/m/Y'.

What should be the correct syntax?


texts:
My views shows the nodes of a content type. With an exposed filter I can reduce the result list (e.g. show all entries of a category).

I have a views page and a views block (with same views configuration).

On the page the exposed filter works without problems.
Using the block the exposed filter does not work, no response when I use the exposed filter. The filtering seems to be dead.

Can you help to solve this? Thank you.


texts: In the File Entity module, what is the difference between "Manage display" and "Manage file display"?

texts: As per the screenshot, what is the difference between "Manage display" and "Manage file display"?


texts: Omega 4: despite of environment set to production, css-file is full of sass-debug-info

texts:
I've built an Omega 4 subtheme, generating css through sass with 'drush omega-guard'. Despite my config.rb looks like this, all sass-debug-info{} rests in my generated css files:

saved = environment
environment = :production
if (environment.nil?)
  environment = :development
else
  environment = saved
end

output_style = (environment == :production) ? :expanded : :nested
line_comments = (environment == :production) ? false : true
sass_options = (environment == :production) ? {} : {:debug_info => true}

I there a wrong declaration in my config.rb or is there another setting overriding my config.rb?