texts:
I have a views-view-unformatted.html.twig template working fine where I can print fields from a view of nodes.

Example: having i = 3, print row number 3 title

{{ rows[i]['content']['#row']._entity.title.0.value }}

This view has also a working relationship with flag. I see it working in the view preview.

How can I print the flag link inside views-view-unformatted.html.twig?


texts: Can't go anywhere from user edit page after login

texts:
Having an issue with a certain user that is not reflected on other users, when this particular user is logging in he isn't redirected to homepage or to

  admin/dashboard

but to

  user/edit

page, and from there can't go anywhere, accessing any links lead to the same user/edit page and the url look like this example:

  /user/80/edit/account?destination=node

I'm getting the server response (again for this particular user)

  302: moved temporarily

Is that a server issue? If yes, why another users don't have this issue?


texts: How can i delete user profile picture in drupal 7?

texts: Is there a way that I can remove/delete user profile picture through programing? or How can i override existing image with my new one?


texts: How can I find all database schema changes introduced in a CiviCRM major version upgrade?

texts:
I'm using CiviCRM with Drupal. When upgrading a site to a new CiviCRM major version, it's very useful to know all the database schema changes introduced in the new version, so that any custom code referring to database fields can be amended accordingly.

A case in point is civicrm_contribution_recur.next_sched_contribution -> next_sched_contribution_date in 4.3 -> 4.4 .

"You shouldn't be accessing database fields directly, you should be using the CiviCRM API", I hear someone say. Often that is the preferred approach but even so, API v3 is very closely tied to the database structure and the fields returned by an API call reflect the database field names, so the code would still need amending.

A really useful resource for CiviCRM would be an equivalent of Drupal's  Converting n.x modules to (n+1).x documentation.


texts: How to find if file was successfully uploaded to webform

texts:
I am using the file field in webform, I would like to check if the file was successfully uploaded. I was using

  .onChange

But that only means that a file was attempted to be uploaded. How can I be sure if the file was correctly uploaded. Would like to do this via javascript/jquery to trigger some next steps.

Thanks.


texts: How to ONLY display an image in the teaser for Drupal 7

texts: I'm currently using a modified version of the Stark Theme, customized to what I need, on this site tobyNews. However, following some new design inspiration, I've decided that instead of showing text in the teaser I want to ONLY display an image. Each image would be displayed as a grid. What I need help on is getting the teaser to show just an image and not the title, date, or author.


texts:
In the process of building a headless website and one of the first requirements it was to provide JSON schema of my data model (JSON data from my entities.)

Here will be an example of the user entity.

{
    "User": {
        "type": "Object",
        "fields": {
            "first_name": {"type": "String"},
            "last_name": {"type": "String"},
            "age": {"type": "Number"}
        },
    }
}

This does not provide any real values rather than extra information to front-end developers to have an understanding of API. This is also useful for making sure that the API is always valid because we could provide a middleware that tests the API before even gets to the front-end app.

There are more examples of these JSON schemas at - https://www.npmjs.com/package/web-service-api

Do you know if there is an away to get this type of information in Drupal 8 programmatically?


texts: taxonomy tokens throwing invalid token error

texts:
I have a drupal 7 site, any time I use a token with taxonomy term in it, I am getting the error,

The Default path pattern for Product (applies to all Product content types with blank patterns below) is using the following invalid tokens: [term:name].

for example [term:name] or [term:description]


texts: Can a product support recurring and not recurring payment at the same time?

texts:
So if for some product variant I check option "Allow subscriptions" all product variants of that products can be bought only in recurring way? Is that true?

I mean, I can not have one product and one set of variations that can be purchased "normal" way (by paying whole price during checkout process) and other set of variations support subscriptions and recurring payment? Is that right?

If I want to support both ways of paying (recurring and "normal") for one product I actually have to create 2 separate products? Correct?

Asking because when I edit product variation fields "Subsription type" and "Billing schedule" are both mandatory.


texts: I'm created a content type and have got field_year. I want, sort my contents by field_year on my sidebar. How can I do this?


texts: Help understanding how to modify lay out of pages within drupal

texts:
I have built my website locally and I am trying to have three pictures display on all pages of the website. Those three pictures need to be on one line:

Now I have the pictures as such:

picture 1
picture 2
picture 3

I need:

  picture 1, picture 2, picture 3

I understand that I need to create a css file that will alter the structure of all the pages to display the pictures. I have done that following example on the net.

.field-type-image {
  float: left;
  padding-left:20px;
}

Now I have edited the .info file of my website to link the style.css but the pictures are still not showing the way I want. Moreover, they are only showing on one page.

What am I missing here ?

I have used firebug to try to find the css page on which I could have made the change for the pictures to appear but there were none. That is why I decided to create the style.css


texts: Coming from Drupal 7, which files should I be versioning with git in Drupal 8 projects?

texts:
So, having read through:

What are all the directories for in the new Drupal 8 structure?
https://drupal.stackexchange.com/questions/126660/how-do-the-seasoned-oo-php-people-go-about-setting-up-a-professional-development?rq=1
Cloning site and $config_directories
https://www.drupal.org/node/2360331 (especially #19 and #20)

... I'm still not sure what is best way to go when setting up a D8 project with git.

modules and themes

Apparently, the contributed/ custom modules and themes folders have moved from D7:

/sites/all/modules
/sites/all/themes

to:

/modules
/themes

in D8. When I copy modules to /sites/all/modules D8 does recognize them. But when I add modules via Admin UI, they get downloaded to /modules So, which folder to git? Is it generally bad practice now to go for sites/all?

Formerly, we had this file and git structure (D7):

/
↳ www.example.com
  ↳ sites
    ↳ all -> /repo/repo.git/all
↳ repo
  ↳ repo.git
    ↳ all

Now, I imagine it way more complex:

/
↳ www.example.com
  ↳ modules -> /repo/repo.git/modules
  ↳ themes -> /repo/repo.git/themes
↳ repo
  ↳ repo.git
    ↳ modules
    ↳ themes

just for the modules and themes.

This leads me to the question: what about sites/default/files/conf*?

I understand that this folder is being used for the configuration files, but:

is it right that my local dev environment and the staging/ prod environments have their very own folder?
is the usage of configuration files necessary when we only tend to have one "real", always up-to-date main database (prod/live)?
should the conf be tracked and deployed with git? Why?

Thanks a lot!


texts: Prevent CSS/JS query hash when preformance is disabled

texts:
When working in a dev environment with performance caching and aggregation turned off is there a standard way to prevent the cache clear hash from being appended to CSS/JS file names?

I'd like to avoiding hooking into the output and removing this manually in a dev only module.


texts:
In Drupal 8 some JavaScript changes were introduced: All JavaScript scripts should be defined using hook_library_info() and added to the page only with #attached attribute of the render array.
What should I do to define external libraries? Should I create a libraries directory and upload the library there, or should they be managed by the module using Composer?


texts: How can I output markup fields or descriptions in my Webform email?

texts:
I have a webform that requires a markup field, or alternatively, a description to be carried through to the email or "View form submission" page.

Typically one can put the token %email_values in the email template which will give a list of fields and their labels that are submitted to the form - but this doesn't seem to include markup fields, or field descriptions.

I have tried using other tokens such as %post or %value. For instance, I have a markup field with machine name "foo" in a fieldgroup "bar", and putting %value[foo][bar] just dumps the string [foo] into my email.

So is there a way to reference these parts of the webform?


texts: Updated to 8.5.1 but front end still says 8.4.4 installed

texts:
I have been going through and updating my drupal sites after the announcement of CVE-2018-7600.

All have gone smoothly except for one site that was running Drupal 8.4.4

I updated the site following the composer/drush method. This finished successfully.

When I access the sites admin section I still get the warning of a critical update and the Available Updates page states that the currently installed version is still 8.4.4.

I have tried re-running the composer/drush commands, composer returns Nothing to install or update and drush returns No database changes required. I have also executed vendor/bin/drush cr to rebuild the cache.
Navigating to /update.php in the browser returns a green No pending updates. page.
I have also tried logging out and back in, as well as clearing browser cache.

Is there anything else I can do? Is my site updated and just not displaying correctly in the front end, or is the site still vulnerable?

Edit:
Here is the contents of my composer.json file:

{
    "name": "drupal/drupal",
    "description": "Drupal is an open source content management platform powering millions of websites and applications.",
    "type": "project",
    "license": "GPL-2.0+",
    "require": {
        "composer/installers": "^1.0.24",
        "wikimedia/composer-merge-plugin": "^1.4",
        "drush/drush": "^9.2"
    },
    "replace": {
        "drupal/core": "^8.5"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "preferred-install": "dist",
        "autoloader-suffix": "Drupal8"
    },
    "extra": {
        "_readme": [
            "By default Drupal loads the autoloader from ./vendor/autoload.php.",
            "To change the autoloader you can edit ./autoload.php.",
            "This file specifies the packages.drupal.org repository.",
            "You can read more about this composer repository at:",
            "https://www.drupal.org/node/2718229"
        ],
        "merge-plugin": {
            "include": [
                "core/composer.json"
            ],
            "recurse": false,
            "replace": false,
            "merge-extra": false
        },
        "installer-paths": {
            "core": ["type:drupal-core"],
            "modules/contrib/{$name}": ["type:drupal-module"],
            "profiles/contrib/{$name}": ["type:drupal-profile"],
            "themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/contrib/{$name}": ["type:drupal-drush"],
            "modules/custom/{$name}": ["type:drupal-custom-module"],
            "themes/custom/{$name}": ["type:drupal-custom-theme"]
        }
    },
    "autoload": {
        "psr-4": {
            "Drupal\\Core\\Composer\\": "core/lib/Drupal/Core/Composer"
        }
    },
    "scripts": {
        "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
        "post-autoload-dump": [
          "Drupal\\Core\\Composer\\Composer::ensureHtaccess"
        ],
        "post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
        "post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ]
}


texts: How to have rendered node html in a preprocess function

texts:
I need to pre-fill a webform hidden field with the nid of a node and display the node formatted in 'preview' mode.

I formatted the URL like

  www.example.com/urlwebform?nid=56

and I built a preprocess like this one

function custom_preprocess(&$vars, $hook) {
  switch ($hook) {
    case 'webform_form':
        if( isset($_REQUEST['nid']) ){
            $vars['form']['submitted']['nid_field']['#value'] = $_REQUEST['nid'];
            $vars['form']['submitted']['pacchetto_nid']['#suffix'] = 'FORMATTED NODE HTML'
        }
        break;
  }
}

Now, how can I retrive the formatted HTML node in preview mode to display it?


texts: Which module(s) should I use to create a customer support section?

texts:
I've got a site where I need to get a customer (not client) support system set up. Support Ticketing System, unfortunately, is geared towards client support. I think Storm is too (it's huge, in any case).

The way I see it, I've got a few options:

Set up a different installation of Drupal entirely and use something like OpenAtrium or Drupal Commons for the support area. OMG overkill. Plus I'd like to just have it be a coherent part of my current site, same theme and shared logins and all that.
Patch Support ticketing system, or Storm, or whatever module I wind up using.
Use CaseTracker + Mailhandler to get a simple system, but I'll probably wind up still needing to do an amount of configuration to get it working.
Give up and use something like Trellis Desk on a subdomain.

One thing that maybe makes my search a little harder is that I'm adamant about having inbound email integration. The same way that we do, customers want to email an address and get a support ticket created. If this functionality isn't there, they'll send an email.


texts: How to restrict user access from all the paths except one?

texts:
Suppose you get users from an external service. In the case where the user is locked or has temporary password in the Service, I redirect the user to a change-password page in Drupal and assign to him a "tmp_pass" Role. When the user has that role, he can't see anything but that page.

How should I restrict the access to all paths/menus in one place?

I thought of implementing hook_menu_alter() and in the case of "tml_pass" role, assigning a new access callbacks to all the menus, but this is probably not a performance solution.

How can I achieve this?


texts: How to re-create content types using the feature module which removes deleted fields?

texts:
I've been looking into the Feature module to move changes from Dev to Staging without redoing everything.

On my Dev site I made changes in the content types (added new fields, deleted some field). Then I exported all content types as a feature and imported in to Staging. But still I see the deleted fields on staging.

I thought to delete all content types on staging and enable the module exported by feature but there is no delete option in content types.

Am I doing it in the correct way?


texts: How do I avoid unwanted users create accounts?

texts:
I am using Drupal 7 and use the User verification module for blocking (prohibiting) unwanted users in our site, but a user is creating an account every second.

How can I stop that from happening?

Is it possible to first send an email to the users, with a verification link  included? When that link is clicked, users will be registered on the site.


texts: How do I show a 403 error page when the server returns a 403 error code?

texts:
I use the nginx config file from https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/
It has return 403 and deny all on some file.
Ex. When I visit /core/CHANGELOG.txt, nginx returns default 403 Forbidden page.
I want it to display drupal 403 error page not nginx white default 403 page.
I have tried adding error_page 403 /403  but it returns

Not Found
The requested URL "http://mysite/core/CHANGELOG.txt" was not found on this server.


texts: How to put a site in maintenance mode by non-admin

texts: Is there a module (or other way) to give permission to non-admin-users to put the site offline (and only that permission)?


texts:
Im using entity api. How to update record in entity api

i have:

class ExampleTaskController extends EntityAPIController {

  public function create(array $values = array()) {
    global $user;
    $values += array(
       'title' => '',
       'description' => '',
      'created' => REQUEST_TIME,
      'changed' => REQUEST_TIME,
      'uid' => $user->uid,
    );
     return parent::create($values);
  }

Then:

$task = entity_create('ExampleTask', array('description' => "alamakota");
entity_create($task);

if my task have id=1 how to perform update on record? I want change 'description' to 'newtext' in record with id =1


texts: Auto rendered images from external links

texts:
I'm trying to make a functionality for users, so when they add a link in a body of some article(in text editor with other text), it displays as an image.
Any ideas?
Thanks)


texts: Node view, reference User and Profile2 fields

texts:
I am trying to accomplish the following.

I have a node view that shows fields based on the nid contextual filter.
This I use mainly for formatting purposes.

I then added a content pane where I want to show User AND Profile2 fields that reference the node being viewed.

When adding a relation ship to the profile, this does not seem to work..

Is there a clean way to do this, or do i need to create a separate user view for this?

The general idea is to show all users that reference this node in a content pane.

Thanks so much for all suggestions!


texts: alterations in tpl file work, but not dpm();, dsm(); or drupal_set_message();

texts:
This question here at DA has a popular suggestion to check page.tpl.php to see if it says print $messages;. I verified this and this is the case.

I cleared caches many times, btw after which there actually is a drupal message saying the caches are cleared.

I made sure the dpm(), dsm() or drupal_set_message() functions are nicely outside any conditional statement or php logic whatsoever. I also put all these functions on different places in the tpl file. Still no result.

The same theme also has another tpl file that I used before and had some commented dpm(); functions that I uncommented but these didn't work anymore either.

Devel module is enabled and I am logged in as admin the whole time.


texts: Moved drupal 7 site to new domain, white screen of death

texts:
I've recently moved a drupal site to a different hosting section on the same server, the new site is under a different domain. If I edit settings.php to the new database settings, the site white screens and no errors are reported.

However, if I place the old settings.php in then the site works perfectly. I think the new domain affects the move obviously but I'm not sure how?


texts: Contrib Module JavaScript interfering with Node

texts:
If one has a contrib module that works fine in most cases, but on a specific page (say /comment/comment) you wish it NOT to appear, but the options in Config don't give you that ability...what's the best practice for disabling functionality (in this case javascript) coming from the contrib module?

I'm using the sharebar module but it's all messed up in my comment/comment page. I tried hiding it with CSS (visibility:hidden) but can't target it no matter what I try. I even hid the html of the page itself and it still shows up! (although nothing else does)...which leads me to believe it's javascript...so how can I disable that for a particular page?


texts: How do I suggest broken link fixes to a Drupal module project page description?

texts:
I noticed that a Drupal module's project page description has a broken link.

How do I suggest/contribute the change? Is this done through GIT?


texts: Difference between hook_services_services and hook_services_resources

texts: I'm doing this tutorial to get familiar with the concepts of the Services module. In that tutorial, you implement a custom service for the Services module. Therefore it uses hook_services_services. But there are other tutorials (e.g. An introduction to Drupal 7 RESTful Services) that use hook_services_resources for the same thing. So what is the difference?


texts: Querying for user's whose birthday is today plus other OR conditions

texts:
We have a date field attached to the user entity.  It stores values for year, month and day, in the following format (looking at the field_date_of_birth_value column in the DB): 1987-06-08T00:00:00.

We are using EFQ and wish to return users who's birthday is today OR some other conditions on another field also attached to the user entity (field_babys_date_of_birth, which doesn't necessarily have a value for every user and has is stored in the same format as the other field).

Is there a way to compare the stored month and day with the current ones using EFQ? If not, how would you approach this problem?

Pseudocode specification

  FETCH every account where:
    date_of_birth == TODAY (month and day only)  OR
    babys_date_of_birth == TODAY + 6 MONTHS OR
    babys_date_of_birth == TODAY + 3 MONTHS
  END FETCH
  FOREACH accounts as account
    // Custom logic (always the same).
  END FOREACH

Implemented code

<?php
// Fetch users whose birthday is today.
$today = new DateTime('today');
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
  ->fieldCondition('field_date_of_birth', 'value', $today, '=');
$result = $query->execute();
$uids = array_keys($result['user']);
foreach ($uids as $uid) {
  $account = user_load($uid);
  // Custom logic (always the same).
}

// Fetch users where babys_date_of_birth == today + 3months.
$after_three_months = new DateTime('today + 3 months');
$after_three_months = $after_three_months->format('Y-m-d\T00:00:00');
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
  ->fieldCondition('field_babys_date_of_birth', 'value', $after_three_months, '=');
$result = $query->execute();
$uids = array_keys($result['user']);
foreach ($uids as $uid) {
  $account = user_load($uid);
  // Custom logic (always the same).
}

// Fetch users where babys_date_of_birth == today + 6 months.
$after_six_months = new DateTime('today + 6 months');
$after_six_months = $after_six_months->format('Y-m-d\T00:00:00');
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
  ->fieldCondition('field_babys_date_of_birth', 'value', $after_six_months, '=');
$result = $query->execute();
$uids = array_keys($result['user']);
foreach ($uids as $uid) {
  $account = user_load($uid);
  // Custom logic (always the same).
}
?>

Known problems with the code:

We think it should be better to have only one query to return all the accounts, as the custom logic to be executed is the same for all of them.
The first condition should only check for month and day (excluding year).

Maybe EFQ doesn't support ORed conditions, and we should use something else?


texts: Delivery Date Changes Price field value with New Custom Field

texts:
I got project with following requirements:

The customer should be able to select delivery date(date popup) in the checkout form.
The administrator can set special delivery date, in configuration settings.
If the customer select a delivery date that matches with special delivery date, the prices will change.
There are 2 price field in 1 product reference. The default price field and custom special price field.
Price value will change according to the delivery date that the customer selected.

For example:

Case 1:

The admin set Special date to be: Feb 14, 2016
The customer selected delivery date: March 2, 2016
The final product price uses the default price field value.

Case 2:

The admin set Special date to be: Feb 14, 2016
The customer selected delivery date: Feb 14, 2016 (match)
The final line item product price will use the value that was set in the custom price field.

What would be the workaround with this one. I feel stuck with my module. I was thinking if I need to use rules instead. Thanks in advance.


texts: find file physical directories location in drupal 7

texts:
I have news feed in drupal website. The news feed is XML format and can be read as https://www.mysite.ac.uk/news.xml. I can see via admin news content type. Now what I want to access or in other word how I can find physical location of this xml file in drupal directories. I have check root level and I cannot see any XML (news.xml) file there.

Many Thanks in advanced


texts: Attach javascript library and settings to a node page

texts:
Normally, to attach javascript (settings or just a library) to a Drupal 8 node type (page), you should use template_preprocess_node and add it to the #attached array. (example)

Problem with the display suite is that the function is never reached. So you can't add the library and optionally the settings for that library to that node.

Although the hook_preprocess_field function would suffice, I have the issue that I want to add it to a non-renderable field. So the field will never be displayed. I just need some javascript settings based on that field.

Example:

I have a node type: background_carousel_page
With a field: images (field type: image, multiple allowed)

I need to be able to add the images url to the settings of javascript to make the carousel displaying the images.

So to summarize: I need a solution where I can add the library + settings to a specific node based on a field that's not being rendered.


texts: Overriding the output for the primary navigation links

texts:
Is there another way the primary navigation is supposed to printed out besides how it is done in the core system template?

print theme('links__system_main_menu', array('links' => $main_menu));`

None of the changes I made via the theme_menu_link() function are recognized when the links are printed this way. Are they only seen if I manually put the primary links block into a region?

Which is the function that I could use to override the primary links when printed out this way? Everything I have with theme_menu_link() does nothing.


texts: How can I create a download link to a private file?

texts:
I have a views page that is only accessible by a certain user role. This user role also has permission to "view private files" and to "document: download any files" (coming from File Entity Module). The views page displays a table of all private .pdf files that lie in the private file directory and I would like to add a column to this table, using a Views PHP field (at least for prototyping), that displays the corresponding download link next to the file name. As mentioned above, any user that can view the table also has permission to view private files and to download documents, so this should be doable and not be a security issue.

For now, let's assume I always want to display the download link to a fixed private .pdf file, say with file id $fid=17. According to Working with files in Drupal,

  once configured, files stored in the private directory are inaccessible via a direct link; however, if Drupal constructs a link to the file, the file will be accessible to anyone who can see the link.

What precisely is meant by "if Drupal constructs a link to the file"? I have read many times that file_create_url() will create a direct link that, if the user has access to view private files, will take the user to the private file. So I tried in my Views PHP field as output code

<?php
$fid = 17;
$file = file_load($fid);
$uri = $file->uri;
$url = file_create_url($uri);
print l(t('Link'), $url);
?>

and the link gets displayed as it should (with reference to mysite.com/system/files/Name_Of_Private_File_17.pdf). But even though the user has permission to view and download private document files, clicking on the link will result in an "Access denied. You are not authorized to access this page."

Can anyone tell me the correct workaround?


texts: Why aren't the options in my dynamically inserted webform showing up?

texts:
I've created a webform with one question that includes a list of checkboxes.

I made the webform available as a block, and am rendering the block in my template using:

<?php
$block = module_invoke('webform', 'block_view', 'client-block-#####');
print render($block['content']);
?>

However, when the form renders, I see the title of the question and the submit button, but the options are not visible. How can I debug why the checkbox options aren't showing up?


texts: Drupal 7 Views filter criteria Entity Reference

texts:
At the moment i'm making a drupal environment.

I'm trying to reach the following:

"Use a views to show my content types, but only the content types that have lets say "ads" as a field_type (Entity Refrence)."

Setup:

Content Type: Packets

Title
Image
Entity Reference field_type to Content type: packets_types..

It gives me blank result.. the sort criteria is just working fine on thee Pakket_type

I've tried the Relationships, but this didn't changed anything for me.

If there is someone out there to help me, i would love that =)

Already thanks!


texts: Upgraded to 7.31 but getting "no pending updates" message

texts: After copying over the files for 7.31 (was 7.26), minus the /sites folder, and running update.php, the result is "no pending updates." I followed the instructions at https://www.drupal.org/node/1494290 properly - any thoughts about what to do next? Thanks.


texts: SQL Error on Calendar View with Relationships

texts:
I have a calendar set up to show a date field from nodes that I get using relationships.

The relationship goes:

Application > Discipline > School > Date Field

In my view I get this error when attempting to use that date field as an argument in the Calendar:

user warning: Unknown column 'node_data_field_school_term_deadline.field_school_term_deadline_value' in 'where clause' query: SELECT DISTINCT node.nid AS nid, node.title AS node_title, node.created AS node_created, node_node_data_field_discipline_school_node_data_field_school_term_deadline.field_school_term_deadline_value AS node_node_data_field_discipline_school_node_data_field_school_term_deadline_field_school_term_deadline_value, node_node_data_field_discipline_school.nid AS node_node_data_field_discipline_school_nid, node_node_data_field_discipline_school.type AS node_node_data_field_discipline_school_type, node_node_data_field_discipline_school.vid AS node_node_data_field_discipline_school_vid, node.changed AS node_changed, node.type AS node_type FROM node node LEFT JOIN content_type_application node_data_field_application_discipline_id ON node.vid = node_data_field_application_discipline_id.vid INNER JOIN node node_node_data_field_application_discipline_id ON node_data_field_application_discipline_id.field_application_discipline_id_nid = node_node_data_field_application_discipline_id.nid LEFT JOIN content_type_discipline node_node_data_field_application_discipline_id_node_data_field_discipline_school ON node_node_data_field_application_discipline_id.vid = node_node_data_field_application_discipline_id_node_data_field_discipline_school.vid INNER JOIN node node_node_data_field_discipline_school ON node_node_data_field_application_discipline_id_node_data_field_discipline_school.field_discipline_school_nid = node_node_data_field_discipline_school.nid INNER JOIN users users ON node.uid = users.uid LEFT JOIN content_type_school node_node_data_field_discipline_school_node_data_field_school_term_deadline ON node_node_data_field_discipline_school.vid = node_node_data_field_discipline_school_node_data_field_school_term_deadline.vid WHERE ((node.status = 1) AND (node.type in ('application')) AND (users.uid = 1)) AND ((DATE_FORMAT(STR_TO_DATE(node_data_field_school_term_deadline.field_school_term_deadline_value, '%Y-%m-%dT%T'), '%Y-%m') <= '2011-12' AND DATE_FORMAT(STR_TO_DATE(node_data_field_school_term_deadline.field_school_term_deadline_value, '%Y-%m-%dT%T'), '%Y-%m') >= '2011-12')) ORDER BY node_changed ASC in /var/www/clients/client4/web39/web/sites/all/modules/views/includes/view.inc on line 799.

I'm not sure why it would be an unknown column. I don't know sql very well so I don't know where to begin when debugging this.

Any suggestions?


texts:
Hello I am working with Views PDF Module, and I am asking how could add a fields to the PDF template file

Thanks.


texts: How do I get navigation menu on top with narrow viewport?

texts:
I'm running Drupal 7.28 with Zen 7.x-5.5.  In the default setup, there is a region on the right side named "First sidebar" which contains a block named "Navigation".  I have put my navigation links there.  When shrinking the width of the browser to see how my site will be rendered on a mobile the navigation block gets positioned at the bottom of the page.

I want the navigation to be at the top in a mobile scenario, ideally with a bootstrap-esque collapsed menu.  How can I achieve this?


texts: How to display unanswered questions when using the Answers module?

texts:
I am using the Answers module 7.x-4.0-rc2. I would like to have links to different displays of the questions view so that one link goes to only unanswered questions and the other link shows all. When I go to filter options, I'm not sure how to filter the content by if there is an answer or not.

This is done on the demo site but out of the box, the 7.x-4.0-rc2 version of the module doesn't have any special views. See screenshot of the demo site below.

Edit:
When attempting to import views from https://www.drupal.org/node/2783513#comment-11516603 as suggested, I get the following errors for rankings.txt, repeated:

  Style plugin datatables is not available.
  Field handler userpoints_total.points is not available.
  Field handler userpoints_total.last_update is not available.
  Sort criterion handler userpoints_total.points is not available.
  Unable to import view.

When importing questions.txt, I get:

  Style plugin datatables is not available.
  Field handler userpoints_total.points is not available.
  Field handler field_data_field_tags.field_tags is not available.
  Relationship handler userpoints_total.uid is not available.
  Unable to import view.

I attempted installing answers_userpoints (which is uninstalled) but could not do so because it depends on userpoints_rules, which couldn't be found or downloaded.

Edit 2: I took a look at the code for the exported view for unanswered questions, and believe that section I need to replicate is the following portion; this issue I am having is that COUNT(Flags: Flagged) doesn't seem to be available as a filter but I do have flag enabled.

/* Filter criterion: COUNT(Flags: Flagged) */
$handler->display->display_options['filters']['flagged']['id'] = 'flagged';
$handler->display->display_options['filters']['flagged']['table'] = 'flagging';
$handler->display->display_options['filters']['flagged']['field'] = 'flagged';
$handler->display->display_options['filters']['flagged']['relationship'] = 'flag_content_rel';
$handler->display->display_options['filters']['flagged']['group_type'] = 'count';
$handler->display->display_options['filters']['flagged']['operator'] = '!=';
$handler->display->display_options['filters']['flagged']['value']['value'] = '1';


texts:
I just came across a solution regarding media module.
It suggested that:
replace all
unset($form[$id]);

to
$form[$id] = array('#language' => NULL);

in media_gallery.module
This worked nicely for my problem, but I do not understand what it actually does.
The unset is used when we want to remove a field from a form, fx when someone does not have access to the form.
Is the 2nd equivalent of the 1st?


texts: 7 - Mapping multiple LDAP groups to single Drupal roles using Boolean operators

texts:
I'm attempting to set up fairly complex permissions in D7 based on LDAP group membership, and it would help greatly if there were a way to use Boolean operators to perform the role mapping.

Some context:

There are multiple, similar departments: each has a pool of employees, and each has a manager.
LDAP groups map to departments as well as roles. The manager of the Finance department belongs to two groups: one that designates the group Finance_dept, another that designates the group Managers.
Managers should have R/W access to parts of the site that correspond only to their respective departments; employees should only have R access.

What I've tried (and ruled out):

I have the LDAP module configured to provision Drupal roles based on LDAP group membership--that piece works well for one-to-one mappings; e.g.:

Finance_dept|finance
Managers|managers

I've tried various iterations of LDAP search filters, to no effect:

Finance_dept & Managers|finance_managers
(&(Finance_dept)(Managers))|finance_managers

Has anyone gotten this to work?


texts: How to count date difference excluding weekend and holidays in Computed Field

texts:
How to count date difference excluding weekend and holidays?

I should count the number of days between two dates but the weekends and holidays must be excluded from the counting. I used Computed Field.

$start_date_value = array_pop(field_get_items($entity_type, $entity, 'field_date_from'));

$end_date_value = array_pop(field_get_items($entity_type, $entity, 'field_date_to'));

$start_date = new DateObject($start_date_value['value'], '');

$end_date = new DateObject($end_date_value['value'], '');

$entity_field[0]['value'] =$start_date->difference($end_date, 'days');

Here is my working code for counting the days.


texts: did the registration page in which the user enters the desired field to me, I try to search for these fields, use the search module api, but can not  find where I must to create a search field - for example, a user at registration indicates that he smokes in finding should be a line "smoking" yes, No (checkbox) - here I can not think of how it makes


texts: How to get Media entity image (Entity Reference Field) URL in TWIG theme

texts:
Apologies if this question has already been asked. However, in my research I found the answers have been for simple image fields which are in default install of Drupal 8. However, in order to have reusable media, I am using Media Entity and associated modules. The problem is I am not able to access image or its URL in TWIG template, where simple image fields work just fine.

While the code below works as expected if field_image is a simple Image type, but doesn't work if it is Entity Reference field.

<div class="header-title white overlay" style="background-image:url({{content.field_image.0}});">

In case of Entity Reference field, the output is fully escaped and breaks the structure of my theme. How can I get raw image or URL? I am not a programmer so I don't know how to write preprocessor code.

I am attaching configuration images for the Media Bundle I am using and the node configuration in which I'm using the two types of image fields.

Media Bundle configuration

Node configuration. Note, 'field_image' is default drupal image type, while 'field_image2' is an entity reference field as configured in the Media bundle above.

Please advice how to get this working. Thanks.

Drupal Configuration

Drupal 8.3
media_entity_browser-8.x-1.0-beta2
media_entity-8.x-1.6
media_entity_image-8.x-1.2
embed-8.x-1.0-rc3
entity-8.x-1.0-beta2
inline_entity_form-8.x-1.0-beta1
file_entity-8.x-2.0-beta3
file-8.2.6
field_formatter-8.x-1.0
image_raw_formatter-8.x-1.x-dev
image_url_formatter-image_url_formatter


texts: How to create a query nodes, that queries content with more than one comment?

texts:
Consider this example:

  $query = \Drupal::entityTypeManager()->getStorage('node')->getQuery();
  $nids = $query->condition('type', 'question')
    ->condition('status', 1)
    ->condition('field_category', $tid)
    ->sort('created', 'DESC')
    ->pager(10)
    ->execute();
  $questions = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);

I would like to only query the questions, with answers. (that are comments)
I was hoping adding ->condition('comment_node_question.0.comment_count', '0', '>') would work, but no luck.


texts: Import users from old site with no email address

texts:
As the Molot pointed out, my question is crap.. so, ignore?

Current plan is to simply drop-in the existing authentication scheme and associate successful logins with the new accounts. Somehow..

Original cruft for posterity/horror:

I've hit a logistical road-block migrating a site from LAMP stack into Drupal.. none of our users have email addresses listed.

We previously used reddit OAuth, so they just hit Login but only their Username was ever saved..  ergo we have no idea what their email address is!

How can I import hundreds of users without MAKING them re-sign-up.. possibly breaking a trust with the community?

My idea is to simply spoof phony email addresses, and somehow hope that it works when they try and login again using their OpenID creds.. but I'm thinking its never going to work.

We have the https://www.drupal.org/project/social_login system in place to handle multiple types of site login providers, however the origin site only used reddit. perhaps we should simply lock it down to a single source again, and slowly open it up again after relaunch..

Alternately, perhaps I should simply modify the social_login system itself to detect an existing user from the original OpenID provider and link the accounts then and there, perhaps asking for an email address at that time.. Dunno.
I don't think this issue is the same: https://www.drupal.org/node/1955820 as I don't have an email address to match.
The module seems to use:  social_login_core_get_user_for_user_token($user_token); to restore the login for existing users, except we won't have associated that users token yet, as they won't have ever logged into the new site.. I'm sure there is security issues surrounding things like this that would break my desire to simply grab all the user-tokens for our existing users?

IDEAS INCREDIBLY WELCOME!

I'm leaning towards the garbage approach illustrated here: Ignore "invalid" or incorrectly formatted Emails addresses (on Signup/User Import)


texts: How to alter SQL queries in theme layer in Drupal 8?

texts:
In Drupal 7, we could use

  hook_query_alter()

in theme layer since drupal_alter() made modules and theme run the alter functions, but in Drupal 8, it seems this as been restricted to custom modules...

Is this true? or can themes partake too? another way?

I have a view, that i will change context argument depending on page it is rendered.


texts: How to create a link on a field in a custom template file

texts:
I created a custom tpl file for the teaser of a node.
To print the fields i use render() eg:

render($content['field_subtitle']);

This all works fine but i would like for example that the rendered output of field_subtitle has a link to the actual node.

My workaround for the moment is to do something like this,

<a href="<?php print $node_url; ?>">
   <?php print render($content['field_product_subtitle']); ?>
</a>

This works but produces some nasty looking html with div's inside the .
So i was wondering if you could just add a parameter to the render function that produces a link to the node?


texts: How to redirect after node insert (not form redirect)?

texts:
I am trying to find out how to redirect after I insert a new node. All the answers I have been able to find discuss $form_state->setRedirectUrl(); but this is a form redirect; not a proper redirect after insertion.

The difference is that when I submit the node form; I use hook_node_insert to create another entity based on information from the node being inserted. After the parent node is inserted; I want to redirect to a path based on the entity id of the new child entity.

In hook_node_insert (for the parent; i.e. original form submit)) I set a drupal_register_shutdown_function which properly saves my child entity and I then have the ->id() of the new (child) entity.

I have seen various examples using RedirectResponse, such as this:

$redirect = new RedirectResponse(Url::fromUserInput('/admin/commerce/orders/' . $order->id() . '/payments')->toString());;
$redirect->send();

but none of these work.

EDIT

to try to line this up with @4k4's suggestion, this is where I am at:

function my_module_node_insert($node) {
  $s = \Drupal::service('sia_general.redirects');
  $s->createPolicyRedirect($node);
}

in my Service:

class RedirectServices implements EventSubscriberInterface {

  static function getSubscribedEvents() {
    $events[KernelEvents::RESPONSE] = ['gotoPolicy'];
    return $events;
  }

  public function createPolicyRedirect($policy) {
    $this->policy = $policy;
  }

  public function gotoPolicy(FilterResponseEvent $event) {
    // We only care if this happened after policy was created.
    if (!$this->policy) {
      return;
    }

    $redirect = new RedirectResponse(Url::fromUserInput('/node/' . $this->policy->id() . '/edit')->toString());;
    $event->setResponse($redirect);
  }
}

when the Policy node is created; the hook_node_insert is called, which in turn calls the createPolicyRedirect() service and passes the newly created Policy object. After this it returns to the event subscriber which originally called the function which created the Policy. After that it hits the final pass of gotoPolicy(); but $this->policy is not set at this point.

Just to test that the redirect response worked as i hope; i tried setting a SESSION var in createPolicyRedirect(); but even that isn't set once i get to final gotoPolicy call.

EDIT #2

Still no luck and guessing due to the event handler within event handler that i am doing... so more context.

The complete flow is as follows:

create App entity
this adds items to Commerce cart
admin adds payment
PaymentComplete handler "places" the Order
OrderComplete handler loads the App and sets a Workflows field and then saves  the App
during the App->save(), the change in Workflow triggers creating a Policy entity
this triggers my hook_node_insert($policy) (note: this is still within OrderComplete event handler).
in my insert hook i fire my 1st method above (which sets $this->policy)
i then return to finish the OrderComplete event handler
after the OrderComplete is finished; i hit my final run through the 2nd method (the KernelEvent); but by this time, $this->policy is no longer set.

My guess is that the ordercomplete does a page load before my kernel event is run (not sure that makes sense); so maybe this is a bug in Commerce; or at the very least i need to approach this differently, like alter what commerce is doing. Perhaps Drupal's event handling system isn't quite ready to handle situations this complex yet??


texts:
I have a query like this in Drupal 6:

$sql = 'SELECT sid, score FROM search_index WHERE word LIKE "%%%s%%"';
$result = db_query($sql,$search_term);

And it worked fine, but now I'm upgrading to Drupal 7.

I read up and this is supposed to work, but it's not:

$sql = 'SELECT sid, score FROM search_index WHERE word LIKE "%:term"';
$result = db_query($sql,array(':term'=>$search_term));

Does anyone know what I'm doing wrong?


texts: Get link field URL in Display Suite Token field

texts:
I have a custom block type with a link field.
I'd like to get the URL only from that link field in a Display Suite token field.

When I try this: [block_content:field_career_highlight_button:uri]
I get this: internal:/news/2020/correct-path which is not a valid link.
How can I get a valid link url?


texts: How to calculate the average ratings for the post when the user submits 3 field ratings?

texts:
I need to implement ratings in my site. I have user five star rating and voting API module, I created a content_type with "beach", and created some field in the manage field settings, name, id, etc. And also I configured the five star module with tags like location ratings, beachratings, facilites ratings and overall (average ratings) ratings. I display all the rating stars in the page by using the code.

$bid=explode("/",$_GET['q']);
$node = node_load($bid['1']);// we get the node id here//
$fivestar = field_view_field('node', $node, 'field_overall_ratings');
echo render($fivestar);
$beachrating=field_view_field('node', $node, 'field_beaches_ratings');
echo render($beachrating);
$locationrating=field_view_field('node', $node, 'field_location_ratings');
echo render($locationrating);
$easyrating=field_view_field('node', $node, 'field_easy_to_get');
echo render($easyrating);

When I submit the ratings, they are stored in the database but the average is not updating.
But I need to calculate the overall ratings when the user votes for the three section. Can anyone help me how can we implement this in my site?


texts: I want users to be searchable by their location. How do you add a free tagging widget type to a location field. Or, can GMAP/Location recognize every city as a term? Basically, how can users have location terms in their profile.


texts:
How to add html tag in a form element drupal 8?

$form['buttons']['submit'] = [
  '#type' => 'submit',
  '#value' => T('Send'),
  '#prefix' => '
',
  '#suffix' => '<button type="button" class="btn btn-sm btn-default" data-dismiss="modal">' . $this->t('Close') . '</button>
',
  '#attributes' => [
    'class' => ['btn-success'],
  ]
];

I try to add allowed_tags:

$form['buttons']['submit'] = [
  '#type' => 'submit',
  '#value' => T('Send'),
  '#prefix' => '
',
  '#suffix' => '<button type="button" class="btn btn-sm btn-default" data-dismiss="modal">' . $this->t('Close') . '</button>
',
  '#allowed_tags' => ['button'],
  '#attributes' => [
    'class' => ['btn-success'],
  ]
];

OR

$form['buttons']['#allowed_tags'] = ['button'];
$form['#allowed_tags'] = ['button'];

Not working...
Help me please!


texts: Theming color attributes in Commerce Kickstart

texts:
After much tinkering I finally could install images as color attributes in Kickstart.

http://i.imgur.com/eHHNCBX.png

Several problems:

  Images do not display their own titles, but the field name.
  I do not need the product variations title.
  I need image attributes displayed in rows of 10, in small expandable thumbnails, I should be able to use colorbox or Cloud Zoom
  on them.

Please help.


texts: I want to have navigation menu inside few pages on the left panel apart from the website's main menu on the top, and these menu items will be different for different pages. Is there a module for that?


texts: Authorize.net Getting error "A valid amount is required."

texts:
In our project we have used Commerce Authorize.Net module. We have not added any discount. No coupons are applied yet still when we proceed to checkout in testing mode we are always getting error as "A valid amount is required.". Our product price is $17.95 and when we get response from Authorize.net we are getting price as $-99.05 and hence payment is declined.

We have also used PayPal for payment method and it is working fine and giving proper amount for same product.

How can we solve this issue?


texts: Module that allows visitors to suggest modifications on a node

texts:
I'm looking for a module (or some other way) that allows users to send suggestions about how to edit a certain node. I'll explain:

There is a node type with the following fields: name, description and phone number. One node contains these values:
Name: "Lulu's Restaurant"
Description: "A very good restrurant"
Phone number: "123456790"

A visitor notices that some values are incorrect, clicks on a link "send suggestion" and he's brought to a form where the fields are filled with the node's data. The visitor edits the fields

Body: "A very good restaurant"
Phone number: "1234567890"

And clicks on "send", this will memorize the data on drupal (on a different place than the node, but this has to be linked with the node) and notifiy registered users of this new suggestion.
Registered users should be able to see a comparison view of the original node and the suggestion (possibly with highlighted text, like your typical diff checker application) and then edit the node accordingly.

Registered users should also be able to change the status of the suggestions (pending, accepted, not accepted, spam).
Another feature i need is that visitors (unregistered) should be able to subscribe to nodes and receive notifications whenever the node is edited.

I think some basic features can be done with normal drupal features (like a node that can be created by unregistered users) or the rules module for notifications, but i was wondering if there's a specialized module to do this.


texts: Programmatically change block content on page render only

texts:
I have a situation where I want to change the content of a block on certain conditions, but not permanently.

I'm using a theme_preprocess_block() hook to change the content of the block, but it's not carrying through to the page render:

function MYTHEME_preprocess_block(&$variables) {

  if ( $variables['base_plugin_id'] == 'block_content'
    && $variables['attributes']['id'] == 'block-mycustomfooterblock' ) {

    $variables['content']['#block_content']->set('body', [[
      'value' => 'New Content',
      'format' => 'full_html',
    ]]);

Even after clearing caches, the block content doesn't get replaced with "New Content".

I added this line

$variables['content']['#block_content']->save();

However, that permanently saved the change to the block, which I don't want.

How can I alter the block content just for the page render?


texts: Is it possible to add template suggestions for image styles?

texts:
I am experimenting with durpal 8 theme hook suggestions. I tried to customize the the theme suggestions based on the style name. I want the ability to add a twig template for each style if I wanted so I tried this:

function themename_theme_suggestions_image_style_alter(&$suggestions, array $variables, $hook) {
  $suggestions[] = [$hook . '__' . $variables['style_name']];
}

and

function themename_theme_suggestions_image_alter(&$suggestions, array $variables, $hook) {
  $suggestions[] = [$hook . '__' . $variables['style_name']];
}

I was expecting to see this as a theme hook suggestion in the html comments printed by in the page source after enabling twig debuging.

Using xdebug the hook is triggered but I don't find it in the suggestions list in the html after enabling   twig.config.debug to true.

am I missing anything?


texts: Twig template suggestions for user default, compact, and user account view modes

texts:
Is there a way i can create a diffrent template than user.html.twig to have a diffrent View mode when i use default, compact or user account

Something like user--compact.html.twig ?


texts: Using FBOauth, only allow existing users to associate a Facebook account

texts:
How might I configure a login scheme where by

if someone already has an account on the site they may associate a FB account and login with it
But yet, deny login to any FB account that is not already associated with an existing account

Is something like this approachable?

In other words, I don't want random FB accounts to log into a Drupal instance but yet, want to allow existing users to associate a FB account with their Drupal login.


texts: Child navigation sidebar or drop-down navigation displaying child items

texts:
I have a 'basic page' which is a parent and is provided a menu link. This page has several children (subpages).

How would I display the subpages for each nav item either in the following cases?

Drop-down menu from the main navigation menu, or some close alternative
Display all the children for that page in a sidebar


texts:
I want to build popups in Drupal 8. This is the code I am using.

$attr = array(
 'attributes' => [
   'class' => ['use-ajax'],
   'data-dialog-type' => 'modal',
   'data-dialog-options' => Json::encode([
     'width' => 700,
   ]),
 ]
);
$url = Url::fromRoute('resume.grade_detail', ['uid' => $id, 'courseid' => $courseid]);
$internal_link = \Drupal::l($average, $url, $attr);

return array('#markup => $internal_link);

In the rendered output, i don't find the CSS classes I added; as result, the popup doesn't work.

I need help.


texts: How to display users with same select list value to each currently logged in user

texts:
In my site each 'User' as a profile (created using Profile 2). One of the fields in the profile is a 'Select list field' that allows the user to choose his/her State of origin.

Please how can I create a View which displays to each "currently logged in  user", the people who come from his/her State.

I have tried the following but it returned empty.

I created a User view.
I added some fields
I added the following relationship- "User:Profile"
I added the contextual filter on "(Profile) Profile:State" to provide default value from "User ID from logged in user" if filter value is not in the URL.
I added the contextual filter on "User:uid" to provide default value from "User ID from logged in user" if filter value is not in the URL.


texts: Problem with character encoding ( danish æ ø å ) when using page handler include files in hook_menu().

texts:
When I use an .inc file to handle my page output, all the danish special characters (Æ, Ø and Å) shows up as question marks, i.e. they are rendered with the wrong character encoding.
This following module works as expected.
stack_exchange_minimal.module
<?php
/**
* Implements hook_menu().
*/
function stack_exchange_minimal_menu() {
  $items['mypage'] = array(
    'title' => 'Minimal example',
    'page callback' => 'mypage',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function mypage() {
 return 'ÆØÅ - æøå'; //outputs 'ÆØÅ - æøå'
}

When I split the code up in two files, however, it doesn't.
stack_exchange_minimal.module
<?php
/**
* Implements hook_menu().
*/
function stack_exchange_minimal_menu() {
  $items['mypage'] = array(
    'title' => 'Minimal example',
    'page callback' => 'mypage',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
    'file' => 'stack_exchange_minimal.pages.inc',
  );
  return $items;
}

stack_exchange_minimal.pages.inc
<?php
function mypage() {
 return 'ÆØÅ - æøå'; //outputs '��� - ���'
}

I have tried passing the text through a render array instead of just dumping a string as the return value, but whith the same results.
I'm using drupal core version 7.31
What can I do to work around this issue?


texts: Running an immutable setup in production

texts:
I'm looking into using Docker to streamline my Drupal development workflow. One approach would be to locally create a Docker image for my Drupal installation (not the database, just the Drupal files default found under /var/www/html), and deploy that image to production.

This approach would imply that all changes to the Drupal installation, i.e. all changes to anything under /var/www/html, would be considered immutable or read-only in production. Any changes here would be gone when the next deployment comes along.

I assume the content created by our content creators logged into our production server, is stored in the database, not in the Drupal installation itself.

My question is: Is there any reason why the Docker installation (i.e. files under /var/www/html) would need to be changed when deploying to production, or can these files remain consistent across environments (dev, test, prod)?

Note that I'm quite new to Drupal.


texts: How to change the SID of webforms to increment from a new starting number

texts:
We launched a new website that uses webforms but need to make sure our webforms are using an SID for results larger than the last number used on the old site.

Please note that I am not referring to the serial for the webform submission but Drupal's SID.

For example, on the new site, the first submission ID was 1. I need it to be 10000.


texts: How to serve files from a second server in Drupal 6?

texts:
I have bandwidth limitations for a busy and image-heavy D6 site so I decided to outsource my /webroot/site/default/files to my second server which is almost idle.

I tried to do so using CDN module, which I previously used successfully with a CDN provider. So I moved (and rsynced) all the files to the second server and set up a cdn.mydomain.com there. I could wget images directly off the second server but for some reason I could not manage to display images on the site.

Due to my budget constraints I can not use S3 or any commercial CDN for this purpose. So I am wondering what you guys suggest to serve static files from my second server?


texts: How to lock in the Sort Order for view display?

texts: I've got a View of 10 images displaying inline, the first and last images are different (have rounded corners), and it is really important that the order for all 10 images is locked in. Is there a way to do this, without having to edit all the nodes in order to get them displaying in the correct order?


texts: Disable welcome message for specific roles but keep for others, user_mail_notify

texts:
In Drupal 7...

I am trying to find a solution to disable the sending of the user mail register by admin for certain roles. I have scoured the internet and have come up with using a combo of mailcontrol and Rules or custom code in my module.

I'm using Rules to send the message. I didn't want to completely disable the welcome email message for the other roles.

How can I create this functionality of sending the system mail to some users but not others? (either programmatically or via Rules)

I have a custom module already, so I used the following hook but nothing happened. I still get the welcome message.

function myMod_fields_user_mail_notify($op, $account, $language = NULL) {

 $notify = variable_get('user_mail_' . $op . '_notify', $default_notify);

if (in_array('Administrator', $user->roles)) {
  if ($op == 'register_admin_created') {
   //don't send system email we'll do this with another rule.
    variable_set('user_mail_register_admin_created_notify', false);
  }
  else if ($notify) {
  $params['account'] = $account;
  $language = $language ? $language : user_preferred_language($account);
  $mail = drupal_mail('user', $op, $account->mail, $language, $params);
}
return empty($mail) ? NULL : $mail['result'];
 }
}


texts: Drupal 7 Add user delete tab in user profile

texts:
I would like to show the user delete confirmation form as a tab in user profile, just near View and Modity. I am trying the following code in a custom module but it is not working, I'm not sure I am calling the right callback and arguments:

function custom_morebuttons_menu_alter(&$items) {
  $items['user/%user/cancel'] = array (
    'title' => 'Cancel profile',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('user_cancel_confirm_form', 1),
    'access callback' => 'user_cancel_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
  );
}


texts: Views: Create a block with terms marked (reference field) by the term viewing

texts:
I am having two vocabularies, for example, styles and artists.
Each of the artists term has a term reference field to styles voc.

When one of the styles term page is open i want to show all terms from artists vocabulary marked with this term.

Can't figure out why my contextual filter with term id doesn't work. Could you please help me to achieve it?


texts: Manage custom modules across multiple installations

texts:
We have some custom modules which are used for multiple sites. Those can't be released as contributed modules, for example because they are client specific, make assumptions that don't work for contributed modules and so on.

I know about the following possibilities to deal with this:

copy & paste them around. Makes it obviously hard to keep the module up to date on all installations.
Have a single multi-site installation, but this isn't always possible.
Use git submodules, but they can be nasty, it's easy to forget to update them and aren't always supported (e.g. Pantheon)
Drush make scripts to check out from a common git repository. For this, you AFAIK need to use drush make for the whole site and we don't use it currently.
http://drupal.org/project/fserver. I haven't tried that out yet, does someone know if it is stable enough? The project description doesn't sound very promising and there is no 7.x version.

Anything else/better? What do you prefer and why?


texts: Drupal downloads the module update but need FTP

texts:
As the above screen shots, from Drupal 7 shows, the updates are downloaded! However, it still says Updating modules and themes requires FTP access to your server.
I have tried the ownership of sites directory as whole sudo chown www-data sites. I also tried chmod -R 777 sites. Is there any other way beside having to configure an FTP server, and if it must need a FTP, what is the directory I should set it to files?


texts:
Here is a slice of code from my twig template, which outputs the contents of some fields into a p tag:

<p>
    {{ content.field_story_program_name }},
    {{ content.field_story_relationship}},
    {{ content.field_story_city }},
    {{ content.field_story_state }}
</p>

The output on the page renders a trailing white space after each field's content, which I don't want (because it creates spaces before the commas):

  Local Head Start Program Provider , Head Start administrator , Los Angeles , CA

Things I've tried:

Based on this post, I checked my field.html.twig template to see if it's introducing spaces (it's not).
Tried putting a - in the {% endfor %} on that field.html.twig template anyway to see if it would help: {% endfor -%} (it didn't).
Put all of my values on one line in case a carriage return was being interpreted as whitespace (I think that was a Drupal 7 issue that I read) as in:
{{ content.field_story_first_name }} {{ content.field_story_last_name }}, {{ content.field_story_program_name }}, ...etc
But that didn't fix it
Tried {% spaceless %} though I know it's just for spaces between tags and so of course that didn't end up helping
Using the |trim Twig filter, which makes the entire value disappear and produces a rendering error. I suppose that technically solves the whitespace problem...  ;)

Can anyone help give me a clue? I would like to either

Find out where the extra space is coming from and turn it off there, or
Use the appropriate Twig filter to remove the space


texts:
My site will be divided into multiple areas, or tabs, for example, Music, Politics, News, etc. Under each tab I'd like to display a different sidebar (my sidebar will contain menus representing categories, for example, in the Music tab, the sidebar should show Rock, Classical, Jazz, but in the News tab it should show National, International, Sport, etc). I'm hoping that all my content could be of the same content type, but that they exist under one tab or another.

How should I set this up?
So far I have tried similar content types, one for each tab, and a theme for that type which shows the appropriate sidebar. But it'd be nicer to use just the one content type overall, with a field indicating which tab it belongs to. Is that possible?


texts: Customising the print stylesheet for the print module

texts:
I Would like to customise the http://drupal.org/project/print style sheet.

In the readme file it says: - To modify the template of printer friendly pages, simply edit the
print.tpl.php or the css/print.css files.

Re: css/print.css
Does it refer to the print.css inside the print module or inside my theme? If inside the module, wouldn't this make the maintenance difficult when the module needs updating?


texts: Control the data facebook fetch and post on "share"

texts:
I am building a drupal 7 site using Addthis module, Meta tag module and Open Graph meta tag module

When clicking on the facebook share button - facebook fetch the relevant image properly, but a lot of text data.

Some data is duplicated data.
For example, the author name is fetched twice (e.g. "Admin Admin")

In addition, the labels of the field are fetch as well.
For example: "description: text text text".
I prefer without the label: "text text text".

How can I control the text data / fields that facebook fetch?
prevent duplicated data?  prevent fetching the labels?


texts: Ajax to update select list, an illegal choice has been detected

texts:
I am updating a select list via Ajax - the list is an entity reference field with cardinality of 4.  There is a plethora of "An illegal choice has been detected" results; however, none of them work for me.  Typically they call for setting #validated = TRUE but it's also been noted several places that this solution does not work on multi select fields.

The parts to the ajax callback are:

// Only relevant because is a user that is added to entity reference list
$instructor_user = cela_events_cela_instructor_piggyback($form_state['values']['add_instructor_text']);
// Get a copy of an entity to pull allowed values from it
$entity = entity_create('event', array('type' => 'event'));
$values = $form_state['values']['field_instructors'][LANGUAGE_NONE];
if ($values == '_none') { $values = []; }
$event_form =  drupal_get_form("eck__entity__form_add_event_event", $entity);
$field = $event_form['field_instructors'];
// Update the field values to include the newly created instructor
$field[LANGUAGE_NONE]['#value'] = $values + [$instructor_user->uid => $instructor_user->uid];
$commands[] = ajax_command_replace('[id="instructors-wrapper"]', drupal_render($field));
$element = [
  '#type' => 'ajax',
  '#commands' => $commands,
];

return $element;

Note that I have confirmed, multiple times, that $field[LANGUAGE_NONE]['#options'] does contain the $instructor_user as an option.

What happens: A user Adds a new instructor via another field and the field in question, field_instructors is updated with the new instructor as an option, which is also a selected value as well.  When I submit the form, I get the illegal choice error.

I have tried using $form_state['rebuild'] = true as well as updating $form_state['complete form'] (grasping at straws on that one).  No matter what I've tried, _form_validate doesn't end up with the new user as an option.

Any ideas what I've done wrong?


texts: Search Solr View with exposed filter fullsearch return no results

texts:
I setup a Solr search index (Solr 7.7.1 and Search API Solr 3.2) with custom entities. I have several fields indexed and 2 of them are fulltext. Additionally :

I setup the view with an exposed filter in a block (page view)
No Ajax option is set
I have a filter Search enabled : Fulltext Search with following options :

Expose this filter to visitors
Signle filter
Contains any of these words
Allow multiple selections
Parse mode : direct query
All Fulltextfields selected

Exposed form settings

Exposed form in block : YES
Exposed for style : basic

I also setup some facets on other fields

When I come to the page, all results are displayed by default. When searching for any term(s) via the Full-text textfield, I am getting blank results. Instead if I select some facet options, results do show up accordingly to the facets.

How can I get the Fulltext search to work?


texts: Can I edit Content Y within Content X Edit Form using Rules?

texts:
I have created a content type VIP PAGE, and another content VIP IMAGE. Now I want to allow the user to upload 5 VIP IMAGES at the same time as creating the VIP PAGE content.

So what I did was to add 5 Image fields to the VIP PAGE content type, then I created 5 Rules, which trigger when content type of VIP PAGE is created and it takes those 5 images and creates 5 VIP IMAGES content and uses Entity Reference field to connect the IMAGES to the PAGE.

Now this all works fine, until a user decides to Edit one of their images. I want to still use a single page (VIP PAGE Edit Form) to handle images being edited. Can anyone recommend a good way to achieve this?

I can't figure out how to tell Rules which of the images it is that was edited.


texts: How to add java script in a content type: article or blog or basic page

texts:
I need to add following kind of java script and html element in one of my computer programe coding tutorial article:

what I want to add a java script + html to create a text box to add function to copy the text inside the box on mouse click. (I know the code and html for that, but I was unable to paste that here)

I am looking to do it through: content tab in administrative tab: add content:  article: new article creation form in full html option.

Please let me know how to do it in drupal 7: by article or blog creation form or if there is any other easy way to do it.

Thanks.


texts: How to simultaneously pass parameters internally and make external url call on form submit?

texts:
I'm using Drupal 7.15, and have setup a simple form with a textfield, textarea, and file fields.

This is the code I use in upload($form, &$from_state).

// Return textfield, textarea, file upload
$form['data'] = simple_form($form, $form_state);

// Call internal function
$form['redirect_uri'] = array(
  '#type' => 'hidden',
  '#value' => url('upload/completed/' . $asset, array('absolute' => TRUE)),
);

// Submit form
$form['submit'] = array(
  '#type' => 'submit',
  '#description' => t('Upload your file'),
  '#value' => t('Upload'),
  // '#submit' => array('upload_completed),
);

// pass params to this other external url via get
$form['#action'] = $upload_url;

Upon submit, the form is submitted to $form['action']; then the user is redirected to  $form['redirect_uri'].

This is the code for upload_completed($form, &$form_state, $asset).

 // Stored values and input are blank because $form is not being passed
 $form_state['stored_values'] = $form['input'];

 // I do some processing of the $form_state['stored_values'] here

 // then I forward control to another url, and that's it.
 drupal_goto($some_url);

I'm unable to process any of the form data in upload_completed(), because it's empty. How can I pass the data in the form created in upload() and call the #action url simultaneously? The redirect passes via GET, so Sessions are a possibility. When I use the callback:

 $form['submit'] { ... '#submit' => array(callback) ... }

only the $form['action'] url gets called, not the #submit function. Since I'm able to pass data by reference, I really need to have that function called. Thanks in advance!

P.S. Here's how the redirect, upload_completed is called in hook_menu:

 $items['upload/completed/%'] = array(
  'title' => 'Upload asset',
  'page callback' => 'drupal_get_form',
  'page arguments' => array('upload_completed', 3),
  'description' => 'Nothing left to do, file uploaded.',
  'type' => MENU_CALLBACK,
  'visible' => FALSE,
  'file' => 'file.asset.inc',
 );


texts: Hide webform after the user's first submission

texts: How would I hide the webform in drupal7 after user's(authenticated user) first submission.Later the user should not be able to view the webform again. Please help me on this.


texts:
I expect this is a trivial question for those familiar with OOP/PHP. The migrate_d2d module provides an example module that demonstrates implementing a D6 -> D7 migration. I'm making great progress in defining the migration as I need. However, I am stumped on how I can add team information to my custom migration. The provided beer examples show performing this step when extending the Migration class.

abstract class BasicExampleMigration extends Migration {
  public function __construct($arguments) {
    parent::__construct($arguments);

    $this->team = array(
      new MigrateTeamMember('Liz Taster', 'ltaster@example.com',
                            t('Product Owner')),
      new MigrateTeamMember('Larry Brewer', 'lbrewer@example.com',
                            t('Implementor')),
    );

    $this->issuePattern = 'http://drupal.org/node/:id:';
  }
}

With migrate_d2d, the chain of dependency starts with the migrate_d2d class definitions:

Migration > DrupalMigration when then forks to:
DrupalUserMigration > DrupalUser7Migration
DrupalTermMigration > DrupalTerm7Migration
DrupalRoleMigration > DrupalRole7Migration
...etc

For my purposes, I'd like the DrupalMigration object to have the team properties set.

How do I modify DrupalMigration class properties so that I can set the team's properties and have all the children classes inherit this property?


texts: How do i get the type attribute when adding javascript to drupal?

texts:
i'm adding javascript with

  drupal_add_js()

but drupal cuts the script attribute "text/javascript" or just forgot it. It just adds the

<script></script>

tags. Can i add the script tags? Its w3c standard...;-P


texts:
Do you know what to write to the page.tpl.php file so that it shows only 5 regions (header, menu, left_sidebar, content, right_sidebar)?
Something like the following code, but to work correctly with other Drupal files and components (like *.info file) and don't collide with Drupal default regions.

<?php print $page['header']; ?>

<?php print $page['menu']; ?>

<?php print $page['left']; ?>

<?php print $page['content']; ?>

<?php print $page['right']; ?>


texts: How to alter form password and add current password in user_profile_form

texts: How to alter form password and add current password like in this image?


texts:
The client I'm building a site for has a collection of content that they want paged by its ReleaseYear Field. The pager they want should look like:

[ < | 2011 | 2012 | 2013 | 2014 | 2015 | > ]

How I build a pager like that?


texts: Getting warning message in statistics module

texts:
Below is the warning message. I'm getting this message sometimes and I'm using Drupal 6.

  user warning: Table './ri5_r3/accesslog' is marked as crashed and
  should be repaired query: DELETE FROM accesslog WHERE timestamp <
  1376371846 in
  /home/ri5/public_html/modules/statistics/statistics.module
  on line 189.

not sure what to do, what is the proper way to solve this issue ?


texts:
On Drupal 8.9.3, I am using Webform 6.0.0-alpha14 and Media 8.9.3 and I'm trying to figure out how to combine both of these modules so a user can paste a YouTube URL into a Webform which then displays the embed upon save (like how you can do that when attaching Media field to a node, for instance).
I can see how to add Video files but I'm needing to add external video embeds instead.
Is this possible?


texts: How to list all articles on default search page?

texts:
I am new to drupal, and trying to get all articles on default search page .i.e. when user has not yet entered any keyword to search, I want to show all articles by default.

I know I have to do something in search-results.tpl.php but not sure of how to do it.


texts: How to update the blocks db-table correctly

texts:
I wrote a module that comes with a default_view (a block view). The corresponding block is not automatically listed inside the blocks db-table, even after a cache clearing, but it is shown after I visit admin/build/block. My problem is that I have a hook_update_N(), which is going to update the blocks table (the configuration of this specific block); if it's not there, it can't be updated.

When I use _block_rehash('MYTHEME') the table is updated, not only for MYTHEME (ZEN-subtheme) but also for the Minelli theme. Is there another way of "updating" the blocks-table? What exactly is going on, when admin/build/block is visited?

Edit: I just noticed that Pro Drupal Devel (2. Ed.) states, at page 218, to use a Insert INTO query and do it "by hand." I think thats what I'm going to do now.


texts:
After reading the documentation and searching through code, I can't quite figure out what the entity_view function is for.

The documentation explains it executes the view callback if defined, with a fallback to the entity controller's view function. Since I use the EntityAPIController I want to use that view function, that adds a similar structure like below.

So I assumed entity_view is to replace a structure like this (part of a page callback).

// Prepare the entities
entity_prepare_view('entity_type', $entity_field_query_result);

// Apply theme to all entities
foreach($entity_field_query_result as $key => $item) {
  $entity->content = array();
  $entity->content += array(
    '#theme'     => 'my_entity_theme',
    '#element'   => $item,
    '#view_mode' => 'full',
    '#language'  => LANGUAGE_NONE,
  );
  $render[$key] = $entity->content;
}
return $render;

Thus I've replaced that with

$render = entity_view('entity_type', $entity_field_query_result);

return $render;

This however shows an empty page, where the previous function showed me a list of entities. I have custom themes applied to these entities as follows, could that be an issue?

function my_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_entity_theme' => array(
      'variables' => array('element' => null),
      'template' => 'my_entity_theme',
      'path' => $path . '/template',
    ),
  );
}

So, is my assumption on entity_view correct, or am I missing steps to come to a renderable output?


texts: How can I embed the YouTube field module in a specific page?

texts: Shifting from Wordpress, I'm quite a newbie at Drupal. So I want to embed the YouTube field module in a specific page, not just on the landing page (as it is shown in the setup video https://www.youtube.com/watch?v=SzvEEMO0_Ug). But how can I do this? I somehow just can't figure out where I can select the page I want it to be on. Thanks a lot for any help


texts: Can I migrate content to non drupal sites

texts:
I've been reading up on Drupal migration module recently and it seems like very powerful tool. That's why I was wondering is it possible to make migrations like Wordpress -> Joomla with Drupal only as intermediary between those two.

I tried to find some answers to this question but so far I've found only X -> drupal migration


texts: How to create a Draft view with Content Moderation?

texts:
In Drupal 7 with Workbench Moderation is easy to create a view to show the last Draft of a content:

You have a relation in the view named Workbench Moderation: Node, so using the filter Workbench Moderation: Current (Yes) is easy to create the view.

But in Drupal 8 with Content Moderation I can't find the way to have this working in a site with 2 languages.

EDIT:

If I use a relation to Content Moderation and Content revision I can access to the Moderation State and to the Latest Modification fields.

But if I make a Draft in the English version of the node I see in the view the French version as a Draft.


texts: Select option values loaded with AJAX call, shows error illegal choice has been detected

texts:
I have a select field in my form named country. on change country i need to load values in state. I already placed the field for listing state, only want to load the values from ajax. In same way I need to add city field also. whenever I submit form it shows state (field loaded by ajax) is ' An illegal choice has been detected. Please contact the site administrator'. How can I update the new option values of field state which I have loaded from ajax call to the drupal form. How to clear the particular field cache data?
i will provide a code sample soon .

$('#edit-field-p-location-value').change(function(){
        form_build_id = $('input[name=form_build_id]').val();
        locationval = $(this).val();
        var url = window.location.href;
        var arr = url.split("/");
        var result = arr[0] + "//" + arr[2];
        if(locationval!= ''){
            $.ajax({
                type : 'POST',
                url: result+"/gasf/getIPSecZone/"+locationval,
                data:{datacenter:locationval},
                success : function(data){
                    //$('#edit-field-p-ipseczone-value-wrapper').html(data);
                    $('#edit-field-p-ipseczone-value').html(data);
                }
            });
        }
    });


texts: How to retrieve default Title in custom module block

texts:
I have custom module that implements a block with our own template file to render:

function MODULE_NAME_block_view($delta = ''){
    $blocks = array();
    switch($delta){
        case 'twitter_feed':{
            $blocks['subject'] = t('');
            $blocks['content'] = theme_render_template(drupal_get_path('module', 'MODULE_NAME').'/inc/block--twitter-feed.tpl.php', twitter_feed_config());
            break;
        }
    }
    return $blocks;
}

I would like to pass the title value set in UI in blocks section to the template via the function twitter_feed_config specified above as following:

function twitter_feed_config(){
  return array(
       'title' => 'title set by user i am unable to retrieve'
   );
}

However, I don't seem to find a way to retrieve the value of title for this block configured via UI in the admin/block section. How to get this title value, so i can pass it to the template for rendering? Thank You


texts: How to set Panel to homepage when setting the panel's path as homepage on Configuration > Site Information doesn't work?

texts:
I have created a panel for my home page and set its path to /home. I have changed the directory of the front page in Admin > Configuration > Site Information to mysite.com/home. Still, when I visit mysite.com/home, the custom panel saved to path /home doesn't populate.

I've made sure I'm saving correctly (rather than just updating) and have also cleared my cache.

Any ideas how else I might be able to fix?

Thanks in advance!


texts:
I create module with many sessions . I want unset all session after module work . When I use session_destroy(); end of my module code , I have error and after that my sessions seem delete (session_unset(); not worked) . but after 4 or 5 time refresh page all sessions show to me .

Error:

Warning: session_destroy(): Trying to destroy uninitialized session in Drupal\...

How can I fix this problem in my drupal 8 ?


texts: Is there a way to to enforce uniqueness on a multi-value field of a content type? I have been searching for a module that does that and I couldn't find it. The Unique Field module does not support multi-value fields.


texts: I have a use case where I need to adjust the landing of the route, user/login to direct to a custom developed user/register page once clicked. What's the quickest method of doing this without overloading the core User module with changes?


texts: How to enable both passwords at registration AND email confirmation together?

texts:
I know how to enable setting the password at registration, and I know also how to set email confirmation after registration. But I don't know how to enable both features to work together.

When I enable the former function, the ladder would stop works.

Is it possible to enable both functions using UI?

I have tried Login Toboggan module but it doesn't have this function, either.


texts: Unset a SQL condition with query builder

texts:
I try to remove a where condition to a query statement. To resume, I build a query and add geographical coordinates condition to get POI in a specific area. I execute the query and if there is no result, I remove the condition to get all the POI. Here the script :

//Declare the statement
$statement = $this->connection->select('table', 't')
            ->fields(/*...*/)
            ->range(/*...*/);

//Add the condition
$statement->condition("lat", [$GPSbounds['lat_min'], $GPSbounds['lat_max']], "BETWEEN");
$statement->condition("lng", [$GPSbounds['lng_min'], $GPSbounds['lng_max']], "BETWEEN");

// launch the SQL query
$statementInterface = $statement->execute(); // Execute the statement
$results = $statementInterface->fetchAll(\PDO::FETCH_OBJ); // Get all the results

So, if there is no result, I do this :

if (sizeof($results) == 0) {

    //We remove the bounds conditions
    //=& is reference equality, changes applicated to $conditions are applicated to $statement->conditions();
    $where =& $statement->conditions();
    foreach ($statement->conditions() as $index => $condition) {
        if (array_key_exists('field', $condition)) {
            if ($condition['field'] == 'lat' || $condition['field'] == 'lng') {
                unset($where[$index]);
            }
        }
     }

     //dump $statement->conditions() : condition is removed
     $statementInterface = $statement->execute(); // Execute the statement
     //dump $statementInterface->getQueryString() : condition is in the query so the result are empty again (as the first execution)
     $results = $statementInterface->fetchAll(\PDO::FETCH_OBJ); // Get all the results
}

If I do a var_dump() of $statement->conditions() before execute(), the condition has been removed (not in the array). But after the execute(), if I dump the query string, the condition is present and the query result 0 result again (because of the condition restriction). What can I do ?


texts: I already found Get "Raw" views data (with no or little markup), but it wasn't, what I was looking for. I really do need the raw fields for having them differently styled in a module. Because the view itself should just be styled like it is, when navigating to it as page. But my module should be able to read the fields in raw-style. Or do I have to clone a view in order to be able to read the raw format?


texts:
In a multiseller Drupal Commerce Installation, where every Drupal user being a seller,  Some products can be the same from all users, for example a book from some publisher which can be sold by many sellers. Like in amazon, if one is searching for a book, it comes up and shows other sellers also of that particular book.

Is there a way in Drupal commerce to achieve the same?


texts: getvalue() of multiple values field return only the first value

texts:
I added a new field in the field manage user page. This is a sample integer multivalue field. (we can enter several integer)

I edited the profile of the admin user. I added (and save) some values in this field :

42
66
23
77

In a custom module, I load the current user and I want display all values of my integer multivalue field :

// Load the current user.
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());

// Get field data from that user.
$mycustomfield = $user->get('field_mycustomfield');

but when I print $mycustomfield->getValue(), I get only the first value :

// Display values
kint($mycustomfield->getValue()); // return only 42, but I want get 42, 66, 23, 77

How can I get ALL values of a custom field ?

Thanks :)

EDIT

I try this ...

// Load the current user.
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());

// Set and save field data from that user.
$user->get('field_mycustomfield')->setValue(array(1,2,3,4,5));
$user->save();

// And display
$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$user_mycustomfield = $user->get('field_mycustomfield')->getValue();

kint($user_mycustomfield); // print array(1.2.3.4.5) x)

With a new user, if I set several values from his user profile edit page, getValue() return only the first value

But if I set several values via the api, I can get all values with getValue

It's really strange..


texts: In a drupal commerce, how to use the same picture for every size attribute

texts:
I have a dresses drupal commerce. I have 45 dresses in différents colors and size.

My problem is that I have the same picture for every size.

My product variation is composed of a sku,price,color,size,image.

As You can see , I have the image in the product variation. Mean that I need to reselect the image for every color,size variations.

Any Idea on how could I do this?

Thanks


texts:
A site I'm working on came across the following error in Drupal based on the addition of an emoji flex graphic put into the form field.

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect string value: ‘\xF0\x9F\x92\xAA e…’ for column ‘data’ at row 1: INSERT INTO {webform_submitted_data} (mid, sid, cid, no, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder3, :db_insert_placeholder_4);
     Array ([:db_insert_placeholder_0] => 64
    [:db_insert_placeholder_1] => 10
    [:db_insert_placeholder_2] => 11
    [:db_insert_placeholder_3] => 0
    [:db_insert_placeholder_4] => Need multiple 250 ton Jacks, force not strong [AndroidFlexEmoji] enough) in drupal_write_record() (line 7239 of E:\webserver\Inetpub\wwwroot\includes\common.inc).

After digging around for a while on this site and others, I came across the following suggestion:

[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

I'm not 100% sure if this will fix the issue I'm having, however, I'm not sure where to alter this to test it. The link below states that in Drupal you can find it under /includes/database/mysql/database.inc around line 53 but no luck.

Reference link: How can I remove emoji from all user input?
Any clarification would be great.


texts: How can I correct a word on the CKEditor field?

texts: When editing a text area in Drupal 8, right clicking a highlighted spelling error doesn't produce a context menu option to correct the misspelled word. How can I correct the word on the CKEditor field?


texts:
I don't have access to a client database, but need to know how a "Date" CCK field stores its information.
I'm using MySQL, and this easily found in the structure of the table. Anyone use Postgres and can check?

Is it a timestamp or a date?


texts: How do I  keep the sum of related nodes' specific field values in a field?

texts:
I have two different content types: "Parent" and "Child".

On Parent nodes, there is a multi-value reference field where I keep some Child nodes of this node. Every child node has a field "Integer" and I keep some integer values in it.

What I want is keeping the sum of those Integer values of all child nodes of a Parent inside a field "Sum".

So I will have:

Parent 1 (sum=11)

Child one (integer=3)
Child two (integer=6)
Child three (integer=2)

Is it possible?


texts: printing file entity fields in a node.tpl

texts:
I have some fields in a file entity type. Now I need to print some of these fields directly in a node.tpl.

How can I do this?


texts: Are there any issues with installing memcache on a VPS running multiple Drupal sites?

texts: I have a VPS running a few independent Drupal sites (not multi-site). What considerations do I need to make (if any) when installing memcache?


texts: AJAX callback fails using form_alter on two fields

texts:
I have content type with two text fields field1, field2
so i'm using hook_form_alter() to alter my form and i'm added for the first field

autocomplete_path path

ajax callback and wrraper

and for the second field i'm added

prefix : with id ind the wrraper of first field

suffix

I want to add a AJAX callback to check the value of a first field and added this value to check a value of second with autocomplete .
The code:
function ajax_callback($form,$form_state) {
        return $form['field_annonceur']['und']['0']['value'];
    }

    function newsletter_form_alter(&$form, &$form_state, $form_id) {
        //dpm($form['field_annonceur']['und']['0']['value']);
        if ($form_id == 'newsletter_node_form') {
            $form['field_annonceur']['und']['0']['value']['#autocomplete_path'] = 'admin/get_path/autocomplete_field1';
            $form['field_annonceur']['und']['0']['value']['#ajax'] = array(
                'callback' => 'ajax_callback',
                'wrapper' => 'autocomplete_id',
            );

            $form['field_campagne']['und']['0']['value']['#disabled'] = TRUE;
            $form['field_campagne']['und']['0']['value']['#prefix'] = '
';
            $form['field_campagne']['und']['0']['value']['#suffix'] = '
';

            if (isset($form_state['values']['field_annonceur']['und']['0']['value'])) {
                ['field_campagne']['und']['0']['value']['#disabled'] = FALSE;
                ['field_campagne']['und']['0']['value']['#autocomplete_path'] = "admin/publicite/autocomplete_field2/{$form_state['values']['field_annonceur']['und']['0']['value']}";
            }
            return $form;
        }
    }

autocomplete_field1($value_field1){};
autocomplete_field2($value_field1,$value_field2){};

but i get the same field  when i select a first field , the second field is hidden !!
before input on field 1

after input on field 1

What am I missing? Thanks in advance!


texts: I want to do something similar to views slideshow. The thing is my javascript is written already. I would like my javascript to be able to be integrated within the drupal framework from views. The JQuery just is a simple image slideshow like this one here.  I just would prefer that I could show all or specific view field content instead of putting in the url in the javascript the long way. I want these images to come directly from a content type. Can you show me how?


texts: Fallback to default language when node not translated to current language

texts:
I set up a multilingual blog site with Drupal 8 (in English and Japanese). What I want to do is create a blog in two languages. The default language is English. Mostly, the author will be translating the articles to Japanese and sometimes no translation.

So for the nodes I have to display the original content if there is no translation available with japanese url.

For ex: http://example.comarticle/article-title is the english node and  I have no translation for this node. So http://example.com/ja/article/article-title should show the English node content where ja is the japanese language code.

Is there any way to do this?