texts: Drupal 7.x + Ubercart 3.x + Domain Access

texts:
I have a full working Drupal 7 with Ubercart 3 running fine. It is well configured with thousands of products in it. I would like to create a sub-domain where all the contents and users are the same, but some things (theme, views, ubertcart) are configured differently.
Domain Access module seemed to be the best way to acomplish my goal (it can handle differnt views, settings, themes, etc), but there is no such an option for Ubercart.

So, my problem is that I can not set different configuration on my subdomain for my Ubercart.

My questions are:
 - Is there any way to force Ubercart to use maybe an other db prefix, where Im storing the different settings.
 - Is there any other solution (other module) to my multisite problem?

Any help, tip or suggestion is much appreciated!


texts:
Drupal 8 is supplementing the testing framework based on Simpletest with PHPUnit, and Simpletest could be removed in Drupal 9.

I'm not upgrading yet to Drupal 8, but I was wondering how I can write existing tests in PHPUnit (to follow-up with the trend) for Drupal 7, instead in Simpletest?

Is there any method or module for integrating PHPUnit with Drupal 7?

There are few like phpunit or drunit, but they're not for Drupal 7.


texts: Why is my form themed as table not posting data correctly, or displaying correctly?

texts:
I have created a form in the admin.

$form['things'] = array(
  '#prefix' => '
',
  '#suffix' => '
',
  '#tree' => TRUE,
  '#theme' => 'table',
  '#header' => array(t('Field Label'), t('Field Name'), t('Location'), t('Stuff')),
  '#rows' => array(),
);

I then add each row to it like:

foreach ($type_fields as $field_name => $attrs) {
  $stuff = array(
    '#type' => 'textfield',
    '#default_value' => $attrs['stuff'],
  );

$form['things']['#rows'][] = array(
  array('data' => 'label'),
  array('data' => $field_name),
  array('data' => $field_name),
  array('data' => $stuff),
);

}

The form looks great! But the first problem is the value assigned to #default_value is not showing up in the form.  When I change it to #value the correct value DOES show up. So I wonder how this should be done? The Drupal documentation says #value should not be used with forms although it is functioning exactly how I would expect it to function.

The main problem is when I fill in some test data in one of the textfields and submit it: I do not see any of the submitted values in my _submit function.

Neither $form nor $form_state contains any of the values I input into the text fields.

I wonder if this is because I am rendering #theme => "table"?  Has any one ran into this issue? Any Ideas on changes I can make that would allow me to see the values I am inputting when I post the form to the _submit function?


texts: How do I add a custom CSS file for default theme?

texts:
For example - I have enabled Zircon as my default theme. I want the user menu account to appear on left.
I want to add a custom CSS file where I can write a CSS elements and add to a default theme on site.


texts: How do I include data from the order item type fields in the order receipt email?

texts: I have created an "Event Registration" product type and order item type. In the order item type, I added fields for the registrant's name and job title. How can I print the submitted values for those fields in the commerce-order-receipt.html.twig?


texts: Adding icons from the right or left to menu H2 or Li

texts:
Let's say I want to add Icons from the right\left of a Drupal menu H2 or li (such as in the place in the picture)... Actually I would also like to put a picture as a menu item by itself...

What is a good, veteran, and trusted module you could recommend for achieving all of these targets?

Thanks.


texts:
We are a web development agency. In the past we've developed on Joomla, Wordpress and Drupal however we're becoming more Wordpress focused. We have systems such as InfiniteWP that we use to manage multiple sites with Wordpress installations and keep them up to date. This works really well for us as we can collect maintenance fees from our clients to keep plugins up to date and we can use a single admin login to be able to login to any of our WordPress sites.

I'm looking for a similar system for Drupal and as yet I haven't bee able to find a solution that offers me the same benefits as I can get with the other CMSs. At the moment, it's really only the one thing that's holding us back from dedicating more development resource to Drupal. Can anyone offer advice on a similar solution or how other companies are managing this issue.


texts: How can I select a set of nodes directly linked to a node using views and wikitools

texts:
I'm a newbie with Drupal so I apologize if my question is not presented appropriately, I'll try to be as specific as possible.

So I am developing an academic wiki using Wikitools (gathering academic information such as papers, economic data, etc.). The two types of content I will mention here are (i) Articles - each article presents an academic paper written by one or several authors; and (ii) Authors - a page presenting a particular author/researcher and providing internal and external links related to the researcher (e.g. his website, videos, etc.).

What I would like to do is to select all the Article pages for which a researcher is categorized as an author and display them in the Author page corresponding to that person.

I tried to do that with Views: I created a view, filtered using 'Content type' (i.e. Articles) and 'Links to' as criteria. The view has been integrated into the Author page and links have been established between Article pages and the Author page using Wikitool link format ([[name|name]]).

However, no article pages get displayed in the Author page. I removed the 'Links to' criterion to see what would happen, and all article pages created get displayed. So the view is working correctly but it seems that the links created using the Wikitool format are not recognized as actual links. It's the only explanation I could think of so far, and I could not find any hint in other forums.

So if you guys have any idea, I would really appreciate some help... I'll stay posted to provide additional details if needed.

Thanks a lot for the awesome work you're all doing. I've just discovered Drupal and I still can't believe how innovative and well-designed the whole project is.

Cheers,
Igor


texts: After clicking on the "Remove" button, the entry disappears, but the file is still on the server.


texts: How to make the help text of a content type field collapsible?

texts:
I have built my Drupal 7 tennisclub-site so that a few users can maintain the content in it.

Most of these few are irregular users, that only come to maintain their part of the content a couple of times a year.
For these people it is important that they are led through the steps of lets say... creating a calendar item, using the field-helptext. So there is a helptext for the title, a helptext for the date(s) and a helptext for the body of the content type "calendar-item".

While very usefull to the infrequent user, these helptexts are quickly becomming annoying to regular users.
How do I make the helptexts collapsible and how do I set it's default state?
Which modules do I need for this to work?

Thanks in advance,

Tijs


texts: How to prevent jQuery from loading during ajax callback

texts:
Using Drupal 7's implementation of jQuery and Drupal.behaviors, how can I get some of my jQuery to run only once when the page is initially loaded, and the rest to run when the page is loaded AND during AJAX callbacks.

How can I prevent ajax callbacks from triggering certain parts of my Drupal.behaviors?

(function ($) {
    Drupal.behaviors.fsrevs_user = {
        attach: function (context, settings) {

            //I want to run this only during the first page load.
            jQuery('#edit-message').after('
Do Once
');

            //I want this to run during first load and during each ajax callback.
            jQuery('#edit-message').after('
Do Every Time
');
        }
    }

})(jQuery);


texts: flex slider with unique links and no links

texts:
I have a flex banner that displays images from a content type I have created for the banner. In my banner view I can only link the image to the original image, the banner page or nothing. My goal is to be able to assign links to some of the banners. For example link slide 1 to a basic page, slide 2 to an article and slide 3 to another custom type page. My googling skills seem to let me down here.

I know that you can meet these requirements on different platforms for example on magento you can use 'Magestore_BannerSlider' where for each banner you upload an image, set up the dates to display from X to Y, add a unique link to each banner or if left empty it is not linked.

I am interested if I can get similar functionality using Drupal.


texts: How can I convert first page of a pdf as its thumbnail?

texts:
I'm trying to build a document sharing site so I need to convert first page of each document as its thumbnail in a grid view. I've found some module like PDF-to-ImageField module, but unfortunately it has been released only for Drupal 6.

Now what can I do? is there any Module to convert first page of each document (specially pdf and doc) to a thumbnail for drupal 7? or any other ways?


texts: Don't allow "Delete this field" if a module is activated

texts:
Inside "Article" type, I have a field called 'field_xenforo_thread_id' (machine name), It's possible to disable the "Delete" option only for this field and only if my module is activated please ?

If the module is activated and if the administrator remove this field, the module is broken and I want prevent this problem.


texts:
Are there any 'instant search' modules (similar to Google's instant search) available for Drupal 7?

I found the Drupal 6 modules listed below, but neither of them seems to be available for Drupal 7, yet.

Drupal Instant search
Instant Search


texts: How do I programmatically show a view block?

texts:
I created a view block, whose machine name is "news."

How do I display it using module_invoke() and the machine name of the view?


texts: How to insert multiple tables into their respective backup tables using insert sql?

texts:
For the purpose of backup and restore i want few tables to be just backup  while performing a restore process. I have created backup tables but now whenever i do restore process it shows:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062      Duplicate entry '1' for key 'PRIMARY':

Actually both tables have same schema and same primary key so whenever it try to update it there is conflict.
Can anyone please tell me how to do it ?
One more thing can i use drupal Features to do it and if yes please let me how.


texts:
Having taxonamy term issues - as glossary terms showing with text below the text  saying "There is currently no content classified with this term."

does anyone know how to remove or hide the statement mentioned?

Drupal 7


texts:
Here is my problem: I have 2 SWF files for a crossword puzzle: first one is for creating puzzles and outputting XML files upon clicking the "Save" button and second SWF is displaying those puzzles to the users by listing and loading those XML files and upon clicking it loads the selected XML file into SWF. This is okay so far here. But I need to use web interface so that a user inside a website sees those XML list on the web page and upon clicking/selecting, the second SWF will load with the related XML file. I need this because I will organize those XML files with some modules inside drupal such as Organic Groups. So each user will see different lists of XML files. For example, I have 2 groups created with my organic groups module inside drupal, each group has a different editor. So those editors will create puzzles and will set them for their groups with Organic groups module.

After some research I think I figured a possible and reasonable way to achieve this with a help of a friend. So, to wrap up things so far;

-I have a puzzle maker swf and a puzzle player swf.
-Puzzle maker actually generates some xml files that could be played by Puzzle player(swf).
-These xml files are to be stored in Drupal.
-The stored xml files behaviour is same as Organic groups behaviour. Where the files belonging to a particular group is accessible to the group members.

So the idea of implementation is here,

1.) A custom page for creating puzzle using Puzzle maker(swf). A "Puzzle Data" content-type to hold the xml files. This node is under organic groups.

2.) The editors creates puzzle (things okay so far here) and the xml file will be downloaded to editor's computer.

3.) Now the editor may upload the xml file and attach it to "Puzzle Data" node.

4.) Now I may create a view to display all the "Puzzle Data" nodes in a Organic Group with Views module.

5.) Now comes the tricky part. The actual node display should be a Puzzle Player(swf) that uses the "xml" file uploaded to the node.

After some research I may achieve this either Creating a custom node template or creating a custom field formatter. So here I need a bit help with the php codes part so that each node will post/sent the attached xml file to puzzle player(swf) attached to the node.

(Btw this 2 step: downloading xml and later uploading it to a node is something unwanted, maybe puzzle maker(swf) can be embedded inside node/add path for Puzzle Data content type and editors may download xml so will upload it again into the field on the same page. )


texts:
When I view a node via Services in json or xml format a field I am adding via hook_node_view is unavailable. How could I add the field so it is available also when the node is viewed via Services?
I only seem to be able to access the node via hook_node_load


texts:
I am trying to install
Vote Up/Down module via drush. But even if it is not already installed and it has been downloaded, it is not being installed.

[root@localhost custom]# drush dl vote_up_down
Install location /var/www/html/d7/sites/all/modules/contrib/vote_up_down already exists. Do you want to overwrite it? (y/n): y
Project vote_up_down (7.x-1.0-alpha1) downloaded to /var/www/html/d7/sites/all/modules/contrib/vote_up_down.                [success]
Project vote_up_down contains 5 modules: vud_term, vud_field, vud_node, vud_comment, vud.
[root@localhost custom]# drush en vote_up_down
vote_up_down was not found and will not be enabled.                                                                         [warning]
There were no extensions that could be enabled.                                                                             [ok]
[root@localhost custom]#

Can anybody help me with this?


texts: Drupal Commerce product sale price using Rules

texts:
I tried Rules like explained here enter link description here. It works but when it comes to checkout, order total amount displays 0. I've got no clue why. Here is my rule:

{ "rules_sale_price" : {
    "LABEL" : "\u0426\u0435\u043d\u0430 \u0441\u043e \u0441\u043a\u0438\u0434\u043a\u043e\u0439",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "sale price" ],
    "REQUIRES" : [ "rules", "commerce_product_reference" ],
    "ON" : { "commerce_product_calculate_sell_price" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } },
      { "entity_has_field" : {
          "entity" : [ "commerce-line-item:commerce-product" ],
          "field" : "field_produkt_sale_price"
        }
      },
      { "NOT data_is_empty" : { "data" : [ "commerce-line-item:commerce-product:field-produkt-sale-price" ] } }
    ],
    "DO" : [
      { "data_set" : {
          "data" : [ "commerce-line-item:commerce-unit-price" ],
          "value" : [ "commerce-line-item:commerce-product:field-produkt-sale-price" ]
        }
      }
    ]
  }
}


texts: Separate statistics on sites from Domain Access

texts: Is it possible to separate statistics (like number of views) on shared node on few sites while using Domain Access module, so the same node can be viewed like 50 times on site1 and like 80 times on site2, etc.?


texts: Unable to get my ContentEntity base field definition to appear as checkboxes

texts:
I am trying to implement a base field with multiple selections as checkboxes I have had a go at implementing it but it stills appears as a select even after clearing the cache. I'm sure I'm doing this wrong but this is what I have:

$fields['content_display'] = BaseFieldDefinition::create('list_integer')
  ->setDisplayOptions('form', array(
    'type' => 'checkboxes',
    'weight' => -4,
  ))
  ->setSetting('allowed_values', $values)
  ->setDisplayConfigurable('form', TRUE);


texts:
I'm trying to do an ajax callback on page every load with drupal to get some info. The problem is that when the ajax callback is done and the data processed, Drupal continues calling the ajax function once and over again adding the typical "Please wait..." text repeatedly.

The javascript:

(function($){

  Drupal.behaviors.myModule = {
    attach: function () {
      var settings = {};
      settings.url = '/my_module_ajax_callback';
      settings.event = 'onload';
      settings.keypress = false;
      settings.prevent = false;

      var base = 'myModule';
      var ajax = new Drupal.ajax(null, $(document.body), settings);
      Drupal.ajax[base] = ajax;

      $(ajax.element).trigger('onload');
    }
  }

})(jQuery);

The php:

<?php

function my_module_init() {
  drupal_add_library('system', 'drupal.ajax');
}

function my_module_menu() {
  $items['my_module_ajax_callback'] = array(
    'page callback' => 'my_module_ajax_callback',
    'access callback' => 'user_access',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function my_module_block_info() {
  $blocks['my_module_block'] = array(
    'info' => t('My Module Block'),
  );
  return $blocks;
}

function my_module_block_view() {
  $block = array();

  $block['content'] = '
This data must be replaced by ajax
';

  return $block;
}

function my_module_ajax_callback() {

  $commands[] = ajax_command_replace('#my_div', '
This data has been replaced by ajax
');

  $page = array('#type' => 'ajax', '#commands' => $commands);

  ajax_deliver($page);
}

Seems the ajax callback is never complete.

In misc/ajax.js:

complete: function (response, status) {
  ajax.ajaxing = false;
  if (status == 'error' || status == 'parsererror') {
    return ajax.error(response, ajax.url);
  }
},

I don't know what I'm doing wrong. I really appreciate your help. Thanks.


texts:
Im using the 2.0 version of Entityform. I have 236 fields. When I rearrange the fields in Manage Display and click save nothing happens. When I click a gear to edit a frameset it says "please wait" then nothing happens.

Thoughts?

EDIT: I wanted to mention that I'm not getting any PHP errors.


texts: How to filter content in views based on user id

texts: Is there a way to for a normal user (without admin power) to set permissions for a specific piece of content (not a content type) so that it is only visible to a specific user? I want it so that said specific user can see content that has been specifically assigned to them in a table in a view.


texts:
I have a taxonomy term page that lists certain nodes. I would like to include custom sort options like the one on amazon's search results page, at the top. It is a drop down with sort options, unlike the usual clicking on a table column. I have searched but found no resources on implementing this in drupal. Any ideas on how I can implement this?
Thx


texts: How to prevent CKEditor trim plain text in source view

texts:
I'm using Drupal 8,

In source view when I paste some plain text like this:

Hello sir.

Hello  sir.

And submit node form, without toggling back to rich-text mode, text above is removed.

If I toggle back in rich-text mode before submitting, CKEditor automatically wraps my text in p tag, like this:

Hello sir.

Hello sir.

Hello sir.

Hello sir.

So is it possible to make CKEditor wrap plain text in p without toggling back to rich-text view?

I have tried several things and failed in all of them, I have written custom CKEditor plugin which listens to submit button click and execute this editor.execCommand( 'source' ); but it isn't working, somehow data is submitted before I switch to rich-text mode.

Is there any solution to this?


texts:
CKeditor strips the <i> tags, and I can't find where in config.js I can put this code.

CKEDITOR.dtd.$removeEmpty['i'] = false

This is a solution for Drupal 7 and the CKEditor module.


texts: Migrate D6 ImageField Extended captions to D7 File Entity Inline captions

texts:
First of all, I am completely new to the Drupal world and my apologies if I fail at clearly explaining my issue, or if I am missing something that should be obvious.

I "inherited" a D6 website just as D6 reached end of life, and decided to migrate it to D7 (fun little introduction to Drupal, right?).

My main issue after days of tinkering is that I want to use image captions that were originally created thanks to the ImageField Extended module (v. 6.x-4.2), which was replaced in D7 by the File Entity Inline module (v. 7.x-1.0-beta1).

The original D6 captions were saved into a table called content_field_figure along with other information in the form a:3:{s:5:"title";s:10:"Figure 5.4";s:7:"caption";a:3:{s:4:"body";s:383:"This is the caption text";s:6:"format";s:1:"1";s:5:"style";s:9:"formatted";}s:3:"alt";s:0:"";}, whereas the new caption field created with File Entity Inline saves the data in a table called field_data_field_caption, on its own, under field_caption_value.

In my formatters, the original captions were called via the [imagefield-extended-caption] token in D6, whereas the new ones (created with the custom "caption" field created with File Entity Inline) are called with the [file:field_caption] token.

I would love to be able to merge the existing D6 caption data into where File Entity Inline stores the new caption data, so I can use both the original captions and the newly created ones with the same [file:field_caption] token, and also edit them in the multi-line text editor that I have set up in my figure field.

How would I go about it?


texts: Overwrite taxonomy/term page with custom view isn't working

texts:
I'm trying to style my taxonomy/term page and as it turns out, a lot of people are trying to do this. Internet is filled with tutorials and how-to-guides, but for some reason, it seems I'm doomed and not able to do so.

I've installed the Taxonomy Display module and I think my settings are all good:

And my view is configured with the taxonomy arguments:

But still, the products/tents (aka taxonomy/3) doesn't take the View style I've configured... What am I overlooking here?

When I take a look at my live preview of my view, it seems everything is right. Only something looks overwritten on my website because there it doesn't take over the Views layout.


texts: How to implement jquery fullcalendar library in my custom drupal 7 module?

texts:
I am going to implement the 'Full Calendar' JQuery library in my custom drupal module, and event data fetching from url as JSON formate, but design becomes hazy, this is my 'template code'.

NOTE: All the jquery and css files are loaded successfully.

<?php global $base_path;?>

<link href="<?php echo ( $base_path.drupal_get_path ( 'module', 'sogh_full_schedules' ) . '/css/fullcalendar.css' ); ?>" />

<link href="<?php echo ( $base_path.drupal_get_path ( 'module', 'sogh_full_schedules' ) . '/css/fullcalendar.print.css' ); ?>" />

<?php
/* $today_schedules = array();
$today_schedule_list = ($form ['full_schedules'] ['#value']); */
?>

    php/get-events.php must be running.

loading...


texts:
I have a bit more complicated problem here, so I'll describe the background first.

In my Drupal 7 site, there are two content types: the 'car' and the 'inspection'. The only two important things about them is that the 'inspection' includes 'Date' field and that 'car' and 'inspection' are linked using Node References module (there's Node Reference Field named 'Car' in 'Inspection').

Now, here's my problem. I need to create a view that shows only the cars that haven't been on inspection in last two years which means that they have no 'inspection' with date > two years ago referencing them.

I'm able to achieve that if there's only one or none inspection referencing the car. In that case, I simply use 'Filter Criteria' on Date property of Nodes referencing this car (using relationships) and it works just fine.

However, if there are more 'inspections', the filter takes every single one and list the car whenever there's at least one with date < 2 years ago (even if there's another one newer).

What I need is to somehow create a filter that would consider all 'inspection' nodes that are referencing the 'car' and shows the car only if there was none that would be newer than 2 years ago.

I hope it is clear.

//I have one more smaller problem that is (probably) connected with this one. I need to show the date of the newest inspection of a car in a  view of cars. The view, however, always shows the oldest one (Table->Fields-> Date field of 'inspection'-> Nodes referencing this one 'car').

//BTW: If you don't understand the problem I have because of my level of English, please tell me. I'll try to rewrite it in a simpler way.


texts: Export and Import Taxonomies and Extra Fields

texts:
I created extra field in Login Form, I Installed even Extra Module (address) and create Taxonomies

Now I want to Export these configurations to another Drupal. This Drupal is the Clone of the main Drupal.

I Tried to use import/export Configuration (admin/config/development) But I have several error during import ( shortcut and error Ajax 500 )

I don't have active and staging folder (link)

Is it correct to use Conguration Management to export Module and Taxonomies?


texts: What are the advantages of running NoSQL (ex MongoDB) over MySQL, PostGRE SQL or MSSQL in Drupal? Are the advantages gained from simply using the storage or does some Drupal configuration need to change?


texts: Taxonomy vs. CCK List for categorizing Events

texts:
Could someone let me know what the best practice is for choosing between implementing something as a Taxonomy vs. a List field in the Content Type?  Assuming that there is a preset list of values and there is no need for content creators to create their own.

For example, a Content Type of an "event" could be categorized based on audience or type.  Audiences can be [Kids, Youth, Adults, Seniors, etc.].  Similarly, type would have a preset list as well.

Should audience or type be created as Taxonomy or a List field in the Content Type?


texts: Count items in nested field array for if/then in template

texts:
I'm sure I'm missing something very straightforward here:  I want to prevent the thumbnail slider in my image gallery from being rendered if there's only one image for the node. My first thought was, optimistically:

  <?php if (count($content['field_media']) > 1): ?>

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

  <?php endif; ?>

I saw why that didn't work when I examined the node structure. In an example case for a node with one image, I have

 field_media (Array, 1 element)
    und (Array, 1 element)
        0 (Array, 17 elements)

the last one being the actual file element with an fid, etc. The corresponding field for a node with two images is

 field_media (Array, 1 element)
    und (Array, 2 elements)
        0 (Array, 17 elements)
        1 (Array, 17 elements)

So the array I need to count is nested inside the 'und' array. I know I've used that in other templates, like $field_external_link['und'][0]['url'].  But when I print count($content['field_media']['und']), I get 0.  How do I evaluate the number of elements in that array?


texts: Webform doesn't send hidden input if sender is not logged-in

texts:
I have a webform which works fine only it is submitted for logged in users.

The problem is that the webform includes a hidden input. When I receive the email (sent by the webform) I can see all the values for the inputs, but the hidden input value is missing.

This does not happens if the webform is submitted for a logged in user.

Is this something related to permissions?

thanks


texts: What is required for a view menu item to show up as a link in the admin page?

texts:
I'm creating several views that are to be used as reports. Since they all have a common topic, I'm grouping the views under a sub-path of admin/reports (e.g. admin/reports/data/needs_correction and admin/reports/data/status).

With most admin sections in Drupal, there's usually a landing page that lists all of the sub-content for the section. So, to provide that, I've implemented hook_menu() in the feature that contains the exported report views, as follows:

/**
 * Implements hook_menu().
 */
function MY_menu() {
  $items = array();

  $items['admin/reports/data'] = array(
    'title'             => 'Data reports',
    'description'       => 'Various reports on the status of data in the system.',
    'position'          => 'left',
    'page callback'     => 'system_admin_menu_block_page',
    'access arguments'  => array('access administration pages'),
    'file'              => 'system.admin.inc',
    'file path'         => drupal_get_path('module', 'system'),
  );

  return $items;
}

The only problem is that, after a cache clear, when I navigate to admin/reports/data, all I get is the message "You do not have any administrative items."


texts:
I have a webform (survey) on my site, some of the fields are personal details (age, name, DOB, etc). I want to actually force the user to login with facebook and pro grammatically obtain those few details from facebook.

Which module(s) would I be most interested in, in achieving?


texts: Is there a way to implement drag and drop for image upload in drupal 7

texts:
I amn looking for a way to inplement drag and drop image upload for  the profile image field and serveral other image fields as well for drupal 7 is there a module that is easy to use or an easy way to implement uploading per drag and drop in template.php?

Thank you!


texts: Computed field that displays the full username of the author

texts:
I am using a computed field and I want to display the field_first_name and field_last_name, which are properties of the user that created that node.

I have been trying things, but it seems like $entity does not have a uid?

I have no idea how to get load the user. These are the variables I have:

  The variables available to your code include: &$entity_field,
  $entity_type, $entity, $field, $instance, $langcode, and $items. To
  set the value of the field, set $entity_field[0]['value']. For
  multi-value computed fields continue with $entity_field[1]['value'].
  Here's a simple example which sets the computed field's value to the
  value of the sum of the number fields (field_a and field_b) in a node
  entity: $entity_field[0]['value'] =
  array_pop(array_pop(field_get_items($entity_type, $entity,
  'field_a'))) + array_pop(array_pop(field_get_items($entity_type,
  $entity, 'field_b'))); The first pop fetches the last (or only) item
  from the field while the second pop fetches its ['value'] contents
  (assuming it's the only key that's set).


texts: How to fix AJAX HTTP request which was terminated abnormally?

texts:
I keep getting this AJAX error message every time when I add taxonomy terms or open view pages with AJAX, to name a few.

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /system/ajax
StatusText: error
ResponseText:
ReadyState: 4

Any suggestions to how I can resolve the problem? I'm using the dev desktop.


texts: Form element with type = value odd behaviour

texts:
I have 2 forms on the site, each of them has an array, that I want to store inside the form to use in form_submit function:

$form['store'] = array(
  '#type' => 'value',
  '#value' => $fields
);

But in one form_submit function this works:

$fields = $form_state['values']['store'];
unset($form_state['values']['store']);

In another one it doesn't work, giving an error:

  Notice: Undefined index: store in scores_search_form_submit

While this code works:

$fields = $form_state["complete form"]["store"]["#value"];
unset($form_state["complete form"]["store"]);

Why does this happen?


texts: How can I indicate "NEW" content in faq module after updating an entry?

texts:
I use the faq module in Drupal 7.

After I update an entry, I want to display a visual indicator (e.g. "NEW!) if the node has been changed/updated recently.

if I don't use views module.


texts: How to expose an entity reference field as a filter on a custom entity in Views?

texts:
I have a field on a custom entity that is an entity reference to a node. However when I select this field as a filter and expose it, it just acts like a numeric field instead of a reference field (only option is less than, greater than, equal to... etc).

How can I make this field act properly? I just want a drop down of options (only 32 nodes ever) to make filtering easy.


texts: "Hide if empty" does not work in Views if 'Show prefix and suffix' is enabled

texts:
I have a price field that I need to hide if the value is 0. As I want to use :- as a suffix I turn on "Show prefix and suffix". Unfortunately this makes the field visible again. In my different views I have managed to hide the field anyway with this snippet in hook_views_pre_render(&$view):

foreach($view->result as $val){
    if(isset($val->field_field_pris[0]['raw']['value'])){
        if($val->field_field_pris[0]['raw']['value'] == '0'){
            $val->field_field_pris[0]['rendered']['#access'] = FALSE;
        }
    }
}

But in my search result page (I use the Search API module), this does not work. For some reason I have no access to the fields in the variable $view->result. So how can I hide a field in the search result view if the field value is zero, and still use the prefix & suffix?

EDITED: Ok, so I created a field template file as suggested and replaced the <?php print $output ?> line with this code:

<?php
if($output) {
  $pris = $row->_field_data['field_pris_tillbehor']['entity']->field_pris_tillbehor['und'][0]['value'];
  dsm($pris);
  if($pris == 0){
    dsm($row);
    hide($row->_field_data['field_pris_tillbehor']['entity']->field_pris_tillbehor);
    print $output;
  }
}?>

... but even though the zero value is confirmed by the dsm statement, the value still appears in the search page view.


texts:
I recently moved a project from one server to another. the server is running on nginx.

I noticed some issues like that I cant upload any picture to ckeditor using imce module (I can upload images via filefield) then while trying to fix this issue I encountered this problem that I cant enable or disable any module.

It's like when I check/uncheck a module and hit submit on module's list page, it refreshes but nothing change afterwards.

the other thing is Im running another website on this server with the same version of drupal and it just works fine, I wonder what could be wrong? is it a server issue or a drupal problem?

I'd really appreciate any help and tips.


texts: How to save form data after hook form alter?

texts:
I'm trying to hook into the Social Content module to add taxonomy tags. I've got the fields showing up where they are supposed to, but I don't understand how to actually save the field data.

Here's my hook form alter:

function upup_taxonomy_form_alter(&$form, &$form_state, $form_id){
  // target a single form
  if($form_id == "social_content_form"){
    $form['client_taxonomy'] = array(
        '#type' => 'textfield',
        '#title' => t('Up&Up Client'),
        '#maxlength' => 160,
        '#autocomplete_path' =>'taxonomy/autocomplete/field_up_up_client',
        '#default_value' => '',
        '#weight' => -1,
        '#description' => 'Enter a client name.'
      );
    $form['contact_taxonomy'] = array(
        '#type' => 'textfield',
        '#title' => t('Up&Up Contact'),
        '#maxlength' => 160,
        '#autocomplete_path' =>'taxonomy/autocomplete/field_up_up_contact',
        '#default_value' => '',
        //'#weight' => 0,
        '#description' => 'Enter a contact name. This is optional.'
      );
    $form['#submit'][] = 'upup_taxonomy_form_submit';
  }
  return $form;
}

Now i have function for upup_taxonomy_form_submit, but I don't know what's supposed to go inside there. I want to save the taxonomy id in this field.

function upup_taxonomy_form_submit(&$form, &$form_state){
    //what goes in here?
}


texts: hook node access drupal 7, not working when the node is updated

texts:
I have created a module using the following code.

<?php
global $user;

if (in_array('contributor', array_values($user->roles))) {
    function publishEntities_node_access($node, $op, $account) {
        if (in_array('article', node_permissions_get_configured_types())) {
            if($node->status==0) {
                if ($op == 'update') {
                    if ($account->uid == $node->uid) {
                        return NODE_ACCESS_ALLOW;
                    }
                }
                if ($op == 'delete') {
                    if ($account->uid == $node->uid) {
                        return NODE_ACCESS_ALLOW;
                    }
                }
            }
            elseif($node->status==1) {
                if ($op == 'update') {
                    if ($account->uid == $node->uid) {
                        return NODE_ACCESS_DENY;
                    }
                }
                if ($op == 'delete') {
                    if ($account->uid == $node->uid) {
                        return NODE_ACCESS_DENY;
                    }
                }
            }
        }

        if (in_array('events', node_permissions_get_configured_types())) {
            if($node->status==0) {
                if ($op == 'update') {
                    if ($account->uid == $node->uid) {
                        return NODE_ACCESS_ALLOW;
                    }
                }
                if ($op == 'delete') {
                    if ($account->uid == $node->uid) {
                        return NODE_ACCESS_ALLOW;
                    }
                }
            }
            elseif($node->status==1) {
                if ($op == 'update') {
                    if ($account->uid == $node->uid) {
                        return NODE_ACCESS_DENY;
                    }
                }
                if ($op == 'delete') {
                    if ($account->uid == $node->uid) {
                        return NODE_ACCESS_DENY;
                    }
                }
            }
        }
    }
}

The module does not work after the node is being updated.

Can anybody help me to make this module work as expected?


texts:
I have several rows with elements and I created the delete operation for each row. When I clicked the delete link, nothing happens (it seems that don't calling the delete function).

Code of the menu item (delete function):

$items['node/%webform_menu/webform-factors/factors/%factor_component/delete'] = array(
  'page callback' => 'drupal_get_form',
  'page arguments' => array('forms_grade_factors_delete_factor', 1, 4),
  'access callback' => 'user_access',
  'access arguments' => array('access administration pages'),
  'type' => MENU_LOCAL_TASK,
);

Code of the deletion function:

function forms_grade_factors_delete_factor($form_state, $node, $component) {
    $form = array();
    $form['node'] = array(
      '#type' => 'value',
      '#value' => $node,
    );
    $form['component'] = array(
      '#type' => 'value',
      '#value' => $component,
    );
    $question = t('Are you sure you want to delete this component?');
    $description = t('Description');
    return confirm_form($form, $question, 'node/'.$node.'/webform/components');
}

Code of the table (with the deletion links):

foreach($all_factors as $factor) {
  $delete_link = l(t('Delete'), '/node/'.$nid.'/webform-factors/factors/'.$factor->fid.'/delete',
                                  array('query' => drupal_get_destination()));
  $factors[] = array($factor->factor_name, $factor->factor_formula, $delete_link);
}
$form['factors'] = array(
  '#tree' => TRUE,
  '#theme' => 'table',
  '#header' => array(t('Factor'), t('Formula'), t('Operations')),
  '#rows' => $factors,
);

Thanks for your help! :)


texts:
I created a foundation sub-theme and am now customizing my site.  I am confused as to where to edit styles sometimes.  For example there are these styles are generated somewhere which I can't find where.  If I wanted to change the padding and line-height, what is the correct way of going about this?

@media only screen and (min-width: 40.063em)
.top-bar-section li:not(.has-form) a:not(.button), #topbar-forms li:not(.has-form) a:not(.button) {
    padding: 0 0.5208333333rem;
    line-height: 1.5625rem;
    background: #FFFFFF;
}


texts: What is the best practice for having a global collection or set number?

texts: I am setting up a content type for a collection of samples. There is already a lot of samples that have a collection number that can't be changed, so I will have to import that data. But My question is how to apply this number; I know its a broad question, but would using taxonomy, or a field in the content type be better?


texts: How can I allow users to edit CSS in a WYSIWYG editor

texts: Is there a way to give the administrator of a site the ability to edit and save CSS files in a wysiwyg editor? I thought perhaps the CSS could be node therefor allowing for some type of versioning and reversion.


texts: Webform image select element is dispalying another image while used in webform handler

texts:
In drupal 8,

I have created a custom webform handler to create a new article node and copy the data and images from the webform element
to the created article node.

In both artcle node and contact webform, i have created the required fields/elements.

Article node fields:

Contact webform element:

Now, after submitting the contact webform:

everything goes as expected and a new Article node is created with all fields filled in with data/images.

However, only the Webform element image select is displaying another image instead of the one selected
while submitting the webform.

Below is the created article:

As you can see, the webform element image has been properly populated  but the problem is within the webform element image select !!!

I am sure that my custom code is fine as all other fields are populated correctly.

Any idea/help why the picture is being replaced by another one ??!!

Below is my custom handler code:

<?php

namespace Drupal\my_module_name\Plugin\WebformHandler;

use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Serialization\Yaml;
use Drupal\Core\Form\FormStateInterface;

use Drupal\node\Entity\Node;

use Drupal\webform\WebformInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\webformSubmissionInterface;
use Drupal\webform\Entity\WebformSubmission;

/**
 * Create a new node entity from a webform submission.
 *
 * @WebformHandler(
 *   id = "Create a node",
 *   label = @Translation("Create a node"),
 *   category = @Translation("Entity Creation"),
 *   description = @Translation("Creates a new node from Webform Submissions."),
 *   cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_UNLIMITED,
 *   results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 *   submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_REQUIRED,
 * )
 */

class ExampleWebformHandler extends WebformHandlerBase {

  /**
   * {@inheritdoc}
   */

  // Create node object from webform-submission.

  // Function to be fired while submitting the Webform.
  public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
    // Get an array of the values from the submission.
    $values = $webform_submission->getData();

    // Before you actually save the node, make sure you get what you
    // want. So at first comment the line further down with
    // $node->save(), run the debug code, check the output and then
    // uncomment the $node->save() and delete the debug foreach loop.
    // You can use whatever debug method you prefer, this is just a
    // simple one-time example.
     foreach($values as $key=>$value) {
       drupal_set_message($key . ' -> ' . $value);
     }

    // This is the node creating/saving part.
      $node = Node::create([
     'type'        => 'article',
    // Use this format: 'node_machine_name_field' => $values('webform_machine_name_field') for below fields.
      'title' => $values['subject'],
      'body' => $values['message'],
      'field_image' => $values['picture'],
      'field_picture_select' => $values['picture_select'],
    // etc...
     ]);

    // Before you un-comment this line, make sure you get all the
    // values you need from the webform data (in the foreach loop).
    $node->save();
  }
}


texts:
I want to strip all the javascript from a website.
Only have the libraries available when I need em on a page.

After a fresh install, with using bootstrap theme, I already have 50+ script tags including javascript files on the frontpage. https://www.pastery.net/hgxhsn

I know in d8 you can attach JS libraries to a render array, but it seems even when nothing is attached and no requirements are needed it blasts JS.

How could i strip and have only those attachments define requirements?


texts: Rule to send mail to the users about the percentage of their profile completed(single & multiple profiles)

texts:
I am trying to write a rule to send an email to the user if his/her one of the profiles is not completed. But I am not getting how to get the empty field's list to sent to the user. What actually i wanted to do is. List all the fields which are empty from profile (Single & multiple) and sent the list to the user, requesting to fill all the details or just percentage of profile completion . Please help me to sort out this problem.

Thanks for your time,


texts: Node paths with custom prefix based on taxonomy

texts:
I have a "category" field attached to the "article" content type that is a taxonomy term reference. I want to setup path auto to create a path wich is prefixed based on the category. My problem is that i.e.: I have a category called "Interesting facts", path auto will create a path /interesting-facts/node-title but I want to have /facts/node-title And I could change the taxonomy term to "Facts", but the taxonomy term index page would show "Facts" too, but I want it to remain "Interesting facts".

So basically I want to customize prefixes, without changing the taxonomy terms. Is that possible?


texts: Feeds import creating more nodes instead of replacing or updating - Drupal 7

texts: I have Feeds module, but even if I use the correct "guid" and it appears in feeds_item database table, and I configured it to "Update" (also tried "Replace") existing nodes, and "Delete" non-existing nodes, it will create more nodes, so my database is getting higher and higher Nid numbers. I am using Feeds Tamper submodule. What can be wrong?


texts: How do I make a block appear in a panels display based on the state of a field

texts:
I have a field that is a single on/off checkbox. Whenever it has been selected it outputs a key of 1 into the panel display, if it hasn't it outputs a 0. I want it to output custom html for a link to another page if it's a 1 and I want it to become disabled/hidden if it's 0. The resulting block/field/html needs to be inputted into a panels display, just like the key currently does.

As of right now, I'm using jquery to do this for me, but it seems like there HAS to be a way to do this with drupal. I've looked into  conditional_fields and field_conditional_state but they seemed to be more focused on entering conditional information and not on only making conditional outputs. I'm currently looking into minipanels, panel pages, and context right now to figure this out, but haven't found an easy way of doing it and it feels like I'm overthinking it.

I know that there's a States API that handles this kind of thing, but there's surprisingly little information that I've been able to find on how to apply it to displays. Any help here would be greatly appreciated.

Thanks,
Cole


texts: I'm trying to restyle the status messages block, and I just can't figure out how to do it.  I ought to be able to -- it's just defining a theme function, right? :) -- but it's just not happening for me.  I'm not sure if I'm not defining the function properly, or not registering it properly in hook_theme, or even if I need to register it in hook_theme.  Arggh -- can anybody out there clarify this for me?  Thanks very much!


texts: Adding a webform to a different content type

texts:
I have an "event" content type.  Now I want to add a Webform to it so that people can request purchasing and availability information.

I checked my event content type in admin/config/content/webform under Webform-enabled content types but how can I now add the form to my existing content?


texts:
I want to use as much as I can from http://twitter.github.com/bootstrap/base-css.html#forms for my theme, and as part of this I really want to get rid of the <div class="form-item"> that is being wrapped around each <input> element.

As far as I can tell the only way to do this is by copying the entire http://api.drupal.org/api/drupal/includes!form.inc/function/theme_form_element/7 theme_form_element() function and remove the code that produces the <div> wrapper.

Is this really the only way?


texts: How to make content translation available for front page?

texts:
On my front page I have a language selector (English / French). The default language is French. The translation works only in the content of page (in the views) i want make the translation work in the front page.

Can someone help me please to do this? I have tried several times but could not get it to work ...


texts: How can I change the Cardinality of a field which has previous data present?

texts: I want to change the Cardinality of a field which has existed values in drupal 8.


texts: Drupal 6 will not use updated htaccess 301 information

texts:
I'm not 100% sure that this is a Drupal problem, but I think there is any issue with my site not flushing the cache. I am trying to change a redirect. I was having some trouble with URL Redirect in the CMS, so I am using the .htaccess file directly. Previously I had set up

redirect 301 /renew https://OLDREDIRECT.com

I just changed that to

redirect 301 /renew https://NEWREDIRECT.com

However, no matter what I do, the site keeps redirecting to the old link.

I have flushed the cache in Drupal, I've flushed my own browser cache, and I even tried running cron, but it will not use the new redirect info in .htaccess.

Does anyone have any idea what might be going on?

Thank you.


texts: Completing the checkout process event isn't firing

texts:
I have a Drupal Commerce 7 installation which isn't firing the Completing the checkout process event.

Steps I've tried:

I've rebuilt Rule's cache
I've rechecked the integrity of the rules
I've set "Log debug information to the system log" (Log all warnings and errors)
I've disabled all of the rules bound to the event "Completing the checkout process"
I've created a new rule, which will only send an email.

However, the e-mail is never sent and I don't see the rule being written on the log.

I've tried to submit correctly the order in the storefront (with a "normal" user and with an Admin user).

I've tried to use different types of payment.

I've tried to change the order status to "Checkout complete" in the Backoffice.

What else I'm missing? What's making this event not firing?

Based on others posts, I've checked the rules for other events and realized there's a rule "Commerce order message: changing status", for the event "After updating an existing commerce order". It has the following actions:
Creates new entity Message Type Commerce Order: state change of the order
Set a data value message:message-commerce-order = commerce-order
Set a data value message:arguments:order-status = [commerce-order:status-title]
Set a data value message:arguments:order-status-previous = [commerce-order-unchanged:status-title]

However, this doesn't seem to be responsible for the event never firing, or is it?

Can anybody help me and shed some light on this?

This is the Rules debug information I get, after changing the Order status to Complete, directly on the Backoffice:

Rules debug information:
" Reacting on event After updating an existing commerce order.

0 ms Reacting on event After updating an existing commerce order.
11.574 ms Evaluating conditions of rule Delete shipping line items on shopping cart updates. [edit]
13.432 ms The condition data_is evaluated to FALSE [edit]
13.442 ms AND evaluated to FALSE.
13.546 ms Evaluating conditions of rule Commerce order message: changing status. [edit]
14.047 ms The condition data_is evaluated to FALSE [edit]
14.057 ms AND evaluated to TRUE.
" Rule Commerce order message: changing status fires. [edit]
    0 ms Rule Commerce order message: changing status fires.
    6.493 ms Evaluating the action entity_create. [edit]
    7.441 ms Added the provided variable message of type message [edit]
    9.105 ms Evaluating the action data_set. [edit]
    24.349 ms Evaluating the action data_set. [edit]
    26.206 ms Evaluating the action data_set. [edit]
    26.454 ms Rule Commerce order message: changing status has fired.
40.578 ms Saved message of type message.
46.594 ms Finished reacting on event After updating an existing commerce order.

Still no information regarding the firing of "Completing the checkout process" event...


texts:
I'm running some really long batch process. So in case user navigates away from the batch progress page, I'd like to be able to give him a link that leads back to that page. How can I get the batch ID needed for the batch processing page?

Knowing that batch processing url is something like http://example.com/batch?op=start&id=183 so in theory I could look for the $_GET['id'] inside my batch process function and store that in a session variable but it seems really ugly. Yet I didn't find any way to get the id of the batch that I just started.

It would be really nice if batch_set() would return batch id or would just add it to the batch definition array.


texts:
I appear to be getting quite heavily crawled by robots that are seeing urls like

?q=node/668

1) how are robot's able to find these urls?

The robots are referring too are not google or popular search engines. Are there anyway apart from robots.txt to defend against these. The amount of traffic i'm getting is quite intense.

I'm using drupal 7


texts: How to display search results in admin theme?

texts: I want to start using the search function in my admin area. I googled quite a lot, but i couldn't find away to display the search results in the admin theme. Anyone any idea's how to accomplish this?


texts: Term taxonomy child from first and second level menu

texts:
I have a drupal commerce with taxonomy which have child.The menu was generate automatically.
Exemple:

Vehicle
      |-->4 wheel
                |-->car
                |-->bus
      |-->2 wheel
                |-->motorbike
                |-->bicycle

I want to display a link "4 wheel" and a "link 2 wheel" when we are on the "Vehicle" page (which don't have product inside)
And I want to display "motorbike" and "bicycle" when we are on the "2 wheel" page (which don't have product inside).

I have a drupal commerce default content display and the default views product_category.
I found this video which make me make a new view call catalog which does exactly what I want (video at 15:18). https://www.youtube.com/watch?v=y1jqu8JnLbU
But the main menu (automatically generated) still going to product_category. So now if I want a can make a menu and add every link by my hands but I don't like bad work.

So my question is how can I say to drupal commerce: "Hey now stop using the default view which is call product_category and use my view which is call catalog.
Or
How can I configure the product_category view to display all the child taxonomy like I explain.

I found many stuff but nothing very helpful
https://drupal.stackexchange.com/questions/5732/is-there-a-good-tutorial-for-entity-views-attach-module
The path module
The PHP filter with code
Try to make a block this context filter and display it ...

If someone can help It will be nice !


texts: Can I switch the download mechanism from HTTP GET to HTTP CONNECT?

texts:
I am on Drupal 7.72 and my Drupal instance is behind a HTTP proxy, so have I defined the proxy variables in sites/default/settings.php.
$conf['proxy_server'] = 'firewall.mydomain';
$conf['proxy_port'] = 8080;

Fetching update information works, but installing the updates from Home » Administration » Reports » Available updates fails with this error.

HTTP error 301 occurred when trying to fetch https://ftp.drupal.org/files/projects/ckeditor-7.x-1.19.tar.gz.
Downloading updates failed:
Failed to download ckeditor from https://ftp.drupal.org/files/projects/ckeditor-7.x-1.19.tar.gz

Unfortunately, I can not find anything in the logs at admin/reports/dblog.
When I do a tcpdump on the requesting machine when starting the Drupal update process, I see the following packets.

09:11:48.854809 IP drupal.51397 > firewall.mydomain.http-alt: Flags [P.], seq 1:158, ack 1, win 29200, options [nop,nop,TS val 14715265 ecr 527844548], length 157: HTTP: GET https://ftp-origin.drupal.org/files/projects/ckeditor-7.x-1.19.tar.gz HTTP/1.0
09:11:48.855654 IP firewall.mydomain.http-alt > drupal.51397: Flags [.], ack 158, win 30016, options [nop,nop,TS val 527844548 ecr 14715265], length 0
09:11:48.858255 IP firewall.mydomain.http-alt > drupal.51397: Flags [P.], seq 1:369, ack 158, win 30016, options [nop,nop,TS val 527844549 ecr 14715265], length 368: HTTP: HTTP/1.1 301 Moved Permanently

Doing a manual wget on the machine works and looks like this.

09:15:17.791422 IP drupal.51402 > firewall.mydomain.http-alt: Flags [P.], seq 1:115, ack 1, win 29200, options [nop,nop,TS val 14767500 ecr 527896782], length 114: HTTP: CONNECT ftp-origin.drupal.org:443 HTTP/1.1
09:15:17.792354 IP firewall.mydomain.http-alt > drupal.51402: Flags [.], ack 115, win 28960, options [nop,nop,TS val 527896783 ecr 14767500], length 0
09:15:17.804522 IP firewall.mydomain.http-alt > drupal.51402: Flags [P.], seq 1:70, ack 115, win 28960, options [nop,nop,TS val 527896786 ecr 14767500], length 69: HTTP: HTTP/1.1 200 Connection established

So this looks like Drupal tries a simple HTTP GET request but should do a HTTP CONNECT to successfully fetch the file.
Is there anything I can do to change the download mechanism?


texts: Displaying content type in translated languages

texts:
So i have a Content Type named "My content type" (a simple form) and it has 5 fields.Now the default language of the field names is in English.[i.e feild1 is 'Name'].
I have translated the field names using the translation interface into 20 different  languages.And when users fill out the form the field names are in their respective and/or preferred language.I have created a custom page template for "My content type",and print the $content of the form there,but it is English (in other words,the field names are displayed as they are written in the content type itself).

My question : How can i display the results of the filled form so that the field names are in a specific translated language ?

A little visual example :

(this is how the "My content type" results are displayed, atm) :

First Name : lorem
Last name : ipsum
Age : 55
Hobbies : lorem ipsum

(and i want the display the field names in a specific translated language,i.e. German)

Vorname : lorem
Familienname : ipsum
Alter : 55
Hobbys : lorem ipsum

This would be a sinch to do if i could use views (but sadly i can't,client specific rule)

If anyone can help ,i'd greatly appreciate it :)


texts: Where do I find the settings for adding a vocabulary to a content type in Drupal 7?

texts:
In Drupal 7, I can't find the Content types and Required setting under edit vocabulary.

How do I customise it?

Drupal6

Drupal7


texts: Views: How to show titles of nodes but hide link based on role

texts:
In views (D7) i made a list of nodetitles that link to content. Some nodes are not accessible for anonymous users, others are. I want the view to list accessible nodetitles with a link but non-accessible titles without a link. How can i do that?
I use content access for setting permissions on individual nodes.

What if i add two fields for Title, one with a link to content and one without. Both fields excluded from display. I can add a binary (or whatever works) field in my content type telling views if visitors should have access to an individual node. Nodes that allow access should (manually) be set open with content-access. That isn't the best way because it requires two edits for every node that should be accessible, but i don't mind.

Than i can make a Views-PHP field that tests on the binary field and either displays the first title-field or the second.

Anyone can help me with some rough coding example for this?


texts: How to convert User points to vote ballots?

texts:
I want to achieve the following functionality and I'm wondering if this could be possible:

For each purchase, one can gain userpoints (I can handle this using Rules).

Those userpoints will then be used to vote nominees. So if I have 1000 userpoints, i can use 300 for Candidate A, 500 for Candidate B, and and 200 for Candidate C. ( 1 userpoint = 1 ballot)

Can some give a hint/suggestion on how I could implement this. Workflow would be:

I select a candidate.
"Input" a vote amount.
Vote gets recorded.
Vote amount will be deducted from my userpoints.


texts: How to create a scheduled mailing list using Rules?

texts:
I am looking for a way to send out an email to a list of users once a week in Drupal. My obvious choice was Rules Scheduler, but that has not been ported.

Is there a preferred way to do this in Drupal 8?


texts: Select first option only in language switcher dropdown module

texts:
I have integrated language switcher dropdown module, which contains four languages
English, China, Japan, Korea.

No matter user browse from these languages, I just would like to select only English language only in dropdown. How can i acheieve this ? Do i need to implements hook ?


texts:
How do I give restrict access to forum?

I am using the Content Access and the ACL modules, and they work fine for individual node/forum topic, but I need this for forum, as the Forum access module did in Drupal 7.

How to achieve this?


texts: How to hide terms with no nodes in "Simple Hierarchical Select" in views?

texts:
I am using a Simple Hierarchical Select as an exposed filter in views.

How would I hide terms that have no nodes from the select box?


texts: Taxonomy term lookup during content migration is failing

texts:
I'm importing some data from a CSV file as nodes into my site. I'm having trouble with importing values into a entity reference field (which is a taxonomy term with multiple values).
Here's just that field (not going to write the entire migrations file as everything else but that field works)
  field_cars_available:
    - plugin: skip_on_empty
      source: "Audi, BMW, Citroen, Renault, Volvo"
      method: process
    - plugin: entity_lookup
      source: "Audi, BMW, Citroen, Renault, Volvo"
      value_key: name
      bundle_key: vid
      bundle: proposed_usage
      entity_type: taxonomy_term
      ignore_case: true
    - plugin: explode
      delimiter: ','
    - plugin: callback
      callable: trim

I've replaced the source file with the actual value for that field (so that it's more clear).
The only error I get is that the migration failed.
Any help?


texts: Manually adding sdk for AWS SDK PHP Module

texts:
The AWS SDK for PHP Module comes with a drush make script:

; Drush Make (http://drupal.org/project/drush)
api = 2
core = 7.x

projects[awssdk][type] = library
projects[awssdk][download][type] = git
projects[awssdk][download][url] = https://github.com/amazonwebservices/aws-sdk-for-php.git
projects[awssdk][download][tag] = 1.5.10

projects[libraries] = 2

What do I need to do to get this SDK manually? I am running Windows and I ran into some issues trying to add the script using drush. I already tried adding the sdk folder to /sites/all/libraries as "awssdk" but that did not work as I keep getting "Failed to load the AWSSDK" in Drupal reporting.


texts:
Our current setup involves a multisite for different parts of our company. We need all sites to share a single user pool for various reason, but each site has slightly different user profile regulations that we need to adhere to. We have different permissions for profile fields on each site, so I need to prevent user profiles being saved if a user isn't on their home site.

I have a field in every profile called "Domain". I intend on pairing this to the current site url to determine if the user is on their home site or not. If not, I need to stop all user_saves from completing. What would be the best way of going about this?

I've found in D6 hook_validate('user') would have done the trick, but there doesn't seem to be anything in D7 that I can use. Would hook_presave work, if I throw an exception?


texts: I'm trying to include a Drupal 8 Rocket Chat plugin module in my website. I installed the plugin module, set up a chat server, but I'm failing, of all places, at actually placing the block on a page (/chat). How do I do that? I'm completely new to Drupal.


texts:
I am  new to drupal and I already created a table using view. I also applied exposed content filtering and I got the following screen

Now I want to show all the category and author are listed in a drop down and i want to select one from that. Also how can I display all the content of table before filter?

Thanks in advance.


texts: Adding Data to a Variable in a Contributed Module

texts:
I'd like to add some data to a variable in a contributed module but I'm not sure how to do that with a custom module.

The Question:

The module I need to 'hack' is the Drupal Commerce PayPal WPP Module. I talked with PayPal and they said specifically I'd need to hack this file: 'commerce_paypal_wpp.module'. They said on line 365 if I added more data to the 'CUSTOM' variable (see below) it would pass that on to PayPal. Sweet! But how can I do that?

My Proposed Solution

I'm thinking I will create my variables to add to CUSTOM, like so (this is how I'd normally do it in PHP of course:

$fname = 'examplename';
$lname = 'examplelastname';
$arr = array($fname, $lname);
$allthedata = implode('+', $arr);
CUSTOM = $allthedata

It's that last line I don't know how to add properly! This, because 'CUSTOM' is already defined in the contributed module (see below).

The Function I Need to Edit:

The function in question in the contributed module is:

function commerce_paypal_wpp_submit_form_submit($payment_method,
$pane_form, $pane_values, $order, $charge) {

And the relevant code with 'CUSTOM' > the variable I want to change:

// Add additional transaction invormation to the request array.
  $nvp += array(
    // Order Information; we append the timestamp to the order number to
allow
    // for multiple transactions against the same order.
    'INVNUM' => substr($order->order_number, 0, 127) . '-' . REQUEST_TIME,
    'CUSTOM' => substr(t('Order @number', array('@number' => $order-
>order_number)), 0, 256),
    'DESC' => substr(implode(', ', $description), 0, 127),

    // Customer Information
    'EMAIL' => substr($order->mail, 0, 127),
    'IPADDRESS' => substr($ip_address, 0, 15),
    'FIRSTNAME' => substr($billing_address['first_name'], 0, 25),
    'LASTNAME' => substr($billing_address['last_name'], 0, 25),
    'STREET' => substr($billing_address['thoroughfare'], 0, 100),
    'STREET2' => substr($billing_address['premise'], 0, 100),
    'CITY' => substr($billing_address['locality'], 0, 40),
    'STATE' => substr($billing_address['administrative_area'], 0, 40),
    'COUNTRYCODE' => $billing_address['country'],
    'ZIP' => substr($billing_address['postal_code'], 0, 20),
  );
}


texts:
Like the title says, is there a way I can use a block inside my panel? It looks like it can't be done...

As you can see here, there is no option to add a block to my panel...


texts:
I have included a javascript in the module "myid" I've been developing in drupal by using this code:

function myid_init() {
    drupal_add_js(drupal_get_path("module", "myid") . "js/myid.js");
}

This is my Javascript file "myid.js":

function myid_js_start(){
    alert("hello world");
}

Below is the code that creates a button that invokes an alert function:

$form['add_button'] = array(
    '#type' => 'button',
    '#value' => 'Take a picture',
    '#attributes' => array('onclick' => 'myid_js_start()'),
);

I dont know where did I go wrong. The button shows up but doesn't fire any alert function. Can anyone help me with this?


texts:
i have a content type which display some text image and comments count, in my View module i need to rewrite this comment count to link on this node. How to do it?
I though i should create field with nid but i dont know how to do it.


texts: Sort Node Queries by an entity reference field within a field collection item

texts:
I am trying to fetch a list of nodes of a particular content type, alongside their field-collection items. The code below works perfectly for my use case.

    function report_cards_get_term_data($type, $term, $session, $student_id, $class){
    $resarr = array();
    $query = db_select('node', 'n');
    $query->join('field_data_field_term', 'ft', 'n.nid = ft.entity_id');
    $query->join('field_data_field_session', 'dfs', 'n.nid = dfs.entity_id');
    $query->join('field_data_field_admission_number', 'rn', 'n.nid = rn.entity_id');
    $query->join('field_data_field_result', 'fr', 'n.nid = fr.entity_id');
    $query->join('field_data_field_class', 'cg', 'n.nid = cg.entity_id');
    $query->join('field_data_field_subject', 'cfs', 'cfs.entity_id = fr.field_result_value');
    $query->join('field_data_field_exam_score', 'ces', 'ces.entity_id = fr.field_result_value');
    $query->join('field_data_field_first_ca', 'cfc', 'cfc.entity_id = fr.field_result_value');
    $query->join('field_data_field_second_ca', 'csc', 'csc.entity_id = fr.field_result_value');
    $query->fields('cfs');
    $query->condition('n.type', $type);
    $query->condition('field_term_value', array('1st Term', '2nd Term', '3rd Term'), 'IN');
    $query->condition('field_session_target_id', $session);
    $query->condition('field_class_target_id', $class);
    $query->condition('field_admission_number_target_id', $student_id);
    $query->addExpression('cfc.field_first_ca_value + csc.field_second_ca_value + ces.field_exam_score_value', 'total');
    //$query->orderBy('cfs.field_subject_target_id->weight', 'ASC');
    $report_card = $query->execute();
}

However, i need to sort the result alphabetically by the entity reference name (taxonomy term) called "Subject". The entity reference is a field within the field collections. I know i can use "$query->orderBy()" but i can't get it to work. That's why it was commented out in the given code above.
Thank you for your suggestions.


texts: How to add sorting option to a field in views bulk operation

texts:
I have created one view with the help of views bulk operations and now I want one of the field to able to sort records according to the field value.

I am attaching image

How can I make the "credits" field as sorting field.


texts: My php is showing a numeric value for my list field...Why?

texts:
In a form I'm trying to take a value a user selected from a radio button and compare it with what's in the database. The value for the radio button is stored in $form_state['storage']['level'].

The list field in my resource type for this set of items is set as follows:

Novice|Novice
Experienced|Experienced
Professional|Professional

And yet, when I echo out the value in $form_state['storage']['level'] it just gives me what appears to be the delta and not the value of the field. Would someone please enlighten me as to how the value is obtained in php code?


texts: How to set Drupal Commerce shipping rules by the longest of the shortest dimensions of a product?

texts:
How can I create shipping rules which will base the shipping charge on the length of the package? Specifically, I need two rules for shipping: 1) if the length is less than X, then charge Y; 2) else/if the length is greater than X charge Z. Finally, I only need longest of the shortest dimensions for the shipping price.

I have a use case where the shipping charge is determined by the length of the packaging, not weight, or number of units. The products are posters, which will be rolled along the shortest side, such that I cannot simply base the shipping on a specific physical dimension (e.g. the length) as the posters are sometimes horizontally oriented and for this reason the dimension which needs to be used for the shipping calculation should be the shortest, but shipping must be calculated on the longest of the short dimensions. I'm only just now diving into the shipping rules and I've looked at Commerce Physical and Physical Fields, but I'm not sure how to take the shortest of two dimensions of the products, and then base the shipping on the longest of these.

As always, any advice would be greatly appreciated.


texts: Why do my breadcrumbs see double? and How can I control them? A double question?

texts: I have a taxonomy menu that invokes a Panel variant linked to a view that uses the taxonomy term.  The display works fine, but I get a breadcrumb trail that repeats the menu path twice.  I cannot find a setting in the menu, panel or view that offers control of the breadcrumbs, in fact, since this is my first time dealing with breadcrumbs, I discovered I cannot find what controls them at all.  How do I configure breadcrumbs?


texts:
I recently tried to use an Upsert query in a table with a composite primary key, but when I go to see the key() method it only allows one parameter and not an array, so we only can only have a singular key:

public function key($field) {
  $this->key = $field;

  return $this;
}

I just tried to use one key and the query works fine! How is posible this? Let see in the core files.

This always will work because if you see the code inside the __toString() function the key property is never used:

public function __toString() {
    // Create a sanitized comment string to prepend to the query.
    $comments = $this->connection->makeComment($this->comments);

    // Default fields are always placed first for consistency.
    $insert_fields = array_merge($this->defaultFields, $this->insertFields);

    $query = $comments . 'INSERT INTO {' . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES ';

    $values = $this->getInsertPlaceholderFragment($this->insertValues, $this->defaultFields);
    $query .= implode(', ', $values);

    // Updating the unique / primary key is not necessary.
    unset($insert_fields[$this->key]);

    $update = [];
    foreach ($insert_fields as $field) {
      $update[] = "$field = VALUES($field)";
    }

    $query .= ' ON DUPLICATE KEY UPDATE ' . implode(', ', $update);

    return $query;
  }

}

Ok, If the key property is never used I will try to made my upsert without it.

$upsert = $this->database->upsert('forcontu_node_votes')
        ->fields(['nid', 'uid', 'vote'])
        ->values([
          'nid' => $nid,
          'uid' => $uid,
          'vote' => $node_vote,
        ]);
dpm($upsert . '');
// Using dpm() because dpq() doesn't works with upsert https://www.drupal.org/node/2847155
$upsert->execute();

The code will throw an exception because always you need to set the key, if you don't set the key property you will get an exception:

protected function preExecute() {
  // Confirm that the user set the unique/primary key of the table.
  if (!$this->key) {
    throw new NoUniqueFieldException('There is no unique field specified.');
  }
...

If you put comments in the lines

  // if (!$this->key) {
  //  throw new NoUniqueFieldException('There is no unique field specified.');
  //}

the code will works fine, and you will see that if you set or not the key property always the query is the same, in my case:

INSERT INTO {forcontu_node_votes} (nid, uid, vote) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2) ON DUPLICATE KEY UPDATE nid = VALUES(nid), uid = VALUES(uid), vote = VALUES(vote)

So, Why we need the key property in the Upsert class if it is never used?

Note: This is just in the mysql and sqlite clases that the key is not used, but in the postgre clases is used (at this moment I don't have postgre to made some test).

Database Schema:

CREATE TABLE `forcontu_node_votes` (
  `nid` int(11) NOT NULL COMMENT 'Node ID',
  `uid` int(11) NOT NULL COMMENT 'User ID',
  `vote` tinyint(4) NOT NULL DEFAULT '0' COMMENT '1 to 5',
  PRIMARY KEY (`nid`,`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Stores Node votes';

forcontu_blocks.install:

/**
 * Implements hook_schema().
 */
function forcontu_blocks_schema() {
  $schema['forcontu_node_votes'] = [
    'description' => 'Stores Node votes',
    'fields' => [
      'nid' => [
        'type' => 'int',
        'not null' => TRUE,
        'description' => 'Node ID',
      ],
      'uid' => [
        'type' => 'int',
        'not null' => TRUE,
        'description' => 'User ID',
      ],
      'vote' => [
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => '1 to 5',
      ],
    ],
    'primary key' => ['nid', 'uid'],
  ];
  return $schema;
}


texts: slideshow module where editor can upload images

texts: I am looking for a JQuery slideshow module, where an editor can upload images from Drupal, without having to go into the code or through ftp.  I imagine this module already exists.


texts: How to use #states with Heirarchichal Select?

texts:
I want to show a field based on the value of an taxonomy in hierarchical select in Node Add form.I am using #states for it but i can't find where the value of the heirarchichal select is stored or how it is selected. This is how i tried to do it using hook_form_alter.

$form['field_name']['#states'] =  array (
      'visible' => array (   // action to take.
        'select[name="field_category[und][hierarchical_select][selects][0]"]' => array('value' => '62'),

      ),
    );

When the value of heirarchichal select is 62,i want to show it?


texts: How can I theme profile field forms in an HTML table?

texts:
I put this code in Drupal 6, and made a template file called "user-register.tpl.php" to override the default registration page.

function my_theme_theme(){
  return array(
    'user_register' => array(
      'arguments' => array('form' => NULL),
      'template' => 'user-register',
    ),
  );
}

With this, I could print profile user name, email and password.

<?php print drupal_render($form['account']['name']); // prints the username field ?>
<?php print drupal_render($form['account']['mail']); // print the email field ?>
<?php print drupal_render($form['account']['pass']); // print the password field ?>

This code doesn't print the profile field form.

<?php print drupal_render($form['profile_category_name']['profile_field_name'] ); ?>

Ideally I would like to print the form itself separately from the title, and the description so that I can arrange them with <table> tags.


texts: How can I set specific download URI for file?

texts:
Here is my problem. I've got file (eg. some.xml) and multisite Drupal 7 installation.
How can I allow to download this xml from my-multi-site.domain/some.xml?
Is there any way to do it without writing custom module with hook_menu?

P.S. this file should be different for every site on multisite installation


texts: Passing an array stdClass Object from custom module to template

texts:
I’ve created some D8 custom modules which call rest API and and it’s working fine when I get simple array in my $response.

In my controller, this is working :

return [
            '#theme' => 'webservices_client',
            '#id' => $infos_clients->body->id,
            '#nom' => $infos_clients->body->nom,
 ];

But when I receive that kind of array $response->body :

Array
(
    [0] => stdClass Object
        (
            [numero] => 625
            [dateDebut] => 2018-09-27T09:21:54.5746973
        )

    [1] => stdClass Object
        (
            [numero] => 468
            [dateDebut] => 2018-05-17T16:50:33.6357383
        )

)

I don’t how to send my array from the controller to the twig template and assign variable in my-module.module

Could you explain how to this ?

I've tried this kind of thing :

in controller :

return [
            '#theme' => 'webservices_informations',
            '#myvariable' => $response,
       ];

in my-module.module :

function webservices_informations_theme(array $existing, $type, $theme, $path) {
    return array(
        'webservices_informations' => array(
            'variables' => array(
                'myvariable' => NULL,
            ),
        ),
    );
}

In twig template :

{% for key, value in myvariable %}
            Key : {{ key }}

            Name : {{ value.id }}

{% endfor %


texts: How to get the node title of a refernced node

texts:
I'm using Drupal 7, and trying to work some magic from within a hook_node_presave() function.

I have a node reference field, and I'm trying to get the name of the referenced node rather than nid. When I trace out the field ($node->field_my_name) I get the following

Array
(
    [und] => Array
        (
            [0] => Array
                (
                    [nid] => 23
                )

        )

)

I wondering if there is a way to get the title without doing a full load of the referenced node. Is there anyway I can do this with a token? Would this no be an issue if I were using entity reference rather than references?


texts: For $vars['id'] == 1 render field Y instead of field X

texts:
So on my Blog listing page, the first listing is "featured" meaning it spans two columns rather than one, I've achieved most of my styling changes by adding CSS class feature to $vars['id'] == 1 for the blog page.

However, the image for  first teaser is a different proportions and therefore uses custom field header image rather than custom field thumbnail image. In the following:

function innovista_preprocess_node(&$vars) {
  if ($vars['id'] == 1 && arg(0) == 'blog') {
    $vars['classes_array'][] = 'feature';

    //do stuff to switch field here?

  }
}

I want to add a command to switch render of $content['field_blog_thumbnail_image'] with render of  $content['field_blog_header_image']. How can I go about this?

Thanks for your time!


texts: add an additional item to an array in Drupal Settings javascript from php

texts:
I've got a hook_node_view which I'm trying to add a property of the node to an array that I have created in the Drupal.settings

drupal_add_js(array('embedded_videos'=>array()));

So in the node_view I can do

function mymod_node_view($node, $view_mode, $langcode) {
if($node->type == 'video'){
   drupal_add_js(array(
    'vimn_video' => array('embedded_videos' => $node->nid,
      ),
    ),
  'setting');
}

But this overwrites what is in there, whereas I want to add to the array. Because this node_view is running multiple times as I have 2 video nodes embedded into an article node.

Any ideas appreciated. I am new to the usage of Drupal.settings javascript api.

edit: The issue was that I needed to put $node->nid into an array array($node->nid), then it will add an item to the array rather than overwriting it.


texts: How do I add a link to an operations dropdown menu in views?

texts:
I am using Commerce Kickstart 2.

There is a view that lists all of the orders.  On each order, there is a dropdown menu with the options of 'Quick Edit' 'Payment' and 'Delete'.  I want to add my own operation on that order to view just the list of line items plus some custom information in a view.

However, I can't seem to figure out what I need to do to add a link to this dropdown menu and then go to my view when it is chosen.


texts:
I am trying to display the ID of the group the user is currently viewing. I created a block, and added the following PHP code into it:

<?php
$group = og_context();
if ( !empty($group) ) {
   print "$group->nid";
}
?>

Problem is, when I run it, I get the following error:

Notice: Trying to get property of non-object

Any idea why this is happening, and how to fix it? Seems like it should be easy enough of a task.


texts: How to create a view of Media images that do not have any Alt Text

texts:
For accessibility purposes I want to create a view of Media images that do not have any Alt Text.
Creating a view of Media images and also displaying Alt Text is not difficult, as explained is this d.o post Media alt text not available in Views
However I do not know of a way to create a filter of 'Alt Text is NULL' so that a view can be built which only returns images without alt text.
Any suggestions for how could this be accomplished? Ideally this would be a view of media entities so that other filters relating to media can also be used.


texts: Export the default system email text to code?

texts:
Is it possible to move the default system email message text found in the account settings page out of the database and into the code for version control?

Currently using the mimemail module since we use HTML/CSS formatted emails.


texts: Display nodes with same CCK radio button value in a Views block

texts:
I have a CCK field with some values that you can choose with a radio button. When you are viewing a page that has one of the values selected, I'd like to show all of the other pages that have the same value selected in that field.

I have tried with contextual filters (adding that field as an argument), but nothing showed up.

How can this be achieved?

Thank you in advance for any help!


texts: Undefined index: XXX in accept_exposed_input() (line 1273 of sites\all\modules\views\handlers\views_handler_filter.inc)

texts:
I am getting the following notice on the views edit page:

  Notice: Undefined index: l12agno in accept_exposed_input() (line 1273 of
  C:\xampp\htdocs\drupal7\sites\all\modules\views\handlers\views_handler_filter.inc).
  Notice: Undefined property: views_display::$handler in execute() (line 1134 of
  C:\xampp\htdocs\drupal7\sites\all\modules\views\includes\view.inc).

I have added a filter on a taxonomy term for which I have written a custom filter handler (by using _views_data_alter):

$data['taxonomy_term_data']['l12agno'] = array(
    'title' => t('L1/2 Agnostic'),
    'help' => t('Lx Agnostic filter'),
    'real field' => 'tid',
    'filter' => array(
      'handler' => 'views_handler_filter_lx_agnostic',
    ),
  );

the custom handler looks like this:
here "categoryta" is a 3 level hierarchy.

class views_handler_filter_lx_agnostic extends views_handler_filter {

  function value_form(&$form, &$form_state) {
    parent::value_form($form, $form_state);
    if (!empty($form_state['exposed'])) {
      $form['value'] = array(
        '#type' => 'container',
        '#prefix' => '
',
        '#suffix' => '
',
        '#tree' => TRUE,
      );
      $vocab = taxonomy_vocabulary_get_names();
      $tree = taxonomy_get_tree($vocab['categoryta']->vid, 0, NULL, TRUE);
      $options = array();
      foreach ($tree as $item) {
        if(!$item->deleted) {
          $options[$item->parents[0]][$item->tid] = $item->name;
        }
      }
      $form['value']['t0'] = array(
        '#type' => 'select',
        '#options' => isset($options[0])? $options[0] : array(),
        '#empty_value' => 0,
        '#empty_option' => t('All'),
        '#default_value' => 0,
      );
      if (isset($options[0])) {
        foreach ($options[0] as $tid => $title) {
          $form['value']['t' . $tid] = array(
            '#type' => 'select',
            '#options' => $options[$tid],
            '#empty_value' => 0,
            '#empty_option' => t('All'),
            '#default_value' => 0,
            '#states' => array(
              'visible' => array(
                ':input[name="l12agno[t0]"]' => array(
                  'visible' => TRUE,
                  'value' => $tid,
                )
              )
            )
          );
        }
      }
    }
  }

  function query() {
    $this->ensure_my_table();
    if (!empty($this->value[0]['t0'])) {
      $t0 = 't' . $this->value[0]['t0'];
      if(!empty($this->value[0][$t0])) {
        $field = "$this->table_alias.$this->real_field";
        $this->query->add_where($this->options['group'], $field, $this->value[0][$t0], '=');
      }
      else {
        $def = $this->definition;
        $def['table'] = 'taxonomy_term_hierarchy';
        if (!empty($this->table_alias)) {
          $def['left_table'] = $this->table_alias;
        }
        else {
          $def['left_table'] = $this->table;
        }
        $def['left_field'] = $this->real_field;
        $def['field'] = 'tid';

        $join = new views_join();

        $join->definition = $def;
        $join->construct();
        $join->adjusted = TRUE;

        // use a short alias for this:
        $alias = $def['table'] . '_' . $this->table;

        $this->alias = $this->query->add_relationship($alias, $join, $alias . '_' . $this->real_field, $this->relationship);
        $this->query->add_where($this->options['group'], "$this->alias.parent", $this->value[0]['t0'], '=');
      }
    }
  }

  public function operators() {
    return array();
  }
}

The same code is working on production, but not in my local system.
I have tried flushing cache and trying different browsers and switching between different jquery_update versions.
Any help is appreciated.


texts: My if statements are working everywhere except in my hook_block_view function

texts:
I am trying to make a custom form block in drupal.  I want it to display my form, then after submitting, show the results.  I have an if statement in the hook_block_view function saying if my form has been filled out to set $block['content'] to "Form Submitted".  This doesn't work though, it just displays the form again.  I have the same if statement in my hook_form_submitted function to either set drupal_set_message to either 'Submitted' or to display what was put into the form.  After submitting, when the page reloads, The form still displays, $block['content'] does not get set, but drupal_set_message() does.  What am I doing wrong?

Just thought of something, my block_view() only passes ($delta = '') is it just that $form_state['values'] is not being passed through the function?

<?php

/**
 * @file
 *
 */

 /**
 * Implements hook_block_info().
 */

 function search_engine_block_info() {
     $blocks = array();
     $blocks['search_engine'] = array(
        'info' => t('Search Engine'),
        'cache'=> DRUPAL_CACHE_GLOBAL,
    );
    return $blocks;
 }

 /**
 * Implements hook_block_view().
 */

 function search_engine_block_view($delta = ''){
     $block = array();
     switch ($delta) {
     case 'search_engine':
         $block['subject'] = t('Search Engine');
         //Check to see if the form has been submitted.  If not, show form, or else show results.
         if(!isset($form_state['values']['searchInput'])){
            $block['content'] = drupal_get_form('search_engine_form');
         }else{
            $block['content'] = 'Form Submitted';
         }
     }
     return $block;
 }

 /**
 * Implements hook_form.
 */

 function search_engine_form ($form, &$form_state){
    $form['searchOptions'] = array(
        '#type'     => 'select',
        '#title'    => t('You can search by GWF Number, name, email address or phone number.'),
        '#options'  => array(
            'gwf'           => t('GWF Number'),
            'applicant_email'   => t('Email Address'),
            'name'          => t('Name'),
            'phone_number'      => t('Phone Number'),
            ),
        '#value'    => 'gwf',
    );
    $form['searchInput'] = array(
        '#type'     => 'textfield',
        '#title'    => t(''),
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value'=> t('Submit'),
        );
    return $form;
 }

 /**
 * Implements hook_form_submit.
 */

 function search_engine_form_submit($form, &$form_state){
    if(isset($form_state['values']['submit'])){
        drupal_set_message('Sumbmitted!!');
    }else{
        drupal_set_message($form_state['values']['searchOptions']);
    }
 }


texts:
The submit element on my form uses an ajax callback which sends out an email.

I have a validation callback which I've added to this form, but it gets run after the ajax callback and so the email will be sent out even if the form doesn't validate.

I can't add the validation to the ajax callback itself because it gets used on lots of other forms on my site.

Is there any way to run my validation callback before ajax is run?


texts: How can I pass parameters to allowed_values_function for a field?

texts:
Tried these 3 ways... none of them work.

->setSettings(array(
    'allowed_values' => array(),
    'allowed_values_function' => '\Drupal\xrm_core\Util\DefinedValuesListUtil::getRegionValues',
    'allowed_values_function_arguments' => '["country_id", 0]',
  ))

  ->setSettings(array(
    'allowed_values' => array(),
    'allowed_values_function' => '\Drupal\xrm_core\Util\DefinedValuesListUtil::getRegionValues(1)',
  ))

  ->setSettings(array(
    'allowed_values' => array(),
    'allowed_values_function' => '\Drupal\xrm_core\Util\DefinedValuesListUtil::getRegionValues\1',
  ))

This particular feature seems totaly undocumented in existing drupal docs. Any ideas to point me in the right direction please?


texts: Limit the number of levels (depth) of a taxonomy vocabulary

texts: I would like to limit the depth of a taxonomy vocabulary to a maximum number parent/child nestings. I would like my users to not be able to add at most 4 levels deep of taxonomy terms per tree. Is there a module for this or what code is needed to enforce this depth on the tree?


texts:
I'm trying to add some custom JS to the search module in Drupal 6. I've added all of my custom JS through template.php via THEME_preprocess_node()

How can I add JS to the search module (without hacking the search module) via template.php in my theme?


texts:
I have created a view and I want to show filtered posts passing arguments via the URL. Example:

http://mysite.com/press/2012-01

I want to show all press posts created in January'2012.

How can I do that ?


texts: how to select particular product from bunch of products

texts: I have two fields in my content type. one field(seat) has more than 10 products( product reference ) and another field (default). while selecting one product in the seated field ,should be shown in the default field. I do not know how to get that product from seat to default. How to solve this ?


texts: Prevent redirection after comment submission

texts:
When a user add a comment on a node, I would like to prevent the page reload.

I added a form_alter in my theme

function theme_form_alter(&$form, &$form_state, $form_id) {
    switch($form_id) {
      case 'my_form_id':
        $form_state['redirect'] = false;
      break;
  }
}

But this is not working.

I also tried to replace $form_state['redirect'] = false by $form_state['redirect'] = false but it seems to be the Drupal 7 way to do this.

how could I achieve that on Drupal 8 ?

EDIT

I tried to use a submission handler

function theme_form_alter(&$form, &$form_state, $form_id) {
        switch($form_id) {
          case 'my_form_id':
            $form['#submit'][] = 'theme_form_submit';
          break;
      }
    }

function theme_form_submit(array $form, FormStateInterface $form_state){
    $form_state->disableRedirect();
}

But it's still not working.


texts:
Whenever I run cron , all the articles in drupal which I have edited/created get updated with the new timestamp(the time when cron runs) and the "updated" tag appears beside the article name.This happens again and again as I run cron,even if I did not make changes to that article again.
To be more precise :
I edit two articles 1 ,2 today at 10:00 AM and run cron 5 min later at 10:05 , the time stamps of both are updated to 10:05 .
Again I edit article 1 at 10:10 and run cron at 10:20 and now, articles 1,2 have their time stamps at 10:20.
Any thoughts regarding this?


texts: how to apply standard and advanced theme to tinymce in drupal 7

texts:
I have integrated wysiwyg with tinymce editor.. now Tinymce asks to choose buttons which we want in editor... I want to apply its own theme like 'standard' or 'advanced' or any other and dont want to select buttons..
How can I do it ?


texts: How to add library if Ajax is enabled for view?

texts:
We have a view, myview, where Ajax is disabled. We created a custom library that would override the load more button's indicator so that we can use our own. However, we would only like to add this library conditionally if myviews->Use Ajax->Enabled, but when it is disabled then do not add the library. I know how to conditionally add the library, but not sure how to check if myviews->Use Ajax is set to enabled.

How can we detect if myview->Use Ajax->enabled?

mytheme.libraries.yml

mytheme-custom-indicator:
  version: 1.0
  js:
    /path/to/js/custom-indicator.js: { attributes: { defer: true }}
  dependencies:
    - core/drupal
    - core/drupal.ajax
    - core/jquery

custom-indicator.js

 /**
   * Infinite scrolling progress indicator.
   *
   * @type {{attach: Drupal.behaviors.progressIndicator.attach}}
   */
  Drupal.behaviors.progressIndicator = {
    attach: function (context, settings) {
      Drupal.Ajax.prototype.setProgressIndicatorFullscreen = function () {
        this.progress.element = $('<div class="myclass"> </div>');
        $('body .pager').after(this.progress.element);
      };
    }
  };

What we tried

/**
 * Implements hook_views_pre_render().
 */
function ns_general_views_pre_render(ViewExecutable $view) {
  // Add library to all for ajax progress.
  $view->element['#attached']['library'][] = 'mytheme/mytheme-custom-indicator';
}

Goal

/**
 * Implements hook_views_pre_render().
 */
function ns_general_views_pre_render(ViewExecutable $view) {
  // Add library to all for ajax progress.
  if($view->hasAjax) {
    $view->element['#attached']['library'][] = 'mytheme/mytheme-custom-indicator';
  }
}