texts: Condition plugins: two on the same form?

texts:
I'm working on porting the CAS module to Drupal 8. On the main configuration form, users can list paths that will activate a feature of the module.

I read about using the new condition API recently, which has a condition for matching request paths, and decided to try and incorporate it into the module settings since it seems perfect for what I'm doing.

On the form submit handler, I have code like:

$this->myPathCondition->submitConfigurationForm($form, $form_state);

And the actual submitConfigurationForm code from the RequestPath class looks like this:

public function submitConfigurationForm(array &$form, array &$form_state) {
  $this->configuration['pages'] = $form_state['values']['pages'];
  parent::submitConfigurationForm($form, $form_state);
}

Couple problems though:

I have two instances of the condition plugin, so they would trip over each other in the form submission
For that reason, I would typically "namespace" each to a section, like: $form_state['values']['forced_login']['paths']

But since the condition plugin looks at a specific array structure for the value, this won't work. This appears to be a limitation of the plugin, but perhaps there's a reason for this, or a method around it?

I understand D8 isn't even in beta yet, but I didn't want to comment on the closed issue where this was implemented: https://www.drupal.org/node/1921544


texts: Drupal equivalent of wget (with permissions)?

texts:
I'm working on a drupal 6 module and need a way to save a static html version of a node to the server, using the user's permissions.  Basically I need the equivalent of "wget -O out.htm http://mydrupalsite.org/node/1635" in drupal, that uses the activating user's permissions and login, but don't know enough about drupal to make this work without some pointers in the right direction.  I've looked through the functions list and the module code for http://drupal.org/project/print, but no luck.  Any help?

Thanks in advance.

EDIT: Clarification:  What I'm trying to accomplish is have a sidebar link for users to use that saves a copy of the current page -exactly as apache just sent it the user- to the server.  I'm trying to do this through drupal -without- using wget or any other system utility.


texts:
When I use it then it then the form page load shows endless errors like table system not locked, undefined index, table cache not locked etc.

How to use it in Drupal?

I'm using LOCK TABLES for a small piece of my code:

 if(!AnuDonationTable::lock_tables())
                {
                    form_set_error('',"Fatal problem with database access");
                    $form_state['redirect'] = false;
                    return;
                }

                $ret = AnuDonationTable::verify_count($sno, $itemarr[0]['hidden_total_updatedrows']);

                if( false == $ret )
                {
                    form_set_error('',"Fatal problem with database access");
                    $form_state['redirect'] = false;
                    AnuDonationTable::unlock_tables();
                    return;
                }
                else if( -1 == $ret)
                {
                    form_set_error('',"Underlying data has changed after your page load. Please refresh this page.");
                    $form_state['redirect'] = false;
                    AnuDonationTable::unlock_tables();
                    return;
                }
                //else success

                $query = "INSERT INTO {anu_donations_housekeeping} (sno2,status,updated_by) VALUES
                       (%d,'cancel',$user->uid)";

                if( false === db_query($query,$sno))
                {
                    drupal_set_message("Fatal Error:Unable to add data in the database",'error');
                    $form_state['redirect'] = false;
                    AnuDonationTable::unlock_tables();
                    return;
                }
                else{

                    AnuDonationTable::unlock_tables();
                }


texts: How can I alter the 'submitted by username' for a comment?

texts:
I am rendering comments on my site. I am using the Zen theme. If I remark out <?php print $submitted; ?> in comment.tpl.php the 'username replied on' part is no longer rendered. But I don't want to remove the whole thing - just the 'replied on' text. I can't work out how to alter this bit. Thanks

In Zen comment.tpl.php it reads: '$submitted: Submission information created from $author and $created during template_preprocess_comment()'. Presumably, somewhere there will be: $author . 'replied on' - and this is what I need to alter.


texts: Recommendation On Search Form For People

texts:
We want to develop a 'Directory' of People in our organisation (a View) with search form that lets authenticated users search for one another by last name or User ID.

I'm looking for recommendations on the best way to do this as we will have literally thousands of 'People' and I don't want the standard widget with 'people' which I fear would be dreadfully slow. All I need is a text field and the SQL equivalent of...

Lastname LIKE('FRA%') OR UserID LIKE('FRA')

...where the user typed 'FRA' into the form. They would get all users (People) with a last name starting with 'Fra'.

Is there a pre-built module that someone can suggest that does this, or can someone provide some (basic) guidance on how to implement this on a View?

I looked at the default Search User tab and I didn't see a way to theme this to include various fields we will need such as the user's photo and so on.

TIA


texts: Drupal sending out unwanted emails about new content

texts:
I am receiving tons of Mail Delivery System failed regarding new content notifications.

Looks like my website is sending out new content notification to every registered user.

But I never set up such behaviour, and I don't want my users to receive updates this way.

This is going on since 1 week, have to find a solution.

---[Here below one of the thousands of the returning message:]---

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

 name@gmail.com
   SMTP error from remote mail server after end of data:
   host p3nlsmtpcp-v01.prod.phx3.gdg [72.167.191.78]:
   552 5.2.0 q6pN1p00w4NPGeA01 :: CPANEL :: Message rejected for spam or virus content ::
   Please include this entire message when contacting support ::
   v=2.1 cv=O7y3vXNW c=1 sm=1 tr=0 p=65lisdlOQaQA:10 p=9sfF_i041VMA:10 a=GrLZr1+P9ClXUG4p+qBB1A==:117 a=GrLZr1+P9ClXUG4p+qBB1A==:17 a=TZb1taSUAAAA:8 a=h0rLbXwqTyIA:10 a=IkcTkHD0fZMA:10 a=60h86PuPWa4A:10 a=H9FGv8k8AAAA:8 a=0HtSIViG9nkA:10 a=e4lbWNnZ9XO776ZxNvwA:9 a=QEXdDO2ut3YA:10 ::
   97.00

------ This is a copy of the message, including all the headers. ------

Return-path: <me@mywebsite.com>
Received: from my na by p3plcpnl0675.prod.phx3.secureserver.net with local (Exim 4.84)
    (envelope-from <me@mywebsite.com>)
    id 0002fW-5m
    for name@gmail.com; Sun, 08 Feb 2015 23:52:06 -0700
To: name@gmail.com
Subject: New content notification for name from mywesite
X-PHP-Script: www.massamagra.com/index.php for 123.124.125.126
MIME-Version: 1.0
Content-Type: text/plain;charset=utf-8
Content-Transfer-Encoding: 8Bit
X-Mailer: Drupal
From: me@mywebsite.com
Message-Id: <E1YKiCU-0002fW-5m@p3plcpnl0675.prod.phx3.secureserver.net>
Date: Sun, 08 Feb 2015 23:52:06 -0700

Greetings name, this is a notification about new content from mywebsite.

This e-mail may only shows excerpts. Click on the links below to see the
whole node/comment.

---[I omitted content here because is full of links to my website]---

This is an automatic e-mail from massamagra.
To stop receiving these e-mails, change your notification preferences at (omitted: link to user)


texts: How to map ubercart attributes to CCK fields?

texts:
The reason I am trying to map ubercart attributes to CCK fields because I can then use these CCK fields to display price list using views for many use cases.

Is there any fields references module which can do this?


texts: Multisite domain not working without symlink

texts:
I used to have to work with my own custom *.conf file in order to get my multi-site to work off a non root install of drupal but now have moved it to root ,I don't need that file anymore as system reads the .htaccess.

So while my subdomains work fine in sites folder, my other domain name in sites folder refuses to work without symlink. Which I always thought was only necessary in tandem with *.conf file for virtualDocument hosts.

So my question is --

Why won't my other domain work like other sites in sites folder?

Why must it have a symlink to work?

And why do other sites have clean-urls working along with main install site but not other domain name?

My set up is

  mainsite.com/sites/

                  subdomain.mainsite.com
                  subdomain2.mainsite.com
                  otherdomain.com

If I symlink otherdomain.com while in www folder:

ln -s /var/www/html/ /var/www/html/otherdomain.com

It works but without clean-urls


texts: Publish content on user unblock event Drupal 7

texts:
I know that this is most probably and easy question but I simply can't get it to work. I have a custom module which generates a form to create a content (unpublished) of a certain type and also register the anonymous user creating that content with a username and password.

I am using the User verification module  to send a validation mail, and when the client clicks the link the account is unblocked.

I want a rule (I tried using the Rules module) to publish the content when the account is unblocked or validated (i need it to work on one of these to events) , but I can't find either of these events, nor can I manage to set the data selector to publish that specific content when setting the action to publish content.

If anyone can explain to me what I am missing or doing wrong it would help me a lot.


texts:
i have a project that is based on a normal drupal, and i have added commerce modules to it,
but i can't find the module or setting that changes the way of editing the product from:

to:

can anyone point me to the right direction?


texts: Setting up a download page requiring a user to fill a form before downloading anything

texts:
In the Drupal site I'm setting up, there's a Download page containing several links to download softwares.

What is the best way to "bind" the softwares to the page, put them anywhere online and place a direct link in the page?
Does anyone know a module that would show a contact form when a user clicks one of the "Download" buttons, preventing him from downloading unless he properly completes the form?  Our goal is to receive the contact information of any person downloading our software.


texts: How to programatically submit an entityform?

texts:
My use case:

Anonymous user submits information via an entityform.
The form data ($_POST) is cached and a modal dialog box displays with a login form.
The user authenticates, and the cached form data is retrieved and then submitted.

I've been able to do this with webforms, but I haven't been able to accomplish the same task for entityforms. I can get the form using the following code...

<?php
$entityform = entityform_empty_load('my_eform_type');
$form = entityform_form_wrapper($entityform);
?>

What I've had trouble with is creating a $form_state array with the correct structure and values from the cached $_POST that I can then pass to drupal_form_submit(). My entityform has image, date, and checkbox fields, so that adds to the complexity.

I've been able to manually create and save an entityform submission using the following code...

<?php
$values = array(
  'type' => 'my_eform_type',
  'uid' => $user->uid,
  'created' => time(),
  'changed' => time(),
  'language' => LANGUAGE_NONE,
);

// For brevity's sake, I don't show adding all the fields
// from the cached $_POST to the $values array.

$entityform = entityform_create($values);
$entityform->save();
?>

...but that doesn't provide the form validation and reload on error functionality. Errors such as the wrong size image being uploaded, which is caught during form submission.

When my entityform is submitted, there is also an entityform notification email sent and the user is redirected to the confirm page. I don't want those things to happen prior to the user authenticating.

There's some code in the d.o. handbook, but it doesn't talk about drupal_form_submit().

I'm using Entityform 1.1.


texts:
I'm running Drupal 8 with two taxonomy vocabularies, which are as follows:

Color

Red
Blue
Green

Containers

A
B
C
D
E
F

My content has 2 term reference fields

Color
Containers

The first term reference can have multiple tags. What I'm trying to do is use the first vocabulary (Color) as exposed-filter/menu and the second (Containers) as term reference list on my views. I want to be able to show the second vocabulary (Containers)reference list based on the first vocabulary (Color) tags. So if someone clicks Red it will only list the second vocabulary (Containers) which has the term tagged as red.

How can I achieve this?


texts: How do I get debug_backtrace() to fire on the endpoint site of a Deployment process?

texts:
I'm trying to work through this UUID features bug with the deploy module. On the receiving site, I see errors in that log like

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'fc661e5c-62de-fa34-2557-0f6f5a2acbfe' for column 'fid'

I've followed the example laid out here to have a backtrace show for any error on both the sending and receiving installations. However I can' seem to find a way to get the backtrace to show for the error on the receiving site after the deploy process completes. I can see the service error in /admin/reports/dblog but that's it.

Any help is greatly appreciated!

-adbo


texts: “Show as expanded” selected but children menu items not displaying

texts: I've main menu navigation and some links checked "Show as expanded" and have child items under it. In the main site page, only parent items are appearing and child items not appearing. I've created a twig template "menu--main.html.twig" and kint the item and found that "is_expanded" is FALSE and there are no child items.


texts: Could someone explain the 'hit' and 'miss' status in memcache per page output?

texts:
I've instructed memcache to append stats to each page. Someone did an excellent job explaining the memcache reporting page. However, I've since stumbled upon this appended information shown below and am curious.

Specifically what are miss and hit status?

(enlarge picture)


texts:
I cannot upgrade my user profile info in Drupal. After pressing submit this error message appears:

  This user already has a content profile of this type. You can only
  create one profile per user.

and the name became red.  I am using the Content Profile module.


texts: theme() parameters sent to output.tpl.php

texts:
What I am trying to do, is to set some variables in my function and to send this to my output.tpl.php.

My steps are the following.

Declare my theme template

function mymodule_theme() {
  return array(
    'my_file' => array('template' => 'output')
  );
};

Define the following function

function mymodule_myfunction() {
  $build['variables'] = array(
    '#theme' => 'my_file',
    '#variables' => $my_vars
  );
  return $build;
}

I use the following code for my output file (output.tpl.php)

<?php echo $my_vars[0]; ?>

I get an error saying $my_vars is unknown.

What am I doing wrong?


texts: How to tell what filename to select when using twig debugging in drupal 8 theming

texts:
this is my second week with drupal 8 (or drupal in general). I want to be a drupal developer and contributer to the modules and themes community. However, I am a little lost with the file name suggestions shown in this image.

When reading books and tutorials, i see the author suggesting we use one of the filename suggestions shown, but how do you know which one to select?
So like in that list, the author switched from the default selected which is the last one, to the second from top. What criteria did he use to determine which is best? Thanks in advance.


texts: Create a new user from an entry submitted with the module "webform"

texts:
i'm using the module webform  so that user can ask for the credentials to login to the site. I need to add a button to the the "view" of each submission so that the user that it's viewing that submission can create a user.

Do i have to modify the code of the module to achive this or should i write my own module? If i write my own module what hooks should i implement to add the button, the logic for the button to be present only if i didn't create a user, and the custom action for that button?


texts: AJAX / AHAH 'Add More' Button on Unlimited Cardinality Fields Conflicts with Custom Submit Handler

texts:
I have a node add form with some integer text fields that have unlimited cardinality, which causes an AJAX 'Add More' button to be displayed for those fields. The form also has a custom submit handler that is defined in a custom module.

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

$form['actions']['gaylord_submit'] = array(
  '#type' => 'submit',
  '#value' => t('Add Gaylord'),
  '#submit' => array('inventory_stocking_ticket_form_gaylord_submit'),
  '#executes_submit_callback' => TRUE,
  '#name' => 'edit-gaylord-submit',
  '#limit_validation_errors' => array(),
);

function inventory_stocking_ticket_form_gaylord_submit(&$form, &$form_state) {
if ($form_state['clicked_button']['#id'] == 'edit-gaylord-submit') {
  node_form_submit($form, $form_state);

//do custom stuff here

}
}

Here's my problem: If the custom submit handler function is defined inside the hook_form_alter function & there are no unlimited cardinality fields, everything works great, node is created or modified, form values are saved, & my custom submit handler stuff is performed. If, however, I have a field with unlimited cardinality & my custom submit handler function is defined inside the hook_form_alter function, I receive an error: PHP Fatal error:  Call to undefined function inventory_stocking_ticket_form_gaylord_submit() in /hosting/somesite/com/htdocs/cms_sandbox/includes/form.inc on line 1464 & a white screen of death. If I move the custom submit handler function outside of the hook_form_alter, there's no error even with unlimited cardinality fields, the node is created or modified, & my custom submit handler stuff works, but field values are not saved.

I've further discovered that commenting out the code that creates the AJAX 'Add Another' button in core's field.form.inc makes everything work, even with the submit handler inside the hook_alter & unlimited cardinality fields. Of course there's no 'Add Another' button now, defeating the purpose of having unlimited fields.

I have two questions:

What is causing the conflict & PHP error when the submit handler inside the hook_form_alter is combined with unlimited cardinality fields?
Why won't the custom submit handler save field data when it is defined outside of the hook_form_alter?

If I could solve either of these problems I'd have what I needed. Any help is hugely appreciated.


texts:
I have 2 Content Types: Activity and Event.
For each of Event node, there will be an Entity Reference field which References Activity Node.
Example:
Event:

Title: Hiking in Utah
Activity: Hiking (Entity reference field referencing Activity node hiking)

I am Referencing Activity In an Entity Reference Field in Event Content type...
How can we use "Referenced Entity" within Views and make them available as Exposed Filters ?
In the end I want the Referenced Entities to be visible in a Dropdown field and filter results on selection.
I've had a look at EVA, but i am unable to understand if that can be used to accomplish this.


texts: Backup an enterprise application server and restore

texts:
What is the best practice to back up a server running Drupal?
I have backed-up server A, and I want to restore it on server A using server B (both are not on same network).
On both server I have Windows Server 2008, and for backup I am using "Windows server backup."


texts: Show and require field if birthday (date field) is less than 18 years old

texts:
I have a field that should be visible and required if the user selects a date that would make them less than 18 years old. If they are over 18, the field should be hidden and not required. Right now, I am using this:

In birthday.js:

(function ($) {

$(document).ready(function() {
    $('#edit-field-minor-agreement').hide();
});

$(document).on('change', '#edit-field-dob-und-0-value-year, #edit-field-dob-und-0-value-month, #edit-field-dob-und-0-value-day', function() {
    var yyyy = $("#edit-field-dob-und-0-value-year").find(":selected").val();
    var m = $("#edit-field-dob-und-0-value-month").find(":selected").val();
    var d = $("#edit-field-dob-und-0-value-day").find(":selected").val();

    if ( $('#edit-field-dob-und-0-value-year').val() && $('#edit-field-dob-und-0-value-year').val() && $('#edit-field-dob-und-0-value-year').val() ){
        dateString = m + "/" + d + "/" + yyyy;
        var today = new Date();
        var birthDate = new Date(dateString);
        var age = today.getFullYear() - birthDate.getFullYear();
        var m = today.getMonth() - birthDate.getMonth();
        if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
            age--;
        }
        console.log("Birth date: " + dateString);
        console.log("Age: " + age);
    }

    if(age<18) {
        $('#edit-field-minor-agreement').show();
    } else {
        $('#edit-field-minor-agreement').hide();
    }

});
})(jQuery);

It is successfully setting the visibility, but I can't seem to figure out how to make it required. Any help is appreciated.


texts: Date token to use user timezone instead of site timezone

texts:
Our site is having users from different timezones and we are sending event notification emails using rules. We need to specify the event date-time in addressee's timezone.

So, is there any way to specify the the timezone within/along with date-time token?

Or, should I introduce a custom token for this purpose?


texts: How to have a content type that displays a title, a description and a list of feeds imported from an external URL such as blogspot?

texts:
I know this is already discussed, I read many answers, but I am unable to make this simple operation.

I want a content type that displays a title a description and a list of feed items from an external URL that user can set when creates this content type node.

Ok, I installed feeds module, created an importer.
Before this I created a content type named "blogger" (for test only).
So I created an importer also named "blogger" and I attached to "blogger" content type.

Then I set fetcher as http download and parser to rss.
Now, in processor settings I can see bundle that are my content type installed, so I selected blogger, but I tried to select feed item, the result is the same.
In mapping I am confused: I tried to set all possible combinations; I set item guid as unique field.
I then create a node type of blogger content type, and I added URL of my blogspot page. I named this node "test page".
When I view "test page" I can't see feed items that are imported.
Drupal creates 25 node of "blogger" type, that are my feed items, but I don't want this.

Now, I wrong something in settings of feeds module? Or feeds module is not my way?

I only want see my blogspot items all in my test page; that's it...

Can anyone help me?


texts: Checking for existence for a field on an an entity_metadata_wrapper

texts:
I am iterating through a field collection, and wrapping the field collection items with an entity_metadata_wrapper. I would like to check for the existence of field before calling its value method (which results in an error on fields that do not have a value), but I cannot find a way to do so.

$field_collection_item = field_collection_item_load($id);
$item_wrapper = entity_metadata_wrapper('field_collection_item', $field_collection_item);

// this results in an error if the field_contrib_headshot field is empty
$headshot = $item_wrapper->field_contributor->field_contrib_headshot->value();

My current workaround is to use field_get_items to see if the field is empty, but i'd love to be able to do this through the metadata wrapper if possible.


texts:
Has anyone managed to get Pressflow built into a Vagrant box? I'm new to vagrant and am completely failing at this. Have looked into both Puppet and Chef to configure it (either would be fine) and can't seem to find a recipe that does the trick.

This example.make file seems to describe a way to do this with Puppet, but then I have the added complexity of putting Drush on the vagrant box and I'm not really even sure what to do with the ".make" file.

Any pointers are appreciated - thanks!

EDIT:

Here's the state of my Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant::Config.run do |config|

 # Every Vagrant virtual environment requires a box to build off of.
 config.vm.box = "quetzal64"

 # Boot with a GUI so you can see the screen. (Default is headless)
 # config.vm.boot_mode = :gui

 # Forward a port from the guest to the host, which allows for outside
 # computers to access the VM, whereas host only networking does not.
 config.vm.forward_port 80, 8080
 config.vm.forward_port 3036, 3037

 # somehow specify to use drush, puppet, and the example.make file?

end

and example.make:

; Core version
; ------------
core = 6.x

; API version
; ------------
api = 2

; Core project
; ------------
; Use Pressflow instead of Drupal core:
projects[pressflow][type] = "core"
projects[pressflow][download][type] = "file"
projects[pressflow][download][url] = "http://launchpad.net/pressflow/6.x/6.15.73/+download/pressflow-6.15.73.tar.gz"


texts:
I'm writing a custom module, and I need it to upload an image. I'm having trouble finding good documentation on this, but I think I'm close.

What am I missing? $file returns false in the form submission.

function mymodule_custom_content_block_form($form_state){
    $form = array();
    $form['custom_content_block_text'] = array(
        '#type' => 'textarea',
        '#title' => t('Block text'),
        '#default_value' => variable_get('mymodule_custom_content_block_text'),
        '#required' => true,
    );
    $form['custom_content_block_image'] = array(
        '#type' => 'file',
        '#name' => 'custom_content_block_image',
        '#title' => t('Block image'),
        '#size' => 40,
        '#description' => t("Image should be less than 400 pixels wide and in JPG format."),
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Update'),
    );
    return $form;
}

function mymodule_custom_content_block_form_submit($form, &$form_state){
    if(isset($form_state['values']['custom_content_block_image'])){
        $validators = array('file_validate_extensions' => array('jpg jpeg'));
        $file = file_save_upload('custom_content_block_image', $validators, 'public://');
        if($file == false){
            drupal_set_message(t("Error saving image."), $type = "error", $repeat = false);
        }
        else{
            $file->status = FILE_STATUS_PERMANENT;
            $file = file_save($file);
        }
    }
    variable_set('mymodule_custom_content_block_text', $form_state['values']['custom_content_block_text']);
    drupal_set_message(t('Custom Content Block has been updated.'));
}


texts: Adding thumbnails to bottom of page in drupal 7

texts:
I'm trying to add a bunch of thumbnails to the bottom of my page (footer or page bottom), the thumbnails come from article posts, or even forum posts.

I have enabled views, and set it up as a block at the bottom of the page. When I preview the view on admin/structure/views/view/thumbnails3/edit/block%3Fdestination%3Dnode it displays the thumbnails how I want, but on the actual page it displays the title without thumbnails.

I'm using Drupal 7, and I have created a Zen sub-theme. Also, this is just locally on my computer using xampp at this stage.

Why doesn't the page show the thumbnails?


texts:
I need a way to localize menu Items pointing to Views in a menu that has field translation.

I cannot create them neither from views nor manually (weird access denied messages).

EDIT: Here comes the original post. The title was "Translate the main menu with preserving English in case the translation is missing". I learned a thing or two in the process ;-)

I think I am doing something basically wrong...
I have set up a basic multilingual site with fields (entity) translation. Now, all works fine up to the menus. If I translate the menus, however, only the menu links that have actually been translated show up in the other languages. What's more, the menu structure does in other languages does not preserve the weights of the particular links.
What I'd like is to happen is:

English (or other provided) menu link show up when no translation is available.
The translated links preserve the weights.

Settings the menu links to "language neutral" solved the issue to a point. I cannot apply this practice, however, to views. Menu Items from views have English by default. What's more, when I remove the menu item in Views menu and try to make a  menu item that points to it by path, I get:

  You are not authorized to access this page.

Any ideas?


texts: Add product to the cart with attached custom line items

texts:
I need to add a product with some additional custom line items programatically. The source for the custom line items are text fields.

This is my code used in submit function

    function my_add_to_cart_form_submit($form, &$form_state) {
      global $user;
      $product_id = $form_state['values']['product_id'];

      // Put the product in the cart
      $order = _create_order_with_product($product_id, $user->uid, TRUE);

      // The code below has to add custom line items, but does not.

      // Create empty line item
      $line_item = commerce_line_item_new('product', $order->order_id);
      $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
      $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);

      // Set Line Item Label
      $line_item_wrapper->line_item_label = t('Custom Line item');

      // Set quantity
      $line_item_wrapper->quantity = 1;

      // Set Line Item price
      $line_item_wrapper->commerce_unit_price->amount = '400';

      // Set Line Item currency
      $line_item_wrapper->commerce_unit_price->currency_code = 'USD';

      // Save price data
      $line_item_wrapper->commerce_unit_price->data = commerce_price_component_add(
        $line_item_wrapper->commerce_unit_price->value(),
        'base_price',
        $line_item_wrapper->commerce_unit_price->value(),
        TRUE,
        FALSE
      );

      // Save the item in DB
      commerce_line_item_save($line_item);

      // Add to the order.
      $order_wrapper->commerce_line_items[] = $line_item;

      // Save order again
      commerce_order_save($order);

    }

    function _create_order_with_product($product_id, $uid, $use_cart = TRUE) {
      $order = commerce_cart_order_load($uid);

      if (empty($order)) {
        $order = commerce_order_new($uid, 'checkout_checkout');
        commerce_order_save($order);
      }

      $product = commerce_product_load($product_id);
      $line_item = commerce_product_line_item_new($product, 1, $order->order_id);
      commerce_line_item_save($line_item);

      $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
      $order_wrapper->commerce_line_items[] = $line_item;

      commerce_order_save($order);
      return $order;
   }

So now I have the following result:

1) On "/cart" page fatal error:

  EntityMetadataWrapperException: Unable to get the data property
  product_id as the parent data structure is not set. in
  EntityStructureWrapper->getPropertyValue() (line 442 of
  C:\wamp\www\work2\sites\all\modules\entity\includes\entity.wrapper.inc).

2) Product and custom line items saved in DB

3) No orders available on "admin/commerce/orders" page

Please help to understand where is mistake.


texts: Cron is not working - leading to user/0/edit instead

texts:
When I was trying to migrate my site and export the database I realised that the cache_form field is enormous. According to suggestions I have found online the proper way to solve this is to run cron. So I try to run cron by going to the admin/config/system/cron page, and in there it said that cron was last run 3 weeks ago.

When I press run cron or when I visit the link with the cron key provided in that admin/config/system/cron page, they have both led me to user/0/edit instead of running cron. I did a quick search among the files I have made changes to in the site directory in these three weeks and none of them are leading to user/uid/edit. I wonder what else can I do to solve this properly?

Thanks!


texts: Are there any other modules that can implement the same functionality as Nodequeues i.e, making a customized list of selected nodes? I think I might be having some problems which might be related to it's permissions (I'm not sure of it as I'm still novice at Drupal). Maybe it's because it is still in beta phase for D7, I don't know...


texts: Views not sorting scandinavian characters correctly

texts: I have created a view and applied sorting on the title field. When a title starts with the characther "å" it shows up before "a" even though its supposed to come last. The view is set to sort ASC. First i thought this was all connected to the table collation in mysql so i changed to "utf8mb4_danish_ci" and now when i do a select statement with order by directly in phpadmin i get the desired result. However when i go back to my view "ås" still comes before "at" even though its shows correctly when i do the select statement on the database directly. It seems like Drupal/views is doing something behind the scenes here, i dont know.. Anyone?


texts: How come javascript:void(0) is creating a 404 page?

texts:
We have a need to have an  to have href="javascript:void(0);" so that some action can take place on the page without refreshing the page. HOwever, this is generating a 404 page and we need assistance in how to best get rid of the 404 but also keep the functionality so that the action can take place without page refresh.

Code in question:

Some action


texts: Redirect user to order completion after successful offsite payment

texts:
On my order_information page I have a Paypal Express checkout button.  Using this hacked together route, I can successfully save the payment, apply it to the order, and then move the order to complete:

public function onReturn() {
  $method = $this->requestStack->getCurrentRequest()->getMethod();
    if ($this->requestStack->getCurrentRequest()->getMethod() == 'POST') {
      $request = $this->requestStack->getCurrentRequest();
      $test = $request->get('test');
      $data = $this->requestStack->getParentRequest()->query->all();
      $carts = $this->getCarts();
      $payment_method_storage = $this->entityTypeManager()
        ->getStorage('commerce_payment_method');

      // @todo can't be right
      /** @var Order $order */
      $order = array_pop($carts);
      $order->set('payment_gateway', $this->paymentGateway);
      try {
         $this->paymentPlugin->onReturn($order, $request);
      } catch (PaymentGatewayException $exception) {
        // do something - like cancel moving the order into complete state.
      }
      // I prefer the "throw-it-all-at-the-wall-and-see-what-sticks" method
      $transition = $order->getState()->getWorkflow()->getTransition('place');
      $order->getState()->applyTransition($transition);
      $order->save();
      throw new NeedsRedirectException(Url::fromRoute('commerce_checkout.form', [
        'commerce_order' => $order->id(),
        'step' => 'complete',
      ])->toString());
    }
  }

The flow here is:

User clicks paypal express button
paypal modal opens, user completes payment, modal closes
paypal executes the callback (hitting this onReturn)
payment is applied to order
order is moved to complete
user is still on order_information page.

There are some obvious gaps here (hard coded stuff, not sure how to deal with carts, what if payment isn't paid in full) but what I'm trying to solve right now is: how do I move someone to the order complete page? (or any other page for that matter).

The throw is only my latest attempt, I've tried redirecting to the CartController and returning RedirectResponse - just can't get it to move :).


texts:
I'm running Drupal in an intranet which is behind a simple HTTP proxy. I'd like for the module and core update checks to actually work.

I seem to remember there was a core hack to do this on Drupal 6, but I can't find the page anymore.

Does anyone know how I can get this working?


texts: Form #ajax event keyup do not leave me to type

texts:
Using Drupal form with ajax looks good and works fine, but when I change ajax event to keyup it would not let me typing, it will blur the textfield after I type a first letter. Why?
Please anyone came with a solution, the idea is to update the database in real time while typing.
Here is a part of my code:

$form['second']['schulbuch_fieldset']['firstname'] = array(
    '#type' => 'textfield',
    '#title' => t('firstname'),
    '#value' => $data->firstname,
    '#validate' => array('second_submit'),
    '#ajax' => array(
        'callback' => 'second_callback',
        'event' => 'keyup',
    ),
);

function second_submit ($form, &$form_state) {
    $nid = db_update('student_data')
        ->fields(array(
            'firstname' => $form_state['input']['firstname']
        ))
    ->condition('id', $form_state['build_info']['args'][0])
    ->execute();
    $form_state['rebuild'] = true;
}
function second_callback ($form, &$form_state) {
    $commands[] = ajax_command_replace('#fieldset-schulbuch', drupal_render($form['second']['schulbuch_fieldset']));
    return array('#type' => 'ajax', '#commands' => $commands);
}


texts:
I have an custome made entity

  function sbsl_order_entity_info() {
    $entitys = array();

    $entitys['sbsl_delivery_information'] = array(
      'label' => t('Delivery information'),
      'controller class' => 'EntityAPIController',
      'base table' => 'sbsl_delivery_information',
      'fieldable' => TRUE,
      'entity keys' => array(
        'id' => 'delivery_information_id',
        'bundle' => 'bundle',
      ),
      'bundle keys' => array(
        'bundle' => 'bundle',
      ),
      'bundles' => array(),
      'load hook' => 'sbsl_order_delivery_information_load',
      'view modes' => array(
        'full' => array(
          'label' => t('Full content'),
          'custom settings' => FALSE,
        ),
      ),
    );

    return $entitys;
  }

I want to attach a form to my widget with field_attach_form

but can't figure out where i should define the form elements


texts: Add Commerce Checkout progress bar and extra stage

texts:
I believe as such there is no template file for checkout? So how I want to add the following graphical navigation to the top of commerce checkout?

Can i target checkout with a page.tpl.php? Alternatively a hook in template.php?

At each stage/page of checkout the navigation images will change.


texts: Display all nodes with identical field value to current node

texts:
BACKGROUND:
Site is using content types which are auto-created through Rules, called CT-A and CT-B. CT-B represents a full URL, and CT-A represents that URL domain. CT-A is always created via Rules only once, the first time a content type CT-B is created. Both content types share a field (field_domain) specifying the domain. The original content is user entered, so it isn't possible to predict the value of field_domain in advance.

ISSUE:
I need to display a simple 'related content' type view in CT-A, showing all nodes of type CT-B which match the value for field_domain. The value for field_domain cannot be pre-defined, and needs to be provided program / systematically, either by being taken from the field in the node, or as a token (same difference).

APPROACHES:
I am assuming the answer is in Views. Specifying a value for field_domain doesn't work, because the value changes based on user entry. I've tried Global: Field Comparison, but it doesn't seem to be possible to compare both the current node's field_domain and that same field in the nodes displayed in Views. I have tried using Views Panes to pass the argument for the current node's field_domain into the pane display, but it also didn't return results. I have seen various Contextual Filter PHP solutions, but they also don't seem to work (the most promising one is https://www.drupal.org/node/1006484#comment-4990312 , but this returns the following error: https://www.drupal.org/node/829250).

Taxonomy hasn't worked, because of the auto-create nature. It doesn't seem to be possible to create unique TermID by passing values in Rules - the Term name will be the same, but the TermID is different, and Views judges the Term based on its ID. It isn't possible to auto-create a Term Vocabulary in Rules due to a bug with assigning the machine name.

Entity Reference also has problems with the auto-create nature. I haven't figured out a way in Rules to reference the two types according to field_domain value, and not sure if there is one.

Search API Tried this approach (compare the search index) suggested in the link below, but again it doesn't work unless you have a predefined value for field_domain, as it requires setting the value manually.

The most obvious approach seems to be "Views filter display all nodes with same field value. But despite being obvious, this doesn't seem to be easily possible. Perhaps there is a non-Views way which I haven't considered?

Related questions to this (all seem to be unsolved):

[apologies, I'm limited by reputation...but there are at least 4 open questions in related questions to the right which are still unsolved]

Throwing it open...seems like a few people have run up against this problem. Any new ideas out there?


texts:
EDITED: This has been altered to include the code suggested by Dooshta.

I need to fill a computed field with the average value of all entries in a certain field, and only from nodes that have a specific node reference field.

What I have right now in my Computed Field is:

$nids = db_query('
  SELECT entity_id FROM {field_revision_field_venue_reference_review}
  WHERE field_venue_reference_review_target_id = :nid',
  array(':nid' => $entity->nid)
)->fetchCol();

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

This is working, and displays the correct average from the correct nodes. However, I get a PODexception error on some pages that do not include the above code. This is confusing to me, because it seems that if there is bad syntax, then I should get the error on the page using the code as well as pages not using the code, right? Either that or it just shouldn't work.

As requested by Booshta, here are screenshots of the tables I'm querying.
The first is the table containing the entity reference field in the $nids part of the query

The second is the table containg the values being averaged in the $entity_field part of the query


texts: Show a field on a taxonomy term in views

texts:
I have a view that's showing a custom entity type. Each of these entities is categorized with taxonomy term. Terms in this vocabulary have a field on them that I need to pull in to my view.
Currently, I'm able to see each unique term showing up for each entity. For instance, if "Entity 1" is showing:

red
blue
orange

However, I need to be able to re-write the results of these terms with a field on each term so that I'll get:

red (red_field_value)
blue (blue_field_value)
orange (orange_field_value)

I added a relationship to that term but I'm only getting:

red (red_field_value)
blue (red_field_value)
orange (red_field_value)

What am I doing wrong?


texts: Link a Page to another Page using Views and taxonomy

texts:
I have a Page created using a View using a Content Type called Sectors, which displays rows of images with a title underneath the image. The Sector content type has the fields - Title, Image, Sector Category (uses a Taxonomy). A Sector can have many Projects.... so.....

When the user clicks on the Sector Image or Title, i want my site to go to another Page which is created using a View and display all the Projects belonging to that Sector using the Sector Category field (which is a field on both Sector and Projects content type, passed to it from the previous Sectors page), to select all the Projects that are held in the Projects Content Typle - which has fields Title, Image, Sector Category.

How can I link the 2 views?


texts:
I'm trying to figure out how I can remove the default css libraries of Drupal 8 on the theme I'm working on. I tried using libraries-override: to remove a specific CSS but it doesn't seem to be working. The css file is still showing. As you can see the align.module.css is still showing on Google Network Tab. I'm not sure if the method I'm using is deprecated or incorrect

name: Barebones
description: Drupal light
type: theme
core: 8.x

base theme: stable

libraries-override:
  system/base:
    css:
      component:
        /core/modules/system/css/components/align.module.css: false

libraries-override:
  system/base: false


texts: Views_embed_view fatal error in views.inc

texts:
I'm getting this error when I embed a view on a page. It doesn't happen when I preview the view in views UI.

"recoverable fatal error: Object of class stdClass could not be converted to string in views\includes\view.inc on line 728."

This is my embed code:

<?php print views_embed_view('list_applications_for_reviewer', 'block_1', array(85, 229)); ?>

I don't have this problem in any of the other views on my site, of which there are many doing similar things.

Any ideas what I might need to fix?


texts: How do I prevent rewritten views field output from having ":" stripped out of the  sizes attribute?

texts:
I'm working on advanced responsive images in a Drupal 8 view, designed to suggest showing different images at various screen sizes around the Bootstrap theme.

Is there a way I can prevent everything up to the ":" from being stripped/filtered out in my views field output sizes attribute?

My views field rewrite looks like this:

It renders for the most part. However, the resulting html looks like this:

<img src="/sites/default/files/styles/product_listing_lg/public/products/2017-01/IMG_0196.JPG?itok=pUdgY8n9"
srcset="/sites/default/files/styles/product_listing_lg/public/products/2017-01/IMG_0196.JPG?itok=pUdgY8n9 1w,/sites/default/files/styles/product_listing_md/public/products/2017-01/IMG_0196.JPG?itok=t7jNSmMk 769w,/sites/default/files/styles/product_listing_sm/public/products/2017-01/IMG_0196.JPG?itok=NH8p7qki 993w,/sites/default/files/styles/product_listing_xs/public/products/2017-01/IMG_0196.JPG?itok=feCEjmRl 1201w"
alt="black and gold variegated infinity scarf (wrapped, front)"
sizes=" 993px) 25vw"
class="img-responsive">

sizes attribute in rewrite:

sizes="(min-width: 0px) 100vw, (min-width: 769px) 50vw, (min-width: 993px) 25vw"

sizes attribute output:

sizes=" 993px) 25vw"

I seem to have the same challenge whether I'm rewriting an image field or specifying replacement patterns in a global text area.

I haven't explored any preprocess or twig template options yet. Is this something I need to resolve outside of views UI to prevent the filtering? What's the best way to proceed?


texts: How do use hook_views_pre_render() to modify view fields

texts:
Want to use hook_views_pre_render() to modify a field in view based upon data in another field. Starting with this code:

function sbn_views_pre_render(ViewExecutable $view) {
  drupal_set_message($view->id());
    foreach ($view->result as $key => $value) {
    // How do I select fields I need?
    }
}

What I don't know how to do is select the fields I want to work with from the $view object.

Some of the things I've tried so far:

kint($value->_entity->get('id')->value);

drupal_set_message($value->_object->get('id')->value);

drupal_set_message($value->get('id')->get(0));

drupal_set_message($value->get('parent_id')->getValue()['0']['value']);

Can someone tell me, or point me to documentation which will explain?

Thanks!


texts: Processing data sent from drupal 7 webform

texts:
I've inserted a webform in a node's template like so:

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

and created the webform in the admin panel for that page. The form shows up fine and I've styled it correctly. I would now like to know the Drupal way of grabbing the data from the form. Most likely a preprosses function from what I've researched.

The form is very simple, just an email address and a submit button. I'm good with PHP but still getting used to drupal's backend functionality.  Any help or direction is greatly appreciated. Cheers!


texts: add new format to description fiield of taxonomy display modes

texts:
when you go to structure -> taxonomy -> VOCABULARY_NAME -> manage display
you will find the description field with no label, and with two available format : hidden and visible.

I want to add new format to this field (exactly I want add the "trimmed" format) like existing in manage display of nodes...

I used the custom_formatter module, but it didn't do the trick, because the description field is of type "Term description textarea", and custom_formatter use text, text_long... types.
I used some hooks to change how this field is displayed but no luck

any help will be appreciated
thanks in advance.


texts: Is it possible to use ajax inside the html output of a computed field?

texts:
I tried making a simple computed field that outputs some html that can be latter modified with Ajax. If we consider a typical hello world example, the computed field output would be a link saying 'say hello' and when you click on it the AJAX adds the text 'hello world' in the div below the link. This is based on a javascript/ajax example inside 'Drupal 7 Module Development' by Matt Butcher. It works inside a normal page, but inside a computed field it gives an error.

Here is the code for my computed field. It just creates a link which is ajax enabled and a second div where ajax content will be inserted.

drupal_add_js('misc/ajax.js');
$link = l(t('Say Hello'), 'hello_world_link_callback/ajax/', array(
           'attributes' => array('class' => array('use-ajax'))));
$output = '
' . $link . '

';
$entity_field[0]['value'] = $output;

Implementation of hook_menu() to create the AJAX callback function:

$items['hello_world_link_callback'] = array(
    'page callback' => 'hello_world_link_response',
    'access callback' => 'user_access',
    'access arguments' => array('access content'),
);

Here is my callback function:

function hello_world_link_response($type = 'ajax') {
    if ($type == 'ajax') {
        $output = t("Hello World!");
        $commands = array();
        $commands[] = ajax_command_append('#saying-hello', $output);
        $page = array('#type' => 'ajax', '#commands' => $commands);
        ajax_deliver($page);
    }
    else {
        return t("Hello World in a new page.");
    }
}

When I click the link it crashes to a white screen with this text:

[{"command":"settings","settings":{"basePath":"/drupal/","pathPrefix":"","ajaxPageState":{"theme":"bartik","theme_token":"fN8xkldpLQAwubNZ1n0BzdQPnF577BDw6sfuzoVrcmw"},"overlay":{"paths":{"admin":"node/*/maestro\nnode/add/*/maestro/*\nnode/*/edit/maestro/edit/*\nmaestro/trace/*/*/*\nnode/*/edit\nnode/*/delete\nnode/*/revisions\nnode/*/revisions/*/revert\nnode/*/revisions/*/delete\nnode/add\nnode/add/*\noverlay/dismiss-message\nuser/*/shortcuts\nadmin\nadmin/*\nbatch\ntaxonomy/term/*/edit\nuser/*/cancel\nuser/*/edit\nuser/*/edit/*\ndevel/*\nnode/*/devel\nnode/*/devel/*\ncomment/*/devel\ncomment/*/devel/*\nuser/*/devel\nuser/*/devel/*\ntaxonomy/term/*/devel\ntaxonomy/term/*/devel/*","non_admin":"admin/structure/block/demo/*\nadmin/reports/status/php"},"pathPrefixes":[],"ajaxCallback":"overlay-ajax"}},"merge":true},{"command":"insert","method":null,"selector":null,"data":"","settings":null},{"command":"insert","method":"prepend","selector":null,"data":"","settings":null}]

Any ideas?

Updated based on comments from tenken

I've altered hook_menu to be a callback only and set the delivery callback to be an ajax response. I've also split the hook_menu into items for the cases with and without ajax. So the hook_menus now look like this:

$items['hello_world_link_callback/nojs'] = array(
    'page callback' => 'hello_world_link_response',
    'access callback' => TRUE,
    'access arguments' => TRUE,
    'type' => MENU_CALLBACK,
    'page arguments' => array(1),
);
$items['hello_world_link_callback/ajax'] = array(
    'page callback' => 'hello_world_link_response',
    'access callback' => TRUE,
    'access arguments' => TRUE,
    'type' => MENU_CALLBACK,
    'delivery callback' => 'ajax_deliver',
    'page arguments' => array(1),
);

The callback function is unchanged from above with the exception that it now returns the AJAX commands, rather than calling 'ajax_deliver'. So it returns:

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

This code is now working for me, so it had nothing to do with the fact that it was a computed field. This code is also covered here.


texts: How can I distinguish the first image in an image field in a Twig template?

texts:
I have a custom field formatter for an image field. The Twig template for the image field is the following:

{% for item in items %}
  {{ item.content }}
{% endfor %}

Each image is then formatted by the following template:

But what I want to do is to format the first image of the field in a different way. I found how I could change the for loop in the template and use loop.first to treat the first image differently. But the formatting I want to change is in the inner template that formats each image, the one I call with item.content. In the outer template for the entire image field I can distinguish the first image, in the inner template I have no idea how to check for that or how to transfer that information from the outer to the inner template.

Any idea on how I can solve this and format only the first image in a different way?


texts: automatically fill the field info based on user selected

texts: I have content type "A" and I have field_users, and field_mail, where in the fields_users is entity reference field referring node of users, now when we select the user from the select list automatically the field_email should update based on the user selected since the user already created in D7.Is there any way to achieve this?


texts: Programatically render block with contextual links (in php)

texts:
I'm trying to find a solution to embed a drupal custom block using PHP. I found this snippet that works :

<?php
$block = \Drupal\block\Entity\Block::load('your_block_id');
$render = \Drupal::entityTypeManager()->getViewBuilder('block')->view($block);
print render($render);
?>

The problem is that this code directly render the block content, I don't have any contextual links for that block. My question is, how to render the whole block (including contextual links), exactly like if I added it in a region using the UI.

Thank you


texts: search block form not accepting special characters in drupal 7

texts:
If I search with any special character in drupal default search block form it returns error message like "You must include at least one positive keyword with characters or more.".after i do search with letters or numbers it does not bring results.shows same error.the form has been submitted but value does not change.
Any help appreciated..


texts: Add fields from another form to a existing form in a widget

texts:
I am trying to build a module that provides a widget.
The widget is based on FileWidget and I would like to add some fields from another form to the existing FileWidget form.
I would like to save the content of these fields after submit of the parent form.

So I loaded the form, from which I want to add some elements, in my widgets process method, with
\Drupal::service('entity.form_builder')->getForm($entity) but I am having troubles extracting specific field elements.
If I add a new form element, let's say a textfield, it works as intended and I can access the user input of this field in hook_entity_presave, but sadly not with elements from an existing form.

In Drupal 7 this could be done with the function field_attach_form() but this is not possible anymore.

Is there a clean way in Drupal 8 for this?


texts: Views 3 and HTML5 - how to override output for markup?

texts:
I have a view that I've created that selects blog posts based on a specific taxonomy term, creating a sort of "Featured Posts" view that I've embedded on the front page of my site. The issue I keep running into is trying to output the view so that each post is semantically marked up using some of the new HTML. I've tried the built-in "Rewrite this field's output", but it ignores the tags I use (ie, article, header, footer) and wraps everything in divs even when I deselect the placeholder tags.

Should I create a overriding views--view_name.tpl.php to rewrite the output of each post as it appears in the view, or do I need to use preprocess hooks in the template.php to affect the output?

I should state that I have basic experience with writing PHP and preprocess hooks, but I can any resources I need to move me down the linke if I'm pointed in the right direction.


texts:
I need a way where someone can visit multiple nodes, add them to a list, and email them in a batch / list to a person.  I've looked at ShareThis and AddToAny, and each would seem to do a fine job for a single page, but I need to be able to collect an arbitrary number of pages and then forward them via email when the client is done creating the list.

The "use case" is that a salesman will visit a store, select 3 or 4 items on an iPhone / iPad that they would like to send more information on, and use Drupal to create the list and send the email.

I'm trying to avoid custom coding a solution because my skills are not quite up to the task, and as with everything, deadlines are tight.


texts:
I'm still not comfortable writing sql queries. As i'm pretty new to drupal module writing.

Are there any potential issues with using views to generate a sql query? In terms of security or future considerations?

Example:
Generate a form dropdown on the usermenu of number of users by role.

Grabbed this query via creating a view

  $query = "SELECT users.uid AS uid,
   users.mail AS users_mail,
   users.name AS users_name
   FROM users users
   INNER JOIN users_roles users_roles ON users.uid = users_roles.uid
   WHERE users_roles.rid = 7";

Convert database object into array:

while ($user = db_fetch_object($result)) {
  $reps[$user->uid] = $user->users_name . ' - ' . $user->users_mail;
}

Spit out the options and create a form dropdown:

// Generate output of all the client reps
$form['Business']['profile_txi_account_rep']['#options'] =  $reps;


texts: Drop-down select instead of selection box in custom field widget

texts:
I am creating a custom field for phone numbers. The field creates a phone record that contains the type of phone contact (work, home, etc), as well as the number and an extension... much like Apple's "Contacts" app.

The problem I am having is for the phone type drop-down list. Instead of showing a nice drop-down select list like this example of a publishing status...

I end up with a selection box like this...

Here is what my hook_field_widget_info() looks like...

/**
 * Implements hook_field_widget_form().
 */
function MYMODULE_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

  $element['label'] = array(
    '#type' => 'select',
    '#options' => drupal_map_assoc(array(
      t('home'),
      t('work'),
      t('main'),
      t('mobile'),
      t('other'),
    )),
    '#size' => 12,
    '#default_value' => isset($items[$delta]['label']) ? $items[$delta]['label'] : 'home',
  );

  $element['number'] = array(
    '#type' => 'textfield',
    '#title' => t('Number'),
    '#size' => 16,
    '#default_value' => isset($items[$delta]['number']) ? $items[$delta]['number'] : '',
  );

  $element['ext'] = array(
    '#type' => 'textfield',
    '#field_prefix' => t('ext'),
    '#size' => 6,
    '#default_value' => isset($items[$delta]['ext']) ? $items[$delta]['ext'] : '',
  );

  $element['primary'] = array(
    '#type' => 'ckeckbox',
    '#default_value' => isset($items[$delta]['primary']) ? $items[$delta]['primary'] : 0,
    '#return_value' => 1,
  );

  return $element;
}

I can see how the selection box style select element can be useful for multiple selects, but this is just a single select. I'd like to see a drop-down element. I must be missing something here, but I haven't figured out what it could be. Any ideas?


texts:
Is there a way convert this static query in a dynamic query?

$sql = "SELECT n.nid, n.title, n.created, n.type, n.status, IF((SELECT nid FROM `newsletter_lists` WHERE cid=$cid AND nid=n.nid), TRUE, FALSE) AS included FROM `node` AS n
  LEFT JOIN `newsletter_lists` AS nl ON n.nid = nl.nid";

This is what I have, but it throws errors.

$query = db_select('node', 'n')
  ->fields('n', array('nid', 'title', 'created', 'type', 'status'))
  ->extend('PagerDefault')
  ->limit(5);

$subquery = db_select('newsletter_lists', 'snl')
  ->fields('snl', array('nid'))
  ->condition('cid', $cid)->condition('nid', `n.nid`)
  ->execute();

$query->addExpression($subquery, 'included');

return $query->execute();


texts:
Let's say some people are working on a contrib module (link) to provide some obvious template suggestions which are not covered by the default Twig Template naming conventions. View mode for fields, region for blocks etc.

Out of habit I'd use hook_theme_suggestions_HOOK_alter. I simply add my suggestions following some logic, done.

  This hook allows any module or theme to provide alternative theme
  function or template name suggestions and reorder or remove
  suggestions provided by hook_theme_suggestions_HOOK() or by earlier
  invocations of this hook.

Then I see there's hook_theme_suggestions_HOOK which more or less does the same except for reordering or removing suggestions. But basically looking at its description it does exactly what that contrib module is supposed to do.

  This hook allows modules to provide alternative theme function or
  template name suggestions.

And now I'm wondering which one of these hooks should be used at best? Is it totally up to us? Do there arise any disadvantages of using the *_alter hook? Do we better use the mere suggestion *_HOOK to allow other modules to intervene later in the process?


texts: Send e-mail when a field has a specific value

texts:
I use the Workbench moderation module for Articles workflow. I would like to send an e-mail when Workbench moderation field has the needs review value.

I tried using the Rules module, but I don't know how to select this field and compare data. How do I get the value of the Workbench moderation field in a rule?


texts: Internal relative links in Menu by using http:/alias/path/to/link

texts:
In Drupal 7.22, I would like to link create an additional link to an existing node from with in a menu. This target node already has an alias and its own menu entry. I'd like to create an additional link to that node. I thought the method would be to enter the url as http:/alias/path/to/link. However, this seems to fail.

If you notice from the devel_themer output that the path contains http:/contact. My hope that this link resolves to http://mysite/contact.


texts: Error messages when running "drush verify-makefile" on a generated make file

texts:
When running the following command, Drush is printing a number of error messages:

drush verify-makefile

There is only one make file in document root and it was created with:

drush generate-makefile drupal-org.make

There were no errors printed with generating the make file. All that is said was:

Wrote .make file drupal-org.make                               [ok]

I am trying to publish a new Drupal distribution on drupal.org. The particular error messages I am receiving are:

The project-level attribute 'custom_download' on project 'datasets' is not allowed. [error]
The project-level attribute 'custom_download' on project 'operations' is not allowed. [error]
The project-level attribute 'custom_download' on project 'quadstat' is not allowed. [error]

My guess is that these modules are not published on drupal.org so they can not be included with the distribution. It seems related to this Drupal.org issue: #1427762

Before I went and created these modules on Drupal.org, I was hoping someone could confirm my theory.

Also the syntax generated for the make file seems to follow YAML (a Drupal 8 convention) even though my Drush version is 8.1.2 and my drupalorg_drush version is 7.x-1.x-dev. My Drupal core distribution is 7.44.

I thought it may be helpful to include the make file too.

core: 7.44
api: 2
projects:
  admin_menu:
    version: 3.0-rc5
  ctools:
    version: '1.9'
  node_clone:
    version: '1.0'
  features:
    version: '2.10'
  field_group:
    version: '1.5'
  field_permissions:
    version: 1.0-beta2
  filefield_paths:
    version: 1.x-dev
  panels:
    version: '3.5'
  jquery_update:
    version: '2.7'
  libraries:
    version: '2.3'
  mathjax:
    version: '2.4'
  node_export:
    version: '3.1'
  nodeaccess:
    version: '1.4'
  text_with_summary:
    version: '1.0'
  uuid:
    version: 1.0-beta1
  views:
    version: '3.14'
  views_filters_populate:
    version: '1.1'
  shiny:
    version: '1.7'
  datasets:
    type: module
    custom_download: true
  operations:
    type: module
    custom_download: true
  quadstat:
    type: module
    custom_download: true
  libraries:
    SlickGrid:
      directory_name: SlickGrid
      custom_download: true
      type: library

There are some other unrelated error messages, but the ones I mentioned are the first that popup.

Thank you for any suggestions provided.


texts:
I am having difficulties in overriding the default PHP settings within my Drupal installation. I do not want Drupal to display E_NOTICE messages. So I wanted to override the default PHP error_reporting setting from E_ALL to E_ALL & ~E_NOTICE or from 2047 to 2039 (the corresponding error reporting values).

I added the line ini_set('error_reporting',  2039); in both sites/default/settings.php and sites/default/default.settings.php, but still when I go the status report page and view the PHP info file, I see the error reporting setting of PHP is still set to 2047. What am I doing wrong here? How to override the php setting?

PS: I even tried adding the line php_value error_reporting 2039 to Drupal's .htaccess file, but there is no effect.


texts: List nodes of children using taxonomy_select_nodes

texts:
I want to list nodes from children terms using or editing taxonomy_select_nodes function.
Actually I added these few lines but I get an infinite loop or slow response:

function taxonomy_select_nodes_ext($tid, $pager = TRUE, $limit = FALSE, $order = array('t.sticky' => 'DESC', 't.created' => 'DESC'),$promote) {
  if (!variable_get('taxonomy_maintain_index_table', TRUE)) {
    return array();
  }
  $query = db_select('taxonomy_index', 't');
  $query->addTag('node_access');
  $query->condition('tid', $tid);
  if ($pager) {
    $count_query = clone $query;
    $count_query->addExpression('COUNT(t.nid)');

    $query = $query->extend('PagerDefault');
    if ($limit !== FALSE) {
      $query = $query->limit($limit);
    }
    $query->setCountQuery($count_query);
  }
  else {
    if ($limit !== FALSE) {
      $query->range(0, $limit);
    }
  }
  $query->addField('t', 'nid');
  $query->addField('t', 'tid');

      // This block of code is the custom code I added.
      //SELECT only promoted article
      if($promote==1){
        $query->join('node', 'no', 'no.nid = t.nid');
        $query->condition('promote', 1);
      }
      $taxonomies=array();
      $taxonomies = taxonomy_get_children($tid);
      $taxonomies[]=$tid;
      $query->condition('t.tid', $taxonomies,'IN');

  foreach ($order as $field => $direction) {
    $query->orderBy($field, $direction);
    // ORDER BY fields need to be loaded too, assume they are in the form
    // table_alias.name
    list($table_alias, $name) = explode('.', $field);
    $query->addField($table_alias, $name);
  }
  return $query->execute()->fetchCol();
}


texts: Show only unread content; remove item once read or option to remove items

texts:
I require a view which only shows unread content or provides functionality to remove items listed in the view once the node has been accessed. Alternatively a "x" button to remove the items manually for users.

So for example a view would show article's 1, 2, 3 & 4.

Once I had visited article 1 & 4 the view would now only show 2 & 3.


texts:
I tried to run drush up on two front-ends (sharing a common database server). The first server went right and updated Drupal and modules just fine. But when I tried to run the same command on the second front end I just got:

Command pm-update needs a higher bootstrap level to run - you will   [error]
need to invoke drush from a more functional Drupal environment to run
this command.

Yes, I am on the same directory on both servers. And yes, the SITE works on the second front end (checked with change to hosts) so it surely gets connection to the database server.

If I run drush status the outputs are same EXCEPT FOR missing "Drupal bootstrap: Successful" and lines for Drupal user and two Theme lines missing. So any ideas how to start resolving this problem?

hank


texts:
I need to update my nodes created from my own module. The data is extract from my database external.

Now, I want to update this nodes via hook_cron.. My question is: What is the function that update nodes? Or the steps for do this?


texts:
I am writing my first test in Drupal 8's API and for some reason, I am unable to geocode.

When I run my code in a controller, it works fine, but when using a test, $addressCollection evaluates to false and I get the message 'The geocder returned FALSE'.

namespace Drupal\Tests\custom_tests\Functional;

use Drupal\Tests\BrowserTestBase;

/**
 * Test that Geocoder works
 * Source: https://deninet.com/node/1631
 *
 * Note: need to have Gecoder: Google Maps configured properly before testing.
 *
 * @group custom_tests
 */
class GeocoderModuleTest extends BrowserTestBase {

  /**
   * The modules to load to run the test.
   *
   * @var array
   */
  public static $modules = [
    'geocoder',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();

    // $this->geocoder = \Drupal::service('geocoder');
    $this->geocoder = $this->container->get('geocoder');

    /* Values tested for */
    $this->staticAddress = 'St Patrick\'s Close, Wood Quay, Dublin 8, Ireland';
    $this->staticCordinates = [
      'longitude' => 53.339529,
      'latitude' => -6.271501,
    ];
  }

  /**
   * Tests the setting form.
   */
  public function testForm() {

    $plugins = array('googlemaps');
    $address = '1 Centennial Square, Victoria, BC V8W 1P6'; // Victoria City Hall

    // $this->geocoder = \Drupal::service('geocoder');
    $addressCollection = $this->geocoder->geocode($address, $plugins);

    if ($addressCollection) {
      $this->assertTrue(TRUE);
      // $coordinates = $addressCollection->first()->getCoordinates();

      // /* Check the longitudes */
      // $this->assertEquals(
      //   $staticCordinates['longitude'],
      //   $coordinates->getLongitude(),
      //   'The latitudes didn\'t match',
      //   0.001);

      // /* Check the latitudes */
      // $this->assertEquals(
      //   $staticCordinates['latitude'],
      //   $coordinates->getLatitude(),
      //   'The longitudes didn\'t match',
      //   0.001);
    } else {
      $this->assertFalse(TRUE, 'The geocder returned FALSE');
    }
  }
}


texts:
I've done research and simply cannot find how to clear the images from the temporary folder on Drupal 7! I have a jQuery slider on my home page that pulls the five latest image files to display. I tried to upload a new logo through the edit theme but decided to delete it because it needed resizing. Now that logo file (but broken) is displaying in my slideshow and it's located under:

  "/system/temporary/styles/front_page_slideshow/temporary/Logo2.png"

I've tried everything and cannot find that folder and or how to clear it. I tried clearing all caches and running a cron job--no changes. Please help! I cannot have this issue on the production site.

*Edit
I'm using Acquia Dev Desktop to run the site. Under "File System" I saw that my temporary drupal folder is located in my

  C:\Windows\Temp directory

. SO I went there and found and deleted the image file, and ran a cron job... but the broken image is still showing up as part of my slideshow.


texts: How to make a reservation and a booking of seminars during the Commerce checkout process?

texts:
I have set up my first Drupal Commerce shop that works as it should with fixed booking ("selling") of seminars.

Now these seminars (realized as line items) must not only be booked ("sold") but must also be available for reservation. It is needed that booking and reservation has to be done during the checkout process, where only booked items must be paid.

My problem is now, that I do not know how to combine booking and reservation in one line item and also how to separate it during checkout process, as both need different information and also a variable amount of input fields, depending on number of participants.

Maybe someone can give me some hints how to do it - I am stuck at the moment ...


texts: How do I embed an "EVA" view display in a twig template?

texts:
I installed the "Twig Tweak" module for Drupal 8

I created an "EVA" display. The view id is "contenu_relation_groupe" and the display id is "entity_view_1".

I added the following in the twig template for my nodes:

{{ drupal_view('contenu_relation_groupe', 'entity_view_1') }}

But nothing is displayed. Any idea why?

I've never managed to embed an "EVA" view in a twig template.


texts: I'm trying to make node/add URL appear on front of site to anonymous user and when clicked, it redirects to login or register page. drupal hides links automatically, any help please. I'm using drupal 7


texts: How to create a chart about a date range if some dates in this range are missing?

texts:
I use charts module Charts and I want to create a view that shows the stats from a date range.

I have an exposed filter and this filter has a between range. I want to show all dates from values of exposed filter.

I provided the values 7/10/2015 and 15/10/2015 as my date range and always show the dates if no stats exist for specific days in this range.

For example:
7/10/2015, 8/10/2015, 9/10/2015, 10/10/2015, 11/10/2015, etc. up to 15/10/2015,

Attached an image to understand what I want (how the chart should look like).

How can I do this, with filter, arguments or handlers, please give me a example.

For this moment the module "views between date filter" is not working as I want: it only shows all dates for which some data exist. But always need show the dates that no have results.


texts: How do I limit webform submissions based on the email address?

texts: Is there a way to limit the submissions based on the email address when using the Webform module in Drupal? Right now, there is a setting to limit using the ip address & cookies but I only want to limit using the email address. Anyone has any ideas?


texts: How do i change the time between 2 reservation in Agreservations?

texts:
i didn't spoted any field that can change that.
I book meetings rooms that can be booked multiple time in a day (hour reservation).
 But for exemple i have one reservation early morning (8:00 to 9:00), i can't book the same room on late morning (9:30 to 12:00)
it return the error:

  There is a ressource conflict: [room name] is currently booked for [previous reservation name] from [date] 8:00 to [date] 9:00. Please choose a different time or a different ressources.

I can book the same day but 2 hours after the end of the previous reservation.

How can i change that setting? if i can't can i change the code?


texts: for D8, How to skip (don't update) some fields from existing entity during import if this field already has a value

texts:
How to skip (don't update) some fields from existing entity during import if this field already has a value?
That for Drupal 8 with modules (migrate, migrate_plus and migrate_tools)

example of an yml I would like:

process:
  uid:
    -
      plugin: migration_lookup
      migration: users
      no_stub: true
      source: uid
  field_telephone: phone
  field_user_country: pays
  field_adresse/given_name: prenom
  field_adresse/family_name:
    -
      plugin: skip_on_notempty  \--> do not exist
      method: process
      source: \--> actuel value of 'field_adresse/family_name', How to get that ?
    -
      plugin: get
      source: nom


texts: Getting started with the Form API and Ajax framework

texts:
I'm really struggling to understand how to use Drupal 7's Form API in conjunction with its Ajax framework. I'd like to accomplish the following:

On certain pages, multiple nodes may appear. Each one of these nodes should have a comment form appear right below it. When the user submits a comment, it should be done via Ajax and the resulting comment should then appear under the node in question.

Can someone give me an overview of the steps that are required to do this?


texts: How do I access the parts of twig.html arrays that start with a #?

texts:
I am trying to make an html.twig file and change how a paragraph renders its content, but I can't access the part of the array that has the info I need.

This is the vardumper line I used to get this far

{{ vardumper(content["field_recommended_content"][0]["#node"]) }}

and this is the result I get from that

Node {#2249 ▼
  +in_preview: null
  #values: array:28 [▶]
  #fields: []
  #fieldDefinitions: array:30 [▶]
  #languages: array:3 [▶]
  #langcodeKey: "langcode"
  #defaultLangcodeKey: "default_langcode"
  #activeLangcode: "x-default"
  #defaultLangcode: "en"
  #translations: array:1 [▶]
  #translationInitialize: false
  #newRevision: false
  #isDefaultRevision: "1"
  #entityKeys: array:4 [▶]
  #translatableEntityKeys: array:8 [▶]
  #validated: false
  #validationRequired: false
  #loadedRevisionId: "1111"
  #revisionTranslationAffectedKey: "revision_translation_affected"
  #enforceRevisionTranslationAffected: []
  #entityTypeId: "node"
  #enforceIsNew: null
  #typedData: EntityAdapter {#2251 ▶}
  #cacheContexts: []
  #cacheTags: []
  #cacheMaxAge: -1
  #_serviceIds: []
  #_entityStorages: []
  #isSyncing: false
}

but for the life of me I can't figure out how to access the contents of the #node array, if I try to do

{{ vardumper(content["field_recommended_content"][0]["#node"]["#values"]) }}

it returns null, and if I try to do

{{ vardumper(content["field_recommended_content"][0]["#node"][#values]) }}

it crashes the page.

Does anyone know how to access those array values that start with # and don't already have "" around them?


texts: How to create a map like the one used on the drupal.org homepage?

texts:
I want to know how to create an interactive map like the one used on the home page of drupal.org.
Thank you very much


texts: how to get the block region value from the plugin block class build method?

texts:
how to access the set block layout region from a plugin block class build method ?

class HalPublicationBlock extends BlockBase implements BlockPluginInterface
{

  /**
   * {@inheritdoc}
   */
  public function build()
  {
        //do not contain the layout region of the block
        $config = $this->getConfiguration();
        //$region=$this->get->?

EDIT : This block, being placed on /user/*,
I'd like to display or not the block and allow the user to choose the region depending on his choice on some user custom fields

  public function build()
      {
        $current_path = \Drupal::service('path.current')->getPath();
        $exploded_path = explode('/', $current_path);
        $uid = end($exploded_path);
        if (prev($exploded_path) == 'user') {
          $user = User::load($uid);
          if ($user) {
            if ($user->hasField('field_publications_bloc_region')) {
                  $block_region=$user->get('field_publications_bloc_region')->getString();
            }
           //change this block region with $block_region ( none or  content or sidebar etc)


texts: How to show token value in Webform confirmation

texts:
In Webform > Form settings > Submission settings > Confirmation message, how can I show a webform token as part of the confirmation message? Something like:

  Hi %value[name], thanks very much for joining our event!


texts: Calling a javascript function from a form item ajax callback?

texts:
I am working on a project and I think I am stuck on this. I have a form that I want to add points to a map as users edit it.

Here's a rundown on how the form works:

The user chooses a number (1-10) for how many stops they'd like to make from a select list. The select list defaults to 1 and below it there is a select list that lists all of the points of interest they can choose from. If they change the first select to 2 the ajax callback updates the form and adds an additional select box of POIs. That's working great.

What I'd like to be able to do is add the POI to a map on the page whenever they select it (with driving directions between them). I have an ajax callback on the POI select list in order to do this but I am having trouble figuring out where to go from here.

I have the following in my POI callback (for testing) and it works, but I am having trouble figuring out what ajax_command_ function to use to call a js function to add the point to the map.

$commands = array();
$commands[] = ajax_command_alert("Here!");
return array('#type' => 'ajax', '#commands' => $commands);

Basically I just need to pass the latitude and longitude of the POI (which I am gathering in the callback) and send it to a js function to then update the map. My first thought was using drupal_add_js but I couldn't get it working and discovered later that it was not the right way to go.

Any thoughts?


texts:
I created a view to display blog pages.Then i created a blog archive block which shows years.if i click on the years it shows the blog view which i created.now i want to show the archives(year) block in a panel and the blog view in another pane in the same panel page .
Years in left pane and when i click on year it should show the blog view in right side pane in the same panel page.I need help in solving this problem.Thanks in advance.


texts: Field configuration changes after clearing the cache

texts:
I have a content type with only an image field where users can put multiples images.

Sometimes, after clearing the cache, the configuration of the field resets by itself and it sets the cardinality to 1, not letting users to more than an image.

How can I prevent this problem?


texts: show content type fields from user on another content type

texts:
I need to be able to show fields from one content type on another.

Example:

Article: basic title/body fields
Author Bio: User information (website, twitter and FB info, email, etc... fields)

Trying to create a block that will look at the NID, pull the node author and show the bio at the bottom of the node.

I tried using UID and NID as the contextual filter and author as the relationship. I also filtered to show only published and content type "author bio"

But when I try and use the auto preview, I get my labels with no data.

So I went into the individual fields, but there is no drop down to force a relationship to the node author like in entity references.

I am missing something, but I can't seem to find it. Any help would be appreciated.

Thank you.


texts: How can I get field labels from submission data?

texts:
I have created a custom webform handler by extending WebformHandlerBase. And I can get the data from the WebformSubmission. However, I can only get the machine name of the field. I would like to get field label. For instance, I get "fname" machine name as the key, but I want to get "First Name" or what ever label is set in the admin for this webform.

Does anyone know how I might get to that information from a webform submission entity?


texts:
I have a D7 site up and running and working fine. Today I logged in to update some content, but I saw that the admin pages just show the system messages about necessary module updates and that's it. I tried several pages and they all show the same, no content except for the message on top. I can see the site content, but whatever link I click within the admin pages will show the right URL but the same content as the attached image.

Just a few months ago I logged in and everything was okay. What could be causing this? Any help is appreciated.


texts: Drupal 8 - Drush composerRequireDrupal8 error

texts:
System: Ubuntu 14.x

Drupal: 8.x

Drush: 8.x

I recently have installed Drush using composer global require drush/drush:dev-master code and it got installed successfully.

I ran command which drush and the terminal gave me the path /home/ravi/.composer/vendor/bin/drush.

The problem is, I am not able to execute any commands from project root. It gives me below error:

PHP Fatal error:  Cannot redeclare composerRequireDrupal8() (previously declared in /var/lib/composer/vendor/composer/autoload_real.php:63) in /var/www/html/study/drupal/8/vendor/composer/autoload_real.php on line 70

But when I execute below command from project root:

/home/ravi/.composer/vendor/bin/drush status

then Drush works perfectly well.

Is there any way I can use Drush from project root? Or have I made any mistakes in installation? Please help.

PS: I have tried updating composer and composer self-update but it did not help.


texts:
Does anybody have experience integrating external libraries with Drupalgap (in particular the BarcodeScanner)? I've been able to get BarcodeScanner working with Phonegap relatively easily but Drupalgap's architecture is more complicated and requires using a function to acces. Any help would be great!

Here's the BarcodeScanner info:

https://github.com/cfjedimaster/Cordova-Examples

I created a project from scratch using Cordova, added the plugin according to the readme, and then copied the contents of www from the repo to my project. This works great standalone. How do I add this button to Drupalgap so I can scan barcodes from within the app?


texts:
Is it possible to use Mimemail, Mail System, and SMTP Authentication Support modules together?
Currently I am using Mimemail to send HTML-formatted messages; however, because of the configuration of my server, these e-mails are often being recognized as spam.  To reduce the chance that they will be recognized as spam, I want to use the SMTP Authentication Support module.


texts: Regions. how can I disable a region? (not disabling blocks)

texts:
I want to disable a region, to not show blocks in this region to an specific page. I want this because, I have several blocks (more than 20) so in this case is necessary enter to each block, and configure in what page or pages must not be showed. Well I can do that, I just want to know if exist some way to make this task in a more practical way, or in a programmatically way.

I am using Drupal 6.


texts:
I have a form which I have included a reset button. Here is the code:

function submission_list($form, &$form_state) {

  ...code here...

  $form['filter']['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset'),
    '#submit' => array('submission_list_reset'),
  );

  ... more code ...
}

function submission_list_reset($form, &$form_state) {

  if (isset($form_state['etd_filter'])) {
    unset($form_state['etd_filter']);
    $form_state['values']['filter_user'] = '';
    $form_state['input']['filter_user'] = '';
  }
  $form_state['rebuild'] = TRUE;
}

I thought what I have in the submission_list_reset function is correct but it still displays whatever the user typed in the filter_user text field. I have tried clearing the values and input array with no success so I must be missing something really basic here. I have searched Drupal Answers and Google but have not found an answer. The answers I have found on Drupal Answers is about adding a reset button but not about clearing specific fields.

Thanks.


texts: Difference between function names from Drupal Devel

texts:
The devel module in drupal allows us to print variable data using functions like:
kpr,krumo,dpm,dsm
Can anyone please explain how different is each function from the other


texts: Trying to get form elements to appear in draggable table

texts:
So I saw this table example on Drupal.org with two form elements per row. I wanted to do something similar except have the rows draggable. Below is example of the Drupal.org code.

$form['contact'] = array(
  '#type' => 'table',
  '#caption' => $this->t('Sample Table'),
  '#header' => array($this->t('Name'), $this->t('Phone')),
);

for ($i = 1; $i <= 4; $i++) {
  $form['contact'][$i]['#attributes'] = array('class' => array('foo', 'baz'));
  $form['contact'][$i]['name'] = array(
    '#type' => 'textfield',
    '#title' => $this->t('Name'),
    '#title_display' => 'invisible',
  );

  $form['contact'][$i]['phone'] = array(
    '#type' => 'tel',
    '#title' => $this->t('Phone'),
    '#title_display' => 'invisible',
  );
}

It's simple and clean, but lacks the draggle functionality I need. So following some docs I came up with the code below.

$rows = array();

for ($i = 1; $i <= 4; $i++) {

  $rows[$i] = array(
    'class' => array('draggable'),
  );

  $rows[$i]['data']['name'] = array(
    '#type' => 'textfield',
    '#title' => 'Name',
    '#attributes' => array(
      'class' => 'contact-row',
    ),
    // '#title_display' => 'invisible',
  );

  $rows[$i]['data']['phone'] = array(
    '#type' => 'tel',
    '#title' => 'Phone',
    // '#title_display' => 'invisible',
  );
}

$form['#tree'] = true;

$form['contacts'] = array(
  '#type' => 'table',
  '#caption' => $this->t('Sample Table'),
  '#header' => array($this->t('Name'), $this->t('Phone')),
  '#rows' => $rows,
  '#attributes' => array(
    'id' => 'contacts-table',
    'class' => array('field-multiple-table'),
  ),
  '#tabledrag' => array(
    array(
      'action' => 'order',
      'relationship' => 'sibling',
      'group' => 'contact-row',
    ),
  ),
);

For the most part everything is there except the table cells don't contain the form elements. It just references the name. What do I need to do to make the textfields appear.


texts: Fieldable Panels Panes: title is shown twice

texts:
When putting fieldable panel panes on a (panel) page the titel field is shown twice. It makes nog difference whether I choose a Display Suite or Panels layout. How can I change this?

I don't know if this is related but I can't figure out how to config a DS view mode, once I've created it and attributed it to 'fieldable panels panes'.


texts: Upgrade Status module reports PHPUnit\Framework\TestCase is not an interface

texts:
Our site is running Drupal 8.8.13 and we want to move to Drupal 9. I've installed the Upgrade Status module v3.3. When I scan a module, like Admin Toolbar, it reports the problem:
web/modules/contrib/admin_toolbar/admin_toolbar_search/admin_toolbar_search.module

Internal error: PHPUnit\Framework\TestCase is not an interface
Run PHPStan with --debug option and post the stack trace to:
https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md

Lots of other modules have the same problem.
Is this warning legit? or is there a problem with the configuration of Upgrade Status module?


texts: How to stop drush displaying a Drupal error message?

texts:
This question is a follow-on from this one about creating managed files. If you look at the question in the link, you'll see that I am writing a drush command to detect all the inline-images in a just-migrated Drupal 8 system, and add them into Drupal as managed images attached to the relevant nodes. To cut a long story short, this bit of code takes the existing file name and creates an entry in Drupal:

$file = entity_create('file');
$file->setFilename($file_name);
$file->setFileUri('public://images/'.$file_name);
$file->save();

This works fine, except that it very irritatingly displays this error message with every file: Object(Drupal\Core\Entity\Plugin\DataType\EntityAdapter).uri: The file public://images/rint135_graph4_0.articleimage.PNG already exists. Enter a unique file URI.

Of course the file exists! That is precisely the point! Despite the error message everything seems to work ok, but I would really like to get rid of those error messages. I guess that they are being set by drupal_set_message(), since they include HTML which of course is pointless in drush - but I can't find any way to switch them off.


texts:
I've on a drupal 6 site a custom module which generate a page, i send in that page a form.

When i try to test my form as an anonymous user, it doesn't work as i get:

  You are not authorized to access this page.

I've a hook_perm on my module and permission are activate for anonymous user, but that still doesn't work, even after "cache clear" or "rebuild permission".

So i must have another permission in conflict here that forbid me to show my form to anonymous user (as an admin, i can see it). Is there a way for me to print the "rights" that forbid me to access my form, to get a list of the permission used in a specific page?


texts: How can I create a block that shows the total items in my cart?

texts:
I'm using Ubercart ajax cart, and I want to create a static block with AJAX that only shows the total items in the cart.

How can I go about doing this? Is there a module that has this functionality?


texts:
I have these two functions,
the first is to send the email via drupal_mail() function :

function example_function_name($what) {
  drupal_mail('MYMODULE', 'some_mail_key', 'myaddress@gmail.com', language_default());
}

And the second is the hook_mail function :

function MYMODULE_mail($key, $message, $params){
    switch ($key){
        case 'some_mail_key':
            $message['subject'] = 'test subject';
            $message['body'] = 'test body message';
            break;
    }
}

But I recieve a blank email in spam without neither subject, or body message.
Is there somthing missing here ?

Thanks in advance.


texts:
I am using D8. I have two views (articles and videos) sharing the same taxonomy (segments). How can I filter the views based on the view type?
For example, if I am on the articles page, I would need to filter only articles when I select any of the taxonomy term. Right now, by default both articles and videos linked to the taxonomy term are shown.
I am using Taxonomy Menu to display the terms in a block.


texts: How do I create a download link knowing the uploaded file ID?

texts:
I've a column in database containing the IDs of the files uploaded using a managed file form field.

How do I create a link to the uploaded file knowing its file ID?

EDIT :
The obvious solution doesn't work for me , i'm using another table where i put my Fids .

this is the warning i got everytime :
Notice: Trying to get property of non-object in Affichage_form() (line 188 of C:\wamp64\www\Gestion_tickets_licences\sites\all\modules\Recherche\Recherche.module). << 188 : $uri= $file->uri; >>

Solution : Thank you for you help .
my solution for my problem is , Once I upload the file , I create the url. Instead of saving Fid , I save the url , It worked .For the download link , I used Alen syntax and it worked great .


texts: How can I sort the search results alphabetically?

texts:
I would like to sort the search results alphabetically in Drupal 6.
How can I do that?


texts:
I've created one view with used of php code for some fields in it, and set pager on it too. It's working fine whenever i created given link of view but actually I print that same view on another basic page, using this php code:

<?php print views_embed_view($viewName); ?>

on that basic page pager is not working, because on that page the pager link is generated with that basic page url link not with views url link. can anyone give solution when i print the same view on basic page and also pager can work over there perfect?

Thanks in advance :)


texts: Show block for pages of every content type but one; including the front page

texts:
I've created a custom block, and I want to show it on every page including the front page, except for pages of one specific content type.

In block settings, under "Visibility Settings", there is a list of checkboxes for each content type.  If none are checked, the block shows on every page; but if any are checked, the block only appears on pages with the checked content type.  So I tried checking everything except the one content type I want to exclude.

Except that this also excludes the block from the front page.  It appears as though the front page doesn't have a content type you can choose to make the block show up.

Is there a way to get my block on the front page as well, while still excluding some content types from showing it?