texts: How can I make db_select recognize an empty field?

texts:
I am writing a db_select in D7 to get various user fields, including the URI's of user's avatars (if it exists).

My initial attempt looked this:

$query = db_select('node', 'n');
$query->join('users', 'u', 'n.uid = u.uid');
$query->join('file_managed', 'f',
  'f.fid = u.picture OR u.picture = :null', array(':null' => 0));
$query->fields('f',array('uri'));

This almost do the job.  The only glitch is that if the user has no avatar, the field uri always contains the uri pointing to f.fid #1.  In that case, I want it be missing or empty.

As a workaround, I now execute two db_selects: First one for all users that have an avatar:

$query->join('file_managed', 'f', f.fid = u.picture);

Then one for all users without:

$query->join('file_managed', 'f', u.picture = :null', array(':null' => 0));

I then just concatenate the results. This produces the desired result, but is a bit clumsy.

I would like to do it with one db_select if that is possible.


texts: Set default country for the Address type element (Webform)

texts:
I'm using the webform module (8.x-5.0-rc12) and I've used the Address type element to store my addresses.

I'd like to set the Country field to default to United Kingdom when the form is displayed.

Does anyone konw if I can set that within the user interface?

Thanks.


texts: How anonymous users can un-publish or delete a node with a key based URL?

texts:
I am looking for a solution where I can create a special URL (with keys) for each node and when a user (anonymous) visits the node, they can unpublish or delete the node.

There is a module. But it does not work with views.
https://drupal.org/project/node_authlink

any clues or any alternate solution ?

Clarifications:

I have more then 10,000 nodes created by admin. i need to generate special access links for all nodes. Once the link is visited the Anonymous user will have permissions to delete the node.

thanks.


texts: Is it possible to get rid of content duplicates?

texts:
I've got a site, mysite.com. Now I'm trying to add blog on it at sub-domain, blog.mysite.com, using the Domain Access module.

When I create an article in blog, with alias blog.mysite.com/article-alias, it is available from main site, by URL mysite.com/article-alias. At the same time, main site articles, like mysite.com/about are available from blog by URL blog.mysite.com/about. No matter which affiliate I'm sending this article to, or which source site I choose, it still happens. Today, I've found that some of such pages were indexed by Google as duplicates, despite having canonical tag.

Is it possible to get rid of such pages with this module settings, or with the help of some additional modules? Still, I can't find no solution.


texts:
I know about user_access API. I've written a module that should display some information only if the user has specific rights on the taxonomy.

To be more precise:

we've created a vocabulary, say books.
in this vocabulary books we have a lot of terms, say for example children and cooking
we've created roles according to the terms, i.e. roles like role for children and role for cooking => one role = one term.
now I've written a module that should diplay a link to 'edit' or 'create' only if the user is logged, and if he has the rights based on the role (which heavily relies on the taxonomy access rights).

In short: in my node_view hook:

I have to check if it's a node with books vocabulary.
if so, I have to read the associated term (there can be only one), let's take an example: children
if the user is logged in and has the permissions of editing nodes with the specific term (children here), the I display a text with a link like edit this book and another like like create a children's book.

This is only the last part that is a problem to me.

Does the user access API call works flawlessly, and takes in account those rights, or do I have some specific calls to do? No API seems available for the taxonomy access control (TAC).

Maybe you have an example somewhere (didn't find one actually)?


texts: How do I add a Commerce product type to a feature?

texts:
I have a custom product type that I created in my local dev environment and I'm trying to export it into a feature.

However, I can't seem to find where the product type is stored in the Features module UI.  I found the permissions (Product: View Own Custom Products) and the field instances (commerce_product-custom-commerce_license_role) but I don't see the product type itself.

Instead, when I enable the feature on production, I get the following error message:

  Warning in features rebuild of custom_module. No module defines permission
  "view any commerce_product entity of bundle custom_product_type_machinename".

When I export to production, the product type is not created.  Where are the Commerce product types in the Features UI?


texts: How can I filter sensitive data being recorded in calls to Watchdog

texts: I have sensitive data that is sent to a Drupal instance and I don't want it to be logged. I can filter out sensitive values with simple string replacements for my own calls to watchdog(), but for PHP errors and other modules making watchdog() calls, the data may be logged and this needs to be filtered too.


texts: How To customize user account creation form

texts:
I successfully customized the user login and password reset form using this:

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

  $items['user_login'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'responsive_bartik') . '/templates',
    'template' => 'user-login',
    'preprocess functions' => array(
       'responsive_bartik_preprocess_user_login'
    ),
  );
  $items['user_pass'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'responsive_bartik') . '/templates',
    'template' => 'user-pass',
    'preprocess functions' => array(
      'responsive_bartik_preprocess_user_pass'
    ),
  );
    return $items;
}

then I created two files, user-login.tpl.php and user-pass.tpl.php
Which each have code like this:

<?php print render($intro_text); ?>

  <?php print drupal_render_children($form) ?>

Forgot Password

Don't have an account? Sign Up

I tried to the the same thing with the registration form but it still looks the same. It has not overriding it. Here is the code i am used for that:

  $items['user_register'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'responsive_bartik') . '/templates',
    'template' => 'user-register',
    'preprocess functions' => array(
       'responsive_bartik_preprocess_user_register'
    ),
  );

I stuck this right before the
 return $items;
}
section.

Then i created a file: user-register.tpl.php and placed this code into it:

Hello TEST!

<?php print render($intro_text); ?>

  <?php print drupal_render_children($form) ?>

Already have an account?Log in

Don't have an account? Sign Up

Form output didn't change.
I am using Profile2 Module and Logintoboggan Module


texts: Slideshow with images of a gallery ,at the end of the gallery next gallery images should start

texts:
I have several modules to show the images in slideshow, but i need to show the images of a gallery with slide counter.

At the end of the last image in that slide there must a next gallery navigation,to start the next gallery images with slide counter.

It will continue as for next galleries.

Anyone say how to do this using views or by modules ? am in urgent need of this, to update

Thanks in advance.


texts: Commerce equivalent of Signup, Pay Per Node, etc

texts:
I had previously asked for some information about specific e-commerce functions on D6, and was pointed to UberCart, along with Pay Per Node, Signup, and a few other modules. I've just learned that our hosting company has updated their php install so D7 is now supported.

Are there equivalents to those modules for D7? I know Commerce is the big one, but can it do pay-per-node type stuff (to support a print-on-demand fundraiser)?


texts: How to provide option for users to select whether to ship a product or not at time of chekout using ubercart in drupal ?


texts: Fatal error: Cannot redeclare MYTHEME_preprocess_page()

texts:
I'm new at Drupal, so please help to solve the problem. :)
I've found an article: Change templates based on path alias

It describes my situation. But when I include described code or just this line:

function lm_sr4_preprocess_page(&$vars) {}

In mywebsite.com/sites/default/themes/lm_sr4/template.php it just causes this error:

Fatal error: Cannot redeclare lm_sr4_preprocess_page() (previously declared in /var/www/sites/lmsr2.video-site.ru/sites/default/themes/lm_sr4/template.php:11) in /var/www/sites/lmsr2.video-site.ru/sites/default/themes/lm_sr4/preprocess/page.preprocess.inc on line 10

Here's all template.php code:

<?php

/**
 * @file
 * Template overrides as well as (pre-)process and alter hooks for the
 * lm_sr4 theme.
 */

function lm_sr4_preprocess_page(&$vars) {
  $alias_parts = explode('/', drupal_get_path_alias());

  if (count($alias_parts) && $alias_parts[0] == 'ep') {
    $vars['theme_hook_suggestions'][] = 'page__epcustomtemplate';
  }
}

function lm_sr4_views_tree_inner($variables) {

  $view = $variables['view'];
  $options = $variables['options'];
  $rows = $variables['rows'];
  $title = $variables['title'];
  $result = $variables['result'];
  $parent = $variables['parent'];

  $items = array();
  foreach ($result as $i => $record) {
    if ($record->views_tree_parent == $parent) {
      $variables['parent'] = $record->views_tree_main;
      $items[] = $rows[$i] . call_user_func(__FUNCTION__, $variables);
    }
  }
  return count($items) ? theme('item_list', array(
    'items' => $items,
    'type' => $options['type'],
    'attributes' => array(
      'class' => array(
        'menu',
      )
    )
  )) : '';
}

function lm_sr4_omega_layout_alter(&$layout) {
  if (arg(0) == 'eparchies') {
    $layout = 'eparchy';
  }
}

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);


texts: How can I increase the number of excerpts shown per result?

texts:
I have approximately 300 book-sized documents (50k up to 300k words each) that I'm trying to make searchable. I would like to display as many excerpts from each result as possible up to a maximum number.

It appears that excerpts are handled by Solr's highlighters, but there doesn't appear to be any parameters I can change to force it to show me more. The closest I've found is this:

  hl.snippets - Specifies maximum number of highlighted snippets to
  generate per field. It is possible for any number of snippets from
  zero to this value to be generated. The default is 1.

but it seems to have no effect on the results returned. I've increased this to 50, along with increasing maxAnalyzedChars and fragsize to no avail.

EDIT:
If I add hl.snippets=50 in a manually composed query it performs as expected - for some reason search_api_solr isn't applying the setting, it always returns 2 snippets. I've also noticed that it's not respecting my search:excerpt view settings.

Will keep updating as I persist.

I've been at this for nearly a week now and am about to start looking at other solutions. Hopefully I'm just being dense - any help is appreciated!

A little more background:
I am loading up a database with several hundred manuals, from small to phone-book sized. I need the user to be able to:

search the entire database using keywords and facets. The results must feature many large snippets which can be skimmed to determine which document is the correct one for their purpose
Then they need to perform a second search within that document only, which they will refine until they find exactly what the need from it.

So I need the ability to display lots of verbose snippets and any extra control I can have over how they are generated would be a huge boon.

Thank you :)

[Update]

I've added

<str name="hl">on</str>
<str name="hl.fl">fieldname</str>
<str name="hl.snippets">20</str>

to solrconfig.xml and confirmed that it does cause solr to return the specified number of snippets, but I still can't figure out how to get search_api_solr do the same. It appears that no matter the settings I apply in the search index or search server, the module still insists on returning 3 or less snippets and generating them via search_api's highlight.php.

[Update] There is a setting in:
Configuration -> Search API  -> Search Server -> EDIT -> Advanced:
"Retrieve result data from Solr" and "Retrieve highlighted snippets" that sounds like it makes drupal use solr's response instead of creating it via php but it appears to have no effect.

[Update] Ok, so now I guess I am going to attempt to create a simple module that uses hooks to modify the query and override the appropriate parameters, then hope that the results get processed properly.

[Update] Used devel and determined that Solr is returning the correct number of snippets according to my changed seettings in solrconfig.xml, so it's just a matter of getting drupal to take them and display them. I guess this means either hooking into highlight.php somewhere or just trying to hijack the query and write my own processor/template logic for it. Will share whatever solution I find. Tried to open an issue on drupal.org but it got flagged as spam. Oh bother :)

[Update] I am officially giving up. In order for drupal to work with the snippits that solr returns, "Retrieve result data from Solr" and "Retrieve highlighted snippets" must be enabled. When they are enabled however, Drupal asks Solr to send every field used for snippets for each result - in my case these fields are huge so this destroys performance. When those options are not enabled, Solr returns just the result data and highlights, but I cannot work with them because highlight.php generates it's own snippets from scratch. Oh well. My apologies to anyone who makes it here looking for a solution - and good luck!


texts: How to restrict access to some nodes based on roles or users?

texts:
I am using Drupal 8 and I am a little bit confused that there is no core functionality to restrict the access to some nodes based on roles or users.

I found PageAccess, which is marked as unsecure and ACL/Access Control which are both dev and not working on my system.

Isn't there any option to do so? I need the private sector on my site and can't believe there is no way in Drupal.

Hope you can help me, because if not I have to redo the whole site with another wcms.


texts: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "glossify_taxonomy" plugin does not exist.

texts:
In Drupal 8 when we upload the module we will get this kind of issue very often.

I have installed glossify and its submodule glossify_taxonomy and configured. we have created some content in production.

After some days we felt we don't need glossify module. In our local instance we have uninstalled the module using composer and exported configuration and pushed to production and configuration also imported.

whenever we have try to create content or else try to access existing content we are getting plugin not found exception.

We have fixed it by first removed all the configuration, deleted all the content and removed the modules from contrib directory

But in production we can't do this every time. Please suggest how to safely uninstall the module.

thank you everyone for the answer in advance.


texts: How to dynamically add css after image upload on node?

texts: I have used drupal_add_js() for my profile content type and modified CSS using jquery .css() function. in this content type i have image upload field but when i upload image the image preview display is changed. my question is how can i apply the style for image preview field which is added after image upload.


texts:
I'm trying to make signature.tpl.php available to spam filters (by default it is  not).

Will adding a preprocess hook to template.php will do the trick?
If so, what preprocess hook should I choose?

In this drupal answer post, someone has suggested the following snippet to solve this problem:

function THEME_preprocess_signature_forum(&$variables){
  $content = $variables['signature'];
  $test = spam_content_is_spam($content, 'signature_forum');
  if (!empty($test['is_spam']) && $test['is_spam']){
   $variables['signature'] = t('This signature has been removed by our spam filter, please contact the site administrator for assistance');
  }

}

But it had no effect for me. Any ideas?


texts: Contextual Filter for a Multiple Value Taxonomy Field

texts: I have a content type with a taxonomy field that allows multiple values (a set of positions within the organization).  I'm trying to create a view of some of these positions by passing a contextual filter via the URL.  I can make a hard coded filter for a specific position by entering a filter criteria that says the field must be one of whatever position I'm looking for.  However, when I try using a contextual filter instead, nothing is returned.  I'm guessing it's because the contextual filter is not using a "one of" comparison. How do I create a filter that will display content types with the given position from the URL?


texts: Why the menu items to edit a specific vocabulary and terms does not show up in administration tool bar?

texts:
I created a new user with specific role and permissions to CRUD 1 content type and 1 taxonomy vocabular and terms. The thing is that the administration menu item does not show up for the taxonomy pages, logged in as that user i only see the Content tab > Add content > My content type

The user has permissions to adminiter vocabularies and taxonomies and edit/delete terms for its specific vocabulary. Has access to administration toolbar

If i put the URL directly i can edit a term, even create a new one for the specific vocabulary

Do i need to set up another permission?

I'm using admin_toolbar module


texts: Count term nodes including child terms nodes

texts:
I have a taxonomy with similar structure (only two levels depth)

  Parent term 1 (3)

  Child term 1 (5)
  Child term 2 (2)

  Parent term 2

  Child term

I want to display only parent terms with a node counter for each of them, but I want this counter also include child term nodes

E.g. Lets say Parent term 1 has 3 nodes assigned to it, Child term 1 has 5 nodes assigned to it and Child term 2 has 2 nodes. In this case I want view to display something like this:

  Parent term 1 (10)

Also I don't want to show Parent term 2 since it doesn't have nodes assigned to it as well as it child

Is it possible through views?


texts: Hiding a Tab when the View from Field View is Empty

texts:
I'm using Views Field to show a view in a Horizontal Tab in a content type. My trouble is that when the view returns empty based on filter criteria, the tab is not hidden.

The view itself has 4 fields from the content plus some custom text.

I tried going through some of the "Not Empty" tips for hding blocks when views are empty, but It didn't work and it was all a shot in the dark anyway.


texts: Commerce discounts by day-of-week and by age

texts:
I am creating a store where users can pay for attending events at a fixed rate of £7 for each event; that's the easy part.

The hard parts are as follows:

Every Tuesday all events are half price (£3.50)
Students are admitted any day of the week half price
Senior citizens are given a £1 discount every day of the week

I am investigating the Rules module as the most feasible solution, but I am not sure it will deal with all the scenarios above.

I would appreciate any advice to help me reach a working solution.


texts: How do I import a csv-file into a table via Drupal?

texts:
I would like to import a csv into a table via Drupal. I use Drupal 7.

I create a content type 'Import', which contains a File field to upload a file to the server (destination: sites / default / files / import / *)

When I validate my form content 'Import', I will wish to make a db_query ()

db_query ("
LOAD DATA INFILE '$ csv_filename' INTO TABLE $ temp_table
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\\n'
IGNORE 1 LINES ");

$ csv_filename, I test the relative and absolute way, but drupal tells me it can not find the file. I even give the rights to the file to test 777 but it is not ca.

$ temp_table is my table, it already exists in the database.

You would know the procedure and a use case that works for this query?


texts: Change the rendered output of a Message entity

texts:
I'm using the Message module to create messages on certain events, for example, on forum node creation:

"X has posted a new thread in the Y forum."

I've got a view that spits all of these out.

I now want to create a new view that shows the same messages, but in this view, I want to change the output of the above message to:

"You have posted a new thread in the Y forum."

Every time the node's author matches the currently authed user.

Now my thoughts would be that I could somehow intercept the output of either the token (X) or override the whole message entity template, but I'm not entirely sure how to go about this.

Another thing I tried was to create a new user token, called "Username or you", which would output "you" if the associated message node matched the authed user, or the username if not. However, I'm not sure how I could get the message object. It's worth noting that I have the token:

[message:field-forum-post:author:username_or_you]

So if I could follow the trail back to "message" and get the message id, I'd be all set.

Any pointers?


texts: adding a grid with specific class in adaptivetheme

texts:
I'm trying omega and adaptivetheme to use responsive webdesign.
On omega that uses 960grid, I can add a "grid-X" class to an html element to display it in the grid, with the right width etc.
Is there a way to do the same thing with adaptivetheme?


texts: Display an element based on user country

texts:
I guess this isn't a webforms specific question, but it might have been solved here before.

I want to display an element based on the country that a user is from (based on GeoIP or Cloudflare / Akamai header), but I can't find anything particularly helpful on Google on how to do this. Ideally I could use a computed token or twig to pick up a specific header, but I'm struggling to find the right way to do it.

Many thanks!


texts: Checkboxes options with class in form api

texts:
I need something like a filter on checkboxes #options in my form built via Form API.
Is there a way to group checkboxes or add a class to filter them via js front side?

In the documentation options are simply 'value' => 'label'. Can I filter or group them?


texts: Get Field Collection Array From Field Collection ID

texts:
I'm using the following code to return array of all field collection IDs for a node's field collection. How do I use these IDs to get an array of the values of the fields within the field collection?

case 'field_collected_dates':
$fid = field_get_items('node', $node, $key, $node->language);
$return[ $key_clean ] =  $fid;
break;


texts:
I am using Drupal 6, and Views 2.0; I need to create a node where one of the fields is a filterable view. I then need to store the final SQL query of the view in the database.

How would I add the block view to a node creation page?


texts: Drupal views module ask for GB of RAM and lead to white page

texts:
I set memory_limit  as -1 in my php.ini. Drupal exhausted it all apparently and when i dump the memory limit with ini_get, it give 8GB. Even with this confortable resource, it cannot fullfill the request :

( ! ) Fatal error: Out of memory (allocated 20971520) (tried to allocate 1717530240 bytes) in C:\AltaV2Drupal\src\main\drupal\sites\all\modules\contrib\views\modules\image.views.inc on line 28
Call Stack
#   Time    Memory  Function    Location
1   0.0006  358328  {main}( )   ...\index.php:0
2   0.0089  361952  drupal_bootstrap( ) ...\index.php:23
3   0.0835  1297480 _drupal_bootstrap_full( )   ...\bootstrap.inc:2523
4   2.3001  4800256 menu_set_custom_theme( )    ...\common.inc:5301
5   2.3001  4800256 menu_get_custom_theme( )    ...\menu.inc:1780
6   2.3492  4810968 menu_get_item( )    ...\menu.inc:1765
7   2.3517  4810992 menu_rebuild( ) ...\menu.inc:468
8   2.3594  4812928 menu_router_build( )    ...\menu.inc:2775
9   4.1009  11234688    views_ui_menu( )    ...\menu.inc:2812
10  4.1009  11235504    views_get_all_templates( )  ...\views_ui.module:33
11  4.1185  11250128    node_views_templates( ) ...\views.module:1395
12  4.1250  11259832    views_db_object->new_display( ) ...\node.views_template.inc:24
13  4.1251  11259832    views_db_object->add_display( ) ...\view.inc:2431
14  4.1251  11259832    views_fetch_plugin_data( )  ...\view.inc:2335
15  4.1258  11326056    _views_fetch_plugin_data( ) ...\views.module:1304
16  4.1550  11349528    views_discover_plugins( )   ...\cache.inc:145
17  4.1595  11350584    entity_views_plugins( ) ...\plugins.inc:414
18  4.1652  11350624    views_fetch_data( ) ...\entity.views.inc:320
19  4.1652  11350624    _views_fetch_data( )    ...\views.module:1293
20  4.1665  11350696    _views_fetch_data_build( )  ...\cache.inc:75
21  4.1665  11350696    module_invoke_all( )    ...\cache.inc:90
22  6.4209  14253608    field_views_data( ) ...\module.inc:963
23  8.1812  17633680    module_invoke( )    ...\field.views.inc:32
24  8.1813  17633952    image_field_views_data( )   ...\module.inc:926

I use acquiadev environnement on windows, with drupal 7.51, php 7.0.

Any hints ?


texts: What is the relationship between hook_cron() and hook_cron_queue_info()?

texts:
Some modules (e.g. Feeds, Rules Scheduler, Revision Scheduler) implement both hook_cron() and hook_cron_queue_info(). When used with Ultimate Cron and the Enable cron queue processing setting enabled, this causes two jobs to appear in the jobs list. Are both jobs necessary?

Taking the Revision Scheduler module as an example, its hook_cron() seems to add items to the queue:

function revision_scheduler_cron() {
  $ids = db_query("SELECT * FROM {revision_scheduler} WHERE time_scheduled <= :now AND time_queued = 0 AND time_executed = 0 ORDER BY id ASC", array(':now' => REQUEST_TIME))->fetchCol();
  if ($operations = revision_scheduler_operation_load_multiple($ids)) {
    $queue = DrupalQueue::get('revision_scheduler');
    foreach ($operations as $operation) {
      if ($queue->createItem($operation)) {
        db_update('revision_scheduler')
          ->fields(array('time_queued' => REQUEST_TIME))
          ->condition('id', $operation->id)
          ->execute();
      }
    }
  }
}

whereas its hook_cron_queue_info() function calls a function that processes single revision operations:

function revision_scheduler_cron_queue_info() {
  $info['revision_scheduler'] = array(
    'worker callback' => 'revision_scheduler_operation_process',
    'time' => variable_get('revision_scheduler_cron_time', 30),
  );
  return $info;
}

Is it the case that hook_cron() adds the items to the queue and hook_cron_queue_info() processes them?

The documentation for hook_cron_info() says this:

  While there can be only one hook_cron() process running at the same
  time, there can be any number of processes defined here running.
  Because of this, long running tasks are much better suited for this
  API. Items queued in hook_cron() might be processed in the same cron
  run if there are not many items in the queue, otherwise it might take
  several requests, which can be run in parallel.

I'm not sure how to interpret that, but it seems to suggest tasks should be processed with one or the other.


texts: How to filter a view on a property of optional entityreference-related content (table join / views relationship)?

texts:
Consider this example: we have three content types: Concept, Language, and Word.

The Word content type has two entityreference fields:

field_concept references concept nodes, and
field_language references a language node.

The view shoud list all existing concepts, with related words (referencing the concept via entityreference) in a second column. The words are optional; we always want to show all concept nodes. We can accomplish this by creating a non-required Views relationship based on the field_concept entityreference (Entity Reference: Referencing entity). (This results in a LEFT JOIN in SQL).

The problem is how to filter words on the field_language value, without filtering out any of the concepts. Consider the following data.

Concept | Word   | Language
---------------------------
CAT
DOG     | Hund   | German
DOG     | chien  | French
FIRE    | fuego  | Spanish
WATER   | Wasser | German

Say we want related words (if any) filtered on a particular language. The desired views result for German is this:

CAT
DOG     | Hund
FIRE
WATER   | Wasser

We cannot use regular (grouped) filters with a condition like field_language = German OR field_language = NULL: while this would show CAT, DOG and WATER, it would remove "FIRE" from the results, since there is a Spanish result for FIRE.

So it seems we need to have a condition on the JOIN itself, preventing any words other than German ones to be joined. This question somewhat addresses how this should work, but: how would I access the field_language values? This is the basic query created by Views to show the concept and word titles - I'm not seeing how I should modify this:

SELECT node.title AS node_title, node.nid AS nid, field_concept_node.title AS field_concept_node_title
FROM
{node} node
LEFT JOIN {field_data_field_concept} field_data_field_concept ON node.nid = field_data_field_concept.field_concept_target_id AND (field_data_field_concept.entity_type = 'node' AND field_data_field_concept.deleted = '0')
LEFT JOIN {node} field_concept_node ON field_data_field_concept.entity_id = field_concept_node.nid
WHERE (( (node.status = '1') AND (node.type IN  ('concept')) ))

It seems we cannot use the field_data_field_language.field_language_target_id value as a condition on the first LEFT JOIN without having another JOIN first, which would defeat the purpose - or am I missing something?

Can this be achieved with Views? Or are there alternative ways of doing this?


texts: Creating a "scrapbook" node type using an entity reference field

texts:
I'm building a site that includes two node types, "scrapbook" and "press clipping". A user can create multiple scrapbooks which are either public or private, and they can also add press clippings to a public pool.

Each scrapbook includes an entity reference field that allows multiple press clippings to be referenced from each notebook. This works fine, but the only way I can add a reference from a notebook to a press clipping is by editing the scrapbook. I want to include a dropdown on each press clipping that allows the user to select one of the scrapbooks they have created and add the press clipping to that scrapbook.

What's the best way to achieve this result?


texts: How to build a dynamic user-page from LDAP (Active Directory) and show this page after logged in?

texts:
I have Open Atrium 2 with Drupal 7. User are able to login over the active directory using the Lightweight Directory Access Protocol (LDAP) module, which works pretty well.

After login the user should come to its own personal page. In which the user can see his/her personal data and so on. But how to create a dynamic page like a template for this personal page?

I couldn't find any similar on the net. Any help I would appreciate.

Edit:

My first step is: After Login over LDAP (active directory) getting all personal data and lead every person to his own page with all this personal data in it.

Can I do this with some appropriate modules or do I have to script this in php or a mix of both (scripting and modules)? And which modules or plugins for Drupal with Open Atrium 2 can help me to get this?


texts: Configure Australian GST Taxes on Commerce Kickstart 7.x-2.14

texts:
I would like step-by-step instructions as to how to configure Australian GST Tax on a Commerce Kickstart site, if possible using configuration only.

The business rules are:

Primary Objevctives

Australian GST tax is 10%.
It has to be included in the quoted price. So an item that is quoted as $11 would contain $1 of GST.
The amount of contained GST has to be displayed as a separate item in the bill.
It is only applied to orders being sent to an Australian shipping address. This includes the shipping cost itself, which is GST-free for orders going overseas.
There can be GST-free items, which don't incur GST whether they are sent overseas or not.

Secondary Objectives

Related to the third item above, technically one is not meant to show separate "(tax-free) Subtotal" and "Included GST" rows but for the time being I'm willing to ignore this legal requirement.
Somewhat related, instead of just removing the GST for overseas orders I would prefer to still show the contained GST amount but have the line item as something like "GST (removed)" and then not have it included in the calculation. My gut feeling is that these two secondary objectives are related.
There seems to be an issue that sometimes crops up if I'm testing within the one browser and it remembers my previous shipping address, so that when I change to an overseas shipping address between orders it doesn't update as I would have expected. Might be a bug in Commerce though, and I'm expecting this to be an edge case.

My basic strategy so far has been:

Do a clean install of the latest Commerce Kickstart via Aquia Desktop
Write out a strategy of how I'm going to implement the tax
Implement using a combination of things based on Randy Fay's Conditional Tax video, commerce_australia module, various other patches/tax removal modules/etc that are buried in drupal.org
tweak until I realise that I'm no closer. Pull out hair. Take a walk and try to come up with another strategy. Rinse and repeat.

Also, is anyone able to give me a clear answer to what the difference is between how the tax is applied in Rules as opposed to if I access it from Taxes-->Configure Components?

Apologies for the long post but I'm honestly at my wits end here. I can give more information on what I have tried so far but I'm worried I may pollute the responses.


texts: Do tokens work with Rules "Set a data value"?

texts:
I have a simple Rule created in which the action is that a particular entity is created (a node) and then another action is called to "Set a data value" of one of this node's field (a standard text field). In the Rules action I setup the tokens that I want to be put as data into this field. For some reason the tokens are not showing up properly when the entity is created:

I have tried a few different combinations but as you can see above the token I am using (node:author:link) does not display properly when the node is created. What is the reason for this? I have experimented with all of the different input filters but it does not seem to work for any of them.


texts: Using Panels and Views to Display Information from Entity Reference

texts:
I'm currently work on a site that manages retail stores and visits made by salespeople to those stores.

I have the following two content types:

Store:

    contains basic store information: address, phone number, etc

Sales Survey:

date of sales call
salesperson
general info gathered on call
Entity Reference to the Store

I'm currently working with panels to create a custom display for the store content type and I would like to include a section showing the 5 most recent sales calls made to that store and the information about that call.

I've been trying to create a content pane in views to include in the panel for the store node display, but I can't figure out how to access all Sales Surveys that reference the store that is currently being displayed.

Any thoughts?

I'm using:
Drupal 7
Panels3
Views 3
Entity Reference

Let me know if I can provide further clarification, I think part of my problem is just in wrapping my mind around all the things I'm trying to bring together and I'm still very new to Drupal.  Maybe I'm going at this in the wrong way?

Any help is appreciated!


texts: Get Block object from A view block object

texts:
I have a custom module with the following function:

function custom_hide_product_range_views_post_execute(ViewExecutable $view) {

  if ($view->id() == 'brand_product_range') {
    if (count($view->result) < 2) {
        $view->display_handler->setOption('css_class', 'hide');
    }
  }
}

This hook_views_post_execute is removing the view if it has less than two results.

There is another block that depends on this block, so I cannot just remove the whole block I have to hide it using CSS

1- What I would like to do:

The problem is The view is hidden but the block (parent of view) still exists so the title of the block still exists, How can I get the object of the block from the $view variable, so I can hide it as well?

2- Failed approach!

I tried to go the other way around by using hook_block_view_alter to get the block then get the view object from the block object, this approach failed because (I think) the block is constructed first, the view inside the block was yet to be constructed and it contained no results at all.


texts: Views with attachment - How do I exclude pagination offset on every page but the first?

texts:
I have a view with an attached view to display the first row with different fields and markup. This works perfectly except for when you start using the pagination.

When I press another page (in the pagination) to load the next group of rows, I don't want either the attached view nor the pager offset.

I've seen some solutions which rely on showing rendered nodes with a different view mode for the first row. I would very much like to find a solution which is compatible with fields instead.

My main problem is that when you've started going through the pages, the first row is always skipped. Even though that is the expected behaviour, it's not how I want it to be.

Here's the pager settings for the default display and the attachment display.

Pager settings

Default display:

Attachment display:

The rendered view

Here's how the rows are rendered on the first and the second page.
The blue box represents all rows (in my case only 1) from the attachment display and the red boxes represents the rows from the default display. The number in the boxes is the row id.

Please note how row 9 is never shown.

First page:

Second page:


texts: How to use views to make queries on the webform (or entityform) results and show in a node?

texts: Do you know how to use the Views module (or any other "query builder") to filter/query the submissions made either by webform or entityform?


texts: Modules installed with Composer placed in wrong directory

texts:
I'm trying to install modules via Composer. I've set up my composer.json file according to Drupal.org's direction. However, the installed modules are being placed inside of vendor/drupal/. I'm new to Drupal 8, so I wouldn't be surprised if this is a result of a simple mistake. I'll include my composer.json file below:

{
    "repositories": {
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    },
    "require": {
        "drupal/admin_toolbar": "^1.19"
    },
    "extra": {
        "installer-paths": {
            "core": ["type:drupal-core"],
            "libraries/{$name}": ["type:drupal-library"],
            "modules/contrib/{$name}": ["type:drupal-module"],
            "profiles/contrib/{$name}": ["type:drupal-profile"],
            "themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/{$name}": ["type:drupal-drush"],
            "modules/custom/{$name}": ["type:drupal-custom-module"],
            "themes/custom/{$name}": ["type:drupal-custom-theme"]
        }
    }
}


texts: eck entity reference field not displaying custom fields

texts:
I created two entities using eck module, entities A and B.

Entity A has text field and I want it to be searchable and displayed in entity reference autocomplete.

I created entity reference view for entity A, and I set my custom field to be searchable.
In view preview, content is normally displayed.

Entity B has entity reference field, where I target entity A.

I edited reference field by setting:

Reference Type -> Reference Method: Views: Filter by an entity reference view

And View used to select the entities: ENTITY_A_reference_view - Entity reference

Now in entity B add/edit form I'm using autocomplete widget, and search works, but display doesn't.

All I'm getting is ID.

(other widgets are empty as well)

I guess it's because it's still using only ID and Title fields for display, and I'm not using title as property so it's empty.

So how can I display custom fields instead of default?


texts:
I am trying to change the states via the the following code:

function my_module_form_alter(&$form, &$form_state, $form_id) {
  ...
  case 'my_form_node_form': {
    $form['my_file_field']['#states'] = array(
      'visible' => array(':input[id="my_id"]' => array('value' => 'my_value'),
    ),
  );
 }
}

but, my file field is not becoming visible after my input id is selected, instead is already visible.


texts: How to add a default controller to the  route?

texts:
Is it possible to add a default controller to the '<front>' route? There's no default controller defined in system.routing.yml.

I'm trying to get a handle on it by using the following code:

<?php

namespace Drupal\mymodule\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    // Get front page and set controller.
    if ($route = $collection->get('<front>')) {
      $route->setDefault('_controller', '\Drupal\mymodule\Controller\MyModuleController::MyModuleMethod');
    }
  }

}

But it doesn't seem to do anything. However this code works when replacing '<front>' with another route like help.main. Why is that? Do I have to add the controller instead of setting it?
(D8)


texts: Load Colorbox multi image gallery from node display

texts:
I need help understanding/implementing display of multi images from a node directly to a colorbox popup.

I've created a new content type with an Image field, set to allow unlimited images. Revised display setting to colorbox.

I've loaded multiple images into the node.

Use case 1: From menu item, directly display a colorbox popup which references a node's images 1 of n (I don't need/want to display the node) .

For this use case, I've added the specific node number in the Path and added colorbox-load class. The result of this, clicking on menu item, the node displays with images (as colorbox popup), then when I click on any image, I get the colorbox multi-image popup (which hangs the page).

How do I go direct to colorbox multi-image popup from a menu rather than seeing all the images in a node first?

Use Case 2: Create a link within an article page to directly display a multi-image popup of an individual node's images.

I've created an  tag, added colorbox-load class, and get same results as above.


texts:
It vanishes suddenly without any notifications today. I am using Drupal 7 with "Mix and Match" theme. I used to working this morning.

Website shows no error at all.

I have tried the following to get it back:

Find the block table in the database and tried to modify the visibility of the user, login of current theme entry - not working
At admin->structure->blocks, under the current theme. The "User login" is already under sidebar first. I tried remove it and add back, changing the weight - not working
In the other themes the user login block does not show up either, including the default theme Bartik.
Repeat the above steps with a drush cc all command. Not working.

What else could I try to get it back?


texts: How do I change the top picture for blueprint theme?

texts: I just need to change the top image of the website to another image. The website is using Drupal 6 and the Blueprint theme. I am able to get to the theme building page, is that the right place to start?


texts: Drupal implementing an advertising takeover with page background image

texts:
I need to implement a background image advertising takeover that surrounds the page content in drupal. It's similar to the ones on ign (screenshot attached below).

The only ways I can think of seem really hacky, such as using a view block to display one result of a custom content type containing the image and showing the view in a custom region that spans the background of the page.

Can anyone think of a better way? It needs to be easy to set up in the CMS for an administrator and they need to be able to create different takeovers for different sections of the site.

Thanks


texts:
I am on Drupal 7. I was on a hosting company that would give me only 64MB of PHP Memory. That led to several issues when installing new modules. My website would run short of memory and would brake right after installing the module. But when reloading the modules page, the module would prove to be installed and working. I confess I kept on playing with fire until I finally broke the installation of one of my modules. It was Menu Blocks. The module would appear as installed, but clicking on the Configuration link on the Modules page would lead me to the wrong page. I couldn't reach the module configuration page. To make a long story short: the installation failed.

I swiched to a new host with more memory and now I am OK. But I still can't install Menu Blocks. I have tried disabling it and reenabling... Nothing. Still not working. Then I disabled AND uninstalled it. Then reinstalled. Nothing happens, still the wrong behavior for the module configuration page. What do I need to do to really and completely uninstall any problematic traces it could have left on my Drupal install? Completely delete Menu Block's tables on the database in case they still exist in there? If I completely remove those tables, do I risk breaking up my website? Completely deleting the Menu Block package, then restarting? I thought this wouldn't solve the problem... Any help appreciated, thank you!


texts: Create user login programmatically in Drupal 7

texts:
The questions is very simple and the task is difficult.
Which functions I need to create a new login form from scratch in Drupal 7?

The reason I need this is because I modified the default login form. It connects to a web service with two different methods and it has different validates, depends from a user roles and lots of customized stuff.

Right now to login as admin, I have to comment my custom module, so I can use the default login form.

I need to create a new login form on different page that will be dedicated to admin user.


texts: How to use data in fields from one node to create a new node of different content type?

texts:
I have a content type called "Submit a photo" where anonymous users can upload a photo alongside with their name, email and short description. And I have another content type where an admin uploads images and publishes them as "Looks", and Looks are more complicated content type, with image tags, categories ...

Than I have a view which lists all of the submitted images so that an editor can pick and create new node "Look" using existing fields. But I'm looking for a way to somehow pre populate fields in that new content type with fields of "Submit a photo".

So editors can review all the images that are submitted by anonymous users. If they like one, they click “Add new Look” or something like that, which opens a new “Add Look” form using that image.

Should I look at nodereference or something like that?


texts: Cache sometimes is not being updated on saving operations

texts:
This is a problem I'm struggling with for a few months already. I'm maintaining a pretty big news website, with a lot of content and multiple editors. The website is using paragraphs (which I don't think is relevant to the core of the problem, but is relevant for the description of it) and Memcache modules. Editors can rearrange the blocks on the front page, add/edit articles etc. The problem is that occasionally (and sometimes pretty often) when editors will do something on the website (edit article, rearrange blocks), change won't be visible on the website. It won't be even visible in the edit form of the just edited node when they will try to edit it again. It will appear after few approaches.

I know that in fact the change is being made after the first time, because I can reappear it with the dmemcache_object()->flush();, which made me think that it is a problem with Memcache. However, I replaced it with Redis and there is no improvement.

Some more information about the problem:

Core cache is basically disabled as we are caching everything in the CDN, but editors have direct access to the website, without CDN, and experience this problem there, so it is not CDN related. Below are website's cache settings.

I cannot reproduce the problem locally, even if I'm also using Memcache/Redis.
Sometimes when they are creating a new node with paragraphs, it appears "empty". During the edit, there are also no paragraphs. However dmemcache_object()->flush(); seems to fix this problem and makes everything appear (I tried it few times).
I tried even to add dmemcache_object()->flush(); to the save/update hooks, but it didn't help.

Any ideas of what can I do to diagnose and fix this problem? It is particularly hard to approach because it happens only on the production server.

Added #1:
When using redis module, and adding to settings.php:

$conf['path_inc'] = 'sites/all/modules/contrib/redis/redis.path.inc';

Problem expanded on paths. Some nodes had paths in the form of node/[node_id], but after removing this line, and clearing cache - proper, aliased paths has been restored.

Note: database is located on the different server.


texts: Remote Entity Create with Node Reference

texts:
I am writing an Android app which is creating Drupal nodes remotely.  I am creating these nodes via a straight php form.  But now I need to create Nodes which are node_references of the main node.  Usually in order to do this you will need the entity ID of the main node before you can create a node reference.

Creating the second node as a reference should be easy as it is just an extra field with a reference value in it.  The problem is, once the App creates the main node, I need the entity ID to be returned to the App so that the value can be used to create the other referenced node.

How do I get the entity ID back as a return value after node creation?

or... am I thinking about this all wrong  :)


texts: How to use multiple values for an exposed filter via url

texts:
On my current setup I'm exposing a view that outputs json through a service.

The view can be called like this: http://domain.com/api/books.json.

I also exposed a filter to a referenced content type "Author". I'm NOT using context filters, I'm using the regular Filters and exposed that particular filter to the user, this way I can give my filter a nice argument name author_nid.

So now I can call this: http://domain.com/api/books.json?author_nid=38. And this returns all books of the author with that nid.

But I can't seem to figure out how to get the list of books of both author 38 or author 32.

The things i tried:

http://domain.com/api/books.json?author_nid=38,32

http://domain.com/api/books.json?author_nid=38+32

http://domain.com/api/books.json?author_nid[]=38,32

http://domain.com/api/books.json?author_nid[]=38+32

http://domain.com/api/books.json?author_nid[0]=38&author_nid[1]=32

I seem to have the feeling that this isn't supported right now. Am I correct? If so, what are my options? I'd like to give my arguments a name because I'm about to expose 10 to 15 filters (some optional, others required). Using context filters and filtering like this: args[]=2&args[]=43,23&args[]=44 isn't very readable/maintainable.


texts: Path to theme within a module / jQuery context?

texts:
I've written a custom D7 module as a companion to a theme I've contributed to drupal.org and in the module, I effect output of the logo image with some basic jQuery as such:

$("li.purple").click(function () {
$('#logo-img').attr('src', '/sites/all/themes/mytheme/images/logo-purple.png');
});

$("li.green").click(function () {
$('#logo-img').attr('src', '/sites/all/themes/mytheme/images/logo-green.png');
});

etc...

Now this works fine but ideally I'd like not to have to hard code the theme path as above, it would be great to have a variable instead.

I did some searching and found a drupal docs page, "Pass the theme path to javascript", but I can't really make heads or tails of it within the context of what I'm trying to do. There's a preprocess function on the aforementioned docs page that supposedly can tell jQuery what the path to the theme is but I don't quiet understand the usage in terms of actually creating a theme path variable.  So from this:

function my_module_preprocess_page(&$vars) {
  drupal_add_js('jQuery.extend(Drupal.settings, { "pathToTheme": "' . path_to_theme() . '" });', 'inline');
}

I need to extract the path variable and put into this:

$("li.green").click(function () {
$('#logo-img').attr('src', pathToTheme + '/images/logo-purple.png');
});

... However, I get this error:

Uncaught ReferenceError: pathToTheme is not defined

... so I'm just struggling how to get this to work or if it's even possible.


texts:
I'm working on a views to show different events in a calendar. I want to be able to filter on terms (In my view the field is called 'Wat?' for terms like music, art, design, etc). For this I create a filter criteria with an exposed filter for these taxonomy terms.

When I filter on film, only the film items are shown, perfect!

But now I want to make a complex filter by using filter groups. In both groups I want to use this genre filter. So I add another one. But for some reason this doesn't work, when I select film on both dropdowns and click apply it doesn't work anymore, and no results are given. I created a simplified view to test this. Here are images of my filter, and the use of it.

This is my complex filter

Using one filter gives results

But when selecting the film in both I get no result


texts: Saving multiple field values in a users entity

texts:
I am trying to reference other nodes on the user entity on field_clinic but everything else is saving except that multiple value field. What could i be doing wrong. The field_clinic accepts multiple values. Below is my code:

$clinics = [

        array('value' => 132),
        array('value' => 133),
        array('value' => 134),
    ];

    // if the user exsists update basestation
    $UserEntity = User::create([
        'name' => 'Final',
        'roles' => array('subscriber'),
        'field_age' => '2',
        'field_city' => 12,
        'field_clinic' => $clinics,
        'field_base_statition' =>  $bs_nid

    ]);

    $UserEntity->save();

The clinics array contains the node ids that I am trying to reference. Please help


texts: Druapl 7 Update displayed price of product when quantity changes

texts:
I'm new to drupal. What I want is the price to be updated for an ubercart product when I change the quantity the same way it happens with the attributes on the product page.

So far I have a custom module to edit the type of the edit quantity form when I add a product in my cart. I turned it to a select box and tried to append the class ajax-processed but nothing happens.


texts: Menu elements not being links, just to create submenu?

texts:
Is there a built in or module way to add menu items with hook_menu to serve as containers, not links? I have a module set. Main module provides central configuration and satellite modules do actual work. main module should create submenu satellite modules will use to add their entries to, but there is no form nor page to put in the main element. Is there a way to avoid dummy content?

I want to avoid editing template.php - I use theme downloaded from drupal.org and I don't feel creating a subtheme to get that is really worth the effort - there should be an easier way, shouldn't it?

I know there are ways to do this with Menu UI, but I need it to work out of the box for my clients, so UI is not an answer.


texts: How can I programmatically set a default select option in for loop?

texts:
I have a for loop in my code that creates elements in a table using data from the database. Each row has a select element, where the default option should correspond to what's stored in the database:

$listmode = [
    '#type' => 'select',
    '#options' => [
        'none' => t('Unlisted'),
        'black' => t('Blacklist'),
        'white' => t('Whitelist'),
    ],
    '#attributes' => ['id' => ''],
    '#default_value' => '',
];

$rows = array();
foreach (BlocceConfigStorage::getBlocks() as $block){
    //I really wish there were a better way to do this
    if ($block->listing == null || $block->listing == 2){
        $default = 'none'; //set select to unlisted
    }
    else if ($block->listing == 0){
        $default = 'black'; //set select to blacklist
    }
    else if ($block->listing == 1){
        $default = 'white'; //set select to whitelist
    }
    $listmode['#default_value'] = $default;
    $pre = $listmode;
    $pre['#attributes']['id'] = 'select-block-'. $block->id;
    $tlist = drupal_render($pre);
    $rows[] = [
            'data' => [$block->id, $block->info, $tlist]
        ];
}

I attach the generated rows here:

$form['table'] = array(
    '#type' => 'table',
    '#header' => $thead,
    '#rows' => $rows,
    '#attributes' => array(
        'id' => 'blocce_blocks',
        ),
    );

I've tried messing around with the sample found here and adding a single listmode select to the form and setting the default. Both of them worked on their own; I've also tried pre['#default_value'] = $default, but that also was availed me nothing. I suspect that the problem either lies in the drupal_render($pre); (without this, however, the selects refuse to show up) or that the for loop itself is the problem.

Tl;dr: How do I set the default select option in the for loop?

Edit: I'm using Drupal 8, but from what I've seen, this doesn't seem to have changed much from Drupal 7.


texts: Ajax Multiple form request not working properly

texts:
I have one form with multiple fieldset's, each fieldset has one form element. When the form element changes then the ajax callback should get triggered. This ajax callback changes the fieldset class and returns $form.

This works perfectly when first fieldset gets changed. When I change the value in second fieldset and second ajax callback is triggered, the second fieldset gets changed but the first one is back to normal, it is like drupal forgot the changes  which I made in previous callback.

If it makes any difference, i have tried with $form_state['rebuild'] = TRUE; in my ajax callback but it is not helping...

Simplified code looks somethig like this:

function ajax_form_callback_function($form, &$form_state) {               $form_state['rebuild'] = TRUE;
$key = $form_state['triggering_element']['#name'];
if ($key == 'key_1'){
    $form['some_fieldset_1']['#attributes'] = array('class' => array('new-  class'));
}
else if ($key == 'key_2'){
$form['some_fieldset_2']['#attributes'] = array('class' => array('new-class'));
}
else if ($key == 'key_3'){
$form['some_fieldset_3']['#attributes'] = array('class' => array('new-class'));
}
return $form;
}`


texts: Stop User From Publishing an Event if the Start Date is Before a Certain Month Using Rules

texts:
I'm working on a development site that will not be launching for a few months. I'm looking to create a rule that will not allow a user to publish an event if the event's start date is prior to launch. I am using the date field in this content type.

How could I accomplish this with rules? Thanks!


texts:
I set up the Services module as REST server, so I can create nodes with custom fields by REST client as in Services 3 - POST node.create with custom fields.

The settings of the Services module are the following.

Server => REST
Path to endpoint => "neoapi"
Session authentication => yes
Response formatters => json
Request parsing => application/json & application/x-www-form-urlencoded
Resource path => http://127.0.0.1/neoapi/node

Content type => mycontent
Term reference field => Autocomplete term widget (tagging)

And post next JSON data via Google Chrome Advanced Rest Client

{
"type":"mycontent",
"title":"The New Article",
"body":{
  "und":[ {
    "value":"This is the body of new article."
    } ] },
"field_neo_terms":{
  "und":[ {
    "tid":"3"
    } ] }
}

At REST client I receive "200. OK" NID and URI of new node. But in site i have new node with title and body, but without terms and error:

Warning: mb_strlen() expects parameter 1 to be string, array given in drupal_strlen()
(line 441 of C:\Program Files\VertrigoServ\www\includes\unicode.inc).
Warning: preg_match_all() expects parameter 2 to be string, array in   drupal_explode_tags()
(line 7254 of C:\Program Files\VertrigoServ\www\includes\common.inc).
Warning: array_unique() expects parameter 1 to be array, null given in drupal_explode_tags()
(line 7255 of C:\Program Files\VertrigoServ\www\includes\common.inc).
Warning: Invalid argument supplied for foreach() in drupal_explode_tags()
(line 7258 of C:\Program Files\VertrigoServ\www\includes\common.inc).


texts:
I have two modules that both extend NodeForm the usual way:

function MY_MODULE_entity_type_alter(array &$entity_info) {
  $entity_info['node']->setFormClass('default', 'Drupal\MY_MODULE\Form\MyModuleNodeForm');
  $entity_info['node']->setFormClass('edit', 'Drupal\MY_MODULE\Form\MyModuleNodeForm');
}

As far as I can tell (both from actually looking into what setFormClass() does and simply trying out) this is a race condition that only one of them can win. Although they both want to deal with different content types and what they do would not conflict at all, they can't coexist. With the old, 7-style alter and submit functions, this could be solved but what would be the proper 8-ish way to do it? Both modules are mine, I can combine them if necessary but that wouldn't be really elegant.


texts: How can I find webform e-mail submission values keys?

texts:
I created a Webform and now I want to send an email on submit to the customer. But I'm not understanding how to take the submission values one by one and use it in the email body.

The submission tokens description says:

  %value[key] - A value without additional formatting. Elements may be
  accessed such as %value[fieldset_a][key_b]. Do not include quotes.

What kind of key the %value array have got? How can I find they?


texts: Is there a temporary fix for a deprecated module that prevents cron from running?

texts:
I have a client D8 site that is using the Field Collections module, which is no longer supported. We are working on migrating Field Collections to Paragraphs, but in the meantime the Field Collections module is throwing an error that prevents the cron from running:

Message   Error: Call to a member function isDefaultRevision() on null in Drupal\field_collection\Plugin\Field\FieldFormatter\FieldCollectionListFormatter->viewElements() (line 45 of /code/modules/field_collection/src/Plugin/Field/FieldFormatter/FieldCollectionListFormatter.php)

I'm looking for a temporary workaround for this issue that will allow the cron to run while we're getting everything moved over to Paragraphs. Some kind of patch to Field Collections? A preprocess function that bypasses the issue for this particular instance? Any suggestions?


texts:
I have created a content type called 'landing', however when I try and setup this as my homepage

config/system/site-information to the alias 'landing'

It takes on the node--front.tpl.php as the template rather than my node--landing.tpl.php.

If I look at it in /landing the page looks fine.

I also try and hijack the main landing page by setting this in the .htaccess

DirectoryIndex landing

but no luck - any idea how I can set this custom landing pages as my homepage and retain the template style?


texts: How do I consume REST data with an external service?

texts:
I want to integrate RESTful API with drupal 8.

What I want to achieve is my a project which is built in drupal 8 is the consumer and RESTful API is integrated into another website using CodeIgniter.

I want to create a page in drupal using routing and all data will be coming from another website.

Example:

http://mywebsite.com/products [drupal 8]
http://webservice.com/products/list.json [CI]

My website will consume web service of webservice.com and will display the products on my website.

What is the better way or structure to achieve it?


texts: Is it normal that Organic Groups group creator is not automatically "Administrator member"?

texts: I am getting my head around OG and its permissions. I have a user (not super-user uid=1) who can create OGs. Rather to my surprise, when I look at the OG members, the user who created the OG is there as a member but has not been given the "Administrator Member" role. Yet he seems to have full management rights on the Group rather like a local super-user. Does this mean that he should create an "Administrator" separately?


texts: How to render a node with absolute URL to use in a mail?

texts:
I have to send node content by mail using an API. I manage to load and render the content to use it with my API class, and to send it.
But when Drupal render the node, all URLs and image SRC are relatives, and it can't be used in a mail.

Here is the code I got so far

$node = \Drupal::entityTypeManager()->getStorage('node')->load($test_node); // $test_node is a (integer) NID
$renderBuilder = \Drupal::entityTypeManager()->getViewBuilder('node');
$node_view = $renderBuilder->view($node, $view_mode); // $view_mode is define in my admin settings
$html = \Drupal::service('renderer')->render($node_view); // I also tried renderRoot and renderPlain
dump($html); // URLs are relatives
exit;

I really search for days now, and I cannot figure how to tell Drupal Renderer to use absolute URL to generate the HTML string.


texts: I am using Drupal for facebook module to login into my drupal site. How can i get facebook user id after user login to my site. I want to store user details and give a chance to edit his profile. I can able to track firstname and Lastname,Email But i can not able to track user id.


texts: How To Display Node Tokens/Keys/Content Fields In Twig Template

texts:
I'm fairly new to theming with Drupal, especially using Templates and Twig. After a lot of searching and experimenting I seem that have accomplished my desired view mode the way I want...almost.

I have a field in my content type called Category. The machine name is field_category. I have been able to output the field in my template using the key: {{content.field_category}} But as you can see it also applies a CSS styling I have on the full default Node Page which I would prefer not to have it there.

Going at it a different way, I used a View along with the given replacement patterns and was given the token of {{ field_category }}. After everything was done it does the same thing without any CSS styling since it's not pulling in the HTML markup of class="field field--name-field-category".

My question is I wonder if there is a way to grab the value without the markup? And if so how? Any steps in the right direction would be very much appreciated, I am a complete beginner at Drupal and even more so with Twig. Thank you.


texts: entityreference_autocomplete -- Return list that contains

texts:
I am quite new to the D7 Form API, but nevertheless I've got the basics up and running...

I have a custom content type (A) and I want users to be able to submit some Information, which in turn will create one node of that type (A).

This type (A) has an entity Reference field to another type (B) and would like to have an autocompletion field to assist the user.

I have this code:

$form['production_ref'] = array(
    '#type' => 'entityreference',
    '#title' => t('Production Reference'),
    '#description' => t('The Production referenced'),
    '#era_entity_type' => 'node',
    '#era_bundles' => array('typeA'),
    '#era_cardinality' => -1

    '#era_query_settings' => array(
        'limit' => 15, // Default is 50.
    /*
        'property_conditions' => array(
          // 'entity property', 'filter value', 'operator'.
          array('uid', 30, '>'),
        ),

        'field_conditions' => array(
          // 'field name', 'column', 'value', 'op', 'delta', 'language'.
          array('field_test_field', 'value', 'test'),
        ),
  */
      )

  );

What creates an autocompletion field which is somehow working. But the result in the List looks somehow arbitray and does not return the relevant matches.

How can I tweak that, so that the query will take the typed Characters and tests each nodes´ (type B) title, if it contains these charackters?

I am using the "entityreference_autocomplete" module, which is hosted here

Thanks in Ahead!


texts: Cleanest way to write EntityCondition on field from widget

texts:
The widget is nodehierarchy_menu_links - it has a structure embedded in the node like:

[0]
-> [module]
-> [menu_name]
...
-> [pnid]

It has more than one value as per the widget system. I have a partial entity query, but want to filter on [pnid] i.e. show me all the nodes owned by uid and belonging to a particular parent. Is there an elegant to filter on these sub-items using the basic EntityFieldQuery?


texts: How to create dynamic select field with values from a view?

texts:
I need a dynamic select field to display a drop down box with results from a view. I'm using entityform to design the webform. Does anyone knows how to create such as a field?

The view is populated from a xml feed with data from an external database. View results will be an unformatted list, which is what I need to display in the drop down box within the form for users to select one.

Please help! I'm trying to avoid querying the external database to get the results. Thanks.


texts:
A little bit of introduction:
I have a specific content type with the name "Database" where i can add content and with the views module and Search API, the user is able to search on my site for that content.

When I was creating the fields for the content type i noticed there were no fields for "date". So I installed Date module that allows me to have a Popup Calendar. On "MORE SETTINGS AND VALUES" i managed to extend the year range for 10 years. So, when i am adding content i'm able to choose from 2004 to 2022. So far so good!

In the view I created, i added some filters to make it easy for the users to search in the database. One of them is "Search by date" and I was able to display the same popup Calendar.
My problem is: the year range is not the same. It is only 2011 - 2017 and i have no idea how to change that. Since is the same from the previous configuration it should work...

Sorry for the confusing explanation, i don't know how else to put this.

Hope you guys can help me! Thank you!


texts: How to get image with image style path to a twig template

texts:
I had created a field called tv_adbackground on the settings filed to be a ble to uplaod a background image.

The upload works great!

How to get the path of the file or the image style medium or thumbinal in to a twig template like this?

...


texts: How do you force drupal 7 to make a new revision every time you edit a node?

texts: I'd like to make drupal 7 create a new revision every time you edit a node? This was an option in Drupal 6 but not 7.


texts: How to set a datetime field = now() during insert?

texts:
I'm using db_insert() to insert a record into a table. That table as a "creationDatetime" field which should be set to now() on insert. I tried setting it to REQUEST_TIME, but that value is a unixtime value and not an sql datetime format so I get an error.

I suppose I could write a php function that will automatically format REQUEST_TIME as an sql datetime value and call that function every time I try to insert, but does anyone else have a better solution?


texts: Loading a custom library after all other libraries got loaded

texts:
So i wan't to load a custom .js file at the very end of the page after all other .js files have been loaded.

This is my library file:

my_library:
  js:
    assets/js/custom.js: {}
  dependencies:
    - core/jquery
    - core/drupal
    - core/drupal.dialog.ajax
    - core/toolbar.escapeAdmin

So the lib is loaded in the page footer with all the rest of the .js files, but it's not last, it's somewhere in the middle. I even tried to add the dependency for toolbar.escapeAdmin as it's javascript file is loaded the very last, as you can see from the picture bellow of the of page:viewsource, but it didn't work.

Any ideas?


texts: Get $form_state values from individual entity form fields

texts:
I have a weird use case. I created a custom form with some fields and I added some other fields from one entity form like this:

public function buildForm(array $form, FormStateInterface $form_state) {
    $entity_fields = array('entity_field_1', 'entity_field_2');
    // added other form fields here
    $entityForm = \Drupal::service('entity.form_builder')->getForm($entity, 'default');
    foreach( $entity_fields as $key ) {
        $form[$key] = $entityForm[$key];
    }
    // etc
    return $form;
}

I need to get the exact entity field widget because these fields can be updated from the interface and I can't have them hard-coded.

Now, If I submit the form, the form state values for 'entity_field_1', 'entity_field_2' are empty. $form_state->getValue('entity_field_1') is returning an empty array. Other fields defined manually are returning the correct value when saving.

How do I get those entity field values? In drupal 7 I used field_attach_submit() to attach the form values to an entity.


texts: Combine like products on the same line item in the cart

texts:
I am having the same issue as outlined here but the solutions below do not work. I do have "Commerce Product Option" enabled.

I also alter the price using this hook,

function mectronic_get_amount_qty($price, $length) {
    //print '
P ' . print_r($price, 1) . '
';
    //print '
L ' . print_r($length, 1) . '
';

    if ($length >= 1 && $length <= 5) return $price;
    elseif ($length >= 6 && $length <= 10) return $price * (1 - 0.166666667);
    elseif ($length > 10) return $price * (1 - 0.285714286);
}

I have tried

$entity->commerce_pricing_attributes[$set_id['set_id']][$field_name] = $price;

As in #4 but it does not work.


texts: Create and use a custom Account Email Template

texts:
I am trying to create a new Email Template for the Account object using hook_form_alter. Here is how I create the template:
function my_module_form_user_admin_settings_alter(&$form, &$form_state, $form_id) {
    // Adds the Course Link email template to the Account Settings form
    $form['email_course_link'] = [
        '#type' => 'details',
        '#title' => t('Course link'),
        '#description' => t('Edit the course link e-mail messages sent to mobile app users.'),
        '#group' => 'email',
    ];
    $form['email_course_link']['user_mail_course_link_subject'] = [
        '#type' => 'textfield',
        '#title' => t('Subject'),
        '#maxlength' => 180,
    ];
    $form['email_course_link']['user_mail_course_link_body'] = [
        '#type' => 'textarea',
        '#title' => t('Body'),
        '#rows' => 15,
    ];
}

This adds the email template to my Account Settings form, but I am having two issues:

When I go to edit the template and hit save configurations, nothing gets saved. The subject and body edits I made are wiped out and they no longer exist.

When I go to use the template via _user_mail_notify('email_course_link', $user) I get NULL as the response and there are zero errors to be found and I never get the email...

What else am I missing here?


texts: Corresponding Type and Size of Data Types in Drupal in order to create a table field in PostgreSQL

texts:
I was trying to create dynamically a table in Postgres using db_create_table function.

$schema = array(
    'description' => t ('Contains a particular templates data inputted from the MyID Inputting System'),
    'fields' => array(
                     'bigint_column' => array('type' => 'int', 'size' => 'big' )
                ),
);

db_create_table('myid_template_1', $schema);

The code above works fine. It creates a table myid_template_1 in my database with a column field bigint_column with a type of bigint.

I also wanted to create fields with the following type:

bit
boolean
character varying
date
double precision
time with timezone
time without timezone
timestamp with timezone
timestamp without timezone

What is its corresponding type and size in Drupal? It is somewhat missing in the documentation I read.

UPDATE 1:

Basing from Sir Mario Steinitz answer, I updated my code above.

$schema = array(
    'description' => t ('Contains a particular templates data inputted from the MyID Inputting System'),
    'fields' => array(
                    'bigint_column' => array(
                                           'type' => 'datetime',
                                           'size' => 'normal',
                                           'pgsql_type' => 'time with timezone'
                     )
                ),
    );

It was not working still. Am I missing something?


texts: Role wise editing and delete permissions on a node

texts: I have a drupal7 site and I need to implement this functionality into the site. I have two user roles(private and public), if a user of public role creates a node then all the users of public role should be given the edit and delete permissions for that node but the users of the private role should only be able to view the node and vice-versa. I have two views for two different roles and I want the edit and delete link to appear in those views for the user having same role as the role possessed by the node author, Please tell me how to achieve this programmatically as I have been searching for a module that can perform this functionality and there is no such module.


texts: How can I delete orphaned Product Displays?

texts:
Using Commerce Kickstart 2.

We have a number of orphaned nodes we would like to delete, ie Product Displays which reference no Product Variation.

I created a View with VBO which shows me these nodes, but unfortunately, it throws an error when attempting to delete since each orphan is missing certain required fields.

Is there a way to -force- VBO to delete these nodes (bypass the form validation for each delete?)

Or... is there a SQL Query you can recommend which will do the same thing (hopefully safely)?


texts:
i am building a website where many users will be able to add specific content. I want each content-node to have a link to the the authors profile page. I am using profile2 for users profiles and the alias of link in the node must be the "Company Name" field and not the username.

How can i achieve this?

Thank you!


texts:
I'm almost new with Drupal . so far i could do almost every thing i wanted by customizing the Bartik theme .
one problem i have right now is to change the main menu color "when selected". It has the same color as the site background and the only way to change it , is to change the site back ground color too , but i don't want that. I opened style.css file and there i could change any color of the menus except when they are selected. I think what i want to change is [#main-menu-links a:active] , but when i added this line : [background-color:#ff1221;] in it, nothing happens and it keeps having the back ground color of site when selected.
what do you think the problem is ?


texts: How to check the value of a field within the current node?

texts:
In order to display a block only above certain nodes of Article content type,
I created a boolean field with two values : On / Off

The goal is to display the block only above the articles that have the Off value

After enabling the PHP filter module, the block gives me this option : "Pages on which this PHP code returns TRUE (experts only)" but i haven't been able to figure out the php code that returns TRUE

( Can the context module achieve this without PHP ? )

Any help is help


texts: Services Entity REST Application - Update (via put) Field Collection Data

texts:
I am trying to figure out what the format and required parameters are for an update request to a field collection via the Services Module's REST API. I have installed the Services Entity API Module to allow interaction via Services with additional entity types.

I was able to save to a field collection when I first set everything up, using a PUT request, the CSRF token and properly formatted JSON.

{"field_fivestar_value":[
      {
         "rating":"100",
         "target":"0"
      }
   ]
}

which gave me this to access: field_fivestar_value['und'][0]['value'] which seemed to work perfect in the past, but now it seems that something is interfering/wrong as i get a notice after submitting a PUT request that $revision_id and/or $field_name aren't set, which never happened before...


texts: Panels Node template with additional arguments

texts:
The basic crux of what I'm trying to achieve is this:

When viewing a node - Content Type A (which is currently overridden with a panels node template) I want to be able to show a views block that will display the fields from one node of content type B.

To control which node from Content Type B would display on Content Type A pages, the idea was to set up a views pane with a contextual filter, so that any two nodes from hte two content types could be displayed together. This works fine by itself and in the preview.

But, I am having trouble getting panels to comply with my wishes!

I can set up a node template panel, but can't work out how to pass the second argument to the view pane. And I have tried to create a new panel to override the node so that I can pass the argument to the pane but it isn't overriding the node.

Any ideas how I can do this please?!


texts: Lightbox2 doesn't open html content and links

texts:
I installed Lightbox2 module and I tried to link an image to a webpage, say google.com, this is my code

<img  src="<?php print $base_url;?>/sites/all/themes/MY-THEME/image/fp/map.jpg">

but it displays nothing in Lightbhox. This is the print screen of the Lightbox using Firebug

as you can see there is nothing in body.


texts: 7 - How to Add Custom Error Class to Radio Button and Checklist Fields

texts:
I created a field with Radio buttons and when it fails to validate, there is no red highlight around it.

There is only an error message at the top.

How can I add a custom CSS class to any radio button fields upon a failed validation?

I am already altering this form with hook_form_alter(); and have a custom validation function, so I am willing to work on a custom module for this but just need some help being pointed in the right direction.

I would ideally like to add a ".error" class or something to this div and customize it in my CSS to also give it a red border.

How can this be acheived?


texts:
I recently saw that when I open of my sites as a anonymous user, a session cookie is set. I checked the database sessions table, and there is a line for uid 0 as well.
How can I prevent drupal from setting this cookie?

Greetings SG

This is what the cookie looks like in the session table:

Sry that the image is so tiny ...


texts:
I have always used CSS media queries on past sites for a responsive layout. Recently bumped into Drupal Mobile Tools dev.7 and liking it thus far. Trying to understand the purpose of it besides another method for a mobile site.

CSS Media Queries: Great if desktop / mobile sites are similar in functionality. Easy.

Drupal Mobile Tools: Need to load a different theme for major desktop/mobile site differences. Contextual layout. Exportable configurations.

Mainly looking for what is best practice out there. Can too many media queries put a major strain on a website with tons of hits or is Mobile Tools bit of overkill for any small/media site?

Thanks.


texts: How to show in different positions exposed filters in a View?

texts:
I would like to design my view in this way:

EXPOSED FILTER1             EXPOSED FILTER2

                            MyView resulting output...........
EXPOSED FILTER 3            ............................

EXPOSED FILTER 4

Which is the cleanest way to do it? I would like to avoid to absolute positioning items in css.


texts:
I would like to perform an actoin if the user's last access time was last month.

Would this be through hook_user(), when $op is equal to "after_update"?

I assume the last access variable would be updated, and I could check.


texts: Access denied for database user message on production

texts:
Our live D7 site suddenly created the white screen of death, followed by an access denied message for the drupal database user.

I was creating a new database for another version of the website in a different docroot, something I've done in the past with no problems. When that install didn't go well, I granted permissions to the new database to the same user as our live site.

I'm not sure why that had an effect on the live site or how to fix it. A MySQL query still shows that the drupal database user still has privileges:

SHOW GRANTS for 'dbuser';

GRANT ALL PRIVILEGES ON `drupal`.* TO 'dbuser'@'%' WITH GRANT OPTION


texts: Attach a script to a particular node ID or view

texts:
In Drupal 7, you can use the following code to attach a script to a particular content type:

function THEMENAME_preprocess_node(&$variables) {
  if ($variables['type'] == 'INSERT_CONTENT_TYPE') {

        // include javascript
        drupal_add_js(path_to_theme() . 'INSERT_SCRIPT');

      }

    }

What code do you need to use to attach a script to a particular Node ID or a specific View?

I have tried swapping variables['type'] with various items, but none seem to work.


texts: hook_update_N() for more than 100 updates or 10 major releases

texts:
The documentation for hook_update_N() says the following:

  Implementations of hook_update_N() are named (module name)update(number). The numbers are composed of three parts:

  1 digit for Drupal core compatibility.
  1 digit for your module's major release version (e.g., is this the 7.x-1.* (1) or 7.x-2.* (2) series of your module?). This digit should be 0 for initial porting of your module to a new Drupal core API.
  2 digits for sequential counting, starting with 00.

These are hypothetical questions:

What happens if you get to something like 7299? Are you required to release a major version update next even if you don't implement the hook, or if you do?

What happens if you have a lot of branches or major releases and get to something like 8900 and want to release a new one for that version of Drupal... 8(10)00? I know some modules go from 7.x-3.x to 8.x-4.x, so this could potentially happen if they continue in that way.


texts: How do I programmatically assign the access to a block?

texts: I have created a block programmatically but I don't know how I can programmatically assign the access to it. How can I achieve it?


texts: How can I override the Calendar module's theme functions?

texts:
I'm trying to override Calendar module's theme functions. Specifically, I'm trying to override template_preprocess_calendar_month() and template_preprocess_calendar_mini().

The override seems to work, but the problem is that the variables are processed/modified by template_preprocess_calendar_month() and template_preprocess_calendar_mini() before they reach the functions I implemented.

I need access to some of the theme variables before they are processed. Is there a way to do so?


texts: user_save() isn't saving the right password if it has an exclamation point

texts:
I'm creating a user programatically using the user_save() function. If I use a password with an !, @, etc., the function seems to save the wrong password to the database because I can't use it to successfully log in. The user is otherwise created correctly. If I don't use a special character like the ones I listed, I'm able to login with the password fine.

There isn't too much relevant code to show...

$edit['pass'] = $_POST['password'];
...
$user = user_save($account,$edit);

I have verified that $_POST['password'] and then $edit['pass'] have the right values. Any idea what's going on, or even how to troubleshoot further?


texts:
I sure I have succeed to use these snippets in previous code, but now I get a "Call to undefined function db_set_active()" error. I don't understand why.

public function allUnits() {
  global $dbUtil;

  $list = array();
  $qryStr = "SELECT * FROM unit ORDER BY u_id";

  db_set_active('mpd_pro');
  $rs = db_query($qryStr);

  while ($row = $rs->fetchAssoc()) {
    $list[$row["u_id"]] = $row;
  }

  db_set_active('default');

  return ($list);
}


texts: View filter - Show content that has 1 field matching another field in current node

texts:
I have a content type called Specifications which has 4 fields

Engine Specifications
Features Specifications
Variation (exposable filter)
Model

I also have another content type called Cars which has 1 field called Model too.

I am created a  SpecificationsView which displays the content-type Specifications as a block in Cars.

Is it possible to show in each Car the Specifications  whose model matches the current ''Car'' node's model?


texts: Selectively applying image style to a class

texts:
On a page that displays pictures that have two different classes, how to I apply an image style to one class and not to the other?

Or, how do I apply different image styles to images that have different classes?

Thanks. :)


texts: How to limit the words in search api autocomplete suggestion?

texts: I have a requirement to limit the words to show up in row of autocomplete suggestion. Now its showing titles but problem is titles are too long and suggestions are covering entire width of the screen. So any way to limit it? I checked with HOOK_search_api_autocomplete_suggestions_alter hook but not getting what is the attribute to limit this feature. Any help will be appreciated.


texts:
I would like to change the tpl.php file used depending on the taxonomy term applied to a node.

There is a snippet on this page that explains how to do that. However, it is written for Drupal 6, and doesn't work for Drupal 7.

The snippet is as follows:

// Add this to your theme's template.php
// Replace "THEMENAME" with your theme's name
function THEMENAME_preprocess_node(&$vars) {
  foreach ($vars['node']->taxonomy as $term) {
    $vars['template_files'][] = 'node-term-'. $term->tid;
  }
}

I have tried to update it for Drupal 7 as follows:

function THEMENAME_preprocess_node(&$variables) {
  foreach ($variables['node']->taxonomy as $term) {
    $variables['template_files'][] = 'node-term-'. $term->tid;
  }
}

However, it still doesn't work. I just get the following error message:

  Notice: Undefined property: stdClass::$taxonomy in
  THEMENAME_preprocess_node()  Warning: Invalid argument supplied for
  foreach() in THEMENAME_preprocess_node()

Any help would be appreciated.


texts:
I have several views that display data from the same content type, Customer.

I had to decide whether the view should display the teaser and format the teaser in a custom node--customer.tpl.php or to use Views ability to specify exact fields and format those. I decided to use Views to format the fields (under Format->Show->Fields) based on the preference to configure rather than code.

However, I don't want to duplicate this field formatting for each view that needs to display customers.  Is there a way to reuse the field formatting configuration from one view in a another? (besides cloning the entire view) And is there a way to keep them in sync?


texts: Redirect HTTPS to HTTP for a bilingual site

texts:
I set up a bilingual site pointing to 2 different domains for a client. My client then started receiving comments about unusual behavior, and digging a little I found out they (unknowingly) signed up for an HTTPS account while being on shared hosting and not having an SSL certificate.

I understand I can revert this by going to settings.php and force HTTP writing:

$base_url = 'http://example.com';

My question is if this is the correct way to handle this and I don't need to change anything else (like .htaccess); also, I have a different domain for a Spanish version of the site, could this domain be affected by pointing $base_url to the English domain? should I add both?


texts: Flag linked to a content, not to an user

texts:
I have custom content "Character". Each user can add several Characters.
I have another content type named "Item". Everyone can add several Item.

I want to create something like a "Whishlist" for characters, that means each user can link an item to a specific character to show that one specific character wants to have this item. This whishlist is not linked to an user but to a Character content this user created.

To create this relation, I thought about a Flag on items (like "Bookmark this !") but the flag is linked to an user, not to a content.
I have 2 solutions but i don't really like them.
1-I can add a node reference in Character content to allow creator to search for Items. But i'd prefer to make it easier : when a user sees an item he wants to link to one of his character, he can directly link it on the item page.
2-I can also add a node reference on Item content to allow a user to search for the character he "owns" and add the item to his whishlist. But how can I limit the node reference to the content the user has created ?

Do you see other ways to do it ?
how can I link a flag to a content but not an user ?

(sorry for my bad English)


texts: Sass error with zen 5, 'it is not clear which file to import

texts:
So, I'm getting what seems to be  a common error in working with SASS in a windows environment. "Error: It's not clear which file to import @import'print';" using zen 5.

I have tried changing the sass-globbing versions, and even tried different variations of the @import statements syntax (e.g. @import "print/", "print/", "print//" etc, nothing seems to affect the error.

The issue is that while there are plenty of people reporting this issue, there doesn't seem to be a clear picture of how to fix or address the issue, suggesting changing developing environment is not helpful.

At it's face, the issue is that the SASS parser can't seem to tell the difference between the partial _print.scss and the other empty print.scss files in the same folder.

Do I need the empty print.scss file, or can I rename it? Or can I rename the partial _print.scss to something else? Is there a non-hack way to fix this?


texts: Drupal Form API tableselect programmatically check or uncheck checkbox

texts:
I followed this code example and built up my own version of how I want to use the tableselect. I want to use the table select for configurations. To do this I need programmatically check or uncheck a checkbox. How would I go about doing this.

Here is the general idea of my code

function my_form($form, $form_state) {
  $users = array(
    array('uid' => 1, 'first_name' => 'Indy', 'last_name' => 'Jones'),
    array('uid' => 2, 'first_name' => 'Darth', 'last_name' => 'Vader'),
    array('uid' => 3, 'first_name' => 'Super', 'last_name' => 'Man'),
  );

  $header = array(
    'first_name' => t('First Name'),
    'last_name' => t('Last Name'),
  );
  $options = array();
  foreach ($users as $user) {
    $options[$user['uid']] =array(
      'first_name' => $user['first_name'],
      'last_name' => $user['last_name'],
    );
  }
  $form['table'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#empty' => t('No users found'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}

I am hoping/guessing it something simple like setting something in the options array.


texts:
I use hook_init() to check the users' last access time. If the last access time is yesterday, I increment a counter and set some variables.

The problem is that hook_init() is sometimes executed more that once (i can see this using dsm()) for the same page load, so my code is executed multiple times resulting in wrong variables.

Why is hook_init() executed more than once?
What would the best approach to my problem be? Should I use another hook?

I did some more digging on this:
I search for calls to the hook_init() (searched for string module_invoke_all('init');) but found only the core call). I dont know if this can be called differently.

This is my hook_init()

function episkeptis_achievements_init(){
    dsm('1st execution');
    dsm('REQUEST_TIME: '.format_date(REQUEST_TIME, 'custom', 'd/m/Y H:i:s').' ('.REQUEST_TIME.')');
}

and this is the output:

1st execution
REQUEST_TIME: 09/07/2012 11:20:32 (1341822032)

then, changed the dsm() message to dsm('2nd execution'); and executed again, this is the output:

1st execution
REQUEST_TIME: 09/07/2012 11:20:34 (1341822034)
2nd execution
REQUEST_TIME: 09/07/2012 11:22:28 (1341822148)

You can see that the code is executed twice. However, the first time executes an old copy of the code, and the second time the updated copy. There is also a 2 sec time difference.

This is a d7 version with php 5.3.10


texts: Import Users from D6 to D7 without directly accessing database

texts:
I have to import users from a drupal 6 site to a drupal 7 one. I'd use https://www.drupal.org/project/migrate_d2d but i have several limitations on what i can do on the databases:

I can't access the drupal 6 DB from the drupal 7 installation
I don't have ssh access on the D7 server, i can interact with the database only from phpmyadmin
I can't create new databases on the D7 DB (i can create new tables though), and i can import sql files only to a maximum of 10MB. I can't upload a file on the server then import it from local either.
I have no limitations on the D6 database

In addition, user roles are different from the 2 sites so i need to map them before importing.
I think the best solution is to export data from the D6 site in some format and the import it on the D7 site but i don't know how to do it


texts:
How can I implement a product comparison with the Drupal Commerce module?

For example, if there is a list of products, will the user be able to click on checkbox of 3 products, and click the "Compare" button to see a table where products, features, and prices are compared?