texts:
I have an object which is created by transferring the image from another server. The image obj looks like this:

$ImgObj = stdClass Object ( [fid] => 595
[uri] => public://assets/TLK/TLK-4300.jpg
[filename] => TLK-4300.jpg
[filemime] => image/jpeg
[uid] => 1
[status] => 1
[timestamp] => 1459790167
[filesize] => 24616
[type] => image
[metadata] => Array ( [width] => 220 [height] => 140 )
)

I am creating a node which has other fields in it and I'm trying to add this image object to it. I'm creating a wrapper for the node using:

$entity = entity_create('node', $values); //Values is an array defined earlier
$ewrapper = entity_metadata_wrapper('node', $entity);

and want to add the image something like this:

$ewrapper->field_main_image->set($ImgObj);

I've tried a number of options and can't get it to work. I've googled it and tried various methods but always get an error message saying I'm using the wrong type or something like that. Any help much appreciated - thanks.


texts: Can I create a drush make file and installation profile from existing site?

texts: I have an existing Drupal site, that I would really like to be able to put entirely (or as much as possible) into code and use drush, a git repo, and installation profiles to be able to properly track my code and do rebuilds on my site. Is it possible to create this from an existing Drupal site. If so what are the steps to achieve this?


texts: Why is Drupal not pulling data from Salesforce?

texts:
I am using the Salesforce Suite module and have created field mappings. However, when I run cron, no data is pulled into the site.

I have set the Direction to SF to Drupal for all field mappings.

I have enabled the following triggers:

Salesforce object create
Salesforce object update
Salesforce object delete


texts: How can I secure a custom module that contains sensitive data?

texts:
I have made a custom module that contains my backup_migrate module profiles as described in this post.  Inside the array are my keys to log in to Amazon S3, which I certainly want to keep secret.

Putting such data in code inside a module immediately set off an alarm inside my head.  Is this a terrible thing to do from a security standpoint?  If so, why?


texts: record of email notifications sent out (webform / postfix)

texts:
I have a webform with example.com/node/123/webform/emails set to send email notification from info@example.com to several email addresses when a submission is received.

Is there a way to see a record of email notifications sent out ie with date and time etc to verify that the notifications have in fact been sent?

Thanks...


texts: hook_init() equivalent for console command

texts:
I have a module which subscribes to the kernel.request event to set some environment variables for use with LDAP. E.g. setting the LDAP_CACERT environment variable. I'm using it to replace hook_init() as recommended at https://www.drupal.org/node/2013014. However, I've noticed that it does not seem to set the environment variables at the start of Drush commands. E.g. I'd want the environment variables set in a PHP console or a cron run. This is part of a re-useable module so just adding it to settings.php is suboptimal.
What's the best way to execute code before any arbitrary Drush command runs?
I've found the console.command event which says:

The COMMAND event allows you to attach listeners before any command is executed by the console. It also allows you to modify the command, input and output before they are handled to the command.

I had hoped that would work with Drush 9. I've added it to my subscriber like so:
/**
  * {@inheritdoc}
  */
public static function getSubscribedEvents() {
  $events['kernel.request'] = ['setLdapEnvVariablesWeb'];
  $events['console.command'] = ['setLdapEnvVariablesCli'];
  return $events;
}

public function setLdapEnvVariablesCli(ConsoleCommandEvent $event) {
  $this->setLdapEnvVariables();
}

but unfortunately it never seems to be hit, even though I can see from drupal debug:event console.command that Drupal does recognize I am subscribed to it.
It would be nice if I could handle this in the same subscriber as for web requests but I am not set on it.


texts: How to save a field value according to another field value and with a user presave hook

texts:
I'm using Drupal 8

There are field_a and field_b. I'd like to field_b have the same value with field_a but different format after user submit his user edit page.

my_module_user_presave($account)

{
 $data = $account->field_a->value; // There is no value, since this user did not save yet. This is the problem.
 $account->field_b->value=format($account->field_a);//format function will change the format of field_a value, and this is not a problem
}

Since the user did not save yet, so there is no value for field_a. So I am trying to use drupal_register_shutdown_function as below.

my_module_user_presave($account)

{
 drupal_register_shutdown_function('_my_module_user_presave',$account);
}
_my_module_user_presave($account)

{
 $data = $account->field_a->value;
 $account->field_b->value=format($account->field_a); //format will change the format of field_a value.
}

Now the field_a got the value. But field_b value will not be saved since drupal_register_shutdown_function.

What should I do?

Thanks!


texts:
I have a Drupal 7 site. It is HTTPS enabled. When I do a PCA compliance test, some of the links that refer to /sites/default/files/styles/* fail the test. The fail message says "..plain text information passed on request...".

Inside the styles folder I have some other folders where images are saved when I create content for the site. I added an .httaccess file inside /styles folder to re-write all requests on that folder or sub folders to https. The PCA test passes. However, this brought another issue: I can not save any images inside /styles folder or its sub folders. I get a Drupal error "Permission denied".

The folders permission is read,write,execute for owner and group.
Can anyone help me with this issue?


texts: Can I use custom fields inside custom fields in Drupal 7?

texts:
I am making a custom field and would like to use other custom fields -- like the Link or Media fields -- inside it. Can I do this, and if so how do I determine what #type to include in my field definition?

For example, the pattern "Image + Linked Headline + Brief Description" happens frequently enough in my content that I am trying to create a custom field that combines these. But a lot of what I need already exists in both Link and Media plugins, and I'd rather not recreate that functionality if possible.

I have already tried using the Field Collection module for this, but can't because it does not support translation.

Edited

I think I have found my way around the Field Collection translation problem by switching to field translation instead of node translation. Field collection seems to be a little buggy there, especially for collections made prior to turning on entity translation, but so far it seems to be working.

A yes/no answer to this would still be interesting, though, for future custom-field development. The more I think about it, the more I think the answer is likely "no."


texts:
I have 2 fields, state and city. I would like to change the city field when I select the state field.
I tried to use "hs_nodereference", but this module shows the state and city fields as follows.

statename: statelist
cityname: statelist  citylist

I want them to be shown as follows.

statename: statelist
cityname:  citylist

Does anyone know a solution for this?


texts:
I'm interfacing an external database with Drupal 7.  I have created custom entities and custom fields to represent the tables in the external database.  Is there a simple way to set the fields up so all CRUD uses the external database?

I still want to use Drupal's default field_sql_storage.module, but have it switch to the external database and back for these fields automatically.  Can I say "for this field, use this other database".

Something simple like:

function mymodule_field_info() {
  return array(
    'customfield' => array(
      'label' => t('My Custom Field'),
      'description' => t('This field stores text in the external database.'),
      'settings' => array('max_length' => 255),
      'instance_settings' => array('text_processing' => 0),
      'default_widget' => 'text_textfield',
      'default_formatter' => 'text_default',
      // Simple setting to change database.
      'database' => 'externaldb', // From settings.php $database connections.
    ),
}

The hard way is to create a custom storage backend and use it for these fields like the Mongodb module. I've tested this and it works, but it seems like there should be any easier way if you want to use Drupal's default field_sql_storage.module.

Would the strategic placement of db_set_active() allow me to avoid creating a full custom storage backend?


texts: How can I append date and time to node titles?

texts:
I want to append the date and time to node titles. For example, If the title is Test, I want to change it to Test_DDMMYY_hhmmss.

How can I achieve this?


texts: Multiple Sticky Items within using 2 separate views

texts:
I have 10 nodes and 2 views, one view named highlighted nodes, the other - other nodes

I created the concept that if a user sets one of their nodes to appear "sticky at the top of lists" then it would appear in the highlighted nodes view.

My second view outputs the rest of the nodes with an offset of 1 i.e. skipping the first node that I assumed "there will only be one" node that was set to sticky at the top of lists

My question is, how do I cater if two nodes are set to "sticky at the top of lists". Could you offer a solution?

Thanks in advance


texts: Disable delete functionality on Webform submissions

texts:
I need to disable/hide the delete functionality of weform submissions.

Marked as yellow on the images below.


texts: Drupal 7 makes it quite easy to create a new view mode (see this tutorial for instance), but is there a way to define a view mode that is only available for a specific bundle (content type)?


texts: CKEditor Font Size and Family buttons does not appear

texts:
I tried to install CKEditor Font Size and Family on my fresh Drupal 8 install, but both buttons does not seem to show up.

Plugin is placed in /libraries
CKEditor and CKEditor Font modules are both activated
Both buttons S and F appear when I edit my content format (Full HTML)
Both buttons were added to the Full HTML CKEditor toolbar
My content use Full HTML format, and I am administrator
But these buttons does not appear when I edit my content

This problem is still here after a few days of development, so I'm already sure it's not cache-related.

Did I miss something in my configuration?
Thanks


texts: Is there a way to add node grants to anonymous users?

texts:
I want anonymous users to be able to access nodes that are promoted to the front page. (They can't access to nodes that are not promoted.) It seems hook_node_access() isn't seem called for anonymous users. I tried using hook_node_grants() and hook_node_access_records(), but the code I am using doesn't seem to give anonymous users access to nodes promoted to front page.
function myModule_node_grants(\Drupal\Core\Session\AccountInterface $account, $op) {
   return ['show_promoted_news' => [9999]];
}

function myModule_node_access_records(\Drupal\node\NodeInterface $node) {

  $grants = [];

  if ($node->isPublished() and $node->isPromoted() and $node->getType() == 'article') {
    $grants[] = [
      'realm'        => 'show_promoted_news',
      'gid'          => 9999,
      'grant_view'   => 1,
      'grant_update' => 0,
      'grant_delete' => 0,
      'langcode'     => 'en'
    ];
  }

  return $grants;
}

The access content permission is overriding the grants I give to the anonymous users, who can't access published content. Adding a greater priority does nothing.
I'm being forced to allow anonymous users to access content and override that when I don't want them to have access with hook_node_access().


texts: My slider's images have larger file-size than their originals

texts:
I have a slider in my homepage and this slider has 3 photos named a.jpg, b.jpg, and c.jpg.

The original file's sizes are (respectively), 42kb's, 20kb's, 52kb's. And yet when I download them from my slider (Flexslider) they whey much larger (c for example is 191 kb's).


texts: jquery date picker in views exposed filter changes the date values

texts:
I have a node type "tasks" and created a view so that current logged in user can see his/her assigned tasks. I have used a "time ago" formatter in the field "deadline" which shows the remaining time to the deadline correctly. I have also created a filter for "deadline" and expose this filter. The selected options are as follows

The filter is correctly working if I choose "Select" in "Date selection form element" under settings for the "deadline" filter as can be seen below

However, when I change the "Date selection form element" to either "Plain" or "Popup", the duration in "Due In" field changes by a day that means if today is 5th March and the task is due on 6th March 2014 by 14:00, the "Due In" field will show 13 hours xx minutes (see image below)

I really don't understand what is the problem. Any suggestions?


texts: Alter core "Configure Block" contextual link path or text?

texts:
We're using blocks and Beans throughout a very large site. The issue is that the contextual links have "Configure Block" which takes you to the block configuration page for that particular block, and another contextual links labeled "Edit Block".

The "Edit Block" link is the correct link as it brings the user to the Bean admin page for that block with fields and settings.

I'm not able to find the hook to alter that main "Configure Block" link or text.

I've tried:

hook_menu_link_alter()
hook_contextual_links_view_alter()
hook_menu_contextual_links_alter()
hook_block_view_alter()

None of these seem to expose the "Configure Block" text or URL.

I've also tried the Custom Contextual Link module, but it doesn't allow you to edit or remove this link.

I am not interested in hiding it with styling. That isn't fixing the problem. I want to programmatically alter that one contextual link.


texts:
Site  link

here, in this 9 is the user id.it is different according to register users.

When add link in main menu there is an option Path textbox
in that text box if i add "user/9/edit" then link is created but here 9 is login user id. then it is accessible only whose user id 9. but other not access.
I want to add link dynamic which user are login then that user access that user edit page.user/*/edit


texts: Cannot insert images in body of a basic page

texts:
I am using CKEditor and WYSIWYG. After updating Drupal core to 8.5.6, I cannot upload an image using the CKEditor's 'image' button anymore saying "Image Field is required."

I have checked CKEditor's plugin settings. Image upload's enabled there.

I have not found a solution yet. Any help will be appreciated.

PS: If I add an image using html "img" tag then it shows up properly, it's only the button that is not working properly.


texts:
I have 2 content types: location and maintenance.

I would like a view that shows all the locations with a search box at the top so the user can search the right location; when users click on a location, they are redirected to the location details and the maintenance nodes listed under the location details.

So the workflow is like this:

Search the location
Click on the location
See a view with location and maintenance nodes

I have already installed entity reference and made references from maintenance to locations, but I just can't get the view settings right; a list of all the locations is what I am getting, so far.


texts: Drupal custom node type add field to relate content

texts:
I was wondering if it's possible to create a custom node type with a custom field to relate it to another node content(same or diferent node type). And then in my node--customtype.tpl display the fields(render($content['myfield'])) of the custom node type but also to display all the fields of the related node and I want to do it programmatically.

I've been searching, and I found a module called References, but there's no documentation about how to use it exactly.

The other option that I thought is to add a int field to fill with the nid  of the related content, but I don't know if it's possible to generate a query with that nid and append it to the $content['extrafield'] and render it on my node--customtype.tpl

But here you are the experts and I hope you can guide me with the correct way to do it.


texts: How do you make entity fields appear in Rules when converting a Webform submission to node?

texts:
Steps to reproduce this use case:

[Rule event] Submit data on a specific Webform (new submission)
[Rule action] Create content node by type
[Rule condition] Use 'content is of type' condition
[Rule action] Access Webform submission data to set node content fields

How can 3 & 4 above be executed in this order and allow for access to both the created entity and webform submission? i.e. - by passing arguments or otherwise.

Related articles which get some of the way there but did not answer my question entirely:

Using webform rules to create node after webform submission
How to create a node from a Webform using rules?
How to create a node with submissions of a webform?


texts: how to display the machine name of module at /admin/modules?

texts:
I use Drush to enable and disable module, to do this I need to know the machine name of the module.

At /admin/modules I can see the list of modules, but this list doesn't show the machine name, jut the human readable name.

I created a view to list the machine name of modules but I'd like to have it at /admin/modules. Is there any way to do this?


texts: Getting an error with Acquia Dev Desktop

texts:
Upon setting up Drupal 8 through Acquia Dev Desktop, I get to the Choose Language screen fine but then when I get to Set Up Database and put in the Database Name and Database username/password, I get the following error:

  Fatal error: Uncaught exception 'Symfony\Component\DependencyInjection\Exception\InvalidArgumentException' with message 'The service definition "renderer" does not exist.' in C:\Users\Sites\devdesktop\drupal-newest\vendor\symfony\dependency-injection\ContainerBuilder.php:796 Stack trace: #0 C:\Users\Sites\devdesktop\drupal-newest\vendor\symfony\dependency-injection\ContainerBuilder.php(440): Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition('renderer') #1 C:\Users\Sites\devdesktop\drupal-newest\core\lib\Drupal.php(158): Symfony\Component\DependencyInjection\ContainerBuilder->get('renderer') #2 C:\Users\Sites\devdesktop\drupal-newest\core\includes\install.core.inc(1151): Drupal::service('renderer') #3 C:\Users\Sites\devdesktop\drupal-newest\core\includes\install.core.inc(1089): install_database_errors(Array, './sites/drupal-...') #4 C:\Users\Sites\devdesktop\drupal-newest\core\includes\install.core.inc(366): install_verify_database_settings('sites/dr in C:\Users\E0217625\Sites\devdesktop\drupal-newest\vendor\symfony\dependency-injection\ContainerBuilder.php on line 796

I have no idea what this means since I was having no problems before.
I've set up sites before with no issues but all of a sudden, I'm unable to create new sites.

Any help/direction on what I should do to create a new site would be great.


texts: Is there a way to see a report of the users on a site that shows who is logging in and who isn't logging in? (other than just looking at 'People' tab I mean...we have thousands of users on the site).


texts: Completely Locked out of website via User Permissions

texts:
The story:

Here's the full story. I disabled the Drag 'n Drop uploads module and then I was prompted to rebuild user permissions. So I was like, Ok and I rebuilt the user permissions. Then I noticed I couldn't see my admin toolbar, so I scrolled down the list of modules and it was unchecked, so was almost everything else. I went through and rechecked the modules I needed and then I clicked save. Nothing happened so I decided I'd put my site in maintenance mode until I sorted out the problem (so I did). I couldn't figure out what was wrong or how to fix it so I restored my entire website from a backup made earlier (1:28 AM) today but now it's giving me an error and I can't even access my site.

The Error:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.role' doesn't exist: SELECT r.rid, r.name, ur.uid FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid IN (:uids_0); Array ( [:uids_0] => 0 ) in UserController->attachLoad() (line 314 of ...public_html/modules/user/user.module).

The question:

Is there any way to fix this error?


texts: Which hook to use on initial creation of a node?

texts:
I would like to execute a script once a new piece of content of a specific type has been created, but not updated. Which hook would I use for this?

I basically want to execute a script that will node_load the entity reference field and then email a bunch of users from that referenced node.


texts: run-tests.sh error: Test class not found

texts:
Hi and thanks in advance for your patience - I really appreciate the patience this community has shown me despite my silly questions. I'm using Drupal 9 and have just read this tutorial on unit testing in Drupal 7, but it doesn't seem to be working for me. It's unclear to me whether I'm doing something wrong or the instructions simply aren't valid anymore:
www-data@fa5bab330dc3:/opt/drupal/web$ php core/scripts/run-tests.sh --verbose --url http://example.com/ --class "Drupal\Tests\rsvplist\Unit\RSVPListServiceTest"
  ERROR: Test class not found: Drupal\Tests\rsvplist\Unit\RSVPListServiceTest

I have tried pointing run-tests.php to a specific directory but that doesn't seem to work either:
www-data@fa5bab330dc3:/opt/drupal/web$ php core/scripts/run-tests.sh --verbose --url http://example.com/ --directory modules/custom/
  ERROR: No valid tests were specified.

I tried the above with variations on the directory, including modules/custom/rsvplist and /opt/drupal/web/modules/custom/rsvplist/tests/src/unit/ (the location of the test file itself), but always got the same error.
When running unit tests via phpunit directly I seem to be able to get it to work:
www-data@fa5bab330dc3:/opt/drupal/web/core$ phpunit ../modules/custom/rsvplist
PHPUnit 8.0.0 by Sebastian Bergmann and contributors.

Testing ../modules/custom/rsvplist
R                                                                   1 / 1 (100%)

Time: 123 ms, Memory: 6.00 MB

There was 1 risky test:

1) Drupal\Tests\rsvplist\Unit\RSVPListServiceTest::testSomething
This test did not perform any assertions

/opt/drupal/web/modules/custom/rsvplist/tests/src/unit/EnablerServiceTest.php:14

/opt/drupal/vendor/phpunit/phpunit/src/Framework/TestResult.php:860
/opt/drupal/vendor/phpunit/phpunit/src/Framework/TestSuite.php:761
/opt/drupal/vendor/phpunit/phpunit/src/Framework/TestSuite.php:761
/opt/drupal/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:632
/opt/drupal/vendor/phpunit/phpunit/src/TextUI/Command.php:208
/opt/drupal/vendor/phpunit/phpunit/src/TextUI/Command.php:164

OK, but incomplete, skipped, or risky tests!
Tests: 1, Assertions: 0, Risky: 1.

I'd like to run my tests via run-tests.sh as I'd like to use the Drupal\KernelTests\KernelTestBase class so that I can mock out database connections, and as I understand it this should be done via run-tests.sh and not phpunit. Obviously I'd like to resolve the errors above but I'm also happy to be shown a different / better way of achieving what I'm trying to do.
Here is my test class, located in modules/custom/rsvplist/tests/src/unit/EnablerServiceTest.php:
<?php

namespace Drupal\Tests\rsvplist\Unit;

use Drupal\Tests\UnitTestCase;

class RSVPListServiceTest extends UnitTestCase {
  public function testSomething() {
  }
}


texts: Trouble setting up a search for a single field

texts:
I am trying to set up a search that will only search a single field of a single content type. I am currently using search api with database search server module. I set up the search to index only this one field and a bundle filter that only returns results from the specified content type. The problem I am running into is the results.

If I set the field type to integer (it is a zip code I am searching through), it returns every search result regardless of if it contains the integer or not. If I set it to fulltext, it doesn't return anything regardless if i type an exact match to one of the fields it is indexing.

Am I setting this up right? Is there a better way to do this?


texts: Building the sidebar content on each node

texts:
Im going to build a version content heavy site that will contain over 100 of pages. All pages are created in a "Two column layout" the main column contains the Title and body text of the node. And then theres the sidebar, i like the admin of the site to be able to "build" the sidebar for each node.

I like to provide the admin with two types of elements a "text box" and a "image with text box". The admin should then be able to create any number of each box in the sidebar, and they just get listed under each other. These boxes should be attached to the node, and is not general for all nodes.

Basicly im hoping for a solution where they can setup the node, when they visit the node they could hover over the "sidebar" region and in the dropdown select "add textbox" -> "add image box" and those teasers get assigned only to the specific node

It should be very intuitive as the admin is not very techinical (for example they wont be able to create views etc) so im hoping for a simple solution, please advice me :)


texts: Adding a button above rendered output from a contrib module

texts:
What I'm trying to do is add a button above some content that's being outputted by a contrib module (Search Api Saved Searches) .

Can I do this with hook_page_alter, if so how can I add this new render to the $page[content][system_main] .  If not what hook would be best to solve my problem.

Many thanks.


texts:
How can I add custom classes to node links in Drupal 8?

I want to add some classes to the Read more and Add new comment links in article teasers.


texts: How to use taxonomy vocabulary with terms and children using views module

texts:
I have a problem with Views and Taxonomy and maybe can found the solution here. I have a vocabulary with 15 terms and each term have a few childs. I want to show that with a jump menu using views but the result is awful because I have a list with terms and childs but losing the hierarchical order. Please, check it here (http://cubarecipes.org/restaurants-guide), right column, Cuba Restaurants guide block.
Thanks in advance,
Alex


texts:
'Comments', 'Users', 'Taxonomy' are Entity Types because they each define their own sets of required fields.

I am having a discussion with my boss where I am arguing that 'Menu' are really just a type of 'Taxonomy'. This is because Taxonomy has a parent field, and a title, but Menu also shares this, and extends it to require a 'link' field. He, however, disagrees with me and says that there are things which Menus can do that Taxonomy cannot. But I don't see what.

'Menu' has the concept of hierarchy, so does 'Taxonomy'.
'Menu' has a 'link' field to link to a Node, or an external link. But this can also be done using 'Taxonomy', by manually adding in a 'link' field manually.
You can control permissions on 'Menu' items, you can also do this with Taxonomy

I understand that a 'Menu' serves a special and common need, but conceptually I think it's just a type / superset of taxonomy, not another Entity. I think this chain of thought is common, as reflected by the number of sites that uses the Taxonomy Menu module.

In a previous question, I grok that Comments and Nodes are different Entities because they have completely different fields. But here, Menu seems to have the same fields as Taxonomy - namely parent and title.

So, why has the Drupal community decided that Menu need to be its own Entity Type, instead of a being just a module that extends taxonomy? (i.e. Taxonomy Menu) What does Menu offer that you cannot achieve in Taxonomy?


texts: How to create a view to display a block of referenced nodes?

texts:
I have a node type, called "policy", that has a bunch of CCK fields, including a Node Reference type.  This is configured to reference an unlimited number of nodes.

When the nodes are viewed, the list of referenced nodes appear at the bottom of the content.  Ideally, I'd like to put these in a block on the side of the content.

I've tried writing a view that accepts an NID as an argument and displays the CCK field.  This works in the Views configuration preview (displays expected results), but when I put this block on the side bar, and view a node, I do not see any results at all.

I do not have a relationship specified in the view - I'm not really clear on if I need to use it or not.

Thanks!


texts: Assign new customer with specific user role upon checkout registration

texts:
When a new customer is created, in the first checkout steps, its useful to be able to assign him with a specific user role, apart from the default 'authenticated'

A relevant use case would be when there are both customers and different backend user roles (editors e.t.c.) and it is need to create specific permissions to users according to whether they are customers or not.

This has been answered for commerce v1 (drupal 7) in the following
Drupal Commerce assign role on account create on checkout

This solution can be applied to Drupal 8 commerce v2. So by utilizing hook_user_insert one can get the new account and assign it other roles, upon registration.

However its not clear how/if we can determine in this hook whether this new user is a commerce created user and therefore a customer, or if its a user created by the admin and therefore possibly not a customer.

One not so safe condition would be to check if he already is assigned with any roles, as it would be the case if he was a backend user, but still this does not feel so safe.

So, there are 2 questions

Is there a 'by the book' way to assign a specific role to a commerce customer?
Is there a safe way to identify who is creating (commerce checkout or backend admin) a user in hook_user_insert?


texts: getFormId() must be compatible with Drupal\Core\Form\FormBuilderInterface::getFormId (Drupal 8)

texts:
I newish to Drupal and very new to Drupal 8, as this comes out in a couple of weeks it seems to make sense to grab the bull by the horns and start any new project with this now! Anyway I was following pretty good tutorial: http://www.drupalwoo.com/content/blog/my-first-drupal-8-module on creating a Drupal 8 module but it looks to be a year or two old and things have changed. I am getting the following error:

Fatal error: Declaration of Drupal\bd_contact\AddForm::getFormId() must be compatible with Drupal\Core\Form\FormBuilderInterface::getFormId($form_arg, Drupal\Core\Form\FormStateInterface &$form_state) in modules\custom\bd_contact\src\AddForm.php on line 7

This is the file in question: https://github.com/nlisgo/bd_contact/blob/master/src/AddForm.php could anyone tell me what would be the correct way? I have googled it quite a bit and found similar issues but I can't see how I'd integrate those changes into mine.


texts: Encode Forward Slash with &#x2F in Text area drupal 7 form

texts:
I am facing issue in Encoding forward slash with &#x2F in my custom drupal 7 form.
I have a text area field with name "Address", i am using check_plain for encode special characters, All HTML related tags are getting encoded, but i want to encode forward slash(/) as well.

Any suggestions?


texts: Login error: call to undefined function entity_load in User module

texts:
I’m new to Drupal and I have a problem where no users can login (HTTP 500 and WSOD on POST of valid credentials, Drupal 7). The error message is:

“E_ERROR Error in file »user.module« at line 291: Call to undefined function entity_load()”

Any ideas on how to approach troubleshooting this?


texts: How to prevent subsequent Rules to be executed if a previous rule is executed?

texts:
I am using Rules to get the price in Drupal Commerce and I have three different rules to apply when I am calculating product price. The problem is that if the first one is executed I don't want to execute neither second nor third. Second one is executed if first one is not executed and the third one shouldn't be executed neither. The third one is only executed if first one and second one are not executed.

Summing up, I would like prevent the execution of subsequent rules if a previous rule is executed. How can I do that in Rules?


texts: What module lets you delete a node after a specific time if its unpublished?

texts:
is there a module that can delete or prune nodes that does not get published after a certain amount of time has passed? Currently the node prune module doesnt work with the latest core release. Looking for alternatives if possible.

thanks


texts:
I have a field in drupal "field_xyz". it stores json values. JSON looks like this:

{"Id_-_SiteWasteProductAction":"34638393224", "Postcode": "CSF 12CF"}

I want to fetch postcode value from this json using mysql query

i used

$query = $connection->query("SELECT @@sql_mode"); //for group by (php 7.0)
$query = $connection->query("set @@sql_mode=''"); //for group by (php 7.0)
$query = $connection->select('node_revision', 'n');
$query->fields('n', ['vid', 'nid']);
$query->fields('shad', ['field_xyz_value']);
$query->join('node__field_xyz', 'shad', 'n.vid = shad.revision_id');

i fetch postcode value from url-

   $filter_postcode_value = \Drupal::request()->query->get('filter_postcode_value');//postcode

and i use this condition

   if(!empty($filter_postcode_value)){
          $query->condition('an.field_xyz_value->"$.Postcode"', '%' . db_like($filter_postcode_value) . '%' ,'LIKE');
     }

output is coming out as-

    Column not found: 1054 Unknown column 'shad.field_sheet_all_data_value.Postcode

Please help!


texts: Programmatically added block doesn't appear in block admin page

texts:
First of all, this is not a duplicate of this question, as I can't see my block even though I click Place Block.

Below is my block class. To the best of my knowledge, it should appear in the list, but it doesn't. What am I doing wrong? There is another block class, and that can be discovered.

<?php

namespace Drupal\tcmb\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides a 'Tcmb Currency' block.
 *
 * @Block(
 *  id = "tcmb_currency_block",
 *  admin_label = @Translation("Tcmb: currency"),
 *  category = @Translation("Tcmb")
 * )
 */

/**
 * Display TCMB currencies as a block.
 */
class TcmbCurrencyBlock extends BlockBase {


texts:
I would like to retrieve the parameter cookie_domain set in the services.yml like this:

parameters:
  session.storage.options:
    cookie_domain: '.domain.ext'

I try this:

(new SessionConfiguration())->getOptions(\Drupal::request());

This recovers the default value not my value


texts: I want to total order discount in ubercart on drupal 7. I want to 10% discount on total order.Is there any way to do that?


texts:
Is there any option in YAML Form to create conditional page? There is already conditional fields option. But I can not find conditional page option.

What actually I want to do is to take some additional information on another page of the form if there some specific value is selected.


texts: How do I add an additional database for migration?

texts:
I have a Drupal 8 site running in Lando. I need to have the 8 site connect to a Drupal 7 database so I can run a migration.

My understanding is I can import an additional database through Lando, but from the documentation I cannot figure out exactly how to do this.

I've tried adding this to my .lando.yml:

services:
  legacydatabase:
    type: mysql
    creds:
      user: root
      password:
      database: legacy

and then multiple attempts at the lando db-import command to no avail.

I need to know what exactly goes in .lando.yml and then what exactly goes in the lando db-import arguments to get this working.


texts: Cannot install Commerce Commerce License 7.x-1.3 in drupal 7.41

texts:
Not able to enable Commerce License 7.x-1.3 or 7.x-1.x-dev
Tried several times each time on clean Drupal install.

Running
Apache, MySQL, PHP 5.6
clean standard install of Drupal 7.41

All dependent modules are available
Enabled all commerce modules with success
Commerce 7.x-1.11

All dependent modules are available
Trying to enable in admin/modules
Commerce License 7.x-1.3
No error message, not installed, shows uninstalled in admin/modules
No log info.
No changes in DB system table.

I have no problem enabling other modules.
Other modules uses same environment and Drupal version so how can it be
environment problem or Drupal problem?

Have checked PHP extensions and settings and these seems to be according to Drupal standards https://www.drupal.org/requirements


texts: How do I handle smart quotes and curly apostrophes?

texts:
I'm building a new Drupal site, and the content authors and editors ared dyed-in-the-wool Microsoft Word users.  I've got WYSIWYG set up to force all pasting to be treated as "Paste from Word", so much of Word's garbage seems to be handled well.  The one remaining problem is characters like smart quotes, curly apostrophes, em-dashes, and the like.  Although I'm shooting for end-to-end Unicode, and theoretically that should prevent those characters from showing up as weird garbage, I consider it safer to use HTML entities, in case at some future point someone else changes something that interferes with the end-to-end Unicode architecture.
Is there a way to convert non-ASCII characters into HTML entities, either when they are pasted or before they are displayed?
Converting to straight quotes (and using Typogrify to render them as smart quotes) would be fine too, if you can tell me how to convert to straight quotes.  Preferably, other characters should be as well handled.


texts: How to override template for drupal views attachment?

texts:
The view that I am looking at is a 'page'. I have created an attachment. The theming suggestions for the attachment don't seem to be working.

I am perhaps confused as to whether the attachment takes on the theme namespace of the page or the attachment when rendered through the page.

The attachment reports that I should use views-view-unformatted--class-timetable.tpl.php and that this template is being used for the attachment.

When I view the page, this template is not being rendered. Using $conf['theme_debug'] = true; the templating engine reports that it is being rendered with sites/all/modules/contrib/views/theme/views-view.tpl.php.

In theory the unformatted name-spaced template should work for both the page and the attachment (the page is bvt tables, and the attachment is unformatted). What are the template names?


texts: Can invite module work for existing users?

texts: I'm using UR and invite module.  I'm trying to make it so you can "friend" "existing" users.  I don't know why Invite is only set for e-mail address invites for just non-users.  I want A FB style "friend" request.  Is there a way to fanangle this though these modules? Or, do I have to go in another direction with it?


texts: Drupal 8 migrate language: switch all nodes to the default lang

texts:
Where testing the migration from drupal 7 to drupal 8 and everything almost works, except i'm running into a language problem.

I have two different languages enabled in Drupal 7, English(Default) and Dutch, but only for the interface, there is no multi-language setup for nodes.

Now, when i imported the content in drupal 8 with the same two languages enabled, i get to see the content, but it is dived between three types:

Not specified
Dutch
English

I want to see all the content without selecting a language(via url, session, ..). So, how do change it so i can view my nodes without a language prefix in the url ?

I already tried messing with the database and changing the 'langcode' to 'und' and that works, but it breaks many other things. I just want to see site.tld/my-cool-url-alias without anything else.


texts:
Is Pressflow really required for Varnish? I ask because I've set up Varnish on my server with drupal 6.30 standard, and installed the Varnish module, and it's sped up my website no end. Really amazing speed results here, and I'm getting plenty of cache hits.

So my question, what's different about the Pressflow install, and why is it required for Varnish?


texts: How can I arbitrarily execute a rule from the UI to test a login togobban workflow using selenium?

texts:
I am trying to create tests for my Drupal site using Selenium UI.  I am attempting to test Login Toboggan's "verify user" behavior, but since the account verification link is different each time, it cannot be easily included in a test.

I have several rules that should be triggered upon successful validation; since I cannot trigger validation in the normal manner, I would like to activate these rules manually.  Is there a way to do this from within the UI (so that it can be added as part of selenium)?


texts: Is it possible to integrate Zoho CRM with Drupal Webforms?

texts: How would one integrate Zoho CRM with the Drupal Webform module? Salesforce has a webform module that woks well. As I understand the webform module API is different to the Drupal forms API, making it more challenging. I have found an sandbox ZOHO API drupal module that seems to have lost some steam. Any pointers would be appreciated.


texts: How to update the price of a product based on the birth date of the registrant

texts:
I have a content type EVENT with the event date field,

I created products with various attributes (ENTIRE - UNDER - FEMALE, etc ..)

Each attribute generates a different price for the product.

Product1 -> ENTIRE = € 10 -
Product1 -> UNDER € 8

Product2 -> ENTIRE = € 15 -
Product2 -> UNDER € 5

Now, in registration (COMMERCE REGISTRATION) checkout, insert the birth  date of a user. I must compare birth date with event date. If the user is a minor pays UNDER, otherwise ENTIRE.


texts: How to download my drupal site DB in my Drupal 7? I want to know is there any options are there in download db in admin panel.


texts: How to create a custom block and call in a region programming Drupal 9

texts:
I am looking for a solution where i can create a block via my custom module that i already achieved.
class CustomExercise1Block extends BlockBase {

  public function build() {

    $build['wrapper']['#markup'] ="Hello World!";
    return  $build;
  }

Now this block start appearing on Structure > Block Layout from there i can chose the block and call in any region which i want. But i am looking for additionally that stop this process and do via programming from same module
so once in above my custom module a block created it i assign it a region and page visibility so it start appeared in that region and page
I am looking for Drupal 9


texts: Content Access Drupal 6.28 - Doesn't work

texts:
We have a website which has 4 users type (excluding anonymous and authenticated). When we created a node today after we updated the version 6.28, the page access options of that content was restricted to a certain user. But when we visit as an anonymous user, the page can be seen.

I already checked the permission of each user roles and it is ok.

Hope you can help me with this problem


texts: Redirect the title field of a content type to some external url in a view

texts:
I am using drupal 7 with view3

I have content type named News having many fields along with a taxonomy field named News Type, News type have terms: 'Free' and 'Premium', I am displaying News on my page through view, the problem i am facing is I need to redirect the news node to some external url like popup, if its premium news, means if its News Type field is set to premium it should not be redirected to its content, In short when premium news is viewed it should popup some message instead of showing the content of that news,and for free news it should go to the news node detail page. Please find the screenshot of view attached. Please help will be greatly appreciated. If I need to clarify please comment.


texts:
I want to use a single webform to send download links with specific media files to visitors that fill out that form. For example on an URL like this:

https://example.com/downloads?media=1234

The media parameter will be the ID of an media entity type like "Download".  Now I want to send the mail with the name of the media entity and a link to the file of that entity.

How could I get this done? Mail handler and a custom Twig template is what I think about, but how do I get the data of the media entity? Any ideas? Thanks for every helpful comment ;)


texts:
I am using boost for caching my website and i set my Maximum Cache Lifetime to 1 day, but i noticed that my adsense blocks dosen't appear anymore even when i refresh the page or i flash the cache.
Is there any solution or good configuration to do?


texts: How to use the YML structure of routes to control access to Group Content

texts:
I am using the Group module and would like to leverage each Group's permissions in my module's yml files.

I have a module.permissions.yml with something like

tam_api.group_gid_members_uid:
  path: 'group/{group}/members/{member}'
  defaults: { _controller: '\Drupal\tam_api\Controller\TamApi::getGroupMember' }
  methods: [GET, HEAD]
  requirements:
    _permission: 'access user profiles'
  options:
    _format : ['json']
    _auth: ['oauth2', 'cookie']
    parameters:
      group:
        type: entity:group
      member:
        type: entity:group_content

I would like to change access user profiles to the View individual group members for the given Group?

Can this be done within the Structure of Routes?


texts: Weird root redirection happening on internal URL for Drupal (views/ajax 404 error)

texts:
My site is located at http://www.example.com/mysite

For my views on my site, there's one very weird thing happening. Whenever I open a page with a view and use the filters, I get views/ajax 404 error.

This happens because the view wants to go http://www.example.com/mysite/views/ajax

instead it is going to
http://www.example.com/views/ajax

Notice /mysite/ is being missed.

Any idea what's happening?


texts:
I am getting the following error on the server

Fatal error: Call to undefined function cache_get() in includes/module.inc on line 665
Drush command terminated abnormally due to an unrecoverable error.                                                                                [error]
Error: Call to undefined function cache_get() in includes/module.inc, line 665

How to fix this?


texts: How to embed a comment in an entity-field query

texts:
In reviewing the slow query log, some of them are entity-field queries. With a normal select query, I can have something like:

$query = "/*" . __FILE__ . ":" . __LINE__ . "*/ SELECT...

and with pdo object notation, I can add

->comment(__FILE__ . ":" . __LINE__)

but how do I add a comment to an entity-field query? Apparently comment() is not a valid method.


texts: Resolve the error "An illegal choice has been detected..."

texts:
I have written code like below and all works fine, but while submitting the form I get the error below. I am trying to filter the second dropdown based on the first drop down selection.

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

How do I overcome that error?

function dynamic_location_dropdown_form_alter(&$form, $form_state, $form_id) {
  if($form_id == 'product_node_form') {

  $location_options = array();

  if(isset($form['field_destination']['und']['#default_value'][0])) {
    $destination = $form['field_destination']['und']['#default_value'][0];
  }
  else {
    $destination = 0;
  }

  $location_options = dynamic_location_dropdown_locations($destination);

  $form['field_destination']['und']['#ajax'] = array(
    'event' => 'change',
    'wrapper' => 'squadron-wrapper',
    'callback' => 'dynamic_location_dropdown_ajax_callback',
    'method' => 'replace',
  );
  $form['field_product_location']['#validated'] = true;
  $form['field_product_location']['und']['#prefix'] = '
';
  $form['field_product_location']['und']['#suffix'] = '
';
  $form['field_product_location']['und']['#options'] = $location_options;
  }
}

function dynamic_location_dropdown_ajax_callback($form, $form_state) {
  $country_id = $form['field_destination']['und']['#value'];
  $form['field_product_location']['#validated'] = true;
  $form['field_product_location']['und']['#options'] =  dynamic_location_dropdown_locations($country_id);

  return $form['field_product_location'];
}

function dynamic_location_dropdown_locations($destination_id) {
  $nodes = array();
  $nodes[''] = '- None -';
  if($destination_id != '') {
    $select = db_query("
      SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created
      FROM {node} node
      LEFT JOIN {field_data_field_location_country} field_data_field_location_country
      ON node.nid = field_data_field_location_country.entity_id
      AND (field_data_field_location_country.entity_type = 'node'
      AND field_data_field_location_country.deleted = '0')
      WHERE (( (node.status = '1')
      AND (node.type IN  ('location'))
      AND (field_data_field_location_country.field_location_country_nid = $destination_id)))
      ORDER BY node_title ASC
    ");
    $nodes[''] = '- None -';
    foreach ($select as $node) {
      $nodes[$node->nid] = $node->node_title;
    }
  }

  return $nodes;
}


texts:
I have a custom module that interacts with some third-party service.
Please look at this function:

function mymodule_connect_entity_update($entity, $type) {
  // Update the entity's entry in a fictional table of all entities.

  //here's some call to external service and I'd like to log results.
}

I want to log information from $entity and other info. I'd like to know what is the best way to do this. This site is hosted on Acquia if it affects the decision.
Someone recommended syslog, but I'm not sure about that, I'd like to have a separate log for this activity.
My idea is to create a custom logger, and configure Linux logrotator to handle rotation. The thing is that I don't have permissions to configure rotator, and I'll have to support my decision in order to convince the System Administrator, and I'd like to know other approaches and their advantages.


texts:
I'm working with Openlayers and I would like to add a custom layer to a map with markers from a webservice.

It should works in this way:

I create a map with Openlayers UI and display it in a page;
I call an external webservice that returns me X elements with lat/long informations;
I show these elements in the map as a normal layer, with markers etc.

The questions are:

Have I to create with Openlayers UI a custom layer and then I've to populate it with js/ajax?
Or I should create a map without a layer and add this layers js/ajax, and popoulate it with js/ajax?


texts: How can I adjust the position of a cancel button added with hook_form_alter()?

texts:
Based on this answer, I added a cancel button to my user picture upload form like this:

  $types = array(
    'profile_picture',
  );

  foreach($types as $type) {
    if($type.'_node_form' == $form_id) {
      if(arg(1) == 'add') {
        // If adding node link to node/add screen
        $link = l(t('Cancel'), 'account/manage-pictures', array('attributes' => array('class' => array('form-submit','cancel'), 'id' => 'edit-cancel')));
      }
      elseif(arg(2) == 'edit') {
        // If editing node, link to node view screen
        $link = l(t('Cancel'), 'node/'.arg(1), array('attributes' => array('class' => 'form-submit, cancel', 'id' => 'edit-cancel')));
      }
      $form['cancel'] = array(
        '#type' => 'markup',
        '#markup' => $link,
        '#weight' => 0,
      );
    }
  }

However, this causes the red cancel button to be placed at the top of the form instead of the bottom of the form next to the purple save button as shown in the screenshot below.

When I examined the CSS in Firebug, I saw that the save button is under this div: <div id="edit-actions" class="form-actions form-wrapper">, while the cancel button is not.  Is there a way to place the cancel button under the same div as the save button?


texts: Drupal Registration Form In Lightbox With Ajax

texts:
I updated my post up top to pull in the user form created in Drupal, it now loads it in a lightbox correctly, how can I submit this using AJAX, validate this all in the Lightbox? any ideas?

Any help would be good help :)

    <?php
function ajax_register_menu() {
  $items['request'] = array(
    'page callback' => 'ajax_register_mypage',
    'page arguments' => array('ajax_register_form'),
    'type' => MENU_CALLBACK,
    'access callback' => TRUE,
    'title' => t('MY TITLE'),
  );

  $items['request/submit'] = array(
    'page callback' => 'ajax_register_submit',
    'type' => MENU_CALLBACK,
    'access callback' => FALSE,
  );

  return $items;
}

function ajax_register_mypage($form){
    print '
';
    print 'Hello World';
    print render(drupal_get_form('user_register_form'));
    print '
';
}

function ajax_register_submit() {
    $returnO = new StdClass();
    $returnO->status = true;
    $returnO->message = 'MY INFORMATIVE MESSAGE HERE';

    print drupal_json($returnO);

    die;
}
?>


texts: I updated my Drupal, but now the overlay module does not worki and everything shows on the center of page.


texts:
In building a new theme (for a bespoke build, rather than distribution) is it essential to start with a base theme? If I look at the Zen theme, for example, I would scrap most of the HTML and CSS in order to start with a blank-er canvass than that theme provides. Are there still many benefits to using a theme like Zen in that case?

Update
In an attempt to clarify, this is for a professional project, and in terms of HTML/CSS we'd usually start from as little as possible; normalize.css, modernizr and not much more. Most themes seem too 'opinionated', there's too much we'd have to re-style or remove to the point where it would slow development down.


texts: How to add autocomplete tag in Webforms module

texts:
According to the accessibility guidelines fields like email or name need to have an autocomplete tag like, autocomplete=on.

I found the option to turn autocomplete on and off in webforms in the field settings and form settings. But these do not add the tag. If I add it manually in the YAML option then it does appear. But I want writers to be able to enabled this option themselves. Is this possible in webforms?

I'm trying to achieve the result in the image. Webforms allows me to turn it off and on, but only with off does the tag appear. With on it doesn't.

https://www.w3.org/WAI/WCAG21/Techniques/html/H98


texts:
I have an AJAX form. I'm using drupal_add_js() after AJAX calls to update 'settings' and pass new information to my Drupal.behaviour object. However, the results are being merged instead of replaced. I know this is by design but it's messing up my Javascript code because I end up with information from the last callback. Does anyone know of a good workaround for this?

Update:

Current workaround is overriding the code so settings is replaced rather than merged, though only for the page my form is in.

Drupal.ajax.prototype.commands.settings = function (ajax, response, status) {
  ajax.settings = response.settings;
};

Feels wrong, but things are working as expected.

Solution:

The final solution I used, as solved by Alice Heaton, isn't to override code in ajax.js, instead I returned both the form and an AJAX command in the forms AJAX callback:

function my_ajax_callback($form, $form_state) {
  $commands = array();
  $commands[] = ajax_command_settings(array(
    'key1' => 'value1',
    'key2' => 'value2',
  ));
  $output = drupal_render($form['locator']);
  $commands[] = ajax_command_insert(NULL, $output);

  return array('#type' => 'ajax', '#commands' => $commands);
}


texts: How to load a view with ajax with all js files needed?

texts:
I am using this function to load three views which are loading comments of a node in three tabs by three different sort types by ajax:

function sort1(){
var nid='<?php echo $node->nid; ?>';
$.ajax({
    url: 'http://www.example.com/views/ajax',
    type: 'post',
    data: {
        view_name: 'comments_views',
        view_display_id: 'block_3',
        view_args: nid,
    },
    dataType: 'json',
    success: function(response){
        $('#cm').html(response[1].data);
    }
});
    return false;
}

And for other two views there exist a similar function.

Now what is the problem?

These comments can be replied and voted. But after switching between tabs nether reply nor vote works by ajax. I am using ajax_comment module in order to make it work by ajax and voteAPI and Rate module for rating comments.

I think views is failing in loading js of views.

what is the solution?


texts: Strange Issue with displaying information of the current term

texts:
I have built a series of views to build a Drupal Commerce display for products based on the Taxonomy terms of those products. These terms have a hierarchy. There are nearly 40,000 products being imported through Commerce Feeds, the taxonomy terms are attached to the products during the import.

Currently I have a series of 3 views working together to achieve what I want and am attempting to build a fourth view that I am having a strange problem with. View http://cde.gttechlife.com/products for reference.

View 1(Product Taxonomy Children) pulls in all Taxonomy terms based on the Parent Term context in the URL. (Term Alias is the name displayed, Product Code for Image pulls in an image based on product code) It pulls that in through Term Name converted to ID and turns term name spaces into dashes. See Below:

View 2((Top Level Products) Pulls in all Taxonomy Terms that do not have Parents and displays them. View 2 is attached to view 1 if View 1 has no results based on the Contextual URL, this is the only time view 2 is displayed. So no contextual filter on the URL it displays all terms with no parents.

If View 2 DOES have a contextual URl, there it displays a no results attachment View 3. View 3 pulls in all products with that Term Name in the URL.

All of these views work exactly as needed. But I want to add another view. I want View 4 to also be pulled into view 2 with view 3. View 4 (Taxonomy Description). View 4 pulls in the Taxonomy Term Description and the custom field Category Alias, and Product image of the current term in the URL. Oddly enough this ONLY works for contexts with no dashes. Just like the other Views I made sure to check "Transform dashes in URL to spaces in term name filter values" but for some odd reason it still only works for one word terms. For example (cde.gttechlife.com/products/vibratite) works fine but (cde.gttechlife.com/products/Gasket-Flange-Sealant) does not. It seems like such a simple problem to have but I have hit a wall looking for the solution. Any help would be appreciated.

Also trying to figure out the best way to get the Breadcrumbs to reflect the parent terms and even ideally in the url, but I still have some effort to put in on that end. Have been using the Crumbs module thinking I will be able to do what I need if I put in the time. But the problem stated above has me stumped because I can't think of why it wouldn't work correctly.


texts: obscuring email addresses in user to user email conversation

texts:
my registered users can send each other proper emails (not private messages) through contact forms on their user profiles. When user A sends such an email to user B, I need user B to be able to reply to the email that was sent by A such that the two can start having an email conversation.

*) How can I encrypt the sender's and the recipient's email address such that the original email addresses of A and B are never revealed, even if the whole email conversation - after being initiated through the contact form - continues in their external email mailboxes?

Let me elaborate this a little bit further, even though I don't know if the path I am suggesting to take is at all feasible: To each user I assign a randomly generated key, e.g. 1k1 for user A and ki8 for user B. I would then set up the contact form on the profile of A such that every submission gets sent to 1k1@mydomain.com. Then, how can I make sure that every email going to 1k1@mydomain.com automatically gets forwarded to the actual email address of user A? If this could be done, I would simply replace the sender of this forwarded email with ki8@mydomain.com and upon reply start over again.


texts: How to overridden command via hook_drush_command_alter?

texts:
I'd like to override command using hook_drush_command_alter before run as below:

/**
 * Implementation of hook_drush_command_alter().
 */
function policy_drush_command_alter(&$command) {
  if ($command['command'] == 'features-revert-all') {
    $command['command'] = 'custom-features-revert-all';
    $command['command-hook'] = 'custom-features-revert-all';
  }
}

However it doesn't work (it's calling the old command). I'm doing it right? Is it possible using this hook?


texts: Recieving PDOExceptions and missing fields and table on Module installation

texts:
I'm new to Drupal and it's pretty much my first experience of adding Modules.  I've mostly being using the Migrate module so far in.

On loading I'm getting PDO errors which are created by either missing tables not being added or missing fields in the database.    This also happens when I set up my own migrate extension - in regards to the mapping.

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'r.migrate_group' doesn't exist: SELECT mg.name AS name, mg.title AS title, mg.arguments AS arguments FROM {migrate_group} mg; Array ( ) in migrate_ui_migrate_dashboard() (line 29 of /sites/all/modules/contrib/migrate/migrate_ui/migrate_ui.pages.inc).

I can fix these errors - at least to the point of being able to have access to the Migrate UI .  By looking in the migrate.install file

ALTER TABLE `migrate_status` ADD `group_name` VARCHAR( 255 ) NOT NULL COMMENT 'name of group' AFTER `machine_name`

This is not the only table I'm having to fix; but an example.

Also I think it's worthy of noting that the tables I'm fixing have commands such as 'serialize'
On another test website I am now receiving a similar PDO error.

So my question is why this is happening and a permanent fix for when I reinstall this or any other modules

I have Drupal Commons 7x-3.12 core installed using Acquia .

Mysql version SELECT @@version;

Thank you for any advice that will push me in the right direction as to why I'm getting this issue.


texts: Is it possible to change the path of modules/themes installed using an installation profile?

texts:
I have a site which has a profile which downloads a number of modules using drush make. It adds the modules in the path /profiles/profile_name/modules.

Is it possible in the make file of the profile to change the path to where the modules and themes are put, so that they are then installed in sites/all/modules and sites/all/themes?


texts: Taxonomy in Contextual filters for Views

texts:
I am new to drupal and currently I am exploring the Views module. I have a dummy website for a toy shop to learn on.
I have created taxonomy as follows where "Category," "Ages," and "Brand" are vocabularies, and the rest are taxonomy terms :

Category: Activity Centers, Electronics, …
Ages: 0-2, 2-4, …
Brand: FisherPrice, V-Tech, …

I want to create a view that displays all toys, depending on what has been passed in the contextual filters; for example, if the first argument is a term from the "Brand" vocabulary, the second argument is a "V-Tech" term, then toys belonging to these should get displayed with a URL such as http://example.com/Brand/V-Tech.

I selected "Content: Has taxonomy term ID" in the contextual filter, but I don't understand the next screen. I selected the 'Specify validation criteria' checkbox. There should not be a vocabulary option in the validator drop-down? Can anyone help me from here on?


texts: Features : export content types with FieldCollection

texts:
When I try to export my content type using Features, it works. But when I import it on another Drupal installation, I've got an exception :

Exception : Invalid field name given: **my_field** is not a Field Collection field. in FieldCollectionItemEntity->__construct() (line 119 in **path_to_module**\field_collection\field_collection.module)

That's strange, because IT IS a Field Collection, and it worked fine on the first Drupal installation.

Any ideas ?


texts:
I am having menu like this in drupal which i have used superfish to show

I want each main menu to have a sub-title or description like this in below image

I searched alot online. Also tried for modules. Was wondering if there is a way to achieve that.


texts:
Having spent 2 days coding my own content access module, I've managed to grant along with Organic Groups the intended set of permissions to my users.

Thing is, that authenticated users who now have edit grants on nodes, when they press the "Edit" tab, they can only edit the node's title!

Did a print_r in my form_alter for that form and it seems all form elements except for the title have their #access set to FALSE.

Any ideas on what might be going on here? I mean I can set it to TRUE in the same function but instead of repairing the problem I'd like to correct it.


texts: How can I track statistics on how often a hook/error message is triggered?

texts:
I am using the Privatemsg module in Drupal 7.  I have a hook in a custom module that is triggered when users write a message that is too short.  I set this up using the instructions here.

Basically, it looks like this:

function mymodule_privatemsg_message_validate($message) {
  $uid = $vars['message']->author->uid;

  //if root or help user, message should always go through regardless of length
  if ($uid !== '1') {
    if ($uid !== '3') {

      if (empty($message->thread_id) && strlen($message->body) < 200 ) {
    form_set_error('[body][value]', t('My custom message.'));
      }
    }
  }
}

I recently noticed there are not so many messages being sent on my site.  I would like to know if it is because they are being blocked by this hook.  How can I track how many times it is triggered (and even better if I can know which logged-in users are getting the error message)?


texts: Programmatically accessing field values for a file in a custom form

texts:
I have the kint() output below.

How do I get the values for the destination index?


texts: While running the batch process, it takes more than 5 hours to complete; before that, it returns a 502 error. How do I handle it?


texts:
I have custom_form, with Node_reference field.. When I add Any node and leave some require field then I submit .. the Node_reference fail and become [nid:und]

function custom_form_alter(&$form, &$form_state, $form_id) {
   $content_type_forms = array('register_node_form', 'session_node_form');
 if (in_array($form_id, $content_type_forms))
 {
 if(empty($form['field_event_ref']['und'][0]['nid']['#default_value']))
 {
 $form['field_event_ref']['und'][0]['nid']['#default_value'] = arg(3);
 }
 $form['field_event_ref']['und'][0]['nid']['#disabled'] = True;
}
}


texts: Do I need a module to put the trademark symbol in the site title? If I add &trade; at the end of the title, it just gets output as is.


texts: book module navigation horizontal submenu

texts:
I am using the book module navigation block to display links to book pages. I was wondering if it was possible to alter it so rather than the children links appearing below the parent, they would appear to the side. This is because I want a horizontal navigation

Thanks

EDIT:
For anyone wondering, the way to get book links to appear on the same level, you just need to make sure the child pages are pointing to the same parent, then just display that level of links to get a nav bar, styled this gives you a horizontal nav bar.


texts: How to run entity field query in cron without getting undefined stdClass::$roles notice?

texts:
I've got a cron job which executes an entity field query to count the number of some nodes associated with a user (for each user in the system). Whenever this runs I get the following in the watchdog logs:

  Notice: Undefined property: stdClass::$roles in user_access() (line 820 of […]/Drupal/modules/user/user.module).

Is there anything specific I need to do to avoid this happening (not involving changing log levels or otherwise ignoring the issue)? Any particular best practices when using Drupal queries outside the context of a "real" session? The reason I'm doing this is to get rid of any spurious noise in the logs, and reduce the chance of breaking things in case of change to both my own and Drupal code.

Query code:

$q = $query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', $content_types, 'IN')
    ->propertyCondition('status', 1)
    ->propertyCondition('uid', $uid)
    ->propertyCondition('type', $content_types, 'IN')
    ->fieldCondition('field_something', 'value', $code, '=');

$award_count = $q->count()->execute();

Stack trace:

[…]/Drupal/modules/node/node.module(3334): user_access('bypass node acc...', Object(stdClass))
[…]/Drupal/modules/node/node.module(3296): _node_query_node_access_alter(Object(SelectQuery), 'entity')
[…]/Drupal/includes/module.inc(1163): node_query_entity_field_access_alter(Object(SelectQuery), NULL, NULL, NULL)
[…]/Drupal/includes/database/select.inc(1253): drupal_alter(Array, Object(SelectQuery))
[…]/Drupal/includes/database/select.inc(1261): SelectQuery->preExecute()
[…]/Drupal/includes/database/select.inc(1275): SelectQuery->preExecute()
[…]/Drupal/includes/entity.inc(1389): SelectQuery->execute()
[…]/Drupal/modules/field/modules/field_sql_storage/field_sql_storage.module(652): EntityFieldQuery->finishQuery(Object(SelectQuery), 'entity_id')
[internal function]: field_sql_storage_field_storage_query(Object(EntityFieldQuery))
[…]/Drupal/includes/entity.inc(1216): call_user_func('field_sql_stora...', Object(EntityFieldQuery))
[…]/[my code path]: EntityFieldQuery->execute()

Running Drupal 7.56.


texts: user ability to hide one column only on view

texts: What is the best way to give the user the ability to see or hide one column (only one) on a drupal 7 view?  I want to give them a toggle box to be able to hide and unhide the column


texts: Capturing keyup event (JavaScript) from Drupal editors (CKeditor)

texts: I maintain the Textfield Counter module. An issue was raised that the module does not work for textareas with CKEditor enabled. I need to catch a keyup event from editors, or even just the CKEditor module, for the module to work. I haven't worked much with Drupal editors, nor CKEditor. Does anyone have any insight into how to do this, or an alternate solution?


texts: How can I alter the value of a field in views?

texts:
In my process to rewrite the quantity widget field on every page of the commerce process I ran into another issue. I have successfully altered the quantity widget textfield into a dropdown in the shop and on the cart page using the hook_form_alter(). on commerce_cart_add_to_cart_form_ ($form['quantity']) and views_form_commerce_cart_form_default ($form['edit_quantity'].

On my checkout summary I see that the quantity is again 0.1 instead of 100 grams. But when I checked with dpm($form_state) I saw that the commerce_checkout_form_checkout generates HTML under the cart_contents_view instead of hookable $forms..

How should I alter the output of the field on this page?

Best Regards


texts:
I have installed Fivestar module on D7 and tried to translate 'fied_vote'. But the string can not be found in the translation interface at admin/config/regional/translate/translate.
So wondering how to translate it?


texts:
I'm working on Drupal7.

I want to redirect all the URl's to external domain except some.
Below rewrite I have added in .htaccess file and its working fine.

RewriteCond %{REQUEST_URI} !/user.*$
RewriteCond %{REQUEST_URI} !/testurl.*$
RewriteRule .* https://abcxyz.com [R=301,L]

But then, homepage also redirecting to https://abcxyz.com

How to stop homepage redirection or how to add homepage in the exclude list like user, testurl?

I have tried below to exclude the homepage in the redirection.

RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !/index.php$
RewriteCond %{REQUEST_URI} !/homepage$

But nothing worked.

Can you help me on this please?


texts:
I'm new to using Google search on local website installations.

I have successfully installed the Google-CSE module and upon searching, results are successfully displayed from Google.

However, my problem is there are no auto-suggestions when a user begins typing content into the search textfield.

Can anyone tell me how to configure my Drupal textfield to show auto-suggestions when input is typed, please?

PS:

My Google site index has autocomplete enabled.


texts:
I want to create a map where on clicking on a certain location ,a user can find all the content/nodes/posts related to that location. ( Something like http://42floors.com/ )

Is it possible to build it using drupal? Can you suggest some modules that will be useful for this purpose?
Thanks. :)


texts: add #ajax property to email field in node add form usion hook_form_alter

texts:
I've tried to add the property "#ajax" to email field but It dosen't work,
I've tried all this :

$form["field_user_email"]['#ajax'] = array(
      'callback' => 'user_ajax_check',
      'wrapper' => 'usercheck',
      'effect' => 'fade',
  );

$form["field_user_email"]['und']['#ajax'] = array(
      'callback' => 'user_ajax_check',
      'wrapper' => 'usercheck',
      'effect' => 'fade',
  );
$form["field_user_email"]['und'][0]['#ajax'] = array(
      'callback' => 'user_ajax_check',
      'wrapper' => 'usercheck',
      'effect' => 'fade',
  );


texts: Correct permission for site, default and files folders?

texts:
I just need to know if these permission are corrects:

site --> 775
site/default -->775
site/default/files --> 775
site/default/setting.php --> 555


texts: How do I print a taxonomy term in node.tpl.php? (D7)

texts:
I have a custom content type that I can select a vocab term for when editing the page (category more or less). How do I print this term to my page via node.tpl.php?

I've tried several different ways, but to no avail so far. Any ideas?


texts: Seach Page Split into Form Block & Results Block

texts:
I already created a search view like /search it is giving form and results finely but Views UI is disabled in my server .
So i want to split this search page into

1) A block which contains a search form

2) A block which will show appropriate results with form field data.

I created a TWIG file to display form and results on same page as search.html.twig

It is displaying form finely but not displaying any results. Can anybody suggest what i am wrong here?

{%
  set classes = [
    'view',
    css_name|clean_class,
    view.current_display|clean_class
  ]
%}

Sitewide Search

{{ title_prefix }}
{{ title }}
{{ title_suffix }}

  {{ drupal_entity('block', 'exposedformacquia_searchpage_2', check_access=false) }}

 {% if pager %}

     {{ header }}

{{ pager }}

 {% endif %}

 {% if rows %}

Search Results

     {{ rows }}

 {% endif %}

 {% if empty %}

     {{ empty }}

 {% endif %}

 {% if pager %}
    {% if footer %}

     {{ footer }}

 {% endif %}

{{ pager }}

  {% endif %}


texts: How can I add a progress bar to Managed File upload?

texts:
How can I add a progress bar to my Managed File form field? Here's my field code:

    $form['file'] = array(
  '#type' => 'managed_file',
  '#title' => t('Logo image'),
  '#description' => t('Replace/upload a new logo for this sponsor.'),
  '#upload_location' => 'public://',
  '#upload_validators' => array(
    'file_validate_extensions' => array('gif png jpg jpeg'),
  ),
);

I have searched for a while now, and the closest info I could find was this post but I can't quite figure out how I can add the AJAX to make this happen. Any pointers would be appreciated!


texts: Can I make a Views "Rendered Node" field not be linked to the original node?

texts:
I have a view that outputs rendered nodes. Setting "Show: Rendered Entity" doesn't work, because I need to add other things like edit links and custom text. So I set "Show: Fields" and used a "Rendered Node" field to output the node contents alongside everything else I needed.

The problem is that Views brilliantly wraps the entire node contents in  tags and links it to the node's page! This would be fine if I were just showing the titles, but I'm showing the node's entire rendered contents, with all sorts of
s and other links that need to work and other things.

Is there a way to make it not do that? There's no option for it in the field settings and I can't find where in the Views module this field is implemented.

Alternately, is there another way I can show a list of rendered nodes alongside other fields without them being stupidly linked in unconfigurable ways?


texts: I need a advanced search block (by using views) on home page of site

texts:
I'm beginner in drupal.
I'm developing a site contains products that are displayed some product blocks by using views module on front page like featured products and top rated products.
Now, I also need to add a advanced search block (by using views module) on front page like I've attached image below. This search will only search from the one type of content named product and show another page.

How to add input field name titled, dropdown list, radio buttons and Search button while creating views block?


texts: dsm vs drupal_set_message vs debug vs dpm vs watchdog for developing

texts:
dsm requires the devel module but I guess you have that installed anyway if your developing modules.
debug and watchdog having the advantage that is writes to the log file.

I can see the advantage of watchdog on a live site so users don't get bugged by messages while debugging the site. but is harder to use ( you have to write more code )

dsm and dpm are short and simple to use but don't always show output.

So are I think debug is the best way to go while developing modules (on your test server). But apparently it doesn't handle array's that well.

Which one do you use and why do you think that is the best / better or should I use the different functions for different purposes?


texts: use "php code" in page manager access rules to evaluate if current og_group has content of a specific type

texts:
I'm grateful for the amazing organic groups module (and so many other drupal modules), which I am using for a civil society and social economy network platform.

I have a question, which I think would be interesting for others too. I couldn't find the answer anywhere.

Usecase: I have a page (in page manager) which outputs a tab in og_group nodes, showing a view panel pane of og_group content (together with other panes). Specifically, og_group are organizations, and og_group contents are events. So I'm showing events of each organization in a separete tab.

I wish this tab "events" to be visibile only if there is at least one node of type "event" listed as group content of the og_group page being viewed.

In order to do this, I am trying to use page manager "access rules", which, to quote specific documentation:

  are used to test if the page is accessible and any menu items
  associated with it are visible.

The "only" og related rules available are:

  "Node is an OG group"
  "Node is an OG group content"
  "user membership in group"
  "user permissions in group"

So, I think my logic is possible with the generic "php code" rule. But I'm no coder, yet.

Anybody could give me a hint about what code should I write to check if te viewed node (which is an OG group) has at least one event associated with it as group content?

Thanks!!!

Config: D7 7.41, php 5.2.4, panopoly 7.x-1.28, og 7.x-2.7, ctools 7.x-1.8, panels 7.x-3.5

Update: as @Stefanos suggested in his answer, I am searching for a kind of "no results" behavior of views module, in page manager.

@Stefanos, here is the context available in the page:


texts:
How can I translate this to drupal table?

http://www.bootply.com/sXmuAJQjO4

I know how to do simple tables and the header and first row I can do also with this code:

$title = '

Table Title

';

    $header = array(
        array('data' => '&nbsp;'),
        array('data' => 'Job Name'),
        array('data' => 'Description'),
        array('data' => 'Provider Name'),
        array('data' => 'Region',),
        array('data' => 'Status'),
    );

    #'data-toggle' => 'collapse'
    $row = array(
        'data' => array(
            array('data' => '<button class="btn btn-default btn-xs"></button>'),
            array('data' => 'OBS Name',),
            array('data' => 'OBS Description'),
            array('data' => 'hpcloud'),
            array('data' => 'nova'),
            array('data' => 'created'),
        ),
        'class' => array('accordion-toggle'),
        'data-toggle' => 'collapse',
        'data-target' => '#demo1',
    );
    $rows[] = $row;

But I can't add the hidden row. Can anyone help me?

Thanks!


texts: I have a view created for product categories, now I want pager, I configure the settings by displaying specified num of items instead of all items, now I am getting the specified num of items on a page but not getting the pager when I added more than specified number of items?


texts:
I Have a template in my cart_template module called views-view-table--commerce-cart-form.tpl. Is there a way to create a preprocess function for that template.

What I have tried : hook_preprocess(&variables, $hook), but doing dpm($hook) display a lot of weird names like : block, page, views_view ... etc. which doesn't indicate when the function gets called for my template.


texts: Views contextual filter - related nodes as an offset from a node's creation date

texts:
I have a related content view which displays similar nodes based on shared taxonomy terms. I want it to display related nodes that were published in a date range relative to the current node's creation/published date. E.g: for a node published in March, I want to filter similar nodes that were published between February and April.

Currently I am only able to create a contextual filter "Node: Published at year + month" which displays similar nodes that were published in the same year+month, but I am looking for something similar to the post date filter criteria with operator (image attached), but instead of offset from current time, have an offset from current node's creation date. Is that feasible with views contextual filter?


texts:
I'm using the Basic theme and want to show the article date before the title. The problem is, that {{ date }} is only available in node.html.twig, whereas the title is created in page-tite.html.twig.

How can I place the article date before the title?


texts: Feeds import - If title has "=" at the end, check whether duplicate content exists

texts:
I have an XML to import products to Drupal Commerce site. But some products are duplicates. Duplicate products are having "=" at the end of their title, but NOT all products with "=" at the end of their title are duplicates.

What I need is, on importing XML, check whether product exists, if exist, do not import (easy), if product has "=" at the end of title, check whether product WITHOUT "=" at the end of the title exist. If exist, do not import, else import.

I am totally lost how to do that, should I write some feeds tamper module to handle such a behaviour or go completely outside the drupal and parse XML, compare it to current product database of drupal and export new XML to import to drupal? Any advice would be greatly appreciated!


texts: PHP code for selection rules in Path Breadcrumbs not working

texts:
Whenever I have this field filled, no breadcrumbs appear. And it even doesn't matter whether it returns true or false: I wrote 'return TRUE' there & there's no breadcrumbs.

Here's my export file:

$path_breadcrumb = new stdClass();
$path_breadcrumb->api_version = 1;
$path_breadcrumb->machine_name = 'construct';
$path_breadcrumb->name = 'construct';
$path_breadcrumb->path = 'node/%node';
$path_breadcrumb->data = array(
  'titles' => array(
    0 => '%node:field-one:0:pb-join:name',
  ),
  'paths' => array(
    0 => '%node:field-one:0:pb-join:url',
  ),
  'home' => 1,
  'translatable' => 0,
  'arguments' => array(
    'node' => array(
      'position' => 1,
      'argument' => 'entity_id:node',
      'settings' => array(
        'identifier' => 'Content: ID',
      ),
    ),
  ),
  'access' => array(
    'plugins' => array(
      0 => array(
        'name' => 'node_type',
        'settings' => array(
          'type' => array(
            'vocab1' => 'vocab1',
          ),
        ),
        'context' => 'node',
        'not' => FALSE,
      ),
      1 => array(
        'name' => 'php',
        'settings' => array(
          'description' => 'choice',
          'php' => 'return TRUE',
        ),
        'not' => FALSE,
      ),
    ),
    'logic' => 'or',
  ),
);
$path_breadcrumb->weight = 8;


texts: Replacing menu link text with image: overriding the right function?

texts:
I try to use images instead of text in main menu, in a theme I'm building. Used different solutions in my template.php, without any luck. Drupal prints the link to the image and not the image itself. I even use the suggested Drupal modules (menuicon and menuimage). But I got the same bad result.

Same kind of questions was asked here around but with no working solution for me, as far as I tried.

Yesterday, a similar question was asked on Stackoverflow and get a comment from Clive (https://stackoverflow.com/questions/19788449/overridden-theme-menu-link-is-not-used). Clive gave a hint on maybe this user is overriding the wrong function. But unfortunately, the question was removed by the user last night. Yes, I'm that kind of unlucky guy :-)

So, I will try to ask it myself with some posted code, hoping that someone can give me a clue to solve the issue.

Here is the code in my template.php:

    function caracole_menu_link($link) {
       $element = $link['element'];
       // Allows for images as menu items. Just supply the path to the image as the title
       if ( strpos($element ['#title'], '.png') !== false || strpos($element ['#title'], '.jpg') !== false || strpos($element ['#title'], '.gif') !== false) {
       $link['element']['#title'] =  '<img alt="'. $element['#original_link']['description'].'" src="'. url($link['element']['#title']) .'" title="'. $element['#original_link']['description'] .'">';
       $link['element']['#localized_options']['html'] = TRUE;
    }
    return theme_menu_link($link);
    }

It's one of the solutions provided on forums. But I can't get it to work for me...

best regards,

plouf


texts: session value not updating in theme variable for anonymous user

texts:
I am working on multi-level forms, and storing form values in session to display result on final page with some form values. but its works fine only for authenticates users.

For anonymous users session value updates only after clearing cache on the page. but values updates in session variables but doesn't update in theme variables.

Tried all methods:

\Drupal::request()->getSession();
\Drupal::service('user.private_tempstore')->get('module');
$_SESSION['module']

Same results for all. Please help!!


texts: How could I select all the authenticated users and just only them?

texts:
I've a long running Drupal 7 site. Now my client needs a way to select (and act upon) the users who are not in the role "A" and "B", but just "Authenticated Users".

I know that the latter are not in the users_roles table which makes the standard admin/people form and the advanced users module useless (they both skip over the Authenticated Users).

Do you know of any module that could do something like that? Unfortunately it seems there is no way to alter the query in the user.module (which joins users_roles) so I feel like it's a dead end. Should I need to write a module with a form and duplicate most of the features of the admin/people?


texts: commerce unique identification number for each item on each transaction

texts:
What options are they to achieve a unique identification number for each item sold in a commerce store.

I want to have a unique number for each item on each transaction, the number needs to be unique across all transactions.

even if I have 5 of the same line item in an order I should still get 5 unique numbers.

I have a unique id number per item per order but i don't know how to achieve a truly unique id.
Would appreciate any guidance.


texts:
How can I change the title of my blog? It's found on the main page of the blog above the previews of the posts. I am attaching a screen shot.
I want to change "The Scrapbooked Bible Study" (on the left above the first blog post preview) to "Winning the Victory." Thank you.


texts: How do I add a submission handler to the contact form?

texts:
I am trying to get a value from the query string and process it with contact form values to send in email.

For example, I have a contact form with different fields. I want to load one node information (title, description, prize, and PDF) and attach the PDF file to the email sent with the contact form.

How do I add a form submission handler to the contact form?


texts: How can I display a change password form on its own?

texts:
I have a need to place a user's password reset form in areas outside the context of the user edit page.

This Change Password module looked promising; however, it is only available for drupal 6 and only a dev snapshot is available.

I could use hook_form_alter to hide the fields on the edit user form that are not related to the user's password, but I would prefer not to do that if at all possible.

I'm hopping this functionality exists somewhere already.

Thanks in advance.


texts: Removing "node" path from "node/add/*" URLs

texts: How can I remove the "node" part from "node/add" URLs? I have clean URLs on, and I have successfully used Pathauto to remove "node" from other paths.


texts: How to alter the user login response data

texts:
I'm just looking into adding some more data to the Drupal 8 API user login response.

curl --header "Content-type: application/json" --request POST --data '{"name":"username", "pass":"password"}' http://drupal8.localhost/user/login?_format=json

The response is like:

{
    "current_user": {
        "uid": "100",
        "roles": [
            "authenticated"
        ],
        "name": "username"
    },
    "csrf_token": "4gRg8XElB1jRp3xu1a4vm2oYiTCXLaoO8Ii72Dwe1kd",
    "logout_token": "gnUt53JZcM7KEFizLOFe996DTXgEqj7RyzhMwsmUssZ"
}

How can one add additional data to the user login API response?

I've looked into adding a custom Normalizer, but seems a bit tricky to intercept the /user/login response and curious if any other suggestions on it, thanks.


texts:
I have media content I want to add an option for viewers can view by year from select option. I have added Published on and then checked on exposed with year checkbox as you seen in snapshot but it showing as field instead years like: 2018, 2019 in dropdown/select option.

The 1st problem is select/option should show as years like 2018, 2019 so on.... and 2nd problem is when I  clicked on apply filter it showing query as ?sort_by=publish_on&sort_order=DESC so manually I changed it to ?sort_by=2019&sort_order=DESC but still not showed posts which published on 2019.


texts: How do i take a specific node and turn it into a block

texts: I created a content type of which there is only one node of, and i want to add to sidebar left. How can that be done? i would prefer not have to use a module to do this., thanks


texts: How do I deliver a nested JSON array for content reference with export view display?

texts:
I created a product content type with content reference to article(one product to many articles). Then I added field "Content: ID" "Content: Title" and "(field_article: Content) Content: Title" to a new REST export View. "(field_article: Content) Content: Title" come from the relationship "Content referenced from field_article" I added in advanced.

The output is:

[
    {
        "nid":"3",
        "title":"Product1 title",
        "article_title":"Article1 title"
    },
    {
        "nid":"3",
        "title":"Product1 title",
        "article_title":"Article2 title"
    }
]

What I would like to achieve is something like this:

[
    {
        "nid":"3",
        "title":"Product1 title",
        "articles":
            [
                {
                    "title":"Article1 title"
                },
                {
                    "title":"Article2 title"
                }
            ]
    }
]

How to implement this?

UPDATED:
I also tried aggregation, but in case of REST export View as the format is Serializer, no "group by" option in format setting but hal_json, json and xml options, while "Aggregation settings" appears on each filed. In this case, I don't know how to set "aggregation settings" group by node id. Also I cannot find document about aggregation settings of field in "Fields" section.


texts:
When logged in as a user (not admin), some JS scripts do not load on certain pages.
I found out about this issue because I am using the module EU Cookie Compliance and the scripts it uses (eu_cookie_compliance.js, jquery.cookie.shim.js, js.cookie.min.js) aren't always loaded.
I am using a JS method provided by the EU Cookie Compliance module in my custom theme and found out it triggered an error on some pages (because the scripts aren't loaded).
For example, the scripts load on /user/2 but don't on /user/2/orders or /user/2/customer as you can see on the below image. Why does this happen?

I can see no option in EU Cookie Compliance module that prevents loading the script on some pages. Nor did I find anything in the code.

Drupal core: 8.9.3
EU Cookie Compliance: 8.x-1.9

Edit:
I have now included eu_cookie_compliance as a dependency in my theme:
dependencies:
  - core/drupal
  - core/jquery
  - core/jquery.once
  - core/drupalSettings
  - eu_cookie_compliance/eu_cookie_compliance
  - eu_cookie_compliance/eu_cookie_compliance_bare

And this fixed the fact that the scripts weren't loaded on all pages. That said, I now have errors on these specific pages.
All I do in my theme's JS (radix_sub.script.js) is using Drupal.eu_cookie_compliance.hasAgreed() which now triggers the following errors:

I have tried declaring only eu_cookie_compliance and only eu_cookie_compliance_bare and both in my theme libraries, and the errors are identical.


texts: Drush policy restriction doesn't restrict sql_sync

texts:
On my @dev machine, I've installed a drush policy rule that should (?) prevent sql_sync to my remote @prod machine,

cat /etc/drush/policy.drush.inc
    <?php
    function drush_policy_sql_sync_validate($source = NULL, $destination = NULL) {
        if ($destination == '@prod') {
            return drush_set_error(dt('POLICY: sql_sync TO @prod is NOT allowed'))
        }
    }

When I attempt the sql_sync, instead of preventing the action and printing the error, it allows it,

drush -v sql-sync --simulate=0 @dev @prod
    Loaded alias @defaults from file /etc/drush/aliases.drushrc.php                                [notice]
    Loaded alias @prod from file /etc/drush/aliases.drushrc.php                                    [notice]
    Loaded alias @dev from file /etc/drush/aliases.drushrc.php                                     [notice]
    /home/drupal/drush/drush  --backend=2 --verbose --uri=https://dev.mydomain.com                 [notice]
    --root=/home/drupal/dev  sql-conf   --all 2>&1
    ssh -o PasswordAuthentication=no root@prod.mydomain.com 'drush  --backend=2 --verbose          [notice]
    --uri=https://prod.mydomain.com --root=/home/drupal/prod  sql-conf   --all
    2>&1' 2>&1
    Modification time of local dump file /home/drupal/drush-dumps/sql-sync-dev.sql is less than 24 hours [warning]
    old. Use the --no-cache option to force a refresh.

    You will destroy data in prod.mydomain.com/prodDB and replace with data from devDB.

    You might want to make a backup first, using the sql-dump command.

    Do you really want to continue? (y/n): y
    Calling system(rsync -e 'ssh ' -akzv --exclude=".git" --exclude=".gitignore" --exclude=".hg" --exclude=".hgignore" --exclude=".hgrags" --exclude=".bzr" --exclude=".bzrignore" --exclude=".bzrtags" --exclude=".svn" --stats --progress /home/drupal/drush-dumps/sql-sync-dev.sql root@prod.mydomain.com:/home/drupal/drush-dumps/sql-sync-prod.sql);
    sending incremental file list

    Number of files: 1
    Number of files transferred: 0
    Total file size: 14634184 bytes
    Total transferred file size: 0 bytes
    Literal data: 0 bytes
    Matched data: 0 bytes
    File list size: 37
    File list generation time: 0.001 seconds
    File list transfer time: 0.000 seconds
    Total bytes sent: 46
    Total bytes received: 12

    sent 46 bytes  received 12 bytes  38.67 bytes/sec
    total size is 14634184  speedup is 252313.52
    Calling system(ssh -o PasswordAuthentication=no root@prod.mydomain.com 'mysql --database=prodDB --host=127.0.0.1 --user=dbadmin --password=secretpassword --silent < /home/drupal/drush-dumps/sql-sync-prod.sql 2>&1');
    Command dispatch complete                                                                      [notice]

What do I need to change/add to get the policy to restrict the sql_sync?


texts: cck fieldgroup tabs appear but all fields in one tab

texts:
I am using cck fieldgroup tabs to group various fieldsets under different tabs and I want them to appear in tabs to anonymous user.

Somehow the tabs are not working. The tabs are all there sitting above but all the fields within each fieldset are all shown on the same page and the tab links work as if they are internal links for the same page. You click on any link and you are moved down to the fields in that fieldset on the same page.

I looked into the generated page in firebug and it came out that the classes responsible for generation and grouping of tabs are all wrong in the div and ul tags. when I changed them to the correct ones using firebug , they all looked fine in browser.

Now I dont know how are these classes put into div tags in the backend so that i can rectify it. Can someone help please.?