texts: Cannot delete file due to empty entity reference

texts:
I have been asked to delete a file that has incorrect legal information on it from a website so it has to go. My users could not do it.
The site is running drupal 8.9.13 and I have installed the module file_delete
When I try to delete the file I get the following error message:
The file ND Pamphlet re Employee Assistance Program .pdf cannot be deleted because it is in use by the following modules: file.
Click here to see its usages.

There is one reference to a node that does not use this file. Though it may have once been linked to on that node.
I tried deleting the node itself - as it was relatively small and I thought it could be recreated. The error however remains. When I now look at the usage information for the file I see the following:

Caches have been cleared and cron run several times. How do I remove this file and this non-existent reference?
Additionally, why does this happen and how can it be avoided in the future?


texts: Image preview not generated on node edit page

texts:
My content type has field type "Image" and using "Media selector" to upload images.

Images are uploaded properly but not previewed at the same time on node add/edit page. I can check that preview is generated with firebug.

If I go to library then again preview not displayed but after saving node it is displaying.

What could be the issue?


texts: How to provide facility to download & upload files to specific type of user in drupal 6

texts:
What i did:-

So , i am create one content type like "login_page", so in that i want to display title , description and file download & display. This content type display on when user logged in instead of user page . And i have 2 types of user i.e Customer user & guest user.

What i want:-
So now i want to display or download text file such as pdf or doc files facility to customer user & display facility to guest user . This files are uploaded by the admin.

So for that any module is available or any solution nearly same to such situation. Please help me i am stuck on that.


texts: Adding Vue.js to my theme with Webpack not working

texts:
I am trying adding Vue.js into my Drupal 8 theme with my Webpack setup (which I had already working).

It's all compiling fine with Webpack, without errors after my npm script npm run build.

In my index.js I have:

import './styles.css';
import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false

new Vue({
  render: h => h(App)
}).$mount('#app')

In my App.vue I have:

<template>
  <div id="app">
    <HelloWorld msg="Coming Soon: Near-Earth Objects"/>
  </div>
</template>

<script>
  import HelloWorld from './components/HelloWorld.vue'

  export default {
    name: 'app',
    components: {
      HelloWorld
    }
  }
</script>

<style>

</style>

In my ./components folder I have HelloWorld.vue

First I am trying now to render my Vue component inside header.html.twig like

<hello-world></hello-world>

My thoughts are, by the element  in page.html.twig I can show, arrange and position all my Vue.js components where I want. Is that correct?

But why is my component not showing up?

Update:

I figured out. My webpack.config.js is splitting Vue into /themes/custom/my_theme/dist/vendors~main.bundle.js. By this setting:

config.optimization = {
      splitChunks: {
        chunks: "all"
      },

What is the purpose of this? Isn't it better to compile it all into the same file main.bundle.js?


texts: Different "Asc" and "Desc" labels for different Views exposed sort fields

texts:
I have a view of Commerce products that, as is standard for e-commerce product listings, can be sorted by price or by date. I'm having trouble with the sort direction labels:

In the context of dates, "Ascending" or "Descending" is confusing unless you are used to thinking about time in terms of UNIX timestamps. Labels like "Newest" and "Oldest" are much more user-friendly to average users.
In the context of prices, labels like "Highest" and "Lowest" are most user-friendly.

"Newest"/"Oldest" is clearly nonsense in the context of price, while both "Ascending/Descending" and "Highest"/"Lowest" are confusing to average users in the context of dates. I need both highest and lowest options for the prices sort because it's a luxury goods store and some users want to browse the most premium options.

The trouble is, even with Better Exposed Filters module, I can only have one custom ascending or descending label.

Ideally, I'd like something like this:

  Sort by

  Date - Newest
  Date - Oldest
  Price - Highest
  Price - Lowest

...but I'd also accept something that switches the labels in the sort order based on the selection in sort type.

I could roll my own javascript, but surely I can't be the first person to have this use case. Is there an existing solution?


texts: Single Sign On using PURL domain modifier and different TLDs

texts:
I have an organic groups implementation using purl and spaces to set the active space when you visit a domain modifier such as example1.org vs example2.org.  The cookie domains are different, so I'm wondering if there is any single sign on solution that will allow sessions to be transfered from one domain to another in some fashion.

Should I use something like facebook connect, and not allow users to sign onto the site with their regular drupal credentials?


texts: Filter a JSON view by day and time without using Date?

texts:
I created a JSON View, using the Views Datasource module, of a content type that has a time field, using the Time Field module, and a Weekday, using the Weekdays Field module. I am not using the Date module. Now, I need to filter this view showing me only the content that has been registered today and now (or at lest in a time that's before the next registered time in the content type, and after the time the current type content is)

For example, this content type is called Radio Program. The user inputs a radio program with a time and a weekday associated with it. The time the user inputs is only the starting time of the radio program, not the total time.

How do I filter this, so that I get the needed JSON? I'm a bit new to Drupal.


texts: Need to use taxonomy term as url argument to filter a view but the term is attached to a node ref field

texts:
Not sure if the title makes much sense so I'll try to explain what I'm trying to do a little more in detail.

I am building a scoreboard section of my site for high school football scores from around the state. My "score" node has two node reference fields, "home team" and "away team" that point to a "team" node. The "team" node has some taxonomy terms, namely "county" and "conference."

I am trying to build a view that lists all of the "score" nodes for the week. The main scoreboard is working, no problem. But I'd also like to be able to have links like "http://example.com/scoreboard/county-name" and "http://example.com/scoreboard/conference-name" that would just show the scores for the schools in the respective county or conference.

The following is a screenshot of how my relationships, arguments, and fields are set up.

The following is a screenshot of how the view displays on the "/scoreboard" page.

But, if I try to go to "http://example.com/scoreboard/hamilton" I get a blank page. Am I missing something simple here? It seems like it should be possible but I'm not getting it.


texts:
How can I add a field in my entity form that allows the user to add time.
When I use date, I can add time field but there is always a date field.

I don't want the user to add date field, just the time (for time in and time out).
And also, I will use the value of that field in my query.


texts:
I need to embed each node I have in a different block. How can I achieve it?

If it makes any difference, I am using Drupal 7.


texts: Whats the proper way to preprocess field collection items to add first and last class names?

texts: How to add 'first' and 'last' class names in addtion to 'odd'/ 'even' for field collection items in preprocess functions?


texts: Bootstrap subtheme does not recognize stylesheets

texts:
I'm trying to use a custom (LESS) build of Bootstrap in my Drupal project. I have a subtheme in the proper folder and have compiled a style.css file. However, Drupal does not recognize this file. So far I have

Edited the .info file to switch of the CDN and switch on the local .js files
Cleared the cache
Switched off the aggregation of CSS
Restarted the server
Added a foo.css to the .info file for testing

Nothing of this works. The subtheme does not recognize my custom css files.

What could have gone wrong here?


texts: How does one check if user has created a node of a content type in rules?

texts: I would like to check if a user already authored a node from a content type before creating one for the user in rules. How do I create a condition for this? Thanks!


texts: How hidden the user_filter_form to a specific role?

texts: How can I hidden with alter_form to hide the user_filter_form in the page of list of users to a specific role?


texts: Load single value from multiple value image field in View

texts:
I am trying to load a single value from a multiple value image field in View.
I am adding the field with a restriction to print only a single file. I am also filtering by delta(=0). Check the settings in the attachment.

However the view is loading all images attached to the field. How can I load only the 1st one?


texts: Allow user A to grant view permission of their node to user B

texts:
My website users will have the ability to post pictures in a private photo gallery. I would like for those users to be able to grant "view" permissions for their private gallery to other users.

Bob (an authenticated user, not an admin) has a private photo gallery
He wants Dave (another authenticated user, also not an admin) to be able to view his private photo gallery
Bob grants permission to Dave, allowing Dave to view that gallery
Bob can revoke permission from Dave at any time

Is there a module/configuration that will this type of user-controlled granting of permissions?

Thanks!


texts: How to disable this fields for Administator?


texts:
My URL is something like this http://xyz.com/content/show-cat?catid=2  . Now i want the value of catid (i.e 2) and save it in a variable. I wrote php code like $store=$_Get['catid'];

But this format is not accepted in drupal. How can i implement this? Is there any alternative?


texts: How to get add term form of taxonomy inside node type form?

texts:
I'm trying to render taxonomy add term form inside content type ('article') add form. (node/add/article)

In hook_form_alter, I called this callback function on abutton.

public function _cvv_ajax_callback(VocabularyInterface $taxonomy_vocabulary) {
    $taxonomy_vocabulary = 'cvv';
    $term = \Drupal::entityManager()->getStorage('taxonomy_term')->create(['vid' => $taxonomy_vocabulary->id()]);
    return \Drupal::entityFormBuilder()->getForm($term);
  }

But this is not return form in my node/add page, rather giving me error:

  error   php   Drupal\Core\Entity\EntityStorageException: Missing
  bundle for entity type taxonomy_term in
  Drupal\Core\Entity\ContentEntityStorageBase->doCreate()

I tried

if ($vocabulary = taxonomy_vocabulary_machine_name_load('jenis_dokumen')) {
  module_load_include('inc', 'taxonomy', 'taxonomy.admin');
  $edit = array();
  $taxonomy_form = drupal_get_form('taxonomy_form_term', $edit ,$vocabulary);
  return drupal_render($taxonomy_form);
}

but this is also not working in Drupal 8.

Also tried:

 $form = \Drupal::formBuilder()->getForm('\Drupal\taxonomy\Controller\TaxonomyController::addForm','plan_features');

didn't worked :'(

Lastly I tried Inline Entity Form , the problem with module is, when a add term form get rendered inside node type form and if you do

kint($form_id); inside hook_form_alter, you won't get any form id for this inline form. Hence if you want to add custom validations for the term title, it won't be achievable even by hooks this module provides.

Please  suggest a way to do this.


texts: How can I enable moderator role's ability to administer users only apply to certain user roles?

texts:
I am making a Drupal (v7.8) website with several user roles, including Super User, Admin, Moderator, Editor, and Reviewer. I want the Moderator role to be able to use the privileges that Administrate Users gives, but only for roles "below" Moderator (i.e. Editor and Reviewer).

I haven't been able to find a module or documentation on how to do this.

Thanks!


texts: How do I allow users to remove their pictures from their user profile?

texts: Users on my recruitment website are able to upload profile pictures and CVs to their user profile. However, they aren't able to remove uploaded pictures and CVs or replace them with new files. What do I do to allow users to change their existing profile pictures as well as CVs?


texts: hide all of node form except a file upload field

texts:
Bit of a weird one....

I'd like to call a node edit form into an overlay but have it only show a file upload (cardinality unlimited) fieldset and the save button

I know I can program the formAPI bits, get the files and save the node myself, but In this (possibly strange) case I'd like to use the existing form.

Obviously can CSS it, but I'd rather have it in PHP.

So far I've set up a loop in a conditionally invoked form alter that finds form elements and then... well, unsetting/hiding them gets them off the screen but then the upload field doesnt work

foreach($form as $key => &$value) {
  if(is_array($value) && isset($value['#type'])) {
    if(  !in_array($value['#type'], array('hidden', 'value'))
      && !in_array($key, array('field_my_file_field', 'actions'))) {
      unset($form[$key]);
      //or $form[$key]['#type'] = 'hidden';
    }
  }
}

I'm guessing I'm compromising the form array, so it's not working in a callback somewhere.

Any ideas? Or a better suggestion for getting just the field upload fieldset onto a page?

Thanks!


texts: Does the Diff module work with nodes that are displayed using the Panels template? I go to /revisions and I get a "Page not found".


texts: Theme suggestions for text on specific block

texts: I want to have a theme suggestion for field--text-with-summary.html.twig based on block in which it is. I just want to add a css class to it in this specific block. Any idea on how to write the hook function, Please?


texts: Drupal 8 css and images relative to root

texts:
I have the challenge that I want my site to be cache-able by and external varnish cache provider.

Most of my page gets cached nicely, but elements like the ico file, images and css are written with the full url in code and hence doesn't use the cached version.

www.domain.com points to internal.domain.com

When I go to www.domain.com the urls for the images looks like this

http://internal.domain.com/sites/default/files/styles/hero_full/public/hero/image.jpg?itok=WiCUbqbj

What I wanted was that it just wrote a url relative to the root of the site.

/sites/default/files/styles/hero_full/public/hero/image.jpg?itok=WiCUbqbj

The issue is the same with files included from the THEME.libraries.yml file.


texts:
I've been searching for days but cant find a working answer for my issue.

I have a Drupal 8.6.7 site with search_api and search_api_solr installed. I have a view based on solr results. I want to sort the results by creation date in a descending order, but i want the first three items to be created by members with the role "redactie".

This is what i have so far, but it doesn't seem to affect the results in any way.

function mymodule_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
  if($view->id() == 'search_content') {
    // get members
    $rids = \Drupal::entityQuery('user')->condition('status', 1)->condition('roles', 'redactie')->execute();
    if(count($rids) > 0) {
      // get latest 3 bundles, created by one of the members
      $nids = \Drupal::entityQuery('node')->condition('type','bundle')->condition('uid', $rids, 'IN')->sort('created' , 'DESC')->range(0,3)->execute();
      if(count($nids) > 0) {
        // add these bundle ids to the query order
        $query->addOrderBy(null, 'node_field_data.nid IN (' . implode(',', $nids) . ')', 'DESC', 'redactie_order_by');

        // sort the rest of the results by creation date
        $query->addOrderBy(null, 'node_field_data.created', 'DESC', 'created_order_by');
      }
    }
  }
}

Can anyone tell me how to fix this?


texts: is Form api ajax attribute good in performance ? does it require an entire bootsrap?

texts:
Ajax is used for better user experience and also for better performance in a webapp ( change only the requested item instead of the entire page ).

In my case the form will require ajax functionality, interacting live with the Product Configuration Soap Service.
The performance of this form will be important due to the fact that many users may be accessing it simultaneously.

But how #ajax works in Drupal ? Does It require an entire bootsrap ? If so, will drupal be a good solution in my case ?


texts: Migrate addressfield: Call to a member function import() on a non-object in migrate/includes/migration.inc on line 696

texts:
also posted to Migrate issue queue as a support request

I am importing users and data from csv with a Migrate Group. The initial user creation and some additional data in other tables in working fine.

I have read everything I can find on Google about Migrate and Addressfield, and some of it is 2 years old and confusing. For example, Migrate has deprecated $arguments for field mappings, sub-fields are mapped with colon notation. Also, I am adding the Addressfield migration to a group so it gets the correct uid from the completed user migration, so posts about direct csv imports are not helpful.

I am getting a message when I migrate (with drush)

PHP Fatal error: Call to a member function import() on a non-object in /var/www/[site]/sites/all/modules/contrib/migrate/includes/migration.inc on line 696

I put a drush_print_r on that line

drush_print_r($this->destinationValues);drush_print_r($this->sourceValues);

the output of drush_print_r just before the error is

stdClass Object
(
    [entity_id] => 483
    [field_user_address] => Array
        (
            [0] => US
            [arguments] => Array
                (
                    [administrative_area] => NY
                    [first_name] => [actual first name]
                    [last_name] => [actual last name]
                    [locality] => New York
                    [postal_code] => 10028
                    [premise] =>
                    [thoroughfare] => [actual address]
                )

        )

    [revision_id] => 483
)

stdClass Object
(
    [Row] => 1
    [Type] => M
    [Prefix] => Miss
    [FirstName] => [actual last name]
    [MiddleName] =>
    [LastName] => [actual first name]
    [StaffNotes] =>
    [ColumbiaAffiliation] => Alumna/nus
    [ProfessionalAffiliation] =>
    [AddressLine1] => [actual address]
    [AddressLine2] =>
    [City] => New York
    [State] => NY
    [ZipCode] => 10028
    [Country] => Array
        (
            [0] => US
        )

    [TelephoneNumber] => [actual phone number]
    [Email] => [actual email]
    [Birthday] =>
    [ID] => [actual ID]
    [Descriptor] => [A] A: EN07
    [GraduationYear] => 2007
    [SchoolAffiliation] => EN
    [csvrownum] => 1
    [migrate_map_hash] =>
)

my field mappings:

$this->addFieldMapping('field_user_address', 'Country');
$this->addFieldMapping('field_user_address:administrative_area', 'State');
$this->addFieldMapping('field_user_address:locality', 'City');
$this->addFieldMapping('field_user_address:postal_code', 'ZipCode');
$this->addFieldMapping('field_user_address:thoroughfare', 'AddressLine1');
$this->addFieldMapping('field_user_address:premise', 'AddressLine2');
$this->addFieldMapping('field_user_address:first_name', 'FirstName');
$this->addFieldMapping('field_user_address:last_name', 'LastName');

and in prepareRow():

$row->Country = array($row->Country);


texts:
Is there a way to create and display a global 'Last updated' timestamp that would be displayed on every page? 'Last updated' would include adding and changing any piece of content on the website. I know how to display a similar timestamp for each node but I'd like to be able to display just one per page. Maybe looping through all created nodes and finding the latest date? How would I achieve that? Or is there a better solution - looping through all nodes might be memory-intensive, right?

Thanks


texts:
I got custom registration form under /user/register URL but anonymous user gets denied access what type of permissions should I set.
 I tried:

 requirements:
   _permission: 'access content'

and

requirements:
   _permission: 'none'

or I deleted it completly but it didn't help.


texts: How to have OutboundPathProcessorInterface change the URL of the loading page

texts:
I have a page my/topics.  The page presents content based on the user's selection from another page. Having made the selection, it and other information is passed to the page via a query string:

mydomain.com/my/topics/?choice=topic1...

I have no control over the creation of the incoming path. For the processing of the path and for SEO I need the path to instead be:

mydomain.com/my/topics/topic1

In both cases the target is my/topics, but the processing I need from that point depends on being able to access the additional information as part of the URL instead of as a query string.

The available topics are a large non-static list. It might be possible to do some regex magic in .htaccess to handle it as a redirect, but I'd rather handle it within Drupal, if possible.

To that end I've used OutboundPathProcessorInterface. The class is listed, below. The problem I am having is that the path is not changed in the browser address bar. If I put my/topics in a menu link on the page, or a link in the body text, it does become my/topics/topic1 in each of the links, and in the address bar on a subsequent click, but not in the address bar of the page that is rendered as part of the altering of the path... it appears as my/topics.

I have commented out the 'if' statement that limits the change to just that path, and the result is the same on admin/structure, for example. The browser shows admin/structure, but the link to it in the admin menu when hovered over shows admin/structure/topic1.

You'll note that I have the priority of the module being -32766 (I've also tried just -1). No difference.

url_remap.services.yml

services:
  url_remap.path_processor:
    class: Drupal\url_remap\UrlRemapOutboundPathProcessor
    tags:
      - { name: path_processor_outbound, priority: -32766 }

UrlRemapOutboundPathProcessor.php

namespace Drupal\url_remap;

use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\HttpFoundation\Request;

class UrlRemapOutboundPathProcessor implements OutboundPathProcessorInterface {
  function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
    $append = '';
    if ($path == "/my/topics") {
      if (sizeof($options['query']) > 0) {
        if (array_key_exists('choice', $options['query'])) {
          $append = substr($path, strlen($path) - 1, 1) != '/' ? '/' . $options['query']['choice'] : $options['query']['choice'];
        }
      }
    }
    return $path . $append;
  }
}


texts: How to embed multiple node forms in drupal

texts:
I have Drupal 7 site & it has n content types. Of which 2 content types are:-

Product
Dealer

Now, I am in need to embed the above node add forms in one single form. On googling, I got to know about Embed Node Form module & installed it as well.
https://www.drupal.org/project/embed_node_form

But not getting how to embed multiple node forms into single form.

I didn't find any document on it.

Suggestion needed:-
Should I go with this module or develop a custom module.

Any help highly appreciated.


texts: how to display filed values form People » Account settings » Manage fields

texts:
I've added few more fields in "Administration » Configuration » People » Account settings » Manage fields". See the attached screenshots for more details.
Now I want to display user's First name & Last name in page.tpl file. I know that name can be diplayed like this "$user->name". But I want to know how other filed values can be displayed. I want to display the fileds First name, Last name, Phone, Address


texts: Comment Author details are not displayed when comment is submitted by REST API

texts:
Currently I am using the following Drupal 8 REST method

POST: http://example.com/entity/comment

Content-type: application/json

    {
      "entity_id":[{"target_id":123}],
      "entity_type":[{"value":"node"}],
      "comment_type":[{"target_id":"comment"}],
      "field_name":[{"value":"comment"}],
      "subject":[{"value":"Goodbye World"}],
      "comment_body":[
        {"value":"
See you later!
","format":"basic_html"}
      ]
    }

201 - Created

This I referred from this link https://goo.gl/kXCS8Q
The comment is getting created properly but the Comment's Author Details are not been displayed.

Can anyone tell what else I need to send the parameters for Comments?


texts: Security considerations for special characters in usernames?

texts:
I would like to create some users on a Drupal site where the usernames are actually company names and some of those company names contain ampersands or other non-alphanumeric characters.

I have read this answer which describes how that might be achieved (by overriding the form validation for creating/editing a user).

My question is: Would there be some security risk in allowing special characters such as &/#?()+ in usernames, or did the Drupal developers make these characters illegal purely for aesthetic reasons?


texts: Using a conditional OR in a view query alter programmatically

texts:
I am trying to use an conditional OR in my custom module.

hook_views_query_alter(Drupal\Core\Database\Query\AlterableInterface $query)

I get it to work with either one of these conditions set, but not together.

if (isset($query->alterTags['VIENAME'])) {
  $query->condition('draggableviews_structure.entity_id' , NULL, 'IS NULL');
  $query->condition('draggableviews_structure.view_name', 'view_display_name', '=');
}

How do I set an OR value between them, so if either is true?

Thanks


texts: Defining a varibale Node Expire date by custom PHP code in Rules module

texts:
I have a content type, Job Offer, and this node type is able to expire thanks to Node Expire module.

When editing a Job Offer, I want to change the expire date by the value of the Duration field that I added to this node.

In order to do this, I made a rule with the help of Rules Module and I am using the custom PHP code below as an action in the light of this post, but it did not work with my field:

$node->expire = date('Y-m-d', strtotime("+[node:field-duration:field-value] days"));
return array("node" => $node);

node:field-duration:field-value is an integer field of a taxonomy term

Any help would be appreciated.
Thanks


texts: How to programmatically create a custom panel pane

texts:
I created a custom panel layout with Panels 3 (following this excellent link) and my layout is ready. Now I have my static markup ready for a node (I can use it on the article or a custom content type) and I want to find out how to create a custom panel pane programmatically. I don't won't to do it through the UI as I want to totally control the dynamic markup of a node.
to make things specific (but keeping a certain level of generality), imagine

       !!php dynamic day of the date!!
       !!php dynamic month of the date!!

     !!php dynamic title of the node!!

 !!php dynamic content(body) of the node!!

       !!php dynamic read more text!!

How can I achieve to manage the above dynamic node (and let's suppose I want to achieve an exact, specific markup)?


texts: How do I resolve my URLs being escaped in Drupal Popup views Integration

texts:
I have drupal popup views generating a popup on a view on hover, I would also like to have an onclick link to an anchor on the page. I have used a couple of hidden fields in my view to render the contents of the popup, but somehow get my url mangled when I want it to render http://www.myurl.suffix/node#[nid]

My url ends up being: %23%5Bnid%5D


texts: How to remove the grid from a zone in Omega

texts:
I have an Omega subtheme that I am working on, and a request has come in to have a zone and all regions within the zone not be gridded.  By not gridded, I mean that I need the zone and all regions inside it to not be bound by any of the widths that 960.gs imposes.  Just having the full width wrapper around the zone is not sufficient for that the requested layout.

I am not sure what the best way to do this is.

Inside template_process_zone() I can remove the grid classes from $variables["content_attributes_array"]["class"]  and inside template_process_region() I can remove them from $variables["classes_array"].  This is a little messy because it assumes prior knowledge of all the grid classes (or at least the patterns), but it mostly managable.

The problem is that I can't see how I can figure out what zone I am in from within a region.  I want to avoid hardcoding region names in the template_process_region() for those to degridify.

I could also override the grid with CSS for a particular zone, but there are a lot of rules to override to future proof any changes.

Is there a well tested solution to this or other options that I am not considering?


texts: How do I edit the HTML for a part of a panel?

texts:
I am new to Drupal and need to style a blank page. The page has some content in it, but I need to make some little adjustments to the html (.tpl?) files.

The page uses a Panelizer variant with 2 columns. I want to add some HTML to one of the items in one of those columns (a 'mini panel').

On which file .tpl in my theme's directory would I make these HTML changes?


texts: Update entity on cart page programmatically Drupal Commerce

texts:
I need to rewrite default view - commerce_cart_form, because of my design of /cart page. So, I've created file views-view--commerce-cart-form.tpl.php and try to repeat something like on original /cart page were. I can print all needed information about line items in cart, but I don't know how to create "Update" button, to change quantity which I typed in textfield with quantity of line item. That's why I want to get help with this.

I use Drupal Commerce 7.x-1.9

Many thanks in advance!


texts: Adding CCK fields to Simplenews email newsletter

texts: I am designing a newsletter using Simplenews, however I need to add a couple of additional CCK fields to each node included in the newsletter. Seeing as the template file the email newsletter uses (simplenews-newsletter-body.tpl.php) simply uses a $body variable to output content, where would I instruct simplenews to add my additional CCK fields to each of the nodes I am sending?


texts:
How I can add some prefix to the all error messages?

Example:

This field is required!

and I need

Error: This field is required!

I'm using Clientside Validation module for error messages in my forms.


texts: Commerce Email: HTML Mail not reading template

texts: I am attempting to make a custom template for my Commerce Email emails. CE uses Variable Email and HTMLMail. I have put the template (named htmlmail--variable_email--custom_email_order.tpl.php) into the root of my theme folder. Nothing. The test htmlmail template is in the same place and works fine. I have cleared caches on the performance and in PHPMyAdmin, and run cron. Still doesn't work. Is this peculiar to Variable Email or HTMLMail?


texts: How can I theme the Views Exposed Filter Results page?

texts:
I'm trying to theme this page

http://208.87.22.137:50000/admin/rooms/bookings/list/kiosk/3?name=rest

which is the result of an exposed views filter. I have themed the node the views block is on but I'm not sure how to theme this page since it's not using node/NID.

Thanks.


texts: How to send user back to checkout after NAK response?

texts:
In Drupal Commerce, I need a way to send a user back to their checkout page if the payment gateway responds back with an error.

Right now it kind of bombs out and just tosses a nasty error message to the user and the cart and its contents are "gone", since Drupal marks the Commerce order as complete.

I've tried adding in my custom error handler function something like:
commerce_order_status_update($order, 'checkout_review');
or
commerce_order_status_update($order, 'cart');

But in both cases, the order does remain however some weird things happen, such as if you try to go to /cart you get a cart empty message as well as the shipping information gets dropped.

I'm beginning to think I'm not following the best practice for returning a user properly to their cart following an error in the checkout process.


texts: How to acess node object in hook_form_alter

texts:
I am trying to access the node object in hook_form_alter(), but it throws the following error:

  Notice: Undefined index: #node in themename_form_alter()

The code I am using is the following.

function themename_form_alter(&$form, $form_state, $form_id)) {
  $node = $form['#node'];
}

Is there any way to access the node object in hook_form_alter()?


texts:
I have my primary navigation (which is hard-coded into the theme). What I want is for a sub-menu (depending on the page) to appear in the left sidebar.

For example, if they click on the primary link for "bears" then the left sidebar menu might have "black bears" and "brown bears". How can these sub menus be accomplished? I don't want sub-menus these hard coded (i.e. easily configured by the client)


texts:
I'm trying to create a custom block in Drupal 8 in one of my modules, and have followed the examples I've found in tutorials. But when I try to place the block, I'm getting this error:

Notice: Undefined index: provider in
Drupal\block\BlockPluginCollection->initializePlugin() (line 60 of
/Users/pglatz/dev/wdocs/wdocs-d8-code/www/web/core/modules/block/src/BlockPluginCollection.php)

which is followed by this one:

Drupal\Component\Plugin\Exception\PluginException: Plugin (node_usage)
instance class "Drupal\node_usage\Plugin\Block\NodeUsageBlock" does
not exist. in
Drupal\Component\Plugin\Factory\DefaultFactory::getPluginClass() (line
97 of
/Users/pglatz/dev/wdocs/wdocs-d8-code/www/web/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php).

My class does exist; in src/Plugin/Block/NodeUsageBlock.php I have
namespace Drupal\node_usage\Plugin\Block;

and
class NodeUsaqeBlock extends BlockBase {

I don't know what the undefined index provider means or what's causing the error.


texts: Add ubercart catalog paths to xml sitemap

texts: The catalog paths don't appear in the xml sitemap with ubercart 3 and drupal 7. How can this be done.


texts:
I've created a custom module which creates a form and shows it in a block but whenever I submit it, it just refreshes the page and doesn't seem to execute the submit handler at all.

I'm going crazy trying to get this to work.

I've stripped the code right back but it's still not working.

<?php

// declare block info
function paypoint_block_info() {
    $blocks['paypoint_block'] = array(
        'info' => t('Paypoint Payment Form'), // block admin title
        'cache' => DRUPAL_NO_CACHE,
    );

    return $blocks;
}

// declare block functions
function paypoint_block_view($delta = '') {
    switch ($delta) {
        case 'paypoint_block':
            $block['content'] = drupal_get_form('paypoint_form');
            return $block;
            break;
    }

}

function paypoint_form($form, &$form_state) {
    $form['#attributes'] = array('class' => 'content-page-form');

    $form['strForename'] = array(
        '#type' => 'textfield', //you can find a list of available types in the form api
        '#title' => 'Forename',
        '#size' => 30,
        '#maxlength' => 37,
        '#required' => TRUE, //make this field required
    );

    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Make a payment'),
        '#attributes' => array('class' => array('btn', 'btn-default')),
    );

    return $form;
}

function paypoint_form_validate($form, &$form_state) {

}

function paypoint_form_submit($form, &$form_state) {
    drupal_set_message($form_state['values']['strForename']);
}

The validate function seems to get called, just not the submit one. I put print_r($form) in the validate function and got this: http://pastebin.com/Yt6T6Cr8


texts: How to use DefaultSelection::getReferenceableEntities in custom controller?

texts:
My Goal:
I want to create a customized entity_autocomplete form field to better fit my needs compared to the default one - making some modifications to the HTML and JS that's being used, as well as how submissions are handled.
Specifically, I want to do something like this but I need more control over the backend, and everything...
What Drupal can do:
Drupal's default entity autocomplete already lets the user type 2 letters, and it finds all entities that contain these 2 letters.

My Problem:
Unfortunately I have trouble figuring out how to use the existing "search feature" if you will call it that.
Some Considerations:
I looked into using search API, but this was similarly overwhelming. Considering that this functionality I'm looking for is already built into Drupal, I figure I can just re-implement it, without any additional modules, right? Really, I'm just re-designing the UI. And even if I need to beef it up in the future with a faster, resource saving search engine, I can just replace that aspect of my module/controller. (If someone can point out how to use Search API to do what I need, I'd be happy to listen)
What I've done so far:
I have already created my own custom route that points to a JSON controller which will accept the search parameters.
Based on all my research I figured I need to add use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection; to the top.
I see that DefaultSelection::getReferenceableEntities seems to do exactly what I need it to do.
However, the constructor for this class has 9 different parameters, many of them classes which I know nothing about.
But there is a create method, which apparently allows you to inject configuration data, but also it requires a ContainerInterface.
So here's where I'm lost...
How exactly do I make use of DefaultSelection::getReferenceableEntities in my custom controller?


texts: Replace textfield value on ajax callback

texts:
1) Am i missing something here? it's not replacing the textfield value.
2) Also how do i replace if i have a multiple textfield and multiple button in a form.

<?php
    function test($form, &$form_state) {
      if (isset($form_state['values']['your_name'])) {
        $name_value = $form_state['values']['your_name'];
      }
      else {
        $name_value = "";
      }

      $form = array();
      $form['your_name'] = array(
        '#title' => t('Your or your company name'),
        '#type' => 'textfield',
        '#value' => $name_value,
        '#prefix' => '
',
        '#suffix' => '
',
      );
      $form['load_settings'] = array(
        '#type' => 'button',
        '#value' => t('Load my settings'),
        '#ajax' => array(
          'wrapper' => 'subscribers-name',
          'callback' => 'simplenews_mod_load_subscriptions_ajax',
          'method' => 'replace',
        )
      );
      return $form;
    }

    function simplenews_mod_load_subscriptions_ajax($form, &$form_state) {
      $form_state['values']['your_name'] = "loaded value";
      return $form['your_name'];
    }


texts: How should I use hook_field_extra_fields()?

texts:
I just found out about hook_field_extra_fields(), but the documentation doesn't really tell me how to use it.

Where is the extra-fields output generated?

I tried hard to understand the Node and Poll modules, but I can't figure it out. I also tried to add a custom field formatter.


texts: Drupal 7 - Teaser trim ends after first  tag. How can I make it continue?

texts:
I want to my teaser to trim to 400 characters, but the trim stops after the first <p> tag is closed.  Is there a way to override this behavior and make the teaser trim to the first 400 characters?

I have edited the teasers 'manage display' option and set it 400, then edited and saved any old content, but the teaser is still being cut off after the first <p> tag ends.

I have considered adding a body summary but it does not allow any formatting in the box, which I require. Any help would be greatly appreciated.


texts: Is it possible to use Views for listing data created in a custom module?

texts:
The title says it all.

I'd like to create a view and provide rows for that view from a custom module where I've prepared the data for it.

The data is prepared when a page is visited and a callback function has run, the data is not stored in the database.

Is that possible somehow?

Thank you!


texts: How can I create a Views RSS of members only content?

texts:
We have a website with a members only content in the form of a forum.

I have already created the RSS feed and I can see that when I load the feed URL in a web browser that it is working. The problem is that I can only see it when I am logged into the website itself, and therefore when I load it into my web based reader, or Microsoft Outlooks RSS feed; that it can not see any posts.

The views screenshot I used is below:

Does the fact that a user needs to be logged into the website to view the content prevent me from doing this?

EDIT: I have been editing drupal/modules/system/system.api.php to include suggestions below including changing 'forum/%forum_forum' for the explicit 'forum/rss.xml' - it loads the xml but with no content when I am not logged into the website itself.

EDIT 24/09: After a bit of a break I have come back to this one for a fresh look.

I installed Custom Menu Permissions as advised, found the forums/rss.xml and forums/%forums_forum/rss.xml and allocated them to a custom permission which I then allowed for both Anonymous and Authenticated users.

I flushed all the caches and tries while logged off. Still nothing.

I can see the rss feed still while logged in, so I know it is there. That would discount anything stopping it being produced.

I also ensured that I had removed my custom hook_alter code as suggested below to ensure there were no conflicts.

Any further assistance to the right direction would be appreciated....


texts: link next to field to add referenced entity for site editor

texts:
EDIT: I want link button in an edit form of a content type like 'store' that says 'add store section'. This link/button should directly go to  the edit form that adds a new 'store section' which is pre-configure by me as entity reference.
This link would be next to a drop-down list of already available 'store sections'.

First step would be that the link needs to go to the node/add form of contenttypeB.
I've heard as a hint that hook_field() functions are what I need.
Something would have to get the form id somehow and this is where I'm confused, I'm wondering if I need to address the contenttypeB nodeforms hardcoded into my .module file? Or do I just need to start doing this by looping through all the fields of the content types and checking whether those fields are an entity reference and then apply it?

I'm still very scared of module development and php as I can stare at code for too long. I'm sort of getting the hook concept a little bit now. Things like hook_men() and then how it goes to the callback function I sortof get. Or when it can go to drup_get_form() and you fill in the function to build a form, I can dig that.

Just to say what level I'm at.


texts: multidomain commerce with separate cart cookie/session for every domain

texts:
I have 3 domains pointing to same drupal instance (possible without domain access module).
Setup:
DomainA,DomainB,DomainC.
Based on domains, the appropriate translated content is used. This is because they are older domains with existing links.
-DomainA: serves for customers from country A
-DomainB: serves for customers from country B
-DomainC: is new and will be serving for customers worldwide.

Now, with this setup, when customer switches language (another domain is shown), the content of cart remains.
Question: how to be able to redirect customer to home page of appropriate domain and use new session/cookie for cart?
I tried to use domain access entity module which works, but after switching to new domain, the old session is deleted (so after returning back to previous domain, the cart is empty)

Side question: regarding DomainC. There will be more languages with prefixes (domainC/en, domainC/es ...). Is it possible to have separate session/cookie for each language ? (My intention is to have languages representing countries.)


texts: Form generated from form cache displays, but missing name and value attributes

texts:
I'm having a problem displaying a cached multi-step form in a custom module which generates custom entities.

After two steps, the form posts to an external URL (action changed with hook_form_form_id_alter).
If the external URL returns errors, the form is pulled from cache with form_get_cache() and displayed using drupal_render().
Form displays okay, but field elements are missing name and value attributes.
Printing the form object retrieved from cache shows expected values (#entity, fields, and user input associated with fields).

  $form_state = array(
    'submitted' => FALSE,
    'rebuild' => FALSE,
    'cache' => TRUE,
  );

  $form = form_get_cache($form_build_id, $form_state);

  $output = drupal_render($form);

I suspect that I need to rebuild $form_state input/values or am missing a form rebuild step.


texts: find all users of a certain role and return that list

texts:
I am trying to turn this query to drupal EntityCondition query

select u.name, ',', u.mail, ',', r.name , ','
from users as u, users_roles as ur, role as r
where u.uid = ur.uid
and ur.rid = r.rid

This should return a list of all users with their email username and user role

I have this

  $query = new EntityFieldQuery;
  $query
    ->entityCondition('entity_type', 'user')
    ->addTag('role_filter');
  $results = $query2->execute();

So getting all users within a specific role id

function mymodule_query_role_filter_alter(QueryAlterableInterface $query) {
  $query->leftJoin('users_roles', 'r', 'users.uid = r.uid');
  $and = db_and()
            ->condition('r.rid', array(3,4,5), 'IN');
  $query
    ->condition($and);
}

I am not sure how to get the role value based on what I have
is it another entity condition?

The above entityFiledQuery does return the following

{"1":{"uid":"1","name":"admin","pass":"HASHPASSWORD!","mail":"admin@example.com" "roles":{"2":"authenticated user","3":"administrator"},

but
a) I would rather have roles as the value administrator and not this funky array with the "rid" key
b) the hashed password is there, can data be sanitized ?


texts: We have a drupal 7 instances and were wondering how it would be possible to conditionally disable certain cookies for site visitors? We are trying to make sure we are EU cookie compliant. We are currently using EU Cookie Compliance module, but that is not sufficient enough as we have other cookies that we are using on our site. What are some ways to provide an option to opt out of certain cookies?


texts:
I am using Drupal 7. And i am quite new.

I want to develop a system in website where an Event is declared by the Administrator. (Event is a custom event type - or i can use any existing one if needed).  The event has a field (variable number of) subscribers to it.

If a user want to subscribe to event he/she can fill in a web form. Alternatively Subscription can be done by having a button (if such a thing is possible on node).

The problem is, usually such triggers help send an email post this. However, i want that once such an event happens, i want to modify the target node and append the current user_reference in the list of subscribers in the node.

So basically, when a user subscribes the page, the system modifies the node to append the name of such a user in the subscriber's list.

Is such a thing possible? If so, how?


texts: Page cache works on local dev but not on production

texts:
I've a Drupal 8.6.9 site running on Apache 2.4 and PHP 7.2. I've enabled the internal page cache, the dynamic page cache, and the BigPipe module in an effort to tease out some more performance.

I've set max-age to 1 day, under /admin/config/development/performance.

On my local development site (drupalvm, Ubuntu 16.04) I can see X-Drupal-Cache: HIT and a visible improvement in performance, but on the hosting server, also Ubuntu 16.04, I only ever see X-Drupal-Cache: MISS.

As far as I can tell, there's nothing amiss in settings.php on the live server, the Drupal config is identical, so there must be something amiss in the Apache settings, perhaps.

Has anyone come across this before where cache works on one environment, but not another?


texts: How to remove the "Close comment thread" button in Open Atrium?

texts: On my casetracker nodes in Open Atrium, the atrium.module inserts a "Close comment thread" / "Reopen comment thread" button.  What's the simplest way to remove this button, without having to modify atrium.module?


texts: How to let user decide how comments be sorted

texts:
The scenario is, in a project comments has a vote up/down field so users can rate a comment. What I'm looking for now is a solution so user can decide if comments should be sorted by date created (newest first) or by its rate (top rated first).
Should I use a views for that? if so how can I hide main comment section?


texts: Create A Block To Add Field Collection Item

texts: I want to create a block that would hold links to add different field collection items. How would i do this? I am new to drupal, please point me to right direction or help me get started.


texts: MailChimp campaign not showing up in Drupal 7

texts:
I set up the MailChimp (https://drupal.org/project/mailchimp) module by following the readme file. I've enabled all the Mailchimp modules and added the API key to my drupal instance. I've created and Sent one campaign through MailChimp however, when I go to /admin/config/services/mailchimp/campaigns the page is blank. I've cleared the cache but the page is still blank. I was expecting to see the campaign I sent earlier but it is not there.

What am I doing wrong or missing?


texts: Overriding Views markup in handler file (views_handler_field.inc)

texts:
I'm new to theming in Views, but I get the basic idea of working with templates. However, I want to make a small change to the views_handler_field.inc file without hacking Views. All I want to do is add an additional css class in order to open the read more link in a colorbox. This refers to the link that is output when trimming a field to a maximum length in the field settings.

What is the best way to do this? Is there some similar process for overriding handler files as there is for theme templates?


texts: I have an exposed form (from a view) in a block. I'd like to make this block collapsible so that a user is presented with a search box and one other field and when a user types in the search box the form expands out to include the remainder of the form fields. I know I can use ctools_collapsible to make content collapsible but how do I extend this to any div/region?


texts: How to get event node to pull in data from a seperate node?

texts:
I'm trying to setup an events calendar in drupal 6. I have an event content type and a location content type. My problem is that I want the event node to display relevant data from the location node such as location name, address, hours, etc.. I'm not sure of the best way to set this up?

Additional info: My event content type has a cck node reference that points to the location node. I was looking at the reverse node reference module but wasn't sure if that was necessary, maybe this can be accomplished using existing views and block functionality.


texts:
I don't know why, but this page on a site that I administer messed up by itself!

I didn't touch it after it was set up and running well.
But as you can see the content now doesn't fill all the page, and I can't understand why! I tried to delete the view and do it from scratch again, but the problem is still there!

Can you help me try to understand where the error is?


texts:
I'm trying to embed custom content (custom javascript, paragraphs etc) with a Drupal Form. I'm wondering whats the best way to do it in module?

Something like this:

function wow_page() {
    drupal_add_js('jQuery(document).ready(function () { alert("Hello!"); });', 'inline');
    $output = 'teasdasdst';
    $output = '

';
    $output .= drupal_get_form('wow_cake');
    return array('#markup' => $output);
}


texts: How do I pre-populate the login/sign up form?

texts:
I'm working on a project that let any user (anonymous) register for an event. An event is a content type that has duration, name and price and possibly a date. So, when a user browse through different events, they can register for an event by simply clicking on the "Register for this Event" What needs to happen when they click on Register.. is: the info related to that event needs to pre populate to the member login form so that they don't have to fill the event info again.

The user must be a member before they can register for the event but I am trying to give a nice user experience to the user so that he/she can simply click on the Register link and then they will be redirected to the user login/sign up form the event info pre-loaded and they provide the rest of the info.
I have already extended the standard Drupal login form to my need and also created the event content type. Thinking to use flag module to make Register link but have NO idea how to pre populate that event info into the login form. Any help or guide will be highly appreciated. Thanks in advance.


texts: Displaying Line Item Fields in a View (SQL Error)

texts:
I've built a conference registration system using Commerce and Custom Line Item types, and I'm having trouble figuring out how to display my Custom Line Item fields in a View. Here's a short summary of what I've done:

The registration fields (e.g. name, email, etc.) are fields in a
custom line item type.
My product view doubles as a registration form. It displays the fields of my custom line item type as part of the add to cart
form. It also references a custom product type I created for the
conference.
Some of the fields in the custom line type are booleans that trigger rules that add additional related products to the cart (e.g. hotel accommodations, meals, etc.).

I've built a View that summarizes the store's Orders, so that the conference organizer can see all of the Order info without having to know anything about Commerce or the Drupal admin pages. When I add the Line Items to this Order View, only the products show up (both the product referenced in my view, and those added by rules) - the other fields I've created for capturing the registration data (name, email, etc) don't show up.

I've also attempted to make a View that shows only Line Items (filtered to only my Custom Line Item Type), but nothing shows up and I get the following SQL error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'commerce_line_item.uid' in 'field list'

Any help on getting my other Line Item fields to show up, or insight into this SQL error, would be MOST appreciated. Thanks!

(For some brief background, I have built other solutions using Commerce in conjunction with the Registrations module. This has caused a lot of problems, so I am attempting to recreate similar functionality without the Registration module)


texts: Wrapping javascript code conditionally using a cookie

texts:
I want to include the following code in page.tpl.php only once during first site visit and for subsequently not. I mean this will pop-up an ad only once. I want to set it based on a cookie. How to conditionally include this code based on a cookie? I need the sample code.

<script language="JavaScript">
        var zflag_nid="1185"; var zflag_cid="3307"; var zflag_sid="823"; var zflag_width="1"; var zflag_height="1"; var zflag_sz="15";
        </script>
        <script language="JavaScript" src="http://d8.zedo.com/jsc/d8/fo.js"></script>

EDIT:

Will this work in page.tpl.php ? I want add it before </head> so that the js file is included only once in user session.

<script type="text/javascript">
    if(!jQuery.cookie('myCookie'))
    {
    $.cookie('myCookie':'myValue');
    <!-- Javascript tag: -->
<script language="JavaScript">
var zflag_nid="1185"; var zflag_cid="3307"; var zflag_sid="823"; var zflag_width="1"; var zflag_height="1"; var zflag_sz="15";
</script>
<script language="JavaScript" src="http://d8.zedo.com/jsc/d8/fo.js"></script>
    }

</script>


texts: Login to external server from Drupal site

texts:
Is there any way to customize Drupal login to use authentication from an external server?

I'd like to know about any modules or if Drupal core can implement this function.

Source code:

// Include FirePHP for debug

function authdave_form_alter(&$form, &$form_state, $form_id) {
    // Authentication based on username and password
    if ( ($form_id == 'user_login' || $form_id == 'user_login_block') ) {
        $form['#validate'][] = 'authdave_user_form_validate';
    }
}
/**
* Custom form validation function
*/
function authdave_user_form_validate($form, &$form_state) {
    if( !authdave_authenticate($form_state) ) {
        form_set_error('name', t('Unrecognize username.'));
    }
}
/**
* Custom user authentication function
*/
function authdave_authenticate($form_state) {
    // get first four characters from user name
    $complete_username = $form_state['input']['name'];
    $password = $form_state['input']['pass'];

    // retrieve users credentials from DB
    $credential = get_all_credentials();

    while($row = $credential->fetch_assoc()) {
        // check if there are any match
        if ( $row["username"] ==  $complete_username && $row["password"] == $password) {
            user_external_login_register($complete_username, 'custom_athentication');
            return TRUE;
        }
    }

    return FALSE;

}

function get_all_credentials() {

    //credenziali di accesso al dbms
    $server = "****";
    $username = "***";
    $password = "***";

    //nome db
    $db_name = "credenziali_db";

    //creo una connessione con il dbms
    $conn = new mysqli($server, $username, $password, $db_name);

    if ($conn -> connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    echo "Connection successfully";

    //sql query
    $sql = "SELECT username, password FROM credenziali";
    $result = $conn -> query($sql); //risultato della query

    return $result;

}

?>


texts: Performance (or other) benefit to adding CSS and JS files in a .info file rather than tpl?

texts:
Ive always the Zen theme and added additional CSS and JS files in the page's tpl file, rather than using the .info file. Is their any performance or other downside to my method?

Thanks


texts: Why would error / warning / success messages stack up when using a Service?

texts:
I have a mobile app that uses Drupal as an API. As you navigate the site everything works as normal with appropriate messages on errors, warnings, and successful form submissions.

After doing that a while, when I first go to any Drupal page, Drupal finally prints all the 20+ messages that had occurred while using the Service. I haven't investigated how the messages are stored, but it's either memory consuming and/or heavy on each subsequent request.

How do you prevent messages from being stored for the next page load when those messages are already received via AJAX in the returned JSON.

Some of these messages are from Core modules and others are my own necessary calls to form_set_error so that hook_node_validate does not execute the insert.


texts: How to add form fields dynamically using webform

texts:
Using webform 3 module, is there a way to dynamically add more fields or do these fields have to be created in the database first?
Currently that's what I am doing and with javascript toggling the css display attribute to show or hide fields.


texts: D7 - Organic Groups User Group Permissions when adding other Members

texts:
I really am struggling to come to grips with this using OG-7.27...I have the standard Drupal roles (anon. user, authenticated user, administrator) as well as the standard OG Roles (non-member, member, administrator member) installed.

I want to allow all users in the Drupal role of administrator to create all groups, and for these users to empower certain Drupal authenticated users to manage content and add/remove users to/from it. Drupal authenticated users will be promoted to the OG Role of administrator member when the Drupal Admin user adds him/her to the group. The problem is that when I test this I see that this promoted user can see the ability to:

Block or Remove the Drupal Admin user (even though it actually does not seem to work)
Add other members to the group with the option to add them to the OG administrator member role.

I don't wish for either of these to happen. Below some screenshots:

As seen by the Drupal Admin User:

As seen by the OG Administrator User:

Again as seen by the OG Administrator User when managing group members:

Please may I ask your help as I'm not sure I've configured this properly. Yep, you guessed it...OG noob here. I did go through the videos on Modules Unravelled channel on YouTube, but I still don't get why this is not working?


texts: Show last, last two or last three nodes depending on role

texts:
I'm working on a site where members can have three different roles.
Gold, Silver and Bronze.

Now I'm trying to set up a view that will display the:
last three nodes of all Gold members and
last two nodes of all Silver members and
the last node of all Bronze members,

I want all these nodes displayed together on the homepage, randomly ordered. And I just can't figure out how to do this.

I can make a view that shows all last nodes of all users. And I tried working this out with "views field view" making different views showing nodes per user and combining these views in one view but then I am not able to randomly order them.

Well I hope someone can help me out here.
Thanks in advance


texts: Trying to programmatically alter the id of an exposed filter in views

texts:
This is for Drupal 7.

I am trying to modify an exposed filter's id in views. Basically we've noticed a use-case with multiple simple hierarchical selects on a given page, in separate exposed filter forms will conflict because they're using the same id attribute in the HTML.

The solution we've come up to to solve this is to append a short hash to the end of this id, making it unique across the page.

The problem is that I'm having trouble figuring out exactly where to do this, and the views objects' immense size doesn't help me in tracking down exactly where I have to make this change.

I'm trying things like this (this is in hook_views_pre_view):

$view->display['DISPLAY_NAME']->handler->options['filters']['field_FIELD_NAME_HASH-HERE'] = $view->display['DISPLAY_NAME']->handler->options['filters']['FIELD_NAME'];

$view->display['DISPLAY_NAME']->handler->options['filters']['field_FIELD_NAME_HASH-HERE']['expose']['identifier'] = 'field_FIELD_NAME_HASH-HERE';

$view->display['DISPLAY_NAME']->handler->options['filters']['field_FIELD_NAME']['expose']['operator_id'] = 'field_FIELD_NAME_HASH-HERE_op';

However this only seems to throw an error.

So how do I change the id on a given exposed filter for a view/display?

EDIT - this is the markup I am trying to affect:

 <select class="element-invisible shs-enabled form-select shs-processed" id="edit-field-FIELD_NAME" name="field_FIELD_NAME" style="display: none;"><option value="All" selected="selected"><option></option></select>
<select id="edit-field-FIELD_NAME-select-1" class="shs-select form-select shs-select-level-1 chosen-disable" style="display: inline-block;"><option></option></select>

Everywhere that has FIELD_NAME either has the default field name, or if I change it in Views, the changed identifier, however I can't seem to change any of these names programmatically - even with the answer below, which is what I really need to do.

How do I affect this markup?

Here is my current hook_preprocess_views_exposed_form:

if($vars['form']['#id'] == 'views-exposed-form-reference-views-block-1') {
    $number = <NUMBERHERE>;
    $vars['form']['#info']['filter-field_FIELD_NAME']['value'] = 'field_FIELD_NAME_' . $number;
    $vars['form']['field_FIELD_NAME_' . $number] = $vars['form']['field_FIELD_NAME'];
    $vars['form']['field_FIELD_NAME_' . $number]['#id'] = 'edit-FIELD-NAME-' . $number;
    $vars['form']['field_FIELD_NAME_' . $number]['#parents'] = array('field_FIELD_NAME_' . $number);
    $vars['form']['field_FIELD_NAME_' . $number]['#array_parents'] = array('field_FIELD_NAME_' . $number);
    $vars['form']['field_FIELD_NAME_' . $number]['#name'] = 'field_FIELD_NAME_' . $number;
    $vars['widgets']['filter-field_FIELD_NAME']->id = 'edit_field_FIELD-NAME-' . $number;
    unset($vars['form']['field_FIELD_NAME']);
  }


texts: How to display entire comments in separate page

texts: I know we can display reply form in separate page. But now I having the requirement of displaying entire comments and reply form in separate page. Is there have any way to display those in separate page.


texts:
I've created a custom action to fire when the "checkout is complete" event occurs. The front end is a mobile application, where as the back end is Drupal. So I create an order using its API and update the status the of the order to "complete" manually. But the event is not triggering.

Do anyone know what I'm doing wrong? When I've changed the event to when an order is created, the action is performing.


texts: Categorizing and Sorting Webform Submissions

texts:
I'm trying to find an effective way to categorize and sort webform submissions. I already have them displaying in views, but would like to take it a bit further. Here's the goal:

Anonymous users can fill out an employment application on our site (via a webform). Our recruiter would like to be able to sort through these applications and do things such as categorize them (accepted, denied, etc.) by selecting multiple at once, and send batch emails to applicants.

I already have Views Bulk Operations installed, but it doesn't seem to play well with webform submissions, if at all. Does anyone know of a good way to accomplish this?

I'm on Drupal 7, using Views 7.x-3.6 and Webform 7.x-4.0-alpha6.


texts: How can I get Drupal to hide menu items that user does not have permission for?

texts:
I thought Drupal was supposed to do this (and sometimes it does), but I'm not seeing this behaviour, so thought I'd ask.

My Main Menu contains three manually-added links to useful stuff.

Administration - this one auto-hides; cannot be seen by anonymous users.
Application - provided by a Module. Does not auto-hide, yet the module defines the path as requiring a certain permission that anonymous users don't have.
Documentation - link to a Documentation node type. I'm using Content Access Control and have not provided permission to view this content type for anon users. Should be hidden but is not.

Can anyone explain when drupal hides stuff and when it won't be able to? Obviously there's the "install yet another module" approach that will provide a brute-force fix, but I'm interested in why the behaviour is erratic/unreliable.


texts: What is the proper function for multi dimensional localized menu?

texts:
What is the proper function to get multi dimensional localized menu in Drupal 7?
after searching, I found i18n_menu_localize_tree(), but I didn't get it as tree menu.
Should I use i18n_menu_translated_tree(), or did I miss something?


texts: Move content from field to field collection

texts:
I'm working on a site where a current content type has six image fields, six title fields & six content fields. One field from each (one image, one title & one content) all make up one group, so in total there are six groups of these.

Is it possible to move these into a field collection? I just think it'd be tidier, make more sense & make it easier to maintain.

Also if this is possible, not only how do I do it but is it even wise to move content from a 'normal' field to a field collection like this?


texts: Contextual filter with Node Reference and Pathauto

texts:
I work for an organization that makes research grants. We periodically write "research briefs" for our grants to summarize what they found. My test Drupal site has a view of research briefs, and what I'd like is to display a block of grant information as a user is looking at a specific research brief.

I've got two custom content types: grants and research-briefs. The research-brief content type has a node reference field to grant ID. I use pathauto, so an example research-brief path is: site.org/research-brief/551023442 where 551023442 is the grant ID.

The way it seems I should set up the block view contextual filter is:
Content: Parent ID (field_parent_id)
When the filter is not available:
   Provide the default value.
   Type: Raw value from URL
   Path component: 2
   Use path alias: checked

This doesn't work and I've tried any number of fields and any number of configuration options and would sure appreciate any helpful pointers. If I display all results I can see all grants in the block.


texts: How can I keep track of anonymous users?

texts:
I'm developing a module based on commerce that keeps track of certain user product selections by writing them to a database table. To keep track of who selected what I use the user id for registered users and the session id for unregistered ones. Or at least I would if it weren't for the fact that Drupal keeps changing the session id for every request.

Why is it doing that and how do I make it stop? Or is there a Drupal way of tracking anonymous users that does not involve session_id()?


texts: Views exposed filters : hide options with no results

texts:
This question is about a Drupal 7x site.
I have a views block that display products (= content type). This views is using AJAX and an exposed filter to sort results per taxonomy terms (products categories) in specifics contexts.

I just want my exposed filter to hide options with no results (because it is useless to show them if there is no results...). I thought there was an easy way to it, but cannot find it...

I have already find these docs but i really want to exclude custom modules if possible (client needs) :
https://ffwagency.com/blog/limiting-select-options-for-exposed-filter
How to make exposed filters to hide field with no value?


texts: How to store multiple values in a profile field (specific to each users)?

texts:
I have a profile filed called Amount corresponding to each users, and I want to store multiple values in the profile field Amount. Bu using the custom module, the value of Amount is to be inserted on each registration (or it can be inserted any time by a cron program).

For example User Williams has Value 100 in his Amount field. This is not a single value, it may be

Time    Amount
-------+------
Hour 1 :  10
Hour 2 :  30
Hour 3 :  20
Hour 4 :  35
Hour 5 :   5
============
Total  : 100

I want to display the total amount and individual amount by exact time.

How to do it?


texts:
Is it possible to add arguments from $_GET to the core search?
For example:

search/term1/mystring

This search page should show results that have the "term1" term. Like views, but I've to add this function to core search :)


texts: drush sqlq --file on remote server with local file

texts:
Im trying to run run write a command where I can execute remote queries stored local.

I was trying:

drush @remote.master sqlq < src/sql/data.sql

but no luck, also tried the option --file=path/to/file but it's only for remote files :(

Any ideas?


texts: Show block on all 404 / 403 pages only via context

texts:
Without having to install even more modules on the site for context. I know there a boat load of plugins for context, but I was wondering if this can be achieved by just using core context:

I basically want to show a view block on all the 404/403 pages, which are just basic page nodes. The problem with context is when you choose path as the condition, it will only show up on that path, which is the 404/403 node paths only. Even if you put in something random like: foo.com/adsfadsf -- the context won't fire since its not a recognized path even though it is the 404 page.

What context recipe can restrict a block to show up on the error pages only? I know i can list out all the paths i dont want it to show up on, but thats not going to work in my scenario.


texts: How to make administration menu display child links without child url

texts:
My question is probably a little confusing, so I'm gonna explain with an example. Whenever I create a parent link like "admin/test/execute", the administration menu will display the link and if I create another link "admin/test/execute/log" the menu will display "log" as a child of "execute".
My problem is when I try to add a child to "admin/test/execute" with the following link "admin/structure/ctools-content/list/page", the administration menu doesn't display this link. I tried creating an url alias("admin/test/execute/page") but when I add the alias to the menu, the alias get's converted to the original url.

Solution:

The solution to my problem was in the menu item weight instead of using the drag and drop option, I've changed the parent link weight, and the links started getting displayed correctly.


texts:
Bootstrap.js is breaking a menu plugin I'm using. It's called with this

  $bootstrap = $theme_path . '/js/bootstrap.js';
  $js[$bootstrap] = drupal_js_defaults($bootstrap);
  $js[$bootstrap]['group'] = JS_THEME;
  $js[$bootstrap]['scope'] = 'footer';

in themes/bootstrap/theme/alter.inc. I tried putting a modified alter.inc inside themes/child_theme/theme/ but it doesn't work. Is there a function I can use to override it?


texts:
I use PHP filter module, and write this in other field in my node:

<?php
  $node = node_load(52);
  $field = field_view_field('node', $node, 'myfield');
  print $field;
?>

It doesnt work.
And how i can load id for node?


texts:
I am loading an unmananged image file and would like to render it in a block, but it should be linked.
I have an uri (public://...) and I am able to render the image using

$build['my_image'] = [
          '#theme' => 'image_style',
          '#style_name' => 'large',
          '#uri' => $uri,
];

This works, but how can I render it beeing linked to some url?


texts:
I'm trying to migrate content from an Expression Engine database to Drupal 8.

I set up a $databases['migrate']['default'] in settings.php and copied and modified BeerNode.php from migrate_plus migrate_example module in a custom module.
This is my query code in BlogNode.php.

  public function query() {
    // $this->configuration['ignore_map'] = true;
    $query = $this->select('exp_weblog_titles', 'tab1');
    $query->addField('tab1', 'entry_id', 'bid');
    $query->addField('tab1', 'title', 'name');
    $query->addField('tab2', 'field_id_10', 'body');
    $query->innerJoin('exp_weblog_data', 'tab2', 'tab1.entry_id = tab2.entry_id');
    $query->condition('tab1.weblog_id', 10, '=');
    return $query;
  }

Now Drush complains about a missing column:

  Migration failed with source plugin exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'b.bid' in 'on clause':

SELECT tab1.entry_id AS bid, tab1.title AS name, tab2.field_id_196 AS body, map.sourceid1 AS migrate_map_sourceid1, map.source_row_status AS
migrate_map_source_row_status
FROM
{exp_weblog_titles} tab1
INNER JOIN {exp_weblog_data} tab2 ON tab1.entry_id = tab2.entry_id
LEFT OUTER JOIN destinationdatabase.migrate_map_blog_node map ON b.bid = map.sourceid1
WHERE  (tab1.weblog_id = :db_condition_placeholder_0) AND( (map.sourceid1 IS NULL ) OR (map.source_row_status = :db_condition_placeholder_1) );

This is the implementation of getIds():

  public function getIds() {
    return array(
      'bid' => array(
        'type' => 'integer',
        'alias' => 'b',
      ),
    );
  }

I assume that the second part of the query should be ON tab1.entry_id = map.sourceid1 but I can't set anything other than bid.

I kind of resolved by temporarily setting $this->configuration['ignore_map'] = true; before the query losing some traking functionality though.


texts: Add html widget programmatically to the list “Add fields” in views in Drupal 7

texts:
I'm trying to create a html widget that will be available in all views. I would like to have the widget available in the list "Add fields" in views.

The module Easy social have this functionality, but I can't figure out how they did that.

So how can I from my module programmatically add fields to the list "Add fields" for views?

Any help appreciated.


texts:
Is there a module that allows me to restrict searches to node titles, rather than any node content?
Preferably the user would choose between titles only or everything.


texts:
I have a view with an exposed filter for the node titles. I want to add X in that exposed filter.

I know html5 provides feature to have cross symbol when the input type  is search. I tried changing #type in hook_form_alter() for the text-field to  search, but it doesn't work.

Is it possible in Drupal 7?


texts:
how can I get all (custom) data from other users ?

With my admin account, I want to show them in a page.

For example :

  user 1 :

  name
  age
  custValue

  custValue1 / 2  / 3

I want to get custValue and the other data (custValue is the most important)

Example of values that I want to show :


texts:
I'm working on custom 301 redirect module. I am getting a redirection loop if source url ==  www.xyz.com/aboutus/*.php and destination url == www.xyz.com/aboutus/xyz.php

or source url = /abc/* and destination url = /abc/legal-disclaimer

How can one handle such type of redirections?

How can I validate source url with wildcard while submitting source url and target url in form? Because during form submission, if I write

drupal_match_path($current_path_alias,$source_url)

This will not gonna work as $current_path_alias is not the source url that I have passed in form.

Any way to break this redirection loops??


texts:
Within a page callback, I need to:

Create a new node.
Retrieve the nid from that new node.
Create an entity reference in an already existing node (referenced in a parameter passed to my page callback) TO that newly created node.

The first thought was to use drupal_goto. However; drupal_goto "ends the request".

  (per
  http://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_goto/7)

As expected, I execute the drupal_goto('node/add/newnode'); The node gets created, and I'm out of the page callback...

Any suggestions would be most welcome!


texts:
I have an issue with FireFox where it can't download generated private file PDFs, yet Chrome has no such issue.

We populate PDF files with TCPDF and they get moved and copied into a few different directories. But ultimately, they're in directories in the private files directory behind the document root, with Drupal configured to look at this directory.

If I move any of these PDFs into the root of the site and access them directly with the URL, it works fine, but I wouldn't rule out the PDFs being corrupted in some small way. I've looked at the response headers when the file's downloading and all is in order, until I get this NS_ERROR_NET_PARTIAL_TRANSFER message and it fails.

I've run with xdebug enabled and stepped through hook functions of hook_file_download and the headers generated there all seem ok too.

Other private PDFs that aren't generated can be downloaded no problem.

I'm really running out of ideas of what it could be regarding FireFox and the private files system.


texts: Installing Drupal 7.22 fails at database configuration step on Win7

texts:
I succeeded to install drupal 7.22 on my production server but still fail to have it running on my local EasyPHP running on win7 64b.

At database configuration step of the install process I have the following message:

Warning: in DatabaseConnection->__construct() (line 304 of C:\Program Files (x86)\EasyPHP-5.3.2i\www\drupal-7.22\includes\database\database.inc).
In order for Drupal to work, and to continue with the installation process, you must resolve all issues reported below. For more help with configuring your database server, see the installation handbook. If you are unsure what any of this means you should probably contact your hosting provider.
Failed to connect to your database server. The server reports the following message: .

You might note that no error message is actually reported.

The mentionned line 304 is opening the connection:

// Call PDO::__construct and PDO::setAttribute.
parent::__construct($dsn, $username, $password, $driver_options);

I verified db name, credentials, and other settings by connecting on the database with MySQL Workbench which succeed to connect to db.

I tried editing myself the default.settings.php:

$databases = array(
  'driver' => 'mysql',
  'database' => 'drupal-7.22',
  'username' => 'datagrmdb',
  'password' => 'mypassword',
  'host' => 'localhost',
  'port' => 3306,
  'prefix' => 'drupal_',
  'collation' => 'utf8_general_ci', // also checked that DB is configured this way
);

but that still failed.

I tried editing settings.php directly and reloaded the install process to continue but it stop saying that "Database is already installed". It suggest to empty the db but it is already empty.

Back to drupal wizards I also tried using 127.0.0.1 instead of localhost and setting 3306 manually but that did not changed.

There is another drupal database (another version) in mysql but I assume that should not cause any problem.

EDIT: I verified php_pdo.dll and php_pdo_mysql.dll exist in the php/ext directory

Any hint?


texts:
I have a module which shows content with the page callback. Here is my page callback (just the relevent code):

function my_page_callback() {
    $build=array();
    $build[] = array(
        '#theme' => 'my_theme',
        '#marker' => 'foo',
        '#data' => ...,
        '#contextual_links' => ...,
    );
    $comment=comment_node_page_additions(node_load(getTargetNodeId()));
    $build[]=$comment['comment_form'];
    return $build;
}

However the function getTargetNodeId() retuns a valid id of a node which is generated unter some conditions with this code:

$node = new StdClass();
$node->nid=42;
$node->vid=42;
$node->uid=1;
$node->type = 'my_type';
$node->status = 1;
$node->title = "Fresh generated";
$node->content['mapping'] = 4711; // some internal magic
$node->comment='2';
$node->language = LANGUAGE_NONE;
$node->body[$node->language][0]['value'] = "This text should nobody read.";
node_save($node);

Even if in the code above the nid and nid are fixed I take care of it the ids are unique.

And here is my code where I render my node:

function module_node_view_alter(&$build) {
    if($build['#bundle']=='my_type') {
        $p=my_page_callback;
        $build['body']=$p[0];
    }
}

However the the comment header is generated but the input field is missing. What is the problem?


texts: How can I target a webform results page to create a panel around?

texts:
I'm trying to set up a panel for the submitted page for a webform in order to add a sidebar and bottom section. I need help setting up the panel, specifically with how to select the submission (results) page of the webform.

The url of the submitted page looks like this - http://site.localhost/node/2136/done?sid=8

I tried -

String: URL path : Current path is "node/2136/*"

as well as -

String: URL path : Current path is "node/*/done"

both were a no go

Any ideas?


texts:
I cannot programmatically create a node in anything other than en language.

My site has 3 languages:

en
fr
de

And the code for creating a node is:

define('DRUPAL_ROOT', ...);
require_once DRUPAL_ROOT . 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$node = new stdClass();
$node->type = "foobar";
node_object_prepare($node);
$node->title = 'test title';
$node->uid = 1;
$node->language = 'fr'; // *** this doesn't seem to work

if ($node = node_submit($node)) {
  node_save($node);
}

No matter what I type in the $node->language = '...'; the result is always the same. The node is created in the English language. I confirm that via looking at admin/content.

I've even tried stuffing this variable with a proper language object which I got out of the enabled languages of my site:

$languages = language_list('enabled');
$lang = $languages[1]['de'];
$node->language = $lang;


texts: Let users download and set induvidual blog themes Drupal 7

texts:
I want to enable users customize their own blog appearance and theme the same way it is being done in multi-user blogging sites such as wordpress.com, tumblr.com, typepad.com, etc.

Users can set a theme to their blog
Users can manage some settings regarding ther blog appearance (background color, fonts, etc.)
Users can download themes or even make their own themes available for others.
The theme setting only affects the user blog page (but not the general site layout).

Any possible suggestions to make part of those requirements implemented quickly?


texts:
I'm using the form api #states feature to show and hide fields based on the value of other inputs.

This is working great however I would like to have the option to fade or slide the inputs as they are shown and hidden.

I realise the conditional fields module offers this functionality however I found it too buggy to use.

This live example from the examples module shows the Additional Information section sliding up and down when the checkbox value is changed.

The code used to achieve this:

$form['more_info'] = array(
  '#type' => 'fieldset',
  '#title' => t('Additional Information'),
  '#collapsible' => TRUE,
  '#collapsed' => TRUE,

  // Expand the expand_more_info fieldset if the box is checked.
  '#states' => array(
    'expanded' => array(
      ':input[name="expand_more_info"]' => array('checked' => TRUE),
    ),
  ),
);

This made me think using 'expanded' instead of 'visible' would make the element slide and not just appear however this is not working for me.

I am editing a node form using hook_form_alter so my working code (but with no effect) looks like this:

$form['field_full_name'][LANGUAGE_NONE][0]['value']['#states'] = array(
    'visible' => array(
        ':input[name="field_person_type[und]"]'=> array(
            array('value' => 'Contractor'),
            array('value' => 'ICM'),
            array('value' => 'Member of public'),
        ),
    ),
);

Replacing visible with expanded or collapsed has no effect so I guess these properties only apply to fieldsets, not elements. A full list of possible states can be found here.

So, is is possible to fade or slide form elements using #states?


texts: How to know if jQuery UI is being included

texts:
Is there a good way of checking for if jQuery UI is being included on the current page request?

Found drupal_get_library(), and drupal_add_library(), but neither of them allows me to check if it is being included.

I am trying to do this from the theme, and then load a jquery.ui.touch-punch library to enable iPad/iPhone support.


texts: How to add more than one tags for content?

texts:
For example, I want to create two tag, one is "new", the other is "test"，Now tags is "new test"
Screenshot:


texts: Update database with update module disabled

texts:
I have recently inherited a site which needs protecting from the recent security exploits. The site has not been very well maintained but the hosting company can provide me with a database dump from 6th October.

Trouble is, the database dump has the update module disabled. When I try to restore the site and upgrade to the latest core version* I am prevented because updating is disabled.

Is there a way of enabling the update module via the database? I am pretty new to drush and do not yet have it enabled on the server.

*Actually it's an early version of Commerce Kickstart 2.


texts: Require approval only for the first content that a user submit

texts:
My Drupal 7 site just went live.

In my site, there is an option the register regularly (Drupal core way), and with social login (hybridauth).

Currently, only authenticated users can post content and comments on my site.
Unfortunately, I already have many fake users publishing content on my site.

I want to be able to approve content for new users, but only for the first 3 pieces of content.
After that, if I approved 3 pieces of content for the user (which mean I trust him), I want to allow him to post any content he wants, without any need for approval.

How can I achieve my goal?
Can I do that automatically - meaning that after I approved 3 pieces of content - the user will automatically  be able to post content without approval?


texts: Can't get values from $form in submit handler?

texts:
Using Drupal 7 and a custom form generated with the Webform module, I'm trying to get info from the submitted form to save in additional SQL tables.

I know my submit handler is being called because putting dpm('This is great news, our submit handler is being called!'); inside the submit handler gives the expected output. So does dpm($myvariable); (after setting a value for $myvariable).

But dpm($form); not only doesn't return anything, but also seems to preven the other dpm() functions from working. There are no errors logged, and the page loads otherwise normally.

I should also mention that if I put the dpm($form) in the hook_form_alter() function instead of the submit handler, it does show up, but all values appear to be default or empty, after the form is submitted.


texts:
I've a Drupal 7 site setup on an AWS server, and I'm trying to access a mysql db on a AWS RDS.(The Drupal db is located on the Drupal server, the table I'm trying to get is just to access some external data).

When I try to use the Views API I get the following error:

  PDOException: SQLSTATE[HY000] [1045] Access denied for user 'drupal_viewer'@'localhost' (using password: YES) in views_plugin_query_default->query() (line 1293 of /opt/bitnami/apps/drupal/htdocs/sites/all/modules/views/plugins/views_plugin_query_default.inc).

I've setup the mysql user "drupal_viewer" with the correct permissions, and to verify that I've created a short php page in the root folder of the Drupal server. When I run that, it runs fine and connects and executes a test query. So that verifies that the security groups etc are fine and that my Drupal server can "see" the RDS instance.

I've tried various combinations of the user on the mysql setup (@%, @localhost and @127.0.0.1), but the views API keeps trying 'drupal_viewer'@'localhost' which is failing.

I have the db info setup correct in my settings.php (and have done Clear Cache etc).

$databases['pc_propertychannel']['default'] = array (
  'database' => 'propertychannel',
  'username' => 'drupal_viewer',
  'password' => 'xxxxxx',
  'host' => 'pc-live-main-db.xxxxxxxxx.eu-west-1.rds.amazonaws.com',
  'port' => '3306',
  'unix_socket' => '/opt/bitnami/mysql/tmp/mysql.sock',
  'driver' => 'mysql',
  'prefix' => '',

);

What am I forgetting?

[Edited to Add: as a debug, I tried connecting via mysql console from the Drupal server to my RDS instance, using the above credentials, and it works fine. So I'm thinking this may be a Drupal config/issue?]


texts: How to prevent image/file deletion from a configForm if don't press on submit button?

texts:
I created a custom config Form in drupal 8, and this form have a managed_file field for upload a logo, the problem is that i set all fields, upload my image and fill other fields, press save, and in this point everything works normal. But if i press on "Delete" button of the image, my file is automatically deleted from my file directory and i have not saved the changes to my form yet.
so in my config still saved a fid of my deleted file. But the file was deleted before save my config form so if i update the page without save not matters, my file was deleted.
Any ideas for control this event to prevent this deletion if i don't save the configuration Form?
my_module/src/Form/CustomForm.php
<?php

namespace Drupal\my_module\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\file\Entity\File;

/**
 * Class CustomizationForm.
 */
class CustomForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'my_module.custom',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'custom_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('my_module.custom');

    $form['menu_logo'] = [
      '#type' => 'managed_file',
      '#title' => $this->t('Menu logo'),
      '#upload_validators' => [
        'file_validate_extensions' => ['png jpg jpeg'],
        'file_validate_size' => [25600000],
      ],
      '#theme' => 'image_widget',
      '#preview_image_style' => 'medium',
      '#upload_location' => 'public://',
      '#default_value' => $config->get('menu_logo'),
      '#required' => TRUE,
    ];
    $form['splash_screen'] = [
      '#type' => 'managed_file',
      '#title' => $this->t('Splash screen'),
      '#upload_validators' => [
        'file_validate_extensions' => ['png jpg jpeg'],
        'file_validate_size' => [25600000],
      ],
      '#theme' => 'image_widget',
      '#preview_image_style' => 'medium',
      '#upload_location' => 'public://',
      '#default_value' => $config->get('splash_screen'),
    ];
    $form['theme'] = [
      '#type' => 'select',
      '#title' => $this->t('Theme'),
      '#title_display' => 'invisible',
      '#options' => ['dark' => $this->t('Dark theme'), 'light' => $this->t('Light theme')],
      '#default_value' => $config->get('theme'),
    ];

    $form['#attached']['library'] = [
      'my_module/customization_form',
    ];

    $buildForm = parent::buildForm($form, $form_state);
    $buildForm['#theme'] = 'customization_form';

    return $buildForm;

  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);

    $this->config('my_module.custom')
      ->set('menu_logo', $form_state->getValue('menu_logo'))
      ->set('splash_screen', $form_state->getValue('splash_screen'))
      ->set('theme', $form_state->getValue('theme'))
      ->save();

    if (!empty($images)) {
      foreach ($images as $image) {
        $file = File::load($image[0]);
        $file_usage = \Drupal::service('file.usage');
        $file->setPermanent();
        $file->save();

        $file_usage->add($file, 'my_module', 'file', $file->id());
      }
    }

  }

}


texts: Unable to uninstall an incompatible module

texts:
I have 6.22 core and by mistake added the folder for quicktags 7.x-3.0 to the modules folder.

I deleted the folder, replaced it with 6.x but nothing seems to allow me to enable the quicktabs module under "Home » Administer » Site building » Modules."

All I get against the quicktab folder is:

  This version is incompatible with the 6.22 version of Drupal core.

How can I install the correct version of the module?


texts: get taxonomy terms of specified language

texts:
I know I can get list of of taxonomy of a vocabulary with

 $terms =  \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('course_category');

 kint($terms);

but it returned all that vocabulary terms, I am working on multi language site,I want retrieve terms of specified language.

my Drupal version is 8.1.3


texts: How to override the default image style for displaying user picture?

texts:
I have Statuses Module installed on one of my site. I have created a view to display the status along with the user picture and the following comments.

The view displays the user picture along with the statuses, but the image style used is the default 'thumbnail' style. I have created my own image style for displaying these images.

Usually in a view when images are added we get a option by default to add image style to it. But in this case I dont have that option.

After a bit of searching I found the following code in the statuses.module to display the user picture:

function statuses_display_user_picture($account, $preset = NULL) {
  drupal_add_css(drupal_get_path('module', 'statuses') .'/resources/statuses.css');
  $image_vars = array('account' => $account);
  if (!empty($preset) && module_exists('imagecache_profiles')) {
    $image_vars['user_picture_style'] = $preset;
  }
  return theme('user_picture', $image_vars);
}

How do I override this code to display the image with my choice of 'image style'.


texts: Is it possible to create a calculation field using database abstraction layer?

texts:
I am trying to work out if it is possible to write the following using Drupal's database abstraction layer.  The tricky bit is the second field which is a function to calculate distance.  Is it possible to include this calculation field (3959 * acos(cos(radians(:lat)) * cos(radians(field_bluescope_geolocation_lat)) * cos(radians(field_bluescope_geolocation_lng) - radians(:lng)) + sin(radians(:lat)) * sin(radians(field_bluescope_geolocation_lat)))) AS distance using the abstraction layer?

  $result = db_query_range('SELECT '
  . 'geo.entity_id, '
  . '(3959 * acos(cos(radians(:lat)) * cos(radians(field_bluescope_geolocation_lat)) * cos(radians(field_bluescope_geolocation_lng) - radians(:lng)) + sin(radians(:lat)) * sin(radians(field_bluescope_geolocation_lat)))) AS distance '
  . 'FROM '
  . 'node__field_bluescope_geolocation AS geo '
  . 'INNER JOIN '
  . 'node__field_bluescope_consumer_supp AS consumer_supp '
  . 'ON '
  . 'geo.entity_id = consumer_supp.entity_id '
  . 'WHERE '
  . 'geo.bundle = \'bluescope_business\' '
  . 'AND '
  . 'consumer_supp.field_bluescope_consumer_supp_target_id = 28 '
  . 'ORDER BY distance', 0, 200, [':lat' => $lat, ':lng' => $lng]);