texts:
I'm working on a module in Drupal 7.  I have three different forms set up with hook_form.  I would like to display the three forms on one page along with some html to organize the forms and apply some css to change the look a little bit.  What I have right now is:
  function floormap_setup_page() {
    $info[0] = '
';

    $info[0] .= '
';
    $info[0] .= '
';
    $floormap_options = get_floormap_options();
    $floormap_list = '';
    foreach ($floormap_options['name'] as $key => $value){
        $span_delete = ' ' . t('Remove Floor Map') . ' ';
        $span_default = ' ' . t('Make Default') . ' ';

        $floormap_list .= '
' . $value . $span_default . $span_delete . '
';
        }
    $info[0] .= $floormap_list;
    $info[0] .= '
';
    $info[0] .= '
';

    $info[0] .= '
';
    $info[1] = drupal_get_form('setup_cameras_form');
    $info[2] = '
';

    $info[2] .= '
';
    $info[3] = drupal_get_form('set_expectations_form');
    $info[4] = '
';

    $info[4] .= '
';
    $info[4] .= '
';

    $info[4] .= '
';
  return $info;
}

Doing this displays the page how I want it, the only problem is that I get a bunch of errors along with it..
The errors look like this:

Warning: Illegal string offset '#children' in drupal_render() (line
5887 of /var/www/app.local.nucloudglobal.com/includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line
5897 of /var/www/app.local.nucloudglobal.com/includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line
5935 of /var/www/app.local.nucloudglobal.com/includes/common.inc).
Warning: Illegal string offset '#printed' in drupal_render() (line
5942 of /var/www/app.local.nucloudglobal.com/includes/common.inc).

The entire set of errors repeats for each item in the $info array.


texts:
I want to hide the price for specific products in a product display. I have added a checkbox to the product display type and when it is checked I want to hide the price.

I have figured out that I can hide the field with hide($build['product:commerce_price']) in hook_node_view_alter but the problem is I don't know how to get the value of the checkbox. var_dump($build["field_hide_price"]) outputs null;


texts:
I am looking for a mechanism to Log into Drupal system without a Password and only with some link provided.

My Use case is: Intranet system (made with ASP) passes the Link like: http://example.com/user_name=jhilke&user_email=jhilke@example.com&user_role=developer&TY89823jjkhds234.
To break down the above link separated by &

URL:      http://example.com
USERNAME: user_name=jhilke
EMAIL:    user_email=jhilke@example.com
USER ROLE:    user_role=developer
HASH:     TY89823jjkhds234

Now I need to Log in the User or Create new User (if the user doesn't exists) in Drupal site with exact Username and Role but with just the link and no password.

I have used this URL Login module so far to login to Drupal site without password and with some hash/encrypted key it generates. For eg: The link that URL Login module creates is like http://example.com/l/YUb&8767GUYuiu and logs in the user exactly as the role they are assigned, but it doesn't satisfy the other criteria like username and roles in the link.

Is there any way I can achieve this.


texts: Saving a date field with an 'all day' date value programmatically

texts:
I am trying to set the value of a date field to be 'all day' - but the format is being saved incorrectly.

The code where the value is being set:

 $kw = drupal_json_decode('[{"uid":3,"nid":55,"ts":[1395493200,1395838800,1396011600]}]');

    foreach ($kw as $id => $account) {
      $uid = $account['uid'];
      $user = user_load($uid);
      $nid = $account['nid'];
      $node = node_load($nid);

      // Create the Field Collection to attach to the event node.
      // KW is a contractor
      $fc_node = entity_create('field_collection_item', array('field_name' => 'field_add_kw'));
      $fc_node->setHostEntity('node', $node);
      $fc_node->field_kw_reference[LANGUAGE_NONE][]['uid'] = $uid;
      foreach ($account['ts'] as $key => $value) {
        $fc_node->field_kw_my_dates[LANGUAGE_NONE][]['value'] = format_date($value, 'custom', 'Y-m-d 00:00:00');
      }
      $fc_node->save();
    }

I am trying to force the H:i:s part to be 00:00:00. When I dpm() the outcome after saving $fc_node->save(); I see the following:

  $fc->field_kw_my_dates['und'][0]['value'] gives : value (String, 19
  characters ) 2014-03-26 00:00:00

This is correct. However, when I view the value of the date field on the node, it is being shown as:

  Date: 26/03/2013 Time: 11.00

And not as an 'all day' entry.

How do I programmatically save a field with an all day date? Also is it possible to force the H:i:s part of the timestamp to be 00:00:00?

edit:

It appear if I use

format_date($value, 'custom', 'Y-m-d 13:00:00');

The 'all day' checkbox is selected.  But this seems a bit hacky, what is the best way to achieve this instead of 'Y-m-d 13:00:00'?


texts:
Can we write javascript code in twig template?

Its needed to write javascript code in twig template.

When we are writting the same code in custom.js file that particular code is not working in it.

How to write javascript code directly into the twig template?


texts: /index.php/ appearing in generated clean URIs

texts:
I have a Drupal 8 site with clean URLs. Recently, URLs are similar to example.com/index.php/page-url-alias. The page still loads correctly, but I don't want the index.php part to be indexed.

If I empty the cache, the URLs are shown correctly.

How can I force Drupal not to add index.php in the URLs it generates?


texts: #default_value not being displayed in form

texts:
Here's a function that returns a form:

function myfunc($str)
{
    $form = array();
    $form['header text'] = array(
        '#markup' => '
blah blah blah
',
    );
    $form['new_str_value'] = array(
         '#type' => 'textfield',
         '#title' => 'New String Value',
         '#size' => 60,
         '#maxlength' => 128,
         '#required' => TRUE,
         '#default_value' => $str,
    );

    return $form;
}

The textfield displays correctly with the right size and label, but it is not populated with an initial value. Any ideas? Should I be rendering or building the form in the function before returning it, or setting the value in $form_state ... or something?

Any help much appreciated!


texts: How can I rewrite a date field "End Date" to be "present" if no value is entered?

texts:
I have a date field for an item in which I am entering a range of years. I have created a view which displays the start date and end date as individual fields. Typical output looks like this:

  Title: Pop Art
  Start Date: 1958
  End Date: 1970

However, there are several items which do not have an end date because they are ongoing. Even though for the end date field's "No Results Behavior" I have "No results text" set to the word present it renders the start date in place of my rewrite text:

  Title: Contemporary Art
  Start Date: 1970
  End Date: 1970

I want it to do output like this:

  Title: Contemporary Art
  Start Date: 1970
  End Date: present

How can I get the end date to render as the word "present" when no end date is specified?

Note: in my final view I will output the date range as, "1970-present." Above, I formatted my examples as "label: value" for clarity.


texts: How to get video length of a youtube video in drupal7

texts:
I created a node in drupal7 which contains a youtube link. I installed youtube module in my site. with the help of this module i just created a field for inputting url to youtube video.
every thing worked fine. It is showing me the thumbnail,video etc.
But the problem is how to get the length of the youtube video ?

I am using views to generate a json web service the output is

{
            "title":"social networking",
            "field_eventcat":"Performing Arts",
            "field_eventdaytime":"06\/06\/2012 - 05:00",
            "field_eventvideos":"http:\/\/sample sites\/sites\/default\/files\/styles\/thumbnail\/public\/youtube\/6a_KF7TYKVc.png",
            "nid":"34"
         }

I want to get the video lenght with this object. pls help


texts:
I have a code that generate a big bunch of javascript code and I would like to create a .js file on the fly and include the code in it.

The code would be reconstructed at each cache destruction. The file would be used by all visitors.

Any ideas what I could use to make this possible? Or there's no "drupal way" to do this?

thank's!


texts: I have changed a bunch of permission for certain roles. How do I export them?  There doesn't seem to be any yaml file created when I do drush config-export.


texts: How do I include a custom module translation?

texts:
I have a Drupal 8 custom module (custom_module) and a custom_module-8.x-1.0.da.po file I added to sites/default/files/translations, but my translations are not getting Imported during the module installation, even though translations are available for import in admin/reports/translations. Am I missing any step?

I don't want to put my custom_module-8.x-1.0.da.po file in sites/default/files/translations; I prefer it to be inside the module directory, if possible.


texts: How to get Views caching working with contextual filters?

texts: Using Drupal 7.19 and Views 3.5 cache is not respecting contextual filter argument- it is displaying the same cache result no matter what argument given. How to get this working properly?


texts:
I need the ID of the node the inserted comment is attached to. This is what I have tried:

function my-module_comment_insert(Drupal\Core\Entity\EntityInterface $entity)
{

   // According to https://drupal.stackexchange.com/questions/145823/how-do-i-get-the-current-node-id
    $node = \Drupal::routeMatch()->getParameter('node');
    if ($node instanceof \Drupal\node\NodeInterface) {
        $nid = $node->id();
    }
    drupal_set_message("The vaue is " . print_r($nid), 'warning');
}

But... The value I get is "1", while it should be (according to node URL) "55". Or am I using drupal_set_message for debugging the wrong way?

I also tried $entity->get('entity_id')->target_id (according to:  How to get the node id the comment is attached to in hook_comment_insert?) or \Drupal::routeMatch()->getRawParameter('node'), but I always get "1" and I'm positive that the website cache has been cleared.


texts: Trouble saving canvas as image to the public file directory

texts:
I've created a canvas via jQuery and need to save it back to the public file directory as an image, so I can access it like any other image.

I can create the file and save it, into the same file location as my save.php script, but unable to save it to the public file directory...

var canvas = document.getElementById('myCanvas');
var dataURL = canvas.toDataURL("image/png");

$.ajax({
  type: "POST",
  url:  Drupal.settings.basePath + "mypath/save.php",
  data: {
     imgBase64: dataURL
  }
})

Then the following php as called in save.php:

$img = $_POST['imgBase64'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$fileData = base64_decode($img);
$fileName = 'public://' . uniqid() . 'myCanvas.png';
file_put_contents($fileName, $fileData);

excluding 'public://' . will happily save to the location specified in Drupal.settings.basePath + "mypath/...", but I'm unable to tell it to save to the public directory or even any directory structure...


texts: On quantity change, create individual line items of the same item in Drupal Commerce cart

texts:
Here is a more detailed explanation:

In Drupal Commerce cart, when a customer sets the quantity of a product from 1 to 5 for example, on 'Update Cart', we'll need 5 individual line items of the same product with quantity 1 each.

I've gotten this far on solving the problem but I'm not sure how to continue:

<?php
/**
 * Implements hook_entity_update
 */
function mymodule_entity_update($entity, $type){
  if ($type == 'commerce_line_item'){
    $original = intval($entity->original->quantity);
    $updated = intval($entity->quantity);

    if ($original != $updated){
        $new_product = $entity;
        // Create as many individual line items of the same product as needed, save them and add them to the order
    }
  }
}

I've tried to use commerce_line_item_save() to save $new_product, which is in this code snippet should be a clone of the line item. I've tried it with increasing the line item id and save it that way but I just got DB errors.

How can I make this happen in a nice way? Thank you!


texts: Admin page to show 2 blocks (or page+block) with 1 filter that affects both blocks

texts:
I am new to Drupal and would love some guidance on how best to achieve the following:

An admin page that has (top-down):
- a date selector, defaulting to today's date
- a section displaying Arrivals for the date selected (this selects custom content type 'Bookings' with filter of arrivalDate = dateselected)
- a section displaying Departures for the date selected (this selects custom content type 'Bookings' with filter of departureDate = dateselected)

I'm interested in how conceptually an experienced Drupal developer would approach this with Views.
Note: The project uses Drupal 7.

My approach so far:

One view with Page display that lists the Arrivals and uses an Exposed Filter for the date
One view with block display that lists the Departures and uses a hidden filter for the date
The block display (2) is shown in the Footer of page display (1)
The mymodule_views_pre_build hook is used to set the exposed filter date in (1) and hidden filter date in (2)

The initial load of Page (1) is working fine. Changing the date via the Exposed Filter in (1) correctly updates the Arrivals list; but not the Departures. I'll need to update the hidden filter in (2) somehow.


texts: Add JavaScript into a specific content type

texts:
I would like to know what is the best way to add a JavaScript file into a specific page basing on the content type. For example, I want to add this:

<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false'></script>

So far, what I have done is using this way to add into my specific content type. For the  map_page content type, I adde the below two line of code in page--map_page.tpl.php.

drupal_add_js("http://maps.google.com/maps/api/js?sensor=false", 'external');
$scripts = drupal_get_js();

Is there any other better way? if possible can give some example, currently not really understand well...


texts: Opinions on protecting content: book/password/sub-domain?

texts:
We are going to have a 'micro-site' specifically dealing with HR for possible candidates. There will be some data that will only be available with a login/password.

I'm trying to think which path is easiest, simplest to create and maintain.

We are using the Domain Access module and I've no idea if that will interfere with creating a separate sub-domain for this micro-site. I thought if I created all the content in a sub-domain (such as hr.example.com)and then password-protected all the content at that sub-domain (using Drupal 6 protected_node module) that would be simple to keep separate and not have any of the info somehow end up on the main domain.

Or, coding the 6-8 pages as normal in html/css/jquery. Then, creating a basic page node in Drupal and put all that code in that one page, password protect it so that we'd send a candidate the url of www.example.com/hr where they would have to login before seeing the content. The idea of sticking all the html in there is that the micro-site itself would only be in the one node, thus keeping all the content behind the password.

And/or finally, using a "Book" to keep all the content 'contained' and password protect that.

Not sure. We've had so many silly server issues (I'm not an IT person) that I want to be able to make it simple and not rely on LDAP/AD authentication...just Drupal's authentication.

Thanks


texts:
Am newbie to Drupal this is my first question

i want to embed my images on the blocks body, so i tried below code to embed

Email :

contactus@xxx.com

          <select name="Country" class="countrylist">
            <option>India</option>
            <option>USA</option>
          </select>

i having page.tpl and page--front.tpl in my custom theme, the images are only loading on page--front.tpl, please refer screenshot

But for other pages for example user login page the images are not loading, please screenshot 2

When i inspect with firebug on the image src the url added with the "user" ,this is the reason behind why the images are not loading

http://localhost/projects/drupal/dev/user/sites/all/themes/custom/themename/images/facebook_top.png


texts:
How would I change the category from "Fielded panes" in Panels IPE to something else?

I can accomplish this through the following code:

function template_preprocess_panels_add_content_modal(&$vars) {
  $i = 0;
  foreach($vars['categories_array'] as $item) {
    $new_item = str_replace("Fielded panes", "New Content", $item);
    $vars['categories_array'][$i] = $new_item;
    $i++;
  }
}

However, I'd like to find a more elegant solution by altering the category name in a function that runs before template_preprocess_panels_add_content_modal().


texts: How to make custom jquery method accessible from Drupal.behaviors, across multiple javascript files?

texts:
I have a custom views plugin.  When the view is displayed, the javascript below gets loaded.  Note the custom method, do_stuff, which gets called from within Drupal.behaviors.

(function ($) {
  $.fn.do_stuff(indx){
    alert (indx);
  }
  Drupal.behaviors.mymodule = {
    attach: function (context, settings) {
      if (settings.hasOwnProperty('mymodule')) {
        $('.my-item').each(function(indx, item) {
          // do stuff to each item
          $(this).do_stuff(indx);
        });
      }
    }
  }
}(jQuery));

I would now like to create a second plugin, which loads a second javascript file.  This second javascript file needs access to the custom method, do_stuff.  Is there a way I could access the do_stuff code defined in the first javascript file, from within the second javascript file?  For example, is there a way to move the custom method inside Drupal.behaviors, so that it could then be accessed from within any other javascript file?


texts: Best practices for copying data (only) back from production site to testing site after exporting views as features to prod?

texts:
After building/testing a Drupal 7 site, I deployed it to prod server, exporting all views as features. Now the views are all 'in database' on test site, but 'in code' on live site - on the theory that no views editing should be done in prod. Now if I want to copy my prod database (but not code) back to my testing site for a new phase of development, what's the best way to avoid overwriting (or wiping out) views 'in database' on my dev site?

Should I have renamed the views when creating features?
do I export/import the views, either from/to testing or from prod to testing?
is there some other way to selectively preserve views in the testing db when copying back an sqldump?

Thanks much!


texts: Problems with Search API and Entity Translation

texts:
I'm building a two-language website (Ukrainian - main, English - second) with the new Entity Translation approach. This approach seems very promising however it does not support multilingual content indexing.

I planned to use Search API Database Search module for the website. I also installed Search API Entity Translation and Search API Entity Translation Database Search in order to make them play together.

However the behaviour I achieved is the following:

1. When searching the website from the Ukrainian version: when searching with Ukrainian keywords the search yields no results; when searching with English keywords the search shows results in Ukrainian (the Ukrainian versions of relevant content in English).

2. When searching the website from the English version: when searching with Ukrainian keywords the search yields no results; when searching with English keywords the search shows results in English (with highlighted relevant keywords).

As far as I understand there is a problem with Ukrainian content indexing. Is it somehow possible to fix it?


texts: How to add jQuery.LocalScroll to Drupal 7?

texts:
I'm trying to add smooth scrolling within a page. I did find out it could be done using jQuery.LocalScroll.

What I've done so far:
1. I use Zen subtheme, so into my .info file I put:

scripts[] = js/jquery.scrollTo.js
scripts[] = js/jquery.localscroll.js

2. I put jquery.scrollTo.js and jquery.localscroll.js into js folder of my theme.

Unfortunately scrolling does not work properly. I don't know much about jQuery and integrating it into Drupal. If someone is kind enough to guide me step by step how to make it work, I'll be very grateful.


texts: Drupal 7 Get field value by machine name and pass to javascript

texts:
I have tried to do this a couple of different ways, but I will just include the latest.

My task is to build a module that will get the STRING value of a taxonomy term by the machine name of the field when the page is rendered, and pass that STRING value to a javascript function to output data in a block.

Most recently, I have tried adding the code to the template.php file in the preprocess_html, page, node and process_html:

*The field is called 'field_test'

global $nid;
$node = node_load('12');
$test = $node->field_test['und'][0]['value'];
drupal_add_js(array('mymodule' => array('test' => $test)), 'setting');

Error in processes was a call to undefined index.
Error in page.tpl was a call to non object.

I also tried field_get_items:

$items = field_get_items('node', $node, 'field_test');
$first_item = array_shift($items);
$test = $first_item['value'];

In the node.tpl file, I tried adding this code:

<?php
  $test = $node->field_test['und'][0]['value'];
  drupal_add_js(array('mymodule' => array('test' => $test)), 'setting');
?>

No errors, but Drupal.settings.test returns undefined in the browser console.

I'll admit I am still new to the Drupal API. In addition to the correct code, I may also lack an understanding of the order in which Drupal components are loaded, and specifically where the code should be placed.

I would really appreciate any help you can provide.


texts:
In admin/people/permissions I checked the boxes next to the "Cancel own user account" and "Select method for canceling own account" but in the user profile (user/NID/edit) the Cancel account button is not present.
Why? What could I have forgotten?

I have assigned the right role.

Thank You.


texts: How to block a specific email address domain from being able to submit Drupal webform?

texts:
I've been trying to find an answer to as per title. How can I block a specific email address domain from being able to submit Drupal webform?

Example:

Webform has fields:

Name, Email address, Subject, Query - all fields are set to required.

What I want is a webform submission to be blocked when a visitor is trying to submit it using a specific email address domain, for example *@example.com.

I need my Drupal webform to be able to act similarly to a registration form equipped with User restrictions module.

Many thanks in advance.


texts: Possible side effects when changing node type?

texts:
I sometimes have uses cases where I want to be able to change the type of a node.
There is a nodetype module that comes with a big disclaimer: "only use if you know what you are doing".

Of course I would lose any fields if they have a different name with the other type. What else could go wrong?

Would it be save to use node_load(), modify the type and then use node_save()?


texts: Clean GET parameters after submitting a 'GET' form

texts: How to remove form_build_id, form_id, op parameters that are added to a URL after submitting a form using GET method in Drupal 8?


texts:
Alright, so I have two files which should be added to a module. This is the way I do it:

$form['display']['#attached'] = array(
    'js' => array(
      array('data' => drupal_get_path('module', 'test_module') . '/js/test_module.js'),
      array('data' => drupal_get_path('module', 'test_module') . '/js/common.js'),
    ),
  );

Now my test_module.js file looks like this:

(function ($) {
Drupal.behaviors.test_module = {
  attach: function(context) {
    console.log(Drupal.settings);
  }
}});

And js works fine because I get data from Drupal.settings object. However, the second one is totaly the same and console.log does not work. Here's how it looks:

(function ($) {
    Drupal.behaviors.test_module = {
      attach: function(context) {
        console.log("test data");
      }
    }});

Why the second file does not work?


texts: My queue table is huge, is it safe to empty it?

texts: I have launched some batch jobs that I didn't finish. Now I notice my queue table is almost 1 GB. Is it safe to empty it?


texts: How do I Install an earlier version of Drupal 8 with composer because install fails on server with PHP 5.6?

texts:
My server is using PHP version 5, therefore, I need to install Drupal 8 version 8.6.18. But when I try, composer create-project drupal-composer/drupal-project:8.x-dev my_site_name_dir --no-interaction --no-install, I get the following error.

  [InvalidArgumentException]
  Could not find package drupal-composer/drupal-project with version 8.x-dev
  in a version installable using your PHP version 5.6.40.

Is there anyway to install 8.6.18 with composer?


texts: How to select a Taxonomy term in a Pane's settings and send it as an argument to Views?

texts:
I have a taxonomy vocabulary Help with several terms, representing different topics. I also have a Panel page where I would like to add Panes that contain all nodes with a certain Help term. My idea was to create a content View that accepts filtering on a provided Help term. Next, I would simply add this View to my Panel page and select the desired Help term from a list in the Pane's settings.

I more or less succeeded: my View has a relation Content: Taxonomy terms in node (where I selected the Help vocabulary) and a contextual filter Taxonomy term: name (where I set up an appropriate validation criterium Term name). This works fine, but I have to manually type the term name in my Pane's settings. That is not so efficient, because the term names might change in the future.

Is it possible to pick the desired term name from a list?


texts: how to get webform title and category with no submissions in view or hook?

texts: I have a survey form created with webform module.i have to display all survey form title with submissions and without submissions with webform category on home page.but it displaying only submitted survey forms title.how can i display webform title with zero submission in drupal8?


texts: Drupal 8, use "query api" with "collection fields" (not via FieldCollectionItem::load)

texts:
I added a field collection to the user 'manage field' page, the field machine name is 'houses'. The user may add as many home he want.

This field collection regroup :

- a sample text plain field (the name of the house), the machine name "house_name"
- a sample integer field (the size of the house), the machine name "house_size"

In a custom module, I want check if the current user have a house with a size = 4 (if in collection fields, there is a house with "house_size = 4"), how can I do that via the Drupal 8 Query Api ?

I found several example of Drupal "Query API", but nothing with collections fields..

I can use the function load of the class FieldCollectionItem, but I want use a fastest way for get the information I want.

Thanks you :)


texts:
I'm a newbie, and I'm trying to create a site on Drupal7.

I have a taxonomy vocabulary with many terms. Then I use taxonomy_menu and nice_menu to show the terms. This is working perfectly.

The problem comes when I create (or edit) a node (of any type) and I associate it to a term. The menu item(s) corresponding to selected(s) term(s) loses his place in hierarchy. Searching on database I realize the column "plid" on "menu_links" table is set to 0.

Searching on drupal.org I found this post, I think my problem is related to it. On first comment someone gives a solution, but I can't use it, because in this case nodes won't be shown in the menu.

ideas?

P.S.: sorry on my bad english, ask if you don't understand


texts: How do I show an image in a Drupal 7 module?

texts: I'm creating a module and need to add some images to the admin part of it. I've created an images folder in my module folder but I'm not sure how to get the exact path to the images to echo them in my module.


texts:
I have a strange behavior (or at least this is what I think) I have two form elements. Both are required, in the first (First Name) I want to have a required field so I use '#required' => TRUE and '#required' => TRUE in the second I don't use this properties to says that the field is required, I just add this line to the title '*'. The problem is that the output of the first element is "First name " (with space at the end) and in the second element the output is "Last name" (without space at the end). See the code and the picture with the output code.

Is this a normal behavior or I missing something here?

  $form['general']['group-1']['prenom'] = array(
    '#prefix' => '
',
    '#title' => t('First name'),
    '#id' => 'cf-1',
    '#type' => 'textfield',
    '#required' => TRUE,
    '#attributes' => array('required' => 'required'),
    '#suffix' => '
',
  );

  $form['general']['group-1']['nom'] = array(
    '#prefix' => '
',
    '#title' => t('Last name') . '*',
    '#id' => 'cf-2',
    '#type' => 'textfield',
    '#suffix' => '
',
  );

The HTML code:


texts: How to get an entity create route, given an entity type and bundle?

texts:
I am the maintainer for Views Add Button: https://www.drupal.org/project/views_add_button , which creates a button (link with classes) in a Views header or footer, that allows the user to add content of a particular type. Link building and access checking are meant to be handled automatically by the module, so that the user does not have to write a custom plugin or put a "view in a view" to handle access control.

While working on a Drupal 8 port I'm running into some trouble getting the correct route for entities. At this time, the options form for the plugin will pass an entity type and bundle, but given that there are many entity types, some with bundles and some without, I am not sure how to calculate the route name for a given entity-bundle combination.

So far, I've written this to manually create the URL, based on some assumptions. I left the options building out as it is not relevant to the topic:

// Get the create route
$type = explode('+', $this->options['type'], 2);
$entity_type = $type[0];
$bundle = $type[1];
$u = $entity_type === $bundle ? '/' . $entity_type . '/add': '/' .$entity_type . '/add/' . $bundle;
// Create the link
$url = Url::fromUserInput($u, $opts);

The goal is to use Url::fromRoute() instead of Url::fromUserInput, using the entity type and bundle. For example, 'node' and 'article' should return 'node.add' , which would then be given to Url::fromRoute().


texts: Image styles are not created 404 Not Found

texts:
I'm running on Nginx. All permissions are set to 777 and owner is www-data:www-data.

Create/edit a node with image_field, upload an image.
Original image is uploaded and stored at sites/default/files/image.jpg
Preview works, etc. Save node, no image shown (style Large or any custom).
Error 404 Not Found e.g. URL https://test.example.com/sites/default/files/styles/product/public/image-hd-wallpapers-3_0.jpg?itok=1E64uuXF
The styles subfolders are created like e.g. product/public even the sample.png file is created inside sites/default/files/styles/product/public/modules/image/
But no image style is created when uploading image to a node and saving.

I followed and tried everyting done in this image style (imagecache) images are not being created and this Aplying image styles to images return 404 for images

I have this in my nginx conf:

location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
    try_files $uri @rewrite;
}

Permissions:
htdocs/sites/default/files # ls -al

drwxr-xr-x 10 www-data www-data   4096 Feb 13 13:01 .
drwxr-xr-x  3 root     root       4096 Nov 17 12:58 ..
drwxr-xr-x  3 www-data www-data   4096 Nov 25 18:57 bootstrap
drwxr-xr-x  2 www-data www-data   4096 Feb  8 13:01 ctools
drwxr-xr-x  2 www-data www-data   4096 Nov 19 23:17 fonts
-r--r--r--  1 www-data www-data    476 Nov 17 13:00 .htaccess
-rw-rw-r--  1 www-data www-data 243154 Feb 13 12:40 image-hd-wallpapers-3_0.jpg
-rw-rw-r--  1 www-data www-data 243154 Feb 13 12:49 image-hd-wallpapers-3_1.jpg
-rw-rw-r--  1 www-data www-data 243154 Feb 13 13:01 image-hd-wallpapers-3_2.jpg
-rw-rw-r--  1 www-data www-data 243154 Feb 13 12:37 image-hd-wallpapers-3.jpg
drwxrwxr-x  2 www-data www-data   4096 Feb  8 21:22 js_injector
drwxrwxr-x  2 www-data www-data   4096 Jan 25 00:35 mailsystem
drwxrwxr-x  2 www-data www-data   4096 Nov 17 13:02 pictures
drwxrwxr-x  4 www-data www-data   4096 Feb 13 12:41 styles
drwxrwxr-x  3 www-data www-data   4096 Dec 29 13:00 videos

/styles/ incl. subfolders.

drwxrwxr-x  4 www-data www-data 4096 Feb 13 12:41 .
drwxr-xr-x 10 www-data www-data 4096 Feb 13 13:01 ..
drwxr-xr-x  3 www-data www-data 4096 Feb 13 12:41 large
drwxr-xr-x  3 www-data www-data 4096 Feb 13 12:41 product

I tracked down the issue causing it, but still need to figure out why it is causing it, because we need that setting to keep our images and other files optimized with correct headers, etc.

The issue is this snipped in the domain's nginx config:

location ~* \.(?:css|js|ico|gif|jpeg|jpg|png|woff|ttf|otf|svg|woff2|eot)$ {
    expires 1w;
    #add_header Pragma public;
    #add_header Cache-Control "public";
    add_header ETag "";
    add_header Cache-Control "max-age=2628000, no-transform, public";
}

Removing it, solves the problem, but we need to keep it.


texts:
I am building a module with reactjs and I need to get the current node id from a controller so I can do certain tasks based on the node id but I always receive a null value, my routing is working correctly and my function is the following:

  public function currentNodeId()
    {
        // get current node
        $node_id = \Drupal::routeMatch()->getParameter('node')->Id();

        return new JsonResponse(
            array(
                'node_id' => $node_id
            )
        );
    }

and in mymodule.routing.yml I have:

 mymodule-currentNode:
   path: '/mymodule/currentNodeId'
   defaults:
     _controller: '\Drupal\mymodule\Controller\MyModuleController::currentNodeId'
     _title: 'Current node id'
   requirements:
     _permission: 'access content'

I can get the current node id from my module file 'mymodule.module' doing the same I did in the currentNodeId function:

   $node_id = \Drupal::routeMatch()->getParameter('node')->Id();

Anyone knows if this is some kind of security or am I doing anything wrong? Thank you

EDIT

This is what I have in my js file, I do this call and I want to get the current node id so then I can do a certain task, in the console I get null or undefined every time I do the request

$.get('/mymodule/currentNodeId/', function (data) {
                        console.log(data.node_id);
                    });


texts: How can I stop Views from eating my query strings when rewriting a link?

texts:
I have a view and I am trying to rewrite the links by appending a query string.

[name_1] is the name of the location.  The various values for age[] are the taxonomy term IDs for an exposed filter, and friends is a profile field.

Under Rewrite results, I have checked Output this field as a link.  This is my link:

location/[name_1]?age[]=27&age[]=31&age[]=35&age[]=39&age[]=43&age[]=44&friends=1

When I cut and paste the query string into the URL bar, it works fine.  However, when I tell views to rewrite the string I get URLs that look like this:

location/mexico?friends=1&age[]=44

This gives me no results and a broken view.

It appears that the query strings are processed in reverse, and it only accepts the first value for age[]-- even though when I type the same thing into the URL bar it is OK.

I tried replacing the symbols in the rewriting string like this:

location/[name_1]age%5B%5D=27&age%5B%5D=31&age%5B%5D=35&age%5B%5D=39&age%5B%5D=43&age%5B%5D=44&friends=1

Now, when I access the view, I no longer get an error, but none of the age (taxonomy term) checkboxes are checked and the URL looks like this:

http://localhost:8888/en/location/mexico?age%255b%255d=44&friends=1

So, clearly most of the age[] values are still disappearing for some reason.

How can I rewrite the query string so that views outputs it properly?

EDIT: According to Jimajamma's comment, D6 Views suggests using %5B%5D, as I have already tried (I'm on D7).  &#91;&#93; didn't work for me either (this combo doesn't even work in the URL bar).  Perhaps this is a bug in Views?

EDIT 2: As per the answers, this appears to be a bug in Drupal Core/Views, not a configuration error.  So I attempted to avoid using Views rewrite results output as a link feature and instead just rewrite results and code the link in HTML.

The only problem with this approach is that some of the terms have spaces in their names, and I was using the convert spaces to dashes option provided by the output as a link setting to get around this.  So now the links for terms that have no spaces work properly, but the links for terms with spaces are broken...


texts:
How to create a commerce site which also has the ability to take registration information during/before/after registration?

I am developing a website which offers a variety of training courses. When adding a particular course to the basket, I would like the to be able to take the details of the people (multiple attendees) who will be attending the course.

How can this be achieved?


texts: When should I use the Url::fromRoute method instead of "new Url"

texts:
I'm finding that these two PHP snippets yield the same result:

$arr['query']['confirm'] = 'y';
$text = t('Click here.');
$url = new Url('my_route.import', [], $arr); // Three arguments.
$link = Link::fromTextAndUrl($text, $url)->toString();

and

$arr['confirm'] = 'y'; // No "query" key.
$text = t('Click here.');
$url = Url::fromRoute('my_route.import', $arr); // Two arguments.
$link = Link::fromTextAndUrl($text, $url)->toString();

Is there any reason to prefer one approach over the other?  Which is the more typical approach?  Is there some general PHP rule of thumb that might apply, such as... always use a method on the class instead of instantiating an object with "new" whenever possible?


texts: Load the node as EntityInterface not NodeInterface

texts:
hook_node_insert(NodeInterface $node) gets a NodeInterface parameter. I need to pass it to
mymodule_node_operations(EntityInterface $entity) which accepts an EntityInterface parameter.
How do I load this node as EntityInterface type? Basically I need to downcast to the parent class which is Entity.
This is the error I get when attempting to pass $node to the function as NodeInterface.

TypeError: Argument 1 passed to mymodule_node_operations() must be an instance of EntityInterface, instance of Drupal\node\Entity\Node given


texts:
Is it possible to install Azure SDK via Composer within a Drupal site and use it in custom modules?
{
  "require": {
    "microsoft/windowsazure": "*"
  }
}

Also according to Microsoft docs, below code should be used in order to use Azure API. Not sure where though.
require_once 'vendor/autoload.php';
use WindowsAzure\Common\ServicesBuilder;


texts: How do I cache an object loaded through SOAP from a third party that I use in forms?

texts: I am loading and object that I use to populate a form. Then on form submit I return some of the fields through SOAP back to the third party. On submit the form building function gets called and loads the object then the submit function gets called and loads the object again. How do I cache the object so that it is only loaded once but available to both or more function to act on it.


texts: Yo Dawg, I heard you like $view->execute()

texts:
I've created a View of all the views that Drupal knows about, whether they reside in code or in the DB. It works great, tells the user about each view, its tags, its displays, its base table, its fields if they exist, and its path.

I'm doing this by overriding execute(&$view) in a custom query handler. A very truncated version of what I'm doing:

foreach(views_get_all_views() as $zview) {
    // Examine each display of each view.
    foreach($zview->display as $display) {
      $row = new stdClass();
      ... // Set the things on $row.
      $view->result[] = $row;
    }
}

Now I also want it to tell the user about each View's query.

If I do this it works (for the last of the many Views):

      $zxview = views_get_view($zview->name);
      $zxview->set_display($display->id);
      $zxview->pre_execute();
      $zxview->execute();
      dpm($zxview->query->query()->__toString());

but I have to do it outside of the foreach() that goes through each view. If I try to do $zxview->execute() inside foreach(views_get_all_views() as $zview) { ... } I get

PHP Fatal error:  Maximum function nesting level of '100' reached, aborting!

This makes sense, sort of. But, so how can I list the query being executed for each view next to the name of each view, within a view? (I'm already excluding views defined by the module defining this view of views.)


texts: Using Drupal 8 Feeds with Xpath parser, can I concatenate two attribute values that appear in a single tag?

texts:
I have a dataset content type and an xml structure like this:

<dataset>
   <purpose>blah blah</purpose>
   <abstract>blah blah</abstract>
   <authors>blah blah1, blah blah2</authors>
   <ordered-authors>
      <author>blah blah</author>
      <author>blah blah</author>
      <author>blah blah</author>
   </ordered-authors>
   <tags>
      <themes>
         <theme name="xxx" rank="1"/>
         <theme name="yyy" rank="1"/>
      </themes>
   </tags>
</dataset>

I want to get the multiple attributes of each theme tag into a form like:
xxx-1, yyy-2, etc.
which will be used as entity references for each dataset, whether as an array, or a list that I then implode via a tamper. In Drupal 7 there were "dummy" fields to hold temporary values - I could create extra fields in the content type for this purpose but so far, that hasn't helped me find any way to query the xml and/or use available tamper options to combine the nested attributes to get a usable array of concatenated values (short of giving up with the feeds interface and moving to migrate). ANY help or suggestions would be appreciated!


texts: When creating a content type programmatically, is there a way to disable promoting to the front page by default?

texts:
In Drupal 7, I'm creating a large number (15+) of content types programmatically. There is one in particular that should never be promoted to the front page. It would be really nice if, by default, the box to do this was unchecked. I'm aware that this can be done through the front-end, but my goal is to make the web application as portable as possible. That is, other than content, I want it to be able to be moved completely and properly by only installing the correct modules.

I'm removing authoring information, for instance, by setting the variable node_submitted_{content type name} to FALSE. It would seem like there should be something like this available for promoting by default.

Thanks.


texts: How to go about creating and formatting a custom HTML/PHP table to display SQL data

texts:
I am new to drupal and basically I made a database within drupal and filled it with some dummy data. I want create/format/populate a table that looks like on one of my drupal pages:

+-----------+-------------------------+---------------------------+---------------+
| Resource  |          Week1          |          Week1+7          |    TOTALS     |
+-----------+-------------------------+---------------------------+---------------+
| resource1 | Hours(Week1, resource1) | Hours(Week1+7, resource1) | totals across |
| resource2 | Hours(Week1, resource1) | Hours(Week1+7, resource2) |               |
| TOTALS    | totals above            | totals above              |               |
+-----------+-------------------------+---------------------------+---------------+

I understand that you do it through views and I was trying to do it by creating my own module using the views_data() hook to try to create it (using http://mydons.com/how-to-expose-custom-module-table-to-views-in-drupal/ as a base/resource). I am kind of stuck though and I have no idea what the best approach would be to start to create a table that looks like the above. I am not sure this is the correct way/best way to do it and any direction/tips you guys can help me out with would be great.

Thanks!


texts:
I am a web designer with development experience. I have been using Wordpress and have felt comfortable editing php files and playing with functions. On the tip of an acquaintance I decided to try Drupal despite the more advanced coding level required  & steep learning curve. I am amazed at the level of customization in the admin and excited about things like twig.

However I am having trouble understanding how to get custom variables from fields to work in a template. The theme packaged with Drupal 8 (Stark) seems to apply them automatically. But when I research how to do it (a ton of research) it seems like each group of custom fields need a function declared. Is this the only way? What am I missing?

Thanks.


texts: Moving site from one environment to another

texts:
I have a Drupal 8 site installed on a staging server. When moving on the production server,  I do a git pull, import the database and the site is there and working. I do the same after some configuration is changed,I do a git pull and the usual drush cim, but I get:

  Cannot change the install profile from to standard once Drupal is installed.

How do I get around this?


texts: Is it possible to attach my own datetime class for using it in fields?

texts:
For example, there is a situation, where I need to output date field in some another format. But this format is not supported by PHP.

For example, I want to output year value in Roman numerals format.
Or, I want to calculate year not from the Christmas, but from "the Creation of the world", from foundation of Rome ans so on.
Or "the week" in my calendar doesn't contain 7 days, but it contains another quantity of them.

In this case, if I'm not mistaken, I should create new class inheriting it from DateTime class and there redefine method format or do something else.

Can I afterwards notice Drupal to it use my own DateTime class instead default ?
That is, for instance, I have created new DateTime field for some node type and I can set my date format for this field in the admin date settings page, in Views and so on.

Is it possible in Drupal 7 ?
And is it possible in Drupal 8 ?
If yes, how to do it ?


texts: Cannot log in to Drupal site after moving

texts:
I just moved my Drupal 7 based site from the computer I built it on to the Ubuntu webserver which it will run on. Everything works out fine, except for the fact that I cannot log in.

Whenever I try logging in, the site refreshes with a new URL:
<serverIP>/node/90?destination=node/90

But I'm still not logged in. Why is this happening?

I have enabled Clean-URL.
I moved the site following these instructions: LINK


texts: User name who flagged in Global Node flag

texts:
I have a global node flag where editors can flag the Node article as famous. There are more than 10 editors, so, I want to display in the node who flagged it and when. I used Views Relationships to get the flag data, I could easily get the flagged time but couldn't get flagged user. I tried with flag users relationship but it results in Anonymous user instead of the user who flagged.

Is there any way I can display the user who flagged it ?


texts: Using Drupal 7 with APC, Varnish and Memcache, what bins to put in which cache?

texts:
I'm optimizing a Drupal 7 website and I have varnish, memcache and APC all installed and working with their individual Drupal 7 modules. In my settings.php I have the $conf options below.

My question is to get better performance and have all these caches work together well, do I need to add more configuration options?

The module readme's usually assume a single cache system. Are there any tweks needed to get better performance out of running 3 separate caching backends?

// Add Varnish as the page cache handler.
$conf['cache_backends'][] = 'sites/all/modules/varnish/varnish.cache.inc';
$conf['cache_class_cache_page'] = 'VarnishCache';
// Drupal 7 does not cache pages when we invoke hooks during bootstrap.
// This needs to be disabled.
$conf['page_cache_invoke_hooks'] = FALSE;

$conf['cache_backends'][] = 'sites/all/modules/apc/drupal_apc_cache.inc';
$conf['cache_class_cache'] = 'DrupalAPCCache';
$conf['cache_class_cache_bootstrap'] = 'DrupalAPCCache';
//$conf['apc_show_debug'] = TRUE;  // Remove the slashes to use debug mode.

$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';


texts: How can I create a custom calculator on a drupal site?

texts:
What I want to do is have a page that collects a few pieces of information from the user and then calculates a result of a formula.

I do not want to store the information at all, and was thinking I may need to use the PHP Input type.


texts: Correct way of formatting dates for output in node theming

texts:
I am theming a node where I need to show the created date. Since Drupal stores it as timestamp, what is the best method to retrieve it? I have found this post: http://drupal.org/node/101993. But the problem is that whe using this...

<?php
print date("D, j M, Y \a\\t G:i", $node->changed);
?>

... it delivers me the content in English. My portal default language is Portuguese. Is there a Drupal function that will deliver the timestamp as a regular date that takes into account the user's selected language? And  that maybe takes into account the preformatted dates set in the portal configuration? Thank you.


texts:
I need get to field views in calendar module template.

print_r($view->result) output this: https://jsfiddle.net/36pbj7bb/

How output event_calendar_status?

I type this:

<?php print $view->result[0][_field_data][nid][entity][event_calendar_status][und][0][tid];   ?>

But I get:

  Cannot use object of type stdClass as array in

Any help?


texts: How do I get a URL variable in a template?

texts:
I am trying to include a certain .html file if the URL has ?work=1.

So far I have this, which I got from
Check URL for string in a Twig file.

 {% if 'work' in url %}
    {{ include('work/index.html') }}
 {% endif %}

They say I need a function in my .theme file to actually get the URL variable.
Is that right? Is there any way to get it with just Twig?


texts:
How can I edit a footer menu in theme like Bartik, currently its displaying the menu in vertical format and I want it in horizontal format. Any idea how I can go about editing this.
e.g.
current:
Menu 1
Menu 2
Menu 3

Desired: Menu 1| Menu 2| Menu 3


texts: Whats best practices for handling Drupal 8 core file paths for vendor package.json

texts:
I use drupal-vm when setting up my dev environment and have heard that setting up Drupal core files in the document root is a security issue and should be set in a different way.

So I have set my composer.json to:

 "merge-plugin": {
        "include": [
            "docroot/core/composer.json"
        ],
        "recurse": false,
        "replace": false,
        "merge-extra": false
    },
    "installer-paths": {
        "docroot/core": ["type:drupal-core"],
        "docroot/modules/contrib/{$name}": ["type:drupal-module"],
        "docroot/profiles/contrib/{$name}": ["type:drupal-profile"],
        "docroot/themes/contrib/{$name}": ["type:drupal-theme"],
        "docroot/drush/contrib/{$name}": ["type:drupal-drush"],
        "docroot/modules/custom/{$name}": ["type:drupal-custom-module"],
        "docroot/themes/custom/{$name}": ["type:drupal-custom-theme"]
    }

I get issues with the autoload not being able to find the vendor/autoload:

Warning: require(/var/www/site/docroot/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/site/docroot/autoload.php on line 14

Whats is the best practice for placement of Drupal 8 core files?


texts: How can I split the body field to insert content between the first and the second paragraph?

texts:
I have a node which shows content from the body field. I want to add a another paragraph or a block between between the first and the second paragraph, after the first </p> and before the second <p> tag.
But in my template to output the body there's only {{ content.body }}.
Drupal 7 had something like block in block. How can I do the same in Drupal 8?


texts: Show markers depending on Node ID via Openlayers

texts:
I have a situation that seems very easy, but i can't get it to work. I have a content type called 'countries' which hold all the countries. I want to display a map per country with the borders accentuated.

Here for i have two views, 'data' and 'display' to show an Openlayers map. When i add the 'display' view to my panel, i nicely get the last ten records (because in the 'data' view i've chosen to display a specified number of items | 10 items).

Now i don't want to display the last ten records, but only the records that correspondents with the node id, passed via the url. So i added an contextual filter to my 'data' view and when i test it, it works. The 'data' view only shows the according records.

The problem is that i can't find a way to make the 'display' view dependent on the 'data' view. I've tried to first add the 'data' view and right below the 'display' view in my panel, but it keeps outputting the last ten records.

What setting am i missing?


texts: How to add CSS classes to buttons of Drupal Commerce checkout forms?

texts:
How can I add a bootstrap btn-success class to the Drupal Commerce Checkout button in the cart form?

The Update cart button already has btn-info but I can't find btn-info anywhere in the code.

If would also like to adapt buttons in other parts as I expect btn-success buttons to lead to higher conversion.

Bootstrap has great classes, I don't want to fiddle with CSS to try and recreate that, I just want to use the Bootstrap classes.

I'm okay with adding some PHP code to my theme's template.php, probably _form_alter() and this is probably the way to do it. But how exactly?


texts: How to avoid appending incremental number to filename

texts:
I don't want Drupal to add incremental numbers to my file names to make them unique. I want to always have files stored with the same name they had when I uploaded them.

If the file with given name already exist, "Replace already existing file?" prompt should appear instead of default behaviour.


texts: How we can generate Latitude/Longitude at the time of import while using Feed module

texts: I am using Feed Module For Importing Nodes Form CSV File. What i want that at the time of import how we can generate lat/long pair for every node imported. I have address in csv file for every node an i want to generate lat/long pairs.


texts: The specified library "bootstrap/drupal.ajax" does not exist

texts:
I'm trying to separate a multisite instance in to separate websites. I created two separate instances and moved custom themes and contrib modules in to site specific folders.

When I try to load the site getting following error:

Site is using custom bootstrap subtheme and same database.


texts: Adding nofollow to specific internal paths

texts:
I am looking to add nofollow to specific internal paths when they appear within text anywhere in the posts.

I tried using the text filters but I only get the options to either nofollow all links within a post body or nofollow all external links.

What I am trying to achieve is to nofollow all links following this pattern (/user/* ) when they appear within text body.

What are my options? Custom filter? or a preg replace through preprocess. I will appreciate a bit detailed explanation as I am new to programming.

Thanks in advance.


texts: Is there any way to display an image as background?

texts: I have a picture in a field and I want to be displayed in its exact look but as a CSS background... is this even possible? Is there any mechanism how does that?


texts: js file attached with form via ajax twice time not come with form

texts:
I have attached JS file with form and this form is coming by AJAX. when first call AJAX to get Form, in AJAX response form and JS (attached with form) are coming. but I close form and do not refresh page and again send Ajax call for form, second time form come but JS (attached with form) are not come. this JS file has to run after form for form validation. but second time it not come with form. how solve above problem.

for more information: click here

click on the above link
click on "CONTACT US" link, a contact us form will come via Ajax.
see in fire bug two files are come form and js file.
close it form and do not refresh page, repeat step 2 the form come but JS file is coming the second time.

Question: How to solve the problem?

Edit
attached form code:
 $form['#attached']['js'] = array(
            drupal_get_path('module', 'contact_form_alters') . '/js/contactForm_ClientValidation.js');

Ajax callback function :

//function returns contact form using ajax
function bottombar_contact_form_show($js = NULL) {

  if(!function_exists('contact_site_page')) {
    form_clear_error();
    require_once drupal_get_path('module', 'contact') .'/contact.pages.inc';
    $commands=array();
    $output=  drupal_get_form('contact_site_form');
    $commands[]=  ajax_command_invoke(null, "zeContactUsForm", array(drupal_render($output)));
    $page = array('#type' => 'ajax', '#commands' => $commands);
    ajax_deliver($page);
  }
}


texts: Exposed filter of a view embedded in a panel overriding a node form triggers node submission. How to prevent this?

texts:
I have a panel overriding the node/add form of a custom content-type in one pane and a view listing some nodes including 2 exposed filters to reduce the results of that list in another pane.

Both, the form and the view show up as i want, but if i use the exposed filters the node gets submitted instead of filtering the view.

How can i prevent this? Is there some way to do this step by step?

Drupal 7, latest dev-versions of Views and Panels.

Thanks in advance!


texts:
I have a problem that I have not been able to find the solution. I have an entity reference field for a node to display specific news I need them to be sort them by the date they were created by the latest. In the field settings there is an option to  sort by created but it is not applying the sorting. Is there another way that I can sort them maybe using rules, or programatically. Any idea what I am doing wrong? I cannot use views for this particular problem because each node display different news, do it manually is not an option either because I am creating the content using web services.

NEWS ORDERED BY THE LATEST

September 12, 2012
lorem Ipsum is simply dummy text of the printing and typesetting industry.

June 12, 2012
lorem Ipsum is simply dummy text of the printing and typesetting industry.

May 12, 2012
lorem Ipsum is simply dummy text of the printing and typesetting industry.


texts: Unable to send email using "SMTP Authentication Support" module

texts: I was working on a project where i  used "SMTP Authentication Support" module to send emails. The authentications i provided were my personal gmail account details, It was working fine. Now when i am entering the site admins account details its displaying "Unable to send e-mail. Contact the site administrator if the problem persists." error. It also says that "SMTP Error: Could not authenticate." Can anyone let me where i am going wrong.


texts:
Is there a way to invalidate a render array cache by somehow passing the user.data information to the cache context and tags?
Adding user:ID and user to the tags doesn't seem to invalidate when the user data is updated.


texts:
How to replace two classnames by writing a function in template.php

The two classnames given are:

comment-add

and

comment-comments


texts: How do I add a date picker that is rendered from most the browsers?

texts:
I am migrating from Drupal 7 to Drupal 8. In forms I use '#type' => 'date_popup' for date fields, which Drupal 8 replaces by '#type' => 'date' and uses HTML 5.

I'm finding it most unsatisfactory because:

It has poor browser support; Internet Explorer 11 doesn't provide a popup.
I can't find anyway to change the input format from 'm/d/yyyy' to either 'd/m/yyyy' or 'yyyy-mm-dd'.

I have ensured that my browser language setting is English (Australian) which has a default date format of 'd/m/yyyy'.

Does anyone have a solution that provides a date picker for most the browsers and a text input format that can be controlled by the server, not the client?


texts: How to save in a different subfolders the attachments of my users?

texts:
I want each user's attachments (they will be school assignments docs, photos, maps) to be saved in user's own subfolder in order to be able to collect them easily and separately.

How would this made possible and what are the best modules to utilize in order to achieve it?


texts: Drupal 7 disable submit when pressing enter on an autocomplete field

texts:
In Drupal 7, when you are within an autocomplete field on a node edit form (in my case, it is specifically an entity reference autocomplete field), pressing the Enter key submits the entire form.

How do I disable this behavior?


texts: How to change bean's block view mode programmatically?

texts:
I have created a block entity using bean module.

It has three image fields. Image1, Image2 and Image3.

I want to show only one image depending upon current time. I have three time values.
For this I have created 3 view modes each for one time value.

Now I'm stuck that how will change the view mode based on time value programmatically.

I have used the following code.

function glue_site_block_view_alter(&$data, $block) {
  if ($timevalue1 == $value1) {
    $data['content']['bean']['block_delta']['#view_mode'] = 'view_mode1'
}


texts:
I have defined many regions in my theme template. I would like to have a home page that uses these regions ... how can i use them?
I have made a home.tpl.php but i don't know how to assign code to regions ... is it possible to do it even outside the page.tpl.php?


texts: Which file do I need to edit to implement a 'Back to top' link?

texts: I am running a Drupal 6.22 site, with a custom template installed in /sites/all/themes/mytheme. Which template file should I edit to implement a back to top link?


texts:
Is it possible to to invoke a rule this way?

So far I have not had any luck?

/* Implementation of hook_form_alter*/

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

  if ($form_id == 'user_login') {

  $form['#validate'][] = 'ea_login';
  }
}

/* implementation of hook_form_validate */

function ea_login($form, &$form_state) {

  $response = rules_invoke('rules_my_rule', $args);
}


texts:
I have a user profile form. If a user selects a picture, it's uploaded and shows on user profile but If user just updates other details and leaves the picture the same the user_save overrides the user picture and then there is no user picture.
My code is like this.

if(!empty($_FILES['files']['name']['profile_image']) && isset($_FILES['files']['name']['profile_image']) && ($_FILES['files']['size']['profile_image'] != 0)) {

        $filepath = 'public://pictures/';
        $file = file_save_upload('profile_image', $validators, $filepath);
        $file->status = 1;
        file_save($file);
        if(isset($file) && !empty($file) && !is_null($file)) {
            $loaded_user->picture = $file;
        }

    }
user_save


texts:
We are using Commons modules and among other parts of it a Q&A module. We noticed that when a user question is answered ,, answers do not get published. Not even when admin answers the question. Instead, we have to go in and set publishing options for all answers, one at a time.

The content type used for answers is called "Answers" and a default setting for publishing options is set to "published".

When the answer form is submitted the publishing option is not checked..

Does anyone know why this is getting overridden and how to make this work?

Thanks!


texts: How to choose appropriate token for URL path alias pattern display in URL?

texts:
Using Drupal 7 + PathAuto + Token + Entity API

Having a really hard time setting url aliases...for nice URLs.
I have it set up like this:

[node:field-root:parents]/[node:field-root:name]/[node:title]

But it's not what I want, I want every term displayed separately in the URL, now it's like this:

 ab/c/d/item

but I want:

 a/b/c/d/item

What token should I use to get this done, tried tons of combinations and can't get it working...

I see the explanations besides the token, but still, it's too complex and I can't wrap my head around this to get it working.

I saw a page that asks users to share their pattern recipes (https://www.drupal.org/node/124462), but there is nothing in there...if I could see a list of patterns and then resulting ULR it would be great.

Otherwise, how do I know what token to choose?

Picture below is hierarchy, the URL I want is:

 mysite . com /destinations/northern-laos/outodmxay/history


texts: 403 error in files while hosting drupal site in hostgator

texts:
I'm trying to host my drupal site in Hostgator. Here what i've done so far:
a. uploaded files to server, created db and user and imported too.
b. Change settings.php database content.

My site is up and running although my css and files are not being loaded..when i check my browser console it shows 403 error, even i can't access my backend whenever i try to access it shows 404 error,although it seems to be working fine on my localhost.. i know it's permission problem but i don't know how to deal with it is there any steps i leftover which i need to follow, is there any step by step documentation on hosting drupal site on cpanel any help would be great.Thanks in advance.

P.S.-i'm using nginx, and linux system for my development environment.
And new to drupal :)


texts: Why is my site's homepage loading in static mode?

texts:
I am using the AdvAgg  module and all of its submodules, configured it using the configuration in AdvAgg README file.

After doing so, the site's mobile view got problem. So I disabled all from AdvAgg one by one to see what really caused the problem but haven't found one. Note that I was clearing my cache every time when I edited or did something. I then tried to totally uninstall eveything, including CSS and JS files from AdvAgg. But when I went to homepage there's no style at all. I checked the other pages but it looks normal to me. Also mobile view is back to normal.

I checked the source code for homepage and it is using an old CSS file which is produced by AdvAgg (sites/default/files/advagg_css/.css, which BTW is just a shortcut name for the css file since it is very long). That directory doesn't exist anymore since I already uninstalled AdvAgg. I enabled and configured AdvAgg again hoping everything will go back to normal but homepage still no style. My conclusion is homepage is loading in static mode.

Homepage was assigned to a certain page so I edited it but nothing's change in homepage. I decided to just copy the style from other pages, rename it to the one used by homepage and then upload it through ftp to the same location pointed by home's css.

Now, the site is back to normal but it is loading in static mode. How am I suppose to change it? Is there anything I've done wrong? I also have an error in status report regarding AdvAgg's HTTP request for js files not getting though. By the way, this is the site www.growplants.org. It is supposed to be the same with this page www.growplants.org/grow-plants as it is assigned to homepage.


texts: How to remove content from view once user clicks on it (or reads it) in drupal 7?

texts:
I have a view "Recent content of your interest" based on taxonomy and flag.

Current scenario:

User clicks on content from view and reads it, he comes back to same view.

What I want:

User clicks on content from view, read it, come back and the content (which he just read) is not listed i.e. removed from same view.

Any module I can use for same or any pointer to implement same functionality highly appreciated.


texts: Drush won't use password for DB connection; how to set it to use password and define password?

texts:
I can't figure out why and where Drush is set/configured not to use password when connecting DB.

For instance I was trying setup a quick site e.g. command drush qd which gives:

  PDOException: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

Or is it even any configuration? Is it about qd command? Earlier I tried to add db user name and password along as parameters ie. --db-su and --db-su-pw but no go.

Of course I could remove password for root user but it doesn't help me in the future and certainly won't help in building secure sites.

So how can I get Drush to use password for db connections?
Does it inherit configuration details from some other config php, mysql, apache, debian?

I'm using Drush 6.20 with Ubuntu 14.04, PHP 5.5.9 and Apache 2.4.7.


texts:
I am struggling to find a solution for image styles not getting generated. The original pictures get uploaded to the server but no styles or thumbnails are generated.

I have checked folder permission and set it to 775 and even 777 (temporarily) for the /styles/ and its subfolders.

I even set $conf['image_allow_insecure_derivatives'] to TRUE.

Yet I still get access denied for the anonymous users (not verified when I upload images and no styles or thumbnails).

Any suggestions are greatly appreciated.


texts: php code to load latest posts from a term

texts:
How can I load 10 latest posts from a term using a PHP code, I know how to display latest titles but I need latest nodes body or teaser too.

How is that possible? (title and body)


texts:
I tried to make order by promote when I call taxonomy_select_nodes. Like this:

$node= taxonomy_select_nodes(163, TRUE,10,array('t.promote' => 'DESC','t.created' => 'DESC'));

But I got an error! Is there any solution?
Thanks


texts: Drupal Commerce does not work correctly with attributes

texts:
I have installed Drupal Commerce Kickstart and I am attempting to migrate a wig store from an old version of Zen Cart that has been abandoned for years.

All I have seen so far is that to load attributes you have to create different products that will be shown as 1 product.

But this is not how I can migrate this store: first, I can only create one product with the color shown, that is how manufacturer provides info.

For an example of what I need to migrate: http://ladywig.com/index.php?main_page=product_info&cPath=17_43_44&products_id=175

I need to load only certain images and names that apply to a certain product, from a much larger vocabulary of names and images.

Customer can only select one color attribute per product. Nobody in Commerce seems to have a clue about how to do this, somebody will come up with the brilliant idea to pay for a custom module, but this does not make sense to me because I could rebuild that site with a newer version of Zencart and obtain the functionality I need for free.

So can similar functionality be achieved with Commerce, or with the addition of some contributed module?


texts: jquery.js and drupal.js Producing 'Not Found' Errors, Yet the files do exist

texts:
I'm having a problem where Javascript as a whole is not working on my site. When I view the html source and click on the links to the paths provided in the , I get 404 Not Found errors for 'jquery.js' and 'drupal.js' yet both files exist in the misc folder.

<script type="text/javascript" src="http://capstone1:8082/misc/jquery.js?v=1.4.4"></script>
<script type="text/javascript" src="http://capstone1:8082/misc/jquery.once.js?v=1.2"></script>
<script type="text/javascript" src="http://capstone1:8082/misc/drupal.js?m1ilvw"></script>
<script type="text/javascript" src="http://capstone1:8082/misc/ui/jquery.ui.core.min.js?v=1.8.7"></script>

Above are the way the html appears in the source code. All 4 .js files produce the 404 Not Found error, so I'm assuming there's a problem with paths or permissions but can't figure out what. Any help would be much appreciated - thanks!


texts:
What is the best way to add some validation to the fields in an Entityforms form? I did some googling can't find any good answers.

Thanks,
Jonathan


texts: How to search both Users and Nodes simultaneously in drupal 7

texts:
I have a url for search nodes like "?q=search/node/article/xyz"
   and
  I have a url for search users like "?q=search/user/xyz"

now i want to search both at a time simultaneously so, what is the url for this
  in drupal 7.

I have links for Search Like "Article Search",  "User Search", and  "All Search",

I have url for both article and user but not for All Links that's the problem
  please help.


texts: How to structure repetitive data under an entity type bundle?

texts:
I'd like to use Drupal in one of my projects but I'm wondering what's the best way to organize my content.

I have a list of authors. Each author has 3 properties:

name
bio
list of books

On the list of books each book has 6 properties(5 text fields + image).

I was thinking about creating entity type bundle 'Author' and 'Book', then assigning certain books to certain authors and displaying lists of books on author page.

The downside is that on the content list I'll have a list of many different 'pages' of content type 'Book' that can't be easily filtered by author. Also, creating new content type for each author is not a good solution.

1) Is it the best possible solution for Drupal?

2) Would it be possible to create:

a) hierarhical list of author/book_list posts or

c) content type Author with list of books on it's page(book field with book properties fields)

I'd appreciate your advice :).


texts: Get HTML tags interpreted in field output

texts:
I have an event calendar view and I would like to be able to have HTML inside the field interpreted instead of printed as text i.e. on http://quaaoutlodge.com/myspecial-myevents , the Easter Brunch on April 20th has following event description:

Easter Brunch
<strong>** Reservations required ** </strong> - call 250.679.3090 but instead it shows up as: Easter Brunch
< strong> ** Reservations required ** < /strong> - call 250.679.3090 - why is this and how can get the HTML to be parsed before display?


texts: Why my Webform special token values not rendered correctly in D6?

texts:
I am trying to use "Special Tokens" in the Webform module (6.x-3.18) on Drupal 6.  I'd like the data to populate a hidden field I've created with the email field on the same form.

Under default value for the hidden field I've tried using a number of different values including:

%post[submitted][email]

%post[email]

%post[submitted[email]]

None of this works.  If I go edit the email field, it tells me my key is email.  If I look at the name of the email field in the source code it's submitted[email].

If anyone has any suggestions on what I'm doing wrong?


texts: Using Mysql LOAD DATA LOCAL INFILE with drush

texts:
I want to able to load a huge CSV file directly into the database using LOAD DATA LOCAL INFILE like below:

LOAD DATA LOCAL INFILE 'Subscriber.csv' INTO TABLE temp_data FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'IGNORE 1 ROWS

If I enter into the mysql via command line using drush sql-cli and run the command above I get;

ERROR 1148 (42000): The used command is not allowed with this MariaDB version

After some research I found out that if you access mysql via the command line using the --local-infile flag, I can be able to use the LOAD DATA LOCAL. Below will be the statement that I use to get into mysql :

mysql --local-infile -u root -p -h mysql

Using the command above will make it possible for me to use LOAD DATA in mysql but i want to be able to use it with drush sql-query. How can I apply the --local-infile flag.


texts: Drupal 8 - Add custom HTML with script to embed on a page as block

texts:
I need to add a custom form that has scripts and styles into a page as a block. Its dynamic, so I couldn't attach the scripts (#attached) as libraries. I just need to place the contents as is.

$build['test'] = [
  '#markup' => $test_code,
  '#allowed_tags' => [
    'script',
    'style',
    'form',
    'input',
  ],
];

I tried it as shown above, but this wasn't working. So, I removed, scripts and style as shown below and that works:

$build['test'] = [
  '#markup' => $test_code,
  '#allowed_tags' => [
    'form',
    'input',
  ],
];

Any possible solution to render the contents without filtering scripts and style.


texts: Issue with Registration codes module in Voucher mode, trying to fix

texts:
I am having serious issue with Registration codes module and searching for solution to fix it. It is described here:
http://drupal.org/node/797602

There is a patch to the issue, but author of the code stated that it may be "serious regression and borked a bunch of other modules, like simplenews and profile, anything that expects data to be in $edit."

That patch is very simple:

-  regcode_user('insert', $edit, $account);
+  user_save($account,$edit);

Module works well when used in normal mode, but in "voucher" mode, it does not apply role to user who submits it. To greater misfortune, the rule that this module came with, which could help do it another way, is also broken.

I think this module is not actively maintained as i do not recieve response for about an month on series of my request.

I would be very grateful if someone knows what approach i could take to resolve the issue, knowing how to rewrite patch to avoid harm to other modules functionality.

Thanks for clues!


texts: Create page with different content types

texts:
This should be something simple but I didn't figure out how to do it. Let's say I have three different content types: Client information, client projects and client updates.

I would like to have a "New client" node that will automatically create the three above content types.

Is that possible?


texts: Hover over image and display above like EBAY and AMAZON

texts:
I've tried searching but i cant figure out how to achieve this effect.

Basically i have a VIEW of a content type PICTURE. In the view a main Image is displayed and 3 other images displayed below it, i want to have an effect when a user hovers over one of the 3 images below then the main image shows that image, it doesnt matter if the image stays there or goes back to its original once users mouse goes off the image, but just having it change is what im struggling with. I see this effect done on Amazon as a good example.

Anyone have any ideas? Or even maybe a name for this sort of JQuery effect so i can search for it and try to implement it in to my Views TPL file or something?

Thanks a bunch


texts: Can cookies safely be stored in the public filesystem (sites/default/files)?

texts: One of my modules does some CURLing, and to do this it creates a cookie on the Drupal server. Where should I locate this? Where it will be nice and safe? Is there a convention? Is sites/default/files considered safe?


texts: Use hook_webform_submission_presave () to edit the SID of a Drupal webform

texts:
I'm working with Drupal 7 and I've created a module called uvic. What I'm trying to do is to restart the SID when a form is cleared but it isn't working, what I'm doing wrong?

function uvic_webform_submission_presave($node, &$submission) {

   $result = db_select('webform_submissions', 'sid')
   ->fields('sid')
   ->condition('nid', $node->nid)
   ->orderBy('sid', DESC)
   ->range(0,1)
   ->execute();
   ->fetchAssoc();

if($submission->nid == $node->nid){
  if ($result) {
    $submission->['sid'] = $result['sid'] + 1;
  } else {
   $submission->['sid'] = 1;
  }
}

$component_id = 4;
$submission->data[$component_id][0] = 'foo';

}

Thanks in advanced.


texts:
we've wanted to implement a policy to consider some URLs as whitelist, I've provided a config form to admin to enter whitelist Urls, separated by newline, it must support * ( wildcard).

sample urls are

/user/*/edit
/coming-soon

and my implementation

$config = $config_factory->get('mint_coming_soon.softlaunchconfigadmin');

$white_route_list = $config->get('white_path_list');
$white_route_list = $white_route_list ? preg_split("/\\r\\n|\\r|\\n/", $white_route_list) : NULL;
$is_white_route = FALSE;
foreach ($white_route_list as $route) {
  $route_name = $this->pathValidator->getUrlIfValid($route);
  $route_name = $route_name ? $route_name->getRouteName() : NULL;
  drupal_set_message($route_name);
  $current_route_name = \Drupal::routeMatch()->getRouteName();
  if ($current_route_name == $route_name) {
    $is_white_route = TRUE;
    break;
  }
}

$this->pathValidator->getUrlIfValid doesn't work on URLs with the wildcard, my question is how can I get the route name of Url which contains a wildcard?

Notice: wildcard in this question is particularly *.


texts: Core search, when only one result, open result

texts:
Is there a simple way to accomplish the feature in the title ?
When a search results in one result, don't show the result but go directly to the node.


texts: What entity should entity_id be joined on?

texts:
I'm writing a complex custom query to get order information from a Drupal Commerce install for export.

The table field_data_commerce_customer_address has a column entity_id. I've tried to join that field on order_id, but my results are incorrect. It doesn't match to user id... hmm.

What field should I join entity_id on?

And, more generally, is there a drupal entity informational function that would tell me what columns should be joined to what? Or a master entity table, or anything? Some central location that would tell me things like this so I don't have to dig around?

Looking around the database and googling but haven't found it yet.


texts: Minimally working end-to-end example of drush batch job execution

texts:
I'm trying to make drush run my batch jobs. There's some amount of documentation at Processing batch jobs with drush, however, I can make no sense of it.

I would like to see real code, and the CLI requirements/instructions for running it, that when called by Drush, prints something trivial, such as "Hello world", once per operation.


texts: Approach of building a website for local basketball league?

texts:
I am asked to build a local basketball league website.

Functionality is quite simple:

League news/articles
Different team page with team news, player info, gallery
Each player has profile. such as name, height, position, photo.

Module OG seems to be a good match in this case, but I am wondering if it can be done without OG.

Are there any other easier approaches?

Thanks for any suggestions!


texts: How to apply suggested theme hook using hook_theme_suggestions_HOOK?

texts:
Following this answer,  I'm trying to override core/themes/seven/templates/node-add-list.html.twig using hook_theme_suggestions_HOOK.

So, I added the following function in modules/custom/domain_filter/domain_filter.module

function domain_filter_theme_suggestions_node_add_list(array $variables) {
  $suggestions = [];
  $suggestions[] = 'node_add_list__' . 'custom';
  return $suggestions;
}

I created the custom twig file in my module: modules/custom/domain_filter/templates/node-add-list--custom.html.twig

The suggestion appear well in theme debug but it's not applied (the x is in front of node-add-list.html.twig):

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'node_add_list' -->
<!-- FILE NAME SUGGESTIONS:
   * node-add-list--custom.html.twig
   x node-add-list.html.twig
-->

How to apply node-add-list--custom.html.twig?


texts: Modifying Drupal core (search module, image module)

texts:
I have a couple of modifications I did to the Drupal core:

search module: I added a class to the <ul> that contains the "no-results" text.
image module: I changed the 'title' attribute to have a #maxlength of 500 for a specific content type, so that only nodes of that type can have a longer 'title'

The question is: how would I do that without modifying the Drupal core? Is there a way of overriding those default outputs in a custom module? I'm looking for a way of doing that without touching the core, or to confirm that a modification in the core was the only feasible way.


texts: Display default image if the image isn't set

texts:
Case

A custom image field has been added to the user entity, this field contains a default image for users, which should display if an user doesn't add an image. This field is used on multiple templates across the site.

Problem

Only at the user's profile page is the default image displaying when the image is not set (if set will show the image).
Node templates and other entities will not display the default image. I tried to display the field with theme_image() with no success.

Question

Why won't it display the default image?

When I dump the information about the fields attached to the current user, the field_picture is an empty array if the user has no image set. When the user does have an image set it will return this

Setup

Field name: field_picture
Field type: picture
Field module: default image field module.


texts: Are edited files in core modules overwritten on updating Drupal?

texts:
I have searched related questions but could't really find a decisive YES or NO.

I changed a few files in core/modules/user/ ... to alter the display of the form used on my site. For example:

 $form['account']['name'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Username'),
      '#maxlength' => USERNAME_MAX_LENGTH,
      '#description' => $this->t(''),
      '#required' => TRUE,
      '#attributes' => [
        'class' => ['username'],
        'placeholder' => $this->t('Username'),   // ADDED THIS
        'autocorrect' => 'off',
        'autocapitalize' => 'off',
        'spellcheck' => 'false',
      ],
      '#default_value' => (!$register ? $account->getAccountName() : ''),
      '#access' => ($register || ($user->id() == $account->id() && $user->hasPermission('change own username')) || $admin),
    ];

  Do these edited core files revert back to their original state thus deleting my changes when I update Drupal in the future?


texts: Profile2 Registration Path module integration with LoginToboggan Non-authenticated role

texts:
I have a site where there are 2 independent user roles, USER_TYPE_1 and USER_TYPE_2. Profile2 RegPath module gives me the two unique registration pages for unique role assignments. With LoginToboggan, all new users get a 3rd type of role, NON_AUTHENTICATED, which is removed after verification.

I'm looking for users to get limited permissions (non-authenticated role) before verification, then more permissions (USER_TYPE_2 or USER_TYPE_2 depending on which registration form they used) after verification.


texts: Programmatically create a node with alias and menu item using Entity API

texts:
I've seen the excellent documentation on Drupal.org about how to create a node in code, but that documentation doesn't address how to create the node's alias.  I've seen code snippets that use $node->path; and $node->menu with node_save($node); which works, but with $entity->path->set(); or with $entity->menu->set(); I'm receiving the following error message:

  Unknown data property path.
  Unknown data property menu.

Why does this not work with entity api and how can I modify my code (below) to make it work?

<?php
/**
 * Testing programatic content creation.
 */
function mymodule_update_7000() {
  $about = _create_node_and_menu_item('About', 'about', 'main-menu', 'About the site');
  dpm($about);
}

/**
 * Helper function creates a node, with alias, and menu item, and
 * returns the mlid.
 * @param  string  $title      the title of the node
 * @param  string  $alias      the URL alias
 * @param  string  $menu_name  the machine name of the menu, eg 'main-menu'
 * @param  string  $menu_title the title of the menu item, if none is
 *                             provide, the $title will be used.
 * @param  integer $plid       the numeric id of the parent menu item
 *                             (defaults to 0).
 * @param  integer $uid        the numeric user id (defaults to 1)
 * @param  string  $body       the body copy to use on the node, defaults
 *                             to lorem ipsum.
 * @return Entity              the node entity object that was created.
 */
function _create_node_and_menu_item($title, $alias, $menu_name = '', $menu_title = '', $plid = 0, $uid = 1, $body = '') {
  if (!$body) {
    $body = '
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus
';
  }
  $node = entity_create('node', array(
    'type' => 'page',
    'uid' => $uid,
    'status' => 1,
    'comment' => 1,
    'promote' => 0,
  ));

  // Get a wrapper for adding meta-data.
  $entity = entity_metadata_wrapper('node', $node);
  // Using the wrapper, we do not have to worry about telling Drupal
  // what language we are using. The Entity API handles that for us.
  $entity->title->set($title);
  $entity->body->set(array('value' => $body));

  if ($alias) {
    // FIXME this line is broken :'(
    $entity->path->set(array('alias' => $alias));
  }
  if ($menu_name) {
    if (!$menu_title) {
      $menu_title = $title;
    }
    // FIXME this line is broken :'(
    $entity->menu->set(array(
      'link_title' => $menu_title,
      'menu_name' => $menu_name,
      'plid' => 0,
      'enabled' => 1,
    ));
  }
  // Save the entity and its meta-data.
  $entity->save();
  return $entity;
}

I realize there are other ways to create a path using path_save(), but this is predicated on knowing the node id first.  A valid answer here would show how to do this purely with Entity API and one call to $entity->save(). Is it possible?


texts:
I am trying Omega and wondering if there is a way to specify the size of the Youtube video in grid terms, so I could easily show few videos next to each other (in a view for example).

Or if there is a way to make video automatically fit within a cell of a view?


texts: Access denied for unpublished content in drupal 7

texts: When i unpublished a content in drupal 7, I am getting an access denied message. But for some other unpublished content i am getting page not found message. I need page not found message to all unpublished content. How can i do that? Thanks


texts: Unable to change the widget for a webform coponent

texts: When editing a webform component (7.x-4.23) selecting a different widget type (e.g. from email to hidden) has no effect.


texts:
Drupal allows spaces in usernames, is there an easy way to stop this?

Also, where is the documentation on the username specs? What are the min/max lengths and which characters are allowed?


texts: I use an Omega subtheme in my Drupal 7 site, and I'd like to change the default font to a custom font. How can I do this?


texts: Current password required to change password for self-registered users. No password was ever set

texts:
I cannot figure out how to validate users through email using drupal.

at admin/config/people/accounts I have Require e-mail verification when a visitor creates an account checked, and under Who can register account I have it set to Visitors.

When I go to create a new account, it says a success message and no email is sent. No errors, nothing in the logs. If I request a password, it sends that email no problem. I can also change my password without entering a current password when using the request password link. So the site is sending emails, just not validation/registration emails.

I have to use rules in order to send the registration emails because the emails are not sending and we have a deadline. I got rules to successfully send the emails but the one time validation link does not exist in the email.

I had to then download Login One Time in order to show a validation link in the email.

After clicking the email and successfully logging in as that newly created user, I am unable to change my password because the form is asking for a current password, which is not available for the user to even populate at the registration step.

I have tried using logintoboggan and tried generating temp passwords to send to the user but the token provided by login-toboggan shows up as nothing when the email is sent.

I am seriously confused as to why this is such a difficult process to achieve. Is email validation this difficult out of the box with drupal?

Does anyone know why drupal is prompting me for the current password for newly created users?

Is there something I am missing as to why only registration/validation emails won't fire from my website, but other system emails do?


texts:
I've started learning Drupal 8 and I have question about file directories.

Previously on D7 I've set directories like this:

files - /sites/all/files

modules - /sites/all/modules

themes - /sites/all/themes

Usually I don't make multisites, so can I set directories like this for D8?

files - /files

modules - /modules

themes - /themes


texts: How can I find out a list of available $string values for user_access($string) function?

texts:
user_access($string, $account = NULL)

  $string: The permission, such as "administer nodes", being checked for.

How can I find out a list of available $string values for user_access() function?


texts: how to put markup around indiviual radio buttons

texts: Is it possible to set the markup (#prefix and #suffix) around individual radio buttons? I know that I can add these fields to the radio button group, but that would mean that I would be wrapping the entire group, which is not what I want to do.


texts: Module development - integrating custom content types

texts:
I want to create a module which would need custom content types from the cck module. I know in the .info I can say a dependency is the cck module.

How can I best have the module create the content type? I want this to be easily distributed rather than when I put it on a website I have to also create the content type using cck.


texts: "drush config-split:export" returns "Not enough arguments (missing: 'split')."

texts:
I recently upgraded from Drupal 8 to Drupal 9. I've used drush config-split:export (drush csex) quite often. After the upgrade, it keeps throwing an error which is very vague.

Not enough arguments (missing: "split")

No documentation says what the problem is, nor what that argument should be.
Any help would be much appreciated.


texts: Override templates in profiles templates

texts:
in drupal 8 I'd like to be able to override a template found at the root of Drupal in profiles/name/modules/menu/template/menu.html.
I tried to put it in the child theme in templates/ but both templates are taken into account, so my menu appears twice.
How can I fix this problem?
Thanks in advance


texts: Registration form in a popup window (colorbox or jQuery ui)?

texts:
How to embed a registration form in a popup window?

I would like to use Colorbox or jQuery UI:

drupal_add_library('system', 'ui.dialog');


texts:
I am trying to create an autocomplete field for users.  The following code is fine for username searches but the requirement is for a search by any part of the user's first and last name.

$form['user'] = [
  '#type' => 'entity_autocomplete',
  '#target_type' => 'user',
  '#selection_settings' => [
    'include_anonymous' => FALSE,
  ],
];

I am wondering what the best way to filter by first and last name is.  Is it even possible to use 'entity_autocomplete'?  It doesn't look like any of the EntityAutocomplete class methods would make this possible and I'm not clear on whether or not the '#selection_handler' and '#selection_settings' properties could be helpful.


texts: Kernel Test: How can I get an overridden config value from settings.php

texts:
In my settings.php file i have a custom configuration that is changed on a per site basis, e.g. $config['brand_id'] = 1

I have a function that will fetch that value, and I am trying to setup a kernel test for it. When I try to fetch the config, it returns null.
When I try to setup the config and save it, I get the error Missing namespace in Config object name 'brand_id', which I believe is because there is no . in the name (e.g. brand.id). If i add that it then tries to look for a schema to validate against, which I don't have as it is just in the settings file.

Is there a way to fetch or set this value in the test, or am I forced to setup a config yaml file just to make this testable?


texts: Using pathauto to create multiple aliases, one for each term?

texts:
If I have a taxonomy tags so that I can tag a node with foo and bar and baz, is there any way to make the pathauto module create three aliases?

If it would normally create content/my-new-node, is it possible to make pathauto create foo/my-new-node and bar/my-new-node and baz/my-new-node?


texts: How to set default value for entity reference field in hook_form_alter

texts:
following snippet doesn't   set the default value.

 $form['field_image']['#default_value']='default';

I Have content type called image and I'm trying to set the default value for a reference to it in another content type.  The above code doesn't work.  Printing out the form variable doesn't make it seem like an easy task.