texts: Why would the body field's language not save as the same language as the node?

texts:
I am having a problem where the user is creating new nodes and entering body text, but setting the nodes to "language neutral" for the language. Yet when it saves the node the body field's language gets set to English. Why would this be happening? What would cause this?

On this site we have both English and French enabled and configured. This site is D7 running i18n.

This is similar to Empty body in node edit page except that I want to know how the field would get a different language than the node in the first place.


texts: How do I override an exposed filter input type?

texts:
I'm writing a module to change input HTML attributes with the next code:
use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_alter().
 */
function custom_numeric_filter_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $field = 'yourfieldname';
  if ($form_id == 'views_exposed_form' && array_key_exists($field, $form)) {
    $form[$field]['#type'] = "range";
    $form[$field]['#step'] = 5;
    $form[$field]['#size'] = 5;
    $form[$field]['#min'] = 10;
    $form[$field]['#max'] = 60;
  }
}

The problem is that the type gets overwritten back to number by something else.
I have Better Exposed Filters installed, maybe it gets rewritten there but why? And how can I make sure my module code has priority? With the help from NoSssweat I made sure it was executed after BEF and it didn't help.


texts: Sessions / Cookies not working for user login, registration or shopping cart

texts:
The Problem

One of our sites has recently broken. Users can't login or register, and the shopping cart isn't working either.

Drupal does not display any errors. Upon clicking the submit button for the forms, it simply refreshes the page as if nothing had happened.

It's just as if sessions have stopped working altogether, which is a little strange, no?

The rest of the site works perfectly well.

No Drupal updates have been performed and no new modules have been installed.

I've been reassured that this isn't a server problem, but I'm still (really) not sure about that. Since I don't have SSH access to the server, I'd like to be sure beforehand.

I'm just looking for possible causes/fixes, and if anyone has had experience with this before, great. Ultimately I will end up checking out the server, but is there any chance it could be caused by Drupal?

Things I've Tried:

I've checked /sites/default/settings.php for the $base_url and $cookiedomain variables, but they are set properly.

This is not a .htaccess problem, either. Regardless of whether I use clean urls or not (site/user or site/index.php?q=/user) it just doesn't work at all.


texts: Simulating Facebook videos embedding behaviors in Drupal?

texts: If users are posting comments to a Drupal site and the comment contains a link to a video on YouTube or other sites, I would like to see similar behavior to that when posting a link to a video on Facebook. That is, once the link is entered, it triggers the embedding mechanism and generates a preview in edit mode.


texts: Auto add nodes on save to a queue using entityqueue

texts:
I am using entity queue module, Created a queue with a name ABC.

I want to add nodes automatically to this queue for a specific content type while creating new nodes.

Is there a way to do this?


texts: Quiz module - Results comments: Using points score instead of percentage

texts:
I am using quiz module and I have this:

Question 1:

a) Gathers 0 points

b) Gathers 0,25 points

c) Gathers 0,5 points

d) Gathers 1 point

I want the quiz to sum those points and show a final result if points are between [0-30] [31-60] [61-90] [91-120] [121-150]

I found this option:

But this only shows percentage... I wanted something like "Points Start Range" and "Points End Range"

Do you guys understand my issue here?

Thank you!!


texts:
I want to create a view via hook_update, looks strange but this is the requirement to bypass allocated memory exhaust error by importing a view.
So if view is created by exporting from local instance and importing in DEV instance am running into a allocated memory exhaust error.

I tried by exporting the view and putting that into the hook_update_N();, but its not created any view. Can anybody guide me how it can be achieved via hook_update?


texts: How can I provided simplified custom exposed filter options for a field in Views?

texts:
On my site, users can input their nationality in a field provided by the Countries module.  About half the users on my site are Japanese, and the other half come from all other countries.

I have a view that allows members to search for each other, and I want to make the nationality an exposed filter.  Since there are 200+ countries in the world, I do not want to expose the entire list of countries (this would be a selection nightmare on mobile phones).

Instead, I would like to provide a select list with three options: All countries, Japan, and Not Japan.

The Views UI allows administrators to select options on select lists and limit the list to the selected options by checking a box.  This is not what I want to do, because there is no way to create a Not Japan option (which should show all members from all countries except Japan).

This answer suggests writing a custom views filter handler, but I'm a bit confused about where to begin.

The Countries module provides its own custom handlers, but (I think) these are overkill for what I need (you have to add a relationship to the country, which allows you to filter by continent, etc.); I simply need to make a version of the basic select list handler with my three options.

It seems that most views handlers extend another.  In the views/handlers folder there is a file, views_handler_filter_string.inc, which I think I can use, but I'm not really sure what the next step is to take.


texts: drupal_get_title() has been removed from Drupal 8. How I can get the page title in Drupal 8?


texts:
I have a site where I am using the CDN module in origin pull mode with Amazon CloudFront.  Apache is configured so Drupal will handle www.example.com and static.example.com.

Is there a way to get Drupal to only use the static URL only for my static resources (images, CSS, JS, etc), and redirect other requests to www?  Is the only real way to implement a hook_page_build() and check the Content-Type header to see if it begins with "text/html", and potentially redirect then?


texts:
I am using the value of a field in the page as a variable.
I am trying to use it in the page somewhere else but I think that there is a problem with the cache because the value is sometimes available and sometimes not.

I have the following:

$elements['#attached']['drupalSettings']['pdf_app_height'] = $password;

and then in a .js file I have:

(function ($, Drupal, drupalSettings) {
'use strict';

 Drupal.behaviors.pdf_appAccessData = {

attach: function (context) {
 value = drupalSettings.pdf_app_height;
 alert(value);

  window.xx = drupalSettings.pdf_app_height;
  }
 };
})(jQuery, Drupal, drupalSettings);

The alert (value) always shows the right value but I am using on the page somewhere else the following javascript code:

alert(xx);

Sometimes it is showing the right value and sometimes undefined. Any ideas?

I have seen the answer if we are talking about configuration changes (How do I avoid having to clear the cache when changing a module configuration parameter?) but I don't know how to use it here.


texts:
Folks, a quick one - I'm caching fields e.g: $data from nodes using the following:

cache_set("nids:$nid", $data, 'my_custom_cache');

I have a cron set up to clear all cached data from this bin using the following:

cache_clear_all('nids', 'my_custom_cache', TRUE);

But, if I want to clear only one particular cached node, how would I achieve this?  Currently tried:

cache_clear_all('nids:'.$nw->getIdentifier(), 'my_custom_cache', TRUE);

But no luck, how do can I specify this?


texts: How can I display private nodes on full calendar and still let the dates/times show up as unavailable?

texts:
Okay, this should be easy but I'm not figuring it out.

I need to let clients schedule appointments for my therapy practice. But, obviously I don't want those appointments to be public. So I got content access and only allow the author of the session type node to view it, as well as administrator of course.

But now, it won't show up in the fullcalendar. So, it doesn't display as taken.

How can I have both results? I need those times to be shown as unavailable, but I don't want anyone to be able to view any session.


texts: Rule to demote content from frontpage without advising subscribers

texts:
I have rules that demotes content nodes from frontpage based on different criteria. They use a shared component to set data value

Parameter: Data: [node:promote], Value: false

Problem is that this triggers a mail to all subscribers of node updates.
How can I prevent that?

When manually editing a node, there is a "Send subscriptions notifications" that I can uncheck, but I can't seem to find that option in Rules.

EDIT:
I have this rule:

{ "rules_demote_old_articles" : {
    "LABEL" : "Demote old articles",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_scheduler" ],
    "ON" : { "node_insert" : [] },
    "IF" : [
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "story" : "story" } } } }
    ],
    "DO" : [
      { "schedule" : {
          "component" : "rules_demote_node",
          "date" : "+4 weeks",
          "identifier" : "Demote article [node:nid].",
          "param_node" : [ "node" ]
        }
      }
    ]
  }
}

and the corresponding copmponent:

{ "rules_demote_node" : {
    "LABEL" : "Demote node",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "node" : { "label" : "Node", "type" : "node" } },
    "ACTION SET" : [ { "data_set" : { "data" : [ "node:promote" ], "value" : 0 } } ]
  }
}

Where do I unset the send_subscriptions_notifications to avoid sending out subscription mails?


texts: Can I Display Date Time as saved in database without DST adjustment in View

texts:
My view has data from a Feed that already has the correct time stored.
Apparently the view is adjusting for DST before displaying to the user.  Thus, my Sales and Service Techs are seeing the incorrect time.


texts: How do I switch base URL between development and production sites?

texts:
The production site is on http://example.com/, while the development site is on http://localhost/~aviram/example.com/. Bringing the production database to the development site breaks all links.

How can I fix this so I can work comfortably and move things between the development and production sites (both running Drupal 8)?


texts: Drupal 7 Views - Date Filter Cannot See Year

texts:
I am trying to create a view with exposed filters for a date field with a start date and required end date.

However, I cannot see the year for the date when I created the filter. I can only see the day and the month. I am using Views 7.x-3.11. I also have both the Date module and Date Views module installed and enabled.

Does anyone know how I can have the year show up in the filter option? I have searched and searched for a solution, but I have not found anything yet.


texts: drupal login not working offline because of reCAPTCHA

texts:
I have installed a drupal site completely offline on my local machine I have it running on mysql and apache2. When I got to the localhost/user/login to edit changes because I want to do it on my machine and not on the actual site. I get a recaptcha error because the site key isn't registered for localhost. Is there anyway I can bypass recaptcha so I can login and make changes?

Thank you

edit:
As suggested below I have tried using drush when I run the drush pmu recaptcha command I get the below error:

The drush command 'pmu recaptcha' could not be found.  Run `drush cache-clear drush` to clear the commandfile cache if you have installed new extensions

I have tried running:

sudo drush cache-clear drush

as they suggest but it does nothing.


texts: I install ultimate cron and I saw that errors

texts:
I have all this error but when i am running cron without cron ultimate all run perfect but with cron ultimate i got that errors... Could anyone help i really need help here:

    exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error
    or access violation: 1064 You have an error in your SQL syntax; check
    the manual that corresponds to your MySQL server version for the right
    syntax to use near '))' at line 1' in
    /var/www/html/drupal7.36/includes/database/database.inc:2171
    Stack trace:
    #0 /var/www/html/drupal7.36/includes/database/database.inc(2171): PDOStatement->execute(Array)
    #1 /var/www/html/drupal7.36/includes/database/database.inc(683): DatabaseStatementBase->execute(Array, Array)
    #2 /var/www/html/drupal7.36/includes/database/query.inc(858): DatabaseConnection->query('DELETE FROM {er...', Array, Array)
    #3 /var/www/html/drupal7.36/sites/all/modules/bla/includes/bla.functions.inc(245): DeleteQuery->execute()
    #4 /var/www/html/drupal7.36/sites/all/modules/bla/bla.module(56): bla_clean()
    #5 [internal function]:bla_cron()
    #6 /var/www/html/drupal7.36/sites/all/modules/ultimate_cron/ultimate_cron.module(941): call_user_func('bla_...')
    #7 [internal function]: _ultimate_cron_run_hook('bla_...', Array)
    #8 /var/www/html/drupal7.36/sites/all/modules/background_process/background_process.module(574): call_user_func_array('_ultimate_cron_...', Array)
    #9 /var/www/html/drupal7.36/sites/all/modules/background_process/background_proces
    s.module(503): background_process_service_execute('uc:error_log_ji...', false)
    #10 [internal function]: background_process_service_start('uc%3Aerror_log_...')
    #11 /var/www/html/drupal7.36/includes/menu.inc(519): call_user_func_array('background_proc...', Array)
    #12 /var/www/html/drupal7.36/index.php(21): menu_execute_active_handler()
    #13 {main}

function blabla_clean() {
  $number = variable_get('blabla_number_select');
  // Keeps values equal to the number that user had selected.
  $query = db_select('blabla', 'j')
    ->fields('j')
    ->range(0, $number)
    ->orderBy('j.timestamp', 'DESC');
  $ids = $query->execute()->fetchCol();

  // Deletes all the other values.
  db_delete('blabla')
    ->condition('wid', $ids, 'NOT IN')
    ->execute();
}


texts: Why am I getting call to undefined function after splitting module functions to two files?

texts:
Now my module has two main files:

menu_perm.module
menu_perm.admin.inc

I added second file to .info:

  files[] = menu_perm.admin.inc

I cleared the cache.

In my test class (PHPUnit) file I am bootrapping Drupal by:

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

and I call form submit function manually inside test function, ends with below error:

  Call to undefined function menu_perm_user_form_submit()

Function is in menu_perm.admin.inc.

Before this everything was ok.

What am I doing wrong here?


texts: What is the best way to migrate and optimize 300 GB database to drupal?

texts:
I have a database that was running on a propitiatory system with a hosting company. The data is about 10 years old and mostly text. The database it too large aprox 300GB. We are trying to migrate the database to Drupal and I am wondering if this is a good idea and whether drupal/mysql could support such large databases or not. I have a few thoughts such as archiving the data and using caching tools such as varnish. Is this a good idea? Can drupal support/serve it? What impact could this have on performance?

Edit: We have already migrated the database but performance is a extremely bad. ~17 million nodes, and ~90 million comments. What could I optimize? what kind of infrastructure would you recommend? caching and architecture? Load balancing? Any hints or tips that could help run such big site with drupal is what I need. Case studies if anyone is aware of.


texts:
So I had to update a size of a field and I used an update hook. However, in my update hook I deleted the field and the index and added the field again with the updated size. Now when I go to the configuration page on the drupal admin, I get the following error:

Error: Call to a member function getLabel() on null in Drupal\Core\Entity\EntityDefinitionUpdateManager->getChangeSummary() (line 79 of core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php

Here is my update script:

<?php

function featured_banner_field_update_8002() {
  $table  = 'field_banner_section'; // table name without 'node__'
  $column = 'content_body';
  $spec = [
    'type' => 'text',
  ];
  $schema = \Drupal\Core\Database\Database::getConnection()->schema();
  $schema->dropField('node__' . $table, $table . '_' . $column);
  $schema->dropIndex('node__' . $table, $table . '_' . $column);

  $schema->addField('node__' . $table, $table . '_' . $column, $spec);
  $schema->addIndex('node__' . $table, $table . '_' . $column, [$table . '_' . $column], [
    'fields' => [$table . '_' . $column => $spec]
  ]);

  // The revision table.
  $schema->dropField('node_revision__' . $table, $table . '_' . $column);
  $schema->dropIndex('node_revision__' . $table, $table . '_' . $column);

  $schema->addField('node_revision__' . $table, $table . '_' . $column, $spec);
  $schema->addIndex('node_revision__' . $table, $table . '_' . $column, [$table . '_' . $column], [
    'fields' => [$table . '_' . $column => $spec]
  ]);

  // Current node field configurations.
  $field_manager = \Drupal::getContainer()->get('entity_field.manager');
  // Because the manager was already loaded before the above config was forced,
  // it will return the old configuration that was cached.
  $field_manager->clearCachedFieldDefinitions();
  $field_storage_configs = $field_manager->getFieldStorageDefinitions('node');

  // Get the last installed manager, this is the gatekeeper that determines if
  // an update is needed or can be done.
  $last_installed_repo = \Drupal::getContainer()->get('entity.last_installed_schema.repository');

  // Get the last installed configurations for node fields
  // These are iterative objects and need to stored as such, not just simple arrays,
  // so reusing the previously set configs is not an option.
  $last_installed_configs = $last_installed_repo->getLastInstalledFieldStorageDefinitions('node');

  // Force the last installed config to be the current for the field.
  $last_installed_configs['field_banner_section_content_body'] = $field_storage_configs['field_banner_section_content_body'];
  $last_installed_repo->setLastInstalledFieldStorageDefinitions('node', $last_installed_configs);
}


texts: Some templates are not properly compiled to Twig

texts:
I have a few templates that are failing when compiling them in twig.
What is happening is that the \Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage::save method will create a temporary file like files/php/twig/.0c781c5196 and then it tries to rename this file into something like files/php/twig/DIRECTORY/FILE.php but it fails with No such file or directory.

The target directory exists, it even has .htaccess. On each page refresh, I get different temporary and target file names.

I tried to manually copy and rename the file but on each page load the ID's change so it never works.

The template hasn't been edited and it always worked just fine(it renders properly  even without compiled twig). Any idea what can be causing this?

It looks like this is only a single template issue. Due to the ever changing IDs, I thought there were more.

This is happening on my local windows machine right now so I though there might be an issue with those crazy long directory and file names but I can manually rename the file.

The length of the directory name is 134 characters which are well below 260 maximum.

UPDATE 27.6: I have experienced this same issue on another Drupal 8 project. So it looks like it is not a unique problem but rather universal but I still haven't figured out what the issue is.


texts: Hide a CCK fieldgroup using #states in hook_form_alter()?

texts:
I have a custom module, and I am trying to hide a CCK fieldgroup using "#states" when a certain item is selected in a drop-down select list.

I have tried using states from within hook_form_alter(), like so:

$form['group_mygroup']['#states']['invisible'] = array(
  ':input[name="field_trigger[' . LANGUAGE_NONE. ']"]' => array( 'value' => 'hide' ),
);

This doesn't seem to do anything.

I have looked at changing the weight of my module as per various sites like http://proofgroup.com/blog/2008/dec/modifying_cck_fieldgroups_hook_form_alter.

but still to no avail. I can hide all the form elements within the fieldgroup using states but not the field group itself. Does anyone have any idea?


texts: Using the modules Rules and Facebook Autopost, the previous post body summary is used instead of the current post

texts:
UPDATED 8/29/2016

Thank you so much for everyone that responded and special thanks to Pierre.Vriens for the detailed explanation. I am sharing my answer in case anyone finds this useful.

After much research I found that the summary field was not available so I created my own summary (which is not nearly as good as the built in summary from Durpal) but it fits my own needs. It will break in the middle of a word but that is ok for me and also it breaks on 250 characters no matter what but that is ok in my case as well.

In my case I used the following for the facebook-description field (with php wrappers, or course).

    print substr(strip_tags($node->body['und'][0]['value']), 0, 250) . " . . ."

thanks again to everyone!

----- original question -----

When I add a new article my facebook autopost uses the correct image, correct title, and the correct URL but the body summary is from the previous article?

If I rebuild the rules cache it works correctly but only for the next entry then I need to rebuild the rules cache again.

{ "rules_fb_new_artice" : {
    "LABEL" : "FB - New Artice",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "facebook" ],
    "REQUIRES" : [ "rules", "php", "fb_autopost_entity" ],
    "ON" : { "node_insert--article" : { "bundle" : "article" } },
    "DO" : [
      { "entity_create" : {
          "USING" : {
          "type" : "facebook_publication",
          "param_type" : "post",
          "param_user" : [ "site:current-user" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:field-facebook-name" ],
          "value" : [ "node:title" ]
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:field-facebook-picture" ],
          "value" : "\u003C?php\r\n if($node-\u003Efield_image) {\r\n if(array_key_exists(0, $node-\u003Efield_image[\u0027und\u0027])) {\r\n $fid = $node-\u003Efield_image[\u0027und\u0027][0][\u0027fid\u0027];\r\n\t $result = db_select(\u0027file_managed\u0027, \u0027fm\u0027)\r\n\t\t-\u003Efields(\u0027fm\u0027, array(\u0027uri\u0027))\r\n\t\t-\u003Econdition(\u0027fm.fid\u0027, $fid,\u0027=\u0027)\r\n\t\t-\u003Eexecute()\r\n\t\t-\u003EfetchAssoc();\r\n $path = $result[\u0027uri\u0027];\r\n $style_name = \u0027large\u0027;\r\n print (image_style_url($style_name, $path));\r\n }\r\n }\r\n?\u003E"
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:field-facebook-link" ],
          "value" : [ "node:url" ]
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:field-facebook-description" ],
          "value" : [ "node:body:summary" ]
        }
      },
      { "publish_to_facebook" : {
          "USING" : { "publication" : [ "entity-created" ], "pages" : "140044559353737" },
          "PROVIDE" : { "facebook_publication_id" : { "facebook_publication_id" : "Facebook publication returned ID" } }
        }
      },
      { "entity_save" : { "data" : [ "entity-created" ] } }
    ]
  }
}

Here is a screenprint of the above rule with proper formatting.

Some more details: When a new article is submitted a Facebook post is made using the article title, article url, article summary and article image.


texts: Can't Remove Image from CCK File Field when editing node (Throbber just spins)

texts:
I was able to upload an image, but the thumbnail didn't appear until I hit save on the form.  When I try to remove the image, it just sits there spinning the throbber; if I click on "Save" in the form, the image is not removed.

I think this has to do with AJAX getting caught up somewhere, but I don't know how to go about troubleshooting this.

Do you have any idea? I've tried switching the field from "Bar with progress meter" to "Throbber" and that didn't help.

Edit:

I forgot that I updated jQuery to the latest version and used some special code to prevent it from affecting the backend.  Here is the jquery_update_jquery_path() function from jquery_update.module (I modified it to fix this issue by checking for 'edit' in the uri):

function jquery_update_jquery_path() {
  $curr_uri = request_uri();
  if (strpos($curr_uri, 'admin') > 0 || strpos($curr_uri, 'edit') > 0) {
  $jquery_file = array('none' => 'jquery.js', 'min' => 'jquery.min.js');
  return JQUERY_UPDATE_REPLACE_PATH .'/'. $jquery_file[variable_get('jquery_update_compression_type', 'min')];
  }
  else {
  $jquery_file = array('none' => 'jquery-1.5.2.js', 'min' => 'jquery-1.5.2.min.js');
  return JQUERY_UPDATE_REPLACE_PATH .'/'. $jquery_file[variable_get('jquery_update_compression_type', 'min')];
  }
}


texts:
I am working on a drupal 8 project. I am building menus from drupal. My menu would be like the following structure:

-parent

--child 1

--child 2

--child 3

when i go to a page which is child 3, and the menu will also appear on that page. i would like to set active class on both child 3 and also parent. Is there any way to do so? Thanks.


texts: How to store some info while user is submitting rating with Fivestar module?

texts:
I want to store this rating on different site and I am doing this with the help of RESTful api. I have altered "fivestar_custom_widget" form with hook_form_alter. My call is not working beacuse it is not removing div which has 'field-name-field-fivestar-rating' class and not adding div which has 'rating-wrapper' id.

function recipe_form_alter($form, $form_state, $form_id) {
  if ($form_id == 'fivestar_custom_widget') {
    $form['#submit'][] = 'fivestar_rest_api';
  }
}

function fivestar_rest_api($form, $form_state) {
   $ch = curl_init("http://www.example.com/");
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_HEADER, 0);
   $data = curl_exec($ch);
   curl_close($ch);
   $json = json_decode($data,true);
   $errorMessage = $json['errorMessage'];
   $errorCode = $json['errorCode'];
   $commands[] = ajax_command_remove('.field-name-field-fivestar-rating');
   $commands[] = ajax_command_append('#rating-wrapper', 'Thankyou for your rating.');
   return array('#type' => 'ajax', '#commands' => $commands);
 }


texts: How can I display latest post in another menu tab?

texts: I want my latest post to appear in another Menu tab. For example, in this website www.drupal.stackexchange.com, you have the following menus QUESTIONS, TAGS, USERS, BADGES, UNANSWERED, if I want my post to appear in BADGES, how can I archive this?


texts: How to read JSON from external URL and display in a custom block?

texts: What is the best possible way to read JSON from an external source and display the data in a drupal block programmatically?


texts:
I would like to change the layout of my content type.
I tried the syntax: page--content-type.tpl.php of Drupal 7.
but...I was not able to make the changes appear on the page.
When I write the file: page--node--numberNode.tpl.php work,
but when I write the file: page--content-type.tpl.php nothing happens.


texts: How to migrate users from one website to another website?

texts: I created a Drupal Kickstart site and when updating I created another test site. During the updating process my older site has new members and orders how do I transfer the new database tables to reflect the new changes (members and orders) from the older site?


texts:
I was wondering what is the best way to promote nodes into a page (ie front page).

Drupal comes with its own "promote to front" option and we have other ways such as using Flags modules for this purpose as well, but I need two features that none of those cover.

One is that I only want for example 5 nodes be promoted at the same time, so if the client promote one more node, one of the previous nodes will automatically be removed from the list.

Also I'd like to be able to set the order (weight) of those promoted nodes too.

I have tried to use views and draggableviews for ordering the nodes which works great but can't figure out how to limit the number of promoted nodes?

Many thanks


texts:
Is there a way to open content in new window or add back button to it in views?

When you click on a content title from Views list there needs to be a quick way to navigate back to that list after viewing content.


texts: Importing uid of the author into article nodes fails

texts:
My custom Drupal 7 to Drupal 8 migration correctly follows dependencies and first migrates users, then articles. The problem is that it fails to import user IDs into the 'uid' field and leaves it at '0'. For uid processing, I use the following YAML snipped. Note that 'luxus_users' is the user migration that works fine.

process:
    uid:
         plugin: iterator
         source: uid
         process:
           target_id:
               plugin: migration
               migration: luxus_users
               source: uid

I hoped would work for me as similar one for file migration already works for me.

field_logo:
     plugin: iterator
     source: field_logo
     process:
       target_id:
         plugin: migration
         migration: luxus_files
         source: fid


texts: CKEditor filtered HTML body field is not showing for non-administrator users when editing

texts:
I am on drupal 7.56.

Something really disturbing happens.

I have created a custom content type named "Information" that uses the default body field. I granted access to this content to Administrator and to a newly created role that is "editor".

I made wrights configuration for both roles :

"Editor" and "Administrator" can "Edit own, Edit any" information ;
"Editor" and "Administrator" can "Edit own, Edit any" field body for that Information content type.

But only "Administrator" sees the body field in editing mode.

I am also using field_permission and content_access modules to make sure everything is fine in detail.

Still the same. On any browser, "Administrator" can see the body in edit mode but not the editor. Notice that body field text shows normally when displaying the node(s).

A help will be welcome!


texts: Change the value in the user join date field

texts:
I am building a Drupal 7 site.

User can register in my site using Hybridauth or regular registration form.

I want to change the value in the joined date field.
Meaning change the date a user joined the site.

How can I do that?


texts: How to execute migration on selected nodes thru core bulk action plugin?

texts: I'm trying to execute migration to create a copy of selected content nodes to other content type. Migration source (plugin: content_entity) is content_type_a and destination (plugin: entity) is content_type_b. My migration executed thru drush is working great for all nodes, but how to execute this migration on selected (in a view) nodes thru core bulk action plugin?


texts:
The situation: I have a drupal 7 node which has a date field. This uses the date module and it has multiple values each with a start and end date.

The problem is that I want to query drupal for all nodes where the current date is between the start and end dates of a single delta.

The entity query I have at the moment doesn't check the same value for both start and end dates.

For example if the first date value started 1/1/2013 and ended 30/1/2013 and if there was a second value which started 1/12/2013 and ended 30/12/2013. Using the current date of today 11/10/2013 this node should NOT be fetched. However under the query below it is because there is a start date in the past and an end date in the future, even though they're not from the same field delta.

  $current_date = date("Y-m-d");

  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', RD_PRIZE_DRAW_NODE_TYPE);
    ->fieldCondition('field_rd_prize_draw_dates', 'value', $current_date, '<=')
    ->fieldCondition('field_rd_prize_draw_dates', 'value2', $current_date, '>=');
    ->execute();


texts: Drupal 7 - dynamic, collapsible, navigation bar/block/thing in the sidebar first

texts:
Because a picture tells more than 1000 words.
Click here to see the image --> OPEN IMAGE
On the left side, you will see what I need.
On the right side, you see what I already have.

The question:

Is there a possibility for showing all the chapters in a navigation block (or something simular) like a navigationtree ? with collapsible nodes and meanwhile if you click on some of those chapters, the main page changes?

perhaps with jquery?
But I can't find any good documentation whereby I can say, That's what I need.

I hope that someone can help

Kind regards.

Dieter


texts: How to add anchor link through Link field?

texts:
We have a link field (field_link) on the Basic page content type. We wanted to add the link as an anchor link by putting current-page#section1 into the Link field, but it is not current.

What can we do to populate a link field such that it take the current URL and add #section1?

This is how the link field is used in the twig template

{% set cta = content.field_link.0 %}

 {{ content.field_name }}

 {{ cta['#title'] }}

Current output

 Professionally facilitate standardized vortals whereas high-payoff e-business. Distinctively productize high.

 Download

Expected output

 Completely brand cross-platform "outside the box" thinking through visionary supply.

 Download


texts: Send out mails to registered users after certain time period

texts: When a user registers in my site(drupal 6) they will receive a welcome mail.I would like to send out mails to registered users after some time period (say for example,2 months),so the newly registered users will receive mail after two months from their date of registration.I tried Rules module but the users receives mail as soon as they registered.Is there any module to implement this?Anyone could help me?


texts: Render an entity reference in a twig template

texts:
I have a field that is an entity reference. I would like to print the entire entity in my controller.

I know I can print a particular field of the entity using something like

{{ teacher.field_classrooms.entity.field_classroom_one.value }}

but I need to print the whole entity rather than just one field.

How can I accomplish this?


texts: How to set custom block to not in any region, therefore user can selete region by ownself?

texts:
This is my custom block hoo_block_info():

 function myblock_block_info() {
   $blocks = array();
     if (variable_get('hare_block', 0)) {
       $blocks['abc'] = array(
         'info' => t('test block'),
         'visibility' => 0,
         'status' => TRUE,
         'region' => 'none',
         'weight' => 99,
         'cache' => DRUPAL_NO_CACHE,
       );
     }
   return $blocks;
 }

Now by setting 'region'=>'none' there is an error that block region is not defined. Please let me know how to place block in none region?


texts: What is the use of node--product_display.tpl.php?

texts: I am new to Drupal Commerce, what is the use of node--product_display.tpl.php?


texts: I am interested in creating barcodes from field data on-the-fly using the http://drupal.org/project/barcode module. As a rookie, could somebody explain to us how generally this is done and what is the best approach. For my working project example, I've already installed the said module and integrated a field into a Field Collection, but don't really want to spend more hours 'experimenting' to result on nothing. One idea I would like to explore is a QR barcode dynamically appearing on say a user home page (created via Views/Panels). Since my other interests are in music, a working example maybe a link to a band's website (i.e I create a 'Link' field in a Field Collection about a rock band, a visitor views the rock bands 'Homepage' on a D7 site, the link is dynamically shown as a QR code). This example is probably very common and portable across other content sites (trades, places of interest, 'Buy Now' links etc), but a decent 'how to/work through' or generalisation would be most welcome. Again, possibly it is something that can be done in Views or a case of backend PHP in a custom module (in which case I've a lot to learn). Thanks in advance.


texts: Create and pre-populate a mutiple value field in field collection on new node with ajax call

texts:
This question is in the same area as a previous I asked (How to create (& pre-populate) multiple “field collection” fields on an ajax call), but with the extra level of complexity that I'm trying to alter a multiple value field inside the field collection.

The Problem

I want to add a number of field instances to a multiple value field, inside a field collection when creating a node using an ajax call.

In order to create and pre-populate a multiple value field collection, you need to change the following value in the AJAX callback and then rebuild the form.

$form_state['field']['--machine-name-of-field-collection--'][LANGUAGE_NONE]['items_count'] = x;

However inside a field collection in $form_state, there is no field information, only entity information. So while I can change item_count for the field collection I can't alter it for any of the fields inside it.

The entity also doesn't seem to be fully created because it's on a brand new node so I can't load it and edit it.

Has anyone encountered this before? How do you work with fields inside entities on forms?


texts: Why does Drupal (8) not discover my custom taxonomy term template?

texts:
Following the instructions on how to create a custom template for taxonomy terms I managed to add a template suggestion for a particular view mode of the taxonomy term entity by using hook_theme_suggestions_HOOK_alter:

function linkup_theme_suggestions_taxonomy_term_alter(&$suggestions, $vars, $hook) {
  if($vars['elements']['#view_mode'] == 'teaser') {
    $suggestions[] = 'taxonomy-term--teaser';
  }
}

(linkup is the name of my custom theme)

This seems to work as I can see the template suggestions when I print the twig debug information:

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'taxonomy_term' -->
<!-- FILE NAME SUGGESTIONS:
   * taxonomy-term--teaser.html.twig
   * taxonomy-term--15.html.twig
   * taxonomy-term--group.html.twig
   x taxonomy-term.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/stable/templates/content/taxonomy-term.html.twig' -->

But for some reason Drupal does not pick up the template which is located in themes/linkup/templates/taxonomy-term--teaser.html.twig

I think the naming is correct (unlike Drupal 7 in 8 you dont need to fiddle with underscores to match dashes in file names)

If I add a template called taxonomy-term.html.twig to the theme then that is discovered.

Am I missing some of Drupal 8's logic to discover the custom template?


texts:
Is there any reason why the Commerce rule selector is broken? I tried clearing the cache, but that didn't work.
This causes fatal errors on some pages. On the log, I get errors like the following one.

EntityMetadataWrapperException: Unknown data property commerce_unit_price.
EntityStructureWrapper->getPropertyInfo()

It looks like propertyinfo is not populated for the Commerce Line Item module.
This happens on PHP 7.3 with the latest Drupal 7.78 and Commerce 7.x-1.15.


texts: How to run drush make on remote using relative path?

texts:
I'm writing a script where I'd like to run .make file, but it fails with the following error:

$ drush @remote.test make --no-core profiles/foo/contrib.make --yes
Calling proc_open(ssh drush@remote 'COLUMNS=278 drush  --verbose --yes --root=/var/www  make profiles/foo/contrib.make   --no-core 2>&1' 2>&1);
file_get_contents(profiles/foo/contrib.make): failed to open stream: No such file or directory make.utilities.inc:487

despite the file exists. I don't want to hardcode absolute path, as I'd like to use the same command for other remotes.

The command fails, because current directory of drush is set to HOME folder, instead of webroot (which is correctly passed internally via --root). This example could be related to issue where drush shell alias is downloading the project into wrong directory.

So the question is: How I can use drush make to execute .make file on remote host using relative path? As it seems to work fine on local.

I'm using drush 7.0-dev on local and remote.


texts:
What's is the correct way to add a CKeditor Addon?

Like this one: http://ckeditor.com/addon/fontawesome

Where should the plugin be located?

sites/all/modules/ckeditor/plugins

or

site/all/libraries/ckeditor/plugins

Some plugins need some configuration in the js,

Should I change ckeditor/config.js

or

should be added in "Custom JavaScript configuration" in admin page

I guess I can not use the CKBuilder. Can I?


texts: How to add an image field to a custom fieldtype?

texts:
I see that there is an ImageType field, machine name 'image', with a namespace of Drupal\image\Plugin\Field\FieldType. However, I can't seem to make use of it when creating a custom field and defining the property in the FieldType class.

I tried putting DataDefinition::create('image') but this later causes an abort complaining about the field type not existing, and I notice that the namespace is not referenced.

What are the correct types to use for an image field in the property section of the FieldType, in the schema of the FieldType, and in the FieldWidget?

Exporting an image field config from a bundle yields:
uuid: eecbe6e5-89d5-4708-b9c9-79f77b3cedf8
langcode: en
status: true
dependencies:
  module:
    - file
    - image
    - node
_core:
  default_config_hash: SkXIPKZYiIMMtnBmfnxk58RYfbZ8cHSw5NZPY_JByME
id: node.field_image
field_name: field_image
entity_type: node
type: image
settings:
  uri_scheme: public
  default_image:
    uuid: null
    alt: ''
    title: ''
    width: null
    height: null
  target_type: file
  display_field: false
  display_default: false
module: image
locked: false
cardinality: 1
translatable: true
indexes:
  target_id:
    - target_id
persist_with_no_fields: false
custom_storage: false

and looking at the image module's fielditem:

 * @FieldType(
 *   id = "image",
 *   label = @Translation("Image"),
 *   description = @Translation("This field stores the ID of an image file as an integer value."),
 *   category = @Translation("Reference"),
 *   default_widget = "image_image",
 *   default_formatter = "image",
 *   column_groups = {
 *     "file" = {
 *       "label" = @Translation("File"),
 *       "columns" = {
 *         "target_id", "width", "height"
 *       },
 *       "require_all_groups_for_translation" = TRUE
 *     },
 *     "alt" = {
 *       "label" = @Translation("Alt"),
 *       "translatable" = TRUE
 *     },
 *     "title" = {
 *       "label" = @Translation("Title"),
 *       "translatable" = TRUE
 *     },
 *   },
 *   list_class = "\Drupal\file\Plugin\Field\FieldType\FileFieldItemList",
 *   constraints = {"ReferenceAccess" = {}, "FileValidation" = {}}
 * )
 */


texts: How to grant permission directly to a user other than a role?

texts:
Our client frequently need to grant arbitrary permissions to arbitrary users. It's very boring and fault-prone for our client to create new roles, assign users to roles and then set role permissions.
The module user permissions can grant permissions directly to a user, but the grantee must have the powerful permission "administer permissions", which is not what I want.


texts: Why is unchanged and new value always the same in my Rules condition?

texts:
I have a boolean field called verified defined in profile2. When this field changes from not ticked to ticked I would like to send out an email to the user. Easy I thought with rules

Starting using "After updating an existing profile" then comparing the fields
profile2-unchanged:user:profile-directory-information:field-verified
and
profile2:user:profile-directory-information:field-verified
(bascially saying equal and then negating the condition)

   "IF" : [
      { "user_has_role" : {
          "account" : [ "profile2:user" ],
          "roles" : { "value" : { "12" : "12" } }
        }
      },
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "3" : "3", "28" : "28" } },
          "operation" : "OR"
        }
      },
      { "NOT data_is" : {
          "data" : [ "profile2-unchanged:user:profile-directory-information:field-verified" ],
          "value" : [ "profile2:user:profile-directory-information:field-verified" ]
        }
      }
    ],

However they are always the same value and the rule never fires. However when I take out the condition and send myself an email with the two values. One is true the other one is false.

also tried this in the condition:

  { "data_is" : {
      "data" : [ "profile2-unchanged:user:profile-directory-information:field-verified" ],
      "value" : 0
    }
  },
  { "data_is" : {
      "data" : [ "profile2:user:profile-directory-information:field-verified" ],
      "value" : 1
    }
  }

which is also not working. Tried to move it in before saving a profile, and also in various save user events. Always the same result. So why are the values different in Actions then they are in conditions?

Am I missing something here?


texts: Which statistics like page visitors or most visited pages are tracked automatically, or do I need extra modules for that?

texts:
I'm using Drupal 7.22. In this version are there any "default" or simple site statistics that are tracked automatically? I am looking for the following statistics:

Page visitors
Most visited pages
Most clicks

Do I have to install a module to get statistics?


texts: How can I add CSS variables to the HTML head?

texts:
For my site I want to be able to set custom css variables to the sites head. I don't want to add css files just inline css code. In the end I want users to be able to set colors using a color picker. These colors should be translated to the css variables added to the sites head.
For this I looked at the code in the css vars module this brought me a long way. But i'm not able to add css variables in the body of the page.
For this I use hook_page_top. But my code now is ending up in the top of the <body> and I want it to be in the <head>. Strange enough...when I look at the screencast (min 7:35) of the creator of the css vars module I see that his code does get in to the <head>.
I simplified the code in my theme_color module to figure out how it works. So maybe that's the problem? How can I get my css variables in the head of the page?
I have a theme_color.module:
<?php
/**
 * @file
 *   CSS Variables module.
 */

use Drupal\theme_color\Hooks;

/**
 * Implements hook_page_top().
 */
function theme_color_page_top(array &$page_top) {
  Hooks::hookPageTop($page_top);
}

I have a Hooks.php just like the example module:
<?php

namespace Drupal\theme_color;

class Hooks
{

  public static function hookPageTop(array &$pageTop)
  {
    if ($build = self::makeThemeColorBuild()) {
      $pageTop['theme_color'] = $build;
    }
  }

  private static function makeThemeColorBuild()
  {
    $build = [
      '#type' => 'html_tag',
      '#tag' => 'style',
      '#value' => "html:root {\n--test-var: yellow;\n}",
    ];
    return $build;
  }
}

Update:
I tried earlier, and again after get the suggestions in comments to use hook_preprocess_html
function theme_color_preprocess_html(&$variables)
{
  $build = [
    '#tag' => 'style',
    '#value' => "html:root {\n--test-var: pink;\n}",
  ];
  $variables['page']['#attached']['html_head'][] = [$build, '?tag?'];
}

This is working but what kind of tag do I need to put after the $build in the $variables line of code??


texts: Drupal 7 OG Group Unsubscribe after given time period for member

texts:
I am new to drupal 7 and was willing to implement something like time based unsubscription from a OG Group.

I have users added in OG Group. I want to implement time based unsubscription of the users already added in the group say 'Computers'.

User say 'Tony' is added to the group 'Computers' today, now I wish that a user 'Tony' should be unsubscribed from the group 'Computers' after a subscription of 3 months (a specific time period).

A Notification message should be sent to user 'Tony'.

All the process should be based on systems current date and the joining date of user 'Tony' to the group 'Computers'.

Please help me with any solution.


texts: Installing Drupal patches in Ubuntu terminal

texts:
I'm new to Ubuntu and I never ran Drupal patches before and now is my first to do so: I've searched here in the Drupal answers with the phrase: "Patches, Ubuntu" But I didn't find instruction on how to run patches for a module in a local site via the Ubuntu terminal. I've also searched some in Google in Youtube but I found ways for many other CLIs, but not for the Ubuntu terminal.

Is it possible to run the patches there as I would run Drush commands?


texts: New Content type is not listing in Add Content in Drupal 7

texts:
When create custom content type through UI or programmatically in Drupal 7, there is no link is listed in the Content > Add content.

I was creating the content types without any trouble, but now it is created(succes message is showing) when I check them in the node_type table but not lising in the admin/structure/types.

But no content type is listing(not any links showing) in the Content > Add content, or Structure > Content type administration menu.

Here is the code that allows users to access node pages:

/*
 * Allow users to view the contents
 */
function mymodule_node_access_records($node){
    $grants = array();
    $grants[] = array(
        'realm' => 'example_realm',
        'gid' => 123,
        'grant_view' => 1,

  'grant_update' => 0,
    'grant_delete' => 0,
    'priority' => 0,
);
return $grants;
}

/**
 * Implements hook_node_grants().
 */
function mymodule_node_grants($account, $op){
    $grants = array();
    if ($op == 'view') {
        $grants['example_realm'] = array(
            123,
        );
    }
    return $grants;
}

Then I rebuild permissions using Content Access module.


texts: Dynamic meta tags and description in custom pages

texts:
I have a custom drupal module which will generates pages for players in my site. The players stat data is meant to be updated most of the time, so for ease of use, I have created a custom module for the player pages.

I have an external db where all my players information are stored. My module will define a url pattern and once the pattern is obtained, it will display the players information from the external db.

My issue is, since there is no actual node present for my pages, I was not able to display meta tags and description for my player pages. I have tried meta tags module and meta tag routes modules. But by using these modules, I was only able to define a static meta tag and description for my entire module, means there is only one meta description for all pages. I want them to be dynamic and should vary from page to page. I have tried the examples provided below, but I can add only static string. I want the player wise meta description.

Generate meta in drupal 8 controller

Add meta tag to head in drupal 8

Here is my code structure.

player.info.yml

name: Player Module
description: Creates Page for Player.
package: Custom
type: module
version: 1.0
core: 8.x

player.module

<?php

/**
 * @file
 * Player module.
 */

/**
 * Implements hook_theme().
 */
function player_theme() {
  return [
    'player_page_data' => [
      'variables' => ['result' => NULL],
      'template' => 'player-page-formatter',
    ],
  ];
}

player.routing.yml

player:
  path: '/player/{player}'
  defaults:
    _controller: '\Drupal\player\Controller\PlayerController::content'
    _title_callback: '\Drupal\player\Controller\PlayerController::title'
  requirements:
    _permission: 'access content'

PlayerController.php

<?php

namespace Drupal\player\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal;

class PlayerController extends ControllerBase {

  public function content($player) {
    $result = [];
    /* --------------------
     code logic here
   -------------------- */
    return [
      '#theme' => 'player_page_data',
      '#result' => $result,
      '#cache' => ['max-age' => 0],
    ];

  }

  public function title($player) {
    $title = "";
    /* --------------
     code logic here
    ------------------ */
    return [
      '#type' => 'markup',
      '#markup' => $title,
    ];
  }

}

I am stuck with this issue for long time. Any help will be appreciated.

Edit 1

Thank you for the support, now I am able to add meta tags. But I am using drupal meta tag module for my other pages. Here it shows the default meta tags as well as my meta tags. Some crawlers might ignore mine if they find multiple meta tags with same name. How do I disable my global meta tags and display only mine?


texts:
I currently use only one view with path taxonomy/term/% and without any vocabulary verification.

However, I would like to create two views: news and products (to implement different themes) linked to two vocabularies (1 per 1): news_categories and product_categories.

news_categories looks like:

  category 1
  category 2

product_categories

  category 1

  subcategory 1

  category 2
  category 3

  subcategory 1

I don't want to allow displaying terms which are not from this vocabularies.
In addition I use pathauto to generating path, which sometimes are a few level dept.

I found a module called Taxonomy Views Integrator, but I'm not sure it's in 100% stable, so my question is that you are any other ways to handle many taxonomy term pages by views?


texts: How to add custom field to image area where Alt and Title fields are showing?

texts:
I am trying add new field to image widget using hook_field_widget_form_alter

Bellow is the code:

function MYMODULE_field_widget_form_alter(&$element, &$form_state, &$context) {
     $element[0]['custom'] = array(
     '#type' => 'textfield',
     '#title' => 'Custom Field',
     '#default_value' => FALSE,
    );
}

But it add a new field to first image always. I'm expecting the custom field with each image as Alt & Title fields are showing for each image.

If I remove the [0] index like:

      $element['custom']

or

    $element[]['custom']

it show an error, and show the field bellow image field not with Alt & Title field.

Notice: Undefined index: #file in theme_file_widget_multiple() (line 861 of C:\xampp\htdocs\drupal39\modules\file\file.field.inc).

I also try with [#process][] way:

function MYMODULE_field_widget_form_alter(&$element, &$form_state, &$context) {
if (isset($element['#field_name']) && $element['#field_name'] == 'field_gallery_image') {
      foreach (element_children($element) as $key => $child) {
          $element[$key]['#process'][] = 'MYMODULE_image_field_widget_process';
      }
    }
}

function MYMODULE_image_field_widget_process($element, &$form_state, $form) {
$element['custom'] = array(
    '#title' => t('Custom Field'),
    '#type' => 'textfield',
    '#default_value' => isset($item['custom']) ? $item['custom'] : '',
    '#weight' => 1,
);
return $element;
}

This way the Custom field is adding to all images but create one EXTRA custom field bellow the Image field.


texts: How do I add custom CSS styles to the body field?

texts:
I have a content type "page with fields" which I made out of "Basic page" by adding two text fields at the beginning of the page which now looks like this:

Page title
Field1 Label: field1 text
Field2 label: field2 text
Here goes the body field text which is long text.

The problem is the lack of space between the body text and the fields 1 and 2. Now I want to add some custom CSS styles to the body field in order to put some extra space and later to be able to add some other visual changes.

My theme is Bartik 7.26 on Drupal 7.


texts:
This code is adapted from /core/modules/statistics/statistics.php. It uses a JavaScript file that sends an uncached POST request to the server (to ensure the code within gets run for every page request).

I want my code within to capture the IP and URL of the referrer. I've tried many things to grab this information and write it to the log, but no luck.

Whatever I do, I get a variation on Error: Call to a member function *something* on null in.... Like, I'm not getting anything. For example, the below throws: Error: Call to a member function getClientIp() on null in main() (line 26 of....

Any ideas?

<?php

/**
 * @file
 * Store access data.
 */

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
// use Symfony\Component\HttpFoundation\RequestStack;
// use Symfony\Component\HttpFoundation;

chdir('../..');

$autoloader = require_once 'autoload.php';

$kernel = DrupalKernel::createFromRequest(Request::createFromGlobals(), $autoloader, 'prod');
$kernel->boot();

// $container = $kernel->getContainer;

// $request = $kernel->getContainer()->get('request_stack')->getCurrentRequest();
// $request = $kernel->requestStack->getCurrentRequest();

// $url = \Drupal::request()->server->get('HTTP_REFERER');

// $hostname = $request->getClientIP();
// $hostname = \Drupal::request()->getClientIp();

\Drupal::logger('sitelog')->notice(REQUEST_TIME);

Working code:

<?php

/**
 * @file
 * Store access data.
 */

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

chdir('../..');

$autoloader = require_once 'autoload.php';

$request = Request::createFromGlobals();
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$kernel->boot();

$hostname = $request->getClientIP();
$url = $request->server->get('HTTP_REFERER');

\Drupal::logger('sitelog')->notice($hostname . ' - ' . $url);


texts:
I have created a block using a custom module.

In the block, I have static text which will vary by time; thus, I will have to let the content manager decide when to modify the static text.

Could any one tell what is the best approach should I follow?

Note: I don't want the content manager to edit the text from the code.


texts:
I need to sync my user database with another user database; the other user database uses SHA1 as hash with USERNAME:PASSWORD as algorithm.
Is there a way to rehash it that I can store it in the database?

Do you have any idea?

It should be possible to edit the user/*/edit form and hash the password on my own and save it afterwards, or am I wrong? If it can work, can you give me any tip on how?

I did a bit reasearch about editing the user_profile_form (for example: Making a username/password syncronization scheme - D7) where I read that $form_state['values']['pass'] could give me the password in plain text to hash it on my own and insert it into my database.
Afterwards I directly tried to investigate more and tried to displa me the password with dpm($form_state['values']['pass']);, but I noticed (controlled with dpm($form, '$form info for $form_id '.$form_id);) that theres no values.

How can I get the plain text password in user_profile_form or is it impossible and only possible in user_register_form (as stated in topic above).
In my user_registe_form is no password entered, because I use the method to get a link with E-Mail were you can login one time and change the password with user_profile_form.

Thank you!


texts: The "twig" service or alias has been removed or inlined when the container was compiled. Upgrade Drupal 8.9.13 to 9.0.11

texts:
I'm trying to upgrade Drupal 8.9.13 to 9.0.11 in my local setup (Windows & xampp). I have upgraded all the contributed modules which supports for Drupal 9. When I try to upgrade core, got below error.

The website encountered an unexpected error. Please try again later.
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The "twig" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead. in Symfony\Component\DependencyInjection\Container->make() (line 275 of vendor\symfony\dependency-injection\Container.php).

After google got something similar then tried to upgrade 9.2 then also faced same same issue.
https://www.drupal.org/project/drupal/issues/3161889


texts: How to pay users programmatically (payment from site to users)

texts:
Is there a way to reward registered users with real money in a programmatic way, i.e. via Rules?

Like Commerce Card On File but in reverse:

My site (or some admin account) has a credit card (or whatever works) saved for later billing.
One of my users has saved an account to receive payments (a credit
card, a paypal account or whatever works in Europe).
The user does something that earns him a reward.
He (or a scheduled component) fires a Rule that create an order and
pays from the admin card to his account automatically.

The legal aspects are not relevant at this stage (valid billing for taxes, which would be from the user, etc.)

UPDATE: I found Commerce Funds and Stripe Connect together with Commerce Stripe module to be promising, still I don't see the functionality right away.

Anyone having experience with creating a real market (real money) on Drupal?

I also submitted a feature request (https://www.drupal.org/node/2398423) on Commerce Stripe module.

UPDATE 2: Paypal has something here https:// www.paypal.com/cgi-bin/webscr?cmd=_batch-payment-overview-outside. It is called MassPay but is limited to max 250 recipients via the API and 5000 via a static csv list.
I don't have info on Drupal modules implementing that, if you do, please share.

In the meantime, I could still create a View, data-export it to CSV and manually upload to Paypal to make the payments each month to my users, 5k at a time. It's not so bad, but a completely integrated and automated solution would be way better.


texts: get form_state values from ajax callback through hook_form_alter?

texts:
I'm having a little problem with my drupal 7 module.
I'm trying to get the $form_state['values'] from $form['base']['st-volume-pricing']['price'] and $form['base']['st-volume-pricing']['till-amount'] in my ajax callback so that I can add them to a results table.

Is this the right way to do it or am I missing something?

function mymodule_form_alter($form, &$form_state) {
  $form['base']['st-volume-pricing']['price'] = array(
    '#type' => 'uc_price',
    '#title' => t('Price'),
    '#description' => t('Set the price for this volume\'s reduction'),
    '#size' => 10,
    '#prefix' => '

',
    '#suffix' => '	',
  );
  $form['base']['st-volume-pricing']['till-amount'] = array(
    '#type' => 'textfield',
    '#title' => t('Till Amount'),
    '#description' => t('The amount till which the volume discount applies'),
    '#size' => 10,
    '#prefix' => '',
    '#suffix' => '	',
  );
  $form['base']['st-volume-pricing']['add'] = array(
    '#type' => 'submit',
    '#value' => t('Add'),
    '#submit' => array('mymodule_add_volume_standard'),
    '#ajax' => array(
      'callback' => 'mymodule_add_volume_standard_ajax_callback',
      'wrapper' => 'st-volume-results',
      'method' => 'append',
      'effect' => 'fade',
    ),
    '#prefix' => '',
    '#suffix' => '
',
    '#title' => t('Click this button to add a standard volume price'),
  );

  //this is our results table
  $form['base']['st-volume-pricing']['st-volume-results'] = array(
    '#type' => 'markup',
    '#markup' => '

' . t('Price') . '	' . t('From Amount') . '	' . t('Till Amount') . '

',
  );
  variable_set('vol-st-price', NULL)
  variable_set('vol-st-from', 1)
  variable_set('vol-st-till', NULL)

  //this is our row that will be inserted
  $form['base']['st-volume-pricing']['st-volume-results']['row'] = array(
    '#type' => 'markup',
    '#markup' => '
' . variable_get('vol-st-price') . '	' . variable_get('vol-st-from') . '	' . variable_get('vol-st-till') . '
',
  );
}

When I'm using it inside here:

function mymodule_add_volume_standard_ajax_callback($form, &$form_state) {
  //check if there is a previous volume price and set the from field
  if (variable_get('vol-st-till') !== NULL) {
    variable_set('vol-st-from') = variable_get('vol-st-till') + 1;
  };
  //add or overwrite the value entered in price
  variable_set('vol-st-price') = $form_state['values']['base']['st-volume-pricing']['price'];
  //add or overwrite the value entered in till
  variable_set('vol-st-till') = $form_state['values']['base']['st-volume-pricing']['till-amount'];
  //create new row in results table
  return $form['base']['st-volume-pricing']['st-volume-results']['row'];
}

drupal_set_message("
" . print_r($form_state['values']) . "
");
displays 1.

I suppose that $form_state['values'] should only work during the submission of a form.
How would one go about doing this when using a hook_form_alter() and ajax callbacks?

I also tried displaying drupal_set_message("
" . print_r($form_state['values']) . "
"); in my function mymodule_add_volume_standard. Which also displayed 1.
Neither does it work when trying it in the hook_form_alter() which is default behaviour I suppose?

I'd really appreciate it if someone could clarify some things for me.


texts:
I need to alter my view filter option!

The view must display some comments. Every comment, that I need, has  custom field "node reference". And I want to filter comments by this field.

E.g. if my view displays on page with node 9(nid), view should return me all comments where "node reference" = 9;

I have found such solution: http://www.drupaldump.com/view-3-alter-filters-programmatically

And try to rewrite for me:

function mymodule_views_pre_view(&$view) {

  if ($view->name === 'contest_winners') {
    $view_filters = $view->display_handler->get_option('filters');

    $node_id = arg(1);

    $view_filters['field_for_contest_nid']['value'] = null;
    $view_filters['field_for_contest_nid']['value'][$node_id] = inttostr($node_id);
    $overrides = array();
    $overrides['filters'] = $view_filters;
    foreach ($overrides as $option => $definition) {
      $view->display_handler->override_option($option, $definition);
    }

    dpm($view_filters); // here value = node_id, but view use default value

  }

}

But this does not help: view uses default value.

Maybe i have made some stupid mistake?


texts:
We have a site with the configuration of Drupal 5, and we need to convert content, content types, views, and everything into Drupal 7. We have already tried with the normal conversion process like D5 => D6 => D7, but we are facing many errors; content and views are not imported correctly.

Is there any solution?


texts: How can I set per file access controls by role to files on a node

texts:
I'm migrating a publications database from an old CMS to drupal 7 using the migrate module.  One of the requirements is that some publications (nodes of content type document) will be available to the public (anonymous users and everyone else) and some will be staff only (administrators, staff, and probably some higher level roles created for content editing).  Each publication can have an arbitrary number of associated files, each of which can also be publicly available or internal only (Same set of role based control).

How could I set this up?  So far my two possible solutions have been:

creating a different content type called files and using inline entity form to to associate thre file nodes with the publications.  This will allow me to ad a field for whether the file node is publicly available or not
Using the media module.  Unfortunately it appears that the Migrate Extras module that has media support doesn't support Media 7.2.x (As far as I can tell it is designed for 7.1.x).  I have tried installing Media 1.x but I have so far been unsuccessful at getting migrate to recognize the extra field as a destination field for migrate to write to.


texts: How do I set a node/page's background image to that content's image?

texts:
I've installed both 'Background Image' and 'Dynamic Background' but am having trouble trying to configure them for my situation. In the website I am trying to edit, there are content types of 'Performer,' 'Venue' among others. Now each content type has an image as one of their fields and I would like to have that image as the background image for that content's page.

Background Image only gives me option to do this for 1 content type, and when I tried setting it up, nothing appears.

I'm pretty sure I could do this with Dynamic Background, but the process would be really inefficient; I would have to add the pictures again to Dynamic Background's library.

So is there another way to do this? Or what can I do with Background Image to make it work?


texts:
I have a bilingual site and I want to redirect to a custom page, which has two language versions, upon form submitting. This may be a pretty basic thing, but I am only starting to learn how to code for Drupal in PHP. This is what I tried:

$form_state['redirect'] = t('message-sent-successfully');

'message-sent-successfully' is the URL for the English version of the page. It has a different URL for the other language the site is using. In whatever language I submit the form, I get redirected to the above URL, i.e. the url doesn't get translated.


texts: Apache filehandle issue expected to be mission critical for image uploading

texts:
I have a fresh install of Drupal Commons (version 6.25), and I am not allowed to upload an image. See the full description of this so called image upload issue here on this site.

new Update one a sitenote...

i want to mention  that i - for the purpose of some tests have put two sites onto the server

http://schulcenter.net (for sure Version Drupal-Commons 6.25)
http://schulcenter.org - (probably Version Drupal-Commons 6.23)

and they run on the same database ;-)

guess that that can cause the open File handles
what do you think !? Love to hear from you

well i guess that i have to switch off one site. ;-) greetings (end of update)

here the original-initial-thread starts:

I have changed some settings regarding the file handling; I set the permissions for sites/default/files, I created a temporary directory and edited the paths accordingly. All of these seem to work, and workarounds did not change the bad habit of the site: The image upload is impossible.

Can we verify the impact of a decreased amount of Apache File handlers on the possibilities and capabilities of file, and image-handles, especially of the option to upload images? Is there any impact?

dman, a very experienced web and Drupal developer, had a closer look at the site and noticed the site status under the 'Reports' tab lists many errors, including the following one:

  opendir(*) [function.opendir]: failed to open dir: Too many open files in /home/vhost/WWW/schulcenter.net/includes/file.inc on line 963.

It seems like it could make anything on the site break, especially things that work with files, but also anything that reads files.
I have more than 1200 repots of such message about opendir("profiles/drupal_commons/modules/acquia/acquia_search/apachesolr/drush").

I do not have installed any drush.
Besides this thing, I have no clue why we get such a big amount of open file handles the server is faced with.

  The dblog module monitors your website, capturing system events in a
  log to be reviewed by an authorized individual at a later time. The
  dblog log is simply a list of recorded events containing usage data,
  performance data, errors, warnings and operational information. It is
  vital to check the dblog report on a regular basis as it is often the
  only way to tell what is going on.

  Details
     Type   php
    Date    Sunday, 18 March, 2012 - 21:48
     User   martin
     Location   http://schulcenter.net/?q=admin/reports/dblog
     Referrer
     Message    opendir(profiles/drupal_commons/modules/acquia/acquia_search/apachesolr/drush) [function.opendir]: failed to open dir: Too many open files in /home/vhost/WWW/schulcenter.net/includes/file.inc on line 963.
     Severity   error
     Hostname   188.99.184.201
     Operations


texts: How to migrate an admin.inc file which creates a configuration form for settings?

texts:
I am trying to migrate a module from drupal 7 to drupal 8, but sadly I cannot find any proper documentation on how to do this. I already re-wrote .info file to .info.yml but at this point its just a dead-end. For example I have a admin.inc file which creates a configuration form for settings. It looks like this:

function commerce_shipping_gls_settings() {
  $form = array();
  $form['rates'] = array(
    '#type' => 'fieldset',
    '#title' => t('Shipping costs'),
  );
  $form['rates']['commerce_shipping_gls_shipping_rate_amount'] = array(
    '#type' => 'textfield',
    '#title' => t('Shipping service rate amount'),
    '#default_value' => variable_get('commerce_shipping_gls_shipping_rate_amount', 3900),
    '#required' => TRUE,
    '#element_validate' => array('element_validate_integer_positive'),
  );
  return system_settings_form($form);
}

I was trying to find how to convert a config file to drupal 8, but sadly I didn't get much. Could someone please give me some guidance on how can I achieve this?


texts: Display POA in Ubercart 3 / D7 for products of zero dollars

texts:
I'm building an ecommerce site where some products are price negotiable and want a way to add POA instead of a listing a price when a product is displayed.

I'm kinda surprised at how hard this is to do.. I have a snippet that works for Ubercart 1 in Drupal 5, but it looks like the hooks have changed in Ubercart 3 and I can't find a pricing hook:

    <?php
function zen_uc_product_display_price($price) {
  $output = '
';
    if ($price!=0) {
      $output .= uc_currency_format($price);
    } else {
      $output .= t('P.O.A');
    }
  $output .= '
';
  return $output;
}
function

zen_uc_product_sell_price($price, $teaser) {
  if ($teaser) {
    $output = '';
        if ($price!=0) {
            $output .= uc_currency_format($price);
        } else {
            $output .= t('P.O.A');
        }
    $output .= '';
  }
  else {
    $output = '
';
        if ($price!=0) {
            $output .= t('Price: !price', array('!price' => uc_currency_format($price)));
        } else {
            $output .= t('Price: P.O.A');
        }
    $output .= '
';
  }
  return $output;
}
?>

I've managed to hook the add to cart function and direct it to a webform with the following snippet:

<?php

function fmc_uc_product_add_to_cart( $variables ) {
$sell_price = $variables['form']['node']['#value']->price;
if ($sell_price <= 0) {
return '<form action="http://www.example.com/" method="post"><input type="hidden" name="product" value="' . drupal_get_title() . '" /><input type="submit" class="form-submit" value="' . t('POA') . '" /></form>';
}
else {
return fmc_uc_product_add_to_cart($variables);
}
}

But I'm having no luck with the pricing function, if anyones got a code snippet I can run in my template.php file that'd be the ideal solution, but any ideas / advice is hugely appreciated. Is there a way this can be broken out inside a node--product.tpl.php file maybe?


texts: how to print db_select result using watchdog?

texts:
I'm trying to debug below code:

$perishables = db_select('userpoints_txn', 'up_txn')
    ->fields('up_txn', array('txn_id', 'uid', 'points', 'remainder', 'time_stamp', 'tid', 'operation', 'description'))
    ->condition('status', 0, '=')
    ->condition('expired', 0, '=')
    ->condition('expirydate', 0, '!=')
    ->condition('expirydate', REQUEST_TIME, '<')
    ->execute();
 watchdog('userpoints', 'perishables->remainder  %perrr', array('%perrr' =>$perishables), WATCHDOG_DEBUG);

Can anyone help me how to get  $perishables in the report log files?


texts: Problem with overlay in custom webform extension (D7)

texts:
I'm doing my first drupal module (webform extension) and I have a problem with the overlay when editing a webform.

I added the "Factors" tab in my hook_menu():

$items['node/%webform_menu/webform-factors'] = array(
    'title' => 'Factors',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('forms_grade_factors_create_factor'),
    'access callback' => 'user_access',
    'access arguments' => array('access administration pages'),
    'weight' => 5,
    'type' => MENU_LOCAL_TASK,
  );

But when I click on this Factor tab, the overlay disappears:

I don't know if it's important, but when I click on the other webform tabs, their urls are something like this:

drupal.dev/node/12#overlay=node/12/grant

And my module:

drupal.dev/node/12/webform-factors#overlay-context=node/12

How can I keep the overlay layer?
Thanks a lot!

EDIT:

I also implemented hook_admin_paths:

function webform_factors_admin_paths() {
  return array(
    'node/*/webform-factors' => TRUE,
    'node/*/webform-factors/*' => TRUE,
  );
}


texts: Move a site hosted on IIS/MS SQL Server across to LAMP stack

texts:
I have a Drupal 7 site which is currently hosted in a Windows servers environment (e.g. IIS and MS SQL Server). The site needs to be moved over to Platform.sh, which is using the LAMP stack.

I am wondering if there are likely to be any issues with doing this? For example, is it possible to simply export the existing database from MS SQL Server and then import it into MySQL on the new site using drush?


texts: How to add a new webform submission formatter for the webform components

texts: I'm just wondering how to add a new option to the webform submission formatters for a specific element? is it driven by the field API?


texts: use imce for images in articles but not within the editor

texts:
By default, there's an imagefield of for the article and by default, in this imagefield you are only able to upload a file from your local disc.

Now i've installed imce and i can manage different folders with diffrent files but how do i connect the imagefield from the article to get one of those files from the folderstructure? To get the popup and click through the folderstructure and get the certain file?


texts: How do I add an additional sidebar to a Zen sub-theme?

texts:
I want to add an additional sidebar to my zen based theme with fixed columns.
I added it to the theme info, and printed it in the page.tpl.php file, but I don't know how to
configure its CSS files to make it look correct; I don't know how to make the content region expand to fill the available space when there is an empty region with no blocks in it like with Zen.

My theme contains 4 columns:

left sidebar 1 (130 pixels)
left sidebar 2 (255 pixels)
content (509 pixels)
right sidebar (130 pixels)

The total width would be 1024 pixels.

How can I do that?


texts: Convert Field Collections into Paragraphs during Migration

texts: I have a content type that uses Field Collections in Drupal 7. I am migrating to Drupal 8. Is there a way to convert the Field Collection Entity into Paragraph during migration?


texts: Adding labels to a Webform multistep form

texts:
I have a form with 3 steps using the Webform module. Is there a way for me to identify what step I'm in so I can style it separately? What I'm after is to place text like Step 1 > Step 2 > Step 3 while highlighting the current step using CSS.

So far, I can't find any ID or class which tells me what step I'm in.

EDIT: Not that important but any suggestions on how I can place the text Step 1 > Step 2 > Step 3? I was thinking of adding the text in body but maybe there's another/better way? Just curious.


texts: How to write phpUnit tests for hook_form_alter?

texts:
I have 1 function that is returning cancel form button. This function is in my .module file.

function _cancel_button(array &$form, FormStateInterface &$form_state) {
  // Adding buttons to cancel form.
  $form['actions']['cancel'] = [
    '#type' => 'submit',
    '#value' => t('Cancel'),
    '#access' => TRUE,
    '#submit' => ['redirectcallback'],
    '#limit_validation_errors' => [],
  ];
  return $form;
}

How to write PHPUnit test for this function? Is is possible to write a test for a function which is not enclosed in any class or don't have any namespace?


texts: Let user pick which content will be visible on search

texts:
User can make event that can be visible on their profile.

There is also main view page with filters that has all events made by all users.

I want to give users option (YES/NO) to have the event listed on main view page with filters.

First what i think of is make simple vocabulary with terms YES and NO and in view filter show only those that have YES.

Since each term has its own link i don't want links YES and NO with all the content they have to be visible by search engines or somehow to be found by users.
I know i can disable them in robots.txt but maybe there is more simple solution to this ?


texts: Authcache: Getting user_link to work in template.php

texts:
Problem

I'm trying to set-up an Authcache customised menu.

The first way of doing it would be to create 3 menus, one for each of my roles and one for anon then create a custom tpl.php for each using the user_link and user_name variables.

(These variables are provided by the user example module in authcache to all templates.)

Block logic would then give the correct user the correct menu.

It seems a little clumsy.

Is it possible to grab the links inside template.php and use user_link and user_name variables there because I can't find a function which has the links available.

Or how has anyone else solved this problem?


texts: Looking for a module to hit a tokenized URL when certain actions happen

texts:
I'm working with an API from another software product. And the way to create/update records there is by hitting a specifically crafter URL.

Ex. https://sample.nodeurl.tld/save?xml&object=supporter&Email=mytest@email.com

Is there any way to do this with rules or via another module? Or does this have to be done through a custom coded module?


texts:
I have a custom content type named Movie.

Every user must have 2 lists of movies:

Seen movies
Not seen movies

For this purpose, I am using the Flag module to attach 2 links ("Seen" and "Unseen") on every movie page; with those, users can add the corresponding movie to their list.

I successfully made the two lists using the Views modules; users can see them when they are logged-in.

What I need is allowing users to see the movie lists of other users. How can I achieve this?

The "seen" and "unseen" lists should be mutually exclusive; if a movie is in the "Seen" list for user A, it cannot simultaneously be in the "Unseen" list for the same user.

How can I do this? Is there any other module, apart the Flag module, that could help me?

I am using Drupal 7.


texts:
I have created View and that is with edit node from admin side, and I want to send same view by printing in email and I am using code to print view in email like this

$items['user/%user/display']['access callback'] = false;
$viewName = 'example_view_1';
print views_embed_view($viewName);

But there is edit node link also whenever I see from admin side,but whenever I got same view in email then it will not show edit link of node, Let me know if anyone have solution.


texts:
As I mentioned in my previous question I'm attempting to write tests for a patch that will, ideally, trigger the creation of a redirect if the URI of a file changes.

My patch uses hook_file_update() which is called whenever file_save() runs.

Currently this chunk of code:

  // Move file to new URI
  $new_uri = 'public://qwerty.png';
  file_save($test_file);
  $test_file->uri = $new_uri;
  file_save($test_file);

This calls my hook and creates the redirect, but the redirect fails because drupalGet($new_url) returns a 404.

file_save() returns the error, filesize() [function.filesize]: stat failed for public://qwerty.png.

I've tried file_save() on URIs that linked to existing files, which gives an error, I've tried it on not-yet-extant URIs (as above), which gives an error, and I've tried file_move(), which doesn't call hook_file_update().

How can I programmatically change the URI of a file and trigger hook_file_update() inside a test?


texts: Passing Settings from Drupal Module to Javascript: Uncaught TypeError: Cannot read property

texts:
In my module I have the following code.

$my_settings = array(
    'basePath' => '/',
    'my_locs' => $my_locs // Array of numbers
);

drupal_add_js(array('my_module' => $my_settings), 'setting');

In the JavaScript I am supposed to retrieve settings as follows.

var my_locs = Drupal.settings.my_module.my_locs;

From Goggle Chrome console, I get the following error.

  Uncaught TypeError: Cannot read property 'my_locs' of undefined google_elev.js

These are the various output I obtain from the console.

>my_locs
undefined

>Drupal.settings.my_module.my_locs
[41, 9, 42, 9]

>my_locs = 2
2

>var my_locs
undefined

>my_locs = Drupal.settings.my_module.my_locs
[41, 9, 42, 9]

 >my_locs
[41, 9, 42, 9]

All the rest in the JavaScript file works perfectly; variables are readed, computed, snd used. Settings are loaded in Drupal.settings before loading the JavaScrip file with drupal_add_js().

I don't know what to try. I don't understand if it is a syntax problem, if I must define the var to be an array before, or if something tricky in the order of callings have to be accomplished.


texts: Configuration management and site specific configuration

texts:
I have different site environments for my site; dev, test and live site. On dev (local develop) my solr settings are different then on my live environment.

How do I configure site-specific solr configuration, so I am still able to export my configuration from my dev environment (drush cex) and import the configuration into my live environment using drush cim?

I know there is the config split module. Is this suitable for this, or is there a better solution? I want to controle and export all configuration only form my dev environment. I don't want to use drush cex on my live environment. Only import configuration (drush cim). The drush command drush cim is also implemented in the deploy script.


texts: How to add a custom class or id to a menu

texts: I have several menus that I want to use, and theme differently. I'm looking into different ways to theme them and it appears that the most elegant way would be to use the template.php file with menu tree. I'm not quite sure how to set different conditions for different menus in this file however.


texts: Adding a block to a page build with a call to theme (Drupal 7)

texts:
I have a page on Drupal site that needs to render a webGL canvas.  This page is visited by hitting an end point defined in hook_menu.  Here is the code I use to render the webGL page.

function inflatable_icons_canvas_page() {
    $base_path = drupal_get_path('module', 'inflatable_icons') . '/Online_Inflatable_Icons/IconEditor/public/';
    drupal_add_js(array('inflatable_icons' => array('basePath' => $base_path)), 'setting');
    drupal_add_css($base_path . 'js/dojo-release-1.7.2/dijit/themes/claro/claro.css');
    drupal_add_css($base_path . 'css/shared.css');
    drupal_add_js($base_path . 'js/includes.js');
    return theme('webgl_canvas');
}
function theme_webgl_canvas() {
    $html = file_get_contents(drupal_get_path('module', 'inflatable_icons') . '/Online_Inflatable_Icons/IconEditor/public/editor.html');
    $page = new SimpleXMLElement($html);
    $table = $page->body->table;
    $div = new SimpleXMLElement("

");
    sxml_append( $div, $table );
    return $div->asXML();
}

I also need to be able to add some blocks to this page (either programmatically created or created through interface builder), how would I add these blocks to my page which is created through loading the html file editor.html and calling theme.


texts: Shared Database With Domain Access and Multiple Accounts With Same Email

texts:
We are planning to have the following Drupal architecture:

One install of Drupal.
Multiple domains sharing the same database using the Domain Access module.

Each domain will have user login capabilities, and user accounts will not be shared across domains. This means we will have times when one email address could be associated with multiple accounts (one for each domain where the email address is associated with an account).

Is such an architecture possible using a shared database, or will we have problems trying to associate many accounts to the same email address?


texts: Create videoplayer shortcode module for drupal 7

texts:
I have a custom player I made (Using flowplayer) and would like to make a short code for the id of that player. For example, when the user pastes [myplayer 12345], it will display that player with the appropriate video.

Can anyone point tell me how to do this in drupal?
I know in wordpress it's simple like this:

add_shortcode('myplayer','myplayer_video');

    function myplayer_video($attr) {

    $output = '<iframe width="448" height="282" src="http://mysite.com/embed/' . $attr[0] . '" frameborder="0" allowfullscreen="false"></iframe>';

    return $output;
}

My understanding is I need to make a module and I have looked at many tuts on making modules in drupal, but none on how to access the content field and diplay something or php code.


texts: Behavior not attaching to a form element

texts:
I have a module for relating pieces of content to each other. My module successfully adds a field to all content-types that is essentially a list of integers, meant to hold node ID's. I want AJAX functionality such that when the user begins typing the title of a node, autocomplete suggestions begin appearing. I've already implemented the web service via Drupal to retrieve nodes based on partial titles, and that's working very well. The problem is now attaching the behavior I want to the form element.

Two problems:

1) No way to uniquely identify the form element in question. The class name is not going to be usable if there are more than one of them, which there may be. How can I force a unique class name? Something like class="content-relation" for each one?

2) The behavior I want to attach is failing to do so. I've tried a couple different ways...here they all are.

Way 1:

Drupal.behaviors.content_relation =  {
    attach: function(context) {
        jQuery('input.form-text').change(function() {
            var ul = jQuery('<ul />')
                .css({position: 'absolute', top: '0px', left: '0px'});

            jQuery.get(
                '/api/'+jQuery(this).val(),
                function (data) {
                    jQuery.each(data, function(item){
                        var li = jQuery('<li>');
                        li.html(item.title);
                        li.appendTo(ul);
                    });
                }
            );
        });
    }
};

Way 2:

jQuery.ready(function(){
    jQuery('input.form-text').live('change', function() {
        var ul = jQuery('<ul />')
            .css({position: 'absolute', top: '0px', left: '0px'});

        jQuery.get(
            '/api/'+jQuery(this).val(),
            function (data) {
                jQuery.each(data, function(item){
                    var li = jQuery('<li>');
                    li.html(item.title);
                    li.appendTo(ul);
                });
            }
        );
    });
});

...but none of the inputs with a class of form-text have this function listed in their change-listeners, nor do they respond to changes. Thoughts?


texts: How to translate "New custom content" in a panel?

texts:
I have a lot of panels to which I have added bits of text/HTML using the "New custom content" option of the Panels module.

By default, such text does not show up on the Translate Interface screen.  How should I go about translating them?

Two approaches I have found are:

Changing the custom content text format to PHP code and printing the string(s) of text using t().  This then allows me to translate the strings on the Translate Interface screen, but I worry that injecting PHP code like this is a bad precedent.
Since I only have two languages, I can add a second piece of custom content that is localized in the other language.  Then, I can add a visibility rule to each piece of custom content in Panels and set each piece to show only when the user's language matches the content language.  This works but it is time consuming and ugly on the backend.  It would be even worse if I decide to add more languages to my site in the future, which I may do.

Is there a more efficient, maintainable way to translate such custom content?


texts: How can I get a relation by the endpoints using the "Fetch entity by property" action in rules?

texts:
Short version: I want to fetch a relation by the endpoints.  The relation already exists in the database.  How can I use the Fetch entity by property action to return the relation?

Long version:

I'm using the Rules and Relation modules on Drupal 7.  I have a relation type that is created between two users (the endpoints are user entities).  The relations I am trying to fetch have already been created.

When one user sends a message to another with the Private Message module, I want to fetch the relation between the sender and the recipient.

Here is the rule:

Event: A message is sent (from Privatemsg module)

Action: Add a variable (List of any entity items, endpoint_list)

Action: Add an item to a list (Add privatemsg-message:author to endpoint_list)

Action: Add an item to a list (Add recipient to endpoint_list)

Action: Fetch entity by property (Entity type: Relation, Property: Endpoints, Value: endpoint_list, Limit results: 10, provides fetched_relation)

However, when I try to perform another action (loop, data comparison, data set, etc.) on fetched_relation, I get the following error in the rules debug log:

  4.468 ms Unable to get the data value for the variable or parameter value. Error: Missing data values.

It appears that the relation is not fetched.  However,

I am sure the relation exists in the database with the correct endpoints (the relation appears in the UI correctly and I even checked the MYSQL table).
When I add an action Print message and print privatemsg-message:author:name and recipient:name, it shows me the names of the correct users, so those variables appear to be correct.
I have looked at the documentation for fetching relations with rules but I can't see what I am doing wrong.


texts: Published content goes offline when edited - most prevalent on popular content

texts:
We have a Linux Drupal 7 environment with memcache and mariadb.
It appears that if a page/content is being hit when an editor is publishing an update, the page can be taken offline.  It can take several attempts after that to publish the updated content, as i suspect the page editors are continuing to attempt to publish while the page is being hit.  Eventually they are able to publish.
Is there a memcache setting or something that could be done to avoid this?  Preferably without pulling traffic to one of the WFEs, and having the editors attach directly to that server to perform their publishing operations?


texts:
Ok here is my problem;

I have a list of boats. Each boat have a list of engines that can be fitted to it. Engine is not in anyway coupled with boat as a particular engine can be mounted to any kind of boat.

Boat is a content type, Engine is a content type. Boat has a field of multiple engines in it.

I want this to output in json like this:

[{
    "title":"boat_name",
    "engines":[{
                 "title":"engine_name",
                 "model":"model_nr"
               },{
                 "title":"engine_name2",
                 "model":"model_nr2"
               }]
}]

I've tried to accomplish this through the RESTful web service module by creating a REST export view, but there is no formatter that seem to give me json output. I've understood that you could accomplish this by using View Field View but in my case it would require the engine to have a reference to a specific boat, am I right? That is not really what I want.

Is there any other way I can accomplish this?


texts: Screenfly alternative for testing Drupal 8 sites

texts:
For Responsive screen testing I am using Screenfly (http://quirktools.com/screenfly/).

Drupal 8 can not be displayed inside an iframe (see link, par. 9). This is the reason why Screenfly can not be used to test Drupal 8 sites by default.

Are there any alternatives to Screenfly for responsive screen testing?


texts: Migrate single fields into field collection

texts:
Really enjoy this module, I use it (nearly) in all my projects.
As many people I'm facing the following problem : my client's requirement have changed and I have to create a field collection from 4 existing single fields (vimeo URL, file, image and long text). Hundreds of nodes have already been created, no way to start over. This is a production site with many users.
What options do I have ?


texts: Running cron without setting a cron job on web server

texts:
I know that in Drupal 7 Poormanscron is part of the core, but to have cron running I need the site must be visited regurarly and it's not my case.
I can't set up a cron job on web server to periodically run cron.

Is there any way to run cron periodically without setting a cron job on web server?


texts:
I have a function like:

function MYMODULE_menu() {
  $items['cars'] = array(
    'title' => 'Cars',
    'page callback' => 'section_index',
    'page arguments' => array("cars"),
    'access arguments' => array('access content'),
    'file' => 'pages/section.inc',
    'type' => MENU_CALLBACK,
  );
}

It works fine. Going to cars calls this page. I have a load of node pages like cars/ford and cars/volvo and they get called. However. If you go to cars/volvvvo (for example), it calls the "cars". No 404 is triggered etc.

This also seems to mean that the breadcrumb is glitchy for other pages called by hook_menu which have cars in the path, e.g.

 $items['cars/help'] = array(
    'title' => 'Cars Help',
    'page callback' => 'cars_help',
    'access arguments' => array('access content'),
    'file' => 'pages/help.inc',
    'type' => MENU_CALLBACK,
  );

Has a mangled breadcrumb with additional paths to "cars" in it.

Am I missing something? Is there a way to stop additional arguments being just silently pased through via hook_menu?