texts:
I am using Drupal 7 to create an registration form, there are: username, email dan password fields, but I want to make an username checking while user leave username field (ajax).
I found an module as Username Check

This module is great and working in "myweb/user/register" form, but I need to move this function to my custom form in username field too

The code:

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

  $items['username_check/isunique'] = array(
    'type' => MENU_CALLBACK,
    'page callback' => 'username_check_callback',
    'access arguments' => array('access content'),
    'file' => 'username_check.unique.inc',
  );

  $items['admin/config/system/username_check'] = array(
    'title' => 'Username check',
    'type' => MENU_NORMAL_ITEM,
    'page callback' => 'drupal_get_form',
    'page arguments' => array('username_check_settings'),
    'access arguments' => array('administer site configuration'),
    'file' => 'username_check.admin.inc',
  );

  return $items;
}

function username_check_form_user_register_form_alter(&$form) {

  $mode     = variable_get('username_check_mode', 'auto');

  if($mode != 'off')
  {
    _username_check_load_resources($mode);
    $form['account']['name']['#field_suffix'] = '&nbsp;';
    $form['account']['name']['#suffix'] = '

';
  }

}

/**
 * Load username_check resources.
 */
function _username_check_load_resources($mode) {
  $module_path = drupal_get_path('module', 'username_check');
  drupal_add_css($module_path . '/username_check.css');
  drupal_add_js($module_path . '/username_check.js');

  drupal_add_js(array(
    'usernameCheck' => array(
      'ajaxUrl' => url('username_check/isunique', array('absolute' => TRUE)),
      'delay'   => variable_get('username_check_delay', 1),
    ),
  ), 'setting');
}

and my form as userregis_form
How to apply this to my custom form?


texts: What is x-speed-cache-key? What is its purpose?

texts:
Our drupal site was pentested.  The pentest report labeled an action involving the header X-Speed-Cache-Key as a security concern.

The finding stated:

  Arbitrary parameters supplied to the query string are returned to the user unencoded in the X-Speed-Cache-Key response header.

I'm not familiar with caching or with the header x-speed-cache-key. For a Drupal site functionality should the x-speed-cache-key function as stated in the finding? Is this a valid security concern for Drupal? Is the x-speed-cache-key header provided by a module, or is it a part of Drupal core?


texts: List organic group members from the current user group on his profile page

texts: I am new to organic groups, I ran into a problem, I am a member of some organic group, I need to list other members of same group on my profile page, Trying to display it using views but no luck :(,  I am working on drupal 7 with Organic group 7.x-2.9


texts: What is the "contract" for EventSubscriberInterface functions?

texts:
The EventSubscriberInterface can be used to listen for events, and getSubscribedEvents is used to announce which events an implementation would like to subscribe to.
The getSubscribedEvents must return an array which holds the type of events an implementation would like to subscribe to, as well as the function which is to be invoked when an event triggers.
  public static function getSubscribedEvents() {
    return [
      KernelEvents::REQUEST => [
        ['redirectToLoginPage'],
      ]
    ];
  }

The documentation is very sparse on the function :

The method name to call (priority defaults to 0)

By looking at other implementations, I see that the function may return TRUE, FALSE and even implementations of Response. An example implementation could thus look like this :
public function redirectToLoginPage(GetResponseEvent $event) {
  $random = rand(0,2);
  switch($random) {
    case 0:
      return TRUE;
    case 1:
      return FALSE;
    case 2:
     $response = new RedirectResponse('/user/login', 301);
     $event->setResponse($response);
     return TRUE;
  }
}

What is the "contract" for the function which subscribes to events? Specifically, what is the impact of returning TRUE and/or FALSE from this function?


texts: I am using a webform module to create a contact us form. The customer has asked for a dropdown list for the visitor to select whom they would like to contact (web administrator/general enquiry). Is there a way to change the TO email depending on the selection? Or is there another way of achieving this?


texts: There is a standard for the error codes in the drush_set_error() function?

texts:
I usually use the drush_set_error() function when I want to log a error in drush, sometimes I just do something like this:

drush_set_error('DRUSH_INVALID_ARGUMENT', '....');

sometimes

drush_set_error('MODULE_NAME_INVALID_ARGUMENT', '....');

But I'm wondering if there is a standard or something similar to correctly name the error codes.

The only doc that comes in the function description is:

  \Drupal\Component\Render\MarkupInterface|string $error: A text string
  identifying the type of error.


texts:
Something I've been battling for some time: Is there any way to make the results of a views page permanent?

For Instance: There is a club racing website that inputs Entrants as nodes, to events, which are also nodes. The entrants get scores based upon their performance at the event. However, Entrants come and go in the club, and as they come and go so should their nodes.

Is there any way to make their scores still appear on a views page, even if I happen to delete or unpublish their node? Is there a, 'print as static' option?


texts: Is it correct to use taxonomy_term_is_page() in this code?

texts:
I am trying to get some content to show up when some conditions are verified: if I am on a certain page, the content will be shown; differently, the content is blank.
Everything looks correct; I just don't know if I am not using the correct function or something else is wrong.

<?php if (!taxonomy_term_is_page('18')): ?>

blah 1 News

<?php elseif (!taxonomy_term_is_page('28')): ?>

blah 2 News

<?php elseif (!taxonomy_term_is_page('29')): ?>

blah 3 News

<?php elseif (!taxonomy_term_is_page('30')): ?>

blah 4 News

<?php elseif (!taxonomy_term_is_page('81')): ?>

blah 5 News

<?php endif; ?>

This displays the results; however, when I am on one of the other terms the output doesn't change: it stays the same as the output for the taxonomy term with ID equal to 18.

My description for what I was trying to achieve has been changed; I am not trying to get anything shown based on any conditions. To put it in better words, I am trying to have the content shown; if I am on taxonomy/term/18, the content would show the else nothing would shown if I am on taxonomy/term/28 content shows and so on. It's simular to is_front_page function and you have content shown if you are on the front page, except these are taxonomy terms.


texts: How can I remove zombie Panel menu item links caused by Features?

texts:
I have a site that uses several panels, each of which has a menu link.  Recently I decided to remove the links on my local dev copy.  I updated my feature (which contains the panels) and then reverted on my host... But the links were still there.

Because the links are provided by Panels in code, they can't simply be deleted from the menu.  How can I delete these links?


texts: Implementing different user registration

texts:
I have looked elsewhere for the problem I faced, but I cannot get any clue on solving the problem. Consider, based on the type of user, I want to implement different user registration page. In current D8 version, I could add fields at admin/config/people/accounts/fields. Let's say a teacher has fields like
Fname, Lname, ID, Contact, and School Name whereas student has fields like Fname, Lname, Course, and Age.

If I add those mentioned fields in the user table, I won't be able to differentiate whether that is teacher or student. In that case, how do I make two different registrations, one for teacher another for student, and store them as Drupal users so that I can apply functions such as \Drupal::currentUser->isAuthenticated() on them?


texts: Change content "Author" to the last "Editor"

texts:
On the admin/content page. The field "AUTHOR" shows who created the content, but this is not very helpful for seeing who last edited it.

How would you change this to show who last edited it?


texts:
I created a new role for the user to write.
How do I forbid the publication to a redactor?


texts: Views list with picture as left, title and content as right

texts:
How to make such a layout as on example screenshot?
Picture on left, Title and truncated content on right.

What view format i need to use?


texts:
I try to implement hook_menu() in a module and the code inside of this hook depends on another hook implemented in the same module Example:

function mymodule_menu() {
   $streamwrapper = file_stream_wrapper_get_instance_by_scheme('myscheme');
   if($streamwrapper !== false) {
      $directory = $streamwrapper->getDirectoryPath();
       .....
   }
}

and another hook function in the same (mymodule) module

function mymodule_stream_wrappers() {
  retunr array( 'myscheme' => array(...)
}

Apparently, hook_stream_wrappers() is called after hook_menu(), and file_stream_wrapper_get_instance_by_scheme() returns false during module installation process.

So, the whole idea works because Drupla will call hook_menu eventually and by that time stream wrapper will be in place and ready, but it seems too unreliable, IMHO.

Anyway, is it possible to control hooks order somehow? Or is there a better way to achieve desired result - retrieve stream wrapper in hook_menu after is has been known by the system?


texts: Does Commerce Override Username Or Is Username Linked To A Node?

texts:
Commerce Kickstart 2.

I used the included Feed to import users. I applied this patch: https://www.drupal.org/node/1570544 so I could keep the existing UIDs. Seemed to work OK.

I then wrote a script to import sales orders from an external db. That too seemed to go OK, except that the Username displayed on all reports, views, in fact -anywhere- that the field User:Name is displayed, it shows the First Name/Last Name of the billing profile of the last linked order. eg.

The username is 'MEGACORP'. But 'Frank Smith' is displayed as the User Name because that was the First/Last name of the imported order. -And- the link to the user account profile is users/frank_smith

The weird thing is that when people log in, they log in with the -correct- Username, ie. megacorp, -not- Frank_Smith

I looked at the SQL table Users and the Username is correct. (ie. megacorp)

AND I stumbled on creating a view of users, but as a wild-ass-guess set a relation to node entity reference and the Title field is 'Megacorp'.

Here are my field mappings in my customer profile import:

// Full Name(Required)
$profile_billing->commerce_customer_address[LANGUAGE_NONE][0]['name_line'] = $name;
// Country(Required)
$profile_billing->commerce_customer_address[LANGUAGE_NONE][0]['country'] = $row->country_iso_code_2;
// Address 1(Required)
$profile_billing->commerce_customer_address[LANGUAGE_NONE][0]['thoroughfare'] = $row->billing_street1;
// Address 2
$profile_billing->commerce_customer_address[LANGUAGE_NONE][0]['premise'] = $row->billing_street2;
// City(Required)
$profile_billing->commerce_customer_address[LANGUAGE_NONE][0]['locality'] = $row->billing_city;
// State(Required)
$profile_billing->commerce_customer_address[LANGUAGE_NONE][0]['administrative_area'] = $row->zone_code;
// Postal Code(Required)
$profile_billing->commerce_customer_address[LANGUAGE_NONE][0]['postal_code'] = $row->billing_postal_code;
//Business name(Required)
$profile_billing->field_business_name[LANGUAGE_NONE][0]['value'] = $row->billing_company;
 // Phone(Required)
$profile_billing->field_phone_number[LANGUAGE_NONE][0]['value'] = $row->billing_phone;`

So...
1. why is Username not pulling from the Users SQL table?

Is the above behaviour something Commerce does? If so, can I turn it -off-?
Is there -always- a related node for each user?
The field billing_company doesn't seem to display on any view, even though it is available to import. How do I access -that-? I guess -that- is what I expected to appear on various forms/reports (eg. the invoice)


texts: altering css / asset weight after it's been added?

texts:
I'm using context add assets to add a stylesheet.

It's currently being loaded correctly based on a context; but now it's loading before my global.css stylesheet. I would like blog to load after global.css.

Is it possible to alter the weight of the blog.css stylesheet via preprocessing? If so could you provide an example?


texts: Remove jQuery and find out what is asking it to be included

texts:
I'm using drupal 7 and I simply don't want jQuery included at all. It seems like most people are advocating modify the js in a theme hook. That's fine I suppose, but it seems like this is dangerous and a little silly.

If we're removing jQuery after something has requested it, won't that break whatever requested? How can I find out what is requiring jQuery?

Related to that is all the system CSS files that are included by default. I've also found that using a theme hook to get rid of them is the way to go. It seems like Drupal has a lot of "features" like this that require you to add more code to remove things. It seems like there should be a more efficient way to handle things like this. (forgive me if I'm mistaken, I'm coming from years of work with frameworks and not a full stack CMS).

In the end, what I want is a theme that has NOTHING in it except what I explicitly say should be there. Right now I'm considering just writing the html.tpl.php to not use the dynamic drupal variables.


texts:
In Drupal 7, I could use hook_admin_paths to decide if a page used the main or admin theme. This has changed in Drupal 8. This option is now set in a route definition. Existing routes, like node.add, can be altered. However, looking in node.routing.yml, under node.add, I do not see _admin_route: TRUE, which I intended to alter to FALSE.

What do I need to alter, and how, so that adding and editing nodes is done using the main theme?


texts: In Commerce 2, has anyone gotten Sales Tax calculation to work with the "Limit by postal code" option?

texts:
We've been trying to get sales tax calculations to work to calculate a tax rate depending on the Shipping address postal code.

When we setup up a new tax rule and enter the zip code(s) that match that rate's district the tax is not calculated during checkout.

On the configuration screen we notice that it says:

The tax type will be used if both the customer and the store belong to one of the territories.

This seems odd and is probably the cause of the issue that we're having.

Why would the stores' address need to be in the zip code of the order's ship to address?

We thought we solved it be simply entering another territory to the tax rate that did not include any "Limit by postal code" but all this did is cause the tax rates to display if the State matched and it ignores the other 'limit by postal code' filters.

Are we missing something in the setup, or is this a severe limitation of how you can configure tax rates in Commerce 2 (you can only charge tax for the zip code that the store's address is located in)?


texts: Steps for Changing the Order of the Payment Methods on Checkout

texts:
I have two payment methods: Cheque and PayFlow Pro enabled for my products. However, they are showing up on the checkout form in an undesirable order:

Pay by Cheque (selected by default)
Pay by Credit Card

I'd like to reverse those and make Credit Card the default option. This question APPEARS to be answered here, but I don't understand the answer.

Would someone kindly provide the steps needed to make this happen?


texts: How to add a predelete hook for a custom or existing entity like commerce order?

texts:
I need to do stuff before a Drupal Commerce order is deleted.

On the entity api page I found a patch which somehow adds predelete hooks, or at least makes entities invoke those. But somehow I cant get it to work using the following code:

/**
 * update stock when deleting an order
 */
function mymodule_entity_predelete($entity, $type) {
  if ($type == 'commerce_order') {
    $order_wrapper = entity_metadata_wrapper('commerce_order', $entity);

    $line_items = $order_wrapper->commerce_line_items;
    foreach ($line_items as $line_item) {
      $delete = intval($line_item->quantity->value()) * (-1);
      mymodule_update_line_item_stock_by_diff($line_item, $delete);
    }
  }
}

The function doesnt get called. Basically what I am trying to do is to free each line item's stock (commerce_stock) which of course is not possible when the entity is already deleted.

Do I have to extend the commerce order entity controller somehow?


texts: Operations links missing from Content list

texts:
I've just inherited a project with the odd issue of all Operations links being empty, whether when viewing records in a content list, or viewing themes. Here's what I'm seeing:

This problem exists no matter what theme is selected for admins, and I am logged in as an administrator. Any ideas where I can hunt down the problem?


texts: How to create a rule to conditionally send a notification email, based on field value?

texts:
In the Article content type, I have a field called "Assign to" which is a reference to a User entity. So that the users (editors) can know witch articles are assigned to them by the administrators.

How should I configure the Rules module to send an email to editor when article is assigned to an editor, telling editors witch article is assigned to them, and who assigned this article?


texts:
I am using drupalchat module for my website. And I wanted to check which polling method is best - "Normal AJAX" or "Long Polling". Actually We are facing performance issue. Currently we are using "Normal AJAX" as polling method.
Can somebody suggest which polling method we should use and why?


texts: Write complex access control in a reusable way

texts:
We deal with nodes representing humans with two important properties: mother and father.

Your parents as well as your aunts and uncles should get extra permissions, like to see you in a certain view mode, or to see your private images.

Where should I place this complex access control in a way that I can easily call it in several controllers and hooks?

Is there a name for the kind of feature I'm going to program?

If there's no better idea, I would go with a validation. We could put the access control in a validator that we use like this:

$errors = $family_access_validator->validate($node);
if (count($errors) > 0) {
    throw new AccessDeniedHttpException();
}

However, I'm not sure whether this is the correct approach. When we use validation, we are always interested in the message why the data is rejected. Here, we are only interested in OK or not OK.


texts: How to run `drush make` on the existing Drupal installation?

texts:
Whenever I try to run this command for a second time I get an error.

drush -v make /home/testdev/xipdrupalbasic.make /home/testdev/drupal

Loading release_info engine.                                            [notice]
Base path /home/testdev/drupal already exists                           [error]
Command dispatch complete

I get why it gives me this error, but I would like a way of giving a force or overwrite command with it so it still runs. I get the error because it tries to make a directory that already exist.

I already tried  the adding -r to it but it will then just install it in the directory you execute the command.

When i just do:

drush -v make /home/testdev/xipdrupalbasic.make

in the directory where I want it, it will work without a problem.


texts: Create path alias for hook_menu URLS based on node information

texts:
I'm looking for guidance on how to dynamically create a path alias for dynamic paths that I create in a module using hook menu. For example, I have a module that defines a path such as subsite/template2/% where % expects the nid of a node. For that specific node, however, I want to create the alias based on the title of the node.

So if the title at subsite/node/5 is "Community Gardens" I want the path alias of subsite/template2/% to become subsite/community-gardens. I'm pretty certain this is possible, I'm just not sure how to do it. It even gets more complicated because there are sub tabs that need to be aliased but I figure if I can figure out the first part I can puzzle out the rest. (Using version 7)


texts: How to exclude current node from a block view?

texts:
I created a block view listing nodes of the content type: cars.

I added the block to the second sidebar.

After, I created 2 nodes of this type with the titles: car-1 and car-2.

Then the view block shows these 2 nodes. So far so good.

If I visit the page example.com/car-1 I see the block listing both the car 1 and car 2 nodes. I want to exclude the car-1 node from the block since I'm at: example.com/car1

This is what I did in the view:

1.  Click on add under "contextual filters".
2.  Choose Content:nid.
3.  Under "when the filter variable is not available, choose "provide default value".
4.  From the drop down menu select "content id from url".
5.  Scroll all the way down to the bottom of the window and click on the
6.  "More" link.
7.  Click "Exclude"

I works fines if I visit a node, but the block is not shown in any Views (i.e.: in the frontpage view )

I know that the reason is that the Content nid is not present in a view, but don't know how to workaround this.


texts: How to setup a rule to redirect to shopping cart?

texts:
I am trying to create a rule that after a user creates an account they are sent to a Checkout page that will eventually have them pay via PayPal ( I am using the Commerce Module ).

My steps so far have
1.  Created an event "After saving a new user account"
2.  Leave Condition blank.
3.  Select Action of Complete Checkout For an Order

At step three it asks for a Data Selector: "Select data of the type Commerce Order." and I have no idea where to go from here.


texts: Get the breadcrumbs for a specific node other than the current

texts:
I have a list of nodes created by a view. Those nodes tend to have titles that are mostly the same, but since they are in a rather logical hierarchy defined by the menu I'd like to output the breadcrumb to the nodes as well.

I couldn't find a core-function that does that. Anyone an idea how to work around/on that?


texts: How to find which content type is using which context?

texts:
How to find which content type (abc) is using which context? As I do have around 30 contexts in my site.

Is there a way to find which context is using content type (abc)?


texts:
I'm receiving the following two errors, i'm unsure how to fix them. after doing some research this file has had issues before. The solutions did not solve my problem. Could this be a simple script load order?

  Uncaught TypeError: Cannot set property 'bootstrap' of undefined (anonymous function) @ bootstrap.js?ny6rj2:13

var Drupal = Drupal || {};

(function($, Drupal){
  "use strict";

  Drupal.behaviors.bootstrap = {
    attach: function(context) {
      // Provide some Bootstrap tab/Drupal integration.

  (anonymous function) @ bootstrap.js?ny6rj2:230

})(jQuery, Drupal);


texts: How to stop menu links being disabled after saving nodes?

texts:
A localised Drupal 7 site I'm working on has a navigation menu along the top. Each node is provided with a menu link with a given weight. Nodes are translated into three (non-English) languages (the admin language is English). The nodes show on the menu correctly depending on the current language.

Whenever I edit a node (eg edit the title, body) and click Save, its links disappears from the menu.

The same thing happens if I edit a node but don't actually change anything, then click Save.

I can re-enable it by:

Edit the node again
Untick the menu link
Save
Edit the node yet again
Tick the menu link (re-filling the title/weight)
Save again

Or:

Go to admin/structure/menu/manage/main-menu
All the other menu links are enabled, but the recently saved is not and has "(disabled)" after its name
Tick the box to re-enable
Save configuration

But how can I stop menu links from being disabled when a node is edited?


texts:
On my new site all works fine so far, except that when I try to clear cache (e.g. class cache or table cache or just flush all caches) from the UI. I sometimes get an error about exhausted memory (64M on production, 128M on test site).

Are there any alternatives to clearing cache from the UI? Can I just delete all records from the database tables starting with "cache" and obtain the same result?


texts: Can I use the $language variable in a Drupal 6 template file?

texts:
Is it correct to use the $language variable to make conditions in the page-front.tpl.php?
Is if ($language == 'es') correct?


texts: How to get rid of error messages after second try where file was uploaded successfully?

texts:
My question is similar to:

https://stackoverflow.com/questions/9676988/in-drupal-7-errors-for-file-managed-field-remain-even-when-fixed

Why error message from my custom file validator remains the same after next try where was file uploaded  successfully ?

How can I solve this problem?

I didn't find any JS handler which I can extend.


texts: Create a view of nodes that are not referenced in any entity reference field of another content type

texts:
How can I create a view of nodes that are not referenced in an entity reference field assigned to another content type?

I have a Profiles content type and a Publications content type.  The Publications content type has an entity reference field by which the publications can be associated with one or more Profiles.  How can I list all Profiles nodes that are not referenced in any Publication?


texts: How to implement a dynamic filter with views in D7?

texts:
I have a site where i have several main topics, each containing subtopics.  I've made views block which is shown on each of the pages of the main topics where you have two exposed filter options:
 - filter on main topic
 - filter on subtopic

For the filter on subtopic the idea is to ensure that only those subtopics are shown that reside under the selected main topic.  How can i do that?


texts: Tweet a published content on twitter from Drupal 7

texts:
My goal is tweeting content from a Drupal site as soon as a node / content is posted on the Drupal 7 site.

I follow all the instruction from this post "How to automatically tweet a published content on twitter from Drupal 7?" and did not work. What they recommend is to use the Twitter Module, this module you need to created an app at Twitter to make authentic it. I created the app and I'm able to pull all the tweets from Twitter to my site. Also, I'm able to sign in with Twitter however, I'm not able to automatic post a tweet after a node its created.

I can see the Twitter tab on my content type before I create a node. After I created the node a message said "Successfully posted to Twitter" but on twitter I cant see anything.  Can anyone tell me how to troubleshoot this ? Or do I'm missing something ?


texts:
On my commerce site I give free shipping for users with total order over €100.
Now I would like to create a view that would say, "spend [x] euros more to get free shipping," where [x] is simply 100 - $total_order.

Is there a way to accomplish this in Views, or do I need to use PHP?


texts: How to debug missing default value of managed file?

texts:
I have a form with images. It also contains title and alt for 3 languages, so when I select them in one query, I get the same managed file fid 3 times. But that's not the problem.

Relevant part of code is:

kpr($image_has_language);
$first_language = reset($image_has_language);
$form['image'][$i] = array (
   '#type' => 'fieldset',
   '#collapsible' => FALSE,
   'ImageFile' => array(
     '#type' => 'managed_file',
     '#default_value' => (integer)$first_language['ImageFile'],
     '#title' => t("Image"),
     '#title_display' => 'invisible',
     // '#description' => t('Allowed extensions: gif png jpg jpeg.'),
     '#upload_validators' => array(
       'file_validate_extensions' => array('gif png jpg jpeg'),
       'file_validate_size' => array(variable_get('something_image_size', 5 * 1024 * 1024)),
     ),
     '#upload_location' => 'public://something/image',
     '#theme' => 'preview_upload',
   ),
   'id_image' => array(
     '#type' => 'value',
     '#value' => $clone?'new':$first_language['idImage'],
   )
 );
 kpr($form['image'][$i]);

Below results of that kprs:

As you can see, all is perfectly well. File is on disk, file preview work, in database it is marked as permanent and as used.

When I call var_dump on $form_state['values']['image'][0] in validation function, without changing file on the form, I get:

  array(3) {
    ["ImageFile"]=>
    int(0)
    ["id_image"]=>
    string(3) "599"
  }

Values in $_POST are OK:

  ["image"]=>
  array(4) {
    [0]=>
    array(2) {
      ["ImageFile"]=>
      array(1) {
        ["fid"]=>
        string(4) "3696"
      }

If I change file, it works as expected:

  array(3) {
    ["ImageFile"]=>
    string(4) "3698"
    ["id_image"]=>
    string(3) "599"
  }

and in $_POST:

  ["image"]=>
  array(4) {
    [0]=>
    array(2) {
      ["ImageFile"]=>
      array(1) {
        ["fid"]=>
        string(4) "3698"
      }

How can I identify where my value gets removed? I also have another image on that form, single one (so without foreach), and it works OK.


texts: I am creating a Newsletter field for just one component to include email only for newsletter subscription, but I need a way to style both the input field and the submit button to be inline, i.e side by side rather than above each other like typical forms.


texts: How to get by insufficient memory impass - can't access site?

texts:
Can someone help me by this impasse?
I have multiple instances of Drupal running (for now).  One is for testing and major changes.  It seems that I cannot get past the WSOD on my testing instance.  The php.log indicates insufficient memory when database.mysql.inc runs.  I've tried my php.ini max memory setting at 256M and even -1 (unlimited) and restarted apache with no better results.  I can't run drush, can't access the test site.  I'm STUCK!

Can anyone suggest a method to get by this issue to allow me to move forward?  BTW - the other instances work just fine with a 128M max.


texts: How do I disable the password recovery link?

texts: How can I disable, in the standard login form, the link for password recovery? I need it for my custom theme.


texts: How to prevent required field validation in validation function?

texts:
Issue: When create a node and node publish check box is checked, all validation should work (it's working fine). but when create a node and node publish check box is not checked , then all validation should skip.

function mymodule_form_alter(&$form, &$form_state) {
   array_unshift($form['#validate'], 'mymodule_reqursive_unrequired');
}

function mymodule_reqursive_unrequired(&$form, &$form_state) {
    // print_r($form);die;
    $form['actions_copy']['submit']['#limit_validation_errors'] = array();
    $form['actions']['submit']['#limit_validation_errors'] = array();

    $form['title']['#required'] = FALSE;
    $blog_images = $form['field_image_blog'][LANGUAGE_NONE];
    $form['field_page_title'][LANGUAGE_NONE][0]['#required'] = FALSE;
    foreach($blog_images as $image_k => $blog_image) {
      $form['field_image_blog'][LANGUAGE_NONE][$image_k]['#required'] = FALSE;
    }
    // print_r($form);die;
}

Any suggestion ?


texts:
On deleting a term or full vocabulary I'm getting this error:

The website encountered an unexpected error. Please try again later.

I tried to delete terms but this error occurred but those were successfully deleted.

In error log I see this error:

 [Tue Apr 07 18:27:20.141012 2020] [proxy_fcgi:error] [pid 24707:tid 140522664453888] [client 103.87.207.242:59315] AH01071: Got error 'PHP message: Error: Call to a member function delete() on null in govtschemes.in/modules/taxonomy_breadcrumb/taxonomy_breadcrumb.module

 on line 110 #0 [internal function]:
taxonomy_breadcrumb_taxonomy_vocabulary_delete(Object(Drupal\\taxonomy\\Entity\\Vocabulary))\n#1 govtschemes.in/core/lib/Drupal/Core/Extension/ModuleHandler.php(403): call_user_func_array('taxonomy_breadc...', Array)\n#2 govtschemes.in/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(347): Drupal\\Core\\Extension\\ModuleHandler->invokeAll('taxonomy_vocabu...', Array)\n#3

govtschemes.in/core/lib/Drupal/Core/Entity/EntityStorageBase.php(434): Drupal\\Core\\Config\\Entity\\ConfigEntityStorage->invokeHook('delete', Object(Drupal\\taxonomy\\Entity\\Vocabulary))\n#4 govtschemes.in/core/lib/Drupal/Core/Entity/EntityBase.php(403):

Drupal\\Core\\Entity\\EntityStorageBase->delete(Array)\n#5 govtschemes.in/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php(122): Drupal\\Cor...\n', referer: http://www.govtschemes.in/admin/structure/taxonomy/manage/govt_department/delete?destination=/admin/structure/taxonomy


texts: Drupal 7 Javascript Handling Not Working Correctly on Production Server

texts:
Head scratcher.

I have 3 drupal 7 seven websites all hosted on the same vps server.  On my dev server which is an ubuntu 14.04 LAMP installation, all 3 sites work perfectly.  However, after uploading to the production server on all 3 sites various javascript based aspects stop working.

Things that stop working on the production server are:

CKEDITOR will not load - if I try to edit a page on the production server, the editor doesn't load, all I get is a white space where the editor should be.  If I switch text formats to filtered html full html (no ckeditor) everything works perfectly.
Colorbox overlay stops working - I am using the Colorbox module to display pdf files in lightbox overlay.  On my dev server everything is perfect and the pdf's display as design.  However on the production serever the pdf's do NOT load in a lightbox at all.  They simply load in the browser as if I never installed the Colorbox module.

Solutions that  have tried, but did NOT fix the problem:

Flushed Cache reloaded pages
Re-created & Re-uploaded db a number of times
Re-upload the Drupal 7 code base and the Drupal /sites/all/ folder via ftp
I've run the update script after uploading db's
I tried disabling and reinstalling the colorbox module on the production server

NOTE:  In a rush to upload I did commit a "drupal sin" and forgot to put the site in maintenance mode the very first time that I uploaded the DB.  However since then I have put the site in maintenance mode and tried all o the above steps.

If anyone has any ideas, I would highly appreciate them.

Thanx,
yupthatguy


texts:
I'd like to redevelop a site on my  local machine (which takes a few days to accomplish) and then import to it only the nodes which are created on the production site during this period, so that importing new nodes does not undo changes made on the local version and then I can migrate the redeveloped version to production without loosing recent activities.

I am wondering whether it is possible, and how? I appreciate your hints.


texts: Image appears in edit mode in ckeditor but not on  production site

texts:
I am using Drupal-6 with ckeditor.

Now Image appears in edit mode in ckeditor but not on Home Page

Does anybody have idea what was the exact  problem ??

Thanks a lot


texts: How can I remove old polls/results in Drupal 7?

texts: How can I remove the links to old polls and results in Drupal 7? I unset view results for anonymous users, but they still can view results. I'd like to remove the link to old polls and poll results in template. Is it possible to do it? if the answer is yes, which code should I add to template.php to remove those links?


texts: Rendered markup different than template markup

texts:
I am using drupal 7, and the bootstrap base theme to make a simple theme for a website I am working on. I am having issues with Drupal forcefully changing my html5 hierarchy and it's causing the site to break.

Is there anyone that would know what would cause the issue?

I have attached the code snippet in particular that is causing issues, as well as a screenshot from Chrome's inspector showing the misplacement. I have confirmed it's doing it on at least 4 browsers, so I do believe it's a drupal issue.

    <section class="<?php print $column_width; ?>">
      <?php if (!empty($tabs)): ?>
        <?php print render($tabs); ?>
      <?php endif; ?>
      <?php if (!empty($page['help'])): ?>
        <?php print render($page['help']); ?>
      <?php endif; ?>
      <?php if (!empty($action_links)): ?>

<?php print render($action_links); ?>

      <?php endif; ?>
      <?php print render($page['content']); ?>

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

As you can see from the image, the  is being placed outside of the root
 instead of inside of it (and underneath the other
), like the template is telling it to do.

EDIT: The 5 console errors are from image files not being found because I haven't uploaded them yet.


texts: Cannot get the real author of a node through node_load() in drupal 7

texts:
this is a weird one... I have been using node_load('NID') for a few months now in my custom modules and it has always worked all right. The past two days however, something strange is going on. When I create a variable $node in which I load a specific node with node_load, it seems to do it (I can print the $node and all the details appear), EXCEPT that the [uid] of the node that is displayed in the print message is the uid of the logged-in user (if I masquerade as another user, that user's uid is shown). What is weird about all this is that in the database, the uid of the author of the node does not change at all.

    if (arg(0) == 'node' && is_numeric(arg(1))) $nodeid = arg(1);
    $node = node_load($nodeid);
    drupal_set_message('<pre>$node details '. print_r($node, TRUE) .'</pre>');

What the print message shows:

    $node details stdClass Object
    (
     [vid] => 480
     [uid] => 1
     [title] => test ad blocks
     [log] =>
        [status] => 1
        [comment] => 1
        [promote] => 1
        [sticky] => 0
        [nid] => 116
        [type] => ads
        [language] => und
        [created] => 1434880742
        [changed] => 1434880742
        [tnid] => 0
        [translate] => 0
        [revision_timestamp] => 1434880742
        [revision_uid] => 59
    ...

But in the database, the uid is 59 for the node 116...
This problem is recent, and the only aspects that have been modified are our custom modules which do not modify the nodes in any way. Any suggestions?


texts: How do I create a route with a query string?

texts:
I have tried a few things and I cannot manage to make this working.

My route is the following.

    amu_hal.publicationsPerYear:
      path: '/publications/{year}'
      defaults:
        _controller: '\Drupal\amu_hal\Controller\AmuHalController::publicationPerYear'
        _title: 'publicationPerYear'
        year: 2016
        route_parameters:
          url: 'default'
      requirements:
        _permission: 'access content'

The code for the controller is the following.

    public function publicationPerYear($year,$url) {
      $url=urldecode($url);
      $url .='&fq=producedDateY_i:' . $year;

      try {
        $client = new Client();
        $response = $client->request('GET', $url);
        $content = json_decode($response->getBody(), true);
        // ...
      }
    }

The request http://mysite/publications/2016?url=https%3A%2F%2FmyWS%2Fsearch%2F%3Frows%3D5%26sort%3DproducedDate_tdate%2Bdesc%26fl%3Dtitle_s%2Cen_title_s%2Clabel_s%2Cen_label_s%2CdocType_s%2CauthIdHal_s%2ChalId_s%2CstructId_i%2Curi_s%2Ckeyword_s%2Cen_keyword_s%2CauthLastNameFirstName_s%2CjournalTitle_s%26fq%3DauthFullName_t%3A(%22M%22+OR+%22e+d%22) gives the following error:

  RuntimeException: Controller "Drupal\amu_hal\Controller\AmuHalController::publicationPerYear()" requires that you provide a value for the "$url" argument (because there is no default value or because there is a non optional argument after this one). in Drupal\Core\Controller\ControllerResolver->doGetArguments() (line 165 of /var/aegir/platforms/drupal8-dev/core/lib/Drupal/Core/Controller/ControllerResolver.php).


texts: Pass multiple sets of variables to theme function

texts:
If I want to loop through multiple sets of theme variables in my custom theme template, how do I define them in my theme function and pass them to hook_theme?

For instance, in my case, I'm generating an email body to send via drupal_mail(), and the body will contain a list of spa openings. I want to iterate through each set in the mail (the same way views templates iterate over views rows). I have my theme function defined like so:

/**
 * Implements hook_theme().
 */
function my_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_module_mail' => array(
      'variables' => array(
        'service_name' => NULL,
        'time' => NULL,
        'therapist' => NULL,
        'booking_link' => NULL,
      ),
      'template' => 'templates/my-module-mail',
    ),
  );
}

and I can pass one set of variables to the template just fine like so:

foreach ($available_openings[$tid['tid']] as $mail_opening) {
  $variables = $mail_opening;
  $body = theme('my_module_mail', $variables);
}

but what I want to do is pass an array of the variables array so that in my template can do something like this:

<?php foreach ($openings as $id => $opening): ?>
  <div class="<?php print $classes_array[$id]; ?>">
    <?php print $opening; ?>
  </div>
<?php endforeach; ?>

What do I need to change to do that?

Thanks.


texts: "This entity (node: id) cannot be referenced" error

texts:
I use Drupal 8 and I have a content type which has a field that references another content type as a entity reference field. I use a rest endpoint to create the node and the referenced node which works fine.

I also have the workbench module installed so I can change the moderation state of the nodes.

The problem is that when I change the moderation state from draft to review I get the error This entity (node: {ID}) cannot be referenced.

Why am I getting this?


texts: 500 error when deleting node with 300,000 comments

texts:
I have a node which has been spammed and has 300,000 comments. Whenever I try to delete it I get a 500 internal server error.

Deleting all comments via database is not an option because I need to retain a large number of legitimate comments on OTHER nodes. However, this specific node has been spammed and I wish to delete the node and all associated comments, But I can't. I have disabled commenting on the node, but how can I remove these comments? Any ideas?


texts:
Using Backup and Migrate module on a D7 site

separate backups (data / files) give no problem (backup to nodesquirrel AND download)
but backup entire site (data + files) generates "http error 500" (without "internal server error")

Error reporting

I have no access to Apache error log
Cpanel error: no error messages
Drupal error log: no error messages

Shared hosting | db 10.1.21-MariaDB | php 5.6.30 | drupal 7.53 | backup and migrate 7.x-3.1 | civicrm 7.x-4.7.14

[update]

The web host provider received next message:

 Uncaught exception 'PDOException'
 with message 'SQLSTATE[HY000]:
 General error: 2006 MySQL server has gone away'
 in <drupal root>/includes/database/database.inc:2227
 Stack trace:
 #0 /includes/database/database.inc(2227): PDOStatement->execute(Array)
 #1 /includes/database/database.inc(697): DatabaseStatementBase->execute(Array,  Array)
 #2 /includes/database/database.inc(2406): DatabaseConnection->query('SELECT expire, ...', Array, Array)
 #3 /includes/lock.inc(167): db_query('SELECT expire, ...', Array)
 #4 /includes/lock.inc(146): lock_may_be_available('schema:runtime:...')
 #5 /includes/bootstrap.inc(433): lock_acquire('schema:runtime:...')
 #6 /includes/bootstrap.inc(455): DrupalCacheArray->set(Array)
 #7 [internal function]: DrupalCacheArray->__destruct()
 #8 {main} in <drupal root>/includes/database/database.inc on line 2227


texts: Why do site visitors end up with two sessions after logging in?

texts:
I have an up and running Drupal 6.30 (latest) site, but some users are having problems logging in.
This is due to the user having two rows in the sessions table, one for uid 0 and one for their uid (this one appears after logging in).
The session for uid 0  should be removed from the database after authentication, but it is not.

Question: How could a user end up with two sessions or why is the uid 0 not removed?

Steps to repeat and further background:

Truncate sessions table
Delete all cookies in browser
Visit site homepage.
This gets a new session for uid 0.
Login
Successful login is seen in the watchdog table.
uid x appears in the session table.
The uid 0 session is not deleted, but I think it should be.

I believe that this causes the browser to send both sessions and Drupal only expects one, so if the uid 0 session is seen by Drupal then the request is seen to be from an anonymous user.

The user is redirected back to the homepage and is presented the login form again and is not logged in. Ironically, the user's name appears in the footer of the homepage as a logged in user.

Additional info: I managed to get some debug info from a user. After logging in the browser also has two sessions. Both have the same SESSxxxxxx name but different values. So it seems the old session is not being destroyed properly.

Full disclosure: I've posted this question on the Drupal Community Forum but haven't had any response after 48h, I hope it's ok to cross post it here.


texts: How to disable AVS check in commerce cybersource SASOP

texts:
Using Commerce CyberSource SASOP it is possible to ignore the results of AVS verification?
There is an option for this as specified in the CyberSource Development Guide on the page 74.


texts: How to change Drupal's default login error text

texts:
I have tried using this code -

     */
    function customform_demo_form_alter(&$form, &$form_state, $form_id) {
     global $user;

      if ($form_id == 'user_login'); {
        if (!$user->uid) {
            array_unshift($form['#validate'],'customform_demo_user_login_form_validate');
        }else{
        drupal_get_messages();
        }
      }

}

function customform_demo_user_login_form_validate(&$form, &$form_state) {
  drupal_set_message('Your username or password was not recognized. Click here to reset your password.', 'status');
}

but can't get the message in the default format.


texts:
I have a content type with a multivalue imagefield, each image contains the image file and title attributes.

A lot of the images need to be uploaded again so I need them to replace. If I remove and add the image again I need to add the title again which I do not want because of the number of images.

Is there a module or solution to replace it instead of remove and add it?


texts: Adding core Javascript libraries in my_module.libraries.yml

texts:
I've read Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 module and I can see where you can add assets that are part of your module or from a CDN or external source. What about if that library you want to add is already a core asset?

I'm trying to add jquery.ui.accordion to my modules so in my *.libraries.yml I have:

my_module:
  js:
    /core/assets/vendor/jquery.ui/ui/widgets/accordion-min.js: { minified: true }
  dependencies:
    - core/jquery.ui
    - core/jquery.ui.widget

That library is never loaded. What am I missing? Is there a better way to add core assets to my module?

EDIT: I've also tried different paths like:

core/assets/vendor/jquery.ui/ui/widgets/accordion-min.js: { minified: true }
../../../core/assets/vendor/jquery.ui/ui/widgets/accordion-min.js: { minified: true }


texts:
I want to use the Order number rather than the order id. I'm using Commerce POS and it uses $commerce_order->id()to generate the id used in the receipt generated and receipt email sent. But in trying to use $commerce_order->getOrderNumber() it returns empty (even though that's what is used in commerce/modules/order/src/Mail/OrderReceiptMail.php). I expected that the Order object holds everything related to an order including the Order Number.
The confirmation email which is default to commerce produces the expected order number and formatted as defined by the Number pattern. What is right snippet to order number?


texts: How do I prevent my content's title from appearing in the  tag of my RSS feed?

texts:
I have a newly migrated Drupal 8 site and am noticing that the RSS feed displays the Title of a node twice in my feed reader. This is because a node's title is output both in the feed item's <title> and within the item's <description>.
For example:
<item>
  <title>My Clever Title</title>
  <link>http://example.com/node/123</link>
  <description>&lt;span data-quickedit-field-id="node/123/title/und/rss"&gt;My Clever Title&lt;/span&gt;

  &lt;div data-quickedit-field-id="node/123/body/und/rss" class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;
  Lorem ipsum... my content displays here....
  </description>
  ...other tags here...
</item>

So now, a feed reader like Feedly displays my content like this:

My Clever Title
My Clever Title
Lorem ipsum... my content displays here....

Note: In my RSS Manage Display, the content type is set to display the "Default" (not-trimmed) body field.
How do I prevent my RSS feed from inserting the post's title into the the <description> tag?


texts: Drupal - Run update.php after updating several modules?

texts:
In Drupal, if several modules need updating, is it OK to copy all the files across and run update.php once, or do I need to copy each module individually and run the update each time?
Thanks


texts:
Possible Duplicate:
  Print the query which is built using db_select()

How can I remove :db_insert_placeholder_0 and table prefix from database query __toString() debug function.


texts: redirect internal body urls temporarily for local development

texts:
I have painstakingly moved my production site to a local dev server to do some offline edits.  However, all of the internal site links located in the body of whatever page still point to the production site.

How do I temporarily redirect urls in the body of pages to the local dev server?

I need

  "examplepage.org/randomcontent"

to redirect to

  "examplepage/randomcontent"

NOTE: All the drupal nav pages via admin menu work correctly.  Seems like a common problem, but I can't find a straight forward solution.


texts:
I just spent a lot of time finding an element in a render array. I usually use dpm() to print the array, and then expand the options until I find what I'm looking for.

On larger arrays that's cumbersome. When I use print_r(), I can do a text search, but then it's hard to see the structure of the array and find the path to the element.

What other methods can you suggest?


texts:
I try to install my module, and everything goes ok, without an error while enabling

  DatabaseSchemaObjectExistsException: Table products already exists. in
  DatabaseSchema->createTable()...

I checked it and there wasn't the products table.

My install function is:

function products_schema() {
    $schema['products'] = array(
        'description' => 'The base table for products.',
        'fields' => array(
            'pid' => array(
                'description' => 'The primary identifier for a product.',
                'type' => 'serial',
                'unsigned' => TRUE,
                'not null' => TRUE,
            ),
            'name' => array(
                'description' => 'The title of this product, always treated a non-markup plain text.',
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
                'default' => '',
            ),
            'created' => array(
                'description' => 'The Unix timestamp when the product was created.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
            'changed' => array(
                'description' => 'The Unix timestamp when the product was most recently saved.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
            'description' => array(
                'description' => 'The product description.',
                'type' => 'text',
                'not null' => FALSE,
            ),
        ),
        'indexes' => array(
            'node_changed' => array('changed'),
            'node_created' => array('created'),
        ),
        'primary key' => array('pid'),
    );

    return $schema;
}

function products_install() {
    drupal_install_schema('products');

    cache_clear_all(NULL, NULL, '*');
}

function products_uninstall() {
    drupal_uninstall_schema('products');

    $result = db_select('file_usage', 'f')
            ->fields('f')
            ->condition('type', 'product')
            ->condition('module', 'products')
            ->execute()
            ->fetchAll();

    foreach ($result as $row) {
        $file = file_load($row->fid);

        if ($file) {
            file_usage_delete($file, 'products', NULL, NULL, 0);
            file_delete($file);
        }
    }
}


texts: I am working on a Drupal site. I have put a "Create an account" block on one of my content pages. After the form is submitted the user is redirected to the home page. I want to reload the same page on submit. Can anyone help me out with this.


texts: Load nodes by property, including empty ones

texts:
I want to render a node with certain properties set. For example, I want to load every node which ONLY has field_a and the other fields are empty.
If I use
$this->nodeStorage->loadByProperties(['type' => 'node_type', 'field_a' => $value]);

-> this will load every node which has field_a, but the other fields are not necessarily empty. I tried setting all the other fields to null, but it throws an InvalidQueryException. How can I change that query to IS NULL or which function can I use?


texts: Selecting Specific Fields in Entityform to Display

texts:
Goal: Create a single entity form whereby the the fields that the user sees and can enter information into depends on the tab that they're on.

Approach: I am trying to create a views for each tab. I want to select the field that show up and then create a contextual filter so that the view appears on the correct tab.

Problem: I am unable to select Entityform fields. If I were to create a view for submissions, that would be easy. All of the fields in the entityform would be available for me to select and create a view for inputted data. But the Entityform Type fields are not available.

I've tried to embed the entityform into a content type an then create a view out of that (with a relationship to the content type). When I select "Rendered Entity" under Format>Show in the view set up form, it displays the entire Entity Form. When I select "fields" it does not give me the option to select specific fields that I created in my Entityform.


texts: If I use node_save() to create a new node, do I need to manually escape user input?

texts:
I am writing a custom module for Drupal 6 that programmatically creates a node using node_save().

The various custom node fields come from user input - is it necessary to manually escape these fields, or will node_save() take care of that for me?


texts: Form filter by field on entity_autocomplete

texts:
I have a form with this field.
the user can save one or more results.
I want to filter by the foreign key who is on the user table but i don't know how to do this.

My code :

$form['referent_business'] = [
  '#title' => 'Référent',
  '#type' => 'entity_autocomplete',
  '#target_type' => 'user',
  '#required' => TRUE,
  '#tags' => TRUE,
  '#validate_reference ' => TRUE,
  '#autocreate' => false
 ]

So I tried another solution :

$form['referent_business'] = [
  '#title' => 'Référent',
  '#type' => 'textfield',
  '#autocomplete_route_name' => 'jds.autocomplete_referent_ce',
  '#autocomplete_route_parameters' => [
    'business' => $entity->id()
  ],
  '#required' => TRUE,
  '#tags' => TRUE,
  '#validate_reference ' => TRUE,
  '#autocreate' => false,
  '#access' => $user->hasRole('administrator') ? TRUE : FALSE,
];

With the function

public function autocompleteReferentCE(Request $request, $business)
{
    $matches = [];
    if($string = $request->query->get('q')) {
        $query = \Drupal::entityQuery('user')
            ->condition('status', 1)
            ->condition('id_business', $business)
            ->condition('last_name', '%'.db_like($string).'%', 'LIKE');
        $idUsers = $query->execute();
        $users = User::loadMultiple($idUsers);
        foreach($users as $user) {
            $matches[] = [
                'value' => $user->get('first_name')->value . ' ' . $user->get('last_name')->value,
                'label' => $user->get('first_name')->value . ' ' . $user->get('last_name')->value
            ];
        }
    }
    return new JsonResponse($matches);
}

The custom entity_autocomplete function works. When the user saves several results, the return isn't an array, but a string.

So, someone knows how to filter with the first solution or return an array of result with the second solution ? Or another solution ?

Thanks in advance


texts: Action when a comment has been replied to

texts:
I have a unique case where we need to do something, namely a behavior where a user Comments on a node, and when a new comment is made in response to him, we need to "alert" the user in a variety of ways. Right now, lets say we need to send him an email.

I'm not sure of the best approach to implement this logic, but it looks like it may be possible to extend the Rules module to do so. What would this logic look like? Are there other approaches that can be used here?


texts: How to not show user signatures in comments?

texts: In D7, user signatures appear in their comments. It can be very annoying for many, especially when the signature is long or contain big pictures. So I'm wondering how to disable this?


texts: the Private files folder outside of "sites/default/files"

texts:
The Private Files directory is outside of the sites/default/files directory.

Is that fine? I haven't got any problem with that, yet.

I'm using Drupal 7, if that makes any difference.


texts: Can't delete content type that I created?

texts:
I am running a Drupal 6 installation and created 2 content types through the admin menu (they are not programically created). Now I want to delete them but no delete link is visible in the content type screen. I do not have any pages created with those types so I don't understand why Drupal won't let me delete them.

I have searched this site and Google but I can't find an answer. Anyone here have any ideas how to get rid of them?

Thanks


texts: How do I send an email from a module using an Easy Email module email template?

texts: I am creating a form that needs to send an email upon form submission. I want to use the Easy Email module to send HTML emails. I want to send an email from my module, using an Easy Email template. How can I send an email from my custom module using an Easy Email template?


texts:
this is one of the most confusing tasks I've been asked to accomplish in Drupal. I have a Content Type called Latest News that has a Date field (not the creation date, a date that represent's the new itself and may be used for the filtering process).

What I need is the following page:

_________________________
|  _____  ____________  |
|  |   |  |          |  |
|  | A |  |    B     |  |
|  |   |  |          |  |
|  |___|  |          |  |
|         |          |  |
|  | C |  |__________|  |
|                       |
|_______________________|

Where A is a list of Latest News nodes' titles, B is the node itself (smells like Panels), and C is a menu that contains dates spanning from 2004 to now (dynamic preferably), that acts as a filter to view A.

Whenever a user clicks on a date on C, the titles in A are filtered (much like an exposed filter), and the node display on B should change to the topmost item of the currently filtered list on A.

The current displaying node's title should be highlighted.

If the user has filtered A to display news from 2011, clicking on one of them should retain the filter, and simply display that node.

How would you go about doing this?
I will be editing this question if more clarification is needed. Thanks in advance.


texts: Rules: how to email "last edited by" user

texts: I am using Rules for a node publishing workflow. When a node is in "needs review" status and an admin either rejects or publishes the draft, I'd like to notify the user who created the draft (i.e. not necessarily the node's author).


texts: Commerce Kickstart Product: URI links to admin

texts:
When I try to use a Commerce Product Reference field in any view with a link to content, it links to the -admin- for the product, not the content.

This was discussed for the images here: https://www.drupal.org/node/1970482

But I'm finding that this will happen if you try to create a link wrapper to -any- Commerce Product field. (SKU, Title, etc.)

So.. can someone point me to the place in the Commerce code where that URI is generated so I can override it?

I thought it was in commerce_product_reference.module but I can't figure it out.


texts: how to do a conditional subquery with db_delete

texts:
I currently am deleting by a manually constructed query, but there should be a better way to do this.

$query = "DELETE FROM {$table1} ";
$query .= "WHERE col1 = '$col1' ";
$query .= "AND table2_id in ";
$query .= "( SELECT id from {$table2} where col2=$col2 )";
db_query($query)->execute();

How do I do this using db_delete?

Table2 has a covering index, so this should be done in one query.


texts: Send newsletter - This newsletter has been sent - but never arrives?

texts:
I am using the simplenews module to create newsletters and the subscription module to enable users to subscribe to those newsletters.

"Send one test newsletter to the test address" works and the test email receives a newsletter. However, the same email address which the user is registered with, and subscribed to the same newsletter, does not receive an email when the "Send newsletter" option is selected instead of "Send one test newsletter to the test address" the email never gets received.

Why would this be?

By the way, the user in question is subscribed to the Newsletter Category.


texts: Error : Only variables should be passed by reference

texts:
I get this error Strict warning:

  Only variables should be passed by reference in include() (line 20 of
  ...)

Can anybody see what is wrong here?

        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-nav">
          <?php print t('Toggle navigation'); ?>

        </button>
        <a class="navbar-brand" rel="home" href="<?php print url('<front>'); ?>" title="<?php print variable_get('site_name', ''); ?>">
          <?php print isset($logo) && $logo ? theme('image', array('path' => $logo)) : '
' . variable_get('site_name', '') . '
'; ?>

          <?php print drupal_render(menu_tree_output(menu_tree_all_data('menu-top-menu'))); ?>


texts: Where can I find all form display options types for custom entity fields?

texts:
I created a custom entity with drupal generate:entity:content.

I am adding fields in the baseFieldDefinitions method of the entity class.

Below is what drupal console generates by default for the name field.

Where I can find a list of all possible type values for ->setDisplayOptions('form'). For example, the field below uses string_textfield.

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    ...
    $fields['name'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Name'))
      ->setDescription(t('The name of the entity.'))
      ->setSettings([
        'max_length' => 50,
        'text_processing' => 0,
      ])
      ->setDefaultValue('')
      ->setDisplayOptions('view', [
        'label' => 'above',
        'type' => 'string',
        'weight' => -4,
      ])
      ->setDisplayOptions('form', [
        'type' => 'string_textfield',
        'weight' => -4,
      ])
      ->setDisplayConfigurable('form', TRUE)
      ->setDisplayConfigurable('view', TRUE);


texts:
How do I create a role programmatically?

What am I doing wrong here?

$role = \Drupal\user\Entity\Role::create(['id' => 'client', 'name' => 'Client']);
$role->save();


texts: AJAx HTTP ERROR, can't add views to Drupal 7 site, same behavior on 2 different sites

texts:
I get these errors when creating views at every step, in Chrome errors says 200 in Firefox says 500...

I can get as far as having the view created, by ignoring the error, but then I can't add any fields, so it renders my Drupal site useless basically.

I have played around with Jquery versions and no solution seems to work.

Additionally, this behavior can be seen on 2 different website, identical...

Sites are both up to date Drupal 7, on status report everything is immaculate, they both run Boostrap theme but the admin Theme is Bartik


texts: Create a Rule that assigns a specific role to a user after they have completed a form

texts:
Ok, I have a customer that is wanting to have an applicant complete a specific webform and then have their user account be assigned to a specific role automatically.

My thought was to go the following route using rules:

Applicant creates their user account
They are then automatically taken to the specific webform
Once the webform is completed, then they are automatically assigned a specific role (this is the part where I'm lost as to the best option or if it's even possible)

Is this something that would even be possible using rules? Or are there other options that may work? Any assistance would be greatly appreciated!

I hope I've explained the situation enough :) Let me know if you need any further info.

Thank You!!

Nicole


texts:
We're having a problem with our log detail page (/admin/reports/event/XXXXXX):

As you can see, the content is blank.  There are no apparent errors in the Apache logs.  View source shows that the entire page HTML is rendering properly, there's just nothing in the content div.  Watchdog messages are showing up in the Recent Log Messages page (/admin/reports/dblog), it's just that when we click on one to get more detail, we get the blank detail page.

The details page was working a couple of weeks ago, and we haven't made any configuration changes since then.  We had to restart Apache and MySQL recently, but I don't see why that would cause this.

Tried disabling and re-enabling the Database Logging module.

Any suggestions?


texts: How do I have menu linked content not on main page?

texts:
My web site is the first drupal site I have made.  And after I made it, I left it to do other work -- like write the blogs for the site.  I cannot remember how I set up the content pages that link to menu selection that do not appear as content on the main page.

The best way to explain what I am talking about is with a screen capture.  I have added menu items to my main menu.  I do not remember how I did it in the past.  I want to add content and have it linked to the main menu (this option is available to me when I create the content) but I do not want them to appear as stories on the main page.

The circled areas in this screen shot shows the menu item I just added and the corresponding item on the main page that I do not want to be there.  How do I remove it from the main page?

I am thinking that perhaps I should not have added it as a "content" but something else? If so, what and how?

http://www.arguemax.com/images/problems/12-6-2015/Capture_001.PNG


texts: The previous published revision should be available for the visitors while the current revision is in needs review state

texts:
I am using Workbench Moderation module for moderation on nodes. I notice that it creates revision of the nodes.

I have a node which is in live/publish state therefore it is available for the site visitors. Then when an editor edit that node, I programmatically put that node in needs review state and create a new revision for that node.

After that the site visitors are not able to access that node until its state change to publish.

I want that the new revision should be needs review state and the previous publish revision of the node should be available to site visitors.

The code which I am using for setting the state of the node is as following.

$node->status = 0;
$node->revision = 1;
node_save($node);
workbench_moderation_moderate($node, 'needs_review');


texts: Adding a cache tag to an entity view display doesn't do anything?

texts:
I wrote a module that implements hook_entity_view_display_alter(). I modify the display settings of one of the fields depending on some configuration setting of my module.

/**
 * Implements hook_entity_view_display_alter().
 */
function ps_events_entity_view_display_alter(EntityViewDisplayInterface $display, array $context) {
  // Change the date formats of the date field on the full page display based
  // on configured settings.
  if ($context['entity_type'] === 'node' && $context['bundle'] === 'ps_events' && $context['view_mode'] === 'ps_full_content_no_lb') {
    $eventsSettings = \Drupal::config('ps_events.settings');
    $dateComponent = $display->getComponent('field_ps_events_date');
    if ($dateComponent) {
      $dateComponent['settings']['date_format'] = $eventsSettings->get('detail_page_date_format_day_and_time');
      $display->setComponent('field_ps_events_date', $dateComponent);
      $display->addCacheTags(['config:ps_events.settings']);
    }
  }
}

However, the cache tag I add doesn't seem to have any effect. When I inspect the cache_render table and look at the entry for this entity view display, my cache tag is not present. Changing the settings of my module does not clear the cache for this entity view display.

As a workaround, I also implement hook_entity_view_alter(), which operates on the complete render array of the entity view display. I add the cache tag here and it works.

This seems like either a bug in core, or maybe I misunderstand the purpose of cache tags on the EntityViewDisplay object?


texts:
I need your help. I am running a site (D7.43, jQuery 1.10) with the Jollyany theme under the hood. The theme comes packaged with the revolution Slider from ThemePunch. I am trying to include a slider into a page, but am then confronted with the slider being empty and the loading spinner spinning away merrily forever. Navigation bullets and left right arrows are visible but do nothing.

You can see the page here: wixschool.net/test-class.

This page shows the revolution slider in place. The slider shows the last of three images, constant spinner, no transition to next slide. Navigation also doesn't go anywhere, slider completely stuck. Slider scripts are called in the head, html for the slider is put in place and seems OK.

(In fact the sldier does not even show any picture, but I've removed the 'visiblity hidden" from the CSS of the background image so its easier to see the slider.. and it then shows the last of three images, not the first..)

There were suggestions out there that it may be (double call to) script issue, so I have tried switching off all other scripts that are called in the head  and below the body to see if that would make a difference, but besides losing functionaltiy that those scripst supply the slider stays stuck..

Any suggestions as to why the slider doesn't work is extremely welcome!

Edit: I just noticed that on the test-class page the TB MegaMenu dropdown in the menu don't work (any other page they do..). Tried removing the entire menu as well as the TB Menu scripts but still no working slider..


texts: Only load Views Slideshow JavaScript when needed

texts: Does anyone know how to only load the Views Slideshow JavaScript on certain content-types, pages, or the front page?


texts: How can I extract and print specific field values from $page['content'] in page.tpl.php (vocabulary page)

texts:
I am trying to print some specific fields on a vocabulary term page in order to lay the page the way I want. <?php print render($page['content']); ?> prints the entire content but I want to extract specific values like title, field_photo etc. so that I can put them where and the way I want!

Here is an example how I want this to work:

I am creating a movie database website where each movie has casting associated with it. Each casting (actor or actress) is a vocabulary term. When I click on a term it takes me to a page (example URL: http://localhost/moviedb/tags/kate-winslet) where movies associated with that actor/actress are listed. The list is coming fine but I want to customize the look-n-feel of this page.

I overrode page.tpl with page--vocabulary--tags.tpl.php. Also I created a template.php file and written this function inside:

function introduction_preprocess_page(&$vars) {
     $vars['temp_var'] = $vars['page']['content'];
}

which is equivalent of using $page['content'] directly inside .tpl file. I also used

<?php print var_export(get_defined_vars(),TRUE) ?>
 to get a the nested structure of nodes array. Based on that I tried to access a specific field like <?php print render $temp_var['title'] ?>, nothing is showing up.

I am definitely doing something wrong, but don't know where to check and what to change! I have started learning Drupal just a few weeks back.

UPDATE

I also tried the following code but no luck yet.

function introduction_preprocess_page(&$variables) {
   if (arg(0) == 'node') {
      $variables['node_content'] =& $variables['page']['content']['system_main']['nodes'][arg(1)];
   }
}

INTRODUCTION is the name of my theme.

In .tpl file I tried to access title the following way:

if (isset($node_content) && $node_content['title']) {
    print render($node_content['title']);
}

I have referred the following URLs:

https://www.drupal.org/node/2288941 and https://www.drupal.org/node/223430

Please help me understand what wrong I have done.

EDIT (27.05.2016)

I tried the solution but it did not work. By doing some trial and error I noticed that my node--film.tpl.php template is actually being used even on taxonomy page. In my application film is a content type I created and there is a field called "cast" which is eventually a vocabulary called "tags". I am putting names of actors by using this vocabulary when adding a "film" type content.

My intention was to show a list of films where an actor is associated when a tag (actor) is clicked. The functionality works OK but I don't understand why this page is also using node--film.tpl.php template file and not taxonomy-term.tpl.php. I copied taxonomy-term.tpl.php to my theme folder, took out the line which is rendering the content, cleared cached but nothing happened. But when I take out the same code snippet from my node--film.tpl.php file, the content disappears! Which confirms that node--film.tpl.php is the template being used!

I then renamed the file as taxonomy-term--vocabulary-tags.tpl.php just as a random test, but nothing changed either!

I am still unable to customize the look-n-feel and field display in my vocabulary page.


texts: setting content to display on a basic page

texts:
I'm creating a classified section on my site, and I have a basic page created for the content. How do i set content to go to that specific page?

Thanks for the help


texts: Basic page URL broken because it only consists of server address and page name, docroot path omitted

texts:
I have a local development server setup whereby my drupal sites are in separate folders on the server, for example:

/var/www/site1/
/var/www/site2/
etc.

While most URL links work fine, ( e.g. http://mylocalserver/site1/content/an-article ), the basic page content type does not.

For example, if I create a basic page with (sub)URL, e.g. terms , note - with NO preceding slash,  /  then this is shown in menu links as http://mylocalserver/terms (which is broken) and not http://mylocalserver/site1/terms as I would expect.)

I have cleared the cache ( drush cc all ) but this doesn't solve the issue.


texts:
For my website when using Firefox or Chrome you get the following message:
Sorry, 10.0.11.38 has been banned.
For Internet Explorer you 403 forbidden error.

Note: 10.0.11.38 is the internal IP of the load balancer which has the domains certificate and associated public IP address.
I went to admin/user/rules and noticed that this ip of 10.0.11.38 has been listed as a host to deny access so I deleted this rule and the drupal website displays again.
We did not enter this ip as a rule originally so I suspect that drupal somehow decided to add this ip as a denied host.

How would I prevent this from happening again?


texts: User::create not saving data in database

texts:
I'm currently getting data from a userdata endpoint but the postal address comes back in a json, so i decided to json_decode it to split the data and then put into a database when a new user registers/logs in.

code:

function openid_connect_create_user($sub, $userinfo, $client_name) {
  /** @var \Drupal\user\Entity\User $account */
  $address = $userinfo['address'];
  $decodeAddress = json_decode($address);

  $streetAddress2 = $decodeAddress->{"street_address"};
  $townCity2 = $decodeAddress->{"locality"};
  $region2 = $decodeAddress->{"region"};
  $postalCode2 = $decodeAddress->{"postal_code"};
  $country2 = $decodeAddress->{"country"};

  $streetAddress = (string)$streetAddress2;
  $townCity = (string)$townCity2;
  $region = (string)$region2;
  $postalCode = (string)$postalCode2;
  $country = (string)$country2;

  \Drupal::logger('openid_connect')->notice($streetAddress);
  \Drupal::logger('openid_connect')->notice($townCity);
  \Drupal::logger('openid_connect')->notice($region);
  \Drupal::logger('openid_connect')->notice($postalCode);
  \Drupal::logger('openid_connect')->notice($country);

  $account = User::create([
    'name' => $userinfo['email'],
    'pass' => user_password(),
    'mail' => $userinfo['email'],
    'init' => $userinfo['email'],
    'family_name' => $userinfo['family_name'],
    'given_name' => $userinfo['given_name'],
    'nickname' => $userinfo['nickname'],
    'gender' => $userinfo['gender'],
    'birthdate' => $userinfo['birthdate'],
    'phone_number' => $userinfo['phone_number'],
    'street_address' => $streetAddress,
    'town_city' => $townCity,
    'region' => $region,
    'postal_code' => $postalCode,
    'country' => $country,
    'status' => 1,
    'openid_connect_client' => $client_name,
    'openid_connect_sub' => $sub,
  ]);

  $account->save();
  return $account;
}

The logging shows the data being split correctly but user::create doesn't save the data correctly, any ideas?

The data that isn't getting saved is:

street_address
town_city
region
postal_code
country


texts:
User type - manager
For example he is Manager and has 4 bands he is manager of.

Manager can create several profiles types (like myspace profiles).
Manager creates bio, gallerys, videos etc...
So lets say he has 4 bands with all basic data on each profile.
Biography for band A (bio, galleries, videos)
Biography for band B (bio, galleries, videos)
Biography for band C (bio, galleries, videos)
Biography for band D (bio, galleries, videos)

Manager wants to upload picture gallery from last concert from BAND B.
How can he tell drupal that images he is uploading right now should go "Gallery" of band B ?


texts: how to remove duplicate from views' result page

texts:
I went through all solutions found on the web.

Both Distinct or Aggregation do not work at all in my case.
Is there a way to remove the duplicates using hook_query_alter() ?

My sql query run in the view is the following:

SELECT node.changed AS node_changed, node.nid AS nid, SUM(search_index.score * search_total.count) AS score
FROM
{node} node
LEFT JOIN {search_index} search_index ON node.nid = search_index.sid
LEFT JOIN {search_total} search_total ON search_index.word = search_total.word
INNER JOIN {search_dataset} search_dataset ON search_index.sid = search_dataset.sid AND (search_index.type = search_dataset.type)
WHERE ((( (search_index.type = 'node') AND (search_dataset.data LIKE '% saadan %' ESCAPE '\\') AND (search_dataset.data LIKE '% goer %' ESCAPE '\\') AND (search_dataset.data LIKE '% du %' ESCAPE '\\') ))AND(( (node.status = '1') AND (node.type NOT IN  ('nodetype')) )))
GROUP BY search_index.sid, score, node_changed, nid
HAVING (( (COUNT(*) >= '2') ))
ORDER BY node_changed DESC
LIMIT 10 OFFSET 0

Last note:

I am also aware of the solution the removes content by hooking into hook_views_pre_render() but I do not really consider this a solution since it cracs up your results.

The query works perfectly if I replace 'GROUP BY search_index.sid, score, node_changed, nid' with GROUP BY nid.
How do I achieve this?


texts: Print view header using the "Twig Tweak" module

texts: I would like to print out the header for a view, but not the rest of the content using the Twig Tweak module. I've tried variations on {{ drupal_view('VIEW_NAME', 'PAGE_NAME', 'view_header') }}, but that prints out the entire view.


texts: Add fields to form dynamically with ajax and retrieve values

texts:
I am trying to add a combination of text field and a select box to a form dynamically using Drupal 7 Ajax, when i click on a button.

But i have 2 issues here:

I am not able to add more than 1 set of fields in the form with Ajax
After i submit the form, i am not able to retrieve the values of the form. They are empty. I have the fields as "name_1", "select_1", "name_2", "select_2", etc.

I want to know if there is any way to solve it, with / without using a fieldset.

My custom module code:

function my_form_form($form, &$form_state, $no_js_use = FALSE) {
  $form['#tree'] = TRUE;
  $form['add_more'] = array(
    '#type' => 'button',
    '#value' => t('Add More'),
    '#href' => '',
    '#ajax' => array(
    'callback' => 'ajax_simplest_callback',
    'wrapper' => 'names-fieldset-wrapper',
  );
  $form['names']['name_1'] = array(
    '#type' => 'textfield',
    '#title' => t('Name 1'),
    '#attributes'=>array('id'=>'name_1', 'name'=>'name_1'),
  );
  $form['names']['select_1'] = array(
    '#type' => 'select',
    '#title' => t('Select 1'),
    '#attributes'=>array('id'=>'select_1', 'name'=>'select_1'),
    '#options'=>array('1'=>'One', '2'=>'Two', '3'=>'Three'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  $form['#submit'][] = 'my_form_add_more_submit';
  return $form;
}
function ajax_simplest_callback($form, &$form_state) {
  if (empty($form_state['num_names'])) {
    $form_state['num_names'] = 1;
  }
  else {
    $form_state['num_names']++;
    $form_state['rebuild'] = TRUE;
  }

  for ($i = 1; $i < $form_state['num_names']; $i++) {
    $form['names']['name_'.$i+1] = array(
      '#type' => 'textfield',
      '#title' => t('Name '.$i+1),
      '#attributes'=>array('id'=>'name_'.$i+1, 'name'=>'name_'.$i+1),
    );
    $form['names']['select_'.$i+1] = array(
      '#type' => 'select',
      '#title' => t('Select '.$i+1),
      '#attributes'=>array('id'=>'select_'.$i+1, 'name'=>'select_'.$i+1),
      '#options'=>array('1'=>'One', '2'=>'Two', '3'=>'Three'),
    );
  }
  return $form['names'];
}

function my_form_add_more_submit($form, &$form_state) {
  print_r($form_state['values']);
  exit();
}


texts: How to print a block inside the node body?

texts:
I need to insert a block(webform) inside basic page nodes (wysiwyg body).
How can do it?


texts:
I am theming a page in D7 and need to change the markup that gets rendered out when I print<?php print render($page['content']); ?>. Currently it prints
...some content
, where I want it to print
some content...

I only want to do this on this page and not globally to others. Is there another call or variable I can add to manipulate the markup?


texts:
I am trying to pass URL parameters and access them in a preprocess function. I have done a fair amount of research but did not find an answer. It works if I do the following /example?id=1, but that's quite ugly and non-SEO friendly. Clean URLs is much better.

Is it possible to pass parameters in a taxonomy term's aliased URL using clean URLs?


texts:
I'm trying to install Drupal 7.34 on a VPS (on NodeServ): I followed the guidelines in the file INSTALL.txt, and I managed to reach correctly the last page of the installation script, where I fill the database parameters and other stuff.

The point is, after submitting the data, the script does not conclude successfully, but I obtain a completely blank page. Any attempt to install on this machine lead me to the same conclusion...

I understand that it's not much informative, anyway... Any idea would be much appreciated.

Thanks a lot in advance,

Marco


texts: How to turn fieldset to normal field for date field

texts:
I have a date field that is rendered in a fieldset unfortunatelly. I would like to render it as normal field. I found this for drupal 7  how to avoid fieldset in drupal date field

How can this be done in drupal 8?


texts: How to print flag in page-taxonomy.tpl or in block?

texts:
I am using the Flag Term module and I am trying to put a flag link in my page-taxonomy.tpl file, because I want the flag positioned in a certain region / block. Having read the documentation it suggest using the flag_create_link function. I added the following code to my page-taxonomy.tpl file:

print flag_create_link('like', $term->tid);

but it gave:

An HTTP 404 error occurred
http://localhost/drupal/?q=flag/unflag&destination=taxonomy/term/74&toke...

The same thing happens when I try and print the flag in a block. Any ideas?


texts: How to use Entityfieldquery with two field conditions for the same field

texts:
I need to make a query where the same filed must have one value OR another. Basically:

->fieldCondition($field_example, 'tid', (array) $var1) ... OR
->fieldCondition($field_example, 'tid', (array) $var2)

Already saw some examples using TAG but I really don't understand how it's done.
In alternative, can I use dbquery? Or should I avoid it?

Thanks!


texts: How to add file extensions while creating a field (type file) through the module installer.yaml?

texts:
I need to add 4 fields to an existing content type in Drupal 8 website, 2 of them is text another 2 is file type, I have a multisite setup and have 30 country-specific sites so I need to add for every locale site, Now I have created a module and created installer file, right now I am able to create the fields but I am unable to add the file extension to the file type field. can anyone please help with this?

I have followed this below documentation to create the filed.

https://www.drupal.org/docs/8/api/entity-api/programming-custom-fields-into-your-content-type


texts:
I've done some research on this question, posted it here without any feedback, and have left messages for OG owner (amitaibu) without any response, so hopefully I can solicit useful feedback here.

I'm building a story telling platform that combines passions for genealogy,
family photography, and social media, and brings them to a whole new and
integrated level of telling stories about your ancestors, and celebrating the
life of an individual who has just passed away. I'm building this on Drupal
with Organic Groups as the main organizing construct. Every Album - whether
it's a family tree, a single individual, or even a photo album - is
instantiated as an OG. I'm writing about it and will launch it at
www.greatalbum.net.

Right now, I'm building the prototype on D7+OG because it's stable and it's essential that any piece of content (family/individual/event/place/story/media/etc.) be allowed to exist in more than Album. The goal
is to launch the prototype in April, and then launch the production v1
site in June or July. I'd love the public launch to be on D8+OG, but I'm not
sure how realistic that is, since OG v8.x is currently 1.0-alpha2.

So, my questions are:

Am I correct to understand that Group module does not allow content to exist in more than one group at a time, and hence based on my requirement OG is the better choice?
Should I assume that OG 8.x-1.0-alpha2 is not stable enough to use for a production site, and that I should stick with OG 7.x-2.10 on Drupal7 for now, and wait on the benefits of Drupal8 until OG matures at least to RC1?

Any guidance?


texts: D8: How to get destination without compromising TrustedRedirectResponse?

texts:
I have following code in my controller for route:

\Drupal::destination()->get();
return new TrustedRedirectResponse('http://www.google.com');

Which results in error:

  LogicException: The controller result claims to be providing relevant
  cache metadata, but leaked metadata was detected. Please ensure you
  are not rendering content too early. Returned object class:
  Drupal\Core\Routing\TrustedRedirectResponse. in
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
  (line 154 of
  core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).

How can I get destination without compromising TrustedRedirectResponse?

Or how should I use TrustedRedirectResponse not resulting in error?

(What is "controller provided cache metadata" and what is "leaked metadata"?)


texts:
Depending on a condition I want a node's changed content not to be overwritten on the old content. That is old content should be retained and new one discarded so that node does not change.

Which action should I add?
I've tried many but everytime a user saves a node, it is permanently changing the node's content.


texts: Is there a list of file/image field subtokens?

texts:
Token browser does not show the options for file properties. [node:file-field:0:file:url] gets the url, but is there a list of all file options? Or is there a way to check it from sourcecode somehow?

Gathering the list:

[node:field-image:0:file:url]
[node:field-image:0:file:extension]
[node:field-image:0:file:name]
[node:field-image:0:file:size]
[node:field-image:0:file:mime]
The last thing that is still unknown to me is if there is an option to pull image width and height? If I remember correctly that data is in the db.


texts:
Is it possible to build tableselect form with textfield in each row?

function nowayform_form($form, $form_state) {

      $xsroads = array(
      array('id'=>'PrArcabilPodvoyskaya','xsr_name'=>t('Archabil/Podvoyskiy')),
      array('id'=>'PrArcabilSovetskaya','xsr_name'=>t('Archabil/Sovietskaya')),
      array('id'=>'PrArcabilLenina','xsr_name'=>t('Archabil/Lenina'))
      );

      $header = array(
      'xsr_name'=>t('Crossroad names')
      );

      $options = array();
      foreach ($xsroads as $xsroad){
        $options[$xsroad['id']] = array(
        'xsr_name'=>$xsroad['xsr_name']
        );
      }

      $form['table'] = array(
      '#type'=>'tableselect',
      '#header'=>$header,
      '#options'=>$options
      );

Thanks


texts: Custom 'required' field message ignored for file uploads

texts:
File upload fields in the D8 Webform module don't show my custom 'required' message when they fail validation.

Here's the YAML source of a simple Webform:

cv:
  '#type': managed_file
  '#title': CV
  '#required': true
  '#required_error': 'Please upload a copy of your CV.'
  '#file_extensions': 'doc docx pdf odt rtf'
test_document:
  '#type': document_file
  '#title': 'Test document'
  '#required': true
  '#required_error': 'Custom missing document file message.'
  '#format_items': comma

Instead of Please upload a copy of your CV etc., I get the default:

  CV field is required.
  Test document field is required.

I've run drush webform:repair
I've tested this on an otherwise empty form.
I've also cleared Drupal's cache.

Site setup:

Drupal 8.5.4.
No custom code yet.
(edit: we've since established it's nothing to do with contrib modules)


texts: Adding array of objects to javascript from PHP

texts:
This is a part of my script in template file where php code is used to generate js field of objects:

<?php $count = count($events); $counter = 1; ?>

<script>
  var events = [

  <?php foreach($events as $event) { ?>

    {
      date: '<?php echo $event['date']; ?>',
      linkTarget: "_blank",
      content: "<?php echo $event['content']; ?>",
      class: "<?php echo $event['class']; ?>"
    }
    <?php if($counter!=$count) { echo ','; $counter++; } ?>
  <?php } ?>

  ];
<script>

I know that we can add js variable by drupal_add_js(array('myModule' => array('key' => 'value')), 'setting'); but how can we create the same js array as in example above in order not to use php code in js?


texts: Problem with drupal 7 multisite installation

texts:
OS: UBUNTU 11.10

What I want to achieve:

www.example.local     Main Installation

www.example1.local    Installation inside sites folder

I took the following steps:

Installed drupal 7 as normal installation in the folder /var/www/example.

in /etc/hosts added the following:

127.0.0.1   www.example.local

127.0.0.1   www.example1.local

Then in /etc/apache2/sites-available ::

ServerName www.example.local

DocumentRoot /var/www/example

in example file.

and

ServerName www.example1.local

DocumentRoot /var/www/example/sites/www.example1.local

in www.example1.local file.

I created folder

  /var/www/example/sites/www.example1.local

and copied default.settings.php and made a settings.php from it.

Now , when I go to www.example.local I get the normal(main) installation it works fine.

But when I go to www.example1.local I see the list of files in the www.example1.local folder

What is the step I am missing?
Or did I do something wrong ? Thank you in advance.

PS: I have not made any change in settings.php of the subsite.


texts:
The idea of annotations in Drupal 8 is that annotations names map to classes.
E.g. @ViewsRow -> \Drupal\Views\Annotation\ViewsRow.

From other code I have seen (Symfony, Doctrine), I assumed that to make this work, the annotation class needs to be imported, e.g.

use Drupal\Views\Annotation\ViewsRow;

However, this seems not to be the case for many of the plugin annotations e.g. in Views.

Why? Is this a Drupalism, or would we find the same in some places in Doctrine or Symfony? Is it good practice to omit the import?

In the past I disliked the need for such use statements, because they would show up in the IDE as "unused import". However, now I am using the annotation plugin in PhpStorm, so now it recognizes those imports.


texts: Paging the list of comments, and getting the comment count

texts:
I am getting all the comments listed in the same page. How can I do the paging concept for comments?
How do I get the comment count?


texts:
I am working on a project where I first was only designing the theme. However, I now need to create 5 already made custom pages or blocks in a page, which will be available as soon as theme is enabled.

Each page should hold its own code for grabbing information from external database. Now I am having a huge dilemma on deciding how to create those pages. Since there are DB calls made on each of them, I was suggested to create a custom module, which would display a block with the printed content from database. I tried creating "pvpstats.module" and "pvpstats.info" as normal for custom modules, and displaying it in sidebar_first. After I enable the module, nothing happens. The block is just not visible. I used the code below.

function pvpstats_block_info() {
  $blocks['pvpblock'] = array(
    'info' => t('Example Block'),
    'status' => TRUE,
    'region' => 'sidebar_first',
    'weight' => 0,
    'visibility' => 0,
    'pages' => 'admin*
coder*
node/add*
node/*/edit
node/*/devel
',
  );

  return $blocks;
}

/**
  * Implements hook_block_view().
  */
function pvpstats_block_view($delta = '') {
  $block = array();

  switch ($delta) {
    case 'pvpblock':
      $block['subject'] = t('Block Name');
      $block['content'] = theblock_contents();
      break;
  }

  return $block;
}

function theblock_contents() {
  return '
    $dbserver="serveradress";
    $dblogin="username";
    $dbpass="dbpassword";
    $dbname="databaseserver";

                mysql_connect($dbserver, $dblogin, $dbpass);
                mysql_select_db($dbname);
                mysql_query("SET NAMES 'utf8'");

                $vypis =  mysql_query("SELECT * FROM characters WHERE (accesslevel < '1') AND (pvpkills > '0') order by pvpkills desc LIMIT 20");
                echo '

Nick		Kills
';
         while($row = mysql_fetch_array($vypis))
                    {
                echo '
';
                echo $row["char_name"];
                echo '	&nbsp;&nbsp;	';
                echo $row["pvpkills"];
                echo '
';

                    }
    echo '
';
    ?>

The main point is that I need those blocks later included in my theme so that they are visible immediately after enabling the theme, if that is somehow possible.


texts: How anonymous users are able to complete survey, even when webform is set only for registered users

texts:
I have used Webform module for gathering user data before accessing the content.
Only authenticated users can access the webform, but in the webform submission reports there are some user names with name as anonymous who submitted the webform.


texts: Why anonymous users can only see 1 link in navigation menu?

texts:
I'm trying to show navigation links to anonymous users/ visitors of my site. However, they can only see 1 of the many links while the administrator can see all links just fine.

I'm using Drupal 7 and Zen theme.

My settings : http://i.imgur.com/MVRwejG.png

This is what anonymous users/ visitors see: http://i.imgur.com/3uNNR9Y.png


texts: How can hook some code before deleting a comment?

texts:
How can I add few lines of code before comments get deleted. there must be some hook or something by which we can do this. I am getting nothing relevant by Googling.

Any help appreciated.


texts:
I am trying to use AdvAgg in my Drupal 7 site. I am using a local server for running tests.

The issue is that the module doesn't compress (php-jsmin) all the JavaScript files, which is causing a bad score in page speed insights.

After some debugging, I found out the problem: The uncompressed file didn't have a compress ratio between 0.1 and 0.9 so it was being aggregated as it was.

I'm talking exactly about advagg_js_compress.module file, lines below 143:

// Set to "-2" if compression ratio sucks (it's already compressed)

Why is necessary a min ratio? Could set min ratio to 0 so that all JavaScript files are processed?