texts:
I have installed drush usnig composer by using following command in my windows 10 machine:

 composer global require drush/drush

After that if I run below command in my drupal project folder using git bash, getting below result:

ak@LT123456 MINGW32 /c/wamp/www/myproject (master)
$ drush --version
Could not open input file: C:\\wamp\\www\\myproject\\drush.php

ak@LT123456 MINGW32 /c/wamp/www/myproject (master)

If I run drush status in cmd getting below result:

Microsoft Windows [Version 10.0.15063]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\ak>drush status
 PHP configuration      :  C:\wamp\bin\php\php5.5.12\php.ini
 PHP OS                 :  WINNT
 Drush script           :  C:/Users/ak/AppData/Roaming/Composer/vendor/drush/drush/drush.php
 Drush version          :  8.1.15
 Drush temp directory   :  C:\Users\ak\AppData\Local\Temp
 Drush configuration    :
 Drush alias files      :

But why drush is not working inside my project folder?

My project folder having following files:


texts:
I'm looking for a way to set a minimum quantity per product in a Drupal Commerce store.

I found this module which claims to do just this, but I can't get it working and the project seems abandoned:

I found this one which is useful if you need to set a minimum in the order but it doesn't help to set a minimum in products.

Is there any other way to do this?


texts: How to set/display select options in selectbox using form-api

texts:
I have created a form to allow users to enter some details but I also need to display some mysql data into that form. The contents and fields of the form are displayed in a tabular format. I just want to know the right way to display mysql data in one of the table columns along with the form fields.
How can i display select options in selectbox using form-api ?


texts: Is there a module to show photos on Drupal site that come from Facebook user profile/Facebook page, like Wordpress Fotobook

texts:
Wordpress Fotobook plugin will show photos from a user's Facebook profile (assuming the user has set the appropriate permissions for them to be made visible, and that suitable Facebook App settings and id have been setup).

I wondered if there was an equivalent module for Drupal?

I would prefer a module that doesn't locally copy the photos onto the site but rather links to the original photos on Facebook. This preference is be efficient with bandwidth, storage space, and backup. Effectively, I'm looking for something that makes Rvisible album photos in a similar way to RSS feed (doesn't have to be exactly the same format as RSS but the same kind of idea whereby the original content is not copied.)

I am developing sites for two friends who actively use Facebook but want photos on their own sites. With the Drupal 7 Media module, multi-image batch uploading is very capably handled in Drupal, however this still requires double effort to upload photos both to their profiles and their sites.

Let me know if a module is available. I am considering writing one myself, learning from Fotobook, but didn't want to duplicate effort.


texts:
for my marketplace based on Drupal Commerce I need to give to my sellers the possibility to enter their shipping cost so that the buyer will be choice from 1+ alternatives (say postal mail, ups, dhl, etc etc). For insert and retrive there is no problem, I can write a custom module.

My problem is how to give, in "Shipping cost" page, to the buyer the possibility to choice the best (for him/her) shipping cost method. I have tried to use Shipping module with an hacked version of "shipping flat" module but without success.

is there a possibility to do this thing ? I think yes because the old custom eshop in use into that site allowed it.


texts: How to show the content of a group on the group page when using the Group module?

texts:
Using the Group module, you can create a group, say 'group ABC', and create or update some nodes so that they belong to that group. But when you visit the "Group ABC" page, you don't see those nodes. Moreover, by browsing the nodes you don't see anything indicating those nodes belong to "Group ABC".

How to list the nodes that belong to a group on the Group page?

Note: This module is available for both Drupal 7 and Drupal 8, and this question applies to both releases.


texts: Custom 404 page in a theme doesn't work as expected,

texts:
I want to use a custom 404 page, I also have a theme installed.

This is what I did:

Go to Content, create a Node, I got path: node/28
Go to System->Site Information->Error Pages-> 404 page, I enter node/28

Then I type some pages that are not exists, it doesn't link me to the node/28, instead, it still use the themes' 404 page.

Some hint here?

BTW, I am using Drupal 7 and the theme called MD magnum.


texts: Make hook_menu() argument as global variable

texts:
here's the code from my module:

function vasya_init() {
  // ajax framework
  drupal_add_library('system', 'drupal.ajax');
  drupal_add_library('system', 'jquery.form');
}

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

  $items['get_alt/%/%'] = array(
    'page callback' => 'alt_getter',
    'delivery callback' => 'ajax_deliver',
    'page arguments' => array(1, 2),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function alt_getter($get_alt = NULL, $mode = NULL) {
  if ($mode != 'ajax') {
    drupal_set_message('Turn Javascript');
    drupal_goto(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '<front>');
  }

  // globals
  $GLOBALS['get_alt'] = $get_alt;

  $commands = array();
  $commands[] = ajax_command_html('.big-image', $GLOBALS['test']);
  return array('#type' => 'ajax', '#commands' => $commands);
}

function vasya_node_view($node, $view_mode) {
      $test = theme(
  'image_style', array('style_name' => 'node-image', 'path' => $field_sell->field_photo['und'][$GLOBALS['get_alt']]['uri'], 'alt' => $GLOBALS['get_alt'])
);
}

On the node page i have a links:

When i click on one of these links it gets an argument i.e. 1, 2 or 3. This argument is stored in a variable $get_alt. Then i want to send the value of $get_alt to a function vasya_node_view() through $GLOBALS.

But it shows undefined index 'get_alt' message. Can someone help me?


texts:
I am currently porting a custom field module from Drupal 7 to 8. The field (Topic Access) has 3 select fields, typically about 10 to 20 items per field, and uses a custom widget. When the form is loaded, I typically insert several "inherited" items to the field before displaying it. When saving, only the items that vary from the inherited ones are actually saved to the database.
In Drupal 7, I used hook_field_load() to add these "inherited" items to the form. As explained on Dynamic/Virtual field values using computed field property classes, that hook has been removed from Drupal 8 in favor of computed field properties.
I can't see an elegant way to manipulate the list of items. I could use hook_form_alter() on the forms that contain the field to update $form['field_topic_access']['widget']. However, it would end up duplicating code from the widget and have to specifically pick out the fields by name.
Is there a hook that could manipulate the list of field items before the field is built?


texts: Why is access to some of my product displays denied for anonymous users?

texts:
I think I have some database corruption and a number of commerce display nodes have have become access denied for anonymous users. I am not using any access control modules and the problem persists even after allowing anonymous users to bypass content access control. Clearly there is something badly wrong.

I have clear caches etc, to no avail.

What could be causing this and were should I start looking for a fix?

Following the suggestions given in comments, I have tried rebuilding permissions and this does not help.


texts: I have configured Search api module in my Drupal 8 search. This is the first time I am configuring search api. I am using database search and not solr. My problem is stemmer processor is not working properly. I am not getting intended result for keywords due to stemmer processor issue. Stemmer processor is not stemming the words while indexing but is stemming while search query is executed. For example the word 'cars' is stored in the database as 'cars' itself while indexing but when a search query for 'cars' is executed it stem the word to 'car' and I am not getting the result. How can I fix this.


texts:
I am trying to add JavaScript in footer with drupal_add_js(drupal_get_path('theme', 'mytheme') .'/js/libs/jquery-1.7.1.min.js', array('type' => 'file', 'scope' => 'footer'));, but for some reasons, it is not getting loaded.

What is wrong in my code?


texts: How do I add just one extra node to a view? Display OG contents plus OG group node

texts:
I have created an ajax view that displays the contents of a group.  It shows one page at a time, with a nice jquery pageturn effect when you go to the next page.

I now want to insert the actual group node at the start of this view.  I can't put it in header or template files, as then it wont work with the ajax pagination.

I have worked out the SQL I need to get the results I want...

SELECT node.nid AS nid FROM d7_node node
LEFT JOIN d7_og_membership og_membership_node ON node.nid = og_membership_node.etid AND        og_membership_node.entity_type = 'node'
WHERE (( (node.status = '1') AND (og_membership_node.gid =   '42' ) )) OR (node.nid = '294')
ORDER ASC

The SQL my view is currently using is...

SELECT node.nid AS nid FROM d7_node node
LEFT JOIN d7_og_membership og_membership_node ON node.nid = og_membership_node.etid AND        og_membership_node.entity_type = 'node'
WHERE (( (node.status = '1') AND (og_membership_node.gid =   '42' ) ))
ORDER ASC

So basically I just need to tag on  'OR (node.nid = '294')' to the WHERE.

I'm trying to use this custom module

function hook_views_views_query_alter(&$view, &$query) {
if ($view->name == 'flipbook_ii') {
    $nid = $view->args['0'];
    $query->where[] = array(
      'conditions' => array(
        '0' => array(
          'field' => 'node.nid',
          'value' => $nid,
          'operator' => '=',
        ),
      ),
      'type' => 'OR',
    );
  }
}

But that is still setting the WHERE query

WHERE (( (node.status = '1') AND (og_membership_node.gid = '42' ) AND (node.nid = '294') ))

Can anyone explain a way that works?


texts: Only ask for a shipping address if a real product is ordered

texts:
I'm using the Drupal Commerce module with Shipping 7.x-1.0. I created a webshop with both real and virtual products.

My problem is that the shipping address is required even if all the products are virtual (so there is no shipping). How can I make sure that the shipping address is only asked for if the shoppingcart contains real products?


texts: Get path/url/uri of Entity reference field to content in a Twig template?

texts:
I have a Entity reference field which links to internal content/node.

I can get the title with {{ node.field_related_project_internal.entity.label }}

But how can I get the raw path/url/uri of the linked content/node?
The soloutions for a Link Field to not work here:
How to get the valid URL of a Link field from within a Twig template?


texts: How to use a content type form as a block

texts:
I need a page to be half content, half node edit form.
How can I do this? I thought I'd put the content type's form display into a block. Sounds easy enough.
I've been trying contrib and custom modules, but I can't seem to grab the form.
Thought I could get away with something like this.
class EvaluationBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $node = \Drupal::routeMatch()->getParameter('node');
    if ($node instanceof \Drupal\node\NodeInterface) {
      $render_array = EntityFormDisplay::collectRenderDisplay($node, 'project_evaluation_form');
      // error_log($render_array);
      return $render_array;
    }
  }
}


texts:
I am using CK Editor (version:'4.3.3',revision:'7841b02') with Drupal (core: 7.26) via the WYSIWYG module (7.x-2.2). I'm also using Workbench (7.x-1.2) and Workbench Moderation (7.x-1.3), which may or may not be involved.

I have a node that contains a 'rating' widget from a third-party company in the form of Javascript between "script" tags.

When I edit the node and add this code, it works. I can see the widget and it functions.

But when I go to edit the node again, the script code is not visible in the editor. If I cancel the draft creation, it is still there and functions. If I save the draft (without makeing any changes) it's gone from the draft but still there in the published version. If I publish the draft of course it's gone.

I'm also using drush to sync instances and when I sync down from dev (where it's working) to my local instance, it does not work in my local instance.

In the config I have Verify HTML off, because it says it removes 'malicious' tags, which I would guess includes "script". I've looked over the config and can't see anything else that might affect this.

Has anyone else had this issue? And ideas on where to look for clues would be appreciated.

Also looking at adding it via and include in a single-node template, but wondering if this could work directly in the node content.


texts: Is Migrate module supposed to be used for imports too?

texts:
I am in need of an entity import functionality so I started to write my own. But then I started to think if I'm not reinventing the wheel and it occurred to me that maybe Migrate module will be used for this(beside it's main purpose)?

I mean, since all entity fields are objects with their own specifications regarding data they work with, Migrate will probably handle all of this. So am I correct to assume this or should I continue to work on my module? Because right now I started to think about the field objects(FieldDefinition for core fields and FieldInstanceConfig for field API fields) and I would need to write a lot of data handlers for each type of field and data-type it's working with(boolean, text, file/image, float,...) which will be a lot of work.

On the other hand Migrate would probably have all this data-handlers already in place so they could be reused?

By entity import I mean creating data from csv, xls, xml... files.


texts:
After installing, the cart block view doesn't show any content, even when I had put something in the cart.

I found How to hide an empty shopping cart with drupal commerce, which  says the correct value would be Current user's cart order ID, but this is not available in my installation.

I'm not sure if this is a bug, things changed for Drupal Commerce 2, or I configured something wrong.

I'm using Drupal 8.9.0 and Drupal Commerce 2.1.9.


texts:
In Drupal 7 Commerce, I am running into an issue with this workflow:

Add item to cart
Apply qualifying coupon. Correct discount is taken off item
Add new item to cart with qualifying discount.
Old discount in order shown UNTIL you reload the page 2 times.

Basically I am adding a coupon to the cart at the /checkout/% page

It seems like the block or view is being cached.

What is the best means to uncache the block?

I have tried using:

cache_clear_all('shopping_cart_summary_new', 'cache_views_data', TRUE);

as well as:

$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
commerce_coupon_commerce_cart_order_refresh($order_wrapper);


texts:
I have exported the nodes from Drupal 7 using the node_export module, and I want to import those nodes in my new Drupal 8 site.

Is there any way to achieve this?

The exported nodes look like the following.

array(
  (object) array(
      'vid' => '311713',
      'uid' => '84015',
      'title' => 'How to Create Pro-Level Videos on iPhone Featuring the Storyographist',
      'log' => 'Edited by Donna Cleveland.',
      'status' => '1',
      'comment' => '0',
      'promote' => '1',
      'sticky' => '0',
      'vuuid' => '40b3f8ec-95ba-4699-8192-8dcc731039b4',
      'ds_switch' => '',
      'nid' => '272977',
      'type' => 'article',
      'language' => 'und',
      'created' => '1501684200',
      'changed' => '1516617288',
      'tnid' => '0',
      'translate' => '0',
      'uuid' => 'f85d16e8-484a-4e03-8e7b-c1576f857ffc',
      'revision_timestamp' => '1516617288',
      'revision_uid' => '1',
      'body' => array(
        'und' => array(
          array(
            'value' =>


texts: Breadcrumbs not showing properly translated

texts:
I am using a multilingual site with an Arabic and English versions. Before it was showing properly, but after the menu has been translated to Arabic, the breadcrumbs are showing only in Arabic.

How can I get the breadcrumbs in English too?


texts: Is there an automated way to create another multisite inside of an existing multisite Drupal install?

texts:
I have an existing instance of D7 in a multisite configuration on RedHat.

Can I use drush si to create a new database and /sites/ instance -- without altering any existing subsite? Is there a way to automate this?

I'm envious of Wordpress Networks' ability to spawn up a new site inside the admin console.

In my current process, I create a database on local systems.

mysql> create database nominations;
Query OK, 1 row affected (0.01 sec)

mysql> grant usage on nominations.* to nomnom@localhost identified by 'Sup3rS3cr3tP455w04d';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on nominations.* to nomnom@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

Sudo and edit the alias.conf file

$ sudo su
# vim /etc/httpd/conf.d/alias.conf

In that file add the alias. The current file reads as such. The idea is to point all aliases to the drupal root. Let drupal handle routing based on folder entries inside its /sites/ folder.

 Alias /nomination /var/www/html

Once this file is saved. Restart the server.

# service httpd restart

# exit

Now the database is created and apache has a new alias. Create a new folder inside of /sites/ in the fashion drupal routing will recognize (server.name.path). Create a symlink to make drush maintenance easier.

$ mkdir nomination
$ cp default/default.settings.php nomination/
$ cd nomination
$ mv default.settings.php settings.php

At this point I go to server.com/nomnination and run the typical install process. After and back on the command line, coordinate a bit of module goodness:

$ drush en -y coffee module_filter jquery_update bootstrap

$ drush dis -y overlay


texts: Wyswig editor not showing to authors in Full HTML mode for Authors

texts:
I am using wyswig with tinymce 3.5 for my drupal site.
The editor is not working for Authors in FULL HTML mode.it is not showing any action after changing it to plain text or full html.

I have rebuilded permissions also tried Full Html Text format (and wysiwyg) show only for administrator role this solution, cleared cache but its not showing for the authors.
Not able to resolve whether it is permission issue or js.

Also this issue is came after i am using book access module.
Check image for reference.


texts: How to remove a comment based on it's field value?

texts:
I have a multilingual site, Comments in this site include a language field (field_language), so users who send comment to nodes must specify in what language they are sending the comment. On loading a node I want to display only the comments which their field_language is equal to the current website language. I tried this code based on the following result

function THEME_preprocess_node(&$variables) {
    global $language;
    foreach ($variables['content']['comments']['comments'] as $comment)
        if($comment['field_language']['#items'][0]['value'] != $language->language)
            unset($comment);
}

The $comment['field_language']['#items'][0]['value'] prints the comment field_language so I'm sure this is a correct syntax and the condition holds for a few comments but unset($comment); doesn't unset the comment.

I tried the following code

unset($variables['content']['comments']['comments'][71]);

and it successfully worked and removed the comment. The ID inside the [] is stored in the $comment['#entity_view_mode']['id'], I can easily use this ID to remove the comment but I think there must a more straightforward solution.

Is there any other solution like using hook_comment_load or anything else?


texts: Allow content builder to 'disable' a content type form

texts:
I have a site that allows users to submit a 3d print job to a lab.

The role of the site builder is: technician
The content type in question is: print job

Users can submit a print job (i.e. create a print job node).

What I'd like is to enable the technician to be able to prevent/disable/stop the user from being able to use the form at node/add/print-job when they want to prevent new print jobs from coming in (i.e. too busy at the lab).

I can use the Content Access module, but I'm hoping for something a bit less complex for the technician and that doesn't result in a 403.

I'm hoping that there is a way to do this with rules or workflow. Preferably one button/checkbox with a confirmation. Disabling the content type form will display a message written by the technician on the form path.

Any help would be greatly appreciated.


texts: Need to create a report in Drupal 7 that counts Articles by Author for date range

texts:
I am trying to create a simple display that lists all my authors who provided content to my site during a date range (i.e. Jan 1 thru Dec 31) with a count of the number of articles published, as follows:

Joe Smith, 120
Bob Jones, 87
Tom Kelly, 3

While the output is fairly simple, creating it is not (at least for me). I would think this would be a fairly common reporting requirement, so I'm hoping someone has already created it somewhere. If so, I'd love to use it on my site.


texts: Validate CCK field to not allow links/URLs

texts:
I want to allow users to input free text, but don't want them including any links or references to URLs. I know how to set up a filter on the CCK field so that 'a' tags cannot be included, but this will not stop the user typing www.google.com etc.

I have tried searching for modules to achieve this, but have not managed to find any. Does anyone know of a module to filter CCK fields to validate for 'www', '.com' etc, or alternatively one for custom CCK validation?

If there aren't any modules I think I would have to follow these instructions to build a custom CCK Validation module. I would appreciate advice on whether this would be the most efficient approach or if this would be reinventing the wheel?


texts: Error on manual scoring for quizfileupload module

texts:
I'm using d7 with quiz module, and to enrich question type I installed quizfileupload, as described on quizfileupload features said that we can score manually for the answered question. But when I try to fill score manually and Save Score, its become error like this;
Warning: Division by zero in quizfileupload_score_an_answer() (baris 130 dari /var/www/edon.smkn14samarinda.sch.id/public_html/sites/all/modules/quizfileupload/quizfileupload.module).
PDOException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect double value: 'INF' for column 'score' at row 1: UPDATE {quiz_fileupload_user_answers} SET score=:db_update_placeholder_0, is_evaluated=:db_update_placeholder_1, answer_feedback=:db_update_placeholder_2, answer_feedback_format=:db_update_placeholder_3 WHERE (result_answer_id = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => INF [:db_update_placeholder_1] => 1 [:db_update_placeholder_2] => [:db_update_placeholder_3] => filtered_html [:db_condition_placeholder_0] => 20756 ) dalam quizfileupload_score_an_answer() (baris 136 dari /var/www/edon.smkn14samarinda.sch.id/public_html/sites/all/modules/quizfileupload/quizfileupload.module)

any body could help me how to fix these?, thanks
take a look the screenshot here


texts: How to pass multiple objects to hook_view()?

texts:
I want my hook_view($node) to display not only the $node, but other fancy stuff too - like a table on the bottom using a while-statement. How can I do this?

I am only able to pass one object to hook_view() so I am limited to one object for output? For example:

function Mymodule_load($node) {
  $sql = "SELECT colors FROM ctable,node WHERE ctable.nid=node.nid";
  //returns lots of color (e.g. blue, red, green, pink)
  $result = db_query($sql);
  //here's where I am stuck!
  while($row = db_fetch_object($result)) {
    return $row;  //oh noes! $row keeps getting overwritten
                  //and all my colors aren't being passed to hook_view
  }
}

function Mymodule_view($node,$teaser=false,$page=false) {
  node_prepare($node,$teaser);
  $node->content['colors'] = array(
    // only can display ONE color.
    '#value' => $node->colors
  )
  return $node;
}

The above code returns only ONE color whereas I want ALL my colors to be passed to hook_view().

THE SOLUTION:

while($row = db_fetch_object($result)) {
  $colors[] = $row->colors;
}
$node->colors = $colors;
return $node;


texts: I want to run checking code on Ubercart product attribute

texts:
I want to run checking code on a Ubercart product field attribute before allowed to proceed with the checkout. The code could run right below or in conjunction with the "required" - not empty - check.
But looking at the attributes module I do not see where it runs from. Trying to use the Ubercart Field Attributes module to do this on the fly with Ajax and JQuery my code is running without syntax error but also the form_set_error is not working as I am trying to use an Ajax callback.
No message comes up on the product form.
Both the attributes and field attributes work to throw the errors if the fields are empty as should be, but if I knew where the "required" error could originate I could piggyback my code there for this singular product class item
The Ubercart forums pages seem to be down
Can anyone point me to where that "required" checkbox code is in the attributes system ??


texts: What do I use as URL path in a template file?

texts:
I've created a custom theme override for views-view-fields.html.twig to views-view-fields--about-us.html.twig which is a listing of members on a site and the code I've used is as follows:

{{ fields.field_photo.content }}

{{ fields.title.content }}

{{ fields.field_job_title.content }}

  {{ 'Learn More'|t }}

However, when I view the page, the only thing not working is the link to the content. The "Learn More" is supposed to go to each persons full bio, but instead, all that it links to is the current page/view.

Is {{ path }} not the correct code to use as the URL? I've tried numerous other solutions that I thought I found on this site for it but it either doesn't work or breaks my site.

EDIT 1:

When I try No Sssweat's answer from below, which I had tried before, I get the following issues:

Extra bit of code is printed below the button like the image below:

And, this is what the code looks like when you hover over the link:


texts: Drush do not autocomplete files and directory names

texts:
I'm using Linux Mint 18 XFCE. Drush perfectly works, except for this annoying issue that it does not let me autocomplete file or directory names in a drush command.

Lets say that I want to sync my production files folder to my local files folder, so the command is:

drush rsync @site.prod:sites/default/files sites/default/files

When I'm typing the following parts I can pres tab and they are autocompleted:

drush
rsync
@site.prod

But when I'm typing sites/default/files it is not autocompleted, so I have to manually write the whole text, twice in this example.

It should be possible to do it in Linux because that's the normal behavior in Mac.

Just in case, here is the drush status result:

 Drupal version                  :  7.50
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database hostname               :  localhost
 Database username               :  icolma
 Database name                   :  icolma
 Database                        :  Connected
 Drupal bootstrap                :  Successful
 Drupal user                     :  Anónimo
 Default theme                   :  cornelius
 Administration theme            :  seven
 PHP configuration               :  /etc/php/7.0/cli/php.ini
 Drush version                   :  5.10.0
 Drush configuration             :
 Drush alias files               :  /home/juankvillegas/.drush/aliases.drushrc.php
 Drupal root                     :  /home/juankvillegas/git-repositories/icolma
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Private file directory path     :  sites/default/files/private
 Temporary file directory path   :  /tmp


texts: Notifications for anonymous users on nodes

texts:
I am looking for a module or some kind of workaround e.g. involving Rules, that will allow anonymous users to subscribe to new comments on nodes they have created. My user scenario is as follows:

An anonymous user wants to post a new forum topic
She clicks on the “Add new forum topic” button
On the URL node/add/forumtopic she is presented by the usual form
On the form there is an email field with a check box underneath with the label “I would like to receive an email when comments are posted to my thread”
She types in her email and marks the checkbox - yes, she would like to have email notifications
She submits the form and when a comment is posted in her thread, she
gets a notification email with a link to the comment and a link that
allows her to unsubscribe from the thread.

I have looked at this nice writeup on groups.drupal.org where different notification modules are compared, but none seems to be offering the functionality I am looking for.

I have installed Comment Notify that offers the desired functionality - but only on comments, not on nodes.

I have tried installing Watcher, but it is early in development and still seems pretty buggy.

This seems to me like a very common scenario - what would be the recommended way of implementing this feature? Any help is very appreciated.


texts: How can I place brackets around a field in a view?

texts:
I'd like to place a field's value in a view between brackets. Let's say that there are 2 fields 'Name' and 'Country'. How can I display these as Name (Country) in a view? I know how to inline the fields, but I have no idea how to place the brackets around the second field.

How can I do this?


texts: How to create a Views custom exposed filter with predefined range of date values (today, next 15 days, next month)

texts:
I have a content type "event" with start_date and end_date (fields by date module).

A View lists this events and I need a custom exposed filter with a SELECT with 3 options:

-All-
Today
In the next 15 day
Next month

With the following comparison:

Today
(start_date <= NOW && end_date >= NOW)

In the next 15 days
(start_date <= NOW+15day && end_date >= NOW)

Next month
(start_date <= $next_month_last_day && end_date >= $next_month_first_day)

What is the best way to go to create the above custom filter?

I have to create a Views custom filter handler that does everything, in this case I can generate html select directly in the handler and expose it by default without pass trough views interface to check "expose this.."?
Or is best to FIRST create the above separate filters trough Views interface and then ALTER the form to combine all filters in a unique SELECT and then ALTER the query?

I've already take a look to Easy date selector for Views Exposed Date Filter but grouped filters are not a solution for me because I have to manage 2 dates, and not a single one (post date) as in that example.

I also look at How to customize exposed filter for date field? but I'm not sure if using templates like suggested is a good solution for me or there is a more elegant way to reach the goal.

Also found this module: https://www.drupal.org/project/views_between_dates_filter but doesn't provide the select I need.

Thank you very much for any help.


texts:
In my Drupal7, I have same piece of code in tpl.php files for two different nodes. My tpl.php files are following:

page--node--9.tpl.php
page--node--11.tpl.php

Since code is same for both pages, it is possible to create a tpl.php file for both nodes? I mean something like

page--node--9and11.tpl.php


texts:
I'm hoping someone else has run into this and has a solution:

I have the CKEditor module (v. 7.x-1.13) installed using ckeditor.js version 4.01 (due to compatibility with Media module). The problem I run into is after I've added content into a field and publish it. After I return to edit the content, CKEditor has added all kinds of "stuff", a ton of inline CSS inside of a paragraph and span, and the letters "BESs" See sample below. Hoping someone can make some sense of this and offer a solution.

BESsBESsBESs

Thanks in advance.


texts:
I am having an issue that I don't know how to fix. The title of my website/pages are displayed twice and I can't figure out why. I configured my title at Configuration > basic site settings > name of website

Can anyone help me find what is causing this?
Any help is greatly appreciated.


texts:
I have some menus that are managed in the standard Menus module (Drupal 6, BTW). I want to add a checkbox when I'm editing a menu item to control the display of a "New" banner via CSS (by adding a class for items that have the checkbox turned on).

I can get my checkbox into the form like so:

function mymodule_form_menu_edit_item_alter(&$form, &$form_state) {
  $form['menu']['newbanner'] = array(
    '#title' => 'New banner',
    '#type' => 'checkboxes',
    '#description' => "Add a 'New' banner to this item?",
    '#options' => array( 'new_banner' => t("This item is new") )
    );
}

But I'm not quite sure how to actually save and use the state of my checkbox. I'm guessing I want to start by creating a mymodule_form_menu_edit_item_submit() function? But how do I get my info in/out of the database and use it to add a class to the generated menu on the front-end?


texts: Do I use Content Type creator to create new modules?

texts:
I read the Drupal 7 tutorial on creating modules.  I did fine from code and the example.  Got the basics.

Then I read about creating a new content type with fields.  I have ubercart and it had a product type, so I am kind of lost.  Other modules have their own content types with fields.

Say I wanted to track an inventory at the most basic level.  I want to know the item number and description, and on hand amount.  Nothing fancy.

Do I create a table to hold that data in the drupal database?  somewhere else?  Do I create a field with the content type additions?

Not sure what do to.  Thanks for help.


texts: Custom theme function with drupal render

texts:
I'm trying to make a custom module based on menu module to render a sitemap.

I want to use a custom theme function for rendering it but for unknown reasons my variables are not passed to the theme function. Here is my code (simplified so we get what matter) :

function custom_module_theme() {
  return array(
    'custom_module_link' => array(
      'variables' => array(
       'attributes' => NULL,
       'title' => NULL,
       'href' => NULL,
       'below' => NULL,
       'original_link' => NULL,
      ),
    ),
  );
}

function theme_custom_module_link(array $variables) {
 $element = $variables;
 $output = ...;
 ...
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . "</li>\n";
}

function _custom_module_tree_output($tree) {
    ...
    ...
    // Allow menu-specific theme overrides.
    $element['#theme'] = 'custom_module_link';
    $element['#attributes']['class'] = $class;
    $element['#title'] = $data['link']['link_title'];
    $element['#href'] = $data['link']['link_path'];
    $element['#original_link'] = $data['link'];
  }
 return $element;
}

function custom_module_page() {
  $tree = ...
  $output = _custom_module_tree_output($tree);

  return drupal_render($output);
}

This code return a error page with the following : TypeError: Argument 1 passed to drupal_attributes() must be of the type array, null given ...

I don't understand why drupal_render doesn't iterate over the $element['#theme'] call to fetch variables as described in the documentation. What I'm missing ?

  From the doc : Basically, the '#theme' = 'function_name' calls
  theme_function_name(), and other array values of the form '#var_name'
  = $value in the same array are passed as arguments to the theme function

If I dpm $variables in my theme_custom_module_link function, variables are set as NULL as in my hook_theme ...


texts: Custom .tpl.php file cannot be found in Templates folder

texts:
I've created my own theme with a child theme and a custom template file so in the parent's template.php file:

/**
 * Implements hook_theme().
 */
function mytheme_theme($existing, $type, $theme, $path) {

  global $theme; //need this to set $theme as the child theme

  $path = is_file( getcwd() .'/'. drupal_get_path('theme', $theme) . '/mytemplate.tpl.php' ) ? $path_to_child : $path;

  return array(
    'my_template' => array(
     'template' => 'mytemplate',
     'render element' => 'my_template',
     'path' => $path,
    ),
  );
}

It works but I feel this is clumsy. Also it doesn't find the new template if I put it in the templates folder. You can see that I've had to do an is_file() to look for the mytemplate.tpl.php file in the child theme.

I want my search order to be as follows:

themes/child_theme/templates/mytemplate.tpl.php
themes/child_theme/mytemplate.tpl.php
themes/parent_theme/templates/mytemplate.tpl.php
themes/parent_theme/mytemplate.tpl.php

This already works with page.tpl.php so clearly I'm missing something. Drupal can find page.tpl.php pretty much anywhere I put it. How do I make this work with my own custom template?


texts: Trying to add a column of Mysql timestamp through hook_update

texts:
I was trying to add the column of MYSQL Timestamp to the Database Table, the Query seems to be working correctly in mysql console.But when I execute the same in db_query() the following error is thrown.

  Failed: PDOException: SQLSTATE[42000]: Syntax error or access
  violation: 1067 Invalid default value for 'last_update_date': ALTER
  TABLE stores ADD last_update_date TIMESTAMP NOT NULL DEFAULT
  '0000-00-00 00:00:00';; Array ( ) in store_update_7100() (line 254 of
  /var/www/slocamo_app/sites/all/modules/store/store.install).

Is the Query.

ALTER TABLE  `stores` ADD  `last_update_date` TIMESTAMP NOT NULL DEFAULT  '0000-00-00 00:00:00');


texts: How can I sync just roles/permission config across multi-site instances?

texts:
On a Drupal 8 multi site, we need to have unified ROLES/permission config in all sites.
Then we'll assign these roles to users via interface or Drush.
How could I export / import? Or even better sync these via Drush or other means?


texts: Displaying an image in a programmatically created block (Drupal 7)

texts:
I have created a custom block module that will display the children of a taxonomy term and if a term has no children it will display the nodes of that taxonomy in a table.  The node type that they are showing were created using CCK and contain an image field and I would like to display the contents of the image field in this table.

So far I have only figured out how to be able to display the name of the node with a link and the time/date the node was last updated, but have not been able to figure out how an image might also be displayed.  Could anyone offer advice about how to do this or point me to some documentation on the topic?  Everything I found suggested that I should use CCK but for this particular problem I think I need to create my block programmatically.

EDIT:

function children_view_block_view($delta = '') {

  $block = array();
  switch ($delta) {
    case 'children':
      $path = explode('/', drupal_get_path_alias($_GET['q']));

      $tid = array_pop($path);

      $term = taxonomy_term_load($tid);

      // Set up the table rows and headers array
      $rows = array();

      $children = taxonomy_get_children($term->tid, $term->vid);

      $title = "Child Name";

      $header = array($title, 'Updated');
      // Add a new row for each child term
      foreach ($children as $child) {
        $rows[] = array(
          l($child->name, "taxonomy/term/$child->tid"),
          $child->vid
        );
      }

      // Set up the params for the theme_table call
      $table = array('rows' => $rows, 'header' => $header, 'empty' => 'No terms found');

      //$block['subject'] = t('');
      $block['content'] = theme('table', $table);

    break;
  }

  return $block;
}


texts: Ajax rebuild form is calling all the code from my form function

texts:
I have a form which when I click on on radio rebuild an element of the same form. Somehow when the ajax is called it's recalling everything from my form function.
How can I force him to reload only a part of the code, in that case the $form['container']['network'] and not the whole $form.

There must be some strange behavior during the callback, could it be reloading the whole form and get the part it wants then replace the old by the new?

$form['container']['ZoneId']['#ajax'] = array(
    'callback' => 'change_countries',
    'wrapper' => 'networks-list',
    'method' => 'replace',
    'effect' => 'fade',
);

$form['container']['network'] = array(
    '#type' => 'fieldset',
    '#prefix' => t('
'),
    '#suffix' => '
',
);

function change_countries($form, $form_state) {
    $form_state['rebuild'] = TRUE;
    return $form['container']['network'];
}


texts: How do I free the memory used from node_load()?

texts:
I am using code similar to the following one.

for ($i = 0; $i < 1000000; $i++) {
   $nid = get_node_id($i);
   $node = node_load($nid);
   $data = [
     $node->field_1,
     $node->field_3,
     ...
   ];
   save_to_database($data);

   echo round(memory_get_usage() / 1024 / 1024, 2) . ' MB'. PHP_EOL;
}

Every time a loop is completed, the used memory is increased. For example, after the first loop, the used memory is 110 MB, and after the third loop is 230 MB.

How do I avoid the used memory keep increasing?


texts: How to render a field in a Views' PHP code field?

texts:
in a view, I would like to render the field $data->field_field_video[0] in a PHP code field.
It seems that it contains all the information needed to be formatted but how can I output in the HTML ?

 [rendered] => Array
    (
     [0] => Array (
                [#theme] => image_style
                [#path] => public://video_embed_field_thumbnails/vimeo/58413545.jpg
                [#style_name] => square_thumbnail-100 [#children] =>  [#printed] => 1 )
      ...

Thanks


texts: views to display list and related content on same page

texts:
I have created a veiws block which displays all the taxonomy terms of a particular type.
This block is in left sidebar . Now what I want is ,"when i click on any of the term all nodes related to it should be shown on the same page in the content area " ( what normally happens is it shows all nodes listing correctly but not on the content area of same page but takes me to next page) . Can someone please help me with this and any good tutorials for views


texts:
I am trying to update drupal using drush from Version 7.36 to 7.38 with >drush up drupal
the process finishes in 2-3 seconds stating update has successfully finished and a backup has been created.

As a result, drupal is still on 7.36 - no updates have been made.

but there is also an error stating  no php.ini found - and the created backup directory (where drush is looking for the php.ini) is empty:

(uiserver):xxxxx:~/kochlounge > drush up drupal
Update information last refreshed: Sa, 07/11/2015 - 16:07
 Name    Installed Version  Proposed version  Message
 Drupal  7.36               7.38              SECURITY UPDATE available

///some update-warnings snipped for readability

Do you really want to continue? (y/n): y

Source directory                      HERE COMES THE ERROR  [error]
/htdocs/drush-backups/db570947934/20150712144116/drupal/profiles/php.ini
is not readable or does not exist.

Project drupal was updated successfully. Installed version is now 7.38.
Backups were saved into the directory                                [ok]
/htdocs/drush-backups/db570947934/20150712144116/drupal.
Backups were restored successfully.

my drush status (snipped):

 PHP executable                  :  /usr/bin/php5.5-cli
 PHP configuration               :  /usr/lib/php5.5/php.ini /usr/bin/php5.5-cli
 PHP OS                          :  Linux
 Drush script                    :  /htdocs/.composer/vendor/drush/drush/drush.php
 Drush version                   :  7.0-dev

my .profile:

alias php="/usr/local/bin/php5.5"
alias php-cli="/usr/bin/php5.5-cli"
alias composer="php-cli ~/composer.phar"

export DRUSH_PHP="/usr/bin/php5.5-cli"
export DRUSH_INI="/usr/bin/php5.5-cli"
alias drush="~/.composer/vendor/bin/drush"

Has anyone got a clue as to why the update is not working, what may be wrong with the php.ini... ?
when trying to do updates for modules from drupal-backend, the site throws an error and goes in maintainance-mode.

Thank you!


texts: Is there a way to get the max size of a varchar textfield?

texts:
I have an entity with a textfield created using the core Fields feature that looks like this when I inspect the type of the field table in the database varchar(40).

I want to be able to determine max size of the string that can go into this field programmatically.  I.e. I want do know if there is a function I can call with suitable parameters, and it would return 40.

A Drupal API function would be the preferred answer, but a could live with a PHP function if this is not available in the Drupal API.

I was reminded in a comment (now deleted) that I previously had answered a very similar question.

However, that answer relies on the field in question being part of a schema.

This new question is about fields that has been created using the core Fields feature.  (I.e. using drupal_get_schema() will not fly.


texts: How to display taxonomy term reference field as a rendered entity?

texts:
I have taxonomy term reference field which are displayed as checkbox.
Each taxonomy term has two fields 1. description and other 2. price
I want the description and price field to be displayed alongside the title in field(term refrence).
How can I achieve ut?


texts: How do I update a field value in hook_entity_insert()?

texts:
I want to update an field in hook_entity_insert(). The following code doesn't work.

$entity->field_range->value = 'test';
$entity->save();

I also tried loading from node object, but still it doesn't work.

$node = \Drupal::entityManager()->getStorage('node')->load($entity->id());
$node->set('field_range', 'test');
$node->save();

After inserting the node only I will get the text "test" dynamically and it won't work in hook_entity_presave().

Any help on how to update an field on hook_entity_insert will be nice. Thanks in advance.


texts:
Using Drupal 8, we've built a webform using the Webform module. This form uses the checkboxes element (6 in total) of which we've set to required which to my understanding means at least one checkbox needs to be checked in order for it to pass validation.

During testing, we're noticing that the validation message is not being displayed when the checkboxes are left unchecked.

Is this a bug with the Webform module or is it an ID10T error on my part?


texts: I am using Ckeditor in drupal 7.26. I placed HTML Content with link tag in the source of Ckeditor. It removes link tag. I want to send my css file through that html content. How can I add it into the editor.


texts: Is there a way to create an openlayers map that adjusts size with an adaptive layout?

texts:
I'm building a site that will incorporate data mapped from users quite extensively, and I'd like the front page to mostly be just a map showing various relevant data. I'm also trying to build the site in a way that is adapted to mobile use.

I have an openlayers map constructed, it displays data, mostly behaves as I'd like, and I have it on the front page. That's all good. What I'd like to do is have the map become narrower in order to respond to display size. I'm currently using the omega them and I can get other elements to respond, but not the map.

Is there a way to clip the map? Can I bring in different map displays for different screens? Is this in any way possible?

I'm nearly completely new to all of this, learning css/js/php on the fly as I run into issues. I feel like this might be something js can help with (I found this link, for instance: http://pastebin.com/GumWwSMB), but I'm not sure if it's appropriate/best nor where/how to implement it.

Thanks for your help.


texts: How to validate links before moving to different location

texts:
This would be most simple functional question in Drupal 7.
Now below mentioned things are mandatory to do and cant change the functionality.
1) I have created a custom block in module.
2) I have included form like below:-

function usercontent_block_view($delta='')
{

   $block = array();
   switch($delta)
   {
     case 'user_front_page' :
       $block['content'] = drupal_get_form('genre_all_login');
     break;
   }
   return $block;
}

3) Now I have some other content in block but which put me in trouble is shown below:-

function genre_all_login($form) {
  $form['new_user'] = array(
  '#type' => 'item',
  '#markup' => l('Add New User','http://www.google.com'),
    );
    return $form;
  }

4) So it includes a link which will move me to Google once clicked.
5) Now I want to validate certain content inside the block before user navigates to Google.So if the condition doesn't match then I will stop the user by showing an error message and hence user cannot traverse to Google.

Please tell me if it is possible or should I use different technique to handle this scenario.


texts: How can I display node fields contextually in a block with terms from two separate vocabularies based on node ID?

texts:
I've got a content type that has a file field and as part of custom content type that we use to display document links. As part of that content type I have taxonomy 1 "site section" that I'm using to categorize the documents from that field so that they are displayed in specific places on the site. That part is easy.

However, the client just requested an additional level of filtering because they want more fine-grain control over what documents are displayed on what page/node. So far, the best I can figure out is that this level of filtering should be based on a new taxonomy 2 "site sub-section" that I've created that will correspond to specific nodes in the site where the documents need to be displayed.

I'm trying to figure out how I can set my contextual filter so that it will display the resulting file field document results based both on taxonomy 1, and new taxonomy 2, based on the node ID, but I can't figure out the logic to make this happen.

I'm open to other options regarding contextual filters but the node ID is the only one I can think of that would give the specificity necessary to control how and where they're displayed. But, I also cannot figure out to to declare that "when the node ID is [some node id], display nodes with taxonomy terms y and z, and only those nodes."

Is there a way to do this within Views or should I just look to create a custom PHP piece to do this?


texts:
I'm helping to convert a Drupal 7 module across to Drupal 8 and getting an error on the install.

  Fatal error: Call to undefined function field_create_instance()

I've seen in the Drupal 7 database that a table is created for field_first_name as field_data_field_first_name. Does this still happen in Drupal 8?

I resolved the fact that field_info_field() and field_info_instance() are now deprecated in Drupal 8 and have updated accordingly with \Drupal::entityManager()->getFieldMap() and FieldConfig::loadByName() respectively, but I can't find anything to suggest what to use instead of field_create_instance(); can someone suggest how I get around this?

My code is this.

/**
 * Implements hook_install().
 *
 * Adds custom fields used by module.
 */
function indicia_api_install() {
  $fields = array(
    'field_indicia_user_id' => (object) array(
      'type' => 'number_integer',
      'title' => 'User ID for this key on the warehouse',
      'name' => 'field_indicia_user_id',
    ),
  );

  foreach ($fields as $fielddef) {
    if (!\Drupal::entityManager()->getFieldMap($fielddef->name)) {
      \Drupal::logger('ima', 'Adding field: ' . $fielddef->name);
      $field = array(
        'field_name' => $fielddef->name,
        'type' => $fielddef->type,
      );
      if (isset($fielddef->required)) {
        $field['settings'] = array('required' => TRUE);
      }
      field_create_field($field);
    }
    else {
      \Drupal::logger('ima', 'Field already exists: ' . $fielddef->name);
    }
    if (!FieldConfig::loadByName('user', $fielddef->name, 'user')) {
      \Drupal::logger('ima', 'Adding instance: ' . $fielddef->name);
      $instance = array(
        'field_name' => $fielddef->name,
        'entity_type' => 'user',
        'label' => $fielddef->title,
        'bundle' => 'user',
        'required' => isset($fielddef->required) && $fielddef->required,
      );
      field_create_instance($instance);
    }
    else {
      \Drupal::logger('ima', 'Instance already exists: ' . $fielddef->name);
    }
  }
}


texts: node_view not picking up view mode, always printing full

texts:
I have the following code:

$form['commerce_fieldgroup_pane__group_event_information']['field_event_information']['und'][0]['#markup'] = drupal_render(node_view($eventInfo['event']), 'teaser');

and for some reason, its printing out the node fine, but not printing the correct view mode, its always using full.


texts: How do I create a taxonomy term blacklist?

texts:
I have an "official" vocabulary and a "user-submitted" vocabulary. Content can be tagged from either list, and new user-created terms go into the user-submitted vocabulary.

Periodically, I will merge / rename the user-submitted tags to conform to a standard style, and then move them to the "official" vocabulary. This works well, except when users add a term that I later merge or remove - someone else is then free to add it again later.

So, how can I create a "blacklist" of terms that are disallowed for one or more vocabularies? Ideally, if a user tried to add the term as a free-tag, they would get an error when the form is submitted.

I'm using the following modules, if it makes a difference:

Taxonomy
Content Taxonomy
Taxonomy Formatter
Taxonomy Manager


texts: howto use tokens as "views filter criteria"

texts:
I want make a photo gallery with Drupal and i want show photos uploaded by user in user's page.
I tried add token [node:author:uid] to Content: Author uid as filter criteria, but that shows an error:

Unable to find user: [node:author:uid]

how to add a token to views filter criteria?
thanks :)


texts: How can I show menu according their role?

texts:
I have three roles Business Manager, General Manager and Handler.

How can I show only specific menu according their role?


texts: Attach file to post using C# RestSharp and Drupal Services

texts:
I'm writing a C# app that posts to Drupal using Rest calls to the Services module, I can connect and create new nodes easily but I cannot figure out how to attach files to the nodes.
Using the RestSharp library for C#, this is the code:

var request = new RestRequest("...node/12/attach_file.json", Method.POST);
request.RequestFormat = RestSharp.DataFormat.Json;
request.AddCookie(my_session_name, my_sessid);
request.AddHeader("X-CSRF-Token", restResponse.Data.token);
request.AddParameter("field_name", "field_done");
request.AddFile("file", @"C:\pathtomyfile.png");
var response = client.Execute(request);

No errors are returned, status is 200 but the response is empty and nothing is uploaded in Drupal! And by the way the node date looks like modified, so something worked...!

The AddFile method of RestSharp is multipart and so the attach_file of Drupal:

  Upload and attach file(s) to a node. POST multipart/form-data to node/123/attach_file

Any help?


texts: Adding column in Views for completed submission plus several days

texts:
A have a table column using Views from Webform submission. The variable of this column is submission date [completed].

I need to create another column showing another date [completed] + 7 days.

I tried Global: Math expression
[completed]+7
but it does show the correct date but another value.

How can I display [completed]+7 in another column.


texts: How do the $node modifications in hook_node_presave persist?

texts: I was looking at hook_node_presave() and I tested it out and it works as described. The thing I'm puzzled about is that it doesn't take the $node parameter by reference, nor does it return anything from the function, however when I modify $node in this hook, the changes get saved. I'm really confused. Can anyone shed some light and make sense of this? How do I implement something like this?


texts: IE8 is detecting the pages as mobile media

texts: I am trying to workout why http://www.tradecarsspain.com/ is loading as a mobile page when viewed in IE8 ...


texts:
I have a custom profile form (part of a multi-step registration process) that requires a modal to be displayed once submitted. I am not clear on what the process is for this to happen, and the documentation i've seen isn't clear.

What I have tried (as seen below) is adding the submit action via a $form['#action'] which only returns the JS Object for the modal. Clearly, this isn't working. What should I do to render this modal when the form submits, while assuring the validation and submit calls fire?

The actual Ctools Modal logic is in its own modal, of which it generates on a hook_menu() call to the correct route.

function example_profile_update_form($form, $form_state) {
  $form = array();

  $form['item'] = array(
    "#type" => 'textfield',
  );

  $form['#validate'][] = "example_profile_update_validate";
  $form['#action'] = url("modal/updated/nojs"); //Implemented as a hook_menu() call in its own module
  $form['#submit'][] = "example_profile_update_submit";

  return $form;
}


texts: How to build Taxonomy Menu with Parents and terms based on node?

texts:
After prowling here and Google for a couple of weeks, and not finding the answer, I submit.

I need help assembling a Views-made block, in Drupal 7, that will display links to the pages of each term marked in the content node. I also need it to have a structure of:

Parent Term

Term Link
Term Link

Another Parent Term

Term Link
Term Link

So far, I cannot get the block to display any results, until I remove the Contextual Filters (that I read I'd need.) Does anyone have any guidance? I've installed/uninstalled, made/deleted more Views, Blocks, and Modules than I'd prefer to. I need for this one menu to take shape, before I can move ahead with development.


texts: What is the difference between base tables and data tables for content entities?

texts:
Recently, Views was updated to use data tables (the data_table annotation on @ContentEntityType) by default. See the change record at https://www.drupal.org/node/2433153.

This caught me out since I had both defined on my entity. I hadn't thought much about it, and I don't even know which example got me to do that. I think I may have based mine off \Drupal\comment\Entity\Comment.

Anyway, what's the difference in terms of when they get used? It seems that, despite having defined data_table, all my data was being saved in the base_table anyway, and this caused Views not to work until I removed the data_table property from my @ContentEntityType definition altogether.

It seems my fields ought to be using data_table. What did I do wrong in my entity? I'm porting a module and thus using 8.0.0-beta9.


texts: Stop displaying errors in production server in Drupal 7

texts:
How to stop Drupal from showing unnecessary errors?

I'm deploying my Drupal 7 site to production server, and I want to stop displaying general purpose errors.

EDIT:

I found something about showing errors in this link:

<?php
    error_reporting(-1);
    $conf['error_level'] = 2;
    ini_set('display_errors', TRUE);
    ini_set('display_startup_errors', TRUE);
?>

Can someone explain what will be the appropriate value for $conf['error_level'] to stop displaying errors?


texts:
I rarely ask questions on SE but now the teacher has become the student because this is driving me mad. I am doing a simple batch through an update hook and publishing some unpublished nodes. I am aware I could do this with a flat query, but I am preferring to use the batch system.

For whatever reason it arbitrarily stops at 50% no matter what I do. I have tried modifying the nodes per pass, etc. No errors. It just stop at the halfway point. When I debug the hook, I can see the counter variable increments right up to halfway and then stops. This is the hook. Am I crazy?

function mymodule_update_7200(&$sandbox) {
// Initialize the batch
  if (!isset($sandbox['total'])) {
    $result = db_query('SELECT nid FROM {node} n WHERE n.type = :type AND n.status = 0', array(':type' => 'event'));
    $sandbox['total'] = $result->rowCount();
    $sandbox['current'] = 0;

    // Disable Scheduler
    module_disable(array('scheduler'));
    drupal_set_message(t('The scheduler module was disabled'));
  }

  $nodes_per_pass = 20;

  // Get the nodes to process during this pass.
  $result = db_query_range('SELECT nid FROM {node} n WHERE n.type = :type AND n.status = 0', $sandbox['current'], $nodes_per_pass, array(':type' => 'event'));
  foreach($result as $row){

    $node = node_load($row->nid);

    // Run a database update directly so we don't trigger any API calls through node_save
    db_query("UPDATE {node} n SET n.status = 1 WHERE n.nid = :nid", array(':nid' => $row->nid));

    // Log the event being published
    watchdog(
      'events',
      'Event was published: %title',
      array('%title' => $node->title),
      WATCHDOG_NOTICE,
      l('View', "node/$node->nid")
    );

    // Increment "current" by 1.
    $sandbox['current']++;
  }

  // Set the value for finished. If current == total then finished will be 1, signifying we are done.
  $sandbox['#finished'] = ($sandbox['current'] / $sandbox['total']);

  if ($sandbox['#finished'] === 1) {
    drupal_set_message(t('@nodes events were published. View the log for details.', array('@nodes' => $sandbox['total'])));
  }
}


texts:
I am trying to update node fields directly with db_update():

foreach ($_POST as $key => $_POST_value) {

  $num_updated = db_update('field_data_krown_weight')
  ->fields(array(
    'krown_weight_value' => $_POST_value['weight'],
  ))
  ->condition('entity_id', $_POST_value['nid1'], '=')
  ->execute();

}

It works pretty well, the data is well updated into database, and very fast. The problem is that when I go to the node form edit, the value in my field hasn't been updated.

I read that we must use field_attach_update() instead, something like:

foreach ($_POST as $key => $_POST_value) {

  $node1 = node_load($_POST_value['nid1']);
  $node1->krown_weight['und'][0]['value'] = $_POST_value['weight'];
  field_attach_update('node', $node1);

}

The problem is that with field_attach_update(), the query takes much more time to be executed! I need to update several nodes at the same time, so I would like to avoid field_attach_update()..

How can I perform node fields updates without processing all the node_save() stuff?

I also tried to reset the cache after db_update(), but this doesn't seems to work:

foreach ($_POST as $key => $_POST_value) {

  $num_updated = db_update('field_data_krown_weight')
  ->fields(array(
    'krown_weight_value' => $_POST_value['weight'],
  ))
  ->condition('entity_id', $_POST_value['nid1'], '=')
  ->execute();

  entity_get_controller('node')->resetCache(array($_POST_value['nid1']));

}


texts: Drupal 7 + Services : Error 500 on user registration (Integrity constraint violation: 1048 Column 'uid' cannot be null)

texts:
I'm still working on user registration with Drupal 7 and Services 3 and I got a weird Error 500 :

  Integrity constraint violation: 1048 Column 'uid' cannot be null

Here is the code I'm using :

// REST Server URL for auth
$request_url = SERVER_URL . 'rest/user/register';

// User data
$user_data = array(
  'name' => 'newuser',
  'mail' => 'newmail@mail.com',
  'pass' => 'newpass',
  'field_city' => array('und' => array('0' => array('value' => 'NA'))),
);

$user_data = json_encode($user_data);
// cURL
$curl = curl_init($request_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json'));
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $user_data);
curl_setopt($curl, CURLOPT_HEADER, TRUE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_VERBOSE, true);

$response = curl_exec($curl);

$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  if ($http_code == 200) {
  return json_decode($response);
}
else {
  $http_message = curl_error($curl);
  return $http_message;
}

Is there something I'm doing wrong ?


texts:
Logging as Admin user on Drupal 7 website stored on an IIS machine, I get the following error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]:
General error: 2006 MySQL server has gone away'
in E:\inetpub\wwwroot\teams\includes\database\database.inc:2139
Stack trace:
#0 E:\inetpub\wwwroot\teams\includes\database\database.inc(2139): PDOStatement->execute(Array)
#1     E:\inetpub\wwwroot\teams\includes\database\database.inc(664): DatabaseStatementBase->execute(Array, Array)
#2 E:\inetpub\wwwroot\teams\includes\database\database.inc(2318): DatabaseConnection->query('SELECT expire, ...', Array, Array)
#3 E:\inetpub\wwwroot\teams\includes\lock.inc(167): db_query('SELECT expire, ...', Array)
#4 E:\inetpub\wwwroot\teams\includes\lock.inc(146): lock_may_be_available('schema:runtime:...')
#5 E:\inetpub\wwwroot\teams\includes\bootstrap.inc(420): lock_acquire('schema:runtime:...')
#6 E:\inetpub\wwwroot\teams\includes\bootstrap.inc(442): DrupalCacheArray->set(Array)
#7 [internal function]: DrupalCacheArray->__destruct()
#8 {main} thrown inE:\inetpub\wwwroot\teams\includes\database\database.inc on line 2139

Any idea on how do I debug those statements? And how do I release locks?


texts:
I'm trying to help my father out by building a webform (D8 version) for the 4 theaters his Old Abbey Friends are putting up.

I've made the webform, now i'm setting up an email handler so that people get a confirmation email.  Straightforward enough, however, i'm getting lost when using the twig template option of that email handler on following items:

how do i check if there's at least one checkbox checked in a checkbox element (containing 4 checkboxes)?
how do i check which of the checkboxes is checked in the above element?
how do i get the number in a number element that's part of a custom composite?  I tried using the data.composite_elementkey.elementkey syntax, but that just shows up blank.

Any feedback much appreciated!


texts: Unable to find out how a content type node is getting themed

texts:
I have a drupal 7 installation with a paid template which I am trying to tweak. The template has a demo installation, which has a content-type named 'Team'.

So I created a bunch of content with type as Team. Now if I create a Basic Page content and in the URL Alias if I give 'content/team', then it shows a grid view of all the team content I created (each team members photo, name & designation with a read more button).

There is a node--view--team.tpl file available in the codebase.

My problem starts when I try to rename the content-type called Team to 'Students(machine name was also changed tostudents). After renaming I renamed the tpl file tonode--view--students.tpl`. In the URL alias, if I give any url other than 'content/team', all I get is an empty page. If I change the URL alias to 'content/team' - everything works!!

This is driving me mad, I know I cannot get a complete answer since I am tweaking a custom theme, but any pointers would be greatly appreciated!


texts: Migration issue: Drupal markup isn't rendered on CiviCRM pages

texts:
I've moved a Drupal 6 / CiviCRM 4.3 site to a development server, and I'm getting really strange behavior. When I visit a Drupal page on the copied site, everything renders as expected. However, when I visit a CiviCRM page, the CMS part of the markup is missing from the source. It's almost like every CiviCRM page is being delivered as a snippet.

To be more specific, when I go to /civicrm and view source, I get markup beginning with:

  ...

The opening and closing HTML tags, and all the HTML contained in the Drupal theme are entirely absent. The same appears to be true for every CiviCRM page.

I've tried the following:

reviewing my CiviCRM settings file
reviewing my directory and resource settings
clearing Drupal caches
emptying sites/default/civicrm/templates_c
deleting sites/default/civicrm/ConfigAndLog/Config.IDS.ini
running drush civicrm-update-cfg
checking error logs for Apache, Drupal, and CiviCRM
throwing salt over my left shoulder

Any ideas what might cause such strange behavior? Suggestions for something I might have missed in my migration or a good place to put debugging code to get to the bottom of this?


texts: How do I change the Drupal 8 frontpage template, so it doesn't use the regular page.html.twig template?


texts: Add template suggestions for location.tpl.php to use a different layout for addresses on specific content types?

texts: I have been trying to figure out a method to override the locations.tpl.php template on a per content type basis, but I can't find any good examples on doing this with module template files rather than core template files. Is there code that could be inserted into template.php so that location--blog.tpl.php could be used in the same way that node--blog.tpl.php can be used? Interested in the location module specifically, but would appreciate pointers for general methods of theming contrib modules.


texts:
I'm using LDAP module to allow user login through a LDAP Server. This is server configuration:

Server Properties

sid = eng_ldap_server
numeric_sid = 1
name = Eng LDAP Server
status = 1
ldap_type = ad
address = 10.10.72.202
port = 389
tls = 0
followrefs = 0
bind_method = 2
basedn = Array ( [0] => dc=BMS,dc=ORVIETO )
binddn = admin
user_dn_expression = cn=%username,%basedn
user_attr =
account_name_attr =
mail_attr =
mail_template =
picture_attr =
unique_persistent_attr =
unique_persistent_attr_binary = 0
ldap_to_drupal_user =
testing_drupal_username =
testing_drupal_user_dn =
grp_unused = 0
grp_object_cat =
grp_nested = 0
grp_user_memb_attr_exists = 0
grp_user_memb_attr =
grp_memb_attr =
grp_memb_attr_match_user_attr =
grp_derive_from_dn = 0
grp_derive_from_dn_attr =
grp_test_grp_dn =
grp_test_grp_dn_writeable =
search_pagination = 0
search_page_size = 1000

Anything wrong?


texts: Customize Commerce Event Ticket PDF content

texts: I'm running Drupal Commerce and Commerce Event Tickets on a client site. I'm trying to figure out how to customize the content of the ticket PDF that is generated by the module, and I'm stumped. It's not managed by any of the generated views. Has anyone done this before?


texts: How to theming row results from a view with display suit

texts:
I want to theming every row of a view with "display suit - display mode".
The idea is that depending of a taxonomy selected in the node the row use one or other display mode.
I'm able to make it with a a views*rows-tpl.php, but I'll like to make it with display suit.
I have try with VCD but seems that VCD is only for DS 7.1.x, and it don't support multiples context

If multiple contexts are tripped for a view, then the last active contexts' build mode will be used for that view, overriding all other active contexts.

I'm trying with ds_views_row_adv_VIEW_NAME
<?php
/**
* ds_views_row_adv_VIEW_NAME($entity, $view_mode, $load_comments).
*/
function ds_views_row_adv_prueba_display($entity, $view_mode, $load_comments) {

if($entity->field_prueba_display['und'][0]['tid'] === '3'){
//select the new view_mode
  $view_mode = 'derecha';

}

  $entity = node_view($entity, $view_mode);

//  dpm($entity);
//  dpm($view_mode);
//  dpm($load_comments);

  return drupal_render($entity);
}
?>

But it don't work fine and only use one kind of view_mode.
Thanks.


texts:
I made a custom form using FAPI (Drupal 7), with '#required' attribute in some form elements.
Besides this, I use hook_form_validate() to check some business rules.

The point is at first submission, required fields appears red-bordered, but still no error message.

On second submit, the error messages appear with both required and business rules .

Is there a way, to have the second behaviour on first attempt ?

Thank you.


texts: Views with Qtip - load only view content

texts:
I was looking around for a solution of my problem without luck, unfortunatelly I stuck :/

The problem is as follows:

I have created a view to show list of custom type nodes and another view with Contextual filters to show single selections. On the table view each position have a linked tooltip (qtip), all I want to do is to show in tooltip only content of the view not the whole page. I dont really know how to achieve this as a result I'm getting whole page displayed in tooltip (with header/footer/menus etc.)


texts:
I've got a custom module weekly_digest and I want to make it so each new user is added to a table with info on their subscription preferences.

I've been using the admin UI to add the users to test, unsure if that effects things but I don't see why it would.

As some context, in my .module I currently have weekly_digest_node_insert and that works just fine.

And here is the function which does not get executed and I can't get Xdebug to catch it either:

function weekly_digest_user_insert(UserInterface $entity) {

  $query = Drupal::database()->insert('weekly_digest_user_preferences');
  $query->fields([
    'uid',
  ])->useDefaults([
    'new_posts',
    'digests',
  ])->values([
    $entity->id(),
  ])->execute();

}

Most search results returned "Can't in theme" or "Drupal 7" so I was unable to figure this out.


texts:
I want to know, when all the cache tables are stored in database, then whats the logic behind keeping any data to cache, because whenever we query cache, it again hits the database, same as other normal tables exists in database do.

How cache tables are different from other normal tables in database? How cache boost performance when all cache tables also exists in database?


texts: Display newly added form element at the bottom

texts:
I altered a form, and I added a $form['priorities'] form element.

Why is it appearing right after the title form element, and not at the bottom of the form? How can I make it at the bottom?


texts:
I have a custom module that allows administrator users to review users, and then approve their registration. I can't figure out how to programmatically trigger the 'approve' process.

Changing their role, or doing a regular user_save() with the new status doesn't seem to trigger rules associated with activating the user.

I'm sure there's a simple function for this, but I can't find it.


texts:
I'm currently migrating a site to Drupal. The old site has thousands of dynamic URLs for which I cannot use a regular expression to handle them. Those URLs exist in a slightly different form in the Drupal site.
Unfortunately the URL structure is too complicated for being processed directly in a .htaccess file.
I want all the old URLs to return a 301 redirect to the new URL.
This is what I tried.

I implemented hook_page_preprocess() and sent a RedirectResponse to the new URL when the incoming URL matches the regular expression for the old URLs
I implemented an event subscriber that does basically the same on the onRequest event

In both the cases, the redirect response is sent with the following code.
$respond = new TrustedRedirectResponse($url,301);
$respond->send();
die();

Both solutions do work when the user is logged-in. In my local developing site, it works also when the user is not logged-in. On the live server, it doesn't work for anonymous users.
The funny thing is that, even when the redirection works for logged-in users, the log shows a Page not found entry for that URL. So it seems that even with the event subscriber solution, Drupal handles the 404 part first, and then executes my code.
What am I doing wrong?
Should I implement this differently?


texts:
How do I only show a block on the front page. I have  on only listed pages under block settings and it won't disappear on the second page. I've also added

$is_front
drupal_is_front_page

around the block and those don't work either. Renaming page to page--front.tpl.php didn't work either. Any suggestions on how to fix this? Also please be specific with your answers as I have no idea what to do and I hope this doesn't need a moldule as I'm trying to run a site with little running modules as possible.

Thanks,
Gregory S.


texts: Link checker not working for cck fields?

texts: Link checker is not working for entity fields. It is only checking the body text, but not the text provided in a field. I created text field, but it is not considered when reporting the broken links. Am I missing something?


texts: Webform Views - show results for host node id only

texts:
I'm using block webform on my site.

Is this possible to track submissions by host node ID (node, where user submitted the form)? Or the only way to achieve this is to add hidden field with current node ID and then sort it by this field?

Any ideas?


texts: Why did Views just jump from 3.8 to 3.10 (what happened to 3.9)?

texts:
There was a security advisory issued for Views yesterday, but the new version is two ahead of the last (3.10 to 3.8).  What happened to 3.9?

The Views release page doesn't list a 3.9, or a reason why there is no such version.

Is this some new security rule I don't know about?


texts: How to display only  certain values  otherwise display empty field in Views

texts:
I would like to display only certain values of CCK value in a views field. In another words, I don't want to display certain values of CCK in the views field. Is this possible?

For example I have a CCK field called "fruits" with multi selections of "orange", "apple", "banana". I have also a table view with a "fruits" field and then I would like to display only "orange" value but keep this field empty when the field have the value other than "orange"(when the value is "apple" or "banana" ).


texts: nodeaccess prevent some roles to view views contents even if they allowed to access

texts:
I'm using nodeaccess module to secure some published contents from being seen by normal users or anonymous.

I have a view allowed only to admin and moderator roles to access, but when nodeaccess module is enabled moderator role couldn't see the view contents.
the moderator have permissions to view and edit the content of this content type.

I tried to change the view permission access to "view publish content", it doesn't work until I disable nodeaccess.

So I want understand I what is them problem, and how can allow moderator user to view the view contents? Or at least if nodeaccess is not recommended in my usecase what I should do instead?


texts: How to redirect by adding something after pathauto url?

texts:
I am trying to do a simple thing.
Whenever an anonymous user views a content , I want to redirect the user to

node's-url/#overlay=signup

So, how do I modify the URL to use #overlay=signup at the end for anon users?

I tried to do so by implementing rules.
Event: Content is viewed
Condition: User role is anonymous
Action: Redirect url.

I don't know how to add the pathauto-url/#overlay=signup.


texts: Multiple formatters for a field collection - best approach?

texts:
I'm building a site with a "function" content type, to manage a list of functions and their arguments. Because arguments can be zero or more, and have multiple properties (name, required, usage notes) it seems best to handle them as a field collection, using field collection table as the input widget. Therefore, on the node edit form for the "function" content type, the input widget would look something like this:

On the display side, I need to display the argument data in at least two ways: (1) in a table formatter provided by field collection table and (2) in an arbitrary "syntax" format, where only the arguments are output, but with some kind of visual indication of which arguments are required. So, something like this:

My questions:

What's the best way to add a custom formatter for the field collection (i.e. in code, in a field template of some kind, using the custom formatters module, etc.)?
What's the best way to output two instances of the field collection field, each in a different format?

I do have Display Suite installed on this site, if that helps. Also interested in any general advice if there's a better way to handle this use case.


texts: Is there a module/hook for permissions for list values?

texts:
Say I have a text list field attached to a node with the following values:

Apples
Oranges
Grapes
Kiwi
Strawberries
Pears
Bananas

But I want to give some options only to some roles, for example:

Only Administrators can select Strawberries.
Only Anonymous can select Kiwi.
Only Role C can select Pears.

Is there a module for this?  Or, if I was going to code it myself, is there a hook to start from?

This is for Drupal 8 but if there was a solution only for 7, that would be interesting to look at too.


texts: Change another input field with ajax callback

texts:
I have an existing node with text fields. I want to change another field with ajax; if I input text in text field I need this text appears in another text field. I implemented hook_form_alter() with #ajax callback and it works fine, but when I delete this text and write another value in the same field, the  other field is not changing with #ajax_callback. I guess my ajax callback runs only one time.

Please check my code below.

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

        if ($form_id == 'payment_node_form') {
            //dsm($form);
            $form['#validate'][] = 'classes_payment_form_validate';
            dpm($form['#validate']);

            $form['field_test1']['und'][0]['value']['#ajax'] = array(
                'event' => 'change',
                'callback' => 'validate_uid_ajax_callback',
                'wrapper' => 'field-test2-add-more-wrapper',
                'method' => 'replace',
                'effect' => 'fade',

            );
            $form['field_test2']['und'][0]['value']['#default_value'] = 'xyz';

            $father_name = $form_state['values']['field_father_name']['und'][0]['value'];

            if (!empty($form_state['values']['field_test1']['und'][0]['value'])) {
                $test1_value = $form_state['values']['field_test1']['und'][0]['value'];
                $form['field_test2']['und'][0]['value']['#value'] = $test1_value;
            } elseif (!empty($form_state['values']['field_test2']['und'][0]['value'])) {
                $form_state['values']['field_test2']['und'][0]['value'] = $test1_value;
            }

        }
    }

    function validate_uid_ajax_callback(&$form, &$form_state)
    {
        return $form["field_test2"];

    }

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

    dpm($form_state);

       }


texts: Taxonomy page variables giving empty values

texts:
I have a taxonomy page set up using taxonomy views. I added the page--taxonomy.html.twig template, but the output of {{name}} and {{content}} is an empty string. I also tried using the page--taxonomy--term.html.twig, but it doesn't work.

I tried {{ page['#title'] }} and it works fine, but the characters are encoded.

Please help.


texts: Put link/button in email to reply to sender on website

texts:
I'm having a bit of trouble figuring out how this is meant to work. What I'm trying to achieve is as follows:

1) I've got Webform module installed and working. Just has generic fields for now.

2) What I want it to do is as follows:

User A wants fills in the form (webform) asking for a quote to clean their 3 bedroom house. This form gets submitted and cleaning companies get notified by email. - This bit I have figured out!

BUT - What I want to happen is that when the cleaning companies receive this email (name, number of bedrooms etc) I want there to be a link within the email that allows the cleaning company to click on that takes them to another form on the website where they can enter quote information (like price, imagery etc). When the cleaning company clicks submit the original user A gets notified a quote has come in.

Any ideas how I set this up? It doesn't appear to be included in the standard module.


texts:
One of my content types ran into some kind of corruption state, in that the Vertical Tabs (fieldsets) at the bottom of the form, are not present (not even in the markup). What I tried:

The issue started with 7.9, afterI upgraded the core to 7.12 - it was
still there.
I tried to disable all custom modules and widgets that this particular content type uses
On a copy of the site, I disabled all custom modules, including those essential such as Views, Pathauto, Display suite, etc. (well, this was a bit desperate - if any common module had cause the trouble, it would have affected all content types, not just one)
I tried to export the content type definition with actual nodes and imported them back (using Node export, Features, Demo)

All to no avail. Does anyone have any clue as per any other tests I could do? I would like to restore the content type definition without losing 200+ nodes data already in db. I could try raw phpMyAdmin export of the nodes but I'm not sure what tables should be exported as there seem to bee so many dependencies...


texts: How do I properly add a custom source for RSS feed import?

texts:
I am setting up the mappings for a Feed entity, but I cannot figure out how to properly set custom sources for fields.

In this case, I am grabbing records from an XML document ("RSS/Atom" option) and importing them into an Article content type.

I have a custom tag in the XML document, <alert>, with a value that maps to the Alert Flag Type (field_alert_flag_type) field on Article nodes. I set up a custom source called "Alert" (machine name alert), and when I attempt to import a feed with this new custom source specified, I get the following error(s):

The content [XYZ] failed to validate with the following errors:
    Alert Flag Type (field_alert_flag_type): This value should not be null.

Please check your mappings.

If the XML tag is <alert>, the source name is "Alert", and the source machine name is alert, what am I doing wrong?


texts: How can I sort entity type query results with pseudo values?

texts:
Is it possible to use the D8 EntityQuery condition and sort functionality to filter/sort based on the outcome of multiple fields (and possible external/3th party value) calculations?

Example with condition:

I want to filter the results based on the average of 5 numeric fields.
So i need to add them up and divide them by 5 and if that outcome < 8 i do not want to use the entity.

Example sort with external API value:

I want to sort the results based on a calculation with an external API value.
So lets say i have a numeric field in my entity with the value of 10. The external API gives me a value of 30. The calculation would be 30 - 10 = 20.

Now for my second entity the numeric field value equals 5 and the API sais 20. The calculation would be 20-5=15.

Now i want to sort the results from highest to lowest. So in this case the first entity should be first because the outcome of the calculation was 20 and for the second entity it was 15 so it should come second.


texts: How do I enable the "print PDF" link on only a specific page?

texts:
I have enabled the print module and configured the basic page content type to show a PDF print link under the basic page settings.

On the print module's Links settings page at admin/config/user-interface/print/ui, under the  Advanced Link Options heading, I can specify the paths where I want to show a PDF print link.

But it is still showing a "print PDF" link on all basic pages.

I also tried by disabling the print setting under basic page settings, and only entering the path under print links settings, but then it disable the pdf print link from all basic pages -- even from the one I want it to show up on.


texts:
I've been using the Feeds module to create/update some of my content types.

I was wondering if there is a way to "lock" the value of a field once it is created.

I've searched for a module called: Lock Field Values. But it's in development.

https://www.drupal.org/project/lock_field_values

I was wondering if there is a way to add conditionals on import. For example, if a field has a value, then don't updated or just lock the value of the content.

I appreciate any input. Best!

Edit: I'm using Drupal 8


texts: I am using aggregator feeds.I have to created feeds.xml file. But i have to create JSON file for Drupal 7? How to create it .Anyone guide to me.


texts: How to delete the row item from a view table after purchase is done?

texts:
What I desire to achieve: I have a view where users can consult their payments inserting their ID. These payments will be displayed on a table, this table has a column with a "payment button". This button takes me to the "purchase page" (this url is external, and there is not connection between my site and that payment after button is pushed).

What I need is, once the payment is done, the user will be redirected to the "Approved payment page" on my site. Then when user search again the user's ID, that payment should not exist.

My question: How can I delete that payment row from the table if I don't have an established connection between my site and the payment site?


texts: Set location country based on coordinates

texts: Is there a way to have Location pick the appropriate country based on the latitude/longitude entered when the node is saved?


texts: drush devel-reinstall does not rebuild tables

texts: For some reason if a module is a dependency other another module, and I run 'drush devel-reinstall' on it, it does not delete and then rebuild the tables for that module.  Does anyone know why?


texts: What are the conditions for the "is one of" operator being enabled for filters on a particular field?

texts:
When I am creating a filter on a field, the "is one of" operator is not available. What are the necessary condition for the "is one of" operator to be available for field.

I have seen an example in which the "is one of" operator is available for taxonomy values. What is it about taxonomy values that make the operator available for them?


texts:
Is it possible to use the Amazon S3 module for stage / production only? The site I'm building, is using features. So when I export my fields for the content types, I either have the option to select Local File Storage, or the S3 File System.

I thought I had a solution, where on stage / prod, I would hide the local file system wrapper, but the issue turns out, that unless I select the S3 checkbox when editing a field in the content type, it doesn't default to S3.

I could go thru and select this option for all file fields, but then on the downside, dev will be broken.

My only other option, which I haven't tried, is setting a global variable via settings, and then using a if/else logic in the features for each file field, to pre-set the upload location for that field.

Ahhh, so messy.

Anyone come up with a clever solution in the pasts? That allows me to force files to be uploaded to S3 for stage/prod and local file system when running via local or dev?

Update:

Okay, so I noticed that features has the following hook:

hook_field_default_field_bases_alter()

So, in my module, I'm using that hook, determining if the env should be serving the files via local storage, or s3. If it's s3, I then alter it from 'public' to 's3'

I went and just to be safe, re-exported all my features, and made sure that by default, it was set to public, an not s3. Now, all my env's are using the correct storage location. I'm still not sold that what I'm doing is the best solution, but it is working. Any thoughts?

$use_s3f3 = variable_get('image_save_s3f3', FALSE);

// Only on stage/uat/prod, do we want to use s3 as the file storage engine.
if ($use_s3f3 === TRUE) {
 foreach($fields as $key => $item) {
   if (isset($item['settings']['uri_scheme']) && $item['settings']['uri_scheme'] === 'public') {
     $fields[$key]['settings']['uri_scheme'] = 's3';
   }
 }
}


texts:
Assume the following. We have a taxonomic vocabulary called product. Which contains two terms: tables and chairs. This taxonomy creates the following URL's:

http://www.mydomain.me/product/tables
http://www.mydomain.me/product/chairs

Taxonomy Menu module to create a menu that taxonomy. If we click the Tables menu item leads to http://www.mydomain.me/product/tables. Which shows a list of all published tables. Same with the chairs.

All right. But we want to customize this list, so we to use Views. Views creates the following two pages:

http://www.mydomain.me/product-2/tables
http://www.mydomain.me/product-2/chairs

Here is my problem. How do we make the taxonomic menu leads us to pages created with Views?

Currently I get this by changing the URL's menu with jQuery. But this may not be the best way.

Does anyone know how to deal with this duplicity of pages (taxonomy page, and Views page)?

Greetings!


texts: can i weight content-types and manually manage the display?

texts:
Possible Duplicate:
  Reorder Content Types in (“/node/add”)

Can I weight content-types (not nodes created) and manually manage the display?

Presently, i am prepending some content-types with an x so that they float to the bottom of the content-types list.


texts: How to make https links available to anonymous when new article is published?

texts:
When content/article is created the content is accessible first on the http link and then later the httpS link. There is usually a delay of at least 5mns for anonymous  to access it.

http://example.com/item-just-published
vs
https://example.com/item-just-published

The cache settings have been modified for the content type to refresh cache on update and insert but it seems to affect the http links only not httpS. This is a problem as some time sensitive items don't get to the audience in a timely matter using httpS links.

example.com/admin/config/development/performance

example.com/admin/config/system/expire

How to make httpS links available as soon as it is published to anonymous?


texts: Why is an entity reference view field only showing one view result?

texts: I have a form field on a node create form that is an entity reference, referencing a view that displays all of the appropriate results. The view displays users with a relationship to a content field on the user, so the fields returned are all content. There is also an argument that takes the logged-in user ID. On the node create form, the field in question, when set to show unlimited results, only shows the last result from the view. I feel like I've gone over any technical reason this could happen, now I'm wondering if this is a bug with user views, or elsewhere. I haven't found anyone reporting this yet in my searches, so I thought I'd post it here.


texts: Pass variable from theme page template to commerce-product file

texts:
I am new to drupal and this is my first website in drupal.
I am looking to pass a variable from newtheme.theme to commerce-product.html.twig but I am not able to do so.

Here is my code (newtheme is name of my theme)

function newtheme_preprocess_page(&$variables) {
 $variables['product_cta'] = 'Static Text';
}

in commerce-product.html.twig

{{product_cta}}

but this is not working  the product_cta will be a call to action which will be calculated programmatically and passed to the product single page.
I am using Drupal 8 and Commerce 2.X.X

Any help is really appreciated.


texts: Good Drupal distribution to start with Workflow?

texts: Is there a  better Drupal 7 distribution that I can start with, for an enterprise website which require to have workflow support?


texts: Drupal error. Drupal safe mode possible?

texts:
I added organic groups module to a drupal website. For some reason the website crashed and gives the following error:

Fatal error: Unsupported operand types in /home/content/39/7384539/html/salvare12/sites/default/modules/og/includes/og.info inc on line 115

I removed the organic groups module manually and disabled it in the database. But then it gives a file missing error. I have uploaded the organic groups module once again but it does not work.

How can this be fixed? Is there some safe mode in drupal, to which i can revert when such an error occurs?


texts:
In the past, when working with Drupal Commerce, I have built it from scratch. This is usually to fine tune exactly the modules I need, and to keep an eye on performance as I add each module.

After doing a few sites this way, I get pretty sick of the process of configuring it all every time, and so with this next project, I have decided to save myself some time, and use Commerce Kickstart 2. I have downloaded it and a had a quick play on WAMP, and its great to have a working site ready to go, with a huge amount of time and worked saved.

However, it feels slow compared to the sites I build from scratch, and there is a lot of modules in this distribution that I wont be needing, and so I will go through and disable/uninstall the modules I don't need.

This still leaves a huge list of modules on the modules page, and even though there is a quick search/filter on the modules page, I would just rather they weren't there.

My question(s) is/are, am I OK to just go and delete all of the modules from the Kickstart profiles folder once I have uninstalled them? Is this considered bad practice for any reason? Will I see any sort of performance increase by deleting them? (I think I will as the system table will be much smaller)