texts:
I have a button element in form builder as follows

$form['fieldset']['add_new_event_btn'] = array(
  '#value' => t('Add new event trigger'),
  '#type' => 'button',
  '#attributes' => array(
    'style' => 'margin-top:20px;width:200px;margin-right:275px;float:right',
  ),
  '#ajax' => array(
    // Function to call when event on form element triggered.
    'callback' => '::enable_event_trigger',
    // Effect when replacing content. Options: 'none' (default), 'slide', 'fade'.
    'effect' => 'fade',
    // Javascript event to trigger Ajax. Currently for: 'onchange'.
    'event' => 'click',
    'progress' => array(
      // Graphic shown to indicate ajax. Options: 'throbber' (default), 'bar'.
      'type' => 'throbber',
      // Message to show along progress graphic. Default: 'Please wait...'.
      'message' => 'loading',
    ),
  ),
);

But this button is act as the submit button , and there for the validation for other elements works and shows the error message on the next reload when i leave the page as it is, How can i rectify this problem ??


texts: Removing Queue Table Items / Queue UI Module D7

texts:
While attempting to export the mysql database, I found that there was a large number of items in the drupal 7 queue tables "feeds_importer_expire" and "feeds_source_import", both have about 80,000+ records dating back over a year.

I have installed the Queue UI module but have a question before I proceed.

In the "Queue Manager" at "admin/config/system/queue-ui" there is a delete queues button. If I delete the queue e.g. "feeds_importer_expire" will it regenerate the next time it is needed? Or am I deleting the queue all together and causing major issues.


texts: How to weight a block above a custom form

texts:
I'm creating a page with a form with the hook_menu:

function my_module_menu() {
  $items['rsvp'] = array(
    'title' => 'My Page',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('my_module_form_search'),
    'access arguments' => array("access content"),
    'access callback' => TRUE,
  );
}

I also have created a block that is to display in the content area of the rsvp page. Right now the form shows above the block. How do I reverse that?


texts: Possible to save form "field by field" as soon as a user changes a field instead of pushing a save button at the end of the form?

texts: Instead of pushing a save button, I would like to save user input as sooon as a field is changed. Similar to how mobile apps works. Is this possible in Drupal?


texts:
Is it possible for a Drupal Ajax form to automatically fire a callback when a page is loaded?

I know this is possible using an external JS file and doing it through Drupal behaviors, however I would prefer to be able to do is straight from the Drupal form callback as this allows for less code and more security.

I am trying to do something like this:

$form['mark'] = ['#markup' => '
REPLACE ME
'];
$form['test'] = [
  '#type' => 'textfield',
  '#title' => 'My Title',
  '#ajax' => [
    'callback' => '::callback',
    'event' => 'load',
  ],
];

The load event doesn't work, which makes me think Drupal doesn't want to allow this type of functionality. When I use something like click or mouseout it does work. Is there some type of event here that I can use that will fire this ajax callback when the form loads? Or is it not possible this way?


texts:
I have created some custom page on frontend for particular type of node modyfications. Here's my page callback:

function vintranet_talk_edit_entry_page_callback($sNid) {
    module_load_include('inc', 'node', 'node.pages');

    $oNode = node_load($sNid);

    return drupal_get_form('page_node_form', $oNode);
}

My node has one field with file attachments.

Config:

'vintranet_talk_attachments' => array(
    'field_name'     => 'vintranet_talk_attachments',
    'label'          => t('Attachments'),
    'type'           => 'file',
    'cardinality'    => -1,
),

Instance:

'vintranet_talk_attachments' => array(
    'field_name'     => 'vintranet_talk_attachments',
    'label'          => t('Attachments'),
    'entity_type'    => 'node',
    'bundle'         => 'intranet_talk_page',
    'widget'         => array(
        'type' => 'file_mfw',
    ),
    'settings'       => array(
        'max_filesize'       => 10,
        'file_directory'     => 'intranet/talk',
        'file_extensions'    => 'jpg, png, gif, pdf, zip, doc, rtf, xdoc, rar',
        'description_field'  => 1,
    ),
    'display'        => array(
        'default' => array(
            'type' => 'file_table',
        ),
    ),
),

My first problem is, when I want to upload JPG file after module installation, system sends me this message:

So ok... I'm going to check that particular field settings in Structure and I see this:

Why the hell it is saved like this?!

Okaaaaay.... so I'm changing this form field value on jpg, png, gif, pdf, zip, doc, rtf, xdoc, rar, saving and trying to upload the image one more time...

....clickin "Upload" button.... aaaaandd....

....yup.... that's my 2nd problem :/. Have no idea why it's not working. On the backend, in other hand, the "Upload" button works perfectly. Am I missing something?

(working on Drupal 7.31 version)


texts: Where to find custom Content type related files in Drupal directories?

texts:
I have a localhost Drupal 7.x installation on my system. I have just explored with UI and created a custom Content type which defines a form with radio boxes. (Home --> Structure --> Content types --> Add Content Type, and so on.)

I am assuming these custom content types will be stored in local directories of Drupal core. I am not able to figure out where exactly these stay. I am curious to make changes to that file and see if there is any reflection, though I am not sure if it works that way.


texts: User field imported with Feeds but not showing in user edit page?

texts:
I'm using Feeds Importer to create users from a csv file, in my Drupal 7 site.

It works perfectly, except one case. I added some custom fields to user profile and I can set all them with my importer, except one (a simple text field, let's say 'foo').

The value for 'foo' is correctly imported: if I open the 'View' page for a user profile I can see it, listed as supposed. In the 'Edit' page of the user profile, however, the value of the field is showed empty. If I modify the value in this edit page and save, the value is stored AND showed in the edit page.

I tried even to create another custom field similar to 'foo' and it works perfectly in any case. (I can't delete foo and recreate it for it contains several data)

How could this be debugged? I checked the csv, the importer, even the database (in the table field_data_field_foo the value is stored correctly), and all seems fine. No error in drupal log, neither in importer log.


texts: Make a block display in one page and not in other

texts:
I am using Drupal 7 with omega and adminimal theme. I use adminimal theme for my iframe in the site (using entity iframe module). I would like to display a block in the adminimal theme alone, but not in my omega theme.

I used the default block settings, "Only the listed pages", but this display the block in both the themes.

So is there a way to configure the display options per theme?

Any help would be widely appreciated.


texts:
it is a simple question. Probably the answer is simple too but it stole my 2 hours.

I have a contenty type: Article.
When i create a content from it normally it shown a default display.

I want to create a view and control this display from it.
How can i do that.. what should i write to url part in my view?


texts: hi guys any of you experience having problems regarding memory exhaustion when running a drush command? I made a batch to add taxonomy and do a node_save after to all nodes (a lots of nodes) i've set the limit on settings.php to 1GB and still no luck, it always throws an error regarding memory exhaustion.


texts:
Panels is one of the most useful modules for Drupal and many websites make use of it.
However I always have been cautious using it because of its processing overheads.
I want to know is there any benchmark or article about Panels efficiency on the net?

Thank you.


texts: I have created a platform on my aegir dev server and I found myself wondering once the platform in drupal7 is installed is there a way to create websites using that platform via the commandline.


texts: How do I add AngularJS Material to existing Drupal/Angular app correctly?

texts:
I've inherited a somewhat complicated application that injects form partials into a master page (all managed by Angular) on a Drupal site. We're using the AngularJS Drupal module, Drupal is 7.x Angular is 1.3.4.

Right now the .module has this:

drupal_add_library('angularjs', 'angularjs');
drupal_add_js('https://ajax.googleapis.com/ajax/libs/angular_material/1.0.9/angular-material.min.js', 'external');

This seems to work ok, all the scripts are loaded on the rendered page w/ jQuery first and then src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.js?v=1.3.4" and so on; including animate, aria, and messages. Lastly, material is loaded.

In app.js the module is declared and reused per this error page looking something like this:

angular.module('myModule', [])
  .service('myCoolService', function () { /* ... */ });

angular.module('myModule')
  .directive('myDirective', ['myCoolService', function (myCoolService) {
    // This directive definition does not throw unknown provider.
}]);

The module declaration looks like this:

var myapp = angular.module('myapp', ["ngRoute", "ngAnimate", "ngCookies", "ngMessages", "ngSanitize"]);

Aside from me adding material this all worked before I got to it so I'm reasonably confident this is correct. Once I add material:

    var myapp = angular.module('myapp', ["ngRoute", "ngAnimate", "ngCookies", "ngMaterial", "ngMessages", "ngSanitize"]);

I get a bunch of unknown provider errors, looks like one for each item:

Error: [$injector:unpr] Unknown provider: $$jqLiteProvider <- $$jqLite <- $animateCss <- $$mdAnimate <- $mdUtil <- showDirective

Notice it seems to be looking for jqLite now instead of using jQuery. I don't think it's version, according to the material docs, all 1.x versions are supposed to work with Angular 1.x. I've tried putting ngMaterial in different spots in the order with no luck as well. I'm sure I'm messing up the service injection somehow but I'm not sure how.


texts: use conditional fields to change a label on a field

texts:
Is it possible to change the label on a field using the conditional fields module.  What I want is to call a field "Effective Date" in one case and "Published Date" in another but have it be the same field.

is that possible with the conditional fields module or any other module?


texts: Web services in drupal7 for user profile

texts:
I am new to drupal cms.
I am using drupal7. I created user registration page with profile content. now i want to insert or update or add information through web services. I am using REST server. Earlier i used to get the services for nodes,taxonomy terms,files with something like this /localhost/drupal/endpoint/node or taxonomy_term . But, i am unable to find the way how to get or post data in to profile content. Is there any solution. ?

Actually what i want is, to store(POST) multiple user profile information and would like to (GET or RETRIEVE) the data...


texts:
I have made a 3d Hover effect for a Team Members about page. When you hover over a photo it flips like a box and reveals peoples credentials. I want to be able to make the div link to the team members content (the page that goes further into depth about each individual team member). I have re-written the code like so:

          [field_photo]

 [title]

 [field_position]

I tried linking it like:  . Unfortunately, no luck... I saw that I could make a php function but there must be an easier way !! if anyone could help me out that would be greatly appreciated (=


texts: How can I change the name attribute to "email" in the user login form?

texts:
Users do not always login with their Drupal user name but in some projects by email for example.

What would be the Drupalitically correct way in this case to change the "name"-Attribute of the user name login text field in the user login form? For example to change it to "email" so that a HubSpot JS Snippet would recognize login form submissions? How would this be done in both Drupal 7 and Drupal 8?


texts:
I'm trying to create a conditional twig function in a template I created for my website's home page (page--front.html.twig). Twig can supposedly do this out of the box, but I can't get this approach to work. The h1 is not being rendered, and no errors are being thrown. Here's the resource I used: http://enarion.net/news/2012/access-cookies-in-a-twig-template-using-symfony2/

In my template, I've added the following code:

{% if app.request.cookies.has('loader-activated') %}

You have chosen your cookie brand!

{% endif %}

I'm using Cookie.js to declare my cookies. I've confirmed that it is working using a Chrome extension:

Am I doing something wrong? I'm not strictly a developer, and have very limited abilities with Drupal 8 templating, so I'm sure it's something pretty obvious. If app.request.cookies isn't the best approach, what else should I use? I'd prefer that it is something simple, if possible!


texts: How to grant referenced user access to Profile page

texts: I use Node access user reference module in many projects. I have a very similar task: Grant access to a profile page for those user who is referenced in that profile. Unfortunately, Node access user reference doesn't work in this case, since it's not a node but a different kind of entity. Is there any solution for this task?


texts: Pricing changes based on line item fields in the add to cart form

texts:
I've been using commerce_custom_product to add custom line items options to products I'm selling in the shop. The shop is selling servers and if someone when adding a server to their cart wants a bigger hard drive for instance they select it in the "add to cart" form. I want to alter the price of the line item based on which option they select

e.g.

20gb HDD $40
40 gb HDD $70

The hard drives and other things are not really properties of the product I'm buying. They are options I'm selecting for the product. This is why I looked at commerce_custom_product.

Ultimately this question comes down to How can I set the product price based on choices made in the Add to Cart form. Is commerce_custom_product the way forward with something else bolted in? I'm very happy to code if there is a hook I could use to grab the price from the referenced entity if I was to add price to the entities that get selected in the add to cart form


texts:
In my module

    function hook_page_attachments(array &$page) {

      $og_image = array(
        '#type' => 'html_tag',
        '#tag' => 'meta',
        '#attributes' => array(
          'property' => 'og:image',
          'content' =>   'http://example.com/pic.php?id=839813.jpg&size=300',
        ),
      );

      $page['#attached']['html_head'][] =  [$og_image, 'og:image'];
}

On the page the results look like this

<meta property="og:image" content="http://example.com/pic.php?id=839813.jpg&amp;size=300" />

The & is replaced for html use. Can I avoid that or added meta tags in another way?


texts:
I have created a View page, and added a "Global:PHP" field to embed a View block from another View using the following code:

<?php  print views_embed_view('VIEW_NAME','VIEW_BLOCK_NAME', $data->tid);?>

Now, it worked perfectly, but there's no detail or variables I can find in the print_r($data)/dsm($data) about this View block's content.

My purpose is that, if there's no result in view block, then I will hide a particular custom field. In short, "if views_embed_view() return empty then hide field A

Wondering how to go about it. Please advise. Thanks!


texts: Overwrite Taxonomy Term page display settings with custom URL's

texts:
I would like to define the display settings of my Taxonomy term page. As I understand, this is possible by configuring the Taxonomy view provided by the Taxonomy module.

However, I use custom URL's and by so, my taxonomy pages doesn't have the URL taxonomy/term but something like products/tents.
Is there a way to customize these pages with the provide view?


texts: Adding Values to Header Drupal 7 + .htaccess

texts:
Well, I'm new to Drupal, I was wondering if I can add values to header?

Note: this is the code for my mysite.com

I got this piece of code in mysite.com

<?php

    if (isset($_GET['code'])) {
    echo $_GET['code'];
    }

?>

So for example,

Drupal URL:

mysite.com/U2pVnWK

If I run that URL, it redirects me to PAGE 404

So I tried this, URL:

mysite.com/?code=U2pVnWK

Which it eventually works.

So I tried using RewriteRule thing in .htaccess and added this code

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+)$ index.php?code=$1

Even change it into

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+)$ ?code=$1

Also

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+)$ http://www.mysite.com/?code=$1

None of it works.

Plus I don't know where to put that piece of code in existing .htaccess that Drupal made it.

So to simplify, what I want is:

If I access mysite.com/U2pVnWK I would be able to retrieve and echo  U2pVnWK instead of redirecting to PAGE 404 PAGE

Any help would be appreciated. :)


texts: How can I manage site translations in code?

texts:
I have a site with multiple translations, including a heavily customized version of the default Drupal "English."  (The use case requires that a lot of the help text and labels throughout Drupal be changed.)

I am using the Features module to manage deployment.  However, I can't find a way to manage translations in code.

Currently, I visit the Languages page, click export, download the .po file for each type (built-in interface, node types, taxonomy) for each language, and then commit these downloaded files to code.  This seems extremely inefficient compared to working with Features.

I looked for a Drush command to help but the 5.0-rc3 version which I'm using doesn't have any i18n-related commands.

How can I manage site translations efficiently in code?


texts: Pre-Populating a Form Field with something other than its default value

texts:
I'm having a strange problem. I am constructing a form with checkboxes to toggle email subscription preferences on and off. For the new user sign-up form, this is straightforward:

$form['marketing-container']['restaurant_newsletter_subscription'] = array(
    '#type' => 'checkbox',
    '#title' => t('Subscribe to Restaurant Newsletter'),
    '#return_value' => "True",
    '#default_value' => "False",
);

However, when it comes to the update user form, I'm running into a problem. If I set #default_value to the existing preference, it will check the boxes for those publications you're subscribed to correctly, but if you UNcheck those boxes, the form API just returns the default value....which would still be TRUE.

To work around this, I retrieved the subscriber object at the start of the form function, and I've added hidden fields whose default values are the existing subscription preference values, just like I attempted to do with the real fields in the first place. Then, I used #states to populate the real fields based on these hidden fields, like so:

$form['marketing-container']['existing_restaurant_newsletter_subscription'] = array(
    '#type' => 'checkbox',
    '#title' => t('Restaurant Newsletter'),
    '#value' => $attributes[15]->Value,
);

$form['marketing-container']['restaurant_newsletter_subscription'] = array(
    '#type' => 'checkbox',
    '#title' => t('Subscribe to Restaurant Newsletter'),
    '#return_value' => "True",
    '#default_value' => "False",
    '#states' => array(
        'checked' => array(
            ':input[name="existing_restaurant_newsletter_subscription"]' => array('checked' => TRUE)
        )
    )
);

Now this works! The problem is that the first field is visible. Now if I alter this to hide the field:

$form['marketing-container']['existing_restaurant_newsletter_subscription'] = array(
    '#type' => 'checkbox',
    '#title' => t('Restaurant Newsletter'),
    '#value' => $attributes[15]->Value,
    '#access' => FALSE,
);

The field is hidden perfectly....but its value isn't copied over to the real field that's still visible.

I've searched all over and pored over the Form API documentation, and I'm stumped.

Is there some way to preserve this default value inside the hidden form so it copies over to another field correctly?

If there isn't, or if it's more efficient, is there a DIFFERENT method I could use to pre-check this checkbox but still keep a default value of FALSE so that if a user unchecks it, something actually happens? Is there another class of field I'm missing that is a sort of on-off switch that returns specified values for each state?


texts:
I've been trying to install Open Atrium for at least 6 hours and cannot find a solution. There seems to be a permissions problem…

Here's where I'm at: I successfully installed a Ubuntu VM, and installed Drupal 6. I then downloaded Open Atrium, copied its contents into the example.php folder. I then went to the default folder and changed the settings file to settings.php, etc. Install Atrium launches through Firefox, but then says:

Forbidden

You don't have permission to access / on this server.
Apache/2.2.16 (Ubuntu) Server at example.dev Port 80

Update:

I installed everything using the drush commands per quickstart tutorial. I created the example1.dev folder, then replaced its contents with Open Atrium. I then renamed the Default.install.php file to install.php, and created a files folder inside default.

I'm not sure why I'm having this problem, but it looks like a permission issue with the file folder. I can't figure out how to open up read/write permissions through Ubuntu. Any ideas?

I followed these directions verbatim, and wiped out the appliance and started over a few times as well. I'm at a loss. I think if I knew how to open permissions to Apache I'd be all set. Any ideas?


texts:
I am building a social network with Drupal. I have the following requirement:

A person who adds a post can tag his friends when adding his posts.
His tagged friends can untag themself when viewing the post.

Requirement #1 was met by the amazingly efficient entity reference view widget (see my recent answer).

But how to achieve requirement #2 ?

What is the best way to implement such a feature?

Is there any inline editing tool (such as the edit module) for entity reference fields?
Does editablefields really works for Drupal 7?
Should I just implement it using the Rules Link module?
Any other approach?

Please advise.


texts: open a lightbox2 containing a flowplayer video from a menu link

texts:
Is it possible to make a link from a main menu to open a lightbox2 that will contain a flv video?

I have flowplayer installed but not swf tools

I thought of doing it with javascript but I'm sure there is another way


texts:
Hello Drupal community,

I'm finding some issues in a tamper used in feed's module. I want spaces to be deleted in a field that contains numbers. Something that changes "00 00 00 00 00" into "0000000000".
I've tried the following :

    Regex to find : #(\d{2})[ ](\d{2})[ ](\d{2})[ ](\d{2})[ ](\d{2})#
    Replacement pattern : $1$2$3$4$5

Note that the expression was validated in https://regex101.com/ :

But it doesn't seem to work.
Anyone please ?


texts: Wrong Javascript order: Undefined variable: jQuery

texts:
Since I moved all scripts form the header to the bottom of the page (in the template file of my theme) I have the problem that some scripts of contributed modules (chosen and device geolocation from smart ip) are added before the JQuery library. Using Jquery this leads to an error:

Undefined variable: jQuery

What can I do to get the right order and what could be the reason of the fact that the order is only wrong when the scripts are added at the bottom of the page and not in the header?


texts: How to restrict JS applied to a block only to block visible pages?

texts:
I am using Drupal 6. I have added the javascript to my block using hook_theme as shown below.

function theme_custom($text) {

        drupal_add_js(drupal_get_path('module', 'mymodule').'/sample.js');
        $output =  t($text);
        return $output;
}

I am using $(document).ready(function() { ... }); in my sample.js. I want this js to be loaded only on the pages where the block is set to be visible, but drupal loads this js on all the pages. This makes my script to run on all the pages, increasing the load to the server on every page load. So, how to restrict this js to be loaded only where the block is visible? Any help is much appreciated.


texts:
I have a "Opinions" in my main menu that appears in main menu block in first page. I want to do something that when I click to "Opinion" in goes to a page that has 2 links: "articles" and "others". I mean I click to Opinions and after that I can select articles or other and they go to article page and other page (articles and other are my taxonomy terms)

I don't know what should I do?


texts: How to update current url of view page so that it will filter correct result?

texts:
I have created view to search nodes of video from content type channel. I have set the URL as channel/%/search in view. when redirected to the page the the URL will be channel/all/channel-search?title=test. But I want to replace 'all' with 'nid' which I have got by php code. In short I want to replace channel/all/channel-search?title=test with channel/*NID*/channel-search?title=test (nid may be anything channel/26). I have written the code in views contextual filter but it is not working.

$path = $_SERVER['HTTP_REFERER'];
$filter = preg_replace('///','',parse_url($path,PHP_URL_PATH),1);
$path = drupal_lookup_path("source", $filter);
$node = menu_get_object("node", 1, $path);
$nid=$node->nid;
return $nid;


texts: How can I display the values returned from an external API under a form?

texts:
I have created a custom module that pulls in data from an external API. Users select a few values on a form; submitting the form makes a call to the external API. The module then displays the data, which has been filtered by the values entered from users.
I have been able to show the returned data with \Drupal::messenger()->addMessage(), but this doesn't seem the right method. I've found a few other suggestions, but I can't get any of them to work. They are for older Drupal versions.
I'd like to be able to display the formatted results under the form, on the same page.
How can I achieve this in Drupal 9?


texts: Custom sort to preserve order of referenced nodes

texts:
I have a node type that references other nodes. When viewing node of Content Type A, I have set up a view that displays all references to nodes of Content Type B on a gmap.

This is the code from a template file that overrides the display of view_one; it calls the map in from another view.

<?php
  $view = views_get_view('view_one');
  $view->set_arguments(array($fields['nid']->raw));
  $view->execute();
  $contents = $view->result;

  foreach($contents as $content) {
    $nodes[] = $content->node_field_data_field_B_content_nid;
  }

  if (isset($nodes)) {
    $args = implode(',' , $nodes);
    $view = views_get_view('linked_map');
    $view->set_display('map');
    $view->set_arguments(array($args));
    $view->execute();

    $markup_map = $view->render($args);

  }
  else {
    $markup_map = '';
  }
?>

It displays beautifully. The only problem is I want to use numbered markers, so that the list is in the same order as the referenced nodes in the main view ("view_one"). Is there some way that I can either utilize a "sort" that won't rearrange the list, or write a custom sort that will preserve the existing order?

I am using the Views module version 7.x-3.1.


texts:
My site's core and modules are completely up to date including commerce.
I'm trying to install commerce_paypal via composer require drupal/commerce_paypal.
I've tried --with-dependencies and also (~)versions and (^)versions.
Here is the error...

I have also tried a similar set of commands which worked to get me to core 8.7.7. following a similar doctrine/annotations error, see below...

rm composer.lock
rm vendor -rf
composer clear-cache
composer require --dev drupal/commerce_paypal
composer update

Then I ran: composer why drupal/commerce_paypal and got...

I'm just wondering what I could try next, please?


texts: How can I generate commerce file audio preview automatically?

texts:
In a store of music files with the Commerce File module, how can I generate an audio preview of that file? Would be perfect if I could use the Rules module for detect the adding of file and SOX utility for audio trim (for example the first 20 seconds) and attach the generated file into another field.

If possibile compatible with Media and SoundManager2.


texts: Access custom user field from a different account

texts:
The following works so far:

I can set a custom user field e.g. 'full_name' in Drupal Account Settings
The logged in user has access to this field using the following code.

global $user;
$user = user_load($user->uid); // Fully load the user object
$custom_vars['full_name'] = $user->field_full_name[LANGUAGE_NONE][0]['value'];
echo "My full name is :  $custom_vars['full_name']";

This is what I want to do:

I want to log in as an admin account and for a specific group of
users who's unique IDs know I want to display this field.
So perhaps for userID = (1234, 1175, 14532) I want to see this value
for 'full_name', how do I do it?

I am hoping for a PHP solution that uses code similar to the above rather than a SQL DB call, but if I need to directly access the DB so be it.


texts: why does hook_menu produce a menu that belongs to the system module?

texts:
In my project we implement a little menu that provides information about the module.  This snippet lives in drutexml.module.

function drutexml_menu() {
  $items['drutexml'] = array(
    'title' => 'LaTeX filter implemented via LaTeXML',
    'page callback' => 'drutexml_information',
    'access callback' => TRUE,
  );
  return $items;
}

Actually this is a bit silly, and I want to turn it back off inside the installation profile.  But as it turns out...

SELECT link_path, module FROM menu_links WHERE link_path = "drutexml";

+-----------+--------+
| link_path | module |
+-----------+--------+
| drutexml  | system |
+-----------+--------+

and then in menu.inc, where menu_link_delete is implemented, we see this  bit of logic on line 2997:

if ($item && ($item['module'] != 'system' || $item['updated'] || $force)) { ...

In other words, I can only delete non-"system" links.  That's fine with me!  Or it would be, if my link was stored with the name of the module where hook_menu is implemented in the first place.

What's going on here?  Why is this said to be a "system" link?


texts: How to get a list of Users as values for a select list field?

texts:
How do I get a list of users of a specified role to populate a select list in node/add/* ?

For example when creating a piece of content I want a field "Select Your Moderator of Choice" and the options are a list of all users with the role moderator.


texts: Contextual link missing for particular content type

texts:
I seem to be missing the contextual link (cog) for editing nodes of a particular content type. The contextual links are rendering just fine across a multitude of other content types.

Can anyone point me in the right direction here?


texts: Call to a member function getCacheTags() on null line 1630 of core/modules/views/src/Plugin/views/query/Sql.php

texts:
This error popped up a little while ago and we can't figure out what is causing it to be null or what needs to change. It is caused by a view that is set up as an rest api that you give it a NID.

Most NIDs work but random ones will not and instead throws this error.

Call to a member function getCacheTags() on null in Drupal\views\Plugin\views\query\Sql->getCacheTags() (line 1630 of core/modules/views/src/Plugin/views/query/Sql.php).
Drupal\views\Plugin\views\query\Sql->getCacheTags() (Line: 236)
Drupal\views\Plugin\views\cache\CachePluginBase->getCacheTags() (Line: 113)
Drupal\views\Plugin\views\cache\CachePluginBase->cacheSet('results') (Line: 1428)
Drupal\views\ViewExecutable->execute(NULL) (Line: 1451)
Drupal\views\ViewExecutable->render() (Line: 425)
Drupal\rest\Plugin\views\display\RestExport->execute() (Line: 1627)
Drupal\views\ViewExecutable->executeDisplay('rest_export_1', Array) (Line: 77)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func(Array, Array) (Line: 378)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 139)
Drupal\Core\Render\Renderer->Drupal\Core\Render{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 140)
Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 408)
Drupal\rest\Plugin\views\display\RestExport::buildResponse('story_referenced', 'rest_export_1', Array) (Line: 52)
Drupal\views\Routing\ViewPageController->handle('story_referenced', 'rest_export_1', Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}()
call_user_func_array(Object, Array) (Line: 153)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 38)
Drupal\jsonapi\StackMiddleware\FormatSetter->handle(Object, 1, 1) (Line: 48)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)


texts: Default file upload for a field created in content type

texts:
In Drupal7 we have an option to upload an "default image" while creating a "Image field" in content type. Likewise, I need to know is there is any option to add default "pdf or text file" for "File field". Is there any contributed module to achieve this ? Below I have attached two screenshot to make my question better understandable.

Thanks in advance for your help !


texts:
I have a custom module already installed, and I am trying to add a new table to the database with hook_update_N(). So, I edited hook_schema() and hook_update_N() in the my_module.install file as below.

function my_module_schema() {
  $schema['my_table'] = array(
    'fields' => array(
      'application_setup_id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: ID',
      ),
    ),
    'primary key' => array('application_setup_id'),
  );
  return $schema;
}

function my_module_update_8601(&$sandbox) {
  $spec = array(
    'fields' => array(
      'application_setup_id' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => 'Primary Key: ID',
      ),
    ),
    'primary key' => array('application_setup_id'),
  );
  $schema = Database::getConnection()->schema();
  $schema->createTable('my_table', $spec);
}

I am running drush updatedb to update the database after the changes. No database changes are done.

What am I missing?


texts: How do I remap folder to different folder in URL?

texts:
I have developed website in Drupal. There is folder(e.g., my-demo) which contains few PHP files which are developed in plain PHP. The my-demo directory is placed in the Drupal root directory.

Now I want to access this folder in a menu. If I put http://example.com/my-demo, it is accessible. I want the folder path to be like http://example.com/product-details/my-demo in the menu, without creating the product-details directory, because I have already mapped product-details to a path alias.

How can I achieve this?


texts: How do I programmaticaly get the name/ID of the shipping method for an order?

texts: I need to get the name of the shipping method for a given order in my module. I have the id of the order. After I get the shipping info by means of commerce_customer_profile_load($commerce_order->commerce_customer_shipping['und'][0]['profile_id']) i do get the info about the address, but I do wonder how to get the name / id of the shipping method.


texts: What are the major differences between solr modules

texts:
I am looking into Solr search for my site and am seeing two equally well-used modules.

Apache Solr Search (lots of contrib around this)
Search API Solr Search, built on Search API

Why would I pick one over the other?


texts: Integer field with unix timestamp convert to readable date in views

texts: I have an Integer field in a content type, which contains a unix timestamp.  *(It is not a date module field; just a simple Integer field).  In a View, I am rendering this field, but obviously it is just going to spit out the long unix timestamp; and I want it to read Feb 20th, 2013.  How can I have Views format this field so that it spits out the readable date?  I imagine I would create the views-view-field--field-MYTIMESTAMP.tpl.php, and copy in the default code, then use some php logic to convert it, right?  But I am not sure how to do that part.


texts: Is there a compelling reason to track sites.php with version control?

texts:
I'm wondering if sites.php is a file that should be tracked?  I can see it being useful because domains tend not to change for any given site (not true for development, as I usually run a shortname.local site alias for ease).  But then again, if you're not tracking the actual site folder, then the site folder name could vary from installation to installation potentially, making tracking sites.php potentially a useless cause...

I don't know, I guess I'm looking for guidance here.  Typically I do not track the sites folder because it contains generated site files and sensitive database information, so maybe it doesn't make sense to track sites.php?

Looking for some tips from the seasoned pros out there.


texts: Creating a custom field view using theme_field template

texts:
Folks - I'm trying to create a custom field view with custom content that utilises the standard theme_field template, to display in a node template.

I've tried to call the function programmatically e.g:

  $field_vars = array(
    'title_attributes' => 'test123',
    'label' => t('custom field label'),
    'items' => array('
This is a test
'),
    'classes' => 'test',
    'attributes' => FALSE
  );
  $my_field = theme('field', $field_vars);
  print $my_field;

It returns the template, but none of the $field_vars are being used.  Has anyone done something similar?


texts: How to display the term description on top of view

texts:
In Drupal 6 the TVI module had an option:
"Display term description"
"When enabled, the term description is displayed before the rendered view on term page."

Unfortunately I can't find this option to display the term description on top of views page of taxonomy term in the Drupal 7 version of TVI.

Is there any other way to display the term discription on top of the view (the view displays all content/nodes of the specific term).
Thank you.


texts: How to unpublish content when form submitted and notify a user by eMail?

texts:
In my Drupal 7 site I have content type Job.

Recruiters post information about open positions. Registered users can apply for any position by flagging node using the Flag module. I have built custom form for recruiters where they can manage applications. With this form recruiters can review profile and select candidate for position by submitting the form.

I want to hide/unpublish content when form is submitted and notify user via email that his application was confirmed. How can this be done programmatically?

Also I'm using Rules. If these actions can be implemented via Rules, how can I create event and conditions to perform actions against specific user id and node id?


texts: How to inspected the file system to investigate if the image was uploaded

texts:
After I upload an image, I see blank image. How can I inspect the file system to investigate if the image was uploaded or not?

Thanks,
M


texts: Feeds with Xpath Parser won't import images using image URL in XML file

texts:
Importing images into a multi-valued image field using image URLs from an XML file is not working for me. The Xpath Parser debug output shows the multiple image URLs being parsed correctly, but the images don't get imported. No problem with other ordinary fields.

The XML structure is:

<units>
  <unit>
    <unit_details>
      <images>
        <image>
          <uri>
             http://www.example.com/files/content/villa-102-1.jpg
          </uri>
        </image>
        <image>
          <uri>
             http://www.example.com/files/content/villa-102-2.jpg
          </uri>
        </image>
      </images>
    </unit_details>
  </unit>
</units>

The context is: //unit

The Xpath query for the image field is: unit_details/images/image/uri

I played around with the image grabber module for feeds, but it failed also - doesn't seem suited to this task.

Is it possible to import images using the image URL from the XML
file?
Is it possible to import multiple images into a multi-valued image field?

I'm using Feeds version 6.x-1.0-beta12+18-dev, and Feeds Xpath Parser version 6.x-1.12

UPDATE:

I was able to import images using the CSV importer and the image URL, so this appears to be a problem with Xpath Parser.

UPDATE 2:

I'm seeing no errors in the dblog or the server log.  That patch is for D7. The images do not show up in the node display, but the other fields do.

Looks like the "enclosure" error gets thrown if the local file name isn't in the right form, but I just have an external URL.  As I mentioned above, the image with the same URL does get imported using the CSV parser, so it doesn't appear to be a problem with the Feeds module, just the Xpath Parser.

The relevant code in D6 (FeedsParser.inc) is:

    /**
       * @return
       *   A path pointing to a file containing the resource referenced by the
       *   enclosure. This method downloads the resource if it is not local. The
       *   file path must be considered temporary and is only valid for the current
       *   page load.
       *
       * @todo Get file extension from mime_type.
       * @todo This is not concurrency safe.
       */
      public function getFile() {
        if (empty($this->file) && $this->getValue()) {
          // Check if this enclosure contains a local file.
          if (!parse_url($this->getValue(), PHP_URL_SCHEME)) {
            if (file_check_location($this->getValue(), file_directory_path()) || file_check_location($this->getValue(), file_directory_temp())) {
              if (file_exists($this->getValue())) {
                $this->file = $this->getValue();
                return $this->file;
              }
            }
            throw new Exception(t('Invalid enclosure %enclosure', array('%enclosure' => $this->getValue())));
          }
          $filename = basename($this->getValue());
          if (module_exists('transliteration')) {
            require_once drupal_get_path('module', 'transliteration') . '/transliteration.inc';
            $filename = transliteration_clean_filename($filename);
          }
          $dest = file_destination(file_directory_temp() .'/'. $filename, FILE_EXISTS_RENAME);
          if (ini_get('allow_url_fopen')) {
            $this->file = copy($this->getValue(), $dest) ? $dest : 0;
          }
          else {
            $this->file = file_save_data($this->getContent(), $dest);
          }
          if ($this->file === 0) {
            throw new Exception(t('Cannot write content to %dest', array('%dest' => $dest)));
          }
          $this->delete_file = TRUE;
        }
        return $this->file;
      }

}


texts: Why are permissions hijacked by Features module?

texts:
Trying to understand what exactly I have done here.

I have made a Feature to export CCK config. I added CCK: content to it for a bunch of content types, and so it contains auto-detected dependencies for about 10 modules including Node, Fieldgroup and Date. I put the resulting Feature in code and it seems to work as expected as a deployment tool for CCK.

What I don't understand:

On the dev server, the Permissions pages shows all my node-related permissions (create example content etc.) under node module
On the production server, the Permissions pages shows these same permissions under features module

What is happening and how can I get the config back into symmetry?


texts: Add multiple fields in +Add more button causes problem in sequence

texts:
I am implementing a form and in that form it requires that two form element should be coming under one Add more button, so user can add any number of fields.

Here is the code which i am using to create a form.

function ajax_example_add_more($form, &$form_state, $no_js_use = FALSE) {
  $form['description'] = array(
    '#markup' => '
' . t('This example shows an add-more and a remove-last button. The AJAX version does it without page reloads; the non-js version is the same code but simulates a non-javascript environment, showing it with page reloads.',
      array('!ajax' => url('examples/ajax_example/add_more'), '!multistep' => url('examples/ajax_example/add_more_no_js')))
    . '
',
  );

  $form['#tree'] = TRUE;
  $form['names_fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('People coming to the picnic'),
    '#prefix' => '
',
    '#suffix' => '
',
  );
  if (empty($form_state['num_names'])) {
    $form_state['num_names'] = 1;
  }
  for ($i = 0; $i < $form_state['num_names']; $i++) {
    $form['names_fieldset']['name'][$i] = array(
      '#type' => 'textfield',
      '#title' => t('Name'),
    );
    $form['names_fieldset']['surname'][$i] = array(
            '#type' => 'textfield',
            '#title' => t('SurName'),
    );
  }
  $form['names_fieldset']['add_name'] = array(
    '#type' => 'submit',
    '#value' => t('Add one more'),
    '#submit' => array('ajax_example_add_more_add_one'),
    '#ajax' => array(
      'callback' => 'ajax_example_add_more_callback',
      'wrapper' => 'names-fieldset-wrapper',
    ),
  );
  if ($form_state['num_names'] > 1) {
    $form['names_fieldset']['remove_name'] = array(
      '#type' => 'submit',
      '#value' => t('Remove one'),
      '#submit' => array('ajax_example_add_more_remove_one'),
      '#ajax' => array(
        'callback' => 'ajax_example_add_more_callback',
        'wrapper' => 'names-fieldset-wrapper',
      ),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  if ($no_js_use) {
    // Remove the #ajax from the above, so ajax.js won't be loaded.
    if (!empty($form['names_fieldset']['remove_name']['#ajax'])) {
      unset($form['names_fieldset']['remove_name']['#ajax']);
    }
    unset($form['names_fieldset']['add_name']['#ajax']);
  }

  return $form;
}

/**
 * Callback for both ajax-enabled buttons.
 *
 * Selects and returns the fieldset with the names in it.
 */
function ajax_example_add_more_callback($form, $form_state) {
  return $form['names_fieldset'];
}

/**
 * Submit handler for the "add-one-more" button.
 *
 * Increments the max counter and causes a rebuild.
 */
function ajax_example_add_more_add_one($form, &$form_state) {
  $form_state['num_names']++;
  $form_state['rebuild'] = TRUE;
}

/**
 * Submit handler for the "remove one" button.
 *
 * Decrements the max counter and causes a form rebuild.
 */
function ajax_example_add_more_remove_one($form, &$form_state) {
  if ($form_state['num_names'] > 1) {
    $form_state['num_names']--;
  }
  $form_state['rebuild'] = TRUE;
}

The above code is taken from the example module with little modification. In this code i have added one more text field called surname with name textfield.

Now when i access form it gives me the form fields as shown in the image given below.
Before clicking on Add more button:

Now when i click on the Add more button two fields are added as shown in the below image.

Here you can notice that there are two continuous Name and then two continuous Surname fields.

But actually i want to show these fields like in group. So the first group of name and surname and then second group of name and surname field.

How can i achieve as per the above snapshot ?


texts: How to setup different confirmation email per webform instance

texts:
Background:
I have a ContactUs webform made by Drupal 8 webforms contrib module and used that ContactUs Form on 3 different pages.

Is it possible to setup 3 different confirmation emails per instance?

Many tanks


texts: Why does the php evaluation not work in my rules condition?

texts:
I am trying to add the condition inside a commerce notification: "Order has one or more products where the sku contains.". What I basically need is "Order has only products where the sku contains".

The string that must be contained in the SKU is FOOBAR_.

The operator is =.

The amount: <?php print count($commerce_order->commerce_line_items); ?>

So the condition should just be true when all of the order's line items' products contain FOOBAR_ in their SKUs. But the php replacement does not seem to work. In the tooltip under PHP EVALUATION it says:

  PHP code inside of <?php ?> delimiters will be evaluated and replaced
  by its output. E.g. <?php echo 1+1?> will be replaced by 2. Furthermore
  you can make use of the following variables: $commerce_order

When I put in a hardcoded amount it works, but then its not dynamic, obviously.


texts:
I'm looking for direction on how to format the field layout of a view.

Here's the layout I'm looking for:

--------------------------------------------------
| Field1     | Field2      | Field3              |
| Field4     | Field5      |                     |
--------------------------------------------------
| Body                                           |
|                                                |
|                                                |
--------------------------------------------------

Using the "column" selection in the table settings, I'm able to "combine" fields into a single column (i.e. Field1 and Field4), but I'm stuck on how to display the Body under all the other fields in a cell that spans the whole table.

Suggestions?

I realize there are many ways to achieve my goal, in fact I've found this video that seems to be exactly what I'm looking for, but is this an overkill?


texts: node aliased path as views contextual filter

texts:
I want to have a view which would output a node title and use a contextual filter the aliased path of a node

/nodefilter?url=/category/path-to-article

I see there no php contextual filters in drupal 8 anymore do I have to write a custom contextual filter or is there another solution ? Any help will be greatly appreciated


texts:
I'm  using Drupal 7 and installed the Token filter module.

I want to display a welcome message in block; I used <h2>Welcome [user:name]! </h2> as token, but the token is not recognized.

Why isn't the token recognized? Which token should I use?


texts: Remove contributor role when user deletes all of his content

texts:
I have the following problem that I don't seem to be able to solve myself:

Today user BRIAN feels like creating some content, let's say 5 articles. I created a rule using the RULES MODULE that automatically assigns him the role CONTRIBUTOR after creating the first article.

Tomorrow Brian will realize that 4 of his articles weren't that great, and he decides to delete them. No problem, there is still one article out there authored by him and Brian is still a contributor! HOWEVER, as soon as Brian also deletes his very last piece of contributed content, I want him to lose his contributor role.

How do I put this into a rule?

On Brian's user profile, there is a VIEWS block listing all of Brian's content. The RULES BONUS PACK (http://drupal.org/project/rb) would let me check the number of results of this block and remove his contributor role as soon as the number of results drops down to 0. However, the module is still in development and I really don't want to use a dev-version on a productive website.

I read somewhere that the VIEWS BULK OPERATIONS module could do the job, but I really wouldn't know how. Could someone give me a hint, please?


texts:
I'm trying to set up a cron queue, but for some reason, I don't manage to get this done.
Here is what I have so far:
function mymodule_cron() {
    // Setup the queue
    $queue = DrupalQueue::get('import_jobs');
    // Create cache
    drupal_flush_all_caches();
}

function mymodule_cron_queue_info() {
    $queues['import_jobs'] = array(
    'worker callback' => '_import_all_jobs',
    'time' => 15,
    );
    return $queues;
}

The _import_all_jobs function does it's work excellent, so nothing wrong with that. I use the Ultimate Cron module and my cron job is listed over there:

But for some reason, nothing happens... So I'm wondering what I do wrong...


texts:
Fankly this is a silly question.

I want to print node teaser in a block.

As discussed here: How to programmatically render a node's teaser using the theme layer? I've used this code to get the html code of teaser:

 $node = node_load($nid);
 $rendered_teaser = drupal_render(node_view($node, 'teaser'));
 //now print this teaser in block using PHP filter.

But the problem is that this contains a logo whose img src value is

  http: //default/sites/default/files/styles/small-logo-image/public/ddn-job/iitblogo-1395397403j.jpg?itok=ZhTVC9Ee

Also internal URL's are linked as http:// localhost/node/1 which should have been http:// localhost/mysite/node/1

What is the problem? I've also tried running it through check_markup($rendered_teaser,'full_html')


texts: hook_node_grants() implemented by a custom module is not invoked

texts:
I am using the following code in a Drupal 7 module.

define('BNA_ACCESS_REALM', 'billetsalget_nodeaccess');

function billetsalget_nodeaccess_node_access_records($node) {
  $producttypes = array('internal_product', 'external_product', 'call_product', 'event_product');
  $grants = array();

  if (in_array($node->type, $producttypes)) {
    $grants[] = array(
      'realm' => BNA_ACCESS_REALM,
      'gid' => $node->nid,
      'grant_view' => TRUE,
      'grant_update' => 0,
      'grant_delete' => 0,
      'priority' => 0,
    );
  }

  return !empty($grants) ? $grants : array();
}

function billetsalget_nodeaccess_node_grants($account, $op) {
  dpm($account);
  die(var_dump($account));
}

hook_node_access_records() is working and running as it should, adding data to the database.
As far as I can see hook_node_grants() is never invoked. I have tried with all sorts of stuff in there, but it just looks like it doesn't even run.

It didn't have anything to do with my code. I'm new to Drupal so I didn't know hook_node_grants() don't get invoked when I'm signed in as an administrator.
Newbie mistake from my side :)


texts: Cannot get the label of my taxonomy term

texts:
I'm quite new to twig but I've found out a couple things.

It seems like my code is reading the Taxonomy instead of the term inside. Because all of the icons in my code change when I have the following settings:

{% if topic_type %}
{% embed "node--teaser__field.html.twig" %}
  {%- block field_icon -%}
    {% if topic_type == 1 %}
        group
    {% else %}
        tablet
    {% endif %}
  {%- endblock -%}
  {%- block field_value -%} {{ topic_type }} {%- endblock -%}
{% endembed %}
{% endif %}

I have a taxonomy term called "Personeel" and I want the if statement to change the icon to "group" whenever the topic_type is "Personeel".


texts: How to know which module is responsible for each database query?

texts:
I enable the devel module and set it to Display query log.

Then on every page load I get a list of the generated sql queries. You can see an example of that list in the capture I uploaded. So far so good.

Is there any way to know which module is responsible for each database queries (in case that the query is generated by a module)?

If this is not possible. Is there any way to do an analysis of all enabled modules to see how them are affecting the general performance of the site?


texts: drupal facebook autopost working but post are not visible to public

texts: I am using Facebook Autopost module and rules module to automatically post content to my facebook page when a new content in created. The post are appearing in my facebook page but they are not visible to public. What am I doing wrong.


texts: logging of access to images in image field

texts:
If someone hot links an image attached to a node via the image field, does Drupal add a log entry?

I was thinking along the lines of creating a mechanism where I can use images in Drupal nodes to track who reads emails, much like Mailchimp does. If I embed an image hosted by Drupal, would the log show the node as accessed, when an image from the image field was embedded in an email?


texts: Different code when translation is added & another when save button is clicked

texts:
Is there a way for me to add a code when i first add a translation and a separate code when the save button is clicked. at the moment i am using form _alter to trigger my custom code when adding, My problem is that the same code runs when the save button is clicked. How do i prevent the save action from running this code? Any help will do. Thanks

case 'node_interactive_form':
 //To use to check if it is a default language -- returns 0 = false & 1 = true
 $is_original_language = $form_state->getFormObject()->getEntity()->get('default_langcode')->value;

 if( !$is_original_language && !$form_state->isSubmitted() ) {
    var_dump("only run when adding & not when saving");
    // $triggering_element = $form_state->getTriggeringElement();
    // $button_name = $triggering_element['#name'];

  }

break;


texts: How can i move Revision information to an existing tab on the node edit page?

texts:
I'm using Drupal 7. I know how to hide Revision information on the node edit page, but could they somehow be form_altered to have it's contents in another tab (group), which is defined in the content type? I'd like to have nice and clean tabs on the edit pages, and i already have an "Advanced" tab - there's no reason to have an own tab for revisions with only one field.

EDIT: Solved by form_altering the following lines:

$form['revision_information']['#group'] = 'group_advanced';
$form['#group_children']['revision_information'] = 'group_advanced';
$form['#fieldgroups']['group_advanced']->children[] = 'revision_information';

Just change "group_advanced" to the machine name to which you want to move the revision information to, and it should work! However, this moves the whole revision fieldset inside the custom tab, instead of just the fields... I'm sure that could be done too, but i'm happy enough with this solution too.

I still can't understand why it has to be this difficult, instead of just drag & drop in the content type settings...


texts: Drush site-install working with profile_name_install_tasks and forms

texts:
Is there a way to add some arguments to the drush site-install command to set the value of some form fields introduced by a hook_install_tasks() in an install profile?

I tried some arguments variants on: drush site-install my_profile my_profile_form.my_settings.key=value

But to no avail.

See Drush output (for the form field 'Featureset')

WD php: Exception: Featureset field is required. in install_run_task() (line 414 of X/includes/install.core.inc). [error]

WD php: Warning: Cannot modify header information - headers already sent by (output started at X/drush/includes/output.inc:38) in drupal_send_headers() (line 1216 of X/includes/bootstrap.inc). [warning]

Exception: Featureset field is required. in install_run_task() (line 414 of X/includes/install.core.inc).

Drush command terminated abnormally due to an unrecoverable error. [error]


texts: How to speed up Reference module's Views plugin?

texts:
I have a 'Node reference' field via the References 7.x-2.1 module which is pointing at a View which returns up to ~5000 results. I'm also exposing this field as a filter in a separate View. The issue that I'm having is that these ~5k results are taking up to 20s to render, despite only 10 rows being shown to the browser.

Judging by XHProf's results, I thought the best way to do this was to cache the rendered results of the referenced View. That brought the time for references_plugin_display::render down from 20s down to 10s, but that still seems like a long time. The References module doesn't seem to have documentation.

Is there a way to skip rendering 'Node reference' options, or to generally speed this process up? If the solution is to change modules, is there a migration path from D6 References fields to the new module in D7?


texts: Core listed as outdated, but composer is not updating it

texts:
I'm facing a strange issue with drupal-composer.
It has been installed via the usual command line:

$ composer create-project drupal-composer/drupal-project:8.x-dev ./ --stability dev --no-interaction

Now I want to update drupal/core, and here's what I've got:

$ composer show -l
[...]
drupal/core  8.3.1  8.3.3  Drupal is an open source content management platform powering millions of websites and applications.

$ composer update drupal/core --with-dependencies
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
> DrupalProject\composer\ScriptHandler::createRequiredFiles

I've maintained Drupal instances with Composer for monthes, and never faced this kind of issue (other instances have successfully been updated to 8.3.2 or 8.3.3).
I've tried to clear Drupal and Composer caches, and desperately ran /update.php before another try, without luck.

Any thoughts?


texts: modify submit on user login so that only admins can log in through this route

texts:
I have written a hook form alter which adds a submit action but I get this error

  Recoverable fatal error: Argument 2 passed to xxx_form_submit() must be an instance of FormStateInterface, instance of Drupal\Core\Form\FormState given in xxx_form_submit()

the code is like this

function xxx_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {

 if ($form_id=='user_login_form') {

    $form['actions']['submit']['#submit'][] = 'xxx_form_submit';
  }
}

function xxx_form_submit ($form, FormStateInterface  $form_state) {
  $username=$form_state->getValue('name'));
}


texts: z-index Drupal 7 Skeleton Boilerplate discriminating roles?

texts:
I'm building a website using Drupal 7 for the first time. I have always built them on Drupal 6 using the basic theme to build my own custom themes from. This time I decided to change, because I thought it was time to move onto Drupal 7 and I wanted responsive design for this project.

I have a custom front---page template, and on that front page I have views slideshow (cycle) and wanted to place text on it. So i made a block with such text, and gave it a z-index 999 and an absolute position, when the slider has a z-index -999. Everything looks just as I want it and expect it to, until.... I log out! Is it possible that the css is discriminating roles?

How can it possibly be that logged in as admin I see the slider on the bottom and the block on top as expected, and as an anonymous user the text block is hidden underneath the slider? (And I know it is because when I resize, I can partially see it, as it moves down.... ) I'm lost.

Edit for more info: this is happening in IE9, Chrome, Safari mac, Safari Win, and Firefox is displacing the Slider onto the right....GRRRR. HELP!
Thank you in advance for your help.


texts:
I created a view listing some Articles, but displaying a custom field I added to the Article content type instead of the usually used title.

When I would display a title instead of the custom field, I could check the option to include a link together with the title. How can I do that with the custom field instead? It only offers me the option to display the custom field as a plain text, without the link checkbox.


texts: How to translate breadcrumbs on a views page?

texts:
I am facing problem regarding translation of Views title.

breadcrumbs is not translated.
I have used view on this page. Its title is Latest News.
Could anyone please help?

Translate interface


texts: Settings contains a dot which is not supported, but module gets enabled properly

texts:
I'm developing a search engine module for Drupal 8.

On a clean new Drupal website, I can install it from the admin GUI, but when I enable it I have the classical white screen (The website encountered an error ...).
Checking the error.log yields the following :

  Uncaught PHP Exception Drupal\Core\Config\ConfigValueException: "gref.settings key contains a dot which is not supported." at /var/www/html/core/lib/Drupal/Core/Config/ConfigBase.php line 211, referer: http://10.113.101.197/admin/modules

But, if I go back to the website, the module is installed properly, and no further issue is reported (even when uninstalling the module).

Here is my configuration :

- config
  - install
     - views.view.grefsearch.yml
     - search_api.server.grefserver.yml
     - search_api.index.grefindex.yml
     - gref.settings.yml
     - gref.schema.yml
     - facets.facet.grefother.yml
     - block.block.gref.yml

And here is gref.settings.yml

gref:
  page_title: 'Gref Search'
  source_text: 'Lorem ipsum dolor sit amet'

Any ideas why I have this error ?


texts:
I need a specific vocabulary (A) that has unique terms. I don't want to do validation at form level because I want to be able to add term from everywhere.

I successful used hook_entity_bundle_field_info_alter() and addConstraint() to be sure one specific field is unique on another vocabulary (B). (Will this be deprecated? See https://www.drupal.org/node/2346347.)

For the vocabulary (A), there is no specific field, so the hook_entity_bundle_field_info_alter() is not working here, as this field name is not a "true" field.

I use hook_entity_presave(), but I'm not able to do a proper validation because this hook is called too late in the code, except if I use Exception, but that is not a good way.

How can I achieve what I am trying to do?


texts:
Objective - have a blank screen with only an image on it. (a "play video" button) when the button is clicked a video (from youtube) opens in a section on the screen that is maybe 200X300. Ideally this would all be done within ckeditor so the end user can setup and change as desired. (note - I am not sure if iframe is needed, but this is how I was able to do it)

I can get the appearance I want easily by embedding the following code into ckeditor in "source" mode:

But can not figure out how to have a blank screen that shows only an image that opens the video when it is clicked. thanks for any help


texts: How can we add a date picker in a date field exposed filter?

texts:
In Drupal 8 am trying to add date pickup popup calendar in our custom search form. Search Page is created by Views page and adding DOB field
by the date field expose.

But there is no option to add date popup calendar in views. While date pop up calendar is showing in the "Add Content" page in admin area.

Any idea how can we show datepicker calendar on date field?


texts:
Write a script to filter content by country.

  I have problem Cannot use object of type Profile as array in .... on line 19

Part of code with error

global $user;
$country = "";
if($user->uid!=1 && $user->uid!=0){
  $user_full = profile2_by_uid_load($user->uid);
  if(!empty($user_full['client'])){
    $country_parent = taxonomy_get_parents($user_full['client']->field_clcountry['und'][0]['tid']);


texts: How to get entityreference_backreference data programmatically

texts:
The User profile for my site contains the Entity Reference field 'Parent' which points to another User.

I have the entityreference_backreference module enabled on my Drupal 7 site.
I need to programmatically access the values of the properties added to the user entity by the entityreference_backreference module, so that for User A, I can identify all other Users which point to A via the 'Parent' EntityReference field.

If I do the following

$wrapper = entity_metadata_wrapper("user",$some_user);
$wrapper->getPropertyInfo();

I can see that that an entry for the entityreference_backreference field field_parent_user_eb is available in the getPropertyInfo() output. So the property does exist.

However, if I do

$wrapper->get('field_parent_user_eb');

it comes back with "data = null".

Also if I just try to access $some_user->field_parent_user_eb that also gives a null result.

It looks like the property is never being set.

What am I doing wrong? I can see that there is a "getter callback" defined for the field_parent_user_eb property, which is set to entityreference_backreference_related_entities, but I can't see how I can use this.

Any help much appreciated!


texts: Git making code changes in local branch 'develop' and push to Acquia Cloud Dev

texts:
I cloned Drupal 8 core and modules from my Acquia Cloud distro into my local repo.

In my local repo I have 2 branches * developand master. Currently I am in develop branch. I made some small changes to the .gitignore file and in sites/default/settings/php

(in the develop branch i want to make all my changes to code, themes and add contributed modules).

Currently i am in develop branch. When i try from Dev desktop: Push code to Cloud Dev I get this message:

  NOTE: Your locally deployed branch 'develop' doesn't match 'master'
  deployed in the Cloud environment 'dev'. You will have to deploy
  'develop' in the Cloud to see your code changes.

I know I get this message because I am currently in develop branch. But what do I have to do exactly before Push code to Cloud Dev to avoid this error message? What is the recommended procedure exactly to make changes to my code locally (on another branch) and Push code to Cloud Dev? And is it advisable to make those changes to code on another branch e.g. develop?

Update:

I select develop in Acquia Cloud dev environment after git push
origin develop. Till when? When do i have to choose master again?
In my local repo i have added branch develop to add all my
contributed modules and to develop the frontend etc. When do i have
to merge it to master exactly? Or do i have to stay on develop
all the time?


texts: Standard way of getting a form inside block

texts:
I'm using :

public function build() {

    $form = $this->formBuilder->getForm('Drupal\mymodule\Form\Myformclass');
    return $form;
  }

to get form inside block. But Drupal community doesn't find it as an appropriate way to get form inside a block.

According to Drupal community module reviewing team, Do not hard-code class names in strings. I tried calling class directly but that is not serving my purpose, giving 505 error.

What's the right way to get a form inside a block?


texts: Ubercart Discounts (alternative) applies discount to all items in cart (drupal 6)

texts:
I've created some bulk discounts to be applied when the number of products added to the cart is between specific ranges (e.g. Minimum qualification amount = 10 & Maximum qualification amount = 29).
The problem is that whenever a product qualifies for discount, that discount is applied to all the products in the cart. That's because a condition of qualification requires the product to have a "Bulk Discount" term applied to it. Also, the discount is set to be applied to products tagged with the "Bulk Discount" term.
The solution to this would be to have a different taxonomy term for every product and set a different discount for each one of them. But this would definitely not be practical.

Example:

product1: price = $10, product2: price = $30
Cart contains: 10 x product1, 3 x product2
Discount triggered by qualification rule for product1: -10%
Order total = (10x10 + 3x30)x0.9 = $171
What I want the order total to be = (10x10)x0.9 + 3x30 = $180

Is there any way to do that using that module?


texts: I need to create a view of people a user is following. the default settings for user relationships only shows people following a user. i know i need to use views but i have no clue how to set it up. Any suggestions will be greatly appreciated.


texts: Menu not showing for 1 server of two cloned servers

texts:
After cloning an existing server instance and pointing the new one to the same database I've modified my hosts files to load the 2nd server with the same URL as the first one.

All is well except for the fact that on the 2nd server the navigation menu is missing!

Any insight onto what may cause two otherwise identical servers to behave differently in this fashion?

update: the menu in question is generated by the superfish module.


texts: Weird permissions problems for sites/default/files

texts:
I have this weird problem related to permissions on a VPS where I run 2 Drupal 7 websites.

I have an old site, which was migrated over several hosting providers and VPS setups. I also have a freshly installed website.

The new one works perfectly and I can set it to aggregate and compress CSS files plus JavaScript files. All is smooth and without errors.

The old one... each time I set it to do this, It gives me errors such as:

The specified file temporary://filepIYgt4 could not be copied to public://js/js_IaQHoIpFqzgiVl19GZEd2HEQg6iqLy6d1_xllBmEbqE.js.
The specified file temporary://fileTbJH3r could not be copied to public://css /css_Lnc8IK4qbp4ueX76wBYIBGAqVihLWtCHHNP7WBSphEM.css.

Both websites are configured the same way. The difference though seems to be in the permissions set for the sites/default/files folder. The new website (which works fine) has the permissions set to 0777 and the group and owner are set to apache.

The old website (which generates errors) has the permissions set to 0777, the group to psacln and the owner is the user I'm using to login to the website via SSH or FTP.

If I change the owner and the group to apache for the old website, things still don't work. I get warnings like these:

Warning: realpath(): SAFE MODE Restriction in effect. The script whose uid is 10002 is not allowed to access /var/www/vhosts/.../httpdocs/sites/default/files/css owned by uid 48 in DrupalLocalStreamWrapper->getLocalPath()

Warning: realpath(): SAFE MODE Restriction in effect. The script whose uid is 10002 is not allowed to access /var/www/vhosts/.../httpdocs/sites/default/files/js owned by uid 48 in DrupalLocalStreamWrapper->getLocalPath()

Warning: realpath(): SAFE MODE Restriction in effect. The script whose uid is 10002 is not allowed to access /var/www/vhosts/.../httpdocs/sites/default/files/ctools owned by uid 48 in DrupalLocalStreamWrapper->getLocalPath()

As you can see, Drupal still can't write to the same troublesome folder. :(

What am I doing wrong? Any advice how to fix this?


texts: How to compare two user from relationship in views

texts:
I have a view to display the contents that a user bookmarked.

Here we have three users: the author of the content (uid from a relationship), the viewed user (uid from arguments), the logged-in user.

I would like to show only the contents that were flagged by but not created by the viewed user, how can I achieve this? I can only find a way to filter by the logged-in user.


texts: Passing arguments into hook_block_view in custom module

texts:
I'd like to pass a variable ($myvariable) into the block_view function in my custom module, so i can see the content of the variable in the block content.

But there must be something i do wrong, because the below code gives me the following error:

  Warning: Missing argument 2 for mymodule_subscribe_block_view ...

/**
 * Implements hook_block_view().
 *
 * Prepares the contents of the block.
 */
$myvariable = 'test';
function mymodule_subscribe_block_view($delta = '', $myvariable) {
  switch ($delta) {
    case 'mymodule_test':
      $block['subject'] = t('Test block');
      if (user_access('access content')) {
          // Pass data through theme function.
          $block['content'] = $myvariable;
      }
    return $block;
  }
}

I'd greatly appreciate any hints on what's going wrong here.


texts: Multilingual site, always use language path prefix (no bare URLs)

texts:
I have a Drupal 8 site with two languages, Japanese (default language) and English.

By default, the default language pages are available at both / and /ja.

For example, /about and /ja/about both go to the Japanese "about" page.

I want to get Drupal to force the path prefix so that the URL is always shown as /ja/about and never just /about.

Interface text language detection settings

URL (path prefix, english: en, Japanese: ja)
Selected language (Japanese)

How can I do this?

For Drupal 7: see this question


texts: How can I handle restricted items on a Drupal Commerce site with special display and checkout rules?

texts:
I'm about to undertake the building of a Drupal Commerce site that has special restrictions around purchasing some of it's items.  Specifically these items will not have displayed prices and a sales rep must approve their purchase. I'm new to Commerce but not Drupal I'm basically looking for advice here...

The use case is not set in stone but the case that I would like to achieve is basically this:

user can see restricted item and can add it to their cart but the price displays as 'request a quote' (I thought maybe views could do this with rewrites but I need logic it doesn't offer) I need to add other actions regarding line items as well ('request a sample' in particular).

when request a quote item is added to the cart trigger modal legal mumbo jumbo

once in the cart view the order is categorized into 'purchasable items' and 'request a quote items'

When the cart is submitted only purchasable items will be actually purchased, request a quote items will sent via email to reps/automated in some way/saved in the cart for later.

Maybe a rep can trigger user status change and prices become reveled/items are moved to purchasable, perhaps not?

I'm guessing I'm going to need a custom module?  Is this even possible, processing part of a cart like this?  Any of you E-comm pros build something similar, how did you do it?


texts:
I need to get the latest inserted id, this is the line im using for writing files to my db

drupal_write_record('file_managed', $file, 'fid');

any ideas?


texts: drush language importing untranslated strings

texts:
I am having 2 environments. A staging and a production one. I want all string to sync the strings, so that whenever a new string comes to staging it is available for translation in production. For this reason I've used drush_language module.

Export via

drush language-export-translations --statuses='not-translated'

This provides a .po file where part of it you can see:

msgctxt "tripping_context"
msgid "Giannis test translations"
msgstr ""

When i run an import on prod via

drush language-import-translations  --langcode="sv"

No new strings are picked up.

Anything wrong I am doing here?


texts: Get the uri/path value of an image in the field template

texts:
I have created a custom field template for an image - field--field_images.tpl.php with the following code:

<?php $url = file_create_url($field_images['uri']);
$url = parse_url($url);
$imglink = $url['path'];
?>

<?php foreach ($items as $delta => $item): ?>
<div data-thumb="<?php print render($imglink); ?>" data-src="<?php print render($imglink); ?>" data-time="1500" data-trasPeriod="4000" data-target="_blank" >

<?php endforeach; ?>

currently $imglink returns the value of the root folder "www". I need to find a way to get the path to the image file associated with the field e.g "http://www.example.com/sites/default/files/image.jpg" any help with this would be greatly appreciated.

UPDATE:

I think I'm almost there. Here is the code in my field-field_images.tpl.php file:
<?php foreach ($items as $delta => $item): ?>
    <div data-thumb="<?php $img_src = $element['#object']->field_images['und'][0]['uri']; $link = image_style_url('thumbnail', $img_src); print ($link);   ?>" data-src="<?php $img_src = $element['#object']->field_images['und'][0]['uri']; $link = file_create_url($img_src); print ($link);   ?>" data-time="1500" data-trasPeriod="4000" data-target="_blank" ><?php render($item); ?>

   <?php endforeach; ?>

and you can see the output here: http://www.kfpa.co.za/dev/?q=node/2

The one problem is that it loops through and creates the correct number of elements for the uploaded images, but when it creates the URLs it's only creating for the item as specified for by 'x' in <?php $img_src = $element['#object']->field_images['und'][x]['uri']; i.e if I change 'x' to '2' the third photo displays. How do I change this code so that it finds the correct URL for corresponding image in the loop?


texts: Is it possible to use image styles in Views field rewriting?

texts:
I would like to add "no results" behavior to an image field displayed in Views, such that the image from an alternate field is displayed. Ie., if Image1 is empty, display Image2.

Is it possible to use an image style in the rewrite code? I'm sure I can display the second image, using something like <img src="[field_Image2]">, but how can I specify that the image be displayed using the max_height_125 image style?


texts: We have a multisite install that will have a few shared blocks. As we spin up more sites we'd like to just take the yml file associated with the block and add it to the config directory of the new site.  The issue though is the UUID.  Do these need to be unique across the entire install or just within a sub-site?


texts: How to retrieve a list of nodes not already commented by a user with a specific role

texts:
I'm trying to make an administration view (visible only for user with role = moderator) that simply lists all nodes in my site that doesn't have any MODERATORS comment.

Please notice that I'm not asking to show all nodes with zero comments, but list all nodes not already commented by users with moderator role.

Thank you in advance for helping me.


texts:
We have a checkbox which's title should have HTML () but its rendered as text rather than HTML.

How to use HTML in a webform component's title?


texts: Customizing Forena reports according to the report type

texts:
I am using Forena reports to generate my custom reports. I want to use a custom PHP variable which increments its value under foreach loop in layout under (Create new reports through admin interface).

<?php $num = 0; ?>

            <?php $num += 1; print $num; ?>
            {fn}
            {ln}
            {em}
            {ph}
            {tr}

            {coupon_code}

In the same way, how to use different tags for different document types.
For example, while rendering the image in above td,

For document types doc and html, I want to use as below:

For document types xls and csv, I would like to use like below:

{site.base_url}/sites/default/files/{up}


texts: How to force a login on a specific page only?

texts:
I would like to create a page (with a specific url) which will always require/force the user to login with their credentials. This would need to work irrespective of whether they were already logged in or the permissions they have.

I have considered using one of the access modules such as Content Access, but the issue here is that if the user has already logged in previously, they will bypass the login screen. One way could be to use the Required Login module. But I am not sure how would I exclude all of the website except the one page? The only other option I can think of is to do this on content view via Rules. I have tried this, but there is a noticeable pause between when the page is loaded to when the logout begins; making this appear more like a hack as opposed to a streamlined solution.

Are there any better ways to achieve this?


texts: Views table display with sort and DISTINCT error: General error: 3065 Expression #1 of ORDER BY clause is not in SELECT list

texts:
I have a node view, page display with format "table" where the changed date is set as the default sorting order by the table settings. When I set "Distinct" for the view I get the above mentioned error.
This is the query which is shown to me:
SELECT DISTINCT
 "sidejob"."id" AS "id",
 "candidacies_mandates_sidejob__mandates"."id" AS "candidacies_mandates_sidejob__mandates_id",
 "politician_candidacies_mandates"."id" AS "politician_candidacies_mandates_id",
 "sidejob_organization_sidejob"."id" AS "sidejob_organization_sidejob_id" FROM {sidejob} "sidejob"

LEFT JOIN {sidejob__mandates} "sidejob__mandates" ON sidejob.id = sidejob__mandates.entity_id AND sidejob__mandates.deleted = :views_join_condition_0
LEFT JOIN {candidacies_mandates} "candidacies_mandates_sidejob__mandates" ON sidejob__mandates.mandates_target_id = candidacies_mandates_sidejob__mandates.id

LEFT JOIN {politician} "politician_candidacies_mandates" ON candidacies_mandates_sidejob__mandates.politician = politician_candidacies_mandates.id

LEFT JOIN {sidejob_organization} "sidejob_organization_sidejob" ON sidejob.sidejob_organization = sidejob_organization_sidejob.id

WHERE "sidejob"."id" IN (:db_condition_placeholder_1)
ORDER BY "sidejob"."changed" DESC

I found an issue on drupal.org with a proposed solution which works most of the time but not when the field is from a joined table. The solution for most cases working is adding a custom filter plugin to the view which iterates through all the fields sortable in table display and adding it to the query:
  public function query() {
    // Force View to DISTINCT (because multiple matches makes duplicate
    // query results), and ensure all fields in DISTINCT exist in query to avoid
    // SQL error "ORDER BY clause is not in SELECT list": Table column click
    // to sort (and its default order) adds an additional field too late in the
    // game, so we preemptively add all these fields to the query to anticipate
    // it.
    $this->query->distinct = TRUE;

    // Fields the table sorting plugin might use which might not be in the query.
    $sortable_fields = array_keys(array_filter($this->view->getDisplay()->getOption('style')['options']['info'], function ($item) {
      return $item['sortable'] ?? FALSE;
    }));

    // Get field table meta and add to query:
    foreach ($sortable_fields as $field_name) {
      $field = $this->view->field[$field_name] ?? NULL;
      if ($field) {
        $this->query->addField($field->table, $field->realField);
      }
    }
  }

The remaining problem as described in the issue: when a field is used for sorting the table which comes from a joined table this solution is not working. I don't get why $this->query->addField($field->table, $field->realField); does not manage to ensure the table properly. I will ask this in another question as this might be a different problem.
The main question here: is there any other solution to avoid this SQL error when combining views table disply with sortable columns and the distinct settig for the view?


texts: Which Rules Event can be used with Drupal Commerce when a cart is updated?

texts:
I have created a rule which add the shipping methods on cart page. It works fine when we add or delete the items from cart. BUT there is no event available on rules which fire when we increase the product quantity and update the cart.

I already used the event "After updating an existing commerce line item" but it is also not doing the job.

Here is my rule:

{ "rules_auto_add_shipping_service" : {
    "LABEL" : "Auto-add shipping service",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [
      "commerce_order",
      "commerce_shipping",
      "commerce_cart",
      "commerce_rules_extra"
    ],
    "ON" : {
      "commerce_cart_product_add" : [],
      "commerce_cart_product_remove" : [],
      "commerce_rules_extra_line_item_quantity_changed" : []
    },
    "IF" : [
      { "commerce_order_compare_total_product_quantity" : {
          "commerce_order" : [ "commerce_order" ],
          "operator" : "\u003E=",
          "value" : "1"
        }
      }
    ],
    "DO" : [
      { "commerce_shipping_method_collect_rates" : {
          "shipping_method_name" : "flat_rate",
          "commerce_order" : [ "commerce-order" ]
        }
      },
      { "commerce_shipping_rate_apply" : {
          "commerce_order" : [ "commerce-order" ],
          "shipping_service_name" : [ "" ]
        }
      }
    ]
  }
}


texts: Drush command l10n_update could not be found, but is present in Drupal site

texts:
Installed Drush 6.6.0 using composer following instructions on drush.org. Works fine. I have a set of site aliases in ~/.drush/mysite.aliases.drushrc.php: mysite.dev, mysite.stage, mysite.prod

All the aliases work fine and I can do all built-in commands like drush @mysite.dev up etc.

However, modules that are present in @mysite.dev/sites/all/modules/contrib that support Drush are not found. E.g. l10n_update.

I can do commands like drush @mysite.dev up l10n_update which works fine. I can use the module through the web interface and it works fine.
But I cannot do drush @mysite.dev l10n_update.
It throws the error The drush command 'l10n_update' could not be found.  Run 'drush cache-clear drush' to clear the commandfile cache if you have installed new extensions.
Even when the current dir is anywhere in @mysite.dev or @mysite.dev/all/modules/contrib/l10n_update/

I've tried drush cc drush and drush cc all multiple times in various locations in and outside of the site root without success.

I've read numerous similar questions on this site and followed all suggestions (when relevant to my Drush version), but nothing helps.

I know I had it working long time ago pre composer, but I cannot find what to do now.

Update the correct command is l10n-update not l10n_update. Only looked over it a million times. :-(


texts:
When I add a layout to my theme using .layouts.yml, it will show up in the display settings for various entities (for example, paragraphs and blocks).
I can then set the display to be of a certain layout, but doing so gives me template suggestions. When I try to implement one of the template suggestions, it doesn't even use the template in themes/custom//templates/.

So I am a little confused. Which should I use?  It's easy enough to use a layout, but I feel like I should use templates more often than layouts.

I do remember reading that layouts were added in Drupal 8.3 as experimental module, so it sounds like templates existed before layouts. It sounds like it's up in the air as to which one is better to use, but I just wanted some more opinions.


texts:
I am trying to display my webform in a modal (including error/validation messages inside the modal). I am following this approach for a custom drupal form which is not a webform. I am wondering whether this is possible at all with webforms and in case it is, what I need to take into account to make it run?

The first problem I am having is the following code line from the example's TeacherContactController.php

$modal_form = $this->formBuilder->getForm('Drupal\tl_session\Form\TeacherForm');

When I try to use this in my own controller, I cannot get the webform's proper namespace + id. When I check my webform with devel it says:

[__CLASS__] => Drupal\webform\Entity\Webform
  [id] => add_news_webform

But I get a "The form argument Drupal\webform\Entity\Webform\webform-submission-add_news_webform-form is not a valid form" error. I tried many things, but did not succeed.

How can I get the webform with formBuilder and what else am I missing here (like webform specific ajax settings etc.)?


texts:
I installed a theme that come with different homepage style (homepage-2, homepage-3, etc..)

I configured a new homepage name as homepage-abc, then I set my Default front page to homepage-abc. (Configuration>Site Information)

When I checked the frontpage, it displays homepage-abc with frontpage layout.

I check these frontpage blocks, the blocks show in frontpage is disable.

Is there other place the theme author wrote a script that configure the combination blocks to define the frontpage?


texts:
I have two dynamic links that I want to put in a block, e.g. http://example.com/series/bomberman-jetters/node/add/gallery/82 ("series" is the content type, and "bomberman jetters" is the node title), http://example.com/series/bomberman-jetters/node/add/reivew/82 ("82" is the node ID).

I want to change the URL depending on what node is being viewed. Like if it's viewing node 99 then the links in the block should be changed to http://example.com/series/bomberman-jetters/node/add/gallery/99.

So what I did is insert <?php
print "Add album";
?> but it doesn't work in Drupal 7. The link is correct but it doesn't lead you to creating the node.


texts:
I am trying to set up subscription in drupal 7.However i also want to charge the customer with one time set up charge which will not be recurring in nature.
Ex. If a product cost is $30 per month and set up charge is $15. Then he should only be charged $45 first time. Next month he should be charged only $30 not full $45.
Any ideas about any module or configuration option to achieve this.
Or will i have to do custom  coding only for this.
I assume many sites in drupal might already have this functionality achieved.

Regards to all
Smith


texts:
function THEMENAME_preprocess_views_view(&$variables){
        $view = $variables['view'];
      if($view->name == "YOUR_VIEW_NAME" && $view->current_display == "MACHINE_NAME_OF_VIEW"){
        $variables['attributes']['class'][] = 'page-'.$view->name;
    }

For some reason this does not work. Any ideas?


texts: Drupal 7 rewrite is removing get parameters from query string

texts:
I've recently upgraded a site to the latest release of Drupal 7. The site has a view that retrieves a url with query string parameters from the database and then uses the Drupal rewrite functionality to add a class to the link like so:  View

The issue is, since the upgrade the rewrite now removes the query string parameters. If I modify the view to display a simple link the parameters are there and it works fine. However, the rewrite applies styling to present a button rather than a simple link. I can't find any settings to resolve the issue so I suspect the upgrade overwrote a modification to the Drupal core made by the original developer of the site. Any idea how I can address this issue?


texts: How can I dynamically add URL or taxonomy to body class

texts: Am creating my own theme and have successfully added the URL into the node class in node.html.twig with {% set classes = [ 'url' ~ url|clean_class, ] %} but I need to be able to style each page individually as a whole, not just at the node level - how do I add the URL or the taxonomy of the node to the page or body classes?


texts: Why does the autocomplete return incomplete words?

texts:
I am working on an autocomplete feature based on the Search API Autocomplete module. Basically I almost copied the functions I needed from this module for my use case. I set up a Solr index, and I am trying to query it, so it returns back relevant suggestions.

The problem is that the words returned are not always the words I am expecting. For example, if I enter Pu, the module should return Publication because this word is present in some nodes; it returns Public, which is not even present anywhere. From where does this mysterious word come? I don't know if the problem is with Solr index or Search API module, since they are twice involved in the module.

They are a lot of errors. Here are some examples of the issue.

studi instead of studies
strategi instead of strategies
describ  instead of describe


texts: "Customer information #number" option appeared for sellecting shipping address?

texts:
After implementing ShippingOrderProcessor:
https://gist.github.com/jsacksick/fde031197df92236ef5a916775e17a2e
which I needed to show shipping costs on cart and order overview page (order summary block) on order information page, shipping section, drop-down for selecting existing address or creating new one now has one extra item and it's default? Options now look like:
Some street 225.             -> ok, existing address from address book
Customer information #498    -> this just appeared, want to remove it
+ Enter a new address.       -> also ok, option for adding new address

Inside same section for selecting billing address I don't get that "Customer information #498" option, but just existing addresses to choose from or "+ Enter a new address" which is how it suppose to look.
Drop-down html looks like:
<select class="available-profiles ..." name="shipping_information[shipping_profile][select_address]">
    <option value="183">Some street 233</option>
    <option value="_original">Customer information #498</option>
    <option value="_new" selected="selected">+ Enter a new address</option>
</select>

If I figured it well that ShippingOrderProcessor is creating an dummy user profile needed for adding shipment, that dummy (empty) appears as this extra option.
I managed to removed it by hacking drupal/web/modules/contrib/commerce/modules/order/src/Plugin/Commerce/InlineForm/CustomerProfile.php
but I'm proud of that solution.
What would be the proper way to remove this dummy profile? Maybe to delete it somehow inside hook_user_login()?