texts: Drush pm-list needs a higher bootstrap level to run

texts:
I am getting this error when trying to run pm-list. I am in the Drupal folder, not at the root, on Mamp Pro on my Mac using OS X El Capitan. I have tried setting the host from localhost to 127.0.0.1, tried adding paths to the .bash_profile. Not sure what else to do. Following is the output upon entering pm-list:

The drush command 'pm-list' could not be executed.
Drush was not able to start (bootstrap) the Drupal database.
Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have a
configured database. In this case you can select another site with a
working database setup by specifying the URI to use with the --uri
parameter on the command line. See `drush topic docs-aliases` for
details.
 * connect the database through a socket. The socket file may be
wrong or the php-cli may have no access to it in a jailed shell. See
http://drupal.org/node/1428638 for details.

Drush was attempting to connect to:
 Drupal version         :  7.43
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  127.0.0.1
 Database port          :
 Database username      :  interdev
 Database name          :  interdev
 PHP executable         :  /usr/local/bin/php
 PHP configuration      :  /usr/local/etc/php/7.0/php.ini
 PHP OS                 :  Darwin
 Drush script           :  /Users/studio17/Sites/interdev/vendor/dr
                       ush/drush/drush.php
 Drush version          :  8.1.11
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /Users/studio17/Sites/interdev
 Drupal Settings File   :  sites/default/settings.php
 Site path              :  sites/default


texts:
I successfully migrated external files via MigrateDestinationFile to Drupal files, and now I am trying to map these files to image fields for users, but they are not showing up for the user's image field.

Any tips on how to debug or succeed with such a migration? I am also unsure if my addFieldMappingline will take care of multiple values to the same field.

Here is the relevant code in MigrateDestinationUser:

    $this->addFieldMapping('field_pictures', 'pid')->sourceMigration('CoppermineFileCopy');

even adding MigrateFileFid did not help

            $this->addFieldMapping('field_pictures', 'pid')->sourceMigration('CoppermineFileCopy');
            $this->addFieldMapping('field_pictures:file_class')->defaultValue('MigrateFileFid');

And the CoppermineFileCopy

    class CoppermineFileCopyMigration extends MyMigration {

    private $base_path;

    public function __construct() {
        parent::__construct();
        $this->description = t('Profile images');

        $this->base_path = '/home/myurl/public_html/copperminephotos/albums/';

        $this->map = new MigrateSQLMap($this->machineName,
        array('pid' => array(
        'type' => 'int',
        'length' => 11,
        'not null' => TRUE,
        'description' => 'Coppermine Photo ID',
        )
        ),
        MigrateDestinationFile::getKeySchema()
        );

        $query = db_select('coppermine_pictures', 'copp')
        ->fields('copp', array('pid','filepath','filename','title'));

        $this->source = new MigrateSourceSQL($query);
        $this->destination = new MigrateDestinationFile();

        // In the simplest case, just map the incoming URL to 'value'.
        $this->addFieldMapping( 'value', 'filepath_filename');
        $this->addFieldMapping('source_dir')
        ->defaultValue('/home/myurl/public_html/copperminephotos/albums/');

        $this->removeFieldMapping('pathauto');
    }

    public function prepareRow($row) {
        //dpm("Before Processing:");
        //dpm($row);
        // Always include this fragment at the beginning of every prepareRow()
        // implementation, so parent classes can ignore rows.
        if (parent::prepareRow($row) === FALSE) {
            return FALSE;
        }
        $row->{"filepath_filename"} = $row->filepath.$row->filename;

        //dpm("After Processing:");
        //dpm($row);
        return TRUE;
    }
}

Releated question Migrate images form external source (not drupal) to Node Destination

Also posted at https://www.drupal.org/node/2613266 maybe Mike can comment on it.


texts: Injecting metadata into all nodes within one folder

texts:
For my school I need to add metadata into the  tag of every node/page within the folder /course/

The metadata is the same for every page in this folder:

<meta class="swiftype" name="tags" data-type="string" content="course" />

This will allow me to use weighting for all our course pages in the Swiftype search app.

I've narrowed it down to the html.html.twig file in \core\modules\system\templates - where I believe I need to be adding something along the lines of:

if (preg_match('$^course/', $_SERVER['REQUEST_URI']])) { print_metatag }

But I won't be wanting to use print_metatag. Instead I should be using the fixed metadata referenced above.

Can anyone help me figure out what I need to use, and where, to apply this metadata to all those /course/ nodes/pages.

Many thanks!


texts: Exclude taxonomy term from select list on node add page

texts: I have a view that shows guest user generated articles grouped by taxonomy terms. There is just one taxonomy term which I don't want that users add articles with (only logged in users should). So how can I exclude this taxonomy term from the select list on the node add page? I suppose by some function in the theme file?


texts: Possible to require custom module dependancy on a specific dev version?

texts:
Is it possible for my custom module to enforce it's dependability on a specific dev version of a particular module?

E.g. my custom module, foo is dependant on variable module 7.x-1.1+26-dev.


texts: How to obtain contents from a drupal 7 query?

texts:
I am trying to perform the below simple query:

$query = db_select('sage.USER', 'USER')
  ->fields('USER', array('USER_ID', 'OFFICE_ID'));
$result = $query->execute();

I would like to then pull out the 'office_id' that is returned by the query, which I have been told can be done with the following:

$office = $result->office_id;

However, when I do 'print_r($office)' or 'echo $office', it would seem the $office string is empty. The database is not empty and contains the appropriate values.

Could someone please how I can pull out the contents of a drupal 7 query?


texts: Best practice to deploy an update which depend of a new configuration

texts:
In an entity type, I need to replace a field by another with a more complexe behavior. This new behavior can reproduce the old field and add new. Like this behavior have an impact on the design, I need to update all entities with this new field to keep the data of the old field before delete it.

This import is done with a hook update. My problem is, in my hook_update is executed before I import my configuration. But I can't migrate my data in my new field like it doesn't exist yet. So, my question is, what's the best practice to do that:

Should I create programmatically my new field on my entity type in a hook_update and migrate my datas in the new field before import my configuration. This possibility allow me to delete the old field with configuration and everything will be over. But, if I create my field programmatically, I can do some errors or difference between what I have in my configuration. And, additionally, I want be lazy and don't reproduce a code which exist elsewhere. It's a little problem and I see I can improve this workflow.
Can I import configurations which concern only (and only that) the new field, do my migration of datas and import the rest of my configuration as usually? This seems be the best practice but I don't know if it's possible.
An other solution?

I thought about import all configurations before do the hook_update but this solution seems the worst thing to do: I can have update of contrib modules in my release and configurations could be apply only after these updates (I never met this case, but it's could be possible). Additionally, I will keep my old field until the next deploy.

I suppose my first solution is the only I can do but, maybe I don't thought about another.


texts: Alter a select form using preprocess function

texts:
For some reason I want to alter the value of a select list in an exposed form of views .

I've added this code to the template.php and also Clear the cache :

function mytheme_preprocess_views_exposed_form(&$vars) {
  $myviewID = 'views-exposed-form-ouvrage-page';
    if ($vars['form']['#id'] == $myviewID){
      foreach($vars['form']['field_categorie_tid']["#options"] as $option_term){
        $optionterm = $optionterm."test";
       }
     }
}

After this with devel themer I can see the changes that I've mad but when I clear the cache the changes dosen't take in the select list

am I missing something ? I'm new with preprocess function


texts:
How to alter form submmision response text

code below:

<?php
function response_form_alter(&$form, &$form_state, $form_id)
{
  if($form_id == 'cmis-upload-node-form')
  {
    //$form['#validate'][] = 'my_custom_validate_function';
    $form['#submit'][] = 'my_custom_submit_function';
  }
}
/*
function my_custom_validate_function($form, &$form_state)
{
  // validate here
}*/

function my_custom_submit_function($form, &$form_state)
{
  // submit here
    drupal_set_message('your Form Submitted Succesfully');
}
?>


texts: How do i get all user emails with a special flag (in example member of a Group) for a webform?

texts:
i need a Webform that send a email to group of users, which have the same interests. I use "Groups" (not organic groups, because of Drupal9) for that, so the users can decide themself to join or not.
With Webform it is possible to mail to a role of users, but not for groups. Is there a little chance, that i can select only the email-adresses from users with a special flag, like an extra field, or membership in a group ?


texts:
I have added an edit link before the title in my View by adding the field Content: Edit link on top in the fields list, excluding it from display and not adding any text in the field "Text to display". I also rewrote the output of my title field like so: [edit_node] [title].

That gives me a link with the text "Edit" just before the title (in spite of leaving the text field empty as explained above). But I would like to change that text into a symbol. I have tried a number of things including CSS, but I am stuck on this thing.

Can anyone help?


texts: Add payment to a commerce order using Rules

texts:
I am trying to create a component that can add payments to an existing order.(the payment is received offline). However, when I try to add an amount I receive the alert that the field is not writable ("The selected data property doesn't support writing"). Does anyone know how this may be accomplished using Rules?

This is my attempt so far:

{ "rules_set_order_id_as_paid" : {
"LABEL" : "Set order id as paid",
"PLUGIN" : "action set",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "orderid" : { "label" : "orderid", "type" : "list\u003Cinteger\u003E" } },
"ACTION SET" : [
  { "LOOP" : {
      "USING" : { "list" : [ "orderid" ] },
      "ITEM" : { "list_item" : "Current list item" },
      "DO" : [
        { "entity_fetch" : {
            "USING" : { "type" : "commerce_order", "id" : [ "list-item" ] },
            "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
          }
        },
        { "drupal_message" : { "message" : "[entity-fetched:order-number]" } },
        { "entity_create" : {
            "USING" : {
              "type" : "commerce_payment_transaction",
              "param_user" : [ "entity-fetched:owner" ],
              "param_order" : [ "entity-fetched" ],
              "param_payment_method" : "faktura"
            },
            "PROVIDE" : { "entity_created" : { "entity_payment_created" : "Created payment entity" } }
          }
        },
        { "data_set" : { "data" : [ "entity-payment-created:created" ], "value" : 1575626400 } },
        { "data_set" : {
            "data" : [ "entity-payment-created:payment-method" ],
            "value" : "faktura"
          }
        },
        { "data_set" : { "data" : [ "entity-fetched:status" ], "value" : "completed" } },
        { "data_set" : {
            "data" : [ "entity-payment-created:payment-method" ],
            "value" : "commerce_payment_example"
          }
        }
      ]
    }
  }
]

}
}


texts: I selected entity types and bundles in admin/config/search/apachesolr. So is there any way to featurize or export these settings? If it can be done by Strongram module which variable I should use?


texts: When I clear cache, my menu ordering seems to go out of order

texts:
When I clear cache, especially on high traffic times, my menu seems to go out of ordering. Usually I don't see any log messages except for one time:

  Message              Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction: INSERT INTO {cache_render}

That time my ram and CPU also spiked. What I mean about go out of ordering is this:

The ul.menu-level-1 is suppose to be inside the div.container, but for some reason, when I clear cache, sometimes it's rendered outside the div.container.

I am using the menu items extra module module. It does not have an issue related to this. My network team is pretty adamant that the resources I have are sufficient and i hover about 30%-40% utilization normally for my ram and cpu. The web and database nodes are separate.

I am self-hosted and have cloudflare in front of my website. I do not have caching in cloudflare turned on. Does anyone have any suggestions on what this could be. It normally only happens on my production site - of course - but it's happened on my test sites in the past as well. That's why I don't think its cloudflare.


texts: How to check if a link field uses  in template

texts:
I have a Custom Block type.
It has a link field that allows <nolink>
In the twig template for that Custom Block type I want to check if the link field has <nolink>.

I can see there is a protected value under #url for routeName that is NULL when there is a link, and <nolink> when <nolink> is used, but I can't figure out how to check it.

I can also see there's a protected uri under #url with a similar situation. If <nolink> is used, that value is NULL. If there is a link, the link is in there.


texts: Search API : Elastic Search gives priority to sort instead of title

texts:
I am using below modules for Search module:
drupal/elasticsearch_connector": "^5.0@alpha"
drupal/search_api: "^1.8"

I am using AWS Elastic Search.
What the issue I am facing is, the search result giving priority to sort instead of title.
I am using version 6.3 for elastic search. I cannot upgrade the module or Elastic Search module version due to custom dependency.
Example:

https://search-XXXXXXXXXX.ap-southeast-1.es.amazonaws.com/elasticsearch_index_drupal_product_index/_search?source={"query":{"bool":{"should":[{"multi_match":{"query":"Test
item","fields":["title.suggestion"],"fuzziness":1}}]}},"size":12,"sort":[{"field_x":"asc","field_y":"desc"}]}&source_content_type=application/json

If I have above URL then in the result it will give first priority to field_x then field_y instead of which matches to Test item
So if user is going to search with Product title, then he never get the match product at first place.
In search
admin/config/search/search-api/index/drupal_product_index/processors

Ignore case, Stemmer -> I didn't enabled
Tokenizer -> Enabled with
default settings for all fields

Am I missing something in configiration?


texts: Views Entity reference (user): how to show profile values of respective user only

texts:
i have a rather complex view and have troubles with showing the correct values. im trying to focus on the main issue.

there is a node (team) with entity reference fields to multiple users. the node has for instance two referenced user (UID 80 with 56 points on his profile, UID 23 with 23 points). now, my problem is that i cant get the view to show the correct values (points) of the respective user only. i have installed the views distinct module, but i still cant get the correct values.

what i would need is something like this:

user / points

80 / 56

23 /23

what it does is now is that it shows the values of all users that are referenced (without the views distinct module). with the views distinct module enabled it shows sometimes the values of the first user, sometimes the values of the second - but it does not show the correct values.

i hope this makes some sense. if not, i can post the whole view, but its rather complex.


texts:
I have a custom module which are basically APIs, hence require headers like content-type to be added to the responses. I was using drupal_add_http_header() in Drupal 7, but it seems to be deprecated in 8. Is there any replacement?

I did read about it on the Drupal website talking about Symfony object Response, but I am unable to use that either.


texts: how to avoid fieldset in drupal date field

texts:
I have a date field in registration form, I am using template for that. When I using  its outputs the html with fieldset. How can I remove that I wanna style likebleow fields.

Please see the image

Its drupal 7


texts:
I'm pretty unsure which form builder I should use (Webform, Form Builder etc.)

Which one are you using? Which one is still updated and so on? I want to build a form and edit entries and show them on a drupal site.


texts: HTML corrector doesn't close quotation marks in teaser

texts:
In Drupal6, I have a WYSIWYG input filter with the HTML Corrector filter enabled. When the body is automatically truncated for use in the teaser, sometimes the break occurs in the middle of an attribute value in an HTML tag (e.g. in the middle of the url in an anchor's href), resulting in an unclosed quotation mark. The HTML corrector appears to balance the unclosed tags appropriate, but it doesn't close the quotation mark.

For example, if my content body is the following one:

google.com

The teaser breaks in the middle of the URL:

<a href="http://goog

Then the tags are closed but no closing quote or the end of the opening tag:

<a href="http://goog

The result is a broken theme. Am I doing anything wrong? Is there anything that is mis-configured?


texts: Why isn't the #ajax property available for more Form API elements?

texts:
Looking at https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7.x because I haven't seen a page updated for Drupal 8, it seems like only a select few form elements are allowed to have #ajax on them.  Isn't this too limiting?  I want to do Ajax on a markup element.  There are a lot of scenarios in which I would want to do Ajax with my own custom HTML, but I don't want to lose the functionality of the Form API, like getting the $form and $form_state.

The way I see it, there are two ways of doing Ajax in Drupal, either normally by just calling a controller, or by using an element in the Form API with an Ajax callback.  If I do Ajax normally, I can create data in Javascript however I want and send it to php, but I can't get the data in Drupal's $form object or call some of Drupal's special Ajax functions like entity autocomplete.  If I use the Form API, I lose the ability to respond to any events on certain elements of the form.

Why is it like this? And, is there a way to get around it without modifying core?


texts:
I've found info to add regions to a custom layout in an Omega 4 subtheme.
Regions need to be declared in theme.info, layout.inc and then printed/rendered in layout.tpl.php.

I've done all that and they don't appear on the page after cache clearing.

Note:

They do appear in /admin/structure/block (I can add blocks to the
regions there but they aren't displayed on the actual pages).
The regions also appear if I edit the theme.info file, and
templates/system/page.tpl.php file, and disable the use of layouts in
omega 4 subtheme settings.

Code i used in following files:
/theme.info

regions[footercolumnone] = Footer Column one
regions[footercolumntwo] = Footer Column two
regions[footercolumnthree] = Footer Column three
regions[footercolumnfour] = Footer Column four

/layouts/owr/owr-layout.tpl.php

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

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

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

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

/layouts/owr/owr.layout.inc

regions[footercolumnone] = Footer Column one
regions[footercolumntwo] = Footer Column two
regions[footercolumnthree] = Footer Column three
regions[footercolumnfour] = Footer Column four


texts: Prevent Multiple user registrations from single IP

texts:
I'm using Drupal 6.19.I need two things to be done.First thing, I want to disable multiple user registrations from the same IP.The Second thing is ,I want to allow only 3 user to register at a time.
Anyone know this how to do in Drupal6.19?

Please help me to do this.


texts: How to use token [comment:original:url:absolute]

texts:
I want to use the token service for [comment:original:url:absolute].

As far as I understand, it should be something like this

$message = $token->replace('Hello the comment is: [comment:original:url:absolute]', ['comment' => $comment_entity]);

Unfortunately, it doesn't seem to work like this.

I'm not sure what I'm doing wrong here since the documentation is vague when it comes to specific examples.

Any pointing in the right direction is appreciated.


texts: How to select taxonomy term based on current language?

texts:
My website has 3 languages. The Tag taxonomy is multilingual and for each term I added its translation. I created a block of a view using the Views module that selects one random term and displays it.

I need this block to show its content in the language currently set.

How can I do this?


texts: View is using original template rather than new custom template

texts:
I have copied the views-view-grid.tpl.php file from the views module theme folder into my sites themes/my_theme/templates folder and renamed it views-view-grid--panel-pane.tpl.php, as was suggested in the 'Theme: Information' tab.  After a rescan and flushing of caches, the views-view-grid-panel-pane is bold in the tab, however, my changes are not reflected in the preview.  Am I missing a step?  I copy/pasted the file name, and triple check it, and it's bold, so I feel pretty confident that's not the issue.

Thank you


texts: Drupal content slider like ImageFlow and GalleryFormatter

texts:
I am looking for Drupal modules that allows to create content sliders (img,audio,video) like ImageFlow and GalleryFormatter.

But those modules supports only images.

Are there any modules for creating content sliders like above?


texts:
How I can add a class="" to anchor on the "read more" links of a node.
Im use a bootstrap theme and i need add de btn-default class to anchors, thanks

    <<<<<<<< SET A CLASS IN THIS ANCHOR ? >>>>>>>>>>

      Read more
       sobre Noticia 2


texts: How to asynchronously execute/render a view using views_embed_view in a template file?

texts:
I have the latest Drupal 7 running on a Centos OS.

I have a content type named publications which is composed of lets say around 20 fields (i.e. publication title, name, doi, authors, keywords, date, chapter, etc etc.).

I have Staff content type that references Publications using Entity References. One of our staff has around 700 publications (700 references from Staff node to publication nodes).

I have a view of type page with following features/conditions:

Contextual filter that accepts username of the staff as arg (filters only those publications referenced by that staff whose username is supplied as argument)
Filter on Staff and Publication content types
Relationship (A bridge to the Content entity that is referencing Content via field_staff_selected_publication)
Show output as Fields (I construct a publication entry that should look as follow using the fields of publication content type)

Role of aberrant HLA-DR expression and antigen presentation in
induction of endocrine autoimmunity. Bottazzo GF, Pujol-Borrell R,
Hanafusa T, Feldmann M . Lancet 1983; 2: 1115-1119

The execution time is directly dependent upon the number of publication nodes, one of our staff has around 600 publications and I have get the following execution times for him:

Query build time    4.35 ms
Query execute time  60.24 ms
View render time     6226.73 ms

Executing the view for a staff that has 170 publications, I get the following time

Query build time    1.8 ms
Query execute time  18.99 ms
View render time    2107.41 ms

I have the following code to attach the view in the node template file (node--staff.tpl.php)

      <?php print views_embed_view('selected_publications', 'page',$node->field_staff_username['und'][0]['value']); ?>

      <?php print views_embed_view('all_publications', 'page',$node->field_staff_username['und'][0]['value']); ?>

Opening the staff profile with huge number of publication causes a delay in page showing up because, obviously Drupal executes the view and gets back the result and render it. I do know that Views cache or Boost module might help me here to cache the result of the view rather then execute it every time the page is visited but, I am looking for a more efficient approach.

I would like the node--staff.tpl.php page to execute the views_embed_view only when the document loading is done (this would render everything else in the page but, the publication parts will get rendered afterwards).

OR

I would like the views_embed_view to be  executed asyncronously (in the background) via ajax or similar solution. The would avoid the page from waiting and while the user is looking at the rest of the page, the publications are rendered in the background.

At the moment, opening the profile page of one of our scientists with 600 publication take around 10 seconds, I believe 8 second of that is because of rendering the view, If I be able to do this 8 second in the background, that would be AMAZING.

Thank you in advance for you help/advise.


texts: Field Collection Major Error! Help Needed!

texts:
After trying to add new field collection item, I get this message in Chrome when going back to the previous page in browser:

  Notice: Undefined offset: 92 in field_collection_field_widget_embed_validate() (line 1675 of /sites/all/modules/field_collection/field_collection.module).

and when I tried to save I got this:

  EntityMalformedException: Missing bundle property on entity of type field_collection_item. in entity_extract_ids() (line 7734 of /includes/common.inc).

I should add that I'm having 92 items in my field collection. When I work in Firefox the browser just freeze. Can't find any other solution to my site at the moment then to use field collections this way. Any thoughts? I wonder if a field collection inside a field collection would decrease the heavy JavaScript load?


texts: How do I schedule a publishing date for a node I've created but don't want to publish until a certain date/time?


texts: How do I save session data for the anonymous users?

texts:
In my last project for Drupal 6, I did save the data using code similar to the following one:

$_SESSION['xxx'] = serialize($data);

In Drupal 7, it doesn't work.

How should I save the session data for the anonymous users, in Drupal 7?


texts: Drupal Commerce Relationship Description

texts:
A small question:

Shouldn't the Help text in the commerce_line_item module at line 1582 that defines the relationship between commerce_line_items and commerce_orders say something like "Relate this entity to the order to which it is attached".  As it now stands, the text says "Relate this entity to the line items reference by its commerce_line_items field".  Which doesn't seem to make much sense.


texts: Translate hard-coded strings with source language other than english

texts:
I building a custom module for a multi-language Drupal 7 site where the default language is not english. Now I want to translate the module. Since my source strings are not in english I cannot use t().

The i18n module provides a i18n_string() function which would seem to do the job but I can't find my strings under admin/config/regional/translate/translate? I even implemented hook_i18n_string_info() to define my own textgroup, which shows up, but the strings don't!

What am I missing? Or is there a better way to translate strings that are in an other language than english?


texts: How to make direct editing of cck imagefield?

texts: How to make direct editing of cck imagefield on a user profile node. I want to add link → edit profile photo, which will directly allowes you to change the image. Is that possible?


texts: In the core within the comment module a widget is provided by CommentWidget.php file (namespaceDrupal\comment\Plugin\Field\FieldWidget;). In this widget comment settings like open, close, hidden is provided. I am able to understand its working but not able to find from where it is being further controlled. By controlling I mean where in module (node or comment) status of comment is being processed, how the node decides whether it should show comments or not. Please tell me the file in the core where I should be looking for the code which does this processing. Thanks.


texts: How to theme one specific Views 3 exposed filter form template and HTML?

texts:
I know of two ways to theme views exposed filter forms in Views 3:

Copy the file views-exposed-form.tpl.php in sites/all/modules/views/theme to your theme folder and edit the HTML directly
Use hook_form_alter in your template file, for example:

.

   function yourtheme_form_alter(&$form, $form_state, $form_id) {
     switch ($form_id)  {
       case 'views_exposed_form':
         # do things to the array
       break;
     }
   }

My problem is, I have different exposed filters on different views, and these approaches both hit all exposed filters equally. There's also nothing about exposed filters templates in the Theme Information on the views edit page.

How can I target these to one specific exposed filter on one specific view?

Views 3 with Better Exposed Filters (BEF) module, Drupal 7.


texts:
How to create a contextual filter using a current user multivalue field as the default value?

The idea is to filter content in a view, based on a value present in a multivalue field that the currently logged in user account has.

I tried using views php in the default contextual filter:

$user_profile = user_load($user->uid);
$statusvalue= $user_profile->field_status['und'][0]['value'];
return $statusvalue;

..but that works for a single value and thus does not work in my case.


texts: Commerce 2.0: How can multiple email addresses receive copies of orders?

texts:
If I understand the configuration correctly, only one email address can be specified when defining a Store (the text under the field says "Store email notifications are sent from this address".

When a person places an order, they will receive an email confirmation showing as being sent from that Store owner's email address. No one else - not even the store owner - gets an email copy of the order.

I am converting a client's website from Wordpress to Drupal 8. Their current configuration is that four different people in the office all receive email copies whenever an order is placed. How can the same be implemented in Commerce 2.0? (They don't want to log into the site and check the database for new orders - they want the email notifications sent to them if and when orders are actually placed.)

Has anyone already implemented something similar?


texts: Not able to set the time for auction products, using the Ubercart Auction module

texts:
I guess this question is for those of us using the ubercart auction module

This module allow you to make auction of products (of the Product Content Type generated by Ubercart). When you create a new product you have to fill the Auction Settings and in there you have to set the expiration date and time of the auction.

My problem is that I see the field to set the date but no input is shown to fill the time (i.e.: 18:00:00).

The README file of the module says:

  Use the "Expiration date and time" field to set the expiration time for the auction.

then I understand that this is either a bug (I already posted the issue) or I have a mis-configuration on my site.


texts: how to pass variables from one module to another module?

texts:
I wanted to use apachesolr module along with a field module that is custom written.

The field module gives the input to 'apachesolr' module instead of the normal search bar. The output is passed through the field module. The output is printed as the field output.

Will module_invoke() be helpful in these cases?

I want to pass variables from one module to another module like the input and output.


texts: The array $form_state undefined with ajax

texts:
Why when I submit form generated with ajax, the array $form_state is undefined?

this is a part of module:

1)

$form['#tree'] = TRUE;

$form['addTel'] = array(
        '#type' => 'submit',
        '#value' => t('Add'),
        '#submit' => array(
            'call_tel'
        ),
        '#ajax' => array(
            'callback' => 'call_addTel',
            'wrapper' => 'my_wrapper'
        ),
    );

2)

//call_tel ajax
function call_tel($form, $form_state) {
    return $form['telefono'];
}
//callback
function call_addTel($form, &$form_state) {
    $form_state['i']['tel']++;
    $form_state['rebuild'] = TRUE;
}

3)

//this is a form generated
$form['tel']['my-tel']   = array(
                '#title' => t('Telefono'),
                '#type' => 'textfield',
                '#markup' => '',
                '#id' => 'campo-telefono[]'
            );

Why I call $form_state['values']['tel']['my-tel']['#value'] after submit it is undefined?


texts: Files in the file_managed table with status of 0, not deleting on cron

texts:
I have a form where I am uploading files to the "sites/default/files" directory. I am using the managed_file type in my form API definition. This is all working fine and I notice that in the file_managed table, I see my uploaded files with a status of 0 meaning they are temporary. I was under the impression that these files that have a status of 0 should get deleted, not only from the database, but physically from the server on cron run, but I do not see this happening. I see lots of files with a status of 0 and they are NOT in the file_usage table, so they are not being used by anything, yet if I force a cron run, I don't get errors, yet the files do not get deleted either. Am I misunderstanding how this system works?

Thanks


texts: Howto limit access to a main menu link using drupal 7 api

texts:
in my scenario I am using Drupal 7 with the ubercart modules. I like to add a link in my main menu that is only visible if you are an authenticated user.

For testing purposes I am using the bartik theme.

It is the same function like user/login, which is only visible if you are an anonymus user.

I found some hints and even examples in the drupal api - like

https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_menu_alter/7

The following implements hook_menu_alter to remove access to the "forum" tab for the anonymous user:

/**
* Implements hook_menu_alter.
* Check access for forum menu item.
*/
function MYMODULE_menu_alter(&$items) {
$items['forum']['access callback'] = '_accesscheck';
}

/**
* Callback to disallow access for the anonymous user.
*/
function _accesscheck(){
  global $user;
 return $user->uid;
}

Even after many attempts, I can't catch a value for $items, I was using main_menu.

I like to use the function in the theme template. How can I find the variables that I need to alter one item of my menu - I called it > cart <.

I even tried to print_r($items), but nothing was found.

How can I retrieve $items for the main menue


texts: Account creation emails not being sent but other emails are

texts:
I have a site that was upgraded from D6 to D7 and is now hosted on Pantheon. I'm using the SMTP module and SendGrid for deliverability. The "require email verification when a visitor creates an account" setting is checked. When someone registers as a new user, the message saying that an email has been sent to their account is displayed on screen. However, neither watchdog nor Maillog shows any evidence that an email was sent, and no email is received.

Other emails, including password reset, Webform emails, Comment Notify, etc. all are sent and received as expected.

What could be causing the new user email not to be triggered?


texts: How do I call a PHP function in all the pages?

texts: I used the Boost module for performance issues, and it creates _.html files every time it serves a file from the cache. I need to write a PHP function it should call every page, even the cached ones. How can I achieve this?


texts: DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data()

texts:
DrupalTemporaryStreamWrapper::stream_open call failed in file_unmanaged_save_data()

I do not identify the problem. Could anyone help me?


texts: Issue : Create a new alias. Leave the existing alias functioning

texts:
I tried to save my old alias in Drupal 7 using Pathauto module.

I am selecting the "Create a new alias. Leave the existing alias functioning." in Settings. But, It deletes the old URL. Only current alias is working.

Can anybody suggest on this how to reproduce it.


texts: View to show node titles only when a new comment has been posted?

texts:
I am trying to create a view that will show the titles of all nodes only when these nodes have new comments. I need a filter like "Content has new comments" but there isn't any.
Can somebody help?


texts: How can I display a Browser Prompt for Confirmation before executing ajax callback for a button element?

texts:
I have a button type element in a form. It has an ajax callback to some function that performs a delete operation. Everything works perfect.

I want to add a browser prompt when user clicks on the delete button. The prompt should ask user to confirm the delete action and only after the confirmation should the callback function be executed (using ajax of course).

How can I do this?

Following is the code for button element:

$form['delete'] = array(
  '#type' => 'button',
  '#value' => t("Delete"),
  '#element_validate' => NULL,
  '#ajax' => array(
    'callback' => 'delete_something',
    'wrapper' => 'delete-message',
  ),
  '#limit_validation_errors' => array(),
);

function delete_something(){
  //Some Code
}


texts: How to allow the user to change the language?

texts:
I think I must be missing something here.

I have enabled the multilingual modules and added a language. It all seems to be working with respect to translating content - an admin can easily translate an individual page. However I can't see how to give an anonymous user the ability to change their selected language. I was expecting the multilingual modules to create Blocks that would allow a user to change their default language and which would notify them if a particular page is available in another language. So my questions are:

1) How do I allow an anonymous user to change their preferred language?
2) How do I alert an anonymous user to the fact that a particular page is available in another language?


texts: Does elysia cron need to be executed through Drush cron?

texts: I am trying to understand how Elysia Cron works. If I execute the cron through a curl/wget requests, will the elysia cron still run normally without risking timeouts? Are there any advantages to running it through Drush rather than curl/wget?


texts: In hook_user_login is there a way to know if this is the first time the user has logged in?

texts:
I'm overriding hook_user_login to redirect users to a specific page when they log in. The problem is I'm using the verification email setting on registration which requires the user to set their password on first login, but I redirect them so some users aren't able to login the 2nd time to the site.

Is there something I can check in hook_user_login that will tell me if this is the first time the user has logged into the site?


texts: Access denied when view quiz question by itself

texts: If a user tries to access a quiz question, they get an access denied message because I have configured the permissions so that users can't view questions outside of the quiz. Is there a way they can be redirected to the beginning of the quiz or for me to change it so they don't just get an "ugly" access denied error?


texts:
In a user profile I have start date and end date, I want to send the mail to user every months once based on the end date.

The end date also needs to get updated automatically, based on the start date i.e. every months from current date (start date).

Can anyone help me on this?


texts:
I have custom module with page at /page wich expects $_GET['id'] to do it's job.

Here's .htaccess rewrite rule that works on empty website

RewriteRule category+/(.*)$ page.php?id=$1 [L]

On Drupal 8 I suppose that line should be

RewriteRule category+/(.*)$ page?id=$1 [L]

but it gives me 404 Error when i visit /category/5


texts:
How to modify Drupal user's cookie so the cookie is not available anymore after a predefined time or when the user close his web browser or close all of the websites pages open in tabs ?

After some online searches i found that by setting the cookie lifetime to 0 should create temporary cookies that would be deleted once the browser is closed:

I first tried by modifing some ini_set() values in the settings.php :

ini_set('session.cookie_lifetime',  0);
ini_set('session.gc_maxlifetime',   0);

I created a php.ini file located at the drupal site root, containing:

session.cookie_lifetime = 0;

But it does not work on my test site. Any ideas?


texts: How do I get an image path from field preprocess function

texts:
After 3 hours of searching the web for this I gave up...

I have added a "banner image" field to the basic page. I want to use the image as a background. I wanted to capture the image path in a preprocess_field function but I tried every possible methods on the \Drupal\image\Plugin\Field\FieldType\ImageItem object and can't seem to find the way to get the path.

mytheme.theme:

function mytheme_preprocess_field(&$variables){
  if($variables['field_name'] == 'field_banner_image'){
    /** @var \Drupal\image\Plugin\Field\FieldType\ImageItem $field */
    $field = $variables['element']['#items'][0];
    $variables['banner_url'] = $field->getValue(); // not working, tried everything...
  }
}

Then in my field--field-banner-image.html.twig:


texts: Guzzle httpClient Drupal Core throwing cURL error 28 Operation timed out

texts:
I have been loading the httpClient Core Service in a drupal 8 site. The service class works just fine when the request doesn't take too long from the API. It seems that if the request takes any longer than about 20-30 seconds the site throws a cURL response error 28 saying

GuzzleHttp\Exception\ConnectException: cURL error 28: Operation timed out  after 30000 milliseconds with 0 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in GuzzleHttp\Handler\CurlFactory::createRejection() (line 186 of ../vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php).

After a bit of poking around online I saw some reference to the fact that the "CURLOPT_TIMEOUT_MS" error doesn't work with all versions of php and they suggest to replace the reference to "CURLOPT_TIMEOUT_MS" to "CURLOPT_TIMEOUT" same for "CURLOPT_CONNECTTIMEOUT_MS".

In the above file with the error I found that in lines 374-380 which read the following

if (isset($options['timeout'])) {
  $conf[CURLOPT_TIMEOUT_MS] = $options['timeout'] * 1000;
}
if (isset($options['connect_timeout'])) {
   $conf[CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000;
}

if it's changed to the following

if (isset($options['timeout'])) {
    $conf[CURLOPT_TIMEOUT] = $options['timeout'] * 1000;
}
if (isset($options['connect_timeout'])) {
   $conf[CURLOPT_CONNECTTIMEOUT] = $options['connect_timeout'] * 1000;
}

removing the "_MS" then the site doesn't throw any errors.

Is this an error in the core code? Is this issue possibly related and can it be fixed with the patches attached to this d.o issue? Also please see this comment on that issue with reference to what I mentioned above.

Any suggestions or direction on this would be greatly appreciated!


texts:
Is there a way to take multiple style image for one image field?
I want to use a 150×150, 180×180, and a 300×300 style at the same time.


texts: How to resolve Catchable fatal error in entity.inc?

texts:
Locally (WAMP) I have created a new GIT branch to install Drupal Commerce on my site. Everything went well and I have begun configuring my new shop. But when I decided to pull this branch into my remote test site, I get this error:

  Catchable fatal error: Argument 2 passed to SelectQuery::fields() must be of the type array, null given, called in /home/httpd/mysite/test.mysite.se/includes/entity.inc on line 317 and defined in /home/httpd/mysite/test.mysite.se/includes/database/select.inc on line 1316

Since I can't reach my admin pages (white screen with error message) and Drush stopped working as well, I used MySQL from the command line to import the database on the remote test site. So now both the codebase and the database should be the same on the remote test site as I have locally. Instead I get the above error. Any ideas? I have a feeling that Rules is involved in this, but that's just a feeling.

I have now done everything from the beginning, with the same result. I have installed all the commerce modules and their dependencies (Entity api, Rules, Address field etcetera) in the suggested order. Everything works fine until I export a database dump and add & commit all changes to my new git branch. After pulling that branch and importing the database dump in my test site (or even locally), I get the message above.

I have managed to run cron, which gave me this message:

  User warning: Missing database columns for the exportable entity
  rules_config as defined by entity_exportable_schema_fields(). Update
  the according module and run update.php! i _entity_defaults_rebuild()
  (rad 872 av C:\wamp\www\sites\all\modules\entity\entity.module).

... allthough I am using the latest version of Rules and when I run the database update, the message is that there is no update pending.

I have also seen this warning:

  Warning: array_flip() expects parameter 1 to be array, null given i
  DrupalDefaultEntityController->buildQuery() (rad 308 av
  C:\wamp\www\includes\entity.inc).

Any hints on what I can do to get my site back on track?


texts: Change formset default from collapsed to exanded?

texts:
I'm working with the Support Ticketing System module in Drupal 7. My clients would like to be able to see at a glance who is subscribed to notifications on a ticket. The Subscribed field is collapsed by default, meaning the client has to click on the Subscribed link to expand the field to see the users subscribed.

How can I change this so that the field is expanded when the page loads, and save my clients a click?

EDIT: The node is variable--when creating a new support ticket, it will be /node/add/support-ticket. After the ticket has been created, it could be anything.

But the particular fieldset I want to target will always have the id "edit-subscribed".


texts: Template images are not being loaded, after moving to a differen folder

texts:
I have moved my complete Open Atrium 2.44 installation from "./Test" to the root folder ("./".)
Everything is being displayed as neatly as it would be but a few default links towards images are still pointing to folders whitin the "./Test" folder.
Is there a setting within Open Atrium 3.44 where i can change the base directory to "./".

As an example:
Open Atrium points to: example.com/Test/profiles/openatrium/modules/apps/oa_home/images/bg-hero-line.png

While the path of the "bg-hero-line.png" picture actually is:
example.com/profiles/openatrium/modules/apps/oa_home/images/bg-hero-line.png

Thanks in advance :D


texts: I upgraded my Drupal 8 site from 8.4.5 to 8.5 and I noticed the role visibility in blocks disappears. I did a clean install and it's in Drupal Core, so the problem is not with my upgrade. I am thinking it's in the database but I have no idea how to track it. Does anyone know how?


texts: Drupal 6 - specific template if node contains specific form element

texts:
I am trying to do a check for if some node contains an input element of type = hidden and with value = 'something'. If this is the case, some specific template should be used for the template.

I am trying to do this check in template.php using the template_preprocess_node() method where I have access to the $vars ($vars['node']) variable. However the only solution I can come up with is to loop through $vars['node']->webform['components'] and to check for the input type and after that the value.

However I dont find this approach elegant, what are my options?


texts: How can I change the display settings of the referenced field, programatically?

texts:
A paragraph entity references a media image field, and it needs to change its display options in code.

How can I achieve this?


texts: How do I group by and display only first row of each group?

texts:
I want to apply aggregation on my view so that only first row of each group should be displayed after group by aggregation.
I have a view with two fields Subject and Due_Date and sorted values like,
Subject     Due_Date
A               2016-03-24
A               2014-06-28
A               2012-10-15

B               2013-11-21
B               2011-10-18
B               2010-03-04

C               2013-07-13
C               2012-12-09

After group by aggregation I want it to have like this,
Subject     Due_Date
A               2016-03-24
B               2013-11-21
C               2013-07-13

It should only have the first row of each group.

I have tried Views aggregator plus, but it is just hiding the values and not eliminating them. With that I couldn't get my filters working the way I need.
Is there any solution for this to work?


texts: I have a polls module that comes with drupal 7 enabled, But I need to attach an image filed to a choice, so when users add a choice to pull they get to add an image to it not to the node itself. is there a way to add this image?


texts: How do you get the last star to be only star shown in a rating?

texts:
The out of the box process with fivestar will show star 1,2,3,and 4 highlighted (it will show all stars up to the actual vote). I need stars except the actual vote to be the neutral or the unselected star.

Say for example, someone votes 4 out of 5. How do I show ONLY 4th star highlighted while all the others are either the neutral or unselected star?

EDIT: After reviewing fivestar.js, I believe the code that handles highlighting is the following;

$container.find('.star:lt(' + index + ')').addClass('on');
      $container.addClass('fivestar-widget-' + ($options.length));
      $container.find('a')
        .bind('click', $this, Drupal.behaviors.fivestar.rate)
        .bind('mouseover', $this, Drupal.behaviors.fivestar.hover);

      $container.bind('mouseover mouseout', $this, Drupal.behaviors.fivestar.hover);

      // Attach the new widget and hide the existing widget.
      $select.after($container).css('display', 'none');
    });
  },
  rate: function(event) {
    var $this = $(this);
    var $widget = event.data;
    var value = this.hash.replace('#', '');
    $('select', $widget).val(value).change();
    var $this_star = $this.closest('.star');
    $this_star.prevAll('.star').andSelf().addClass('on');
    $this_star.nextAll('.star').removeClass('on');
    event.preventDefault();
  },


texts:
My client would like me to replace the s's with just ' on the links and breadcrumbs of user blogs for user names that end in s.

For example, the breadcrumb and blog links for the user Joe would remain Joe's blog while the breadcrumb and links for user Chris would be Chris' blog (instead of Chris's blog).

I searched for this and although I did find a way to do this inversion 6 it doesn't seem to work in version 7.

How can I do this?


texts: how to set cron correctly on a shared server

texts:
I set the following command for cron on a shared server.

/usr/bin/php5.3 home/public_html/cron.php

(All the Drupal files are under /public_html)

This commend seems to be working but I get the following error

PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/public_html/sites/default/settings.php:1) in /home/public_html/includes/bootstrap.inc on line 1163
Sorry,  has been banned.

Am I missing something?


texts: How to optionally redirect to a payment page after adding a node?

texts:
I want to add an option to the node add form so that the user who creates the node can choose if the node will be " promoted " or not. If the promoted option is selected, then I want to redirect the user to a payment page, so that the option charges can be payed.

Any suggestions about how to do so?


texts: How do you change the LDAP DN for a user?

texts:
We are using LDAP integration on a Drupal 6 system (with the "LDAP authentication" module).

During initial log-in, the user account will be created and the DN (Distinguished Name) for that user will be set automatically.

Now, due to some structural changes, the DN for some users will change slightly.

Is it possible to somehow change the DN that is used by Drupal, or to force some kind of "re-authentication" of Drupal Usernames with the Active Directory? Or do I have to edit the ldap_dn in the database?


texts: Using groupby in hook_views_query_alter()

texts:
I have a view that is using a format that doesn't include group by fields in its settings. I'm trying to mimic that by using the hook_views_query_alter() function in a module.

I know the code is running, because I see the DPM value and the error log string, but the group by doesn't seem to be working. I know that group by in views is a different thing than mySQL's group_concat (which you can use via aggregation, but that doesn't work in this case because we need one field to not be aggregated.) So I'm not expecting to see a group_concat in the printed-out query. But I would have expected it to produce the same results as if I had set up Group By in unformatted list settings for the same four fields (which does work as expected.)

Here is what my view looks like without any group-by (either in the settings or the module):

You can see that there are two complete chunks of information for April Carlisle, because she is speaking at two sessions.

If I turn on Group By for speaker name (content: title), job title, and company in unformatted list settings, this is what I get (and what I want):

So I had thought that my module code would reproduce that result, but it's not. Can anyone tell me why?

Here's the main function:

function group_speaker_carousel_views_query_alter(&$view, &$query) {
  switch($view->name) {
    case 'speakers_carousel':
      error_log("view name now: ".$view->name);
      $query->groupby[0]['field'] = "title";
      $query->groupby[1]['field'] = "field_job_title";
      $query->groupby[2]['field'] = "field_company";

      $select_query = $query->query();
      $query_string = (string)$select_query;
      dpm($query_string);
      break;
  }
}


texts:
I am trying to make changes to a saved "selection rule" on one of my Panels, but when I click the settings gear icon, the icon moves on top of the "Delete" icon for a second, then moves back alongside - but no modal pops up.

Tried:
 - disabling javascript in browser (results in a page of code after clicking gear)
 - Using a different browser

Checked status page for errors
Switching versions of jQuery (via jQ update) as well as source CDN
Clearing caches
Restarting httpd
Testing it on my dev server with a similar environment - works fine
Tried the same operation in another Drupal installation on the same server, and the same modal works fine with that one.

The site is on a Centos 6 VPS running CPanel, APC and memcached, and behind Varnish.

I see nothing related in /var/log/messages, domlogs, error logs or watchdog, nor in the console.

When a Panels modal works (e.g. clicking the gear icon for a rule in the Context section of the same Panel) the console shows "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/."
But on the site where it works, this message doesn't show up in the console. This is the closest thing to a clue I've been able to find, but I don't know what it means.

Any suggestions how to fix it, or even how to diagnose what the problem is?


texts: VBO Pass Argument to Custom Action Function

texts:
I have a view that list entities. It has a VBO field on it for executing a few custom actions.

I can get the actions working, but I need to add a field to the operations form on the view which lets the user select a date field. I then need to pass that date value on the VBO form submit, to the custom action, so that I can use it to manipulate some entity data.

I am able to add the date field via this method:

function mymodule_views_bulk_operations_form_alter(&$form, &$form_state, $vbo){
    $form['vbo_set_close_date'] = array (
        '#type' => 'date_popup',
        '#title' => t ('Set Close Date'),
        '#date_format' => 'm/d/Y',
        '#date_label_position' => 'within',
        '#weight' => 1000,
    );
}

Now I am stuck because that data doesn't get passed to my custom action, and I'm not sure what the correct method would be to accomplish that. I've though of adding a custom form submit handler, but still not sure if that's working because I can't seem to get it to trigger.


texts: How to highlight only unpublished nodes in views result

texts:
I have a node view with bulk operation style which is available for only admin role.
I would like to hilight only the unpublished nodes. It doesn't matter if just one of the fields or whole row of those nodes are hilighted.

I suppose I need to add special css class to unpublished nodes but how can I do that?


texts:
I have installed these modules:

Media Entity
Media Entity Image
Entity Browser

When I try to add an image field, I have no widget for Media like there was in Drupal 7.
I also tried to add a reference to a media, but it doesn't seem to work.

What am I doing wrong?


texts: Views don't display any result until the exposed form is submitted

texts:
I have a view that display content on my website, but now (i don't know why) my view show results only when i submit the exposed form.

I would like my view display all result by default.

Any idea ?


texts:
I am passing multiple tags into an exposed field separated by a comma. If a single tag doesn't have a result, it ruins the entire view.

Is there a way to treat the extra tags as optional?


texts: How to add backgroud image to bootstrap flatly?

texts:
Hi Im not a theming hero,

Im an happy user of drupal8 and bootstap theme flatly.

I would like to have this sitebranding logo as a background image.

After 2 days of watching youtube tutorials about theming up bootstrap I can;t figure it out where to make the right modifications?

please help


texts:
I am building on an existing site, adding / modifying functionality to it.

There is a form, which is a part of a (sort of a) multi-step form which I need to alter, and add another form to it.

So, I added the following to the existing form:

// Some form elements above this.
$form['new_form_element']['search'] = drupal_get_form('MY_PROJECT_search_form');
// Some form elements after this

And the MY_PROJECT_search_form function returns the form, which is then embedded in the original form. The form is rendered properly.

However, when I submit the form, I get the following notice :

  The form has become outdated. Copy any unsaved work in the form below and then reload this page.

I believe that is because the two forms are getting submitted at the same time, and the submission of one of them is failing.
I have tried adding $form_state['rebuild'] = TRUE to the submit functions, but it did not work.
I have also tried adding an markup type field and embedding form in as
'#markup' = render(drupal_get_form('MY_PROJECT_search_form'));
But, I am not able to implement AJAX in the embedded form after that.

Is there any other better way to embed a form?

Note: There is no other option then to embed a separate form to the current form.


texts: Field widget value not able to save via ajax

texts:
I am trying to create a custom field type widget with a ajax submit handler to save the value of the field to the database without saving the whole node.

Here is my code hook_field_field_info().

function mymodule_field_info() {
  return array(
   'time_logger_time' => array(
   'label' => t('Time loger'),
   'description' => t('Custom Poutine Field'),
   'default_widget' => 'time_logger_time_widget',
   'default_formatter' => 'time_logger_default_formatter',
   ),
  );
 }

Than this is my  hook_field_widget_info()

function mymodule_field_widget_info() {
   return array(
   'time_logger_time_widget' => array(
   'label' => t('Default'),
   'field types' => array('time_logger_time'),
  ),
 );
}

And finally my hook_field_widget_form() looks like

function mymodule_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
    $value = isset($items[$delta]['id']) ? $items[$delta]['id'] : '';
     $element['id'] = array(
       '#type' => 'textfield',
       '#size' => 6,
       '#default_value' => $value
      );

     $element[submit] = array(
      '#type' => 'button',
      '#value'=>'Save',
      '#name' =>  'submit-'. $delta,
      '#ajax' => array(
        'callback' => 'mymodule_ajax_handler',
        'effect' => 'fade',
       ),
   );
   return $element;
 }

Idea is when I click the save button in my widget form it will call my ajax callback load the node, set the value of my field and save the node as follows-

function mymodule_ajax_handler( $form, &$form_state){
     $node = node_load(22);
     dsm( $node);
     $node_wrapper = entity_metadata_wrapper('node', $node);
     $node_wrapper->field_log->set(1);
     $node->save();
 }

But when I click button I am getting some error saying  "Notice: Undefined index: field_log in EntityStructureWrapper->getPropertyInfo() (line 334 of /var/www/html/mysite/sites/all/modules/contrib/entity/includes/entity.wrapper.inc)."

If I change my field in the ajax callback to some other field in my content type its saving fine. Like below-

function mymodule_ajax_handler( $form, &$form_state){
 $node = node_load(22);
 $node_wrapper = entity_metadata_wrapper('node', $node);
 $node_wrapper->some_other_field_from_my_content_type->set(1); //This works fine
 $node->save();
}

Is there anything wrong in my widget form.

Here is my field scheme if someone want to refer-

function mymodule_field_schema($field) {
$schema = array();
$schema['columns']['id'] = array(
    'type' => 'varchar',
    'length' => 50,
    'not null' => FALSE
);
  return $schema;
}


texts: Is it possible to hardcode views as part of the custom module to avoid `config/sync`?

texts:
I've exported views into the custom module using Drupal Console and config:export:view command, so they exist as part of the module in modules/custom/my_module/config/install (YAML files).

After I've enabled the newly created custom module, the views are imported on install as expected.

However when I'm trying to to do config import (drush config-import), Configuration Manager wants to remove the views. Respectively, when I want to export (drush config-export), it asks to create them in ../config/sync (despite they're already existing in the module it-self).

What I'm looking is, the ability to hardcode the views into custom module, so they won't be part of ../config/sync anymore, so config import won't affect or remove them. In other words, I'm looking for locking down mechanism to avoid accidental removal during config import on the production (something similar to hook_views_default_views in D7), where views are hardcoded as part of the code.


texts: Paragraph fields as node tokens in Drupal 7

texts:
Is there a Drupal 7 equivalent to [node:field_paragraph:0:entity:field_hero_image]?

I'm trying to use an image field in a paragraph as the og:image using the Metatag module, but the only token I can see is [node:field_paragraph] and I can't see a way to access fields in the paragraph.


texts:
I am trying to implement a multistep registration form where if the user drops off the first step I then email them a link several weeks later for them to continue to step-2

http://example.com/user/register/step-2

After step two is complete the receive an email asking them to verify the account.

How do I load the users previous data if I send them directly to step2 at a later date. My ctools multistep currently looks like this after following this guide

function MYMODULE_registration_ctools_wizard($step = 'step-1') {
  // Include required ctools files.
  ctools_include('wizard');
  ctools_include('object-cache');

  $form_info = array(
    // Specify unique form id for this form.
    'id' => 'multistep_registration',
    //Specify the path for this form. It is important to include space for the $step argument to be passed.
    'path' => "user/register/%step",
    // Show breadcrumb trail.
    'show trail' => TRUE,
    'show back' => FALSE,
    'show return' => FALSE,
    // Callback to use when the 'next' button is clicked.
    'next callback' => 'MYMODULE_registration_subtask_next',
    // Callback to use when entire form is completed.
    'finish callback' => 'MYMODULE_registration_subtask_finish',
    // Callback to use when user clicks final submit button.
    'return callback' => 'MYMODULE_registration_subtask_finish',
    // Callback to use when user cancels wizard.
    'cancel callback' => 'MYMODULE_registration_subtask_cancel',
    // Specify the order that the child forms will appear in, as well as their page titles.
    'order' => array(
      'step-1' => t('Step One'),
      'step-2' => t('Step Two'),
      'step-3' => t('Step Three'),
    ),
    // Define the child forms. Be sure to use the same keys here that were user in the 'order' section of this array.
    'forms' => array(
      'step-1' => array(
        'form id' => 'user_register_form'
      ),
      'step-2' => array(
        'form id' => 'MYMODULE_registration_group_info_form',
        // Be sure to load the required include file if the form callback is not defined in the .module file.
        //'include' => drupal_get_path('module', 'MYMODULE_registration') . '/MYMODULE_registration_groups_form.inc',
      ),
      'step-3' => array(
        'form id' => 'MYMODULE_registration_invite_form',
      ),
    ),
  );

  // Make cached data available within each step's $form_state array.
  $form_state['signup_object'] = MYMODULE_registration_get_page_cache('signup');

  $output = ctools_wizard_multistep_form($form_info, $step, $form_state);

  return $output;
}

function MYMODULE_registration_get_page_cache($name) {
  ctools_include('object-cache');
  $cache = ctools_object_cache_get('MYMODULE_registration', $name);
  // If the cached object doesn't exist yet, create an empty object.
  if (!$cache) {
    $cache = new stdClass();
    $cache->locked = ctools_object_cache_test('MYMODULE_registration', $name);
  }

  return $cache;
}


texts: Access the value of a disabled field in a twig template

texts:
I'm using the Paragraphs module to create components, i then make a content type and add the Paragraph as a reference field.

The form of the Paragraph has a field (a list) where a content creator can select a color name for a background color for the div. Each Paragraph has 3 values (pacific_blue, smokey_white, white).

However, i'm trying to get the selected value without displaying it on the site.

As long as the field is not disabled i can get the value using this code and add the class to style the div with the right background color:

<div class="c14a {{ content.group_wrap.field_color_backgroud.0["#markup"] }}">
  <div{{ attributes.addClass(classes) }}>
      {{ content }}
  </div>
</div>

So how do i get the value of a field that is disabled in 'manage display'?

Thx...


texts: How to set Content-Lenght http header for images?

texts:
How to set the Content-Lenght header or any other header for images?
I need it to set a rule in the varnish to not cache images larger than 500kb.


texts: Moving the Sites/Default/Files Directory

texts:
We have a client with simple request to move the Public File folder up simply so that links will be shorter like example.com/files/ instead of example.com/sites/default/files/.

I assumed this would just entail running

mv ./sites/default/files/ ./files/

in the root directory where my index.php resides and then changing the line in settings.php. Yet, this does not work, and I can't figure out why. In the file_managed table the uri column looks like public://example.png. Does that variable 'public' not resolve to the default public path?

Here's what my settings.php line reads:

# Change Public File directory
$settings['file_public_path'] = 'files';

The folder is right next to my index.php file and the entire folder, including contents is set to 775, or rwxrwxr-x.

drwxrwxr-x. 47 apache webgrp  28672 Nov 15 10:14 files
-rwxrwxr-x.  1 apache webgrp    648 Oct 25 08:17 index.php

Weirder, in the browser inspector, it appears that Drupal is looking for files at /files/example.png and there is definately a matching file at /files/. What am I missing? The only docs I can find are for Drupal 7, and all modules I've seen are only for 7 as well.


texts: I have changed my Administrative Theme to a theme I don't like and now I cannot change it back. There is a drop down to change, but no save configuration option anymore.


texts: Prepopulate a custom user field on registration?

texts:
I have created a custom field on the user entity. I would like to prepopulate this field with the value 0. So, when the user goes to their account page after registration the field is already filled in, which they are then free to change. Just like the username and email. The only way I can think to do this is to alter the registration form. I added this to my module, but when I created a new user, a new row did not appear in the field table. My module function:

function MYMODULE_form_user_register_alter(&$form, &$form_state, $form_id) {
  $form['account']['field_MYFIELD'][LANGUAGE_NONE][0] = array(
    '#type' => 'value',
    '#value' => 0,
  );
}

Where am I going wrong, or is there a better approach. Thanks.


texts: How do I get paragraph fields text data without the  tags?

texts:
I am trying to pass my paragraph field data from Drupal to a component that I have created in Twig. My component echos out data like so:

{{ my_var }}

In my template file, I am passing data to the component like so:

{% include '@components/my-component-name.twig' with {
   my_var: content.field_my_var_name.0
   ...
} %}

However, when this loads in my browser, what I am getting is:

The contents of my var.

How can I load the contents of my_var into my
 tag without getting another tag injected?


texts: How to show nodes of a content type using contextual filters as filters?

texts:
I have a profile page for each user where it will show all nodes he has created for each content type.

For instance, Autos content type will only list all autos he has authored. I'd like to be able for the user to access it using this path : http://localhost/mysite/myreports/autos and will show his autos, .../myreports/jobs will show his job postings, .../myreports/events for events etc...

I have tried doing it in views using page views with path ..../myreports/% (where argument is the name of the content type) and added a views contextual filter for 'content type' but i cannot get it to work.

I had read this : Drupal 7 Views Contextual Filter to show only nodes of the same type but it's not working.

I can set up each unique view to a content type without using contextual filters so I can specifiy a permanent url for say ...myreports/autos but then that would be inefficient.

Any suggestions?


texts:
I have gotten my validation module to kind of work, I have this:

function product_id_form_validate($form, &$form_state) {

if($form_state['node']->field_product_id['und']['0']['value'] == '123'){
    form_set_error('field_product_id', 'Product ID: is taken');
}

}

But when I change the value in field_product_id the value doesn't change upon save, it stays the same as when I first entered the form. Is there a function I need to call to say, when I click save look at this field again?

Thanks


texts: how to redirect page for anonymous users after number of times?

texts:
if any anonymous users come to my site after number if times they are accessed but i want redirect to register page after 4 time viewed content in my site.

please tell me is there any modules available in drupal 7.


texts: How do I know if a user has access to a private file in the node template

texts:
I have a a content type with Title, Body, File (private), and Taxonomy. I want all users to be able to see the Title, Body and Taxonomy for marketing purposes, but they should only be able to download the file if they are an authenticated and their account is related to the same taxonomy term(s) the node is related to.

I have private files set up properly and have written a custom module implementing hook_file_download_access to check if the user should have access. If I go directly to the file URL, access is working as I think it should.

My problem is I'd like node page to say:

"Register Now" if the user is not logged in
"Contact Customer Support" if they are logged in but don't share the proper taxonomies
or "Download Now" if all checks out.

Just not sure how to get it done?


texts:
I have a Drupal website hosted in the server of our company. One partner has a domain name and we want to use this domain instead of the company's (sub-)domain for the Drupal website. He arrived to do the redirection, i.e. when we hit the partner domain the Drupal website appears. However, all the links inside the Drupal website still refer to the old actual company's domain and if we click them, the corresponding page loads but the URL doesn't change. If we try to write the URL manually in the browser, e.g. partner_domain.com/?q=about, we return to homepage however the domain doesn't change (my_friend_domain.com/?q=about); and then the same problem, wherever we click the page shows but the URL doesn't change.

I Googled it but no success. I tried Domain 301 Redirect module but it is not making any difference.


texts: how do i get the groups which i have joined

texts:
How can i display to my site users after joining into one group, need to display my Joined groups. suppose one person send invitation to his friend and he has joined in to his group after click link. then he has to see in his friend group he has joined using Views.

Like:
      My Joined Groups
      XXXXXXGroup

Thanks


texts: how to customize my views-view-table.tpl.php?

texts:
i have a view table for property list and i want to customize the view source code to make it print specific label that i add from inside of view in the administration

the view source code :

<thead>
  <tr>
    <?php foreach ($header as $field => $label): ?>
      <th <?php if ($header_classes[$field]) { print 'class="'. $header_classes[$field] . '" '; } ?> scope="col">
        <?php print $label; ?>
      </th>
    <?php endforeach; ?>
  </tr>
</thead>

but this code print all fields labels even its empty!

output :

the output that i need like this :

any suggestion to update the code ?


texts:
I am displaying a Drupal 8 view. I see that all of the fields that are displayed in the view are not in the query.

How does this work?


texts: "File (Field) Paths" and "Media" modules: files not saved in the intended folder

texts:
I'm trying to use both the "Media" module (1.4) (to manage uploaded files) and the "File (Field) Paths" (to keep the uploaded files organized in various subfolders).

Basically, I have a content type that has several taxonomy fields and a media field. The taxonomy fields are mandatory and accept only one value each. I want the media file to be uploaded in a folder that uses the various taxonomy fields as a path, and I've configured the file field accordingly (using the "file (field) paths" options). So the file should be saved to e.g.:

sites/default/files/documents/[taxonomy-term-1]/[taxonomy-term-2]/filename.extension

My problem is that, when manually creating a new node and adding a file to it, the file is just saved to the root of the public files directory:

sites/default/files/filename.extension

So the "file (field) paths" configuration for this field seems to be ignored. This also happens if I add a file after the node has been created and saved.
Since I expect the site will have a lot (thousands, maybe tens of thousands) of uploaded files, I fear that storing all of them in the same folder will have an impact on the performance of the site.

What's strange is that when I use the feeds module to import and create nodes in bulk (via a CSV file), the "file (field) paths" configuration is working as intended. The files are saved in the "complex" path.

So why wouldn't it work when creating a node manually?...
Any idea for a solution?

Thanks in advance.


texts: How to show custom user profile fields in a view?

texts: In Drupal 7, I am using Profile2 (7.x-1.0-beta1) module to add custom fields like 'Author Name' etc to an user's profile page. How do I pull those custom fields in a view (7.x-3.x-dev)? All other custom CCK fields shows up in a view's selection list but not those added to an user profile page.


texts: how to use two different feeds on one drupal

texts:
I am using drupal.org/project/views_export_xls Views Excel export
I added two different feeds to my drupal view , but only one of them (the second one) shows as an icon on the page , and if I remove the second one the first one shows up on the page.  how can I see both of them on the view page?


texts: Field is translatable, but field instance is not

texts:
When exporting configuration for a node type with fields with Drupal 8.2, I noticed that translatable: true is set in field.storage.node.my_field.yml, but translatable: false is set in field.field.node.living_word_comment.my_field.yml. my_field is of type Text (plain), i.e. string in the YAML file.

What does it mean for a field to be translatable, while the instance is not? It doesn't make sense to me.

Disclaimer: I'm not sure whether phrases like "field" and "field instance" are still applicable in Drupal 8, or whether that is just 7-speak.


texts: coming from D6, Im confused about why I can't seem to choose which fields from a content type I want to be displayed when I want to use the view as block? I searched for drupal 7 views fields settings but the results weren't about this particular issue.


texts: Drupal7: Rules Module - change the FROM field

texts:
I am using the Entityform module with the Rules module.

When the user submit the form, an email notification is sent out. In the email notification, I want the FROM field to be the user's email address as opposed to the 'site-information' email address.

I couldn't set this with Rules in the Drupal Admin (I can only adjust the 'TO' field)
How can I do that by code? or if you have any other idea to have the FROM field varies depending on the user's email address.

Thanks.

Boutros.


texts: Drush Make and the Windows maximum path length

texts:
When building Commerce Kickstart on Windows, using Drush Make, a customer has this problem:

copy(C:\Users\User\AppData\Local\Temp\make_tmp_1449319094_5662dab66a8f0
\__build__\profiles\commerce_kickstart\modules\contrib/commerce_discoun
t/modules/commerce_discount_usage/includes/views/handlers/commerce_disc
ount_usage_handler_field_commerce_discount_analytics.inc): failed to
open stream: Invalid argument filesystem.inc:267

It results in the Drush error "Project commerce_discount (7.x-1.0-alpha6) could not be downloaded".

The build works on non-Windows platforms.

I notice that the file path is 264 characters long, and I suspect this is a problem of the Windows MAX_PATH constant (variously quoted on the web as being 255, 256, or 260 characters).

Is there a way to get around this?

I should note: I have read the drupal.org issue about Kickstart on Windows (https://www.drupal.org/node/1648992)


texts: Computed field won't update itself or save to the database

texts:
UPDATED ISSUE: In the original issue below, I was getting an error when a query was empty. I've now gotten rid of the error, but content no longer saves into the database (where it saved fine before). Also, if the "store value to database" option is unchecked, then the data does not display at all. The new portion is the the second piece of the below code.

$entity_field[0]['value'] = "";$nids = db_query('
    SELECT entity_id FROM {field_data_field_review_venue_reference}
    WHERE field_review_venue_reference_target_id = :nid',
    array(':nid' => $entity->nid)
    )->fetchCol();

if (!empty($nids)) {
    $entity_field[0]['value'] = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_venue_default_value')));
   }

else {
    $entity_field[0]['value'] = db_query('
    SELECT AVG(field_review_payment_value) FROM {field_data_field_review_payment}
    WHERE entity_id IN (:nids)',
    array(':nids' => $nids)
    )->fetchField();
   }

endif;

If the array_pop portion is all that is in the computed field, then the field saves to the database (or displays, if the option is unchecked) just fine. If it's not included at all, the field saves/displays fine. However, when it is placed within if (!empty($nids)), no values for the field will save/display at all. This includes both the value of the array_pop and independent values calculated by SELECT AVG. As always, any help is greatly appreciated (and thanks to both Clive and Tenken for getting me get rid of the initial error).

ORIGINAL ISSUE: I have two content types: Review and Venue. Each review has an entity reference field to relate it back to the correct venue node. On the Venue nodes, I have computed fields to display calculated averages of fields from reviews referencing the current node (i.e. Average Payment Rating for Joe's Nasty Catering). For one of these fields, the code is:

$entity_field[0]['value'] = "";$nids = db_query('
  SELECT entity_id FROM {field_revision_field_review_venue_reference}
  WHERE field_review_venue_reference_target_id = :nid',
  array(':nid' => $entity->nid)
)->fetchCol();

$entity_field[0]['value'] = db_query('
   SELECT AVG(field_review_payment_value) FROM {field_data_field_review_payment}
   WHERE entity_id IN (:nids)',
   array(':nids' => $nids)
)->fetchField();

The computed field works 100% correctly when a review has already been submitted for the current venue. However, when no reviews have been submitted, I get an error of PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064. It seems that this is because there are no entries where the Node Reference field is equal to the current NID.

Is there some way to fix this? I hadn't gone through the steps necessary to create the error until today, and as such I just realized that the site I'm building is essentially broken because of it.


texts:
The documentation on Drupal.behaviours suggests that local settings can be passed to Drupal's JavaScript behaviors.

Rather than hard coding my series data into my function:

series: [{
    name: 'Jane',
    data: [1, 5, 4]
}, {
    name: 'John',
    data: [3, 1, 2]
}]

how can I pass this series data to my function as settings, directly after the context?

JS code (my_highcharts.js)

(function ($) {

Drupal.behaviors.my_highcharts = {
  attach: function (context, settings) {
    $('#drupal_behaviours').highcharts({
      chart: {
          type: 'bar'
      },
      title: {
          text: 'Drupal.behaviors'
      },
      colors: ['#50b432', '#ed561b'],
      xAxis: {
          categories: ['Apples', 'Bananas', 'Oranges']
      },
      yAxis: {
          title: {
              text: 'Fruit eaten'
          }
      },
      series: [{
          name: 'Jane',
          data: [1, 5, 4]
      }, {
          name: 'John',
          data: [3, 1, 2]
      }]
    });
  }
};

})(jQuery);

Module code

drupal_add_js(drupal_get_path('module', 'my_highcharts') . '/highcharts.js');
return array('#markup' => '

');


texts: On node view page show a link or button that executes an action?

texts:
The closest that comes to this for D5:
http://drupal.org/project/node_operations_block

I am familiar with creating VBO Actions, but not sure how to create it for a node operation. Such as a link or a button, that creates a new node with default values for example.


texts: New Drupal installation not working beyond front page (not accessing database)

texts:
I just installed a new drupal 7.39 using drush.
From the browser, I can only goes as far as the front page(welcome page) and no further. I cannot log-in, suggesting that drupal is not accessing the database. The installation went smoothly.
Below is my drush commands. Anything wrong with it?

$ drush site-install standard --db-url="mysql://root@localhost/mydrupal1" --site-name=MyDrupal1 --account-name=my_username --account-pass=my_password


texts: Views filter: Filter by number of field values

texts: Is there a way in Views to create a filter that shows nodes by number of values for a field? For example, to create a view of nodes, showing only those with two or more terms from a given vocabulary?


texts: Loading views blocks that aren't actively set

texts:
Is there a way to programmatically load a views block that isn't active in the config(not placed under admin->structure->block layout).

My usual method to load a block programmatically is something like the following in hook_preprocess_node:

$block = Block::load('views_block__courses_block_3');
$block_render = \Drupal::entityTypeManager()->getViewBuilder('block')->view($block);

However, that seems to just return null if I haven't placed the block into a region after creating it under views.

Also noticed that the block isn't listed in the config table until placed into a region.


texts: How owerride entity node delete core function

texts:
I'm doing a headless drupal cms.

I need to check the entities before they are deleted.
I need to do it globally as the deletion of entities can take place via api (already written) or by using the cms as an administrator.

How can I overwrite the "delete" core operation?
I've tried using hooks (hook_entity_predelete / hook_entity_delete) but they don't block delete operation.
I need something like this:

if ($condition == true)
  core_delete()
else
  disable_core_delete()

Thank you


texts: How to integrate search option by using search autocomplete in drupal 7?

texts:
Currently i am creating a e-commerce drupal7 website . Tried integrating search autocomplete ,but i want to integrate search option in it, for example as in google search if we type the first three word like Tri it will show the rest option as trivandrum etc.

Can anyone help me with this issue?


texts: Different approval for different user accounts

texts:
I would like user account A to require approval before granting access, and user account B not to require any approval.

How can this be achieved?


texts: How to prevent node creation if blacklisted words detected in the body?

texts:
I have a forum and when user creates new thread (which is some custom content type) and if the thread lets say has word 'loan' in it somewhere, in a title field, or a body field and etc. then the thread doesn't get saved and gives some warning or something like that.

Is there a module for that? Recently my forum got spammed with loans and there's about 1000 of those threads and all about loans. And those spams bypass all anti spam protections. So I came up with this 'brilliant' idea.

Please don't suggest Captchas and etc. I need something like I described with a blacklist.


texts:
I'm trying to migrate a Drupal 7 website to Drupal 8.
I have installed on the same server those two websites. Drupal8 version is empty.
On the Drupal 7 website, more than twenty contrib modules are installed, like LinkIt, PathAuto, Token...
I downloaded with Composer the D8 version of those modules. I installed them without any configuration.
I followed the upgrading process on my D8 website, but the process cannot see installed modules on D8 version and told me that LinkIt or PathAuto won't be upgraded.

How can I fix it? Is there a solution to migrate configuration datas for these modules?


texts: Add css to nodes of certain content type

texts:
I've been trying to add css to a content type for a while, but I can't seem to find any help on this for drupal 8.

How do you add a library to only the nodes of a content type?

Thanks in advance!


texts: How to add a column to DB with weight by using hook_update_N?

texts:
I want to add a column to a database by using hook_update_N(), but it should be 3rd column instead of last column. How I can achieve that please help in this regard. I tried to add weight but not working. below is my code which is creating a column at the last in the existed table.

function test_update_7001() {
  $column3 = array(
    'type' => 'varchar',
    'length' => 256,
    'not null' => FALSE,
    'weight' => 3,
  );
  db_add_field('test_table', 'column3', $column3);
}


texts: Trying to add class to body, based on taxonomy from a product/node

texts:
Be kind to me, my forte is definitely NOT in the pre-process area... or hooks, etc. :-)

I'm using Omega 3.x in Drupal 7. I found a nice function that pulls the user's roles and prints each role as a class in the body. I'm trying to do the same by pulling taxonomy terms from a field "field_event_type" in a product I've got.

I already tried this:
add css class to html element based on taxonomy?

... but it's not printing the class. I tried duplicating the logic from the "user role" part. Can anyone lend an assist? I'm trying to print the various taxonomy terms from the field "field_event_type". Much thanks in advance!!

function saleo_preprocess_html(&$vars) {
  $body_classes = array($vars['classes_array']);

  if ($vars['user']) {
    foreach($vars['user']->roles as $key => $role){
      $vars['attributes_array']['class'][] = 'role-' . drupal_html_class($role);
    }
  }

  if (!empty($vars['node'])) {
    $node = $vars['node'];
    if (!empty($node->field_event_type)) {
      foreach($vars['node']->field_event_type as $key => $tags){
        $vars['attributes_array']['class'][] = 'tax-' . drupal_html_class($tags);
      }
    }
  }
}


texts: Minimum entity properties for field_attach_update()?

texts:
Question: What are the properties that are essential to be defined in the entity passed to field_attach_update() for the function to update the appropriate fields (and not silently do nothing)?

This is not detailed in the field_attach_update API page and, in articles I can find written about it, it seems that what I have defined above (ID, bundle, field data to update) should be enough.

Context: I'm using field_attach_update(); to keep some fields on seperate entities in sync with each other, using code like this:

        // Load entity, get entity type data data...
        $entity = array_pop(entity_load($entity_type, array($entity_id)));
        $entity_info = entity_get_info($entity_type);
        $id_key = $entity_info['entity keys']['id'];
        $bundle_key = $endpoint_info['entity keys']['bundle'];

        // Do stuff with the entity, modify field_some_field
        do_stuff($entity);

        // Build stripped down object containing only essential data
        $lightweight_entity = new stdClass();
        $lightweight_entity->$id_key = $entity->$id_key;
        $lightweight_entity->$bundle_key = $entity->$bundle_key;
        $lightweight_entity->field_some_field = array(
          'some_key' => 'some_data'
          'another_key' => 'more_data'
          );

        // Save it
        field_attach_update( $entity_type, $lightweight_entity );

This did work fine, but has recently (since updating to Drupal 7.14 I believe) been silently failing. No errors, nothing in logs - but no updates to the fields within Drupal and no changes to the field_data_field_some_field in the database. It seems like field_attach_update() isn't so much failing, as judging that it doesn't have any work to do. My theory is, that something is missing from the $lightweight_entity object, causing field_attach_update() to dismiss it as not a match or not a change.

(I'm piping in an entity object that is as simple as possible, partly because this sync function needs to run often and on many entity types, and partly because I have found that sending the whole original modified $entity object to field_attach_update() can result in PDO database fatal errors due to issues like this one, so simplicity is key. I'm using field_attach_update because it's syncing fields rather than updating the entity - new revisions data doesn't make sense in this specific context - from a user's perspective, the content hasn't been revised, and reverting the sync to become out of sync wouldn't make sense)


texts: OK the site was fine until I updated the core of the website. Now the images do not show up. I have checked the paths and they are correct. I have checked the permissions and they are 777. I have an SSL on the site but as I say, it was all working well before! I've spent the last few hours trying to resolve this but to no avail. I've deleted and uploaded the core again - same. Any suggestions appreciated!


texts: How to find hooks being called by a Drupal page?

texts: I am looking at module code, and this is one of my first time working with Drupal modules. How can I find which hooks are being called by the page that I am working on at the moment? I saw this suggestion, but I don't want to hack core like it suggests. I think I might be able to do it with the devel module, but I am not sure how.


texts: Transforming a Webform upload field into a single Attach button

texts: I want to transform the entire "Browse No file selected Upload" to a button like "Submit" nellens.com/home/content/contact, using CSS, I don´t know if this is possible. It is made with Webforms!


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

texts:
I want to print the query which is built using db_select() in a programmatical way. Is there any API function provided by Drupal Abstraction Layer?
It is similar to query output in Views, but I want to print it from my custom module for debugging purpose.


texts:
I have created a view as a page, and set a title for it. It works fine on the view preview, but on the actual page it becomes null. The title also displays on the title bar of the browser.

I have overridden the template views-view--page.tpl, debugged the variables, and found that $title is NULL.

How should I fix this problem?


texts: PHPUnit with custom/contrib and submodules structure

texts:
I am starting to write our tests with PHPUnit on Drupal 8, and I am not sure about the best practices with the phpunit.xml.dist file.
We separates the custom and the contrib modules using two directories in the /modules directory - /modules/custom and modules/contrib.
The original phpunit.xml.dist file contains the following line <directory>../modules/*/tests/src/Unit</directory> so I had to add the
<directory>../modules/*/*/tests/src/Unit</directory> directory.

I have another issue with sub-modules, our current structure is /modules/custom/main_custom_module/modules/sub_module, so I had to add another directory to the file (<directory>../modules/*/*/modules/*/tests/src/Unit</directory>).

What is the best practice when it comes to overriding the phpunit.xml.dist file? should I remove the file from VC (e.g. git,svn..)?


texts: How to programmatically create a node when a payment is successful

texts:
I have a content type, and  with the help of the UC node checkout module, I am able to successfully add the content to cart once it is created by the user. When the user checked out and had made a successful payment, I want to create another node of another content type.

function gy_mod_uc_checkout_complete($order, $account) {
  if ($order->order_status == 'payment_received') {
    exit();
  }
}

The above is not getting fired; I always get it as "in_checkout." I tried doing it using the Paypal sandbox.

Does anyone have a suggestion on how I should write the code I need?


texts: How to see the error messages when I get the white screen of death?

texts: How can I see the error messages when the site I am working on gets a white screen?


texts: Is CiviCRM data vulnerable to the Drupageddon bug?

texts:
Would CiviCRM data have been exposed to a Drupageddon exploit if it happened before I updated the site to Drupal 7.32?

CiviCRM is in a separate MySQL database. However, the site uses Views/CiviCRM integration so all the tables in the CiviCRM database are listed in Drupal’s settings.php file.


texts:
In Drupal 7, currently when I go to a user profile, the breadcrumbs go as follows: "Home > username."
I have a People section as part of my main navigation, so I would like the breadcrumbs to behave more like: "Home > People > username."

How can this be accomplished?


texts: D8 Migration: Can 'Default Bundle in Destination Plugin be dynamic?

texts:
My goal is to take an existing D6 content type ('mini') and migrate it into one of two specific D8 content types based on its current D6 URL Alias (either 'course' or 'page') and where this alias falls in the hierarchy.

I've have successfully written a simple source plugin that adds the alias into RowSource.

How do I control the destination plugin so I can migrate into the appropriate bundle - either 'page' or 'course'?  Is there any property of $row that can be adjusted to do so?

Or is this process more involved?

I know that nodes use the 'entity:node' destination plug-in, but how can I extend this per above? It's unclear to me what exact class the destination plug 'entity:node' represents

Any insight would be much appreciated.

Thanks!