texts: Writing to a drupal table form javascript as fast as possible

texts:
I have a table in my Drupal database this is simply a name value pair for each entry. I need to write to this table from javascript and get back as soon as possible. My first attempt was to create a menu endpoint that looks like this:

  $name = $_POST['propertyName'];
  $value = $_POST['propertyValue'];
  $result = db_query('SELECT * FROM {global_properties} WHERE property=:property', array(':property' => $name))->fetchAll();
  $record = array(
    "property" => $name,
    "value" => $value
    );
  $primary_key = !empty($result) ? array('property') : NULL;
  drupal_write_record('global_properties', $record, $primary_key);

I hit this endpoint from JavaScript using a dojo.xhrPost.

Sadly speed is quite important for this operation and it is taking me around 1000ms to get back from my post (I would like to be around 100ms).  What would be a faster way to write to the Drupal table?

I am running this page on a server running MAMP Pro.


texts:
I can't create a book under Internet Explorer 7; when I click "add a new book" in Book outline, the browser shows, "To help protect your security, Internet Explorer blocked this site from downloading files to your computer. Click here for more options…."

When I click on "Download the file," the file name is "form8c01710d," and it contains { "status": false, "data": "" }.


texts: Inserting Font Awesome HTML into user profile fields with Twig

texts:
I have created user profile fields for Twitter, LinkedIn and GitHub that are just plain Link Fields.

I would like to add the relevant Font Awesome icon HTML to each of the fields so that the icon is printed instead of the URL. I would like this to happen in all instances of the field being used whether its a view or the user entity.

What preprocess function should I use? How should I add the HTML to the template using Twig?


texts:
I have a content type with a select field. When the selected value from that field is "Locked", I would like to lock editing on that node for all roles except admin (or other role I choose to be admin). Then if the admin selects a different value, I would like to unlock editing on the node. For this reason it seems that rules are the best way to trigger an action like this. I have the content access module installed, which allows targeted access permission both for content types, and individual nodes. But how can I combine the two parts to lock editing automatically based on the select list? If I couldn't do it automatically, is there some way to restrict all access per node?

Edit:
This is possible with Rules and content access. There is an action provided by the content access module which will revoke access to a node based on role.


texts: Drupal 7 - Node specific template not working

texts:
I have done some research and everything I see to create a node specific template says to name the template file, for example, page--node--676.tpl.php

However when I clear the cache and load the file it still shows the old template. What could I be missing?


texts:
I have found something strange in the URL on my drupal. I can add text after the node id and the page display as normal. Example :

https://www.drupal.org/node/11111

return the same as

https://www.drupal.org/node/11111/thisisatest

How can I avoid this, as this is starting to getting referenced by Google (at least for one url)


texts: What are some examples of filter Correct faulty and chopped off HTML?

texts:
In Drupal one of the text filters that is enabled by default is the filter Correct faulty and chopped off HTML. As I understand it must fix HTML bugs.

Can anybody please give some example(s) of situations, where it can help?

I am confused, because if I do not close some tag (for example DIV), and save the result, then I get the same result in both cases (= it doesn't matter if that filter is turned on or off).


texts: Passing Argument from URL in Panel to View Pane or Block

texts:
I have a page where I want to display all resources for a course grouped by taxonomy term. The courses are organic groups and the resources are materials belonging to those groups. I'm using panels to display the content and I'm overriding view_node for this. I have already created a view pane which lists all the different resource categories, and I'm now trying to list all the resources for a category.

The panel is using the following URL structure:

course/course-name/resources/resource-taxonomy-term

So for instance I have a URL

/course/test-course/resources/transport

I then want to display all resources that belong to the taxonomy term "transport". So I guess the URL argument I want to pass is %4.

I've tried for over a day now trying different methods to pass the URL argument to the view without success. I've tried using a view pane to display the results and also a view block, and explored various methods of passing the argument across without success. It works fine in the view itself, but when I put it in the panel it doesn't work. Can anyone show me how I can do it?

I'm using D7.18, ctools 7.x-1.0-rc1, panels 7.x-3.0 and views 7.x-3.7.


texts: Get order title value from $order variable

texts:
I have to get order status and order title from $order variable. I can get order status by $order->order_status. But I can't able to get order title. So how to get order title value from $order variable programmatically.

I am using the below hook :

  function hook_uc_order($op, $order, $arg2) {
     if ($op == 'update') {
       if (($order->order_status == 'payment_received') && ($order->title == 'My Product')) {
         // Do something with the $order object.
       }
    }
  }

Here $order->order_status is working individually but $order->title is not working. How to get Order Title?

Looking forward for this answer.


texts: remove 'publishing options' and other settings from node/add

texts: I have a role which allows users to add nodes, viewing the admin form, but I don't want the user to be able to see  Is there a way to remove it?


texts:
I have a fairly simple D6->D8 migration, and I need a custom source plugin for one of my node migrations. As far as I can tell, I have everything written and structured properly, but when I click on the migration group in the admin UI, I get a message that my source plugin doesn't exist.

Here's the relevant part of my node migration config:

In /my-module/config/install/migrate_plus.migration.video.yml:

id: video
label: Video
migration_tags:
  - Drupal 6
deriver: Drupal\node\Plugin\migrate\D6NodeDeriver
migration_group: node
source:
  plugin: mrctvVideoSource
  node_type: video
process:

and my source plugin in /my_module/src/Plugin/migrate/source/mrctvVideoSource.php:

namespace Drupal\migrate_mrctv\Plugin\migrate\source;

use Drupal\migrate\Plugin\migrate\source\SqlBase;
use Drupal\migrate\Row;

/**
 * Source plugin for MRCTV video nodes.
 *
 */
class mrctvVideoSource extends SqlBase {

  /**
   * @MigrateSource(
   *   id = "mrctvVideoSource"
   * )
   */
  public function query() {
    return $this->select('view_videos', 'vv')
                ->fields('vv', array_keys($this->fields()));
  }

  /**
   * {@inheritdoc}
   */
  public function fields() {
    $fields = [
      'video_data' => $this->t('Video Data'),
      'thumbnail_data' => $this->t('Thumbnail Data'),
      'show_ads' => $this->t('Show Ads'),
      'raw_s3_file' => $this->t('Raw S3 File'),
      'nid' => $this->t('Node ID'),
      'vid' => $this->t('Version ID'),
      'title' => $this->t('Nond Title'),
      'node_created' => $this->t('Created'),
      'node_changed' => $this->t('Changed'),
      'node_uid' => $this->t('Node User'),
      'node_body' => $this->t('Body'),
      'teaser' => $this->t('Teaser'),
      'revsion_uid' => $this->t('Revision UID'),
      'log' => $this->t('Revision Log'),
      'timestamp' => $this->t('Revision Timestamp'),
    ];

    return $fields;
  }
}

From what I can tell, I have everything named and annotated properly and in the correct locations, but I'm obviously missing something.  What is it?

Thanks.

UPDATE: Per Mike Ryans'suggestion below, I changed the id of my plugin (after clearing cache) from 'mrctvVideoSource' to 'mrctv_video_source', both in the migration yml file and the id annotation in my plugin definition (is there anywhere else I need to change it?). But now, after uninstalling my module (and having to manually delete the config records in the config database again, config_devel doesn't seem to be clearing anything out), my node migrations are not even listed on the Migration page. Sigh. Still troubleshooting...


texts: How to use union with a query of view itself?

texts:
I have a table that have 2 types of data:

first type is '1'
second type is '2'

And I want to get 3 records of both by union so,
I want to know that how to get 3 records of both types from one table at a time
so it is possible by union with itself so i want to add union with my views content.

How to get query of view and alter it and where I put this query in Drupal 7 but I have no one module for this data.


texts: How to make gmap marker tooltip display node title without tags?

texts: My project uses gmap of nodes locations. When marker is hovered  popup tooltip displays link to node with node title in it. Any possibility  to display node titles in marker tooltips without any tags?


texts: How do I modify the "view" link in a view?

texts:
I'm sure this is a simple question when you know what you're doing, but I'm a bit puzzled.

At the moment, I have a view, from the views module, listing published articles on the front page of my site. After each article, there is a link "view" or "voir" (depending on the language being used) which takes you to the article. This is simply an anchor tag generated by thte Views module containing a link to the article node appended to the end of the item.

However, the person for whom I am making the site wants this link to be styled in a specific way, with an icon and the text to read "Read more" or "Savoir plus". How or where can I modify the HTML markup and text content for this particular element of the View module output?


texts: Migrating site from MariaDB to MS SQL 2012

texts:
I'm trying to migrate the site from a linux+mariadb platform to IIS+MS SQL platform. Could someone please tell me what is the best way to do this?

What I've done so far:

Installed a vanilla Drupal site on IIS server to ensure everything works.
Tried migrating the database with SQL Server Migration Assistant (SSMA): https://stackoverflow.com/a/13898291/3199478

It's a Drupal 8 site so the Migrate and Migrate D2D modules are useless.


texts: Drupal view filter between two dates on published date

texts:
I have a problem with view and filter on published date. In the view i display all my contacts with their published date. It's the published date of the contact not a field date in entity contact. it's look like that :

toto | 20/02/2015
titi | 23/02/2015
tutu | 27/02/2015

I tried to make a filter on the published date with start date and end date but i can't use it.

How can i make a filter between two date on published date ?

Thanks


texts: show field of entity for editing according to path

texts:
I have an entity with many field (about 200) collecting information about buildings (area, height, conditioning system, ...)
my client has asked me to show specific fields in groups for editing, where user can choose from menu "group 1" and see only those fields
it is also possible that users will only visit some groups they want, and leave some of groups un-edited for later
how do i show specific fields of one entity, according to path? /node/1/edit/g1 for fields 1 to 20, node/1/edit/g2 for fields 21 to 30 and ....

extra info: i'ts not about permissions at all, the same user, will fill group 1 today, will comeback tomorrow and fill group2 if wanted to
field collections looks promising, can it do that? instead of deciding by user permission, deciding by path?


texts: Can I Search an entity reference with search api db?

texts:
I am using the search api database backend together with a views (with exposed fulltext search field). I want to show a 'related field' that is related to a content type that is being indexed. When the entity reference field only holds 1 value, all is fine.

But when it holds unlimited values (in the field settings) it no longer works in the view :-(

Does search api db have a limitation on indexing multivalued fields?

UPDATE

My content types are as follows:

Content type a

Field_a = text
Field_b = entity ref to content type b (allowed values unlimited!)

Content type b

Field 1 = text
Field 2 = text

I have indexed all fields above and added the related fields 1 and 2 to my search index as related fields.

Then when i create a view that shows the indexed nodes for content type a, and want to show field 2's information of the node that is referenced it only works when field b is set to allowed values: 1


texts: How can I have drupal ignore a specific folder with another site within?

texts: I am having a multilingual website at www.example.gr which runs Drupal 7. Inside Drupal installation I have placed a folder with an opencart installation. I am able to access www.example.gr/eshop/index.php yet I cannot access www.example.gr/eshop/admin because drupal redirects me to www.example.gr/el/eshop/admin which obviously doesn't exist. Any ideas about how to fix that?


texts: Show nodes of other content type that share a common term (with depth)

texts:
I have two content types: sector and product. Both share terms from the same vocabulary, called branch.

A sector node should list all product nodes that share the same term(s) (from the branch vocabulary).

I managed to set up a view that does what it should: each sector node shows related product nodes. I did this by doing the following (sharing this because this may help others):

First of all: make sure that, eventhough both content types use the same vocabulary, each content type has a different taxonomy field that refers to the same vocabulary. For the sector content type we'll call the (taxonomy) field "rel sector", the (taxonomy) field of the product content type we'll call "rel product". Both point to the same vocabulary: branch.
Create a block display in your (content) View.
Add a contextual filter: Content NID (default value: content-ID from
URL).
Add a relationship: taxonomy terms on node (check the commonly used
vocabulary).
Add another relationship: Taxonomy term: Content that uses "rel
product". Tie it to the previously created relationship (relation:
term, for instance). Make it required.
Configure the Query settings as follows: distinct (to avoid
duplicates)
Open the title field, and tie it to the second relationship (which
in this case would be field_rel_product).

Important:

Make sure not to have a filter criterion based on content type in your view display, or it will actually block the content you'll need.
Again, make sure that, eventhough both content types use the same
vocabulary, each has a different field that refers to the vocabulary.

This works perfect when using common taxonomy terms on one level ànd it works with child terms as well, but in that last case it's required to have all those child terms checked when displaying a parent node. And that's exactly what I want to eliminate.

What I'm after is that it should suffice to check the a parent term, and all its children would be displayed as well, without them being checked necessarely.

It's not such a big deal if this isn't possible by design, but could anyone provide the finishing touch if it is please?


texts: Views - Exposed Filter for 2 Field Collections with Same Fields

texts:
I have a content type with 2 Field Collections(both set for unlimited values), they are Author and Editor. Both field collections are using the same fields(first_name and last_name).

In a Views that I created has both field collections displayed. And I would like to exposed the First and Last Name, but they are not searchable without a relationship. Meaning I have to have 2 First Name and 2 Last Name filters exposed with different relationships.

How to make 1 first name filter exposed and searchable for both Author and Editor?

PS: I have done many other searchable Views page, but this is different(2 field collections with same fields).


texts:
I use unlimited values for image field in a content type, then the images displays one below the other :

Is there a way to render this field differently?
For example every line show me only three images.

Im using display_suite module to display the node content.


texts:
I have an image field attached to a content type created. When I upload images to it, it gives me an error "an illegal choice has been detected please contact sight administrator."  I get this error when uploading images only on this content type.

I cleared watchdog entries, form and image cache tables; it started working again, but when I create a second page, the problem shows again.

How can I avoid this error?


texts:
I want to get the created column from the file managed table of the node field which stores file.Can we have entity query for the same.

SELECT file_usage.id AS file_usage_id, node_field_data.nid AS nid, file_managed_node__field_image.fid AS file_managed_node__field_image_fid
FROM
node_field_data node_field_data
LEFT JOIN node__field_image node__field_image ON node_field_data.nid = node__field_image.entity_id
LEFT JOIN file_managed file_managed_node__field_image ON node__field_image.field_image_target_id = file_managed_node__field_image.fid
LEFT JOIN file_usage file_usage ON node_field_data.nid = file_usage.id AND file_usage.type = 'node'
WHERE (( (node_field_data.status = '1') AND (node_field_data.type IN  ('article')) AND (file_managed_node__field_image.changed <= 1473325611+157766400) ))


texts:
I have a project have a lot of field need to be reference by each other.

Does anyone could give me some suggestion about this situation?

How was the performance of field reference? Should I just saving field by text rather than reference type?  (And then render by my custom module code)


texts:
Using Drupal Services I am able to log in but each time I post a node it posts as anonymous. I get the session id and session name upon login but can´t pass it along with a POST no matter what i try.

I have tried including it in the json string, as a header and within the URL - without any result. I'm testing using the Chrome Postman as REST client.

What am I doing wrong?

Thank you for any help!

var session_id = $('#session_id').text();
$.ajax({
  type: "POST",
  url: 'http://www.website.com/active_services/node?sessid='+session_id,
  data: JSON.stringify(noden),
  headers : {
    "Authorization" : session_id,
    "sessid" : session_id,
    "sessionid" : session_id,
  },
  beforeSend: function (req){
    req.setRequestHeader("Authorization",session_id);
    req.setRequestHeader("sessid",session_id);
    req.setRequestHeader("sessionid",session_id);
    req.setRequestHeader("Content-Type", "application/json");
  },
  dataType: 'json',
  contentType: 'application/json',
  success: function(data){
    console.log(data);
 }


texts: I want to hide the "Manage questions" button from question creation form of Drupal Quiz

texts:
I am using drupal quiz module. It is working fine. My issue is I want to hide the "Manage questions" button from question creation form.

Any help would be appreciable.


texts: how do I add extra classes to a date field at views?

texts:
I am using Drupal 7. I created a view, that is using a date field. I would like to create extra classes to the date field for that specific view.

For example,

 10
 June
 2011
  8:00

Now I have a code:

 10 June 2011, 8:00

How can I do it step by step?


texts: anyone have an example of a remote Flash app login thru Services 3.x REST server?

texts:
I have a REST API implemented in Services 3.x. The API uses session authentication. A client wants to access the API from a remotely hosted Flash application. We've placed a crossdomain.xml in our docroot, enabling the client's app to communicate with us, but they are having troubles getting past login.

Anyone have any examples of a REST Login within Flash?


texts: Drush dl not working with PHP 7 and ubuntu 16.04

texts:
When i try to do:

drush dl drupal-8

i get the following error:

PHP Fatal error:  Uncaught Error: Call to undefined function Drush\UpdateService\simplexml_load_file() in /home/alexander/.config/composer/vendor/drush/drush/lib/Drush/UpdateService/Project.php:74
Stack trace:
#0 /home/alexander/.config/composer/vendor/drush/drush/lib/Drush/UpdateService/ReleaseInfo.php(64): Drush\UpdateService\Project::getInstance(Array, 86400)
#1 /home/alexander/.config/composer/vendor/drush/drush/lib/Drush/UpdateService/ReleaseInfo.php(122): Drush\UpdateService\ReleaseInfo->get(Array)
#2 /home/alexander/.config/composer/vendor/drush/drush/commands/pm/download.pm.inc(111): Drush\UpdateService\ReleaseInfo->selectReleaseBasedOnStrategy(Array, '', 'auto', false, NULL)
#3 /home/alexander/.config/composer/vendor/drush/drush/includes/command.inc(366): drush_pm_download()
#4 /home/alexander/.config/composer/vendor/drush/drush/includes/command.inc(217): _drush_invoke_hooks(Array, Array)
#5 /home/alexander/.config/composer/vendor/drush/drush/includes/command.inc(185): drush_command()
#6 /home/alexander/.config/compos in /home/alexander/.config/composer/vendor/drush/drush/lib/Drush/UpdateService/Project.php on line 74
Drush command terminated abnormally due to an unrecoverable error.

Other commands does work: drush cc, drush status.

Here's output of drush status:

 PHP executable         :  /usr/bin/php
 PHP configuration      :  /etc/php/7.0/cli/php.ini
 PHP OS                 :  Linux
 Drush script           :  /home/alexander/.config/composer/vendor/drush/drush/drush.php
 Drush version          :  8.1.2
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :


texts:
New Drupal and playing with permissions. I can't figure out how to get a content list or something similar if the Administer Nodes permission has been disabled.

I'm trying to restrict a user role, strip down the admin menu, e.g. remove 'Post Settings' under content management.

I have a feeling I'm doing this wrong, so my question is: Can I create a user menu, same as the admin menu without certain links and how?


texts:
I have a custom module, mymodule, that will create custom blocks, block_test and block_test2 on mymodule_install().

When the module is uninstalled, I want to remove any blocks created by mymodule. How would I delete the block generated by a module being uninstalled?

drush command (local dev):

drush pmu mymodule -yv

mymodule.uninstall()

function mymodule_uninstall() {
  // Delete Blocks generated by module.

  /** @var \Drupal\Core\Entity\EntityStorageInterface $block_storage */
  $block_storage = \Drupal::service('entity_type.manager')->getStorage('block');
  /** @var \Drupal\block\Entity\Block[] $blocks */
  $blocks = $block_storage->loadMultiple();
  foreach ($blocks as $block) {
    // I am stuck here.
  }
}


texts: Alter breadcrumb for the taxonomy term edit page

texts:
To ease the navigation in the administration theme I would like the breadcrumb of /taxonomy/term/ID/edit
To be :
Home | Administration | Structure | Taxonomy | TaxonomyName | TermName | Edit
Rather than :
Home | ID | Edit
The ID currently leads to front end view page, and there is NO way on the page to detect of WHICH taxonomy this term is part of. Can you help where I should hook?
Thanks!


texts: Is there advanced configuration for CKEditor in Drupal 8?

texts: In Drupal 7 I was able to add config rules to CKEditor in the admin (like config.allowedContent = true; for example). I can't find this option in Drupal 8. Is it possible to do something similar?


texts: How to show a file list ordered by taxonomy field with views?

texts:
I've a file type of type "document" with an additional field of type "term reference". When I upload a new file I can link a term of that vocabulary to my file, like it was a folder.

Now I need to list all my files in a tree manner like this:

TERM_PARENT 1
  Term child 1
    - file.pdf
    - file.doc
    - file.ppt
  Term child 2
    - file.doc
    - file.pdf
TERM PARENT 2
  Term child 1
    - file.doc
TERM PARENT 3
  Term child 3
    - file.pdf
    - file.pdf

How can I create a view like this?

Thanks a lot


texts: How to plot a chart from CSV uploaded in a content type?

texts:
I am uploading TXT and CSV files in a content type. While displaying it,
I have to show that as a chart when users viewing the content of that content type.

I have tried using the Charts module, etc. Though I am able to plot the chart reading from a file by giving absolute path, I am not able to do it dynamically. Is there a better way of doing this (using Drupal 7)?


texts: How to create a custom text input filter?

texts:
I am using plain text format. I want to create an input filter for when a user enters #15, it should be converted to a link pointing to the post #15. I want to do this for the Statuses (Social Microblog) module. The link of an individual status is like this: https://www.example.com/statuses/15.

Just for your reference, I found a snippet. It is specifically for nodes though, which was meant to be used with custom filter module.

My question: How to create such filter for statuses?


texts: Clear cache changes link language prefix in field

texts:
We have a multilingual Drupal 7 install. On a lot of pages there are internal links to other pages in a textarea field, like the body field, example:
When the node is saved, the internal link is changed to it's corresponding alias, example: http://www.domain.com/en/node-alias.

This works perfectly, until we clear the cache. If we clear the cache in the En version of the site, all the links will use the correct alias in this language version.
If we switch to another language, all the links in that language will use the language prefix of the language that was active when we cleared the cache.
So on the FR version a link would display as http://www.domain.com/en/node/999.

The node id is still correct, only the language prefix isn't the correct language. This means that the link goes to the 404 page.

Is there anyone who knows a solution for this?


texts: Can I use Full-Text Search Functions in db_select()?

texts: Does it possible to use Full text search functions like match() against() with Drupal 8 database Api's OR any alternative to make it work?


texts: Trying to display/printing latitude and longitude from Geolocation Field to node template

texts:
I've been trying to figure how I can fetch the latitude and longitude values using geolocation field and display it on my node.html.twig template.

I've been using to kint() to see how I would be able to fetch but I can't seem to figure out the right syntax. It seems to be inside an array

Tried node.field_geolocation.latitude.value or node.field_geolocation.longitude.value


texts: Need an exposed filter field as select box with values like "Last x days" etc

texts:
I'm trying to filter my nodes on the basis of last 7 days & last 30 days but the below code is not working for me when I tried this in my custom module, its working as a conversion for text-field to select but not working as a filter

function dreamzen_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
    $fromdate = &$form['created'];
    $fromdate['#type'] = 'select';
    $fromdate['#options'] = array(
      'All' => 'All',
      'Last 7 days' => '-7 days',
      'Last months' => '-30 days',
    );
    $fromdate['#default_value'] = '';
    $fromdate['#size'] = 1;
}


texts:
I know how to configure the path for 4 or 5 Term Parents Taxonomy.
I have used this code: [term:vocabulary]/[term:parent:parents-all]/[term:name]
But this is not works for 5 Term Parents Taxonomy path.. any idea?


texts: D6: Create block view which returns all nodes with related terms

texts:
I have a vocabulary which contains a large number of terms, most of which have been given relationships to other terms.

I want to create a block display of a view which takes the term from the current node and displays all the other content which has a related term from the same vocabulary.

So far, I have been able to return all nodes with the same term using this as a views argument:

node = node_load(arg(1));
if($node) {
foreach($node->taxonomy as $term) { $terms[] = $term->tid; }
return implode('+',$terms);
} else { return; }

However, I haven't been able to combine this with taxonomy_get_related to return nodes related by term.  Any suggestions?


texts: User-/Author-Profile with List of Friends

texts:
I have a simple view of articles and on the right side of the page I want to display the user profile of the currently logged in user (user picture, some custom info fields, etc.) I'm doing this with a user view, which is working just fine. But if I click on a specific article, I want to show the article node and on the right side the user profile of the author of this specific article.

How can I display the author's profil on the node page? Is there a way to do this over a view?
The user/author profile needs to show a friendlist of this user.  What is the best way to do this? I would like to integrate this within the user/author view, but can't find a way...


texts: Why do I get a "Unauthorized" error even though the user is logged-in?

texts:
I am trying to programmatically log in a user in a custom module.

The code I am using in mymodule.module is the following.

function mymodule_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_login_block' || $form_id == 'user_login') {
    $form['#validate'] = array('user_login_name_validate', 'mymodule_login_validate', 'user_login_final_validate');
  }
}

function mymodule_login_validate($form, &$form_state) {
  global $user;
  $username = $form_state['values']['name'];
  $password = $form_state['values']['pass'];

  $ch = curl_init();
  curl_setopt($ch,CURLOPT_URL, "http://localhost/MYAPI/oauth/authenticate");
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS,"username=" . $username . "&grant_type=password");
  curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", "Authorization:Basic xxxxxxxxxxxxxxx"));

  // receive server response ...
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $server_output = curl_exec ($ch);
  curl_close ($ch);
  $postData = drupal_json_decode($server_output);
  $count = db_query("SELECT COUNT(*) FROM {users} WHERE name = :name;", array(':name' =>$username))->fetchField();

  if ($count == 0) {
    if (!empty($postData['access_token'])) {
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL,"http://localhost/MYAPI/rest/user/1/get_user_details");
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", "Authorization:Bearer ".$postData['access_token']));

       // receive server response ...
       curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
       $server_output = curl_exec($ch);
       curl_close($ch);
       $postData = drupal_json_decode($server_output);
       $resRoleArr = $postData['userDetail']['role'];
       $resMail = $postData['userDetail']['email'];
       $roleArr = user_roles();
       $common_roles = array_intersect($resRoleArr,$roleArr);

       if (count($common_roles) > 0) {
         user_external_login_register($username, 'mymodule');
         $user_fields = [
           'pass' => $password,
           'status' => 1,
           'mail' => $resMail,
           'init' => $resMail,
           'roles' => [DRUPAL_AUTHENTICATED_RID => 'authenticated user'],
         ];

         user_save((object) ['uid' => $user->uid], (array) $user_fields);
         $account = user_external_load($username);
         $form_state['uid'] = $account->uid;
         if ($role = user_role_load_by_name($common_roles)) {
           user_multiple_role_edit(array($user->uid), 'add_role', $role->rid);
         }
       }
     }
   }
   else {
     user_login_authenticate_validate($form,$form_state);
   }
 }

As you can see I am trying to login an user externally where it's credentials coming from a REST API.

Before to externally log in, I check if the user already exists in the database.  if it doesn't exist, I use user_external_login_register($username, 'mymodule'); if it exists, I use    user_login_authenticate_validate($form,$form_state).

Though I am able to successfully log in the user in both the cases, I am getting an Unauthorized error.

What could the issue be?

I am using Drupal 7.56.


texts:
I want to get the number of rows where the "value" field is equal to 1, and output its number  and all the content_id where  value_type is option in table votingapi_vote.
the following is my code, but it doesn't work.

$result = db_query("SELECT content_id,count(value=1) FROM {votingapi_vote} WHERE value_type = '%s'" , "option");

while ($obj = db_fetch_object ($result)) {
  return $obj->content_id.'<br>'.'$obj->count';
}

it showed an error.  when i delete the filed value in the query. it only output one result of $obj->content_id/ why? i want to output all the results of $obj->content_id

ps: now, if i want to get this result.

1,get the content_id and descending  it according to the value(the count of each content_id 's value=1 substract the count of  each content_id 's value=0 ,each content_id has many value=0 or value=1)

how to write the query.


texts: How can I alter the list of available layouts in the Panels IPE?

texts: I'm trying to hide or remove several layouts from the layout selectors, so that users can only select from an approved list. I can do this successfully with hook_form_alter() code, but the Panels IPE isn't using a form for its layout selection tray. It seems the best method would be to use LayoutPluginManagerInterface somehow, so that any function that displays a list of available layouts will have the same list available, but so far I haven't figured it out. Is there a way to do this?


texts:
What would cause MySQL to suddenly run at almost 800% CPU or quit running?
Our Drupal 7.50 site has started crashing recently.

First time the site went down, the website displayed this error to the public:

  PDOException: SQLSTATE[08004] [1040] Too many connections in
  _registry_check_code() (line 3462 of /var/www/html/example/docroot/includes/bootstrap.inc).

MySQL exceeded max_connections and I had to reboot the server because temporarily increasing from 151 to 500 still didn't help. I checked top and saw that MySQL was running at almost 800% CPU.

Restarting the VPS was the only thing that helped this.

The second time, the Drupal site only displayed a white page to the public, but the command drush ws produced the following error:

  Drush command shows: PHP Fatal error:  Call to undefined function
  module_exists() in
  /usr/local/src/drush/commands/core/drupal/environment_7.inc on line
  187

I confirmed with top that MySQL was not running. Records show that it was running at this same high CPU for several hours just before it stopped.

In this case, all I had to do was restart MySQL.

Is this a Drupal performance issue, traffic related, spam or something else? Any help is appreciated to troubleshoot this issue.


texts:
I'm just using Views Bulk Operations for the first time.

VBO augments Views  " ...by showing a checkbox in front of each displayed row, and adding a select box on top of the View containing operations that can be applied."

I have it all working as it should, however, I would like to move this select box and button to UNDER the view (under the table that I am making in my view). I've been looking at this for sometime, and haven't been able to figure out how to do this. Can anyone point me in the right direction? Thanks


texts:
I am looking for complete and updated documentation for Restful web services.

For example, for the user login, we have to post the following data.

POST: http://example.com/user/login?_format=json
Content-type: application/json
Data: { "name": "admin", "pass": "myPassword" }
Response: 200 OK

This will properly log in via cookie authentication, and return a result similar to this.

    {
      "current_user": {
        "uid":"1",
        "roles":["authenticated"],
        "name":"admin"
      },
      "csrf_token":"abc123",
      "logout_token":"def456"
    }

How do I log out the user I just logged in with?

I found RESTful Web Services module overview, but I still don't understand how to log out.

Using the following request gets back a 403 Forbidden error.

POST: http://example.com/user/logout?_format=json
Content-type: application/json
Data: { "name": "admin" }

What am I missing?


texts: why views items per page set to specific values

texts:
Why does the Views module accep uses the number of items per page that is in pre-defined sets like 5, 10, 25, 50, and doesn't accept values outside those values?

I know how to change it; I just need an explanation.


texts: Access field data in views row template (views 3)

texts:
So I checked Google for the past 2 hours because apparently something that was fairly simple back in the Views 2 days has changed in Views 3 (D7)... All attempts failed.

I have a view set to display as HTML list showing fields. One of those fields is an image field. I want to use the URL to the image file as inline style background-image on the LI element of the particular row.

In Views 2 I would have set the field to be excluded from display and then created a views template for the row and then used the $row variable to access the field information for the particular row. In Views 3 there only seems to be the $title and $options variable available and $row outputs only the rendered HTML for the whole row.

Long story short: How can I access the field data from inside a views-view-list--myview--page.tpl.php?

If anyone can help out, it is greatly appreciated.


texts: Menu hierarchy expansion behavior for child-link that is a child of multiple parent links

texts:
When adding a page that will have a menu-link that is a child of parent menu-link (parent-1) you are able to
select the 'Menu link title' and a 'Parent item' on that create/edit form.  The link appears
and behaves as expected (i.e. when the parent link is clicked and expands the child is shown below
and indented).

If a second menu-link' to this child page is added to a different parent-item (parent-2) by using:
'Home » Administration » Structure » Menus » Main menu >> Add link' which uses a 'node-path'
the child links now appear as a sub-link under Parent-1 and Parent-2.

But when the child of parent-1 is clicked the menu expansion will show the hierarchy
expansion of parent-2. The expansion is always of parent-2 regardless of which parent-child
link is clicked.

If a third parent-child pair is added, the hierarchy expansion is now always shown for the
third parent-child set (i.e. that last parent-child pair added will be what expands).

Is this correct behavior or is there a fix/proper way of doing this such that the expansion is
done for the parent-child pair clicked?


texts: How do I create custom 403/404/406/503 pages in Drupal 8?

texts: I am familiar with creating node and pointing to that specific node in basic site settings. How do i create this programmatically and package in features? Twig override?


texts: hook_theme_registry_alter Why would Drupal forget that a module is registered?

texts:
I am using a module that is using hook_theme_registry_alter.  When I clear the cache it works fine the first time I load the page.  If I refresh the page Drupal forgets the module exists, and does not run the function to make the module work.

From the Drupal documentation I understand that:

  This hook is only executed as the theme cache is re-built. Changes here will not be visible until the next cache clear.

So it makes sense to me why it works immediately after a cache clear.  But, why does Drupal forget that the module exists on the following refresh?  Is this a Drupal problem or a problem with the module? What are some possible causes to investigate?

For further details, I am using is Borealis RI.  I have used it a dozen times in the past without this problem. The hook_theme_registry_alter function is called on line 124 http://cgit.drupalcode.org/borealis/tree/borealis_ri/borealis_ri.module


texts: users see all replies to a message sent by admin [Privatemsg module]

texts:
I (admin) sent a message to couple of users by their username (not by role) . If "user1" replies back to the admin , user2 and user3 will see the message too ,

that's why the module is called PrivateMessage right :)

any clue ?
thanks


texts:
I have two content types: development and house.

A development has many houses.

Each house has a house_type field

I'm trying to perform a db_select query that allows me to search all developments and find the house_types attached to them.

I've managed to find the developments, then found the attached houses_on_development (i've used group_concat for this), AND THEN, WHERE I'M STUCK...

I need to query each of the house_types of these concatenated house_ids individually to find out their house_type.

I've started with:

$search_type = 'development';
$query = db_select('node', 'development');
$query->condition('development.status', '1', '=');

 $query->leftjoin('field_data_belongs2dev', 'property',
        'development.nid = property.field_data_belongs2dev_target_id');
$query->addExpression('group_concat(property.entity_id)', 'houses_on_development');

And now i'm stuck.  I know how to write the query to get the house_types if I was querying house_id one at a time but don't know how to fit that query into a bigger db_select.  For this I would use:

SELECT field_property_type_tid
   FROM field_data_field_property_type
   WHERE entity_id
   IN  ( house_id1, house_id2, etc... )

I feel like i'm so close but missing that final bit od knowledge.  Please help.


texts: Views: count and filter by entity field value

texts:
I have many nodes of type 'Players' and 'Match'. In the 'Match' node there is an entity field 'Strikers' referenced to 'Players' which allow multiple values.

I'd like to create a player page that shows information about that player searching all occurrence of that player in the 'Match' nodes (inside the 'strikers' field of each node).

I tried with the contextual filter but I don't know if it is the correct way..


texts: Form submission in modal is throwing an error

texts:
I have a Form which on submit calls another form via ajax and embeds it into a modal popup (Drupal8 standard) and when I click on submit of that modal form , I get a Drupal ajax error (I think it's due to the fact that ajax tries to find the from on the wrong page).

Here is how the submit button of the first form looks:

$form['table'][$pid]['edit'][$cid] = [
      '#type' => 'submit',
      '#id' => 'edit_'.$cid,
      '#name' => 'edit_'.$cid,
      '#value' => $this->t('Edit'),
      '#ajax' => [
        'callback' => [$this, 'customAjaxModalForm'],
        'event' => 'click',
      ],
  ];

And here's the customAjaxModalForm method, which calls the other form and modal.

public function customAjaxModalForm(array $form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $modal_form = \Drupal::formBuilder()->getForm('\Drupal\accounts\Form\ContactsForm');
  $response->addCommand(new OpenModalDialogCommand('Edit contact', $modal_form, ['width' => '800', 'height' => '300']));
  return $response;

}

Now the submit of the ContactsForm looks exactly as the submit above, as I need to send a few responses to the client (.js).

The rest of the code is pretty straight forward so I only supplied the most crucial parts.

How my code works, is: you go to a page, controller handles the request, it calls the first form (the form only has a textfield  and three submit buttons, the other two submit buttons work - do their job) the rest you know.

Any ideas? I am at a loss.


texts: Does Apachr Solr use Taxonomy or CCK fields for faceted search?

texts:
I'm trying to put together a simple faceted search block using Solr. Search with Solr works, but I'm unsure of what's required for creating a block of search properties for faceted search.

For example, my content is for accommodation, so I want to be able to search by price range, capacity and location. Price range and capacity data are already populated as CCK fields, but location is set up as a hierarchical taxonomy.

I'm wondering what Solr requires for me to implement a simple, faceted search block. Does it use CCK fields for search properties or Taxonomy? Or have I misunderstood how faceted search blocks for Solr are built?


texts: Show all terms that are children of term with argument tid

texts:
I need a view that shows all terms that are children of the argument tid.

term 1
-term 2
-term 3
term 4
-term 5

view/4 should return term 5

I must be missing something fundamental because no matter how I mess with contextual filters and relationships I never come close to actually filtering my results by the context.


texts:
I've defined my own textgroup using:

function foo_locale($op = 'groups') {
  switch ($op) {
    case 'groups':
      return array('foo' => t('foo strings'));
  }
}

The problem is that when I use t('bar') in a template, the entry generated in the database (e.g when viewing the template in /fr) is associated with the default textgroup. This doesn't allow me to use the foo textgroup I've previously defined, thus all my custom strings are mixed with the other "Built-in interface" ones.

How can I solve this?


texts:
At my current job we have a large number of Drupal installations(not multisite) and we are facing some issues regarding things like applying security updates (really any kind of update).  Currently we have a mix of D6 and D7 sites, though all new sites are D7....hopefully we can eventually move all to D7.

I was curious what strategies you guys would suggest for approaching mass updates in this environment.  Do you think it would be worth converting our sites to using Aegir for update administration?  Will this come down to manually updating/working through each site?

Thanks,
Ryan


texts:
We've been using our Drupal webforms for years. Suddenly today, if an authorized user or the admin tries to download the results, the resulting file is 0bytes. The data is definitely there. I am unsure how to even troubleshoot this problem.

The really odd thing is that my dev site is a near identical copy of the live site and it works on the dev site (but the results are outdated). Whatever changed on the live site would have been in the last couple weeks and I can't think of what may have caused it that I wouldn't have implemented on the dev site first.

Drupal 7.50 Commons, webform 7.x-1.0. Let me know what other information would be helpful to provide, thanks!

Things I've Tried, to no avail:

downloaded the results into different formats
downloaded results as regular staff and admin user
downloaded only final and non-draft results


texts:
i have a problem with taxonomy_get_tree().

I want to get all tags from taxonomy. Tags's vocabulary ID (vid) is 1. When I check this in database there are about 4000 terms. If I use taxonomy_get_tree(1) it returns only 150 terms.

Do anybody know what I'm doing wrong?

Thanks for every advice.


texts: Using Services, why is the resource name appended to the endpoint?

texts:
If I want an operation of GET api/v1.0/users and api/v1.0/pages:

Using the Services module to create a REST API, if I define a service with an endpoint of api/v1.0/users and enable the user resource (let's say I enable the Retrieve action), then I have to go to the URI /api/v1.0/users/user/ to get it to work. If I don't include the /user at the end, it returns a 404 error.

However, if I make the endpoint simply api/v1.0, and enable the same resources, then the URI is closer to expect and want: /api/v1.0/user/, but still not quite right. Also, If I define other endpoints using this style (eg. for /api/v1.0/node/), only the last one works; the rest return a 404 error.

Why is it designed this way? And how can I make it not append the resource name to the end?

Update: Based on @mradcliffe's answer, it seems that it's been designed this way so that you can define a single endpoint as a sort of 'endpoint base', such as api/v1.0, then enable multiple resources, which then append their names to the endpoint path.

The problem I see with that is that, if I later create a new version of a resource (eg. the user resource) that does things a little differently, and I thus want to name it with a new version number (eg. users_1.1) to distinguish it from the old resource, that would create a horrible endpoint path of api/v1.1/users_1.1...?

Update: To answer the question of my previous update, I think a better (more efficient) programming practice would be to simply check the api version within the code (wherever the new code deviates from the old) rather than re-naming the resource. I could define a function that pulls the version out of the path for this checking.


texts: How to empty the cart automatically before adding a new item to the cart?

texts:
How to empty the cart automatically before adding a new item to the cart in ubercart ver 6?

Is it possible adding uc_cart_empty($cart_id) ; in uc_cart module?


texts: How to change a content´s workflow state from an url

texts:
I have a server installed with apache2 and drupal 6. In my server, users can make some type of new contents. When they make a new content, they receive an e-mail with creation confirmation.

I´d like to add a new funcionality: I´d like that these users could change the new content´s workflow state from this e-mail that they receive and only from this e-mail(In this way, they are required to sign in their e-mail account).

I have thought that this e-mail could include a url which makes these actions, but I don´t know how do it.


texts: Render a custom module inside an existing node

texts:
I have a site in Drupal 7 and I have created a custom module for a functionality that I need. Usually, I create custom modules and I create a new page to show them, using the following code:

function my_custom_module_theme() {
    $items = array();
    $items['my_custom_module'] = array(
        'render element' => 'form',
        'path' => drupal_get_path('module', 'my_custom_module') . '/templates',
        'template' => 'my_custom_module-template',
    );
    return $items;
}

function my_custom_module_menu() {
    $items = array();
    $items['my_custom_module'] = array(
        'title' => t('my_custom_module'),
        'page callback' => 'drupal_get_form',
        'page arguments' => array('my_custom_module'),
        'access callback' => TRUE,
    );

    $items['my_custom_module'] = array(
        'title' => t('my_custom_module'),
        'page callback' => 'drupal_get_form',
        'page arguments' => array('my_custom_module_empty_form'),
        'access callback' => TRUE,
    );
    return  $items;
}

function my_custom_module_preprocess_page(&$variables, $hook) {
    $alias = drupal_get_path_alias($_GET['q']);
    if ($alias == "my_custom_module") {
        $variables['theme_hook_suggestions'][] = 'my_custom_module';
        $variables['show_messages'] = TRUE;
    }
}

function my_custom_module_empty_form($form_state) {
    $form = array();
    return $form;
}

and my module appears on mysite/my_custom_module .
What I want to achieve now is to add my custom module at the bottom of an existing node, which has it's own content and functionality.
What should I add to my_custom_module-template.tpl.php or in my node--xx.tpl.php to display my custom module inside the node?
I have already used

<?php
   $nid = xx; // NOTE :: Hard coded, but need to be variable!!
   print drupal_render(node_view(node_load($nid)));
?>

from a similar Stack overflow question, but it does the opposite of what I want, it renders the node inside the module.


texts: Path breadrumb crumb displaying just first letter of title

texts: I am using the module path breadcrumb, is it possible to create a crumb which displays just the first letter of the title?


texts: Changing vertical alignment of teasers to horizontal

texts:
I use the theme 'Business' and the standard setting of it is that the teasers of the articles I put on the front page are aligned vertically, but I'd like to have them horizontally in blocks of three--next to each other--instead.

Now I would like to know if it's possible to change this, probably by changing some of the css code (If explained in detail I think I should be able to do this, but I'm rather inexperienced..) and otherwise perhaps with a module I haven't found yet?

I'd be very much obliged.

Edit to answer Volker's question:

I create the teasers automatically when I make a new page: In the menu settings there's an option to 'Promote to front page', which I do and then the link, the image and the first paragraph appear on the front page.


texts:
My zen subtheme doctype is currently !DOCTYPE html and I would like to change this. What is the correct place to add the doctype I want to use?

I copied the html.tpl.php file and pasted it into the templates directory of my subtheme thinking that's where it's set, but it's not being picked up...


texts:
My live/staging Drupal site on remote host was installed without git version control (I don't even recall, but I guess I used wget). Also it has content, modules and themes I wish to keep. The new dev site is also Drupal 7.x but was installed with git version control. To update the dev server I'm thinking to pull down all the content, modules, etc. See if I can get it running, then push it back into a new git repo on remote.

I've added the necessary alieses, and with drush, I copied everything in sites to the local dev site,

drush core-rsync @test:%sites @dev:%sites

Now I wish to use drush sql-sync to pull down the database for the whole site, but minus core. Reading the drush help file for sql-sync, I can only see:

--tables-list  A comma-separated list of tables to transfer.

Which puts me in the same boat if I did a dump from MySQL.

What is the drush sql-sync arguments for modules, themes, sites, but "not core"?


texts: After logging in the user is not directed to the homepage

texts: I noticed that when I login I get redirected to localhost/mysite/user/1 and not localhost/mysite or localhost/mysite/homepage. Why is this and what can I do about to make the user go to the homepage after logging in ?


texts: Views: adding "new" image when published date < 1 month

texts:
In a table view of nodes i want to add a tiny "New" image only when a node is published < 1 month ago.
Is there a way to achieve this without using PHP? If not, is there an easy way and what PHP should i insert?
I was hoping for a little module to get the job done, but haven't found anything.

Thanx,
Cas


texts: How to add Recurring Subscription, Installment to payment gateway in Ubercart

texts:
I am using ubercart-7.x-3.9, Drupal 7.43, ClickandPledge(Payment Gateway found at: https://github.com/ClickandPledge/uc_clickandpledge). My Payment Gateway is integrated with Credit Card type for now(using uc_payment, uc_credit dependencies).
Can someone help me with a way in integrating the functionality. I need a way to display and post my function in checkout on my payment gateway selection.


texts:
I've got around 70k nodes of specified type on my site. I need to run an update on them. Some operations and setting one field to desired value. node_save is really slow and it causes crashes (too long callstack mayby). Is there faster way to write info on this one particular field?

There was field_attach_update mentioned in one post, but it isn't much faster.

EDIT:
There is quite complex view built on this node type, but is not working on this field which I want to update.


texts: Prevent cache when updating with field_attach_update

texts:
I have a problem with caching. I've set up a menu hook for an URL like /user/USER_ID/some_info, which automatically receives the entire user object because of the way I set up my menu hook (see below).

The problem I'm facing is that I have all caching modules enabled in Drupal (including EntityCache) and the $usr variable gets passed from the cache. So naturally if I update a field and save it using field_attach_update, the data is saved into the DB, but the old data is shown on the form, confusing the admins (the checkbox is checked, even though I just unchecked it, and it's value in the DB is in fact 0).

Is there a way I can disable caching for this particular object ($usr) in this particular function?

Note: on my local machine where caching is pretty much disabled, it works fine, both the UI and DB get updated.

My menu hook:

$items['user/%user/some_info'] = array(
    'title' => 'Some Info',
    'description' => 'Edit',
    'page callback' => 'mymodule_edit_user',
    'page arguments' => array(1),
    'access arguments' => array('administer users'),
    'file' => 'mymodule.pages.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 8
);

The function that gets executed:

function mymodule_edit_user($usr){
    // check if POST and validation here
    if(isset($_POST['somefield'])) //checkbox
        $usr->field_somefield[LANGUAGE_NONE][0]['value'] = 1;
    else
        $usr->field_somefield[LANGUAGE_NONE][0]['value'] = 0;

    field_attach_update('user', $usr);
}


texts: How to force homepage to non-default language

texts:
I'm working on a bilingual website (French and English). The homepage currently shows up as per language detection settings, but I need it to show in French first, with the English version available via language switcher.

Info: Both languages use prefixes, and the language detection settings are ordered as URL>User>Browser>Default (English). The homepage is built with Panels and Views.

I've tried playing with redirects (has no effect) and i18n Variables (results in the page content not being found).


texts: admin theme changes to default at editing page, Themekey module

texts:
Using the ThemeKey module, I have changed the theme of user role (EDITOR) to Administration theme. So, when the user of this role logs in, he gets admin theme.

It works find but when he edit something the theme changes back to default. I want to have admin theme, even at editing pages for this user role. Please suggest.


texts: In image_link setting, How can I change "content" to the specific node

texts:
The example in API show that 'image_link' => 'content', How can I change "content" to the specific node. This is my code in basic page:

$node = node_load($nid);
$image = field_get_items('node', $node, 'field_pg_image');
$output = field_view_value('node', $node, 'field_pg_image', $image[0], array(
  'type' => 'image',
  'settings' => array(
  'image_style' => 'thumbnail',
  'image_link' => 'xxxxxxxxx',
),
));
print render($output);

I would like to change 'image_link' => 'xxxxxxxxx' to "node/30?ptype=20"; How to do this


texts:
I have a Drupal 6 site with an increasingly bloated forum. I am wondering whether it is possible I can move the forum out of the main site's database to a new database, possibly hosted in a new server.

So  I guess my question is a special case of distributing a single Drupal database over several servers.


texts: Active user account after administration's confirmation

texts: How to, by using module Profile2 Registration Path, the user's account becomes active after it is activated by the administrator. The administrator should get email when user creates new account.


texts:
I have a view which lists items of food.

I would like to give the user a select box so that they can choose the quantity of the food item and then submit the view as a form. This will then need to be sent as an email.


texts:
I would like to know how I can make File field type display the upload as a download link, instead of having a link. So that user can just click and it will download).

The file field type, I added to a custom Content Type, which I created programmatically through a module.

Currently it looks like below, when I click the link, it takes to the uploaded file page. I would like to have it download instead.

Or maybe is there a way to change the view or add additional view to File types for download? or maybe change view for Content Type where it displays the Download link for the file?


texts: How can I add an external (CDN) CSS style sheet to a theme?

texts:
I'm trying to add Font Awesome to a Bootstrap subtheme I have made.

Here is the code I am using in subtheme.libraries.yml, which is based on the documentation for hosting external JS libraries in Drupal 8:

font-awesome:
  remote: https://fortawesome.github.io/Font-Awesome/
  version: 4.5.0
  license:
    name: MIT
    url: https://fortawesome.github.io/Font-Awesome/license/
    gpl-compatible: true
  css:
    https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css: { type: external, minified: true }

Unfortunately this results in a WSOD.  The error log gives these two errors:

  Warning: constant(): Couldn't find constant
  CSS_HTTPS://MAXCDN.BOOTSTRAPCDN.COM/FONT-AWESOME/4.5.0/CSS/FONT-AWESOME.MIN.CSS
  in Drupal\Core\Asset\LibraryDiscoveryParser->buildByExtension() (line
  143 of
  /srv/bindings/code/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php).

And:

  Warning: Illegal string offset 'weight' in
  Drupal\Core\Asset\LibraryDiscoveryParser->buildByExtension() (line 143
  of
  /srv/bindings/928c941920f8443d9e50a3d908967fee/code/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php).


texts:
I am updating a module that I built for my site. When I originally built the module, I didn't know much about Drupal and I gave it a version of 0.0.1. Now I'm working on a completely different version that will be using 7.x-2.x as the version. I need to run an update for the module to work. I have this function

function contacts_blocks_update_7200() {
  // Update code.
}

When I go to update.php on my site, I get an error that there are no pending updates. I've also tried contacts_blocks_update_7201. Neither is working. I do not understand how to make an update run this function. I've had a similar issue with another module and was never able to get the update function to run and ended up doing it manually.

I checked the schema_version of the module in the system table and it says 0. I'd really like to learn how to do this. How do I determine the N for hook_update_N?


texts: How to use arguments, defined in a custom event, for an action

texts:
I've just defined this event with the two arguments: number and message. I want to use them to verify the message and send a response back to the number. I have an action for that but I don't know how to pass the arguments.

function sms_rules_rules_event_info() {
  return array(
      'sms_rules_sms_received' => array(
         'label' => t('SMS received'),
         'module' => 'sms_rules',
         'arguments' => array(
            'number' => array('type' => 'text', 'label' => t('Number from where the message was received.')),
            'message' => array('type' => 'long text', 'label' => t('Contents of message.')),
         ),
      ),
  );
}


texts: Which template or include file in Omega subtheme takes hook_form_alter()?

texts:
I want to use hook_form_alter in my Omega subtheme. I'm trying to put the function in the correct place but I'm getting no results after clearing caches and refreshing.

Here's the code:

<?php function rescue_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_block_form') {
  dsm($form_id);        // HTML5 placeholder attribute
    $form['search_block_form']['#attributes']['placeholder'] = t('enter search terms');
  }
}

I don't know whether to include a closing ?> or not. I've tried it both ways. I've tried saving it as preprocess-page.inc and process-html.inc but neither has given any result. Help?


texts: Do i need write access to the files directory to migrate d7_file?

texts:
I'm migrating a site from drupal 7 to 8.  It has many many media files.  Something like 6TB worth.  And adding daily.  So i want to do the db migration on my machine (not the webserver), work out kinks and modify custom code to work w/ d8, then do the real thing on the live machine over a slow weekend when i have all the steps worked out.
In the migration process, i've gotten to drush migrate-upgrade d7_node, and it (on initial run, with only a token few files in /sites/default/files) created a handful of db entries in file_managed.  So i sshfs mounted the live files directory read only from my machine and re-ran migrate-upgrade d7_node from the restored db.  Now it doesn't create anything in the file_managed table, so i suspect it's not working, but it gives no errors, and some grepping doesn't readily yield the code that does this work.  I wouldn't mind hacking for this part only.
Hence the question.  And what can i do alternatively to avoid copying 6TB of files for the preparatory migration?
Thanks.


texts: Comment approval permission to non-admin user

texts:
I have three accounts in my Drupal 6 site:

admin (which is admin)
moderator
moderator2 (which is authenticated role defined)

Now I want to give permission to the moderator2 to approve comments just like I did from admin account by only going to /admin/content/comment. How can I do that?


texts: How to have users set a value for a flag field upon flagging?

texts:
I added a field (Text list of options) to my flag.  But, when a user flags the content, they don't get a chance to set the value for the field (the flagging form does not show the field to edit).  Instead, the user has to flag the node, then go to the flag edit page, then set the value, and then re-save the node. Instead, I want the user to set the value of the field upon flag creation.
In other words, I want to use flags like I use nodes. With nodes, when you add a field to a node, that field is shown on the node creation form, and users with permission to add the node can also set the value for the fields on the node.
How do I do this in Flag?


texts: View: update single rows with AJAX on a VBO view?

texts:
We use a view to list all new entities, let's say "message entities". Users can create messages, those messages are created as a custom entity type and get listed in an inbox as long they are not answered. Admins open the inbox (a view) and see the currently not answered messages. They can see which messages are currently worked on by other admins which is indicated by a color for the row of the message in our view. This inbox gets updated regularly: admins keep the inbox open in their browsers. By now we simply do an Ajax request and replace the view in the browser. In this way we achieved that admins can see when a message is worked on by someone else as we change the background color of the row for this message when rendering the view by do a simple check in the background - for know it is not so important how this is working. Just to explain why we do this Ajax replacement every few seconds.
What now appears to be a problem: we want to offer some VBO actions on this view so that messages in the inbox can be bulk updated or deleted for example. When I choose a few of the messages in my inbox my choice disappears every time the whole view is replaced by the Ajax call.
So my question: is there a way to dynamically remove and add single rows from a view by Ajax when messages were answered or newly sent? How will the VBO form already rendered in the browser handle changes in the single rows caused by Ajax - will this work with dynamically added items? Could this be the way to do this. I wondered if Ajax / JavaScript would be a good choice or if Websocket would fit better... is there a way synchronize a view with Websockets when opened in different browsers?


texts: Error after installing and enabling "Rooms-Drupal Booking for Hotels, B&B and Vacations" and dependent modules

texts:
After installing and enabling "Rooms-Drupal Booking for Hotels, B&B and Vacations" and dependent modules, I get this error when I try to go to the content menu. Does anybody have anything to fix this issue? I had to download multiple modules since they were dependent.

If you don't, can you recommend me a better solution for Room Reservations?


texts:
I am attempting to install modules on Drupal 8 but I'm getting a failure that says i need to install commercial guys, addressing and zone libraries. When I put the libraries inside the library directory: (public_html/mysite.com/sites/all/libraries)  I still get this error. I'm thinking I need to install them somewhere else since I'm using Drupal 8.

Also, there is a module called composer manager which according to my reads automatically installs needed libraries for modules. The problem i'm facing is that its asking to use the command prompt to install them. see the link below:

How to install the commerceguys libraries for Drupal Commerce 2.x?

Im using Hostgator hosting, how can I install this using command prompt? Which command prompt do I use, Drush, Bash?


texts:
Is there a way around to build link library repository on a drupal site, so that there can be one place to edit the links and changes will reflect in the instances used else where (like body field of a content type)

Any starting pointers?


texts:
I am using imagefield and D6 with filepaths to upload images to a custom directory using a custom token.

I'd like to validate whether an image that was uploaded is the same as another image in the repository.

I see that imagefile appears to be uploading the file to: default/files/, then deleting it there and saving in the directory I specify using my custom token.

Is default/files where imagefield is saving the file as a "temp" file until validation passes? I would think it would save a temp file in the temp file location specified by php.ini. If the later is true, can I get a hold of the tmp name in $form_state? I believe with image module, I could get the temp name of the file from $form_state, but I don't see that info using imagefield. Thanks in advance.


texts: How to count the number of posts by a author? D8

texts:
I see how to do this in D7. I tried to do something similar in D8.

I tried using Entity instead of Content because there is no content:nid option in D8 my view looked like this

(author) COUNT(File Usage: Entity ID) (Count by User) | Aggregation settings

but my results where all 0


texts: When programmatically adding conditional element to webform, I get errors

texts:
I'm trying to add a new conditional attribute to a bunch of webforms using a script.  There are already 12 conditions, and I need to add a 13th one.

My code looks like this in a basic script module which has $node available:

if(stuff_is_true){
 $new_component = array(
  'nid' => $node->nid,
  'rgid' => '13',
  'andor' => NULL,
  'action' => 'hide',
  'target_type' => 'component',
  'target' => '22',
  'weight' => '13',
  'rules' => array(
    '0' => array(
      'nid' => $node->nid,
      'rgid' => '13',
      'rid' => '0',
      'source_type' => 'component',
      'source' => '21',
      'operator' => 'equal',
      'value' => '0',
    ),
  ),
);

$node->webform['conditionals'][] = $new_component;

// Save the changes
node_save($node);

All of this works if put into a hook_node_view() (without doing a node_save obviously), so I know it's structured properly.

The problem comes during node_save($node) which throws an error like:

Duplicate entry '3033-0' for key 'PRIMARY': INSERT INTO {webform_conditional}...

(3033 is the nid, and the 0 is the rgid key).

Basically, what it's doing (I think) is trying to re-submit the whole $node->webform['conditionals'] array as NEW data, so existing components hit this "duplicate primary key" error (because they already exist).

How can I tell node_save to only ADD my new conditional item to the end of the existing array instead of trying to re-insert the whole thing?


texts: State of form element based on global config

texts: I have a form_alter that adds some settings on a content type. How can I make one of these elements hidden (and cleared?) based on the value of a global config (set with variable_get)? I found the states api, but that only manipulates elements based on the values of other elements on the same form. Is there a best practice for what I am trying to do?


texts: Rules: after saving new content and after updating existing content both triggered on node create

texts:
I define two rules that should send an email once new node has been created. And second rule once user updated his content.

The problem I am having here is that both rules trigger in one time when your create a new node.

I found the same issue has been asked in anther question but not very clear and i am not able to understand enter link description here

But I am not able to understand.

Thanks for the help.


texts: What is the specificity limit of EntityFieldQuery / fieldCondition?

texts:
I have a webform that I want to grade, like a quiz. (No, not with the Quiz module).
I have a content type called Answer Key with a Reference field called field_answer_quiz.
Upon webform submission, I want to:

Look through all nodes of type Answer Key
Find the one with a field_answer_quiz value == the current webform
Use node_load() or something to pull out content

Here's a Q&A that makes it seem possible: how to extract values of field collection using Entityfieldquery?

But here's a comment that makes it seem impossible:

  If that's what you want, then this is the correct way and EntityField does not help you. What EntityFieldQuery does is load entity IDs of entities based on their properties and fields. You could for example use it if you want to load the node(s) that has a specific version value by first loading the field collection item and then loading the node that references the field collection item. You're doing the opposite, you have the node and want the version value. To get field values, you always need to load the entities.

So, which is it? Is it going to be possible for me to use EntityFieldQuery to do this? I'd really like to avoid having to load a ton of nodes just to shuffle through them.

This is the code I am using.

function webformta_webform_validation_validate($validator_name, $items, $components, $rule) {
$arg = arg();
$nid = $arg[1];
dsm('The NID of the current node is '.$nid);
$query = new EntityFieldQuery;
$result = $query
    ->entityCondition('entity_type', 'node')
    ->propertyCondition('status', 1)
    ->propertyCondition('type', 'quiz_answer_key')
    ->fieldCondition('field_answer_quiz_nid', 'value', $nid, '=')
    ->execute();
    $results = $query->ordered_results;
  dsm($results);

It causes the following error:

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_answer_quiz0.field_answer_quiz_value' in 'where clause': SELECT
  [...] (error is really really long)


texts: Inserting field or field collection into body field

texts:
I've created a content type called "News" with the following fields:

Body
Image (using Insert module to allow user to insert picture into the body)
Body Sidebar (a field collection, surrounded by a  with the following fields)

Body Sidebar has two fields:

BS Title
BS Text

I want to be able to give the content creators an easy way to insert the sidebar into the body in a similar way they can with the image field. As far as I know the Insert module can't be used to do that.

Is there any way to allow users to insert the Body Sidebar div into the Body field? If not, is there a way to do this programmatically?

Apologies if this is elementary, I'm very new to Drupal.


texts: How to restrict download file for authentication in drupal

texts:
I have create one file field in my node create form , file is accepting (txt,pdf,xlx,docx) files only.
 but in node view page, i want to authenticate our file before download.

I have create one term and condition checkbox, if user check this term and condition checkbox , then he should be able to download the file..

This functionality i need to do, please suggest me any module is available for this..

or if this functionality is possible through conditional fields , so please suggest me, how can i do


texts: Search in comments of specific content type

texts:
I'm looking for a module that provides the possibility to filter/search in comments.

When there is content of the content type = Proposal you can comment on it. There's a good change that there will be 50 comments or more. Now I would like to have a search box beneath my content, above my comments that filter the comments when you search for a string.

I would also need to filter the comments for ex. between dates, by username, by number of votes, ... .

I've searched the internet but couldn't find anything that provides this functionality.

Has anybody ever needed this and which module you used or how did you approach this?

It's something like this I need:


texts: Node reference - limit so node can only be referenced once

texts:
I have two nodes 'Runner' and 'Buddy'. I'm using node reference to create a select list of buddies on the runner node.

The Idea is that every runner only has one unique buddy and two runners don't end up with the same buddy.

When editing the runner the buddy select list shows all buddies, I would like it only to show buddies that don't have a runner.

How would I achieve this?


texts:
I read this article.
Where is the location of "system" table.

Is the image "system" table?

phpMyAdmin

To disable a module via phpMyAdmin you must login to phpMyAdmin. Then you must locate the database where Drupal is installed. Once you have done so look for the "system" table. Click and open it. Click to browse the table. Find the record for the module that is causing the problems and select the edit function. Set the status to "0" and save.


texts: How to exclude a module from being uninstalled during import?

texts:
On my local I have installed my custom module which depends on a contrib module.
I have removed both modules from the core.extensions.yml and added the following to settings.local.php.
$settings['config_exclude_modules'] = ['contrib_module', 'mymodule'];

But when I execute drush cim, both of the modules get uninstalled.
But I can read this specifically.

When syncing configuration, if an excluded module is already
installed, it will not be uninstalled by the configuration
synchronisation, and dependent configuration will remain   intact.

Do I need to execute some command after adding it to the settings.php? Why it is not working.


texts:
I want to make a frontage with the Views module. On the frontpage, you can see 3 images, horizontal aligned. I don't understand the Views module very well, but I thought you can make for example a page with the Views module where you can add content that already exists on other pages.
So I don't know what to do now, as my images don't exist anywhere.


texts:
The Webform module is installed. I go to /admin/content/webform to build new form, but the page is completely blank. The content is empty. What am I missing? Is there an additional library I need?

I do have Views and Chaos Tools installed. And my administrator role has permission to modify webforms.


texts:
In my status report I'm still getting this error:

Browscap data   /   browscap.ini is not configured in php.ini.

When I searched on the internet I found this topic that suggested this:

[browscap]
; http://php.net/browscap
browscap = "C:\xampp\php\extras\browscap.ini"

I've download full_php_browscap.ini file on browscap.org and placed it in the root where my php.ini is also located (also changed the name to browscap.ini).

Then I've placed this in my php.ini file:

[browscap]
browscap = "/domains/mydomain.be/public_html/staging/browscap.ini"

But I'm still getting the error ... . My php.ini file is located in the same directory as the browscap.ini file.


texts: Shopping cart views are not show product links

texts:
I am using Commerce Kickstart V t-7.x-2.2

I realized the next: When I add a new product and I add to cart it, not show the link "view product" . But when I edit that product and modify something on product variation and save again. The link "view product" appears in Shopping cart.

Somebody could tell me what is happening? Is it a bug of the commerce kickstart ? or Am I doing something wrong?

Any help will be highly appreciated. Thanks.


texts: Dashboard like module that works with Panels

texts:
Dashboard module lets users change the dashboard according to their preferences. IS there a similar module which does the same for panels.

For example.

An admin user decides which blocks should be available on a particular page.
Each user can decide the order in which these blocks should be shown for him and whether they should be shown at all.


texts: Reusing drupal forms in a profile installation?

texts:
I've setup a custom installation profile, and of my installation steps is setting up Google Analytics.  I've downloaded the Google Analytics module and enabled it in my site profile.

What I'm doing in my install step is as follows:

hook_install_tasks()

$tasks['site_google_analytics_form'] = array(
  'display' => TRUE,
  'type' => 'form',
  'display_name' => st('Google Analytics Configuration'),
);

site_google_analytics_form()

/**
 * Configure google analytics.  The only required field is the tracking code.
 */
function site_google_analytics_form() {
  module_load_include('inc', 'googleanalytics', 'googleanalytics.admin');
  return drupal_get_form('googleanalytics_admin_settings_form');
}

The probelm I'm having is that, even if I enter a valid web property ID, the form always comes back saying that an invalid ID was entered.  I checked to make sure the validation function is firing (which also is in googleanalytics.admin.inc), and it is, but the $form_state variable doesn't have any of the form values preserved.

So, I guess my question is this - why is the $form_state variable being passed into the validation function not storing the values I specified in the form during the install step?


texts: How can I temporarily prevent any logins?

texts:
I've a high visitor website in Drupal 6. For performance reasons I've removed Captcha on all pages.
I don't want anybody to log in and  we don't logout.
Can I rename any Drupal file related to login-functionality? I have SSH access and also use drush. When I want to enable login functionality I've move the file back.


texts: How to change a term URI based on content type

texts:
I have 2 content types (photos, videos) and both have a term reference to a "topic" taxonomy.
The topic terms are showing on the node display pages and I would like to link to "/photo/%" for photos and "/video/%" for videos instead of the default "/taxonomy/term/%".

How can I do that?


texts: Create rule to e-mail only someone who has combined roles

texts:
This is for a Drupal 6 install.

In rules there is an IF statement available of "If user has roles" and this can be set to be either an "and" statement or an "or" statement.

Within DO is an option to send an e-mail to everyone of a selected role.

I'd like to combine the selector of "if user has roles" using the "and" portion with the DO action of send e-mail to everyone of a selected role.

The site is currently using workflow & revisioning. Using Node Privacy Byrole I've assigned certain parts of the website to a specific department for editing.

Then using Workflow Access I've set up authors, editors, and publishers to limit the actions someone in a department may take on a node.

So there may be a user who is in the department role of "Marketing" and is also an "Editor." Then there may also be someone who is in "Marketing" who is also a "Publisher."

I'd like to notify say the Marketing Publisher (2 different roles) when a post changes workflow state, then have the Marketing Editor notified when a post changes to a different workflow state.

The workflow state is already available as an IF statement within rules, I just need to figure out how to create the DO statement to allow me to send e-mails based on this combination of roles.


texts: How to create views of nodes and all revisions in?

texts:
As it is obvious form the title I am want to create a views which has all contents of a given type and all its revisions under it.

I tried these ways but none of theme gave all I need:

Create a views from contents with relation to revision NID.
It just give the last revision.
Create a views from contents with relation to revision ID.
It has no difference with the previous one.
Create a views from content revision.
Again just the latest version appeared.

So what will be solution to do that?


texts:
I dislike the notion of using something like this since it may mean I have to commit my table data straight to HTML sooner than I want to:

$render_array = array(
    'maintable' => array(
        '#markup' = theme_table($table)
    ),
    ...
);

Do I have an option to pass the table data into the render array (as opposed to rendering it immediately to HTML), by chance?


texts:
This is related to Paragraphs module in Drupal 8.
I have enabled paragraphs module and Entity Reference Revisions module. Then I created a new paragraph type in Admin> Structure> Paragraph types. After that I added fields to the new paragraph type. After some configuration I tried to add the newly created paragraph type to a content type, in my case article.
But I got the following error:

There was a problem creating field Paragraphs: The "entity_reference_revisions_entity_view" plugin does not exist.

This is a persistent error. As I have rebuild the site from the scratch, and I am getting the same error.
I will appreciated a help.


texts: Use views as radios (or check-box) options in drupal forms

texts:
Here is the scenario:

There is a multistep form for creating a content type "Support request".

Step 1: In this step, the user enters his/her device model and click next.

Step 2: In the next step, a list of technician (technician is a content type) whom has knowledge about that certain device will be shown, in this steps some information about technician is shown (from node) and user can decide which technician to hire.

Step 3: In the last step, some information about device problem is submitted by user and the form is submitted.

Now the question :

  Is there any solution to use views in second step? How can a view like this (note that the view output should be filtered based on the device model selected in first step) can be passed as radios options in drupal forms?


texts:
Following use-case:

An airplane is bought by an (organic) group. Each member has its own share which is dependent on the amount of money chipped in.

All group members together own the plane 100%.

The amount of time a member can use the plane depends on the share he has on the plane.

I was thinking about a share or fraction type of field to link the group member to the airplane.

Any thoughts how to handle the above use-case?


texts:
I would like to display a node as a block in Drupal 8, but I don't know how to do this. I know in Drupal 7 I could use the Nodeblock module to accomplish this task, but there isn't a Drupal 8 version of it (and it looks like that there never will be).

Can this be accomplished using another module that I am not aware of?


texts: (dis)advantages of staging dev->production using 'drush rsync' vs 'git'?

texts:
I set up a Drupal site under git control for development work.

It's parented in a master, bare GIT repo, and as changes are made in my various project-work git clones, and pushed back to the master, a post-update hook immediately pushes the changes to a single live Staging website (http://staging.loc.). Nothing special, works as expected.

I've also drush-aliased the site "@STAGING". On occassion, I want to promote my changes from the Staging site to a production server.

Two relatively straightforward methods come to mind:

(1) At a point in time when the Staging site appears stable, create the Production site as a git checkout from the master repo,

(2) use drush rsync + drush sql-sync from the staging site to the production site.

Both can be made to work.  Other than the fact that (2) seems more Drupal-centric/aware by nature -- drush is, after all, a Drupal-specific set of tools -- what are the relative merits of the two approaches?

Is there any particular reason I should consider (1) over (2)?

In either case "Everything" is under at least one instance of revision control ...


texts: Is there a way to load the content types using DrupalWebTestCase?

texts:
I'm trying to learn how to do testing in Drupal. I'm pretty new with it so maybe i didn't got it right.
well, I'm trying to test some views of content types, but to test those views i need to have that content type created when im testing. actually with drupalWebTestCase it's seems it doesn't load the content types that i would have in my normal drupal(except for the basics).

I tried to use simpletest clone but it doesn't work,don't know why, and I don't need all the database for it, just the content types and views.

So... Is there a way to load that content type WITHOUT having to create everything by code? I've a lot of content types some with some complicated fields and loading one by one sounds too harsh to be done.


texts: Can users be forced to insert only plain text by default in CKEditor?

texts:
I know there is "Paste Text" button in CKEditor, and I can limit allowed HTML tags.
But it's very hard to explain clients to use specific button when they insert text.
As result they often insert "dirt" texts with HTML tags.
As I remember there was setting in early versions of CKEditor to force insert plain text by default but cannot find it in current version.
Is there any solution for the problem?
UPDATE:
I don't want to restrict user to use some tags. But user should get "clean" plain text without HTML tags when insert text.


texts:
In my task I need to display the results based on "the newest first". I perform a query:

$query = \Drupal::database()->select('node_field_data', 'node');
$query->innerJoin('node__field_ils_apps', 'app', 'app.entity_id = node.nid AND app.field_ils_apps_target_id = '.$node->id());
$query->addField('app', 'entity_id', 'nid');
$query->groupBy('app.entity_id');

$query->orderBy('created', 'DESC');
$query->execute();

But it returns me an error:

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column

Could you please tell me what I do wrong?


texts: How to display the first child of a book with the title of the book and keep the url by using a view

texts:
Is it possible to display the list of the first child of every book with a view? I couldn't figure that out so I added boolean to the book content type to check which child is the first child. If that's not possible I'll just keep it the way it is, but the main problem is overwriting the the name of the first chapter (keep the url) with the name of the book. I wanted to do that with the custom text field, but I don't see the replacement pattern of the book name, so is that even possible?
I'm using Drupal 8.
Thanks in advance!


texts: Strict HTML strips CSS classes in a custom block

texts:
I created a custom block using Strict HTML (and adding <div> and other tags to the allowed HTML). If I look at the frontend, it strips all the CSS classes like <div class="myclass">.

What do I have to do to create this block with all the CSS classes, and the custom HTML markup?


texts: zero distance in views geofield proximity problem

texts:
I am having trouble getting it views to calculate the distance. I want a current user to see the distance to other users however the only result I have gotten is 0 between users.

I tried to follow this and still got no result:

  Looks pretty straightforward using geofield 7.x-2.0-alpha2:

  I assume you have geofield and geophp enabled and assume you have
  added a geofield to your users that get the location from an
  addressfield.

  create a view of type users add "[name of your geofield] - proximity"
  field select "source of origin", I tried "exposed geofield proximity
  filter", check the "round" box add "[name of your geofield] -
  proximity" exposed filter and select a "source of origin point" as
  well. For example, add a "geocoded location" (fancy word for address)
  add that same field to your sort options to sort by proximity as well.
  In your example you would probably change the "source of origin point"
  to "current user".

I have checked the users address and they create points. Do anyone have an idea how to get it to work?


texts:
Suppose we have a simple module with 3 files: test.info, test. install and test.module.
test.install
<?php
function test_schema() {

    $schema['test'] = array(
        //fields
        'fields' => array(
            'id' => array(
                'type' => 'serial',
                'unsigned' => true,
                'not null' => true
                ),
            ),
        //additional properties
        'primary key' => array('id'),
        );

    return $schema;
}

When I install the module via the web interface, the table is created. Then I add hook_update:
function test_update_7100() {
    $spec = array(
        'type' => 'varchar',
        'description' => "New Col",
        'length' => 20,
        'not null' => FALSE,
        );
    db_add_field( 'test', 'name', $spec);
}

Now I need to run the update function to modify the table. But I don't know where I can do it. Module is not present in "Modules" -> "Update".


texts:
Im using the Aegan theme, and it uses it's own slideshow. Now I'd like it to use a specific image style, that formats the images according to my presets.

The code in the page.html.twig looks like this

{# Include a slider. #}
  {% if slider %}

        {% for slide in slider %}

            {% if slide.description %}

{{ slide.description | raw }}

            {% endif %}

        {% endfor %}

{% endif %}

The style is called aegan_slide (don't really know where I can find it. But how do I apply my custom style to this code?


texts: Upload file using File type="managed_file" disappears immediately when clicked on upload?

texts:
I want implement upload zip file using FORM API where I want to show the progress bar for uploading file so I have written code like:

$step2['browse']=array(
        '#type'=>'managed_file',
        '#id'=>'choose',
        '#progress_indicator' => 'bar',
        '#progress_message'=> 'File is Uploading',
        '#upload_validators' => array(
        'file_validate_extensions' => array('zip rar')),
        '#upload_location' => 'public://',

      );

But when I am trying to upload zip file using this form, my upload file field disappears automatically and also upload button disappears with it.

I am not getting what is wrong with this field.

I have applied 2 patches but that doesn't helps.


texts: Why is the database not updated before a next Rule is launched?

texts:
I have two Rules (created with the Rules module) that are both launched when an article is flagged with the Flag Approved:

Rule 1. Publish the flagged article with the action Publish content.
Rule 2. Count the amount of published articles by the author of the flagged article. Display a message when this number is 5.

I'm using the following code in the condition of Rule 2:

return MYMODULE_count_articles($flagged_node->uid) == 5;

where my custom module contains the function

function MYMODULE_count_articles($uid) {
  $count = db_query("SELECT COUNT(*) FROM node WHERE uid=$uid AND status=1 AND type='article'")->fetchField();
  return $count;
}

The condition of Rule 2 is evaluated as FALSE when the 5th article is flagged with Approved, but evaluates as TRUE when a 6th article is flagged.

I suspect that this problem is caused because the database hasn't been updated yet when Rule 2 launches, because debugging the $count variable at the 5th flagging returns 4 instead of 5. Also, executing the condition's code afterwards yields the correct value 5.

Is this a know problem/phenomenon or a bug in the Rules module? Or is there an easy way to fix it (apart from changing the condition to ... == 4, which is really dirty)?


texts: form_set_error() doesn't work in exposed_validate()

texts:
I have made a custom module which implements a new field for Field API and a filter for Views. Everything works like a charm except value validation for exposed filters. I will describe a problem step by step:

Made a new view and added two my custom filters on it.
Made them exposed (both value and operator).
Named operators as 'date_op' and 'period_op', and filters as 'date' and 'period' (they MUST be named differently for obvious reasons).
Made both filters 'required'.

In the  value_form() function form element is defined as:

$form['value'] = array(
      '#type' => 'textfield',
      '#title' => t('Value'),
      '#size' => 25,
      '#default_value' => $this->value,
    );

In the exposed_validate() function there is a code which check values for validity and call form_set_error () function in the case of error. But in fact form_set_error() neither show error message nor draw red border around a wrong form element! Form is just simply redisplayed without any visible error. :-(

This is a code excerpts of my exposed_validate() function:

...
$identifier = $this->options['expose']['identifier'];
...
if (!empty($this->options['expose']['required'])) {
  dpm($identifier, 'Required!'); // So I can see that this part of function is really executed.
  form_set_error($identifier, t('This field is required and must be set.')); // Neither error message nor red border here :-(
  form_set_error('period', t('Period error! ')); // As above, neither error message nor red border
  form_set_error('period_op', t('Period_op error! ')); // Both error message and red border around operator element are visible
  form_set_error('value', t('Value error!')); // Error message only, but no red border (because there is no such element on a form)

As you can see, form_set_error() function trying to find a form element named 'value' (as described in value_form() function) but there is no such element on form, there are only 'date' and 'period' ones. And it is strange enough that form_set_error() call for operators works as expected.

So, the question is: how to make a form_set_error() to highlight a right element on a form in the case of error?