texts: How to increase the speed of SQL Views queries?

texts:
I have a View with two relationships, and a few displayed fields. It has a COUNT (use aggregation). The database contains just about 10.000 rows. It takes 4 seconds to complete. A similar query to the very same tables takes 0.002 seconds, i.e., 2000 times faster! It is supposed that the Views module is smart enough not to get involved in a burocracy of tables that will take forever to load the data, but it happens. How can I solve it?

I put the example. Essentialy, they do the same (I need to take a little extra info, but essentialy to get the list of products and number of products in a category, the SQL is working. See the SQL query in one case, and in the other). And I was just very carefully adding the two relationships and the fields, so either I did something very wrong or Views SQL UI needs a very lot of improvement.

Quite fast query:

SELECT SQL_NO_CACHE field_familia_tid, COUNT( DISTINCT node.nid ) AS total
FROM field_data_field_oem_ubicacion AS ubi, field_data_field_oem_ref AS oem_ref, field_data_field_familia AS familia, field_data_field_marca AS marca, node
WHERE ubi.field_oem_ubicacion_value = oem_ref.entity_id
AND oem_ref.entity_id = familia.entity_id
AND oem_ref.entity_id = marca.entity_id
AND field_marca_tid =69440
AND node.nid = ubi.entity_id
GROUP BY field_familia_tid

A similar query, done carefully with the Views UI. Extremely slow, 1000 times slower:

SELECT taxonomy_term_data_field_data_field_familia.tid AS taxonomy_term_data_field_data_field_familia_tid, COUNT(DISTINCT field_oem_ubicacion_field_collection_item.nid) AS field_oem_ubicacion_field_collection_item_nid
FROM
{field_collection_item} field_collection_item
LEFT JOIN {field_data_field_familia} field_data_field_familia ON field_collection_item.item_id = field_data_field_familia.entity_id AND (field_data_field_familia.entity_type = 'field_collection_item' AND field_data_field_familia.deleted = '0')
LEFT JOIN {taxonomy_term_data} taxonomy_term_data_field_data_field_familia ON field_data_field_familia.field_familia_tid = taxonomy_term_data_field_data_field_familia.tid
LEFT JOIN {field_data_field_marca} field_data_field_marca ON field_collection_item.item_id = field_data_field_marca.entity_id AND (field_data_field_marca.entity_type = 'field_collection_item' AND field_data_field_marca.deleted = '0')
LEFT JOIN {taxonomy_term_data} taxonomy_term_data_field_data_field_marca ON field_data_field_marca.field_marca_tid = taxonomy_term_data_field_data_field_marca.tid
LEFT JOIN {field_data_field_oem_ubicacion} field_data_field_oem_ubicacion ON field_collection_item.item_id = field_data_field_oem_ubicacion.field_oem_ubicacion_value
LEFT JOIN {node} field_oem_ubicacion_field_collection_item ON field_data_field_oem_ubicacion.entity_id = field_oem_ubicacion_field_collection_item.nid
WHERE (( (field_data_field_marca.field_marca_tid = '69440') ))
GROUP BY taxonomy_term_data_field_data_field_familia_tid

Note: Afterr careful inspection of SQL and also from suggestion by user tenken, I replaced the LEFT JOIN by WHERE-AND in the SQL. The result was almost identical, and fast, so now the question is: why does Drupal uses by default the LEFT JOIN, and where can I change it (if possible, not programmaticaly, in order to have the logic inside the View).


texts: A module that allows user to create content anonymously, then if they register, assigns the content to them

texts:
I recall a module I came across that was in dev a while back that basically allowed users to create nodes as an anonymous user. Then if they registered on the site, it assigned authorship of these nodes to that user account. Similar to how Drupal Answers works. It helps to lower the threshold for someone to get involved in a site. I just cannot recall the name.

Does anyone know?


texts:
How can I configure the WYSISYG editor in popups?
I am using the TinyMCE module; in visibility I have added the page, but the rich text editor will be visible only on the pages, not in the popups.

I included the popup path and used wildcards, but it still doesn't come up in popups (I am using Thickbox)

Do you have any idea?


texts: Special characters in form element #title

texts:
I am trying to write a custom form for my own search facet. In the form, the labels of the elements are dinamically generated based on the indexed values, and they can contain special Hungarian characters, which are not displayed correctly. This is my code:

  $form['facets'][$current_property] = array(
    '#type' => 'select',
    '#title' => $current_property,
    '#multiple' => TRUE,
    '#options' => $myoptions,
    '#default_value' => $widget->buildDefaultValue($element),
    '#attributes' => array('class' => array('facetapi-multiselect', $form_state['facetapi_multiselect']['facet_class'])),
    '#post_render' => array('_facetapi_multiselect_modified_disable_options'),
    );

So, for example, if $current_property is Belső memória/tárhely, then Bels? memória/tárhely is displayed in the search facet.

Can you suggest any ways how to do this correctly?
Thank you very much in advance.


texts: How to use feeds tamper to set default value from importer node?

texts:
I've got a number of feeds that I want to be able to import regularly. I setup feeds and attached them to a content type, ex. "My Feeds" which imports into another content type, "Article".

I also need to make sure that when these feeds come in, that I can set the default values in the target node. The use case is that I will be importing from feeds in multiple languages and want them associated with an author so I have created a couple of new fields in my importer content type:

field_language
field_author

I want to be able to set the language and author value for each feed when I create the importer and have those associated every time I update but its not clear if any of the existing plugins do this.

I've also started writing my own custom plugin to pull in these values from the parent importer but I can't figure out how to access or load the importer object through a feeds tamper plugin.

Any pointers or is there a better way to acccomplish this task?


texts: How do I export a site without it's Node data?

texts:
I have a site with very high volumes of data (1000+ nodes per day * 3+ years and growing each day). When we need to create a development snapshot of this database it takes FOREVER to import it.

I know this is a long shot, but is there a way to export this database without our node data? Specifically which tables can we excise?

I know as we add more and more custom modules, more and more things will break when we do something like this. But let's say we are just using Drupal 6 core modules with CCK. Would it be possible then? If not, what would we break by doing this and could breaking it be fixed?


texts:
compass watch

      Change detected at 02:13:25 to: style.scss
          error sass/style.scss (Line 20 of sass/partials/global/_base.scss: File to import not found or unreadable: aurora/susy-grid.
      Load paths:
        /Applications/MAMP/htdocs/txmo/sites/all/themes/txmo_aurora/sass
        /Users/davidfells/.rvm/gems/ruby-1.9.3-p362/gems/compass-0.12.2/frameworks/blueprint/stylesheets
        /Users/davidfells/.rvm/gems/ruby-1.9.3-p362/gems/compass-0.12.2/frameworks/compass/stylesheets
        Compass::SpriteImporter)

Running Ruby 1.9.3, latest versions of all gems freshly installed with JewelryBox. Other users on dev team are able to build this with matching gem versions.


texts:
We would like to get label for the field.

As per previous question: How do I get a field label by the field name?

But I need to get this through the REST API of Drupal.

Could anyone please suggest what should be the approach to use the Field API from as REST service.


texts: How to convert username to hyperlink in comment reply similar to StackExchange?

texts:
Is there any contributed module or usable functionality which is somewhat similar to StackExchange reply comment, where when we add username with "@" sign, it notifies user. However in my case I would like to convert them into users profile page hyperlink.

For example, if user added in reply @foobar, if username with foobar exists will be converted in hyperlink to foobar profile page.


texts: What operator is equivalent to "Is not greater than or equal to"?

texts:
I have a view showing a list of events. The events are sorted by a date field, which a user can use to input the event starting date/time. However, I want the events removed from the list once the current time is 1 hour past the start date/time of the event. When I add the event date to the view filters, I get the following operators.

However, none of these operators give me the desired result. What I really want is a "Is not greater than or equal to" operator. All of this said, is there a workaround that I could easily implement to get my desired result?


texts: I need to make a query to get the path alias used for a node.  In which table is it stored?


texts: Load a page with only the form, no drupal theme/element around

texts:
In Drupal 8, I created a form Class. I can access to this form with the route defined in the yml file.

I want load the form page without any theme/elements Drupal, just show the form (with a minimal css for align the form to the center of the page). Is there a simple way for do that ?


texts: How to use Composer to install third party libraries

texts:
All I thought Composer takes care of any external library a contrib module requires automatically. I tried installing one, Composer took care of all its dependency modules, but not so much with the external library.

How do I use Composer to install external libraries that any module depends on?


texts:
I have used the following code to delete the preview button which is on one of my create content type pages, but its not doing anything, what am I doing wrong?

function example_module_form_alter(&$form, $form_state, $form_id) {
// Check for a particular content type's node form.
if ($form_id == 'example_content_type_node_form') {
drupal_set_message("entering formId");

unset ($form['preview']);
}
}

the drupal_set_message does go off, so I know that I am entering the if statement. I have put this code in a custom module (example_module).


texts:
Is there a way in Drupal 7 to display only the titles of node comments beneath the node (hopefully threaded), thus allowing users would click on title to see the full comment?  This was essentially the behaviour in Drupal 6.  In Drupal 7, I only see how to list the full comment title and body, or no comments at all.

Thanks for any suggestions.


texts: how to get a field name by field label in Drupal 7

texts: I have added a custom field with title 'play time'. How can I get the field name(internal value) using label value in my custom module. Is there any function to get the value?


texts: I followed the install directions by deleting all but the /sites folder, copied the files into the drupal dir, deleted the cache but nothing changed except and notice that drupal core needed updating to 7.24, which i did.  What am i missing here?


texts: Can't get fid of the saved file after file_save_data

texts:
I have been trying to get the fid of the file which my custom module is saving and every time I end up getting the error "Trying to get property of non-object in report()". I have tried file_object->id() and file_object-> fid ->value but neither are working. This is my code in .module file:

function file_write($source , $name) {

$uri =  file_default_scheme() . '://'.$name.'.txt';

$file_object = file_save_data($source, $uri, FILE_EXISTS_REPLACE);
return $file_object;
}

And this is where how I call it and try to get fid:

$file_object = file_write($source, $name);
$fid = $file_object->fid->value;

Is there anything wrong with the code?
I also tried using other methods, but no luck so far.


texts: Attaching a view page display to a tab in a content type?

texts:
I've built a CSV exporter by heavily modifying a template file from Views Bonus Pack's CSV feed Views plugin that formats all the content in a particular view exactly how I want it.

Now, I just need to find some way of integrating it into the work flow. Ideally, on each "projectsheet" content-type node, there would be 3 tabs for admins: View, Edit, Export.

The exporter feed is attached to a Page display that's part of the view. If I set that page's path to something like "node/%/export", it usurps the default display of that node and the node becomes that view.

How do I create a new tab, to which a Views Page display is attached, that's visible only in a certain content type and doesn't take over the default view of that content type?

I'm using Drupal 6 and the Views UI; considering everything I've done is in Views UI as a template for Views Bonus Pack, I'd really like to not code a new module to achieve this (i.e., just use Views UI to accomplish it if possible).

Thanks!


texts: Drupal crash recovery - segmentation fault

texts:
A drupal 7 website I am developing is repeatingly crashing. After each crash, I can't access any further pages on the website, in any browser, until I restore the database from a backup and remove half of the modules from the sites/all/modules directory.

The error I get on the browser is "connection reset". Each time I restore from a backup ( I have to remove about half of the modules from the sites/all/modules directory so it will start working), it crashes again at the same points:

When I enter any content type fields editing screen, all I see is 'connection reset' error. (on some other pages it happends too).
When I try to run a database-related drush command (including drush db-drop), I get a segmentation fault message.

Initial Analysis:

That database is OK, at least from the MySQL point of view.
When I restore it, it doesn't work until I remove about half of the modules.
PHP memory limit is 800M so that's not the issue. It seems some of the modules have compatibility problems but how do I find which (No errors appear on the server's error log - the crashes are not logged).
There might be some confusion inside the Drupal tables (e.g. content type definitions or menu definitions).

My questions:

Which tools can I use to debug such a situation?
What are the possible causes?
How do I check for internal inconsistency insider the drupal respository definitions?

The site is hosted on a linux server with CentOS

Thanks

Amnon


texts: Set a data value for a content field with rules

texts:
I am able to create a new content with rules whenever a user has been flagged as 'satisfied'. However, i need to fill in the fields as well with the flagged username, and some other fields in the flagged user profile. This i tried to do with 'set a data value' but the parameters doesn't seem to be available. Only 'site' and 'node' is available in d data selection field.
Is there a way to 'fetch' the user profile of the flagged user and use it in the fields of the newly created contents?


texts: How to pass value from computed Twig to Text filed in a webforms?

texts:
I'm using computed Twig to calculate prices  I need the total in computed Twig to show in my final text filed Total due.
is there is way to pass value from computed Twig to text filed?
thanks


texts: Display content on a node which is referenced in another node

texts:
I have a content type called 'style' and another one called 'style - description'. Unfortunately, it's necessary to split the two up. 'style' will be a sort of portal page, while 'style - description' contains further information about said style.

So, 'style - description' has an entity reference field that points to one of the 'style' nodes. I want to display content from a 'style - description' node on the 'style' node that has been referenced.

I've been trying to do this through a view with a relationship and a contextual filter, though I don't seem to be getting anywhere with that. Anyone any ideas?


texts: Pass value into a view using block input

texts:
I have created a Drupal 9 site with articles that belongs to taxonomy terms. I want to give the ability to the administrator of the site to place a block with whatever taxonomy he wants.
How would I set up the block configuration with a drop-down of the taxonomy terms and pass the selected values to the Drupal views and filter based on the selected taxonomy terms?
In the block settings there is not any option to pass the filter to the block.

Any Idea on this using existing module or with custom code?


texts: Hiding fields when creating node and showing them only when editing

texts:
I'd need to enable editing of certain fields only when the node they're assigned to already exists. Therefore I need to disable them on node create form and enable them on node edit form.

I though I'd do it the same way as with users where you have two separate forms (user profile a user register) and therefore can use settings array on field instance (at least I believe it works this way).

...
'settings' => array(
   'user_register_form' => 0,
),
...

The problem is you can't do it with nodes as nodes don't have separate forms for edit and create.

I know I can do it directly via altering CONTENTTYPENAME_node_form (changing the access status of the fields to false or unseting them completely when the node does not yet exist) but it doesn't seem to be the very best solution (It doesn't feel systematical to unset it on form alter hook).

BTW: I know that someone asked similar question but he hasn't received any answers.


texts: is there a module for instagram like YouTube Field?

texts:
I need a module that permit to my editor user to choice photo from instagram and linked them in a field of a content type.

I have found https://www.drupal.org/project/instagram_feeds but I don't want to create feeds for every node.

Edit: and if possible a youtube module too. ("Youtube" module permit to write video's url, but not a graphical choise).
Thanks.


texts:
I've installed both version of drush using composer, and trying to list migration within my newer drup8 installation, in order to migrate an older drupal 7 website .. then I feel really stucked because I can't follow the next commands to execute ..

composer global require drush/drush:dev-master --> migrate-status not found
composer global require drush/drush:7.* --> won't work with drupal8

Any ideas or enlightment would be greatly appreciated.


texts: Exposed Filters: Is there a way to know how often a query has been run?

texts: I would like to know if it's possible to get the statistics from an exposed filter. For example, if I have a job website, is it possible to get data about which jobs people are searching the most using the exposed form? It would help if I need to improve the quality of the website.


texts:
I am using Media Module 2.x.alpha2 + File Entity Alpha2

Using WYSIWYG (CKEditor)'s Add Media button I can upload videos but there is no proper file formatter to display it in the page, all I see is:

<source type="video/mp4" src="http://path/sites/default/files/myfile.mp4"></source>
<source type="video/ogg" src="http://path/sites/default/files/SSA50002.ogv"></source>

How can I properly rewrite the code to have a proper formatter etc:

<div id="video_lightbox_myvideo" class="lightbox" style="display: none;">
<embed name="player_1" id="player"
          type="application/x-shockwave-flash"
          pluginspage="http://www.macromedia.com/go/getflashplayer"
          width="800" height="600"
          src="http://path/wel/players/jwflvplayer/player.swf"
          allowfullscreen="true"
          allowscriptaccess="always"
          flashvars="file=' . $video_path . '&fullscreen=true&image=' . $video_preview . '&skin=http://path/wel/players/jwflvplayer/skins/mainley.swf">
          </embed>
 </div>


texts:
I have had this module working for years. Recently, it has stopped working. I'm using Services 3 to:

Log in and get a token
Create an image file and get its file ID
Create a node, using the file ID from the previous step for the image field

The JSON I'm posting for the image field on the node is similar to the following.
   "field_image":{
      "und":[
         {
            "fid": 10279
         }
      ]
   }

Suddenly, I can't get the node I'm creating to reference an existing field via the file ID. The node and the image are created without issues, but the image field is empty.
Is there some other way I should be doing this?
This seriously worked for years, so I'm not sure what changed.
I am using the Services module 7.x-3.27.


texts: Does hook_node_submit() fire on feed import?

texts: If I implement hook_node_submit(), will it be invoked when I import nodes from a feed?


texts: Is it possible to send a response from a service, but return something else?

texts: I have a block that returns a render array. I would also like to set a cookie value as well in this process. Is it possible to set a cookie and also return a render array?


texts: Capturing Data on Multistep form to send to an API

texts:
I am connecting to an API that returns some data based on a user's zipcode.  This data needs to be included in the payload of a second call to the API along with sone other form values.

I wanted to build the webform as a multistep, the first page collects the zip code and after the Next Page is clicked, do an API call to send the zipcode and save the response from that call, so that on the second page the Submit sends via another API call that response data plus all of the form values.

This Get the draft data in the webform hook_form_FORM_ID_alter() seems to be the answer but not quite.


texts:
I am looking to achieve the next functionality:

I have a content type about fruits, I've added an autocomplete taxonomy field to the content type with the possibility to register new taxonomy.

I would like to achieve some taxonomy depth.

I am using the autocomplete deluxe module

For example, I input in the field apple, fresh, and green.

When I go to the fruits taxonomy vocabulary, I would like to have the taxonomy depth like this.

Instead, I get the following.

Is there a way to achieve this with taxonomy autocomplete field?


texts: Redirect, change or replace the "user/register" link

texts:
How to redirect, change or replace the "user/register" link
to another registration page, such as "civicrm/contribute/transact&reset=1&id=1"?

Why? Because our "Drupal users" are (paid) members, they have to choose a membership type, they get informed about the corresponding fee (and how to pay offline) and have to provide additional member information (postal address, day of birth,...). All this is handled by a civiMember page, which creates also a Drupal user (user name and password), blocked at the beginning (changed to active as soon as payment is received).
We probably have to keep the Drupal user login block, for registered users (paid members) to login.


texts: How to build and organize menus with rich taxonomies and complex view-based menus

texts:
I would like to hear your insights about strategies on organizing menus. I mean two main approaches: having each menu header as an individual Drupal menu vs. having all menus grouped as one big menu, perhaps named "Main menu".

I built quite a large site where I had to use such modules as OM Maximenu, Taxonomy menu/Taxonomy menu trails, Menu Block, Sitemap, DHTML Menu. Without much knowledge about Drupal and the consequences of my choice, just to keep my progress on, I took my liberty to sometimes put a group of menu items as individual menus, sometimes I grouped them together (this was the case of Taxonomy menu and Menu Block where I could define the level at which menu starts).

Then, when I installed Sitemap I saw that my menu organization revealed to public. This was also a lesson.

Although everything works OK, I don't feel alright with this kind of mess. Especially, after some time I know I will have to do a repetitive research on how a particular menu is built, rather than have it intuitively solved right away.

My question: What is your preferred way to build and organize menus with rich taxonomies and complex view-based menus (OM Maximenu)?


texts: Photos in views taking a long time to load

texts:
We have  views  with  multiple  cck image  fields  http://screencast.com/t/UOGxa9Jr6  with  'Group multiple values'
And  we have a theme  function  to add the needed  classes for a script to display these photos in fancybox

function mytheme_content_view_multiple_field($items, $field, $values) {

  if($field['field_name']=='field_photos_images'){
    $output = '';
     $i = 0;
    foreach ($items as $item){
      if(!empty($item) || $item == '0')
        {
          if($i == 0) {

            $output .= '

';

          }
          else {
            $output .= '

';
          }
          $i++;
        }
    }
    return $output;
  }
}

each node has many images so it takes some time for the nodes to load, you can see each image load one by one taking about 10 seconds to complete


texts: Show a view of all nodes not being referenced by other nodes

texts:
In order to show a view with all nodes of type A not being referenced by other nodes of type B:

I created a view that contains the relation 'is referencing node'
I added the title field
I added a fielter: the NID field using the 'is referencing node' relation.
I turn on aggregation, and set this NID field to 'Count' with the value 0

This does not work. The filter works for all node count values exept zero.
Apparently the views row is not displayed if the count is zero.

I have searched for solutions but have not found one yet.
Help is appreciated, thanks!


texts: How can i edit a content types taxonomy terms trough the front end

texts:
I have put the taxonomy terms on the top of the page and i want to add a little cross on each tag to delete that tag (by the users) and also a 'add' button that lets people quickly add a tag to that page.

Does anybody know in which direction i should look? I'm willing to program is but i don't know which hooks i should use or where to put them. I've found pieces of code i could use but nobody ever mentions where to put it.


texts:
I want to build multidimensional  array at Twig.

In php

 $attributes['attributes']['class'] = array();
 $attributes['attributes']['class'][] = 'innerTab';
 $attributes['html'] = TRUE;

Same thing I want to build in Twig.
I tried but not getting proper one . Please check my code below
          {% set ctn = 0 %}
         {% for key, value in menu.menu %}
{% set attributes = {'attributes':'class'} %}
{% set attributes = attributes|merge( [ { (ctn) :'innerTab'} ,  {'html' : true} ]  ) %}
{% set ctn = ctn+1  %}
 {% endfor %}

As a result I get :

  array(3) { ["attributes"]=> string(5) "class" [0]=> array(1) { [0]=>
  string(8) "innerTab" } [1]=> array(1) { ["html"]=> bool(true) } }
  array(3) { ["attributes"]=> string(5) "class" [0]=> array(1) { [1]=>
  string(8) "innerTab" } [1]=> array(1) { ["html"]=> bool(true) } }
  array(3) { ["attributes"]=> string(5) "class" [0]=> array(1) { [2]=>
  string(8) "innerTab" } [1]=> array(1) { ["html"]=> bool(true) } }


texts: I am using Drupal 8 Panels and it is working fine. The problem currently I have is, that I want to add classes to individual blocks on the panel layout page. Is there a way to add classes to blocks on panel pages?something like the Drupal 7 version of CSS properties on panel panes?


texts: Abstract Base Class versus Service with Queue API

texts:
I'm trying to figure out the best way to structure a custom module that uses the Queue API in D8.  I'm new to D8 and a bit rusty with OOP so forgive me if I'm breaking some recommended design pattern here...

I created a single custom module where multiple different queues need to process items differently, but each queue has common functionality that they may need to use between each other.  So my question is, should I create an abstract base class that extends QueueWorkerBase, make processItem abstract, and then add common functionality to the base class?

Something like this:

In src/Plugin/QueueWorker/ProcessQueueBase.php

abstract class ProcessQueueBase extends QueueWorkerBase {

  /**
   * @inheritDoc
   */
  abstract public function processItem($data);

  protected function doSomethingCommon(){
    // Some common logic
  }
}

In src/Plugin/QueueWorker/ProcessQueueOne.php

class ProcessQueueOne extends ProcessQueueBase {

  /**
   * @inheritDoc
   */
  public function processItem($data){
    // Do stuff now

    parent::doSomethingCommon();
  }
}

In src/Plugin/QueueWorker/ProcessQueueTwo.php

class ProcessQueueTwo extends ProcessQueueBase {

  /**
   * @inheritDoc
   */
  public function processItem($data){
    // Do stuff now

    parent::doSomethingCommon();
  }
}

OR should I create separate classes that all extend QueueWorkerBase and then just create services for the common functionality.

Something like this:

In DoSomethingService.php:

class DoSomethingService {

  public function doSomethingCommon(){
    // Do something
  }

}

In src/Plugin/QueueWorker/ProcessQueueOne.php

class ProcessQueueOne extends QueueWorkerBase {

  /**
   * @inheritDoc
   */
  public function processItem($data){
    // Do stuff

    $do_something = \Drupal::service('mymodule.doSomething');
    $do_something->doSomethingCommon();
  }
}

In src/Plugin/QueueWorker/ProcessQueueTwo.php

class ProcessQueueTwo extends QueueWorkerBase {

  /**
   * @inheritDoc
   */
  public function processItem($data){
    // Do stuff

    $do_something = \Drupal::service('mymodule.doSomething');
    $do_something ->doSomethingCommon();
  }
}


texts: Is there a module that creates an input filter to convert text to the ASCII character-set?

texts: I have a textarea on a content type that needs to be converted ASCII character-set. Is there an available module that adds a input filter for this? This field needs to be fed to another platform with this formatting.


texts: Webform - Validating File Upload with PHP

texts:
How can I validate, via Webform module (using Webform file upload in Drupal 7) whether the file has been uploaded or not?

How can I handle and reference those files?

Seems that normal FAPI calls don't work (e. g. file_save_upload('file1') returns a non-true value if I have a file field).

I see that Webform file fields upload the file BEFORE form submission (i. e. clicking "upload to server" adjacent button).

I don't know if that's the normal file-upload behavior or it's a specific behavior.

How can I handle the files in that way? I need to validate if at least one of those fields was uploaded (assume they are named foto1, foto2, foto3, foto4), and later I need to reference those files (e.g. getting a public link to them).


texts: How to set the link in a view slideshow?

texts:
Currently,  I'm creating a xyz resort website. In my home page, I implemented a slideshow by using views. I want the slideshow to be clickable: When I click on to the resort image in slideshow it should go the respective resort description page.

Can anyone guide me on how to set the link in the view slideshow?


texts: Entityform view block not displaying on page

texts:
I can't seem to get Views-based blocks to show up on an Entityform page (Drupal 7). The View has a Contextual Filter of "Entityform Submission: Entityform submission ID". For the "When the filter value is not available" setting, I have "Provide default value: Content ID from URL" selected:

When I enter in an Entityform Submission ID in the Preview section, I get the results I'm after. However, when I place the Block on an Entityform page, it doesn't even show up.

What am I doing wrong?


texts: View to display nodes with lat long in proximity of specific lat long

texts: I have a content type and it has a geolocation field which stores a lat long . If I create one node with some lat / long info, I need to  look up / show a view of other nodes that have lat long information which is in the proximity of the former's lat long info. Any idea how to do this?


texts: How to import/add translated strings having inline styles?

texts:
I've imported a .po file having Spanish translations. The import was successful but some translation strings were skipped because they contain disallowed HTML.

From UI, I found that some translations were not translated. So I tried them adding those via the translate admin interface (Administration » Configuration » Regional and language » Translate interface)

I could see the original text having inline style like following.

But when I tried to add a Spanish (Latin American) Translation and hit 'Save translations' getting the following error.

  The submitted string contains disallowed HTML:Hola

I've enabled Translatable all HTML text formats under multilingual settings  (Administration » Configuration » Regional and language » Multilingual settings)

It's working when I remove inline style add translation   like the following. So I guess it's not supporting inline styles and classes.

 Hola

What could be the problem? I found a function in function locale_string_is_safe($string) under includes/locale.inc file. Do I need to do any tweaks with that?

Any suggestions would be much appreciated.


texts: Remember users Taxonomy choice, such as which city to filter the site by?

texts:
I want to convert an existing site to support the selection and association of Cities. Each node can be associated with a City, and the Cities will be selectable as tabs at the top of each page.

Lets say the City Taxonomy is:

All Cities (mainly used for old content the client doesn't want to convert)
London
New York
Paris

If a user browses to any City's front page then that will stamp that city in their cookie/user profile, such as:

site.com/all-cities
site.com/london
site.com/new-york
site.com/paris

Then when the user returns to the site front page site.com/ without a city specified, they'll be redirected to their remembered front page.

The site does not support user accounts however, so only anonymous users will visit, so it only needs to use cookies rather than store data in the DB per user.

Importantly, on top of this, the site is using 1 hour page caching due to relatively low traffic and poor page load speeds, so the redirect will need to run before the cache.

What is there a standard Drupal way to achieve the above, or will it need to be entirely custom in order to run outside any form of caching?

Thanks for any advice!


texts: How do I remove the title field from a node's custom view mode

texts:
In my Drupal 8 website I created a custom view mode through the UI. I use it to output nodes using a view.

In the view result I do not want the titles of the nodes to appear. The UI (content type > manage display) does not seem to give the option to hide the title.

How can I hide the title in a specific view mode for an entity via the UI or via custom code?


texts: How to display content from a second database

texts:
I have two separate mysql databases setup:

1) With all the Drupal 7 related tables etc etc

2) A custom database into which I will feed simple high score data from an external source eg. username, score, time etc

Is there currently a module which will turn my second database into something an end user can view/sort in a Drupal Page or content type? Obviously there is little point in collecting user high scores data is the users can't see it. I have come across only the Data module, but it is unclear to me as to if this does exactly I would need it too. For example there doesn't seem to be an options to change the tables appearance or style, something which the D6 only module Table Wizard did do. Has anyone used this module before, and if so has it been for a purpose similar to mine?


texts: I have a content type nodes with comments. I need to show latest comment via views. For this I created a views its just showing me comment status. not comment.


texts: How to use custom class methods in the .theme preprocess functions?

texts:
In a try to get code cleaner, I thought I could write a service in a custom module and use its methods within mytheme.theme, but obviously the preprocess functions signatures don't accept extra parameters.

In modules/custom/custom_module/src/Service/FooThemeHelpers.php

namespace Drupal\custom_module\Service;

class FooThemeHelpers
{
  // Add a specific custom format
  public function format_profile_adresse($field_profile_adresse){

    // do stuff ...

    return $markup;
  }
}

Then in mytheme.theme

use Drupal\custom_module\Service\FooThemeHelpers;

function mytheme_preprocess_views_view_fields(&$variables, FooThemeHelpers $themeHelpers) {

    if($variables['view']->id() == 'bar') {

      $markup = $themeHelpers->format_profile_adresse($variables['fields']['field_profile_adresse']->content);
      $variables['fields']['field_profile_adresse']->content = $markup;
  }
}

  TypeError: Argument 2 passed to
  mytheme_preprocess_views_view_fields() must be an instance of
  Drupal\custom_module\Service\FooThemeHelpers, string given

I tried also with template_preprocess_page_title(), same error.

Should I declare and use static methods instead in my service ? Is there any Drupal coding standard way to export these helpers functions in a dedicated class, so that .theme remains lighter and readable... ?


texts:
I can't seem to figure out how to retain image sizes in CKEditor.  When an image is sized, and the content is saved, and then edited again, I want the size to stay the same as set originally.

Is there a way to configure this?  If not, I can write JavaScript, so is there an implementation I could approach?


texts: I have to put in white-list the URLs used by the Update module. What URLs does it uses?


texts: How to show different delta of a multi-value token?

texts:
I have a multi-value field for user statistics (around 18 INT values): the field field_nurse_patients contains 18 integers 0,5,3,3...

Is there a way to get a format like below with tokens? Maybe with the token custom module or programmatically?

Desired output:

points: 0
height: 5
weight: 3

I've tried accessing the individual values like

[current-user:field_nurse_patients:0]
[current-user:field_nurse_patients:0:value]
[current-user:field_nurse_patients:value:0]
[current-user:field_nurse_patients:und:0:value]

None of which allows me to target the individual deltas.

There are a couple of similar (older) questions, but none of them really answers it.

Tokens for multi-valued fields?

What is the correct token for a multi value field?


texts: adding a background image to a Drupal site

texts:
I have a high-resolution white-paper texture background that I want to add to my Drupal site with the default Bartik theme.

I've looked at several posts across the web on how to do this with no clear answer.

I also haven't been able to find a Drupal module to do this. Most of the advice I've read is to modify the theme's CSS files.

But it's not clear which CSS file I should edit.  Colors.css, style.css?

I'm almost certain that the line I need to add is

 background-image: url("/images/papertexture.jpg").

But I'm not sure where to add the CSS.


texts:
I'm attempting to custom style the TB-Megamenu because there are a lot of color changes I would like to make. I would also like to change how when the mouse leaves an item it stays that color for a moment before changing back to it's default state. I understand that I can always change the css in a custom stylesheet that's also included like

#main-menu-wrapper .tb-megamenu .mega-nav > .active a, #main-menu-wrapper .tb-megamenu .dropdown-menu .mega-nav > .active a {
    background-color: #000;
    color: #fff;
}

But hunting down everything I need to change is quite the task. Especially when trying to hunt down what selections I need to make for things elements are active, or elements that the mouse just left. The fact that the TB-Megamenu is changing the classes also makes it difficult. At the same time the TB-Megamenu is being used elsewhere, and I'd like to keep the default style for them, without affecting other sites that are on the same instance of drupal.
Is there a better way to accomplish this? Or do I need to continue trying to search and override each element?


texts: How to avoid Rules adding blanks to eMail Id subscribed via Simplenews?

texts:
The following rule works fine, only it adds always a blank before and after the emailaddress in the database table . And that gives an error when sending the newsletter.

{ "rules_webform_block_to_simplenews" : {
    "LABEL" : "Webform Block to simplenews",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "webform_rules", "rules", "simplenews_rules" ],
    "ON" : { "webform_rules_submit" : [] },
    "IF" : [
      { "webform_has_id" : {
          "form_id" : "webform-client-form-113",
          "selected_webform" : { "value" : { "webform-client-form-113" : "webform-client-form-113" } }
        }
      }
    ],
    "DO" : [
      { "simplenews_rules_action_subscribe" : { "mail" : "[data:e_mail-value]", "tid" : "211", "confirmation" : "2" } }
    ]
  }
}


texts: How to limit the execution of a rule for sending an email to only run once in a day?

texts:
I have a rule that sends an email out to subscribers on the 28th of each month. The rule is executed when cron is run, I have cron set to automatically run once a day.

I also use linkchecker, which uses cron to check the links on the site. Right now I have to remember on the 28th of the month not to run cron for the linkchecker, otherwise my subscribers will get multiple emails that day for each time cron was run.

How can I limit the rule to only run once in any specific day, so that I don't have the potential to accidentally run cron manually and spam my subscribers?


texts: Checkbox label is not showing when there is a apostrophe in title

texts:
I have the following field with apostrophe in title

  $form['consultant_application']['terms_of_use'] = array(
  '#type' => 'checkbox',
  '#suffix' => '
' . t('In order to provide you with the best possible service, we need to process certain personal information about you. We will only ask for and use information that we genuinely need to provide you with the best possible service.') . '

' . t('In accordance with EU regulations, we need your consent to store your data and provide you with services. Our privacy policy clearly outlines the ways in which we process your personal data. It describes how we collect, use, share and process your personal data and how we comply with our legal obligations to you.') . '
',
  '#title' => t('I consent to La Crème processing my personal information in accordance with the La Crème Privacy Statement'),
  '#required' => TRUE,
);

Checkbox label is not showing, only the suffix text is showing. Can't understand what is happening.


texts: "Content"- Section in Backend cannot be displayed after installing translation module (German)

texts:
after clicking on the "Content"-button (=Inhalt) there is an error displayed.
I am not able to enter the "conten" Section of my Drupal 9 backend.
This happened right after I installed the german language pack.
Are there any experiences with that issue that could lead me the way? Would be greatful for suggestions.


texts: Combining the Same Terms in different Vocabulary as one

texts:
I have two vocabulary used by two different content type.

Category
Tags

However, the second content type does not use the Vocabulary Category. But there are nodes in second content type that has been tagged with same name in Category. So now I want to have the nodes of these same name be displayed as one.

That is
Category has term - TermA
Tags has term - Term A

Node of Type1 has been associated with TermA of Category and Node of Type2 has been tagged with TermA of Tags, but both these nodes should appear in one single taxonomy page as TermA. I am using Taxonomy Term Views.

How can this be done any ideas?


texts: Using Drupal 7 & Omega 3.x - Page Titles + Edit Tabs are not showing up on node content types!

texts: It seems that my page titles and the edit tabs have disappeared. I'm currently using omega 3.x and drupal 7. However the weird thing is that its showing up one content type, but not on others. I even created a new content type and it still doesnt show up. I also disabled the theme and enabled the default seven theme as the main one and it does show up. So it is in fact omega's subtheme that is causing the issue when i enable it.


texts:
I know in order to create views displays you simply declare it as:

  $view = views_get_view('AN_EXISING_VIEW', TRUE);

  $handler = $view->new_display('page', 'YOUR_DISPLAY_NAME', 'YOUR_DISPLAY_MACHINE_NAME');
  $handler->display->display_options['title'] = 'TITLE';
  ...
  views_save_view($view);

You can do this in hook_enable in your install file or using hook_views_default_views

All I need is however to programatically alter an existing view display of a Workbench Moderation module (workbench_moderation): 'YOUR_DISPLAY_NAME' and 'DEFAULT' in order add other fields and permissions on those fields.

My questions are:

How do I effectivelly get the specific display: e.g. $views->get_display?
How do I save it so that will not mess the views caches?


texts: Building a full featured gallery with voting system

texts:
I'm looking for a way to build a simple gallery node type in Drupal, with vote (with Votingapi and Fivestar)per image enabled. (1 vote per image, per node, per user, and users are able to vote on any image in the node).
As simple as it looks, I'm unable to build a simple proof of concept of what I'm trying to achieve.

Here's a mockup of how I see the thing, and here's how I see the thing in Drupal.
A content type 'Gallery' these following fields:

Title
Body
Field Collection (multiple):

Image (single)
Fivestar rating

I succeeded to do it and now, to compute the results, I would like to get the results per node.
However, if you look into the votingapi_vote table, the only data for a vote are:

MariaDB [voting]> SELECT * FROM votingapi_vote;
+---------+-----------------------+-----------+-------+------------+------+-----+------------+-------------+
| vote_id | entity_type           | entity_id | value | value_type | tag  | uid | timestamp  | vote_source |
+---------+-----------------------+-----------+-------+------------+------+-----+------------+-------------+
|      10 | field_collection_item |         2 |    80 | percent    | vote |   1 | 1455270089 | 127.0.0.1   |
|      13 | field_collection_item |         3 |    60 | percent    | vote |   1 | 1455271926 | 127.0.0.1   |
|      15 | field_collection_item |         1 |    80 | percent    | vote |   1 | 1455272041 | 127.0.0.1   |
+---------+-----------------------+-----------+-------+------------+------+-----+------------+-------------+

It is impossible to retrieve data from the parent node because it simple doesn't exists in the DB.

It looks like we could change tags dynamically, so I hooked into fivestar to generate dynamic tags, but it gets blocked in _fivestar_cast_vote(), especially in fivestar_validate_target(), and I'm unable to generate tags dynamically.

I also tried to hook into Votingapi using hook_votingapi_preset_votes_alter() but if you're using Fivestar with the AJAX widget, it's impossible to get information on the current node using menu_get_object(). So I'm still stuck.

Now I'm trying to look for another solution, if you have ideas, please let me know.


texts: Adding taxonomy term list to another taxonomy term's overview

texts:
Let me start by saying I'm fairly new to Drupal. I'm using Drupal 7.

I have a content type "product" which is assigned to one or more taxonomy terms in "collections" (taxonomy). Then I have another taxonomy called "brands".

The "brands" taxonomy has a field reference to a "collections" taxonomy term. For instance: brand "Google" can be assigned to collections "Shoes" or "Bags".

On the collection page for "Shoes", all the products tagged "Shoes" are being displayed. On top of the page, I want to add a list of all the brands in the "brands" taxonomy, that are assigned to this particular collection ("Shoes"). They are independent from the products themselves. How would I display this list on top of the page? Do I need to create a custom overview?


texts: Adding own variables on user registration to created user

texts:
I want to add additional informations to a user on registration.
I have added the fields accountID and clanID to the user .
On registration i load these information according to his entered name from another webpage and i want to have these fields added to the user.

My question is, how can i add these additional values to the fields programmatically?


texts: If the user register, the confirmation mail goes to spam folder.  After doing some R&D, I enabled "Use two e-mail fields on registration form > Set password" and tested; it goes to inbox from the web server. But as i badly need to show the demo to my supervisor from my local server instead of live, using "Acquia Dev Desktop", it goes to the spam folder.　How can I prevent the message from going to the spam filter?


texts: What hook should I use to alter the File Upload field in Webform 7.x-4.16

texts:
In Drupal 7 Webform file field, might there be a way to access the link provided after the a file is uploaded?

The reason is that we have a hot-folder/watch-folder process that runs, cleans a file, converts DOCs to PDFs, checks for accessibility, etc. I'd like to link to converted version of that file.

We want to allow the user submitting everything to ensure their document is converted properly before they click the submit button.


texts: How to prevent other roles from publishing content

texts:
I am new to Drupal. I am working on a website where I have 2 user roles: Site admin and editor.

The site admin has all permissions. I want the editor to only have the permission to edit content but not to publish or edit them. He can view his edited content but cannot publish them.

Different people suggested me different options, like use this module, use that module, but no body is showing me a neat and proper solution.


texts: Is it normal for a database to have 3600 tables?

texts:
I recently inherited a Drupal site and while trying to migrate the site and DB I noticed that the DB is 1GB+ and had 1000s of tables. This is the first time i work with Drupal so I'm not sure what these tables are.

A lot of them are exactly 128KB and named something like drupal_field_data_style_abc or drupal_field_revision_abc. Is it safe to delete these? Not really sure what they are for at the moment.


texts: Can an embedded video be made responsive?

texts:
I currently use the Video filter module to embed Youtube videos in my posts, but on mobile devices the videos are not responsive. They still maintain their width no matter how narrow the screen is.

I am open to another method of embedding videos even raw HTML and Javascript if the video displays will be responsive


texts: CCK field migration reproducibly results in server error on node display

texts:
I am trying to migrate my CCK types to Fields using CCK module in D7, using content_migrate, following the documentation. After migrating all fields of a certain content types, I got a server reset when trying to view any node of this content type.

See also https://www.drupal.org/node/2665208

In Chrome the message is
"No data received ERR_EMPTY_RESPONSE", Firefox says "Secure Connection Failed
The connection to the server was reset while the page was loading". The server log is completely empty for loading this page, so I guess php dies pretty early.

I migrated all fields one by one and tracked it down to a text field that was using an optionwidgets_button widget in D6.

Edit: We found a second broken field. This field does not cause a server reset but a 'The website encountered an unexpected error' from Drupal upon display of any node where this field is set. This field is of type user_reference.

This is the output of from the migration process of the offending field:

Changed field type: The 'field_myfield' field uses a 'optionwidgets_buttons' widget. The field type will be changed from
'text' to 'list_text'.

Rolling back the field suppresses the error; re-migrating this field fully reproduces the error.

no pending dbupdates, Postgres 8.4, PHP 5.3


texts: How to display all terms for specific taxonomy in views incl. ones without content?

texts:
How to set up a view that displays all terms for a specific taxonomy including the ones that have no content assigned?

I just can't figure it out to do it with a view:CONTENT and mainly found posts about hiding them.

In the results table, I also want to show a count of # nodes for each term (which I managed to do with Aggregation > Count).

I also tried creating as a View:TERM which does list all terms associated but then I can't display a count of nodes for it.


texts:
I made a copy of our dev server and gave it a new name and IP,but now I can not login into it. I think the fault is that I can not get LDAP to verify my pwd. Please could somebody point me in the right direction in what am I still missing.
Ihave made the IP changes in the following places

etc/hostname
/etc/hosts
/srv/drupal/sites/default/settings.php
/etc/resolv.conf (madesure that the nameservers are ok)
Updatet all the
firewall servers rules to similar as the dev servers are.

Now I can navigate to the login-page of the site with the new IP,but when I try to use my creditentials it does not give me access like the dev server does.
Have I forgotten to change something on Drupal orr could it be cache related or what?
Thanks for your help
P.S I'm running Drupal on Ubuntu


texts: How to add conditional HTML meta tag using drupal_add_html_head to force only IE9 into compatibility mode?

texts:
Long story short: Some quite nice interative SVG map works fine on every major web browser thanks to svgweb. Except IE, of course. Every IE (8, 9, 10) needs a particular workaround. IE9 would only work when I force it into compatibility mode. Unfortunately I can't find a way to use drupal_add_html_head with #tag' => meta and #prefix and #suffix to only take effect in IE9. drupal_add_html_head works fine, but #prefix and #suffix discard it. So that doesn't work:

$meta_ie_render_engine = array(
  '#type' => 'html_tag',
  '#tag' => 'meta',
  '#attributes' => array(
    'http-equiv' => 'X-UA-Compatible',
    'content' =>  'IE=7',
  ),
  '#weight' => '-99999',
  '#prefix' => '<!--[if IE 9]>',
  '#suffix' => '<![endif]-->',
);
drupal_add_html_head($meta_ie_render_engine, 'meta_ie_render_engine');

Is there another way to use drupal_add_html_head with tag => meta conditionally? Or another drupal-like alternative?


texts: How to use autocomplete text field in fieldset?

texts:
I want to use a textbox with autocomplete features. I have gone through the drupal form API and found the solution at here.

It's working fine if I am using this directoly in the form fields. But it's not working if I am using this any Field collections item in profile2 fields.

I am using profile2 fields with fieldscollection and following is my code.

/*profile_2_type is id for profile 2 module and it's not working for me*/
$form['profile_2_type']['field_test_auto_cmplete']['#autocomplete_path'] = 'user/autocomplete';

/*Here is the code which is working for me for node fields */
$form['title']['#autocomplete_path'] = 'user/autocomplete';


texts:
I'm trying to develop an Ajax process in a Drupal Module. Here's the code :

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

  $items['route/to/ajax/%'] = array(
    'page callback' => '_MY_MODULE_processing',
    'page arguments' => array(3),
    'type'  => MENU_CALLBACK,
    'access arguments' => array('acces content'),
    'delivery callback' => '_MY_MODULE_listing'
  );

  return $items;
}

function _MY_MODULE_processing($region='110') {

  // Executing some operations to retrieve a list of NIDs
  // retrieving the nodes
  $nodes = node_load_multiple ($nidList);
  return ($nodes) ;
}
/**
 * Here is the templating part
 * @param unknown $nodes
 */
function _MY_MODULE_listing ($nodes){
  $build = array();
  $nodeList='';
  foreach ( $nodes as $node ) {
    $nodeList = $nodeList.'<option value='.$node->nid.'>'.$node->title.'</option>';
  }
    $build['content'][]=array(
      '#prefix'=>'',
      '#suffix'=>'',
      '#markup'=>$nodeList,
    );

  return ($nodeList);
}

I don't get any response with this. I've run debugging function and it goes inside every function. First _MY_MODULE_processing then _MY_MODULE_listing.

How can i return a correct response ?


texts: Change display order of a content type fields in the view tab

texts:
How can i change the order of displaying fields details of a node of a content type in D8 ? Its neither specified in the Manage form display or in the Manage display of the content type management menu .

PS : I have added existing fields from another content type to this content type . Will that's display order taken in to this ? How can i change this ?


texts:
I have a large Drupal 7 website on my hands that is very large and has loads of modules (over 200).
I am already seeing poor performance symptoms in the FPM logs with max_children limits reached on the Acquia server.
I installed a profiler (blackfire) and the main issue (on every page) is an absurd amount of calls to unserialize (over 300) coming from DrupalDatabaseCacheprepareItem (autenticated).
This happens even on a basic page.
I am having a tough time coming up with a solid strategy to pinpoint the bottleneck and which module(s) are the culprit.

Anyone can help me with this?


texts:
Hello i have multilingual site. The site was build on Drupal 7.15 and i18n module. Couple of days ago I have updated core and all contrib modules. Everything works kind a nice but I have noticed when I add new menu item it doesn't show.

I debugged this behaviour and I have found out that all menu items added BEFORE updated has parameter "langcode" with proper language, but all items added AFTER update have no "langcode".

Site has condition which filters menu items according to menu item's "langcode". If I remove this condition it actually works nice.

So my question is. Do I understand it right that menu items with proper language are now selected in some preprocess so "langcode" is no longer needed?

Thank a lot.


texts: 2 Drupal Multisites, Separate Databases, Changing 1 Also Changes the Other

texts:
I have a very weird issue. Been doing Multisites in Drupal 7 for a while now without any hitches... until last week. I have 2 multisites both with separate databases, however when I change content on 1 of them it also changes content on the other.

I have Multisite01 pointing to Database01 and Multisite02 pointing to Database02 (copy of 01). I should be able to change 1 multisite and not have it effect the other. I'm not sharing databases or anything. This has always worked for me before.

What I did different in this instance was when I copied Database01, Database01-Copy, to create 02. I was in a hurry and meant to click on 01-Copy to rename but instead, I clicked on 01. No matter, or so I thought... I just renamed Database01 to Database02 and then I renamed Database01-Copy to Database01.

Now Drupal has them permanetly linked... even if I link Multisite01 or 02 to another database (ie Database03 or 04, etc). So I know that the change is outside of each Multisite's database. Wondering if this can be fixed without reinstalling Drupal...

/*Misc. Info
Multisite01 Settings.PHP (Multisite02 is same but connects to database02)*/

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'database01',
      'username' => 'username',
      'password' => 'password',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);


texts: How can I make a view block of related products?

texts:
I have read through the issue queue and read all kinds of documentation and made all kinds of settings in Views Contextual Filter and no luck at all. What can be the definitive way to make a Views block of related Commerce 2 products?
My products are tagged to taxonomy terms of which the taxonomy vocabulary is referenced on the product. I now tried to make a Views block to make contextual filter such that if viewing a product you can find a block of other products belonging to same taxonomy term.
No settings are working.


texts:
The content architecture of the site which I am working on is something like:-

Song - Content type
Genre - Vocabulory

Song has an entity reference field which points to the terms in "Genre" vocabulary.

Genre field is added in the view which lists Songs content.
The field result has been rewritten as link which points to the URL pattern : songs/<genre-name> ([field-genre] was used).

The path songs/% is a separate view page, which is supposed to take the "genre name" as contextual filter, and show songs of that particular genre.

Here the url gets the taxonomy term name but the title gives %2 instead of the name

Override title is %2

The view is working fine but I am not able to replace the title.


texts: Profile2 regpath move account email field, into profile2 form and handle submit

texts:
I have a profile2 regpath displaying my profile2 form, and the system default account registration form below it. I need to move the account email field up into the container with the profile2 fields.

I have altered the form and moved the account mail field from the account form, into the profile form, and I have created an additional validation handler to try insert the mail value into the $form_state value so the user_account_form_validate() doesn't choke on a missing ['mail'] index:

function si_student_form_user_register_form_alter(&$form, &$form_state, $form_id) {
  global $user;
  // remove fieldgroups and tabs for anonymous users, e.g. /student/register
  if($user->uid == 0) {
    // move email field from account to below profile2 name fields
    $email = $form['account']['mail'];
    unset($form['account']['mail']);
    // add email to profile
    $form['profile_student']['mail'] = $email;
    // change weights
    $form['profile_student']['mail']['#weight'] = 3;

    // custom validation handler to inject mail value into
    // correct place in $form_state['values'] array
    $form['#validate'][] = '_si_student_register_anonymous_validate';
    //dpm($form);
  }
}

function _si_student_register_anonymous_validate($form, &$form_state) {
  $form_state['values']['mail'] = $form_state['values']['profile_student']['mail'];
}

However this isn't working, and I get the following:

Any ideas? I'm not sure I'm taking the right approach here. Thanks


texts: How can we do open a popup for login facebook and after complete it will close?

texts:
I want a popup that will open when anybody wants to sign-in using facebook or any social site login. The box pops up and will close after successful login or cancel

This is code I am using for this and I know something missing please give me some hint---

<a href="https://www.facebook.com/dialog/oauth?client_id=MYCLIENTID&amp;redirect_uri=http%3A//www.MYWEBSITE.COM/fboauth/connect&amp;scope=email" class="facebook-action-connect" onclick="window.open(this.href,'popupwindow','width=700,height=500,scrollbar,resizable'); return false;"  target="_self" style="color: White; font-weight: bolder; cursor: hand; text-decoration: none">


texts: Why are two database tables (node and node_field_data) used for node data?

texts: I would like to understand the database architecture of Drupal 8. I noticed that Drupal 8 has two separate tables (node and node_field_data) which include almost the same columns. Can anyone give some clarification on this?


texts: How to get devel content generate module to only include one image per dummy content creation

texts:
I'm using devel generate and it randomly adds multiple images to articles.

I can limit the number of words in the title.

Is there an option to limit number of images or text lenght?


texts: I was just wondering how one should go about scheduling a post in Drupal so that it posts at a point in time later then when you are posting? Is it as simple as changing the post time on the author information to a future point in time or is it more difficult then that?


texts:
I have been asked to control access by different groups of users to files uploaded to a website.

This covers both files uploaded as a field, and files uploaded via IMCE and CKEditor.

I have several Roles to handle; Anonymous users, Authenticated Normal User, Authenticated Coordinator. And probably some more later.

There are already Permissions controlling access of users to relevant nodes and forum topics. For example, an anonymous user can only see the public part of the site, the normal user can see some content types and forums and coordinators can see everything a normal users can see as well as some extra forums.

I need files uploaded by authenticated users in the restricted part of the site to 100% not be accessible to anonymous users. And, I need documents uploaded by the coordinators to not be accessible by the normal users.

Currently, normal users can bypass the node and topic permissions to access files if they have the direct link.

How should we approach this?


texts: Adding a new column to users table: db_drop_field errror

texts:
I'm trying to add a column to the 'users' table. When I install my module, the column gets created and when I uninstall it gets deleted.

The issue is that after I uninstalled, I run a 'drush cc all' and I receive this error:

  WD php: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown[error]
  column 'base.firstname' in 'field list': SELECT base.uid AS uid,
  base.name AS name, base.pass AS pass, base.mail AS mail, base.theme
  AS theme, base.signature AS signature, base.signature_format AS
  signature_format, base.created AS created, base.access AS access,
  base.login AS login, base.status AS status, base.timezone AS
  timezone, base.language AS language, base.picture AS picture,
  base.init AS init, base.data AS data, base.firstname AS firstname
  FROM
  {users} base
  WHERE  (base.uid IN  (:db_condition_placeholder_0)) ; Array
  (
      [:db_condition_placeholder_0] => 0
  )
   in DrupalDefaultEntityController->load() (line 193 of
  /var/www/includes/entity.inc).

Here is my code inside the .install:

function mymodule_schema_alter(&$schema) {
  $schema['users']['fields']['firstname'] = array(
    'type' => 'varchar',
    'length' => 60,
    'not null' => FALSE,
    'default' => '',
    'description' => 'Field added by profile common module',
  );
}

function  mymodule_install() {
  $schema = drupal_get_schema('users');
  db_add_field('users', 'firstname', $schema['fields']['firstname']);
}

function  mymodule_uninstall() {
  db_drop_field('users', 'firstname');
}

Thanks.


texts:
Exploring Drupal, so still lot of unknowns.

Drupal 7 out of the box can do the following :

Authenticated users can create/edit/delete "their own" article content. - works out of the box
Admin can create/edit/delete "any" article content - works out of the box.

Wondering if Drupal 7 out of the box can do the following?

Authenticated users can "only" view their "own" article content. I only see the option "View Content" but it seems to be for "any user". So when the "auth user A" creates an article it's available for "any" user. Is there a way to restrict view. This goes for both published and un-published article.
Does the access control extends to any content types as per above or custom code is required?

Thank you for your clarifications.


texts: Add field to an entity_view for dispaly in a tapir table in ubercart

texts:
In the simplest terms I am trying to add a 'vendor' column to the order view table in Ubercart which will display the author of each line item product.

Below is the table of interest.  I have hacked the direct code contained in uc_order.order_pane.inc but will refactor with hooks the drupal way ASAP. I have added my comments in the code below.

function uc_op_products_view_table($order) {
  dpm($order);
  $table = array(
    '#type' => 'tapir_table',
    '#attributes' => array('class' => array('order-pane-table')),
  );

  $table['#columns']['qty'] = array(
    'cell' => array(
      'data' => theme('uc_qty_label'),
      'class' => array('qty'),
    ),
    'weight' => 0,
  );
  $table['#columns']['product'] = array(
    'cell' => array(
      'data' => t('Product'),
      'class' => array('product'),
    ),
    'weight' => 1,
  );

Added by me:

  $table['#columns']['Vendor'] = array(
    'cell' => array(
      'data' => t('Vendor'),
      'class' => array('vendor'),
    ),
    'weight' => 1.5,
  );

.

  $table['#columns']['model'] = array(
    'cell' => array(
      'data' => t('SKU'),
      'class' => array('sku'),
    ),
    'weight' => 2,
  );
  if (user_access('administer products')) {
    $table['#columns']['cost'] = array(
      'cell' => array(
        'data' => t('Cost'),
        'class' => array('cost'),
      ),
      'weight' => 3,
    );
  }
  $table['#columns']['price'] = array(
    'cell' => array(
      'data' => t('Price'),
      'class' => array('price'),
    ),
    'weight' => 4,
  );
  $table['#columns']['total'] = array(
    'cell' => array(
      'data' => t('Total'),
      'class' => array('total'),
    ),
    'weight' => 5,
  );

  if (!empty($order->products)) {
    $build = entity_view('uc_order_product', $order->products);

This is the entity I want to edit. uc_order_product needs to have a field for Author / Vendor to make my table look right.

    dpm($build);
    $table['#rows'] = $build['uc_order_product'];
  }
  else {
    $table['#rows'][]['product'] = array(
      '#markup' => t('This order contains no products.'),
      '#cell_attributes' => array('colspan' => 'full'),
    );
  }

  return $table;
}


texts: How do I use a "contains" operation as restful contextual filter for text fields

texts:
I'm trying to create a restful view which takes a string as input, search specific content-type titles for similar nodes and return them as result.

The problem is I can't figure out how to configure the contextual operation to act as contains.


texts: field->raw problem with date in views-view-field.tpl.php (add classes to day and year in date)

texts:
I have a template (views-view-field.tpl.php) and I'm trying to get the raw value of the date field so that i can reformat it and add classes to each seperate part of it (ie day, date, year).

This is what I'm doing:

foreach ($fields as $id => $field)
{
if  ($id == 'field_date_published')
{
echo $field->content //outputs string to page as themed expected ie 23 Oct
echo $field->raw     //simply outputs 3 digits ie 234
}
}

My question is how can i get the raw value of the time so that i can manipulate day, month and year with specific css classes.

Please do not suggest i solve this problem in any way other than getting the raw data in the template file.  I know there are other methods to solve this but i have come to the limit of my understanding in the template file and need to find new avenues of learning to progress.

Thanks in anticpation,


texts: How do I alter the options in the add menu link checkbox in the node edit form?

texts:
I am hooking the node edit form with hook_form_node_page_edit_form_alter(). How can I alter the available options when adding a menu item for that node?

I need to only show menu items of given node ids:

if (isset($form['menu'])) {
  $node_ids = array(1,2,3);
  // only show those node's menu links in the options
}


texts: 2 views blocks on 1 page - no duplicate results

texts:
I have 2 views blocks with the same filter criteria. Both are displayed in different regions on 1 page. But they should not display the same results.

Is there a solution for that?

Note: The views have the same data. But they are sorted randomly.


texts:
I have two content types: 'artist' and 'venue'.

When an artist node is viewed, it needs to display a list of venues and dates. Venue name will link to the venue node eg:

Artist
--------------------
Venue1 | 1-Jan 20:00
Venue2 | 2-Jan 17:00
Venue3 | 4-Jan 20:00

The possible solutions are:

Create a 'performance' content type that links (using the References module) to artist and venue, and has a date field. Then attach the list using Views. This seems like a lot of extra work for the editor.
Add two unlimited value fields to artist node: reference to venue and date field. It is difficult to keep them in sync and clunky.
Would this be a good use of the entity API? I don't know enough about entities yet, but have a feeling that would be overkill for something so simple?


texts:
I installed the jQuery Update module, version 6.x-2.0-alpha1, which supports jQuery 1.3.2. I need to update it to jQuery 1.4 or higher, for a jQuery plugin.

I tried replacing the existing jquery.js and jquery-min.js files in the jquery_update/replace directory with the latest jQuery files, and made some changes to jquery_update.module as suggested in Using Newer Versions of jQuery. After doing so, jQuery started loading from misc/jquery.js, which was an older version.

Is there any simple way to update jQuery? I cannot implement the noConflict solution since I will be using third-party jQuery plugins.


texts: Interface translation conflict / same EN word, different translations

texts:
I've created a custom module, that uses templates with hard coded strings. I've created the .pot and .po files and included them my module's YML file. The Twig tempatles translate those strings using the |t operator. This works fine.

Now I've run into a problem: My module offers button to book an accommodation, which clashes with Drupal's book (to read) module. In the german translation those two words are completely different.

I've got two questions:

How to I provide a translation for the book verb in my module, in a way that it doesn't clash with the book module.
How to I use the tell Twig to use the correct book string from my module?

E.g. this template code
First I want to {{ 'book'|t('context_accomodation') }} a hotel room and when I arrive I want to read a {{ 'book'|t('context_reading') }}

should render in english
First I want to book a hotel room and when I arrive I want to read a book

and should render in german
First I want to buchen a hotel room and when I arrive I want to read a Buch


texts: How to add css class on click of CKeditor table button?

texts:
We are using the CKEditor module provided from Drupal 8 (v8.6.2). There is a need to add a css class to the table when it is added to the Body field (text formatted, long) after someone clicks on the table button without having to modify the table via Source button.

How would we add a css class to the table after clicking the CKEditor table button?

The goal is to be able to do this without a module. If it comes down to it, we can review the module, but prefer to use any out of the box functionality. Another goal is to be able to do this on D8.


texts:
If I add a tag like <script src="http://mysource"></script> in the source code side in CKEditor, it appears well in the WYSIWYG side. But if I go back to source side and come back to the WYSIWYG side it has been transformed like:

<!--{cke_protected}%3Cscript%20src%3D%22http%3A%2F%2Fmysource%22%3E%3C%2Fscript%3E-->

So, I tried to disable Advanced Content Filter by unchecking "Limit allowed HTML tags and correct faulty HTML" and also by using the hook_ckeditor_plugin_info_alter, according to this answer.

I also tried to add allowedContent = true by using ckeditor_config.

Unfortunately without any result.

How to disable this filtering, at least for <script> tag?

I mention that I need the ability to add my <script> tag in CKEditor (my script will load an iframe at this area) and style it.


texts: Is there a way to pop form errors off the display stack and/or prevent their display?

texts:
I have a Drupal 7 form which I'm allowing the user to submit via AJAX. If the user does not fill out required fields, or enters invalid information, I can return that and alert the user via the form_get_errors() function. The problem is that these values are still on the "display stack" (not the correct term, I'm sure) - when the user refreshes the page, or navigates to another one, these previous errors are displayed.

Is there a way to set these errors not to display once I've grabbed them with form_get_errors()?

EDIT: The session variable 'messages' is set at $_SESSION['messages']['error'], which is where the display of the errors is driven from. I could wipe this out by doing something like unset($_SESSION['messages']['error']), but I feel like this is very hacky. The drupal_static_reset() function also will not help, since it doesn't eliminate the values in the messages array.


texts: Is it possible to manually sort items from Views? I want to be able to define which content goes first and which one's last.


texts: In D6 Rules, how do I grab a string variable from an event?

texts:
I have a D6 Rules custom event(1), that captures a string argument when invoked(2). I also have a custom condition(3) that I want to work in conjunction with this event. I need the string argument passed from the event to show up in the condition, so that I can match it against another string(4).

With the code as I have it now, a field for argument shows up to be configured on the 'add condition' >> 'Foo response code equals value'  page (instead of being pulled from the event). This is because the rules data type string uses an input form.

My question: how can I access a string variable, passed by an event, in a condition?

(1)

function foobar_rules_event_info() {
 $events = array(
    'group' => t('foo'),
  );
   return array(
    'foo_contactCreate' => $events + array(
      'label' => t('Sending new foo contactCreate'),
      'variables' => array(
        'foo_response' => array('type' => 'string', 'label' => t('created foo contact')),
      ),
    ),

(2) $foo_response is a string

// Invoke event wrappers
function rules_foo_contactCreate($foo_response) {
  rules_invoke_event('foo_contactInfo', $foo_response);
}

(3) foo_response should be the argument passed from the event

/*
 *  Implementation of hook_condition_info
 */

function foobar_rules_condition_info() {
    $items = array(
      'foobar_foo_response_condition' => array(
        'label' => t('FOO response code equals value'),
        'description' => t('Checks the response code from a FOO command. The condition returns TRUE, if the FOO response code has the given value'),
        'module' => 'foobar',
        'arguments' => array(
          'foo_response' => array(
            'type' =>  'string',
            'label' => t('Received FOO Response Code'),
            'value' => ''
          ),
        ),
    //   'foo_response_codes' => array(
    //     'type' => 'list<string>',
    //     'label' => t('Wanted FOO Response Code'),
    //   ),
      ),
    );
    return $items;
}

(4) Desired conditional is currently commented out in line 3

function foobar_response_condition($passed_response_code) {
  if ($passed_response_code) {
  // if ($passed_response_code == $wanted_response_code) {
    return TRUE;
  }
  else {
    return FALSE;
  }
}


texts:
I am having two content-types:
1. article
2. Collection
Where multiple articles can be grouped in a collection i.e. collection = n x articles. Now problem is that when i edit collection and add an article to it which is already in another collection i get an error saying:

  Reference overloading: Collection 2 would of had 2 references and only 1
  reference is permitted. Before adding a reference, you would need to edit
  Collection 2 to remove an existing reference and resave this node to have
  make it correspond. Or you could allow this reference instance to have
  more references,go to the cck field settings of the instance.

But I want is that previous reference should be removed instead of showing such an error.

Also I want that if i remove article by editing collection then it should refer an default collection.

I am using Drupal 7.


texts: Using jquery mmenu, how to close one submenu when I open another submenu?

texts:
I'm building a (Drupal 7.5) site where I use mmenu (Mobile Sliding Menu) module to create the menu. When I click the trigger, the main menu items appears. Some of the main items have a submenu. When I click the trigger for those submenus, the submenu opens, so far so good.

When I then click another submenu trigger, that submenu opens, but the previously opened submenu stays open as well. What do I need to change to have only ever one submenu open at any one time (i.e. triggering a new submenu closes one that was opened before)? There is no setting for this in the mmenu configuration (drupal module), and no instructions on this on the mmenu website (http://mmenu.frebsite.nl).

Many thanks for any help on this.


texts: Set default value to an image field form element using form_alter

texts:
I am using this code, but the form doesn't get default image value:
The image is created and exists in the server:

$image = file_get_contents($url);
$destination = 'image.jpg';
$file = file_save_data($image, $destination, FILE_EXISTS_RENAME);

And $form is populated this way:

$form['field_user_picture']['und'][0]['value']['#default_value']['fid'] = $file->fid;

I think I am missing something, could anybody help?


texts: Batch process is getting duplicated when the batch URL is reloaded or duplicated in new tab

texts:
I am using Batch API to perform certain code manipulation task. The batch works completely fine except for when the batch URL is reloaded or duplicated on a new browser tab. This leads to the batch execute and finish functions to be called twice and hence duplicating the task I want to achieve with this batch process.
Any idea how to prevent it from happening?


texts:
In drupal 7 we used to attach a webform to nodes and then we could render them as a block, nowadays in drupal 8 Webform is a dependent entity and is designed and developed on its own. now my question is :

  I've created a webform and now I want to place it in a block so user can simply fill it up in front page, How can I show a webform as a Block?


texts:
I have added a image field with upload widget to my content type. It is shown when I try to add content as administrator, but not with other user types. Any ideas what may be wrong? Probably some permission or something, but I am simply unable to find out which setting this may be. Any help?

Seems like the fields are visible if I disable the "OG Field access" module. But when I enable it again, I cannot see the fields.


texts: How to redirect a cancel button to destination on each form?

texts:
I'm using the following code to add a cancel button on every form I have for add / edit of every content type. The target should be the destination adress in the url

In some content types it is working and some not:

$link = l(t('Annuleren'), drupal_get_destination());

      // add the actual button to the form
      $form['actions']['cancel'] = array(
        '#type'   => 'submit',
        '#value' => "Annuleren",
        '#access' => TRUE,
        '#weight' => 55,
        '#submit' => $link,
        '#limit_validation_errors' => array(),
        );

      dpm ($form);

It has something todo with #value. If I replace it to #markup like below example then it is working but I do not get a label in the button.

  '#markup' => "Annuleren",

How to solve this?


texts: Add unique class to each link outputted by views

texts:
I'm using views to output a list of links (fields). I can type in an url and a text and the text becomes the link text that goes to the url. Now I want to be able to add a unique class to the link when I add it from the backend. Or have a unique class/ID added to it by default, that is also fine.

How can I do this?


texts: image in newsletter does not apply image style (defaults to original size)

texts:
I'm using a simplenews template (simplenews-newsletter-body.tpl.php) to output with mimemail in html.

Everything works as it should except that the image in my newsletter is always taken from the original size (/sites/default/files/blogs/blablabla.jpg) instead of the smaller "image style" that I created.

In my template, I use the token: [node:field_image], as it's the only available choice I found.

Do you guys have an idea of what I should try?

Thanks


texts: How to send an email that always contains all fields of entityform, without manually updating when fields are changed?

texts: I have a client with an entityform with over 100 fields (trust me, I begged with them to lessen it). I need to send an email using rules with all of the fields exactly as they appear on the form. I don't want to have to manually add all of these tokens to the email and I also don't want to have to manually update the email with new and/or removed fields every time they change the form. Is there any way of using a token that calls all of the fields on the form and maybe even uses the view mode?


texts: 500 error on one page in entire site only showing error "You are here" instead of administration content

texts:
this error seems to only affect one page in on the website, and nowhere else.
Here is what it looks like:

The watchdog reports do not show the issue, and I believe it to be a permission error or caching error with Apache2, but unsure. I have tried:
clearing cache, searching for a relevant php file with unreadable permissions, and looking over .htaccess files for anything out of the ordinary.
I may have missed a few php files but I am looking for confirmation that I am heading in the right direction.

I will probably end up asking the web platform IT people for help if I can't find an answer, but anything at all will be greatly helpful.
Thank you.


texts:
Please kindly help if you know a solution for this or a ready module you may be aware of:

1:I need to set a node a way that each user can only see their own comment and replies to that.
2:Also I need for some nodes, a user can see other users comments, only when he/she has a comment on that node already.
3: A group can see only each other comments on a node.

I hope this can be done by a setting when we are creating a node.

Thanks in advance for any help.


texts: How to create custom 403 page for a particular content type?

texts:
For a particular content type in my Drupal 6 web site, I do not want the users to see the "access denied" message when viewing an unpublished node. Instead I want to show a more meaningful message.
I have tried various modules like http://drupal.org/project/customerror, but I can't find a way to restrict the message for only a single content type.
There is a similar question here http://drupal.org/node/888312.

Do you have any suggestion on how this could be achieved?


texts:
I have a content type with two fields for two different taxonomy vocabularies (Section & Extras). "Section" only have one value, while "Extras" can have multiple values.

I created a block using Views for the "Section" term page that will list in a summary display the "Extras" terms the node tagged with "Section" have using the term page argument.

The issue I am having is that in the view I had to use two arguments and the two arguments are part of the summary base path and I just want to use the second one:

Right now my URLs look like:

/taxonomy/term/X/Y (where X is the tid of "Section" and Y the tid of "Extras")

I want it look like:

/taxonomy/term/Y (where Y is the tid of "Extras")

Current arguments or contextual filters:

The "Section" field getting the Taxonomy term from the URL
The (relationship to "Terms on node")Taxonomy:Term id to create the summary display

I have tried a combination of %2, !2, 2%, 2!, %taxonomy_term, [tid], etc without any luck.

Note: the results of the views are perfect, it is just the URL been overwritten by the summary display.


texts: How to implement variable caching of nodes based on published date in a Drupal 6 website?

texts: I have a Drupal 6 website and I want to write a module that will cache nodes based on the published date. Older nodes would be cached longer than newer nodes.  I plan to use cache_set(), cache_get() and nodeapi hooks to add the node to the cache and check if it is in the cache before loading. However I am not sure if my logic is correct. Can provide any tips to put me on the right track?


texts:
Is there a way to create parent-child entities in Drupal 8?  I'm trying to create a structure where the top entity is for County, and the next level entity is for departments, and next level would be staff.  There will be different counties so the departments created at the second level entity will only be tied to the county it's created for, and same goes for staff which will only be associated to the the 2nd level entity(departments).  So Let's say department 1 on County 1 will have different staff from department 2 of the sane county 1.

Also how will the path for this be programmed?  Where in Drupal or what files should be created or modified so that it will structured like myowndrupalxx.xxx\module\county\1\department\2\staff\1 to display staff information for staff #1 of department 2 of county 1?

Lastly, can the database tables have a key for each table, so let's say for the Staff table being at the 3 level, it will have 3 keys, County, Department, and Staff, vs. the County table will have 1 key County.  This way it does follow the parent-child or relational database structure.

I am not a very skilled programmer in Drupal so please provide your explanations in lay man terms as much as possible.


texts: select2widget: An illegal choice has been detected

texts:
I am trying to use latest select2.js (4.0.1) with drupal select2widget module. As per select2 documentation I have changed the "select2widget_field_widget_form" for "select2widgetajax" option  from "hidden" to "select list" field as follows-

case 'entityreference':
      $options=array();
      foreach ($items as $key => $value) {
          dsm($value);
          $uid = $value['target_id'];
             $user = user_load($uid);
             $user_wrapper = entity_metadata_wrapper('user', $user);
             $options[$uid] = $user_wrapper->field_full_name->value();

         }

    // Check original field configuration
    if (!empty($instance['field_mode']) && !empty($form_state['field'][$field['field_name']][LANGUAGE_NONE]['instance']['widget']['type'])
      && $form_state['field'][$field['field_name']][LANGUAGE_NONE]['instance']['widget']['type'] == 'og_complex') {
      $autocomplete_path .= '?field_mode=' . $instance['field_mode'];
    }

    $default_value = _options_storage_to_form($items, $options, $value_key, $properties);

  $element += array(
    '#type' => 'select',

    '#default_value' => $default_value,
    // Do not display a 'multiple' select box if there is only one option.
    '#multiple' => TRUE  ,
    '#options' =>  $options,
    '#process' => array('select2widget_entity_process_callback', 'ajax_process_form'),
    '#value_key' => $value_key,
    '#settings' => $instance['widget']['settings'],
    '#element_validate' =>  array('select2widget_field_widget_validate'),
    '#properties' => $properties,
     '#autocomplete_path' => $autocomplete_path,
  );
  break;
}

Everything works fine. Select2 is populated perfectly and I can select from the list also. But when I want to save the form it is throughing the    error like:

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

After doing some google I came to know that if we are using a dynamically populated SELECT (dropdown) via AJAX this error will pop up. When a value is not present in options array, Drupal will consider it as illegal. So the user couldn't inject an illegal value into the database.

I've tried this solution as explained here and added:

$element['#validated'] = TRUE;

in my field_widget_form. But no luck.


texts: Using #states API with an image field as a control field

texts:
On a form, is it possible to use #states to hide/show a field based on whether or not an image field has been filled in?

More specifically, I'd like to get this node form:

to only show the "Show featured image" checkbox if an image has been added. If it matters, I'm using the media browser widget for the image field.

I tried using #states, but it doesn't seem to work here. I had the following code in a hook_form_alter function, but adding an image didn't make field_image_show show up.

// Hide the "show featured image" field until a featured image is added.
if (isset($form['field_image_show'])) {
  $langcode = $form['field_image']['#language'];
  $form['field_image_show']['#states'] = array(
    'visible' => array(
      ':input[name="media[field_image_und_0]"]' => array('filled' => true),
    ),
  );
}

If it's not possible with #states, any idea how to handle it with custom JS? I tried the following JS, but it also didn't work.

$field_image_show = $('#edit-field-image-show');

var imageCheck = function() {
  if ($('#edit-field-image-und-0 .preview').is(':empty')) {
    $field_image_show.hide();
  }
  else {
    $field_image_show.show();
  }
}

// Check on initial page load.
imageCheck();

// Check when media browser does stuff.
// @nope This doesn't seem to actually ever fire.
$('#edit-field-image-und-0 input').change(function() {
  imageCheck();
});


texts: form element attribute change doesn't affect submitted data

texts:
I'm trying to change an attribute of form element after it was rendered and delivered to browser, by manually editing html document (in chrome developer). For example:

        $element['username'] = array (
                '#type' => 'textfield',
                '#title' => t('Enter something'),
                '#attributes' => array ( 'some_attr' => array ('1')),
                '#ajax' => array (
                        'callback' => '_ajax_callback',
                        'wrapper' => 'uid_replace_me',
                        'keypress' => TRUE, # to strike callback on enter
                ),
        );

if I change the attribute some_attr in browser manually to something random (actual problem involves attribute change by javascript as part of ajax callback), and trigger callback function as:

_ajax_callback(&$form, &$form_state)

dumping the $form_state still shows that the attribute wasn't changed. I've spent few hours already trying to discover why... : \ Seeking for community help.


texts: Why hook_form_alter implementation is being called twice?

texts:
I have a module where I implemented hook_form_alter:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  krumo($form_id);
}

And I always get each form_id displayed twice. Duplicate form_id for each form!! The problem is that if I add in hook_form_alter line like:

$form['#submit'][] = 'my_submit_function';

then this function is getting called twice, and this follows errors. I have no idea why Drupal calls hook_form_alter implementation twice, possibly you have. Thank you in advance!


texts: How can i send only one time use email link to  for polling and if the user click that link again than he will be redirected to the revise the poll page.Is there any way to do this using contrib module if no any suggestion which is the best approach do it by custom code .I am using Drupal6


texts: How to create an autocomplete textbox in register page - Drupal 6

texts:
Consider I am doing a registration form with the following fields.

1. Name

2. Email

3. City

Here the city should be auto complete.

I created the city field with the help of content profile module in order to add more fields in future.

Now how can i make the "City" text box auto complete.

How can i store the records in the table ?

Thanks in advance...


texts: Disable specific view display in drupal 8 via database or programmatically

texts:
I was modifying a display mode in my view and must have added a criteria which doesn't exist and when I saved my changes, I was immediately thrown to a wsod.  After checking the logs, here is the error that I've found:

Exception: No entity type for field vid on view newsletters in Drupal\views\Plugin\views\HandlerBase->getEntityType() (line 697 of /home/admin/domains/zend8.sitesbycoop.com/public_html/core/modules/views/src/Plugin/views/HandlerBase.php).

Does anyone know of a way to disable this view mode via the database or programmatically so I'm not locked out of my view anymore?

Much appreciated!


texts:
I am using the following code to send emails, but it doesn't work. What is wrong with it?

function yukerja_view_contact_import_form_submit($form, &$form_state){
  global $user;
  $c_user = user_load_by_name($user->name);
  $uid = $c_user->uid;
  $profile = profile2_load_by_user($uid, 'recruiter');
  $field = $profile->field_recruiter_company;
  $tid = $field['und'][0]['tid'];
  $term = taxonomy_term_load($tid);
  $company = $term->name;
  $query = db_select('import_contact');
  $query->fields('import_contact', array('name', 'email', 'company', 'operator_insert', 'status', 'matches'))
    ->condition('company', $company,'=')
    ->orderBy('name', 'ASC');
  $table = $query->execute();
  $a;
  $b;
  $email_user = array();
  foreach ($table as $key => $values) {
    $email_user[$key + 1] = array(
      'name' => $values->name,
      'email' => $values->email,
      'company' => $values->company,
      'operator_insert' => $values->operator_insert,
      'matches' => $values->matches,
    );
  }

  $params = array();
  foreach ($form_state['values']['table_user'] as $key => $value) {
    if(!$value == 0) {
      $email = $email_user[$key]['email'];
      $params = array(
        'name'            => $email_user[$key]['name'],
        'email'           => $email,
        'company'         => $email_user[$key]['company'],
        'operator_insert' => $email_user[$key]['operator_insert'],
        'matches'         => $email_user[$key]['matches'],
        'link_jobklik'    => 'http://dev.yukerja.gotpantheon.com',
        'subject'         => 'Invitation',
        'body'            => 'body tes',
        'from'            => 'as'
      );

      $module = 'yukerja_view_contact';
      $key = 'key';
      $language = language_default();
      $from = $params['operator_insert'] . "@jobklik.com";
      $send = FALSE;
      $message = drupal_mail($module, $key, $email, $language, $params, $from, $send);

      $message['subject'] = $params['subject'];
      $message['body'] = array();
      $message['body'][] = "Invitation";
      $message['body'][] = $params['link_jobklik'];

      // Retrieve the responsible implementation for this message.
      $system = drupal_mail_system($module, $key);

      // Format the message body.
      $message = $system->format($message);

      // Send e-mail.
      $message['result'] = $system->mail($message);
      // drupal_mail('yukerja_view_contact', 'invitation', $email, language_default(), $params, $params['from'], TRUE);

    }
  }
}