texts:
I have a pane on a Dashboard page that's supposed to be an accordion.

It's supposed to update user information. I still haven't figured out how can I add user fields inside this pane, for example:

Update your information:

Name      _______

Password  _______

E-mail    _______

etc.

Is that possible? Do I have to use a preprocess function to add that?

Thanks in advance.


texts: Mathematical operations and Twig variables

texts:
Is it legal to do this in a node template with Drupal 8?

{% set percentVariable = content.field_my_customfield.0 * 100 / content.field_my_second_customfield.0 %}

which will be output like this

Both fields deliver integer values to that variable

Is there any major syntax error or misunderstanding in doing so?


texts: How to redirect according to URL parameter after form submission

texts: Currently I'm using Drupal as my authentication system, and I would like to redirect user to our main site after login, according to an URL-passed parameter, for example user/login?redir=http://google.com. And yes I've found out there is a destination parameter however it doesn't work it the passed argument begins with http or somehow a non-Drupal path. Any ideas? hook_drupal_goto_alter is a hook I found might be helpful, but not sure how to implement it.


texts:
I have a site that generates letters to be sent to schools.

The visitor arrives at the front page where they are presented with a map (leaflet map) with all the local schools marked on it. They then can click on a specific school to view its page (node with school location (addressfield) info).

Here they have the option to 'generate a letter to the school' - I have the form (entityform) set up but it needs the visitor to type in the school address again. How can I dynamically fill the address-field in my form  based on the school the visitor navigated to the form from?

map>school>school-specific-form

There are over a hundred schools, so would prefer not to have to duplicate my form...

Thanks.


texts: How do I make the bootstrap dropdown menu work?

texts:
I like to install in a bootstrap subtheme dropdown menu. But it does not work in my subtheme. Using the bootstrap theme it works.

my jolly.info.yml looks like this
    core: 8.x
    type: theme
    base theme: bootstrap

name: 'Jolly'
description: 'Theme for ...'
package: 'Bootstrap'

regions:
  navigation_collapsible: 'Navigation (Collapsible)'
  header: 'Top Bar'
  highlighted: 'Highlighted'
  search: 'Suchleiste'
  help: 'Help'
  content: 'Content'
  sidebar_first: 'Primary'

libraries:
  - 'jolly/global-styling'
  - 'jolly/bootstrap-scripts'

my jolly.libraries.yml looks like this

global-styling:
  css:
   theme:
     css/style.css: {}

bootstrap-scripts:
  js:
    bootstrap/js/affix.js: {}
    bootstrap/js/alert.js: {}
    bootstrap/js/button.js: {}
    bootstrap/js/carousel.js: {}
    bootstrap/js/collapse.js: {}
    bootstrap/js/dropdown.js: {}
    bootstrap/js/modal.js: {}
    bootstrap/js/tooltip.js: {}
    bootstrap/js/popover.js: {}
    bootstrap/js/scrollspy.js: {}
    bootstrap/js/tab.js: {}
    bootstrap/js/transition.js: {}

   dropdown:
    css:
      css/styles.css: {}
    js:
      js/dropdown.js: {}

and I use the same

  menu--main.html.twig

like the bootstrap theme.

I try so many things but do not find what's wrong or what kind of dependency is necessary.

Can anybody help?


texts: How to check if entity id exists or valid?

texts:
I have created a content entity type. When I save form, I got id in routing url, like:

entityform/1

entityform/2

But if I directly access some non-existing id like entityform/999, page dies.

In watchdog, it is showing error,

  Error: Call to a member function get() on null in Drupal...

I can not call function get() on the fields of entity, if entity doesn't exists.

$content_type = $entity->get('ctype')->value;

How to apply this check, whether entity actually created or not?


texts: What are the advantages of using Apache Solr over the core search module?

texts:
The Apache Solr Search Integration module project page states:

  Solr search can be used as a replacement for core content search and
  boasts both extra features and better performance.

What exactly are these extra features?  (Or if there are too many, in what kind of use cases would I want to use Apache Solr?)

My site is hosted on Pantheon and they provide Apache Solr at no additional charge.  Would this be something I definitely want to set up?  Only set up in certain cases?


texts:
I created a view and I'd like to wrap it with a link in a template file. I've never worked with custom template files for views, so I've no idea where to start.

How can I do this?


texts: Show highest and lowest price in a view from a node reference

texts: I have a content type called Cars, and a content type called Prices.  They are node referenced.  The Prices content type has a decimal cck field for the price called field_price.    So you can create a new Prices node that will have the price for the car.  There are multiple Prices nodes for each Car node.  In views, how would I be able to show the lowest and highest prices for the car.  For instance, it would say, Prices for this car range from $10,568 to $18,259.


texts: Why is the AJAX replaced drop-down list value not being submitted?

texts:
I have an AJAX method for when a value is selected from the source drop-down list the target drop-down gets replaced with new values. The problem is that the new replaced drop-down list selected value is not being submitted (e.g. not in $form_state['values']['target'] = 'not the val I selected'). It looks like the value submitted is from the target drop-down list that is default from when the page first loads.

Any ideas as to why this is happening?

function dashboard_node_filter_form(){
  ...
  $form['filters']['source'] = array(
      '#type' => 'select',
      '#options' => source_options(),
      '#title' => 'Source',
      '#ajax' => array(
          'callback' => 'dashboard_node_filter_target',
          'wrapper' => 'edit-target',
          'method' => 'replace',
          'effect' => 'none',
       ),
  );
  // when source is selected this gets replaced
  $form['filters']['target'] = array(
      '#type' => 'select',
      '#options' => get_,
      '#title' => 'Target',
  );
  $form['filters']['submit'] = array(
     '#type' => 'submit',
     '#value' => 'Submit',
  );
}

function dashboard_node_filter_target($form, &$form_state) {
  return $form['filters']['target'] = array(
      '#type' => 'select',
      '#id' => 'edit-target',
      '#options' => display_options($form_state['values']['id']),
  );
}


texts:
How do you add publishing options to a custom entity or it's bundles?
Currently when I create a new Entity entry I only have a save option. I would like to add published and unpublished states.


texts: Adjusting the month being viewed on the Calendar Block to match the month of the Day being viewed

texts:
So, I am using Drupal 7 with the Calendar Module. I am using the calendar block as the primary calendar for viewing events daily events. Everything works great, except the calendar block doesn't change its month being viewed to match the day being viewed.

For example. The calendar block is visible and starts at the month of November (because it is November). You browse to December and click on a day to view that day's events. The page loads and shows the events for that particular day in December, but the calendar block defaults back to November. I want it to show December since I am viewing a day in that month

Is there a way to have the calendar block show the month that matches the day being viewed?


texts:
How can I add the Google+ option in the ShareThis module? They posted a blogpost on the 6th of July where they stated the Google+ and Facebook options are added to the module. But when I download the module, there is no such thing as a Google+ button...

However they say it's easy to implement, I didn't find any way how to do this. So if anyone would like to help me out here, it would be much appreciated!


texts: Remove link to terms page when printing taxonomy term on node--content_type.tpl.php?

texts:
I have a node--content_type.tpl.php template where I want to print the taxonomy term associated with the current content as plain text so that I can surround it with a div class to print a special label for content with the selected term.

So for example I have chosen "Sold" as a taxonomy term and want to display the word with no link to the taxonomy terms page. It currently outputs as "<a datatype="" property="rdfs:label skos:prefLabel" typeof="skos:Concept" href="/taxonomy/term/6">Sold", so links to the taxonomy terms page.

I am currently using this code to print the term:

<?php

if(!empty($node->field_p_status['und'][0]['value'])) {
  $status = $node->field_p_status['und'][0]['value'];
}

?>

<?php if(isset($status)) { ?>

<?php print render(field_view_field('node', $node, 'field_p_status', array('label'=>'hidden'))); ?>

<?php } ?>

Any idea how to strip it down so it prints just "Sold"?


texts: What is the node:id cache tag equivalent for blocks?

texts:
I am wondering why the last two entries do not work:

public function getCacheTags() {
  $tags = [
    'node:270',
    'node:271',
    'node:273',
    'node:282',
    'block:customblockname',
    'block:7',
  ];
  $cacheTags = Cache::mergeTags(parent::getCacheTags(), $tags);

  return $cacheTags;
}

When I edit my custom block the URL is:

  /block/7?destination=/admin/structure/block/block-content

The actual id of the block (for instance when embedding it) is customblockname.

What are the correct cache tags to include that block in my caching?


texts: How can I create multiple chatrooms using the Drupalchat module?

texts:
I want to create multiple chat rooms in DrupalChat module.

Anyone can help me to complete this requirement?


texts: Alter titles of account tabs containing views tabs

texts:
I can easily alter titles in user account tabs from inside template.php like so

function custom_theme_menu_alter(&$items) {
          $items['user/%user/edit']['title'] = 'mytitle1';
          $items['user/%user/view']['title'] = 'mytitle2';
                }

The user menu contains also tabs created by views (as pages). The problem is that every time the view gets new data, the tabs change back. I need to flush cache in order to see altered titles. What can be done about this? Thank you.


texts: I wonder if someone could tell me how to add details for each image I have for my content on my Drupal 7.32 website (say title and description). For Example, I have a Content Type called Info, this has an image field which can have an unlimited number of images. When I upload the image I would like to also add details about the image. I remember seeing a Module that will allow that, but Ive been googling and I cant find it now. If this is not possible then I guess I will have to link the Image to another node and add the detail there. If you take a look at my About Us page on my website (http://www.caerleonlodgehillprimary.org/about-us), it has 3 images at the bottom, I would like to be able to show a title under each one, maybe some description too.


texts: How can I exclude some entities in "drush entity:delete" command?

texts:
I want to delete all content of custom entity type except some specific items, I found drush entity:delete CUSTOM_TYPE command to delete all contents but couldn't exclude some items from deletion in this command, does it have any option like --exclude ID1, ID2, ID3, ...?

Or is there any other way to do this?


texts:
I'm currently doing recruitment system by using drupal 7.. In my system, the user (anonymous) need to register before they can log in into the system. For log in and registration, i use LoginToboggan module. i also use the captcha module to avoid from spam.
However, when i look at the people..there is a lot of unknown user.. and it seems like spam.
what should i do?


texts:
Has anyone successfully gotten cron jobs to work with GoDaddy shared hosting and Drupal 7.x?

This sort of thing is EASY if you have access to use wget or cURL but GoDaddy for some reason blocks access to their own shared servers through tools as wget and cURL. Why I don't know.

We are stuck with having to use

/web/cgi-bin/php "$HOME/html/drupal/cron.php"

but as described here: http://drupal.org/node/251481

that is bad since Drupal doesn't go through its bootstrap process and certain vars are not initalized. I also get the classic:

Status: 404
Content-type: text/html
No input file specified.

when I use this method. There is also the fact that D7.x requires a cron_key parameter passed along _cron.php?cron_key=XXXXXXXXXXXXX

Anyone have a solution...besides get the hell off GoDaddy?


texts: drush ard fails with error Database dump failed, drush 5.10.0 drupal 7.39

texts:
sudo drush ard -v --destination=sites/default/files/sitearchive.tgz

fails with error "Database dump failed"

Initialized Drupal 7.39 root directory at /var/www/drupal                                                                                [notice]
Initialized Drupal site default at sites/default                                                                                [notice]
php /usr/share/php/drush/drush.php  --backend=2 --verbose --root=/var/www/drupal --uri=http://default  sql-conf   --all 2>&1                                              [notice]
Executing: tar  --exclude "drupal/sites" --dereference -cf /var/www/drupal/sites/default/files/drupal.20161018_203926.tar drupal
Executing: tar  --dereference -rf /var/www/drupal/sites/default/files/drupal.20161018_203926.tar drupal/sites/all
Executing: tar --dereference -rf /var/www/drupal/sites/default/files/drupal.20161018_203926.tar drupal/sites/README.txt
Executing: tar --dereference -rf /var/www/drupal/sites/default/files/drupal.20161018_203926.tar drupal/sites/example.sites.php
Executing: mysqldump --result-file /tmp/drush_tmp_1476823166_5806887e850ef/drupal.sql --no-autocommit --single-transaction --opt -Q  drupal --host=xxxxxx.ceiixl6nbq74.us-east-1.rds.amazonaws.com --port=3306 --user=xxxxxxx --password='xxxxxxxxx'
Database dump failed.                                                                                [error]
Command dispatch complete

I haven't really used Drush, but I'm working through migrating a site to Pantheon and this is the way they suggest.

Here is the output of drush status. (the xs are subbed in for identifiable info)

sudo drush status
 Drupal version                  :  7.39
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database hostname               :  xxxxx.ceiixl6nbq74.us-east-1.rds.amazonaws.com
 Database username               :  xxxxx
 Database name                   :  xxxxx
 Database                        :  Connected
 Drupal bootstrap                :  Successful
 Drupal user                     :  Anonymous
 Default theme                   :  mytheme
 Administration theme            :  mytheme
 PHP configuration               :  /etc/php5/cli/php.ini
 Drush version                   :  5.10.0
 Drush configuration             :
 Drupal root                     :  /var/www/drupal
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Temporary file directory path   :  /tmp

Attempting to run the mysqldump command as shown in the output of the drush command (as suggested in the comments) simply returns 'mysqldump: command not found'

Can anyone shed some light on this problem? I have zero experience with drush so I'm not even sure how to troubleshoot it.

I'm happy to provide any additional information deemed useful.


texts: Dynamically set theme per block/paragraph

texts:
I'm looking to apply specific themes to individual items on a page - a different theme to the rest of the page.

I realise this seems quite obscure, but the general premise is similar to a styleguide.

A themed page/site which describes the behaviour of a paragraph/block, with a rendered version of the paragraph/block, using a second theme - from a site where it's previously been used.

I know there are ways to set a theme per page (ThemeNegotiator) but I'm at a loss for where to begin with a component…


texts: Why am I unable to go to admin content in one of my websites?

texts:
I am unable to go to admin content in (one of my websites using) Drupal 7

https://www.youtube.com/watch?v=fLFP7o0omuM

What would cause this?

I am unable to access any admin pages in Drupal 7. And this happened after I uploaded all the files from backup and I asked the internet hosting company to do a database restore to a back up a month ago when the web site was working fine.


texts: Load current node from block and from display suite field

texts:
Sorry if this question is too obvious, I need to load the current node from display suite and then execute this php code:

<?php

$project = node_load(5);

foreach ($project->field_gallery['und'] as $val ) {
  echo '<img src="' . $val['filename']  . '">';
}

?>

In display suite I tried:

$project = node_load($nid);

and

$project = $entity->nid;

I also tried the same within a block, and it failed. It only works when I set a static id as node_load(5).

Please, can I get the answer how to load the node from display suite custom field and from a simple block?

Edit: I'm adding a custom field to display suite from this url:
 /admin/structure/ds/fields/manage_custom
Structure > Display Suite > Fields > Add a code field.


texts: How to associate the current Node ID when running from Block layout?

texts:
I created a Drupal 8 View that creates a block of content associated with a content type.  The block has a context filter of "Content: Node ID". I can place the Node ID of different nodes in the Views Preview and receive different content for each Node ID.  The Views Block seems to be working well in Views Preview.

I would like to place this Views Block in a region of Block layout.  I need the block to obtain the Node ID of the current node so it will display unique content for each different node -- just like in Views Preview.  I have not been able to figure out how to associate the current Node ID when running from Block layout. Some blocks have this ability -- for example "Page title" and "Main page content" that ship with Drupal 8.  Is it possible to give me Views Block this ability?

I've thought of two alternatives to what I have written above:

write a module that creates the block I need -- obtain the current Node ID and display the Views Block.
integrate the Views Block into the twig file associated with the content type -- when the node is displayed, twig will call Views with the Node ID and return the needed content.

Any suggestions?


texts: Rules Loop does not fully loop through checked taxonomies

texts:
I have a content type that has a field which references my Country taxonomy. The field settings are set to unlimited so it is displayed as checkboxes.
The country field is also displayed on the users profile so they can choose which country they are from.

What I want is to be able to choose several countries on my new node and then have rules send an email to all the users who have those countries set on their user account.

What I have so far is:

Loop: Node: Country field
 Fetch data by property: user/user country field/current list item:tid
 Loop: Fetched data
   Send email to the user

Unfortunatly it only seems to register the first taxonomy in the list and send the email. I cant seem to work out why the loop stops after the first taxonomy.

Can anyone help?


texts:
I'm trying to filter my view based on data in a single field. My field targetuser contains a string of numbers: 47,505,100,20.
I'm trying to setup the view so that if targetuser contains the logged in user ID (in this case, that's 47), the content should be visible.

However, the setup I have now only works if a single number is inside that field, not four numbers.
How can I accomplish this?
Note, I've installed the Views Argument Substitution module. The settings for the second contextual filter I'm referencing are the following.
content:targetuser:provide default value: logged in user id

Update: For those wondering, the existing Contextual Filters so far do the following:
Show node if:

Content: Author uid (logged in user is also the author of the node)
Content:targetuser (if target user is equal to logged in uid)OR IF
Content:targetuser (if target user field is equal to 9506)


texts: How to create global pattern for terms title (not page title)?

texts:
I'm trying to override the titles of taxonomy terms. Not the page title, the heading tag at the top of the taxonomy term page.

I found the Taxonomy Title module that created to control the title individually for every term.

  This module was designed to update the heading tag at the top of the
  taxonomy term page. The contents of this H1 (or sometimes H2) tag are
  extremely important for SEO (Search Engine Optimization).

This module seems good but it doesn't give us the option to set global patterns for taxonomy terms, we can only set titles individually for each term.

There is an issue opened about global pattern but there is no solution presented.

How can I create global patterns for taxonomy terms?

Example (from the issue):

A real estate company is listing its offerings and each property is tagged with location.

Then for the location vocabulary I could set a pattern "Properties in the [term] area".

Note 1: the Page Title module doesn't give us the opportunity I wanted but we can set global patterns for page title with that module.

Note 2: It's possible to set global title pattern with the Automatic Nodetitles module for only nodes. I wonder if it is possible to use this kind of module (or piece of code) to set global pattern for taxonomy terms.


texts: How do I disable the taxonomy term page?

texts:
I would like to disable the taxonomy/term/1 page that list the nodes using that taxonomy term. I have found some modules for older Drupal versions, but I haven't found quite what I'm looking for in Drupal 8.

Is there a configuration setting I am missing? Can I use a hook to disable the taxonomy term page, or does this require a module?


texts: How to apply the attribute "rel=nofollow" to links in the comments?

texts:
I configured the Text Format "Plain text" (admin/config/content/formats) to "Convert URLs into links" so I would like to add the attribute rel="nofollow" to all the links in the comments.

This way I would minimize the effects of spammy links in the comments.

Is there an easier way than using regular expressions to insert the attribute?


texts: What is the appropriate way to store arrays of information with configuration API?

texts:
In Drupal 7 with custom forms and variables, one could easily store arrays of information in the 'variables' table. I would sometimes construct configuration forms that provided a setting per say user role. Then I could either store the setting for each role in a separate variable, or pack all the settings into one array and store it that way.

I am wondering what the standard best practices way of doing a similar thing in Drupal 8.

in Drupal 7 I would have something like this for a form code:

// build list of roles
  $user_roles = user_roles(TRUE);
  // remove authenticated user role from options
  if (isset($user_roles[2])) {
    unset($user_roles[2]);
  }
$role_settings = variable_get('MYMODULE_role_type_mapping', $role_settings);
foreach ($user_roles as $rid => $role) {
      $form['roles']['other_roles']['MYMODULE_role_' . $rid . '_type_mapping'] = [
        '#title'         => $role,
        '#type'          => 'select',
        '#options'       => $membership_types,
        '#default_value' => !empty($role_settings[$rid]) ? $role_settings[$rid] : '',
      ];
    }

and then something like this in the form submit callback:

    // build list of roles
      $user_roles = user_roles(TRUE);
      // remove authenticated user role from options
      if (isset($user_roles[2])) {
        unset($user_roles[2]);
      }
      foreach ($user_roles as $rid => $role) {
        $role_settings[$rid] = !empty($form_state['values']['MYMODULE_role_' . $rid . '_type_mapping']) ? $form_state['values']['MYMODULE_role_' . $rid . '_type_mapping'] : '';
      }
variable_set('MYMODULE_role_type_mapping', $role_settings);

This type of thing is necessary when you install the custom module on multiple sites, where there could be different number of roles on each site.

So now with Drupal 8 we have this new Configuration API. I can't assume I know the roles in advance.

I was hoping to achieve this with "Simple Configuration" but I realize it may be necessary to create a custom configuration entity, although if it can be done without that that would be nice and "simple".

According to this resource: https://www.drupal.org/node/1905070#types
There are just a few schema types for configuration fields, none of which seem intuitively appropriate to this case.

Reading that page, it is not obvious even how one would store the value of a multi-valued select list in configuration, let alone variable that could be an array of all kinds of different information. In D7 a multi-valued select list would return an array. In D7 variables are stored as serialized variables. Even D7's "simple_settings_form" would handle this no problem.

Surely this type of problem has been solved many times, but it is not "simple" to find any information.

So the problem is two-fold
1) Just storing an array of values into configuration, with unknown number of array elements, number depending on custom site conditions (like user roles on a site)
2) Unpacking this array and setting up form elements for it, which on submit, packs it all up into one variable.

Similar question, simpler question is:
If one is defining configuration schema for a multi-valued select list, what data type does one use? String?

Is the model I used here for D7 even portable to D8, there's probably some better way to go no doubt, but making a configuration entity for each role in the site and all of that doesn't seem simple and definitely not as simple as could be done in D7. I do want to give a thought to config export / import between sites. dev/staging/production versions of the site may all have the same user roles, but definitely not separate websites altogether.

Although I ask several questions in this post, the common theme is how to store arrays of information as configuration appropriately in Drupal 8? Simple case is the value of a multi-valued select list, more complex scenario of the setting per user role like I describe.

Thanks in advance!


texts: template preprocess override not respected

texts:
I'm using Drupal 7.

I have a template preprocess function overridden in my template.php as

It does not alter the output as desired.

When I comment out (or delete) the original preprocessor (template_preprocess_views_exposed_form(&$vars))
in the contrib module's theme.inc, the overridden preprocess function then takes effect as it should.

What do I have to do to get my preprocess to work without having to hack a contributed module?

Here is the offending code:

function ncmr_preprocess_views_exposed_form(&$vars){
  $form = $vars['form'];

  if ($form['ncmr_days_only']) {
    $form['ncmr_days_only']['value']['day']['#options'] = array(
      '' => 'Select Day',
      '5' => 'April 5',
      '6' => 'April 6',
      '7' => 'April 7',
    );

    $form['ncmr_days_only']['value']['day']['#printed'] = FALSE;
    $form['ncmr_days_only']['value']['month']['#value'] = 4;
    $form['ncmr_days_only']['value']['month']['#printed'] = FALSE;
    $form['ncmr_days_only']['value']['year']['#value'] = 2013;
    $form['ncmr_days_only']['value']['year']['#printed'] = FALSE;

    $vars['widgets_ncmr']['filter-field_session_date_value']->widget = drupal_render($form['ncmr_days_only']['value']);
  }
}


texts: How to translate $value in the output code of a view?

texts:
I have created a view in which I'm retrieving a time format, whose output is printed by $value.

Here's my Value Code:

$node = node_load($data->nid);
$wrapper = entity_metadata_wrapper('node', $node);
$auction_timeout = $wrapper->auction_timeout->value();
$sub = $auction_timeout - time();
$dtF = new DateTime("@0");
$dtT = new DateTime("@$sub");
return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes');

And the Output code is:

<?php
    print ($value);
?>

The output is in English which is something like:

  35 days, 20 hours, 50 minutes

And I want it as

  35日、20時間、50分

I couldn't find how to translate it. Can anybody help me?


texts: The $directory variable doesn't contain the correct value

texts:
When I print the content of $directory in my theme's page--front.tpl.php, it outputs "modules/system."

This is not I want; I want to output "sites/all/mytheme/images/…." How can I do it?


texts: Add to cart form AJAX not working when loading a product display via AJAX

texts:
I am trying to create "quick buy" functionality. I have a product listing and a customer is able to click on "quick buy" for that product and then I want to be able to load up a view mode for that product display in an overlay which has a few product display fields including the add to cart field.

I can get the loading of the product display via jQuery load (or ajax) no problem, the issue is that the add to cart button is not working via ajax and the customer is instead redirected to the callback (which is now the action in the add to cart form).

Javascript code to load product display node:

$('.quick-buy:not(.ajax-processed)').addClass('ajax-processed').click(function(e) {
  e.preventDefault();
  $.ajax({
    url: '/product/get/ajax/'+$(this).attr('rel')
  }).done(function(result){
    $('#quick-buy').html(result);
    Drupal.attachBehaviors();
  });
});

Module code:

function tweaks_menu() {
  $item['product/get/ajax/%'] = array(
    'page callback' => 'tweaks_get_product_ajax',
    'page arguments' => array(3),
    'access arguments' => array('access content'),
  );
  return $items;
}

function tweaks_get_product_ajax($nid) {
  $node = node_load($nid, NULL, false);
  $node_view = node_view($node, 'product_quick_buy');
  $html = drupal_render($node_view);
  print $html;
}

I have also tried:

function tweaks_get_product_ajax($nid) {
  $node = node_load($nid, NULL, false);
  $node_view = node_view($node, 'product_quick_buy');
  $html = drupal_render($node_view);

  $settings = FALSE;
  $javascript = drupal_add_js(NULL, NULL);

  if (isset($javascript['settings'])) {
    $settings = '<script type="text/javascript">jQuery.extend(Drupal.settings, ';
    $settings .= drupal_json_encode(call_user_func_array('array_merge_recursive', $javascript['settings']['data']));
    $settings .= ');
  }

  print $html . $settings;
}

...to no avail.


texts: Field sharing between translations of a node?

texts:
Assume I have a content type which I want to be translated to 5 languages! And assume that my content type has 10 fields, with 7 of them being some numbers and 3 of them are text.

There is absolutely no need for these 7 fields to be translated to each language. But when I translate each content I should spend a lot of time on filling same values for each language.


texts: Listing all entity properties identifying unique entity instance?

texts:
Is there a generic way of knowing what collection of properties on an entity identify it as a unique instance?

For example, a node has a node id, and a revision id. Some entities do not have the revision id, other entities might require further keys.

Usecase example: Storing various entities in an external system, one wants to be sure to store enough data to be able to uniquely identify the resources in that system.


texts: I want to know how can i display the Last saved date and time of the article to the users. How can i do that ? since it doesn't appear on the Manage display fields ?


texts: In order to change a settings file, i accidentally replaced all files and folders permissions in folder "sites/default" to 777. Do i have to change all files and folders to 555?


texts: How can I 'trim' the users returned by a user reference fields' autocomplete widget?

texts:
By 'trim' I mean that I want to restrict the usernames returned according to some criterion. For example, if I enter 'S' into my user reference field, I want the drop-down list to contain all usernames begining with 'S' and where, for example, the users favourite color equals 'Red'. 'Favourite color' would be a field added on to the user entity.

My first idea is to use hook_query_alter to add a condition clause to the relevant query in user_reference module, but I'm not sure if this is possible. Has anyone done something like this before?

Thanks


texts: How to handle if Drupal site goes down, show a static fallback page instead?

texts:
One of my sites went down with the following mysql server down message:

How can I show a basic static page when something fatal like this happens? Are there any modules that do this already? What are some other solutions if a site goes out. I tried cloudflare, but they don't already detect the site going down and still show a fatal message. It would be good if users were shown a static page instead.


texts: Excluding Book children from a Custom view

texts:
We have a News site that displays all news articles on the homepage and subpages that display only those items tagged with a certain Taxonomy term.  So for example we have a World News term so going to www.example.net/worldnews will only show those articles with that term.  That works great.

Now we have a request to also filter on Book Content type, so that instead of showing just Article Content nodes we want Article and Book.  For the Homepage we'd use the same sort of filter that we did for Article, and that works well.  However on the subpages, Book parents AND children are showing up.  Is there a way to make sure no children ever show up on the subpages ( but of course would still be accessible the usual way from the parent and siblings )?  I've played around with Contextual Filters but can't quite get it right.

We do have some module code written that uses this View so it may be that I need to go that route and write some code, but would love to see if a View-only solution is possible.


texts: How to modify add to cart form in detail

texts:
Currently add to cart form can be modified from the "manage form display" of the line item. But this place shows all the attributes as a single entry.

Where is the best place to modify the sorting of attributes, inject other elements to the form between attributes etc?

For example I want to show an image field (from product) just before "add to cart" button. Should I use form_alter or is there a twig file that I can readily use?


texts: Creating Custom Modules tutorial doesn't work - help!

texts:
I'm trying to teach myself how to create a custom module using Drupal 8, and followed the instructions on their website at this Drupal.org documentation page

I created the folders, hello_world.info.yml, hello_world.routing.yml and HelloController.php pages and have been over them time and time again looking for typos, but can't find any.

I've got to the step to add add a routing file.  The module appears in the Extend area, but when I enable it and click Install, after a short pause I get the error "The website encountered an unexpected error. Please try again later."

When I go back to thet Extend, the module is ticked and I presume installed.

However when I then try to display it using the URL "/hello", I get a "Page Not Found".  Not only that, but every time I try to clear the cache, there is a delay and I get the same "Website encountered..." error again.  I can only clear the cache by uninstalling the module.

I've included the content of the three files below:

/modules/hello_world/hello_world.info.yml

name: Hello world Module
description: Creates a page showing "Hello world"
package: Custom
type: module
core: 8.x

/modules/hello_world/hello_world.routing.yml

hello_world.content:
  path: '/hello'
  defaults:
    _controller: '\Drupal\hello_world\Controller\HelloController::content'
    _title: 'Hello world'
  requirements:
    _permission: 'access content'

/modules/hello_world/src/Controller/HelloController.php

<?php
    namespace Drupal\hello_world\Controller;

    use Drupal\Core\Controller\ControllerBase;

    class HelloController extendes ControllerBase {

        public function content() {
            return array(
                '#type' => 'markup',
                '#markup' => $this->t('Hello World'),
            );
        }
    }

Does anyone have any suggestions what might be wrong?


texts: When should I create multiple Displays of a View instead of multiple Views?

texts:
Is it simply a matter of convenience to create multiple Displays of a View instead of multiple Views, or is there a performance benefit?

Does having any of the following items present in some Displays but not others affect the View as a whole?

contextual filters
content type filters
aggregation

For example, I'm curious whether having a display show just Article content type results, another showing Forum results, another showing a custom Photo content type makes each display run slower.  Or if the Views all share the same content type, but differ only in that one has a contextual filter for nid, and the others don't, do they all slow down?

If I have 30 Displays for a single view, should I refactor it for performance benefit, or just because the UI wasn't meant to show that many Displays.


texts:
I'm using Drupal 7. I want disable link on some node-title.

Like disable ''Link this field to the original piece of content'' in Views.

How can i do this? For example, via template.php?


texts:
On every page, maintenance theme is getting applied along with the user login boxes below the page after logging in. This is the state of the site which was handed over to me. I think this exists from a long time and no one gave importance to this issue.

This is my body tag obtained from inspect element (Chrome)

body class="marinelli html front logged-in no-sidebars page-newmain toolbar toolbar-drawer admin-menu" id="maintenance-page" style="padding-top: 65px;">

Please help me with this issue.

edit:
Uncaught TypeError: $ is not a function
    at marinelli:133
This is the information obtained from inspecting element.
It seems to be present in CDATA.. Where can i find CDATA?

    //grab all header rows
    $('th').each(function (column) {
        $(this).addClass('sortable').click(function () {
                var findSortKey = function ($cell) {
                    return $cell.find('.sort-key').text().toUpperCase()+ ' ' + $cell.text().toUpperCase();


texts: Go to Checkout Complete without checkout payment

texts:
I created a field field_cel_ck_scholar. It's a boolean.
I created this field in a customer profile type. My customer profile type is added in a pane in my checkout.

When this field is equal TRUE, I want by pass the checkout/%/payment's page and to redirect the checkout/%/complete's page.

It's possible ?

I try to use Rules like so:

{ "rules_by_pass" : {
"LABEL" : "by pass",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_checkout", "commerce_rules_extra" ],
"ON" : { "commerce_rules_extra_process_checkout_page" : [] },
"IF" : [
  { "entity_has_field" : {
      "entity" : [ "site:current-cart-order" ],
      "field" : "field_cel_ck_scholar"
    }
  }
],
"DO" : [
  { "commerce_checkout_complete" : { "commerce_order" : [ "site:current-cart-order" ] } }
]
}
}

It doesn't work, why?


texts:
I have a view block that list contents.

What I want to do is to show only 5 items in this view and a load more link at the bottom of the view and if this link clicked, then show all remaining content of the view.

I tried the Views Load More module and the Views Infinite Scroll module. The Views Load More module didn't work, the Views Infinite Scroll module works good but I couldn't do what I want. It has an option to show X items per "show more" link clicked but it doesn't have an option to show all the remaining content of the view.

How to load all remaining content of a view after clicking a "load more" link?


texts: Is the CKEditor module compatible with the Picture and Breakpoint modules?

texts:
Is CKEditor (7.x-1.16 with library 4.4.3) compatible with the Picture (7.x-2.11) and Breakpoints (7.x-1.3) modules?

I have read numerous articles which say that they are and suggest configurations but also some forum post indicating that they are not.

Viewing the source of CKEitor after inserting an image and specifying "Image size":

Viewing the markup on a page created using CKEditor:

It is identical to the CKEditor source.

Is anyone able to confirm, from first hand experience, if the 3 modules can work together to produce responsive/adaptive images?

Configuration Info:
In /admin/config/content/formats/full_html:
"Make images responsive with the picture module" is selected.
Filter processing order is:

Convert URLs into links
Convert line breaks into HTML
Make images responsive with the picture module
Correct faulty and chopped off HTML
(the same markup is produced even if only "Make images responsive with the picture module" is selected)

In /admin/config/content/ckeditor/edit/Full > EDITOR APPEARANCE:
"Support responsive images with the Picture module." is selected.

Update: It does work sometimes, under certain conditions, but not all. Trying to figure out why it works sometimes but not others....


texts:
I have an e-commerce based on Drupal + Commerce module.

My add to cart form use Ajax to reload itself when the user make a choice (item attributes, like color, size, etc..); Everythings works just fine but i need to add an overlay that hide the form just before the Ajax request is sent to prevent the user to click another option before the request has completed (and the form reloaded).

Basically, I need to add my own callbacks in the beforeSend and success events, but I have no idea on how tell Drupal to invoke them for (and only for) this specific form.

edit: I need to add a Javascript Callback, not php.

Any help?

Edit
Mathankumar's solution indeed works, something like:

$(document).ajaxSend(function(event, request, object){
    request.onloadstart = function(){
        $("form.commerce-add-to-cart").css({'opacity':0.5});
        $("form.commerce-add-to-cart input").attr("disabled", "disabled");
    };

    request.onloadend = function(){
        $("form.commerce-add-to-cart").css({'opacity':1});
        $("form.commerce-add-to-cart input").removeAttr("disabled");
    };
});

works BUT i dont like this thing to be run for every ajax call.

I digged the event, request, object parameters of ajaxSend, but i was not able to find nothing about the form_id or something to tell the add_to_cart_form requests from others, any help is appreciated!


texts:
i have a content type named product. i need to add product like this:

title: product1

description: this is a product

company:a
price:100

company:b
price:200

company is a node reference field with numbered of values set to unlimited and price is a text field but i don't know how relate price field with company.

if i can't do something like this in drupal 6, drupal 7 help me?


texts: Check to determine if user is member of any group of specific type

texts:
Our website has three types of groups: area groups, support groups and member organized groups.

While a member can join several or none of the support groups and member-organized groups, we do want each member to be a part of one (and only one) area group.

I'd like to find a way to use rules to check to see if a member is a member of an area group and if not, display a warning/help message to them to encourage them to join an area group. Ideally, I would like to do this several times shortly after they join and then occasionally after the first couple weeks (some people who are in the process of moving to the area may not want to join a group right away and I don't want the messages to get overwhelming for that small minority).

I've been playing around in the rules module to see what I can do, but I'm not sure exactly how to check to see if they are a member of any group of the area group type -- can anyone help me with determining what conditions I have to apply to get it to check this for me? Also can I put a limit (as suggested above) on the amount of times the message shows?

Or in lieu of that, is there an easier way to accomplish this goal of ensuring that all of our members make it into one area group?

Thanks
Heather


texts: Views-How do i redirect to the same page after saving the comment?

texts:
Sorry Guys , i have an easy question!

i used views to create a page that contains a kind of content with comment!

the link is "http://mydomain/testpage"

but when i write the comment on the content which is displayed by the view, the system will go to the "http://mydomain/node/%"

how can i stay at the same page after i writting the comment in the view?


texts:
I am learning Drupal 8, i have 2 content type (Notices, Plan), i want my front page look like this:

List entries of Notices

item 1
item 2
item n

Pager of list Notices

List entries of Plan

item 1
item 2
item n

Pager of list Plan

Can i do this in some way?


texts: How to give permission to a role to cancel user accounts of some roles?

texts:
I have 3 roles in my site: administrators, editor, clients

I need to give permissin to the editor rol to cancel users account with of the clients role.

Can I do this?


texts: How can I get the sub-navigation to show up in the sidebar on child pages

texts:
Drupal newb here :) So I may not have the Drupal lingo correct in my explanation...

I have a menu block called "Sub Navigation".  Here are my configurations:

(I've inherited this site so I'm not sure if this is a default block or not etc)

So, the navigation shows up just fine in the sidebar of parent pages, but it does not on any child page. (The admissions parent page has a context configuration, is why it is omitted here).

Am I missing a configuration here?

Thanks for any help!


texts: View display content by value based on user profile field values

texts:
I need to create a view that displays saved content with defined field values to users with specific attributes.   I.E.

content form with a field boolean of regulated:
  [0] unregulated
  [1] regulated
  [2] both

the view needs to display this content depending upon the user profile value for whether that user is licensed or not.  field value of both needs to display regardless of profile value for licensed.

profile field licensed is a boolean.  0 non-licensed, 1 licensed.

There will be content marked as regulated that needs only to be displayed to licensed users, content that is not regulated that needs only to be displayed to non licensed users, and content that is marked for both that needs to be displayed to both licensed and non-licensed users.

Can this be done in views or do I need to write custom php to accomplish this?


texts: Why does not hook_menu_link_alter() work?

texts:
i want to expand my theme's primary links, so I put the following code in my custom module.

function mymodulename_menu_link_alter(&$item, $menu) {
  if ($item['menu_name'] == 'primary-links') {
    $item['expanded'] = 1;
  }
}

In page.tpl.php I used print theme('links', $primary_links), but the primary links didn't expand. Why?


texts: Creating a system account used by a module: Is setting the password with drupal_random_bytes() too excessive, or is there a better method?

texts:
I am planning to create a module that would use a system account similar to the Community user seen on Stack Exchange sites. As the system account would have permissions that normal users don't have, I would like to avoid somebody logs in with that account, and get permissions that a site maintainer would have.

Is using drupal_random_bytes() to create a password a good method, or is it too excessive, and I should use a different method? In any case, I was thinking of periodically changing the password; I guess this means I could use a faster way to generate the password, as long as the password is still random, and with at least X characters.


texts:
I am working on a Drupal 7 site that uses a replacement pattern %1 inside a View header to generate a URL with the Organic Group id(og_group_ref).

The view header markup is

Create Convo

Example URL of a page is site/b_posts/2, so the link created would be /node/add/post?og_group_ref=2.

This is vulnerable to XSS, since accessing the URL site/b_posts/%22%20onmouseover=%22alert%28559%29%22%20test=%22/2 would result in a JS alert getting executed on mousing over the link. How to protect against this? I used the latest version of Views and this is still happening.


texts: I have a content type where the user gives a location, this is not a mandatory field. When the user don't provide location the node shows a grey map. Is there a way to remove the grey map from showing up? I want it to be hidden if empty. Could anyone provide some help here?


texts: how to change address bar by its content-type/title of node

texts:
I have a content type where user allowed to add the content, which create a node of that particular content, when i click to that content for detail page it re-direct to the node page created by authenticated user, but the address bar is something like

  www.myexample.com/node/23 23

or some no.
Now i want the address should be

  www.myexample.com/(content-type)/(node-title)

please help me.

Thanks


texts: Is the {{ field_file }} token broken within views?

texts:
I am using Drupal 8 and I have a node with a file field. In one node, the uploaded file has spaces in it's filename. When I view the node directly, the shown file url is:

  path/to/files/foo%20bar.pdf

And clicking the link opens the pdf just fine.

In views, I have a block of nodes' files with a global custom text field:

{{ title }}
{{ extension }} / {{ filesize }}

which itself has checked "Output this field as a custom link" while the link path is {{ field_file }}, but the output link becomes:

  path/to/files/foo%2520bar.pdf

To me it looks like the url is decoded twice. Was this introduced in a recent update? How to fix it?


texts: Where does the $node get its field values after a node edit page has been submitted?

texts:
I'm attempting to debug a problem where a date field is not being saved.

The field renders fine with the rest of the node form, but upon submit one particular field has no value.

The $form_state contains the expected value all the way down until the form does a redirect to the node view, however, in hook_node_presave, all the data that should be on the node, is missing.

I'm getting lost in the form api trying to trace down where exactly the form_state gets added onto the node.

I am using Drupal 7, and the Date module version 7.x-2.5.


texts: Drupal Console Installation: The "phar.readonly" setting needs to be off to create Phars

texts:
I am trying to install the Drupal Console for Drupal 8 on Linux Mint 17.1. During the installation I am getting the following warning notice:

[ ] Notice: The "phar.readonly" setting needs to be off to create Phars.

Any idea how to solve this? Will this effect the console operation?


texts: Nesting a View in a View... or something like that

texts:
THE SETUP

I have a View set up to create a page out of a particular content type called "enticements". For context, an enticement is something that would make a guest want to stay at a hotel. Things like local attractions and dining.

So my view uses the content types [machine_name] in this order

Image [field_image]
Title [title]
External URL [field_link]
Body [body]

All fields are set to hidden because I want them to be arranged just so, all within the [body]. The body rewrite result looks like this:

    [field_image]

[field_link]

[title]

    [body]

THE QUESTION
This all works fine except that the [field_image] can be one or more images, but no matter what I try it only shows the first image. Even when I tried telling views to show the [field_image] with "Multiple Field Settings" set to "Display all values in the same row" in an unordered list,  it still just shows the first image.

Why only the first image?
Is there a way to get Views to use every image in the rewrite?
Or can I somehow nest a Slideshow View inside the Enticement view?


texts: set multiple taxonomy values programmatically

texts:
I have a view that has a "Has taxonomy term ID" contextual filter and also a nid contextual  filter.

I execute this view programmatically, but I need to pass also multiple values for the taxonomy contextual filter.

I tried this:

$view->set_arguments(array($tid, $nid));
$view->execute();

and it works only if $tid is only a number.

I tried to put more than one tid using "+", but it doesn't work.
(example 3+5+8)

Any idea on how I can set a multiple taxonomy argument programmatically?
thank you in advance

I found a solution, but I don't like it. I removed the filter from contextual filter and I added an exposed filter for the same field. Then I changed the code in this way:

$view->set_arguments(array($nid));
$view->exposed_input['field_myfield_tid'] = $tid;  //note that $tid is an array of tid
$view->execute();


texts: Large Binlogs Generated When Reverting Features

texts:
We're using features to manage content types and field groups, and every code update, when we perform a features-revert to push out the latest CTs and field group changes, we get a huge amount of data written to our binlogs -- a gig about every 10 mins:

-rw-rw----. 1 mysql mysql 1073759569 Aug  1 02:31 mysql-bin.000138
-rw-rw----. 1 mysql mysql 1073766800 Aug  1 02:42 mysql-bin.000139
-rw-rw----. 1 mysql mysql 1074139941 Aug  1 02:50 mysql-bin.000140
-rw-rw----. 1 mysql mysql 1073954804 Aug  1 02:59 mysql-bin.000141

which quickly locks up our MySQL servers.

What might be causing the large amount of data to be written? What can we be doing on the MySQL side and the Drupal side to keep this in check?


texts: How to edit misc/print.css without changing core

texts:
I want to edit core/misc/print.css that the Book module is referencing, and I don't know how.

If I should move the print.css somewhere and load a new print.css in my theme.info, or is there another way make changes to the core/misc/print.css without changing core?


texts:
quickie,

I want to create a right-hand side sliding overlay panel for my drupal site.  I have been googling and testing solutions for hours. The exact effect that I want can be found here.  The jQuery Mobile overlay panel.

Of course, this script is not working with drupal and bootstrap 3 theme.

Question(s):  Does anyone know a way to make this script work with drupal 7 and bootstrap 3?

The closest substitute that I can find is the Mobile Menu Module (MMenu) module, but it appears to be for navigation purposes only.  I need to add a FAQ with animated expanding divs.  The documentation is unclear if this possible with MMenu.  Can anyone tell me if it is possible?

If I am barking up the wrong tree with jQuery Panel and MMenu is there a better solution? Simple, right hand side overlay panel.

Much appreciate, any suggestions.


texts:
I don't care about having custom error message or anything, but I just want AN error message.  Right now on my registration form I have a variety of supplemental fields listed as required but that has no affect on a user's ability to submit the form.  How can I prevent them from submitting if the field is null?  I don't care about crazy condiitionals or anything, simply if its null to not let them submit.  I have been unsuccessfuly trying to code a validation module and I can't figure out the code.  I really just need something to work ASAP.  I have tried the validation module but it doesn't work for me - no clue why.

Maybe there is something wrong with my theme, does anybody know where that validation would normally be found so I could check?  it seems other people do get the error message.

Any help would be SUPER appreciated.


texts: Programmatically loop form building and only getting the last loop of data in the submit handler (key names, nesting, fieldset wrapping)

texts:
I am looping around users with certain conditions so that I can dynamically build a form, this has required a few levels of looping.

1) This is inside a loop, it creates a wrapper fieldset for each user being supplied on each iteration ($uids['userCount'] is a counter)

$form['userToConfirm_' . $uids['userCount']] = array(
    '#title' => t($subsForDisplay[0]['mail']),
    '#type' => 'fieldset',
);
    .....

2) Within that, I loop to contain all the sets of data about that user

Shown here as a fieldset

foreach ($foobar as $foo) {

    $form['userToConfirm_' . $uids['userCount']]
                            [$foo['subset_name']] = array(
        '#title' => t($foo['subset_name']),
        '#type' => 'fieldset',
    );
        .....

3) Then within that, I pull out the options for each subset

        $form['userToConfirm_' . $uids['userCount']]
                [$foo['subset_name']]
                    [$foo['subset_name'] . 'status'] = array(
            '#title' => t('foo status'),
            '#type' => 'select',
            '#options' => $array,
        );

Based on the following reading:
How to place multiple form elements from a loop

and

https://stackoverflow.com/questions/6456671/drupal-form-api-using-foreach-loops-to-build-forms

I think I'm correct in thinking that it's common to unwittingly override the storage every iteration because the keys are not incrementing, or even changing at all, and therefore be left with the last set of data during the form submit.

What I am confused by is why this would be happening when I have already set incrementing key names (for the fieldsets) in my associative array?

Do I need to remove the multi-dimensional part of the $form array, instead of kinda nesting it inside the fieldset? Instead just going straight for every $form key having a unique name?


texts:
I'm writing a workaround to fix the breaking changes introduced to our XML feed when we updated from Drupal 8.4 to 8.5. Since PATH is no longer available but has been replaced with LINK, I've had to craft the Rewrite Results to be /news/{{ view_node }}, which displays a properly formatted URL in the preview:

<link>http://sitename.com/news/article-title</link>

However, in the actual XML feed, it comes out like this:

<link>http://sitename.com/news/article-title_</link>

arbitrarily adding an underscore and breaking the URL. Is there a way to make this not happen?


texts:
I am trying to create a file validator for .csv uploads.  This is my code that works at allowing csv uploads (which are disallowed by default):

$validators['file_validate_extensions'] = array('csv');
$file = file_save_upload('csv', $validators);

However, when I try to upload another file (in this case fizzbuzz.py) I get this error:

For security reasons, your upload has been renamed to fizzbuzz.py.txt.

How can I change this to being and out right error when a non csv file is uploaded?

EDIT: Did some more testing.  This only occurs for my .py file.  Files with a .png extension get rejected and are not uploaded.

EDITx2: Okay, so it also rejects .bat, .gnumeric, and .txt file extensions.  It looks like Drupal does not validate two letter file extensions in the same way it validates three(+) letter file extensions.


texts:
I have created custom module called mymodule.

In this URL localhost/mymodule/name, I have this field:

$form['name'] = array(
  '#title' => t('Enter name'),
  ...
  '#ajax' => array(
    'event' => 'blur',
    'callback' => 'mymodule_ajax_callback',
    'wrapper' => 'my-wrapper',
    'method' => 'replace',
  ),
  ...
);

My ajax callback is successfully called:

function mymodule_ajax_callback($form, &$form_state) {
  ...
  return ...
}

However, inside 'mymodule_ajax_callback', I need to get the current URL of the page which is localhost/mymodule/name. Currently it returns system/ajax which is how Drupal works by nature.

How to get the current URL inside the ajax callback?


texts:
I installed the heartbeat module to track user activities on my website. It took me hours to configure it but everything seemed to be working as I wanted until I tried to delete a test user from the website. I was wondering if anyone is familiar with this error.

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table
  'etuncel_drup4.drup_flag_content' doesn't exist: DELETE FROM
  {flag_content} WHERE (content_type = :db_condition_placeholder_0) AND
  (content_id IN (:db_condition_placeholder_1,
  :db_condition_placeholder_2, :db_condition_placeholder_3,
  :db_condition_placeholder_4)) ; Array ( [:db_condition_placeholder_0]
  => heartbeat_activity [:db_condition_placeholder_1] => 20097 [:db_condition_placeholder_2] => 20098 [:db_condition_placeholder_3]
  => 20101 [:db_condition_placeholder_4] => 20102 ) in HeartbeatFlagPlugin->activityRemoved() (line 106 of
  /home/public_html/sites/all/modules/heartbeat/modules/heartbeat_plugins/includes/heartbeatflagplugin.inc)


texts: Drupal 8 upload and embed a video to WYSIWYG

texts:
So what I am searching for is a module that gives us the exactly same functionality that we already have with the image tool in Drupal 8 in the WYSIWYG editor.
And that should be working with just uploaded videos.
I found that this module should be doing it for D7 - https://www.drupal.org/project/video

And also this module https://www.drupal.org/project/video_embed_field is doing it for D8, but only for videos from per say YouTube, Vimeo etc.

So please let me know if you found a way to add a similar to the image (see  attached screenshot) but for video

Cheers and thanks in advance!


texts:
I try to input several forms into one page via Controller. With code which is
under, I see those forms but after submit one of them, nothing happens. Any of data is send to database. Has anyone idea how to fix this?
<?php

namespace Drupal\Core\Entity\ContentEntityForm;
namespace Drupal\student\Controller;
use Drupal\node\Entity\Node;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\node\NodeInterface;
use Drupal\node\Entity;
use Drupal\node\NodeForm;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Url;
use Drupal\Core\Link;
use Drupal\Core\Routing;
use Drupal\Core\Entity\ContentEntityForm;

class SFormController extends ControllerBase {

  function new_form() {

    $build = [];

    foreach ($stud as $id => $name) {

      $node = \Drupal\node\Entity\Node::create(['type' => 'student']);
      $form = \Drupal::service('entity.form_builder')->getForm($node, 'student_form');

      $build[] = $form;
    }
    return $build;
  }
}

?>


texts:
I made a pretty dumb mistake..I was copying a library called ZendGdata to the includes folder within drupal and thought I copied all the files wrong so I deleted the folder and recopied the sub folder I wanted.  Right after, I got a white screen of death.

I did a bit of research and realized the problem and restored the files from the orginal drupa install, but I'm wondering if there's any problem with it(the site works right now).  Is there any customized code or anything of that nature in the the /includes folder that will effect me later?


texts: How Do I get specific fields value in Twig?

texts:
Background:

I have a Block view and content coming from content_block with number of fields.

So I want to access those fields value in custom template
Is this possible?
thanks


texts:
I'm trying to execute the following :

db_query('SELECT FROM_UNIXTIME(`created`, "%Y") as year, FROM_UNIXTIME(`created`, "%m") as month, FROM_UNIXTIME(`created`, "%d") as day FROM users ORDER BY `created`');

And because of the % sign the result is :
PDOException : SQLSTATE[42S22]: Column not found: 1054 Unknown column '%Y' in 'field list'

I tried escaping the % with a double %% resulting in : PDOException : SQLSTATE[42S22]: Column not found: 1054 Unknown column '%%Y' in 'field list'

Of course this query works in phpmyadmin

Help ?


texts:
I am new to drupal and have inherited a site.
I want to tidying and edit some of the fields n the user profile that already have been added, however
admin/config/people/accounts/fields does not appear as a tab in admin/config/people/accounts
and nothing happens if i try to access admin/config/people/accounts/fields directly.

How can I enable this tab?


texts:
I am a newbie in Drupal.

Can anybody explain how is block different from mini panel.


texts: How can I export and import users and their content (preferably as code)?

texts:
I've been using the features module successfully to manage configuration changes in content across my dev and production sites.

However, I have a site that is heavily focused on user relationships and I have created a large number of dummy users to test it.  I can't use the devel module to do this because I need to create content for each dummy users as well that cannot be random.  So, creating this collection of users and nodes has taken a fairly significant amount of time.

I was hoping to find a way to export this set (of users and associated nodes) similar to the way features works, but I haven't been able to find any way to do this.  I'd like to export them in order to manage the changes in git as well as to more easily use them across a number of different test sites.

Any ideas on how I can import and export sets of users, preferably as code?


texts: Is it possible for 3rd Party Script to Create Users

texts:
Our company has many systems that require for users to have user names and passwords.  We have been able to use SAML to cut down on the number of accounts we must manually create.  With that said, we do currently manually create Drupal users.

Would it be possible to have an "external script" provide Drupal with the variables it needs to create a new user.

Example:

External system collects user information in one spot.
1) User is created in Drupal according to data passed
2) Users are simultaneously created in other systems.

If it were not Drupal, I would google "API" for the system but with Drupal, I think API can mean a lot of different things and I was not able to easily find anything that might point me in the right direction.


texts: How can I set a message on the page I am `drupal-goto`ing towards?

texts:
I have a page which makes certain verifications and needs to redirect the user in certain cases. In those cases, I want the destination page to show a message, but I can't get it to work. Here is my code:

if ($userNeedsToBeRedirected) {
  drupal_set_message(null, "You've been redirected because ...");
  drupal_goto('destination');
}

The redirection works, but the message doesn't appear. What can I do?

Note: I also tried the following:

if ($userNeedsToBeRedirected) {
  drupal_goto('destination', array(
    'query' => array(
      'message' => "You've been redirected because ..."
    )
  ));
}

and in the destination page:

if (isset($_GET['message'])) {
  drupal_set_message(null, $_GET['message']);
}

but is doesn't work either because (I believe) drupal_set_message is being called too late the the page creation process.


texts: What Hook to Use to Execute a PHP on Every Page?

texts:
I'm new to creating module in Drupal 7 and wondering what hook to use to execute a PHP script.

I use this tutorial but it it explain a different approach.

What I want is simply execute this code in every page:

db_insert('ap_visits')
    ->fields(array(
        'id' => NULL,
        'length' => $t,
        'url' => $url,
        'current_ip' => $current_ip,
        'user_agent' => $user_agent,
        'date_start' => date("Y-m-d H:i:s"),
        'is_bot' => $isbot,
        'is_logout' => 0,
    ))
    ->execute();

Note that I have already created .module and .info file. All I need is to know what hook to put the code above.

Thanks for any help.


texts: Best Way to Implement Location to use as separate entity and with Facet API

texts:
Floundering a little with trying to figure out the best way to do this.  I have a structure where Activity is a node.  Each Activity can have 1 or more Locations which I want to set up as a separate node as multiple Activities can use the same Location.

Modules used:
- Drupal 7.x
- Views 3.3 X
- Search API
- Location Module
- Facet API

Originally, I set up the Location Module and used that as part of the Activity node in the node mode.  This was so I could then display elements of the location module in the Facet API search window.  Search or clicking on a menu is set up to show a table of results.  Then you can narrow your results by clicking on the factors in a separate block.  I am using Search API.

Complicating factor.  I still couldn't get distance/proximity searching working with Facet API.  Though I could get it working with a generic view where the filters are exposed.  Has anyone gotten Location Module distance Proximity working with Facets for Search API?
When I connect to Locations via Entity Relationship the details (address, city, state) are no longer accessible to Facet API if I use Node Location.  If I use Location CCK I can, however my data is not showing up in the view.

I'm at the point of throwing in the towel and writing my own module - anyone have any words of advice on which direction to head?

Thanks,
Elizabeth


texts: Views 2: Combine two multi-value fields per row

texts:
Creating a content type on D6 about short-listed books for a competition. Each entry (book) in the short-list is a node, with fields for book-title, book-description, author-names (multi-value), author images (multi-value).

So in order to create the short-list I'm using views. I thought I could combine multi-value fields using Views 2 but I can't work out how. I wanted to show:

Book title
Book description
Author photo 1 [image]
Author name 1 [caption]
Author photo 2 [image]
Author name 2 [caption]
...

etc

How can I achieve this using Views 2 on D6?


texts: hook_form_alter() exposed filter form item #weight

texts:
I'm trying to insert a form element with hook_form_alter(), and then rearrange the form elements so that the new form item appears at a particular point amongst the existing exposed filters.

I've tried adding #weight of 0 to all existing items and then #weight of -1 to the new element, just to see if I can have any influence on the form item order at all, however I don't seem to be able to affect it.

EDIT: In addition I'm getting kinda weird behaviour regarding the container of the Form element. I'm adding my form element as a new array element at the root of $form, however it is be rendered inside the element <div class="views-exposed-widget views-submit-button"> rather than getting it's own container, which seems like either a bug or I really am doing something wrong!


texts: allow user to set some css settings through UI

texts:
The user wants to be able to choose some sizes and colors for the look of the site. These are css rules. I have a vague vision how this could be done by a module, but maybe there is already something like this?

What I need is to have some form with fields as combo boxes, allowing the user to choose from several values. E.g. allow him to choose from {red, blue, yellow} for the "Background of the News title", which happens to be .news-header-background class.

After he saves, the module would re-create a user.css file which is loaded as the last file in the theme (so it overrides my theme settings).

So the tasks for each role are as follows:

the user fills the fields on a form choosing from pre-defined values
the administrator pre-defines these values and also assigns a css selectors to each field in the form (directly in files, no need for GUI for this)
the module re-creates the css file

One important point is that the interface exposed to the user must be dead simple. No technical jargon, no options, only text that he fully understands, like "Background color of the News title". Second point is that the values he can choose are presented as combo boxes, so they are limited. Third point is that the module should enable validation hook for the values he enters (or be written so that it's easy to hack and validate).


texts:
How to add JavaScript inside controller? I don't want to call build form. I can call css or js in src/Form/Form.php but I want to call css or js inside Controller src/Controller/Controller.php
This process I am using to call css and js in Form page

public function buildForm(array $form, FormStateInterface $form_state,$cid = NULL)
{

$form['#attached']['library'][] = 'cssjs/val_master';

}

Could anyone write some example to call css or js inside Controller

Thanks.


texts: How to set up menu with links to pages in different languages on multilingual sites?

texts:
I have a multilingual site determining the language from the URL Path (www.sample.com/lang/page). I need a menu to have a mix of links to pages in both English and French. 99% of these are node pages, one or two are taxonomies. We do not have any translated content only localized. It doesn't seem to make a difference what Translation mode my menu is in (I've tried all three) the system always adds "fr/" in-front of every URL when I put the menu on french pages, even if that node id doesn't exist in french. I'm sure there must be a way to do this, but I can't figure out how... Here's a sample of what i am looking for in one menu:

About Us - www.sample.com/about-us (not translating to french, but want to link to it from french pages)
Contactez-nous -   www.sample.com/fr/contactez-nous ( node in french, not a translation of another page)
US Locations- www.sample.com/locations (not translating to french, but want to link to it from french pages)

I'm sure this must be possible, but I have no idea how to get there.


texts: Can I use drupal_get_form and drupal_render within a custom Drupal 7 input filter?

texts:
As the title says:  I've got a custom input filter in Drupal 7 which replaces a token with a custom drupal form. Without showing the complete code, which might just confuse things, The main essence is the following:

function _my_filter($text, $filter = NULL, $format = NULL, $langcode = NULL, $cache = NULL, $cache_id = NULL) {
  $rendered_text = $text;
  preg_match_all(MY_CUSTOM_REGEX, $text, $matches);
  if (!empty($matches[0])) {
    foreach ($matches[0] as $match) {
      $custom_form = drupal_get_form('my_custom_form');
      $replacement = drupal_render($custom_form);
      $rendered_text = str_replace($match, $replacement, $rendered_text);
    }
  }
  return $rendered_text;
}

For some reason when the node is being saved this times out.  I've narrowed it down to being something in my drupal_get_form (but this form renders fine without any problems outside of an input filter).

Can I use drupal_get_form and drupal_render within an input filter like this?


texts: I have encountered a weird problem in a Drupal site. Whenever I try to ban an abusive user, by going to the user's profile, change his status from active to blocked, and click save, the change does not take effect. Instead I just get a server time out message. There are a couple of thousands of users so disability to ban abusive ones is quite a hassle. Any suggestion to solve this?


texts: Is there a module that will allow me to set the default meta title for a content type to be the title field of the node displayed?


texts: How to remove comma between taxonomy terms?

texts:
I style my taxonomy terms as boxes, so I don't need comma between them.

Could somebody give me any advice?


texts: How can I see the query that's being run?

texts: I'm using hook_views_query_alter(), and I'd really like to print somewhere (screen, error log, whatever) the query that's being run based on the alterations. I've tried dpm($query), but that gives me the whole krumo tree - all I want is the query - i.e. "select x, y from z where a = 2". Possible?


texts: Getting user photo url and profile url using views_json

texts:
I'm using the views_json module in Views Datasource to send some information in JSON format to a related website.  I've got a bunch of content views built, but now I'm trying to build staff pages.  I've got most of it working fine, but when I try to add the user picture I end up with an empty field, When trying to find a url for the user's profile page (using User: Link), I got the text "view", leading me to believe that when drupal tries to output the content as a link, views_json returns the link text.  I just want the url in plaintext, I don't need the html for a link.  How can I get the user picture, and the absolute url to the user profile in views_json?

Image fields for my node views work just fine, I get field_image.src and field_image.alt elements in the JSON that is returned, with the Use picture I get a blank field or a series of \n´s


texts: There is a confirm password form type.  I don't suppose there is a confirm email address form type available?  Possibly as a contributed module?


texts: redirect to prod url when creating content

texts:
I have a Drupal 7 development site that is a subdomain of the production site, eg. dev.prod.com, for example.

When ever I create a content type, new content, a new user, install a new module, etc on the development site it redirects to the production URL after the form is submitted.  I don't have permission on production so I get "access denied". When I go back to the development site and refresh the browser, the content have been created.  But this does not work for installing a module. The module is not installed.  Obviously, this makes it impossible to work on dev.

I have reviewed .htaccess and settings.php for any rewrite rules that could be causing this but I have not found anything.  $base_url is set to the correct URL for the development server. I have cleared the cache many times.

Any suggestions?


texts: Relevant Content Module Custom/Overwirete Theme

texts:
The module Relevant Content has a function called

theme_relevant_content_block

Which renders the nodes for the module. The comments say the following

"This is provided (the function) so that an item list is the default, however a themer can
easily override this to make a teaser list or table."

I'm not really sure how to use a 'themer' to overwrite this function.

Any pointers on how to do it is appreciated.


texts:
I want to add a block containing an image-(field) to Drupal, so it can be added to the block layout.
I can see the image gets uploaded (because it appears in my file system). But, the block 'forgets' about the image. Next time I configure the block, the image I just uploaded has disapeared.
The documentation is a bit fragmented, and I can't figure out how to:

set a default value for the image
how to create the render-array.

What I've got so far:
  /**
   * {@inheritdoc}
   */
  public function build(){
    $build = [];
    $build['image']['#markup'] = '';
    return $build;
  }

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {

    $form['image'] = array(
      '#type' => 'managed_file',
      '#upload_location' => 'public://images/',
      '#title' => $this->t('Image'),
      '#description' => t("Image to show on the contact form"),
      '#default_value' => $this->configuration['image']['value'],
      '#upload_validators' => array(
        'file_validate_extensions' => array('gif png jpg jpeg'),
        'file_validate_size' => array(25600000),
      ),
      '#states'        => array(
        'visible'      => array(
          ':input[name="image_type"]' => array('value' => t('Upload New Image(s)')),
        )
      )
    );

    return $form;
  }

  public function  blockValidate($form, FormStateInterface $form_state) {
//    File::load( $form_state->getValue('image'));
  }

  /**
   * {@inheritdoc}
   */
  public function blockSubmit($form, FormStateInterface $form_state) {

    /* Fetch the array of the file stored temporarily in database */
    $image = $form_state->getValue('image');

    $this->configuration['image'] = $image;

    /* Load the object of the file by it's fid */
    $file = \Drupal\file\Entity\File::load( $image[0] );

    /* Set the status flag permanent of the file object */
    $file->setPermanent();

    /* Save the file in database */
    $file->save();
  }
}

How do I display an user-uploaded image?
How do I make the block remember this picture?


texts: How to remove default form tag while rendering output in hook_theme

texts:
I am customizing the login form. I have to put all the three forms(login, register, forgotpassword) into one page.
I don't want that unwanted root form tag, how can i remove that one? I am using drupal 7. This is my code.

template.php

function bartik_theme() {

$items = array();

$items['user_login'] = array(
    'render element' => 'div',
    'arguments' => array('form' => NULL),
    'variables' => array('form' => NULL),
    'path' => drupal_get_path('theme', 'bartik') . '/templates',
    'template' => 'user-login',
    'preprocess functions' => array(
          'bartik_preprocess_user_login'
    ),

);

return $items;

}

user-login.tpl.php

        <div id="signupbox">
            <?php
                $login_form = drupal_get_form ( 'user_login_block' );
                echo drupal_render ( $login_form );

                $forgot_password_form = drupal_get_form ( 'user_pass' );
                echo drupal_render ( $forgot_password_form );

                $register_form = drupal_get_form ( 'user_register_form' );
                echo drupal_render ( $register_form );
            ?>
        </div>

My problem is that all the 3 forms are rendering in one more form tag.

My Output:

<form action="/drupal728/user" method="post" id="user-login">

 <form>Login</form>
 <form>Password....</form>
 <form>Registration....</form>

</form>

I don't want that unwanted root form tag, how can i remove that one? I am using drupal 7.


texts: Unable to install ... already exist in active configuration

texts:
On Drupal 8.1 I keep running in those kind of messages when I try to activate a custom module or a custom feature that makes some modification to the basic page. (add fields).

It is really annoying...

Steps:

Clear database entirely
go to /install.php and choose Standard profile
Now that the site is running go to Extend
Select Feature - Basic page

Result:

Unable to install Feature - Basic Page, core.base_field_override.node.page.promote, core.entity_form_display.node.page.default, core.entity_view_display.node.page.default, core.entity_view_display.node.page.teaser, field.field.node.page.body, node.type.page already exist in active configuration.

Well yeah... that is what I want to do: Change those default settings!

Expexted:

Be able to install my feature that makes some modifications to the basic page.

My Feature

Here is my Feature create with the Features module

It basically adds two fields, banner_image and background_image to the basic page

Files:

config
    install
        core.base_field_override.node.page.changed.yml
        core.base_field_override.node.page.created.yml
        core.base_field_override.node.page.promote.yml
        core.base_field_override.node.page.status.yml
        core.base_field_override.node.page.sticky.yml
        core.base_field_override.node.page.title.yml
        core.base_field_override.node.page.uid.yml
        core.entity_form_display.node.page.default.yml
        core.entity_view_display.node.page.default.yml
        core.entity_view_display.node.page.teaser.yml
        field.field.node.page.body.yml
        field.field.node.page.field_banner_image.yml
        field.field.node.page.field_image.yml
        field.storage.node.field_banner_image.yml
        language.content_settings.node.page.yml
        node.type.page.yml
feature_basic_page.features.yml
feature_basic_page.info.yml

Why this simple thing is not supported? Is it a bug? What should I do to be able to use my feature?


texts: How to remove 'error' class from form field?

texts:
I need to remove the error class from field after form submit. How to do that?

I found the function called _form_set_class but I suppose I can't overwrite it.


texts: "Save Configuration" in Drupal 7 Module not visible

texts: I inherited a customized Drupal 7 site and am trying to add some things without a lot of knowledge of how drupal works (I have general html/css/JS, and some classic ASP, .Net experience).  I was able to install a couple of modules (Widgets, Widgets Service Links, Widgets Services  - for Social Media buttons) but can't seem to enable them.  They have dependencies with each other, but they are all there.  I can click the check boxes but I see no where to save the enabling of the modules.  According to what I see out there, there should be a Save Configuration button, but it is not visible to me.  We have a couple of security updates that we haven't done, but when we did these previously they mucked up our configuration so we decided to hold off on them until we know what we're doing a bit more (we were able to restore from a backup).  Could the security update alerts be preventing the saving of modules?  That's the only thing I can think of other than our whole configuration being messed up somehow?


texts: Ajax not working with existing field in hook_form_alter

texts:
If I add new select field and define ajax, all works fine. Whereas if I attach #ajax to the existing select field it just does not work. (I can see ajax loader spining for a while and that is all.) I'm also getting error: "An illegal choice has been detected. Please contact the site administrator."

I'm suspecting my callback function is not correctly implemented. Is it valid to make changes to the form in the callback function?

function hook_form_alter(&$form, &$form_state, $form_id) {
    //...

        // add wrapper to existing select field
        $form['field_event_1_role']['und']['#prefix'] = '
';
        $form['field_event_1_role']['und']['#suffix'] = '
';
        $form['field_event_1_role']['und']['#options'] = array('_none' => t(' - '));

        $events_list_options = array('1' => t('1'), '2' => t('2'));

        // **add new select field with ajax - This is working fine**
        $form['test_select_ajax'] = array(
            '#title' => t('Test select ajax'),
            '#type' => 'select',
            '#options' => $events_list_options,
            '#ajax' => array(
              'event'=>'change',
              'callback' =>'event_roles_ajax_callback',
              'wrapper' => 'select-event-role',
            ),
        );

        // **attach ajax to the existing select field - NOT working?!**
        $form['field_event_1']['und']['#options'] = $events_list_options;
        $form['field_event_1']['und']['#ajax'] = array(
            'event'=>'change',
            'callback' =>'event_roles_ajax_callback',
            'wrapper' => 'select-event-role',
        );
    }

    // Ajax callback function
    function event_roles_ajax_callback($form, &$form_state) {
        $form['field_event_1_role']['und']['#options'] = array('populated' => t('populated'));
        return $form['field_event_1_role'];
    }

Additional info: The form I'm altering here is registration_form from Entity Registration module


texts: How to get an generic image icon for image field type (like Generic File formatter for file field)

texts:
I have media field on a paragraph entity.
This field can hold media types, files, image etc.

Looking at admin/structure/media/manage/file/display there is a generic file formatter. However, for image - admin/structure/media/manage/image/display there is not.

So when the data is rendered, I get generic icon for word documents, but not images.

How can I get all my media items to render as generic icons?


texts: How do I get a double top boostrap nav with bootstrap template?

texts:
I want a secondary bootstrap navbar on my site, a black one on top of the blue one.

Now when resizing, there is a hamburger menu and so on, so stacking 2 bootstrap menus on top of each other, even of different colors may cause problems.

How do I have a double bootstrap menu with 2 colors?


texts: What is InstallerException and can it be thrown from a hook_install() implementation?

texts:
The documentation for this Exception class is this:

  Base class for exceptions thrown by installer.

By "installer" does it mean any hook_install implementation? Which is what I assume, a counterpart to UpdateException? The hook_install documentation makes no mention of this, so my best guess is that it is a part of some plugin ecosystem.


texts: How can I translate the Profile 2 field labels?

texts:
I can't find a way to translate the fields labels for the Profile 2 fields. I have activated the Profile 2 translation module, but I don't want to translate fields of the entity, I just want to show the labels translated in the user page and the user edit form.

Does anyone know how to do it?


texts: Lexicon term description is showing special HTML characters

texts:
I've installed the Lexicon module so I can build a glossary. The problem I have is that the glossary terms description is showing special HTML characters (see link).

http://www.kalleload.net/uploads/jgoepbpqzfhh.jpg  (screenshot)

Lorum ispum "dolor > sit" amet!

will render as:

Lorum ispum &rsqou;dolor &gt; sit&rsqou; amet!

This problem only seems to occur when the term is linking to the Lexicon page.
I've been playing around with the settings, google'd the problem and went throught the module issue list, without any succes.

Anyone knows how to fix it?

Thanks in advance,

Jeroen


texts: I need to have a slider on my main page that has a number of images (taken from views), and also a map that slides. Can anyone recommend any tutorials on how to embed a block as one of the images in a slider or any other solutions to this? So far everything that I have seen is just for embedding images.


texts:
With Privatemsg and Rules modules, I want to create a rule :

Anyone create a node, a special role user recept accepted a privatemsg.

But when I create the rule, in the actions, meet a problem:

The "Data selector" in RECIPIENT, I can't find the role.

Does anyone have a solution ?


texts: Not able to reference Javascript functions inside jQuery wrapper

texts:
I have custom module called interface, through which I'm adding a javascript file. This code is in plain old javascript, no jQuery, and has been working for me.

I now want to be able to add some jQuery functions to this code, I thought this would be possible since jQuery and javascript should be compatible with each other, right?

So here's a simplified example of what I'm doing inside the .js file:

(function ($) {
    Drupal.behaviors.interface = {
    attach: function()
    {
        function foofunction() {
        // execute some code
        }
    function WelcomeScreen()
    {
        Screen.apply( this );
        this.html = function(){
        return "

";
        };
this.activate = function(){
document.getElementById("main").innerHTML = "Test";
        };
        }

    }
    }
})(jQuery)

This code results in the following error in Chrome dev tools:

Uncaught ReferenceError: foofunction is not defined

My guess is that somehow the required jquery wrapper or the drupal behaviors wrapper are causing the functions to no longer be 'global'.

One obvious answer, I think, is rewriting everything in proper jQuery syntax. But I'm interested in how to make these javascript functions compatible with jQuery.


texts: How do I embed a view of comments within a view of nodes using Entity Views Attach (EVA)

texts:
I have one view of nodes. My row style is field. Originally I was trying to create a view that displayed all of the nodes, and all of the comments on those nodes.

I run into trouble using a relationship, because then I get duplicate records for every node. So I'm now trying to make a separate comments view and use entity views attach to attach the comment view as a field to the node.

The problem I am running into is that it seems like there is no way to do this using the fields row style. The only place I can add the comments view is in the displays option.
how can I display a view of my comments within a view of my nodes.


texts: Webform-CiviCRM integration: autocomplete employer

texts:
I set up a Webform for a Membership Application. I followed the instructions on this page for setting up an Autocomplete for the Organization the new Member belongs to:

http://wiki.civicrm.org/confluence/display/CRMDOC/Webform+CiviCRM+Integration#WebformCiviCRMIntegration-CurrentEmployer

This works fine when I am logged in (as an administrator), and it auto completes the organization name with options from the database.

But when I test the form when I'm logged out, it doesn't recognize any organization names that I know are in the CiviCRM. Furthermore, when I try to add a new organization it doesn't get added to the database.

Any ideas why this might be happening?


texts: What is the appropriate hook for hiding/editing user data?

texts: We have a field on the user that I just need to hide one field from. This user object may be loaded from an API service endpoint or just in a regular login. Is there a hook I can use to obfuscate the field? Or something in the admin panel I can do?


texts: Create fields programmatically via content type settings

texts:
I want to make a module to create custom fields to a content type. But I want to be able to turn the fields on and off via the content type edit page.

So I want to add a tab to the vertical tab part at the bottom of the content type edit page where I have a single on off checkbox. When selected and saved, fields are created. When not selected the fields will be removed (or not created).

I created the option in the node type form. By using this:

function HOOK_form_node_type_form_alter(&$form, &$form_state){
$form['new_option'] = array(
    '#type' => 'details',
    '#title' => t('NEW OPTION'),
    '#group' => 'additional_settings',
);

$form['new_option']['new_option_options'] = array(
    '#type' => 'checkbox',
    '#title' => t('Create fields'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 10,
);
}

But how can I save the value of the checkbox in config and use it as default_value.


texts: Show current page on Drupal 7 breadcrumb

texts: Is there anyway to add the current page title on drupal 7 breadcrumb?


texts: Disabling Twig cache does not prevent Drupal from caching

texts:
I have the following content in menu.html.twig template.

Blog

Bilder

Kontakt

If I change the content of the menu.html.twig does not reflect in the site. If I have logged into the backend I can see the changes otherwise it does not apply the changes until I clear the cache.

I have disabled the Twig cache in development.services.yml file and made appropriate changes in settings.local.yml and uncomment the line which enables settings.local.yml  in the settings.yml

parameters:
  http.response.debug_cacheability_headers: true
  twig.config:
    debug: true
    auto_reload: true
    cache: false

services:
  cache.backend.null:
    class: Drupal\Core\Cache\NullBackendFactory

Can anyone here know what is wrong here?


texts: display results from a form in theme-settings.php

texts:
I've been working on a way to upload a background image for months and I finally got it to work. How do I display the URL to the image on page.tpl.php? It's a form called background_file. Here's my code that I'm using:

<?php
function tsaudio_form_system_theme_settings_alter(&$form, $form_state) {
$form['background_file'] = array(
'#type'     => 'managed_file',
'#title'    => t('Background'),
'#upload_location' => file_default_scheme() . '://theme/backgrounds/',
'#default_value' => theme_get_setting('background_file'),
'#upload_validators' => array(
'file_validate_extensions' => array('gif png jpg jpeg'),
),);
form_load_include($form_state, 'inc', 'system', 'system.admin');}?>


texts: How to programmatically manage taxonomies?

texts:
I'm working on a project with this requirement: there will be a couple of custom content types where many fields comes from taxonomies references.
Many of these taxonomies have plenty of terms (50+). These terms are periodically updated (added/corrected/removed) by a third party system in charge of this task, which later exposes these 'most current' terms list through a webservice.
So I don't need to force a human operator to manually check these terms lists and update D8 taxonomies accordingly, I thing that a good approach would be to periodically run a task to verify that webservice and then updated D8 with what have changed.
I've carefully read the following references:

Programmatically create term in Drupal 8?
Programmatically create a term?

Create taxonomy term programmatically on Drupal 8
http://www.drupal8.ovh/en/tutoriels/55/create-taxonomy-term-programmatically-on-drupal-8

Drupal 8 - Examples - create_taxonomy_term.php
https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_taxonomy_term-php

Saving and retrieving taxonomy terms programmatically for Drupal 8
http://btmash.com/article/2016-04-26/saving-and-retrieving-taxonomy-terms-programmatically-drupal-8

The one that come closer to the project needs is the 4th one in the above list. It would suffice the requirements for now.
But I didn't quite get where this code should be typed. Does it need to be a custom module or should it go into themes/mytheme/mytheme.theme or so?
From where I stand, I think that an elegant solution is to have a routine somewhere (where?) that I could call via D8's cron so I can retrieve-then-update taxonomies periodically. But I have no clue on how I could achieve that goal.
Can someone provide any good references so I can fulfill this desire with code?


texts: How to apply pager in a table using theme function?

texts:
I am rendering and displaying data using theme table. I'm using

   $form['pager'] = array('#theme' => 'pager');

for displaying pagination. Now my intention is to display pager in two areas of screen. One is above the theme table and another one is below. I placed this code two times but pager is coming only once.

Can anyone please help me?


texts: Duplicate Results Using Views, loosing results using (File) File: Content using Thumbnail image

texts:
I’ve got a “views” question. I have a view that is using File Usage: File under advanced > relationships and (File) File: Content using Thumbnail image. In that later relationship, (File) File: Content using Thumbnail image , when require the relationship is checked, I loose nodes that don’t have thumbnail images, when it’s not checked, I get duplicates (the content type holds a thumbnail and a header image and for some reason it returns a result with the thumbnail and a duplicate result with the header image instead of the thumbnail) - Anyone got any idea how I can get both the ones with the images and without, and not have duplicates?

I tried Other > Use aggregation and Query Settings > Distinct (and pure distinct) and didn’t have any luck either