texts: Custom form returns NULL in custom template

texts:
I have:

A custom form
A custom theme
A custom module for this form

I am trying to get the custom form to display on a custom template which is in a custom theme.
The directory structure for the custom module (weeks) is the following.

weeks

src

Controller

WeeksController.php

Form

FormWeeks.php

weeks.info.yml
weeks.install
weeks.module
weeks.routing.yml

This is the code I am using.
FormWeeks.php

namespace Drupal\weeks\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class WeeksForm extends FormBase {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'weeks_form';
  }

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

    $form['#theme'] = 'weeks_form';

    $form['deactivate'] = array(
        '#type' => 'submit',
        '#value' => $this->t('Deactivate'),
        '#name' => 'deactivate',
    );
    $form['2_week_pause'] = array(
    '#type' => 'submit',
    '#value' => $this->t('Pause for 2 weeks'),
    '#name' => 'pause'
    );
    $form['start_again_week_1'] = array(
    '#type' => 'submit',
    '#title' => $this->t('Start again at week 1'),
    '#name' => 'restart_week_1',
    );

    return $form;
  }

   /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {

     $action = $form_state->getTriggeringElement()['#name'];
     $user = \Drupal::currentUser();
     if($action == 'deactivate'){
        $user->set('field_52_weeks', $action);
        $user->save();
     }else if ($action == 'restart_week_1'){
        $user->set('field_current_week', 1);
        $user->save();
     } else if ($action == '2_week_pause'){
        $user->set('field_52_weeks', $action);
        $user->save();
     }
    }
}

weeks.module
function weeks_theme($existing, $type, $theme, $path) {
  return [
    'weeks_form' => [
      'render element' => 'form',
      'template' => 'html--52weeks',
    ]
  ];
}

weeks.routing.yml
weeks.page:
  path: '/52weeks'
  defaults:
    _title: '52 weeks'
    _form: '\Drupal\weeks\Form\WeeksForm'
  requirements:
    _permission: 'access content'

themes/custom/mytheme/templates/html--52weeks.html.twig
{{ dump(form) }}

The template file returns null, and I have no idea why. I tried changing $form['#theme'] = 'mytheme', in the WeekForm.php file, but it still doesn't work.
What I want is for this form to be displayed when someone goes to /52weeks. The main problem is that the form doesn't get passed to the template.


texts: How to alter product price on checkout page on Drupal commerce?

texts: I am using Drupal commerce in my site . I have alter a product price programmatically its working fine for me before checkout page. In checkout page its not taking my alter price.


texts: How to assign a confirmed user role upon email confirmation without logintoboggan?

texts:
Is there a way to assign an confirmed user role upon account validation/email confirmation?

there is this possibility mentioning logintoboggan:

How do I assign a role to a user after the user's email is confirmed?

My problem is that I am using email registration and genpass (so the user only needs to enter his email) and the modules don't work together.

I'm fairly good with rules and started looking into development. I'm not a programmer though and I don't know how I should implement a corresponding rules condition that checks whether the user has validated his account.

Any suggestions?


texts: How to SimpleTest a module's use of drupal_alter() or module_invoke_all()?

texts:
I'm developing a custom module.  My module calls drupal_alter() with a $type unique to my module, so other modules can alter the behavior of my module.

I'd like to write a SimpleTest for my module, which includes a test implementation of the hook my module calls.  This hook implementation should only be used by my SimpleTest; it should not apply when the module is installed on a full Drupal installation (so therefore I can't place my test hook implementation in the .module file).

What's the right way to do implement a hook that only applies to an active SimpleTest?


texts: How to download the files data attached to webform

texts: I have webform with text fields and file upload field. How can i download the all the documents which was  uploaded through this webform.


texts: How to render a node with different DS View modes depending on taxonomy term?

texts: I have a Content type containing a term reference field and some other fields. I have created 3 Display suite view modes for this content type. I want each node of this content type to be displayed in one of the defined DS view modes depending on the value of the term reference field of that node.


texts: Show/Hide fields not working for Condition Fields on node display

texts:
I have Conditional fields installed, with a checkbox as the dependency which shows two textareas when checked. The issue is when viewing the content type, the checkbox is NOT checked and the text areas still show up. I have checked in Manage Dependencies and the dependants are required and visible when checkbox field is checked.

Is there another place to adjust these settings, if so where would I look?


texts:
We have a requirement that when we save a node that nodes title should be the site name. We used to do it in Drupal 7. But I was not able to find the proper method for it in Drupal 8.

This is what we tried:

$config = \Drupal::service('config.factory')->getEditable('system.site');
$config->set('system.site.name', "Demo Site");
$config->save();

Got it from here: https://www.drupal.org/docs/8/api/configuration-api/simple-configuration-api

Any suggestions?


texts: How can I automatically apply a shipping service and skip shipping selection during checkout?

texts:
In certain circumstances, you may want to automatically add a particular shipping rate to an order. For instance, you might want to:

use a particular service for estimation purposes
force a particular shipping service based on business logic (e.g. it might be free or fixed cost)
have the customer skip the shipping pane in checkout


texts:
If I have a title that is longer than one line, then the bread crumb trail in the middle of it.

Example:
http://www.energyjustice.net/node/1948

I want the bread crumb trail to either come before or after the title.

I'm using Drupal 7.19


texts:
I would like to pass variables to a single specific template file(tpl.php).
My setting is the following:

my_entities.module

function my_entities_theme($existing, $type, $theme, $path) {
  return array(
    'my_entities_property' => array(
      'variables' => array('element' => null),
      'template' => 'my-entities-property'
    )
  );
}

I am using a template file at my_theme/templates/my-entities-property.tpl.php

In the module file I am trying to invoke a preprocess function to add a variable but it is not being invoked.

function template_preprocess_my_entities_property(&$variables) {
  $variables['test'] = "test";
}

How could I make this work?  I followed https://www.drupal.org/node/2275895#comment-8832701 but it seems that I am doing something wrong.


texts:
It was suggested the below script in template.php might work to assist in creating a modified HTML page.

<?php
function YOUTHEME_preprocess_html (&$vars) {
if (module_exists('path')) {
$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
if ($alias != $_GET['q']) {
$template_filename = 'html';
foreach (explode('/', $alias) as $path_part) {
$template_filename = $template_filename . '__' . $path_part;
$vars['theme_hook_suggestions'][] = $template_filename;
      }
    }
  }
}
?>

I tried it but broke my site. Do I need to copy just the code minus the php brackets? Use my exact subtheme name to replace YOURTHEME and then create my html--foo.tpl.php to correspond?


texts: Rules help: After updating existing content

texts:
First time using Rules to make a complicated rule. Would appreciate some help. I'm making rules to send an e-mail, to a pre-defined e-mail address, after an existing node is updated. This node is of a certain type, and this type has a taxonomy term reference field. When any node of this type gets updated, by a user with certain role, Drupal should send an e-mail, and in the e-mail it should attach the name of the taxonomy term.

tl;dr/problem: What I'm having trouble is, when creating a condition to check the user's role (the user who updated the content, not the author). There seems to be only the "Author" of the node available on the Data selector (see attached image). Is node:author the correct one to check for the user who updated the content?


texts: Module Dev: How to attach a button to a field?

texts:
I would like to build a module whereby a user can enable a button per field, and when the user clicks on it, it gets the field contents and posts it to a service.

If there are any modules like this that would be great as well as an example.


texts: Taxonomy term reference field from custom database table

texts:
I am trying to create a taxonomy term reference field or the equivalent in a View that uses the uuid of a field in a custom table. This field can contain multiple uuids.

My first approach after having issues with the views_handler_field_taxonomy ( because the table does not contain the vid and tid fields ) was using joins and another table that contained all the necessary taxonomy fields. Although I got it to work the multiple joins caused the results to become pretty ugly ( lots of duplicates ). I may have to use this approach and clean up the results with custom code but I would definitely prefer not to.

So the question. Is there any straightforward way I'm missing to get my custom database field of comma separated uuids treated like a taxonomy term reference field by Views? I have tried a variety of different relationship handlers as well as field handlers in my hook_views_data but no luck. I have found very limited documentation and only the simplest tutorials for custom views field and relationship handlers. Any links to good ones and/or good sample code would be greatly appreciated.

I would also be completely fine with a way to treat a custom entity property as a taxonomy term reference field.


texts:
I want https://github.com/dynamick/multiple-filter-masonry to load the drupal way.
But I fail, here is my code:

(function ($) {
Drupal.behaviors.druckgott = {
  attach: function (context,settings) {

  var $container = $('.masonry-processed');

  //here browser tells me that the function multipleFilterMasonry is not
  //a function:

  $container.multipleFilterMasonry({
    itemSelector: '.challenge',
    filtersGroupSelector:'.filters'
  });

//here my editor tells me that multipleFilterMasonry is unused:
$(context).on(function multipleFilterMasonry(options){...});
...

   });
   }
  };
})(jQuery);

So how can I load the function to be recognized by the browser???

-- Update: also doesn't work because of the lack of chaining! $container... --

(function ($) {
    Drupal.behaviors.druckgott = {
      attach: function (context,settings) {

  //console.log('This would be the main JS file.');
  $('.filters .btn input[type=checkbox]').click(function(){
      $(this).parent().addClass("active");
  });

  // initialize Masonry
  var $container = $('.masonry-processed');

  /*$container.multipleFilterMasonry({
    itemSelector: '.challenge',
    filtersGroupSelector:'.filters'
  });*/
  var options = {itemSelector: '.challenge',filtersGroupSelector:'.filters'};

     var cache=[];
     //the main job of the function is to cache the item,because we are going to filter the items later
     var init = function($container){
             console.log($container.find(options.itemSelector));
        $container.find(options.itemSelector).each(function(){

            cache.push($(this));
        });
        $container.masonry(options);
     }
     //filter items in cache
     var filterItems = function(selector){
        var result=[];
        $(cache).each(function(item){
            $(selector).each(function(index,sel) {
                if(cache[item].is(sel)){
                    if($.inArray(cache[item], result) === -1) result.push(cache[item]);
                }
            });
        })
        return result;
     }

     //reload masonry
     var reload = function($container,items){
        $container.empty();
        $(items).each(function(){
            $($container).append($(this));
        });
        $container.masonry('reloadItems');
        $container.masonry();
     }

     var proc = function($container){
        $(options.filtersGroupSelector).find('input[type=checkbox]').each(function(){
            $(this).change(function(){
                var selector = [];
                $(options.filtersGroupSelector).find('input[type=checkbox]').each( function() {
                    if ( $(this).is(':checked') ) {
                        selector.push( '.' + $(this).val() );
                    }
                });
                var items = cache;
                if (selector.length > 0) {
                    items = filterItems(selector);
                }
                reload($container,items);
            })
        })
     }

     return $(this).each(function() {
      //here it is usually only return this.each(function())...
        var $$ = $(this);
        init($$);
        proc($$);
     });
   }
  };
})(jQuery);


texts: How to change path using the Content: Link to Content

texts:
In Block view I want to set the link of content with the title name
How to Rewrite Results using the Content:Link to Content?
Example showing node/8 to john-bartlett(content title name)
By using this {{ view_node_1 }} i am getting the node/8 path but i want the title name john-bartlett.

Please provide any solution regarding this


texts: How to integrate content type to webform Drupal 7?

texts:
I have a content type called "student".

now I want to set that content type as select option component in webform.

Are there any way to do so? thanks,


texts: How to get the alt tag from an image field in twig?

texts:
I have a page of field images which are coming out quite weirdly when I kint their values. I can't seem to get the image url and the alt tag.

The code in the twig file looks like this:

field--field-staff-gallery.html.twig

{% for item in items %}
    {{ kint(item) }}
{% endfor %}

It's output looks like this:

Now I can easily get to the url by doing:

{% for item in items %}
    {{ file_url(item.content['#markup']) }}
{% endfor %}

So how can I get the alt tag?


texts: I installed a pure Drupal on Windows/IIS6 share host, and uploaded several modules in (sites/all/modules). When I want to enable some module together, my administrative pages become white, but front page and other pages work normally.


texts:
I am unable to export a particular view via Features UI because this view is supposedly default by a different module. In features.ctools.inc line 164 - 172:

// If this object is provided as a default by a different module, don't
      // export and add that module as a dependency instead.
      if (!empty($object->export_module) && $object->export_module !== $module_name) {
        $export['dependencies'][$object->export_module] = $object->export_module;
        if (isset($export['features'][$component][$object_name])) {
          unset($export['features'][$component][$object_name]);
        }
      }
      // Otherwise, add the component.
      else {
        $export['features'][$component][$object_name] = $object_name;
      }

As you see from the code, my view is not being exported because it has different 'export_module'. How to clear 'export_module' for a particular view to enable it export via features.
This is what i did:

ensure that the other feature doesn't export this view.
Ensured that the setting 'Allow conflicts to be added' is selected.
I have cleared cache,
Deleted the tables cache, cache_view.

No result, the view i like to export via feature continue to come up with 'export_module' different making impossible to export. Any help much appriciated


texts:
According to Drupal handbook route definition accepts parameter called _theme. Unfortunately this parameter is documented as "TODO".

Can this be used to force admin theme for the route? Is it possible to inject config parameter with admin theme name here?

It appears that other solution is to use Theme negotiator however the _theme parameter looks very tempting and way simpler to use.


texts:
Hi ive been searching about for an answer for this for over an hour now. I know there is the collapible block module but i was hoping to use drupals inbuilt collapisble code just on the block in question. I dont seem to be able to do it.

The block is a Views block if that makes any differance and i am using D6.

Thanks


texts:
Is it possible to import XML and create a node upon request?

For example, if a user clicks a link http://www.site.com/item-1, can the corresponding XML file http://www.othersite.com/path/to/item-1/doc.xml be imported as a node at that time, and the user redirected to the new node?

(The XML file is massive, with about 200 fields I need to bring in.)


texts: It says "No Solr instance available when trying to clear the cache", should I reinstall that module?

texts: In admin/reports/apachesolr/solr  "No Solr instance available when trying to clear the cache", should I reinstall that module? I can`t cope with setting up the search block to return the search result.


texts: Replacing theme() with render() in a block_view

texts:
I'm trying to replace the theme() with render() as recommended:

https://api.drupal.org/api/drupal/includes!theme.inc/function/theme/7
So I started with:

 function mymodule_block_view()
 {
  $variables['module_path'] = drupal_get_path('module', 'mymodule');
  $block['subject'] = t('mymodule Slide');
  $block['content'] = theme('mymodule', $variables);
    return $block;
  }

And I tried

 function mymodule_block_view()
 {
    $variables['module_path'] = drupal_get_path('module', 'mymodule');
    $block['subject'] = t('OpenDTP Slide');
    $rdr = array(
      '#theme' => 'opendtp_slide',
        '#module_path' => $variables['module_path'],
     );
    $block['content'] = render($rdr);
    return $block;
}

But it says Undefined variable for module_path that I used in the tpl.php file.
How I'm a supposed to use variables in the template then ? What is the correct way of doing it ?


texts: Mixed entity types. How to create a view of nodes and groups?

texts:
I want to create of view of nodes and of groups (group module). Being different entity types I am not sure if this possible. Is there a method by which this could be done?

There is no specific relationship between the nodes and the groups, as I am just seeing them all as pieces of content for the purpose of this view.


texts: Configure web.config to redirect non-www requests to www for multi-site Drupal 7 Install

texts:
I have a multi-site Drupal 7 install running on Azure that I would like to force all non-www traffic to the www address for all sites.

I have tried a number of examples from around the web but none of them seem to work.

Here is my current implementation, which looks like it should work, but does nothing.

<rule name="Redirect to www">
  <match url=".*" />
  <conditions logicalGrouping="MatchAny">
    <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" negate="true" />
  </conditions>
  <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" redirectType="Permanent"/>
</rule>

To clarify, yes, the above rule is nested inside <configuration> <system.webServer> <rewrite>

I've read about doing the redirect in settings.php but that seems kludgy to me and I'd rather do it right.

Any help would be greatly appreciated.


texts: I have created a content type, but it doesn't use the following part. I want to remove it without using CSS. how can I doit?


texts:
I'm trying to create a new region called 'usermenu' for my theme in Zen. I've therefore added

region[usermenu] = User menu

to the mytheme.info file, added

<?php if ($logged_in): ?>

      <?php print render($page['usermenu']); ?>

<?php endif; ?>

to the mytheme.tpl.php file and added

#usermenu {
  background-color: #fff;
  height: 35px;
}

to one of my CSS files. After clearing caches multiple times, the new region is displayed correctly and I can detect it with Firebug, but it doesn't show up in the block section.

What's going wrong and how can I solve this?


texts:
So I have a small bit of HTML and Javascript that I want to embed in a basic page. I go to edit the page, turn off rich text editing, and paste the HTML/javascript. I save, and then the javascript portion gets deleted while the HTML stays.

Is there any reason for this?

It is worth noting that the site is maintained and run by the university, although I have full permissions.

Other people say just add a bit of php and add_jscript(), but don't say where that goes, or how to get to that file.

EDIT: So I contacted the IT department and they suggesting adding the script as a block, and then adding the block to the page. Thanks for all your help!


texts: Are custom content types a good way to model the classic entity relationship model?

texts:
I have several content types which will store thousands of records each one.
Those content types will be related to each other as in a classic 1..N or N..M relationships I would like to query those content types taking this relationship into account.

I have searched for this on d.o but I am puzzled with the big quantity of modules available.
For instance is entity and entity reference any good for this ?

What is the best way to model the classic entity-relationship model of the database systems ?
Also, will I be able to tune the database (mainly create new indexes) to increase the performance of the queries ? I am asking this because I will need to tune the database because of the big amount of data, so this is something to take into account at the time of considering different approaches to the modeling decision.


texts: Import Drupal 8 Database in MAMP using PHP Myadmin

texts:
I'm trying to import a drupal 8 database to my local MAMP server via phpmyadmin.

I have a 1.4MB database.sql.gz file (cache emptied, it doens't matter what database export of drupal 8 I use by the way).  But I keep getting an internal server error. Looking at the log I find this:

InnoDB: Error: Fetch of persistent statistics requested for table "databasename"."tablename" but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.

Followed by:

InnoDB: Error: Table "mysql"."innodb_table_stats" not found.

So my settings must be off, but I don't know what to change? Can some help me with fixing this.

Thanks in advance,
Joost


texts: Display a block on some pages according to the fields content of that page

texts:
I created a content type called people, where I create personal pages using that type. One of the fields is 'area'.

Then, I created a view of block called 'software people', where I list all the people who work in software area. I want to show this block only on the pages where the person's area is Software. How can I achieve this?

Thanks


texts: Display entity images with thumbnails and 1 large image

texts:
I want to attach multiple images to custom entity (commerce product),
and display them as follow: 1 large image, and list of thumbnails, user can click on thumbnail thus changing large image.

I found and plan to use the library http://www.elevateweb.co.uk/image-zoom/examples#gallery-lightbox

So my steps:

create subtheme of bootstrap theme
add field "images" to the commerce product entity
write twig file to display images

Is it correct path? or maybe there is better solution? better library?

With image zoom, I need to get output like this


texts:
Our drupal site uses fonts/glyphicons-halflings-regular.woff2 through bootstrap v3.3.2. But I am getting 404 for the file fonts/glyphicons-halflings-regular.woff2.
Is it some issue with the bootstrap? What is proper way to fix this?


texts: Custom Views Filter - won't display as checkboxes

texts:
Trying to do a custom filter so that the user can select multiple states to filter the data by.  This works (or will when I do some customizing to the query after) but it shows a select box.  Any ideas?  Tearing hair out :)

<?php
class custom_filters_handler_filter_state extends views_handler_filter_string{
  function value_form(&$form, &$form_state){
    $options = array(
     'DC' => 'DC',
     'MD' => 'MD',
     'VA' => 'VA',
    );
   $form['value'] = array(
   '#type' => 'checkboxes',
   '#title' => t('State'),
   '#multiple' => TRUE,
   '#options' => $options,
   );
return $form;
  }
}


texts:
I have a calendar feed (using the Drupal Calendar module) on a site and I'd like to add this calendar to Google Calendar. I have this working for a publicly accessible calendar and it works fine.

The problem now is that my calendar is only accessible for authenticated users and should remain so. I see no way to authenticate the application accessing a feed and therefore can't access that calendar from Google Calendar.

Is there any way to provide credentials in the feed url or something similar?


texts: Private files works on one site but not another

texts:
I have two sites on the same machine - demo and dev.

They are served from their respective home directories.

I've set up private files on both. All the settings seem to be exactly the same. However, on dev, private files work perfectly, but on demo, they don't. When you upload a file it gives no indication of error in the GUI, but when you try to access it you get a 404. The dblog says "The file permissions could not be set on private://2018-04/foo.txt." Searching for it on the command line shows that it has been saved to <webroot>/private:/2018-04/foo.txt instead of to /home/demo/private-files/2018-04/foo.txt.

Although, strangely, it does in fact create the subdirectory /home/demo/private-files/2018-04/ ! It just does not put the file in there.

On both sites the private file paths are set :

And the permissions are exactly the same:

There is no difference between the .htaccess in either directory:

What am I missing?


texts: Update/Changed field not updating programatically in node

texts:
I'm creating a node programatically in D8 and passing the value for update field explicitly.
When the node is created it sets the update value which is provided, but when the same node is updated the changed value is set to current time, but when I again update the same node it takes the value which is provided.
Code :
$node_data = [
'title' => 'Test node title',
'changed' => 1594270272
];
 $node = Node::create([
                'type' => 'article'
            ]); //to create new article
$node = Node::load(NID OF ARTICLE CREATED); // to edit already created article
 $node->set('title',$node_data['title']);
 $node->set('changed',(int) $node_data['changed']);
 $node->set('uid',1);
 $node->save();

Case 1 : Created new article with $node_data, updated time is set to 1594270272
Case 2 : Edited the article created in step 1, updated time is set to current timestamp.
Case 3 : Edited the article again created in step 1 and edited in step 2, updated time is set to 1594270272 again.

The same things is happening after every alternate update call.

I want to set the new updated time every time which is passed in $node_data.


texts: D7 Why I cannot just copy a template file from a module to my custom theme to override it?

texts:
I'm using the TimeField module with a custom theme (a subtheme of the Bootstrap theme) and I want to change how the output is rendered.

There's a timefield.tpl.php file located at

  sites/all/modules/timefield/theme/timefield.tpl.php

which I want to modify copying it to

  sites/all/themes/my_theme/templates/

but when I do so the copy is ignored and the original file is loaded instead.

I'm a Drupal newbie but I like to learn, so any advice or link to a resource to understand where the problem lay is fine.


texts: Does Drupal's theme('table') works in email body?

texts:
I want to send the list of some of the node information in email to users.

I have created table of information using theme('table') function. Now I want to send this table to email to user.

Is it possible to send theme('table') using Email ?

Will it work when user will see the information in Email ?

I am sending table structure in Email, is this possible to achieve it?

I have attached the relevant code to generate table and send mail.

$header = array(
            array('data' => t('Title'), 'field' => 'n.title'),
            array('data' => t('Author'), 'field' => 'u.name'),
    );
    $query = db_select('node', 'n');
    $query->leftjoin('users', 'u', 'u.uid = n.uid');
    $query->fields('n',array('title', 'created', 'nid', 'type'))
    ->fields('u',array('name', 'uid'))
    ->fields('b',array('body_value'))
    ->fields('c',array('subject'));
    $query->condition(db_or()->condition('n.type', 'post', '=')->condition('n.type', 'forum', '='));
    $query->condition('n.uid', $user->uid, '=');
    $result = $query->execute();
    $rows = array();
    foreach ($result as $row) {
        if($row->subject) {
            $titlerow = l($row->subject, 'node/'. $row->nid).'</br>'. $row-
        }
        $rows[] = array( $titlerow,
                t('Reply Posted by: ').l($row->name, 'user/'. $row->uid)
        );
    }
    $params = theme('table', array('header' => $header, 'rows' => $rows, array('class' => array('ajax-sample-table'))));
    $language = language_default();
    $send = TRUE;
    $result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
    if ($result['result'] == TRUE) {
        drupal_set_message(t('Your message has been sent.'));
    }


texts: How to create a pie chart of user points and taxonomy terms?

texts:
I have 3 terms in Taxonomy > User Points: Articles, Comments and Favorites. I created some rules to grant user points of one of these categories, based upon the users' actions. So far, everything works fine.

Now, I'd like to create a pie chart of the user points per category for the profile pages. For example, such a pie chart might look like this:

How can I achieve this?

Edit: I'm working with User Points 7.x-1.0.


texts:
I'm using Drupal 7.

I want to disable css defined by theme because I want to use my custom css that is defined by my custom module. What I mean is, I want to disable sites/all/themes/custom_theme/css/custom.css and use sites/all/modules/custom_module/css/custom.css instead.

Is there any way to do that?

Thanks!


texts: Change permissions or add roles on the fly

texts:
Is it possible to add permissions or add a different role to a user on one particular form/page and for those to be removed after the form has been submitted?

It is particularly for when one user creates a new user (using subuser module). They need "Administer Organic groups permissions: Administer all groups and permissions." permissions to set the new users organic group on creation, but they must not be allowed to edit other groups!


texts: Site stuck on maintenance mode only for a single page

texts:
On a live, multilingual (fr/en) client site, I've just update Drupal 7 to its latest version (along with a few modules). Everything went fine, except that, even though the maintenance mode has been disabled, the maintenance page still shows up on ONE specific URL of the public site.

www.domain.com/ -> OK
www.domain.com/fr -> !!! maintenance page
www.domain.com/fr/ -> OK
www.domain.com/en -> OK
www.domain.com/en/ -> OK

(All the other pages are OK, as far as I can tell.)

I've tried clearing all caches multiple times, and I tried running update.php again, with no effect.
Following other answers, I've also checked the database (cache_bootstrap and variables), but as far as I can tell, everything is normal there too.

What's wrong?

UPDATE
Problem solved, although I haven't done anything in particular. Maybe it was caused by some third-party caching mechanism (e.g. from the hosting provider). Will look into that if the problem occurs again.


texts: LDAP SSO - User not redirecting to user/login/sso to login the visitor

texts:
I have implemented LDAP - Single Sign On (SSO) on my Drupal project. All the settings (testing, connecting with server) is working perfectly fine.

The problem is that when I visit my site, the site doesn't authenticate the user.

Upon testing every option regressively, I realized that my site is not redirecting to http://www.theurl.com/user/login/sso, which authenticates and sign in the visitor.

When I manually went to http://www.theurl.com/user/login/sso, the site authenticated and logged in the user perfectly.

Is there anything I can do to mitigate it?

Thanks a lot


texts:
I don’t know why in Drupal 6 some of my parent taxonomy terms have duplicate URLs. For example, I have http://example.com/carrers-0 instead of http://example.com/carrers.
I am not finding any duplicate taxonomy term.

How can I correct it?


texts:
new to drupal. I've added a custom region to my .info file and in the page.tpl.php file I'm printing that region

<?php print render($page['banner_ad']); ?>

The thing is, I want to add an image to that region, but I don't seem to be able to find an easy way to do it (in the template file that is). From what I've read online you can add an image to a container easily by doing something like

<img src="<?php print $directory."/img/myimage.png"; ?>">

which is great if it's an ordinary div, but what if I want to add the said image to a custom region that i've added to the page.tpl.php file? I mean is there a syntax that allows me to do it, something like (of course the below won't work, but you get what I mean)

<?php print render($page['banner_ad[<img src="<?php print $directory."/img/logo.png"; ?>">]']); ?>

thanks


texts: Passing node parameters into views block

texts:
I am on Drupal 7.

I have two content types. Content type 1 is called Bulletin and content type 2 is called Bulletin Text. I have a node reference field in Bulletin Text content type that allows me to link it to a certain Bulletin object.

Now, when my user is on a Bulletin Text node I want him/her to:

see all the other texts associated with that same Bulletin on a block to the side of the page;
remove the current Bulletin Text node from the list of bulletin texts, as it wouldn't make much sense, as the block would be something like "other texts from in this Bulletin".

Is there a pure Views solution for receiving the nodereference value from the current node being displayed on the page (passing that parameter into the Views block) and showing the list of nodes associated with it (also removing the current nid from the list), or do I have to play around with Contexts, Panels or custom code? What do you consider the best approach for me to solve this?


texts: What are these mysterious core.xxx files doing in my site's root?

texts:
I have never seen this before in my 2 years of building site's in Drupal. I just opened up one of my sites folder structure and found a large number of core.xxx files that I don't know what they do (and they are huge files, over 8GB worth). I found a couple of threads on this but no real answer. Any thoughts?

http://drupal.org/node/360867
http://drupal.org/node/115654

core.1688
core.2343
core.8485
core.3039
core.21233
core.23234


texts: Is there a better way to create an alternative URL Alias Pattern?

texts:
Say for example my alias pattern for one node is set up as:

style-[node:field_style]/[node:title]

There may be a case that node:field_style is blank so I would like to use another field and a slightly different url alias pattern:

type-[node:field_type]/[node:title]

I am thinking about just using hook_pathauto_pattern_alter() but wondering if there is a better way?


texts: Attached User profile form gets error on save

texts:
I had attached my user_profile_form in my custom form and called the custom form by the defining a new path in hook_menu(). The user_profile_form got rendered correctly. But while saving the form I'm getting the following error.

Recoverable fatal error: Argument 2 passed to
drupal_array_set_nested_value() must be of the type array,
null given, called in /var/www/html/mytheme/includes/form.inc
on line 2655 and defined in drupal_array_set_nested_value()
(line 6746 of /var/www/html/mytheme/includes/common.inc).

I used the following code in my form :

$form = array();
module_load_include('inc', 'user', 'user.pages');

global $user;

$form = drupal_get_form('user_profile_form', $user, 'account', 'custom');

unset($form['account']['mail']);
unset($form['account']['current_pass']);
unset($form['account']['pass']);
unset($form['timezone']);
//print '<pre>'; print_r($form);exit;

return $form;

Please suggest ideas on resolving this.


texts: Flag module integration with Message module

texts:
I am using Rules, Message, Message Notify and Flag modules.
I added a message to the activity stream when user flags a node as "Favorite".

My problem is I am getting notification, but the node that was flagged seems to be missing from the message entity. Please guide for the steps, or where I may be wrong

UPDATE:
Adding rules in export format for better understanding and reference. In mail being send through rule, every token is working perfectly, but not in message added to activity stream.

{ "rules_user_likes_a_node" : {
    "LABEL" : "User likes a node",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "flag" ],
    "ON" : { "flag_flagged_group_flag" : [] },
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "node", "value" : [ "flagged-node" ] },
          "PROVIDE" : { "variable_added" : { "node" : "Added variable" } }
        }
      },
      { "mail" : {
          "to" : [ "flagged-node:author:mail" ],
          "subject" : "[flagged-node:content-type] [flagged-node:title] est aim\u00e9",
          "message" : "Hello [flagged-node:author:name],\r\n\r\n\r\n[flagging-user:name] loved[flagged-node:content-type] [flagged-node:title]",
          "language" : [ "" ]
        }
      },
      { "entity_create" : {
          "USING" : {
            "type" : "message",
            "param_type" : "commons_activity_streams_user_likes_a_node",
            "param_user" : [ "site:current-user" ]
          },
          "PROVIDE" : { "entity_created" : { "message" : "Created entity" } }
        }
      },
      { "data_set" : { "data" : [ "flagged-node" ], "value" : [ "flagged-node" ] } }
    ]
  }
}


texts: how to use tokens as “views filter criteria” for a custom table?

texts:
I created view for fields from a custom table using handlers.
I need to create a filter so that only the users who created the data can see the data.
how can I create the filter?


texts: How can I always have the node title display on top of a background image?

texts:
With Drupal 8, the page title is available through a block now. We have several content types where we have an Image field (field_image) and we constantly have to write templates per content type to place the title on top of the image.

It would be nice if we could use the view modes of each content type or some module to do this. Basically, something that does "take the field image, set it as a background, and place the title on top."

Is there a better way to do this programmatically as we cannot find any other way to do this?


texts:
I like to have drush command 'go_to' that will move my shell into different directory. My custom implementation does not move the shell directory. How come? here is the script so far:

#!/usr/bin/env drush
<?php

$dir = '/dir/to/move/my/shell';
drush_op('chdir', $dir);
drush_op_system('cd '.$dir);
//drush_shell_exec('cd '.$dir);
//print_r(drush_shell_exec_output());

Thank you for help


texts: How can I correctly include a (non-fragment) # in a URL?

texts:
I need to build an external URL that looks like this:

https://searchapp.foo.gov/search-org/#/collection-name?q=search%20terms%20here

First thought is that /#/ is entirely invalid according to RFC 3986, unless I'm reading it incorrectly, but that's what I've been given. So I'm building it like so:

$base_url = 'https://searchapp.foo.gov/search-org/#/collection-name';
$options = [
  'absolute' => TRUE,
  'https' => TRUE,
  'query' => [
    'q' => $form_state->getValue('search'),
  ],
];
$url = Url::fromUri($base_url, $options)->toString();

Instead of the expected output, I find that my querystring is appearing before the #:

https://searchapp.foo.gov/search-org/?q=search%20terms%20here#/collection-name

I've tried using /%23/ instead of /#/, and that fixes the problem with the querystring being out of place, but creates a new problem by url encoding the %, so that I wind up with /%2523/.

I'm guessing this is a problem with hash segment handling. Is there a right way to handle a URL like this?


texts: Problem on the comment form #validation and #submit

texts:
I've tried to create a validation and submit functions on a custom comment form, using drupal 7.9,  but it's not working, and I don't know why.

In the following code, we can see the "dpm's" in the first function, but not the "dpm's" in the last ones.

function job_form_comment_node_job_form_alter(&$form, &$form_state) {
    $form['#validate'][] = 'job_comment_validate';
    $form['#submit'][] = 'job_comment_submit';
    dpm($form);
    dpm($form_state);
}

function job_comment_validate($form, &$form_state) {
    dpm($form);
    dpm($form_state);
}

function job_comment_submit($form, &$form_state) {
    dpm($form);
    dpm($form_state);
}

if I add a #validate or #submit it also doesn't call others drupal hook comments like presave, insert etc.

If I comment these lines, the hooks are called, but I can't use the validation or the submission functions in this case.

Do you have any idea on why this happens?


texts: How to redirect all images in the files folder to a default file?

texts:
Because we work with DTAP environments, our developers work on their own laptops. To get a good view of the live environment, we copy the PROD database and the files to our own laptop. However, this takes up a lot of space because of all the files directories.

What I'd love to have is a simple .htaccess or Apache redirect rule that points all files in the files directory to one default image, so that we don't have to copy the files directory contents (which can be gigabytes sometimes).

There is one exception though for JS/CSS files and files in the files/styles directory. Those callbacks must keep working.

Any thoughts on if and how this would be achievable?


texts: What are the major differences in building an install profile for Drupal 8?

texts:
There is a good guide for drupal 7 which explains how to build a install profile for drupal 7. I built an install profile using it.

But I want to build an install profile using Drupal 8. What changes do I need to make to my Drupal 7 install profile to make it work for Drupal 8.

PS: I know Drupal 8 is not ready yet but I'm doing this for learning purposes.


texts: Delete Custom Content Type Content with Custom Fields

texts:
I want to delete the content of a custom content type, which has thousand of nodes. The problem is that I can delete the references from the node database table, but the issue in this solution is that the content still remains in the custom field types database table, and when I want to recreate some data, it gives me the error of duplicate data.

Is there a solution to delete custom content type nodes with there related custom field types?

I am using Drupal 7.


texts: Print registration and login forms on same page

texts:
How do I print the register and login forms on the same page?

I think I am really looking just for the form IDs, but if you've got the right render function handy it would be very appreciated.


texts: Received "An illegal choice has been detected. Please contact the site administrator" while creating node with taxonomy field via service3 drupal7

texts:
I am having an error:

  {"form_errors":{"field_category][und":"An illegal choice has been detected. Please contact the site administrator."}}

Field category is a taxonomy field attached to a node. I'm trying to create a node via web services and unable to create taxonomy field. I have also match post array by doing print_r($obj) on node form validate:

PHP Array:

[field_category] => Array(
  [und] => Array(
    [0] => Array(
      [tid] => 6246
    )
  )
)

JSON conversion:

"field_category": {
  "und": [
    {
      "tid":6246
    }
  ]
}

However, in response having an error, the same problem with the other taxonomy field. What I am doing wrong with it.


texts: Change Facebook OAuth connect image by language

texts:
now it uses fbauth.module the line

$src = ($GLOBALS['is_https'] ? 'https' : 'http') . '://www.example.com/sites/default/files/connect_light_medium_short.gif';

How can I change it by language?


texts: User login through token in URL in drupal 6

texts:
I have a drupal 6 website and I would like to implement the functionality to allow user of a particular user role to login into site using the token value in the url.

I have user role "SAP" in the website and will send a link to user in mail "www.example.com/user/token". When user click on this link, I want allow user to login into site automatically.

I have searched through into google and drupal site but I did not find any solution.

Thanks in advance.


texts:
I have a Drupal 7 setup with multiple languages (en and fr). In my template files I have a lot of t() texts which im translating using the i10n_client module. This works perfect for translating texts from en to fr IF the t() texts are written in english. However, what if I want to write my t() texts in Danish and being able to translate them to both en and fr? Meaning that the Danish version never will show up as long my Drupal setup only have en and fr as languages.

I tried using the options parameter with the langcode like this:

print t('Min tekst', array(), array('langcode' => 'da'));

But the translate-text interface (provided by i10n_client module) wont show up when I'm on the en site. Only on the fr site where I can translate it from en to fr.

Is this possible? And how?


texts: How can I insert block content between page fields?

texts:
My page content type has two entity reference types that reference other content types.

Hero
Quotes

The hero displays at the top of the page and I want the Quotes at the bottom of the page.

In between these two pieces of content I have custom blocks and views that I wanted displayed.
How can I have the Hero and the Quotes nodes below other custom content?


texts:
I was wondering if anyone has been able to successfully resolve the issue of the missing custom blocks from the admin list in drupal yet?

I have been struggling with this problem for 2 days now.

I have scanned the internet and forums (including this one) and tried every trick suggested,  and found many examples of what should work, but each time it does not.

I have tried unregistering/registering, clearing out the caches automatically and manually in the DB, all to no avail, I simply don't see the elusive block in my admin.

I went to the database and checked out the blocks table, and I don't see it registered there, I don't know if that gives a clue?

Between I have tried all of the tips in this posting and the links.

I have included by latest web cut and paste, if there is anything you think I might be doing wrong, I would really appreciate your help.

This is the code I am currently using :

function customblock_block_info() {
  $blocks = array();
  $blocks['customblock_abc'] = array(
    'info' => t('Customblock'),
    'region' => BLOCK_REGION_NONE,
    'status' => 1,
  );

  return $blocks;
}

function customblock_block_view($delta = '') {
  switch ($delta) {
    case 'customblock_abc':
      $block['subject'] = 'Block title';
      $block['content'] = 'Hello world!';
      break;
  }
  return $block; // dont forget to the return the $block!
}
}


texts: How to make a child entity automaticially reference back to parent entity when created using inline entity form?

texts:
Here is the example:

'Parent' Content Type = Author

field1: Name
field2: Age
field3: Picture
field4: Entity Reference to Books (inline entity form widget)

'Child' Content Type = Books

field1: Title
field2: Description
field3: Entity Reference to Author using prepopulate (need help)

Author has entity reference to Books using Inline Entity Form. So when creating an "Author", we can add "Books" they have written inline.

When a user visits an individual "Book" page, I want a field that links back to the "Author" who wrote it. How can I create this link automatically when creating a "Book" inline?

I assume I have to create a Book field3 that is an Entity Reference to Author that uses prepopulate. But I have not been able to configure this correctly to get it working as wanted. Any ideas?


texts: Cannot get translated value for an entity inside twig

texts:
Inside a custom module I get the translated nodes like this:

$ids = Drupal::entityQuery('node')
    ->condition('type', 'event')
    ->condition('status', 1)
    ->execute();

$nodes = Drupal::entityTypeManager()->getStorage('node')->loadMultiple($ids);

$events = array_map(function ($node) {
    return Drupal::entityManager()->getTranslationFromContext($node);
}, $nodes);

and inside the template:

  {% for event in events %}

{{ event.title.value }}

        {{ event.field_event_type.entity.name.value }}

  {% endfor %}

The event_type entity which is a taxonomy is displayed in the original language always. How can I get the translated value for the entity too?


texts: Print a block inside a Views header or Views footer using PHP input

texts: There seems to be multiple ways of printing a drupal 7 block via php input filter. What is the most efficient way of printing a drupal block in Views header or Views footer attachment of a global text php input filter?


texts: How to change node field label for some specific conditions?

texts:
In preprocess_node I wrote this and when I do kint($variables['node']) I can see that label is set to "test", however on display it appears with the old label. How can I change the label name? Should it be in preprocess_node or some other hook? Or what else I should update, so it is actually displayed with label replacement?
    $node = &$variables['node'];
    if ($node->getType()=='training') {
      $term = reset($node->get('field_training_type')->referencedEntities());
    }
    if($term instanceof \Drupal\taxonomy\TermInterface && $term->id() == 9) {
      $node->get('field_section_09')->getFieldDefinition()->setLabel('test');
      $variables['node'] = $node;
    }


texts: The theme is broken when I enable the "Optimize CSS files" option

texts:
The theme I made is broken, when I enable the "Optimize CSS files" option. I have cleared the cache, but the theme still doesn't work. With Firefox and Internet Explorer it is OK, but with Google Chrome is not OK at all.
How can I fix this?


texts:
I have 2 views in a page. The first view displays 3 articles and the second view displays a list of all the articles. The problem is that I get duplicated articles in the second view since it is displaying all the articles.

I need to set a range of the last 3 articles added to Drupal and display them on the first view  and on the second view I need to display the remaining articles. I´ve been looking for something like this is in the filters but I haven´t found something.

Thank you for your help !


texts:
Hello i have recently changed domains and ..well it cant be related can it? anyhow all my old comments are not showing. When i went into the database via phpmyadmin i notice that the deleted coloum which should say 0 has 1 in there for all the old comments.

also i note that the bundle coloum (sorry table?) is showing 'comment_node_forumpost' not 'comment_node_post' which is my current content type.

sorry im in field_data_comment_body.

I dont want to do anything wrong here but i have been trying (to do something right)

Can anyone suggest a query that i could run that will reset all my deleted table to 0 and my comment_node_forumpost to comment_node_post?

Thanks


texts:
I am writing a module where I need to grab the submission values of a webform

I am using the webform_submission_insert hook found here however when I print out the $submission array using this:

drupal_set_message('
'.print_r($submission).'
', 'warning');

All I get is this:

1

It appears to me this hook is not working correctly and is not populating the array. How can I get the submission values?

I am using Webform version 7.x-4.0-alpha6. The webform I created has about 10 different input fields.


texts: Redirect language-specific URL to correct path prefix

texts:
Drupal 7. I have a multi-language website. Let's call it website.com.

At admin/config/regional/language/configure/url I have selected "Path prefix" as the "Part of the URL that determines language".

My host is using nginx. The hosting company has configured the site so that when I go to my Spanish language url (let's call it sitio-web-en-español.com) the browser ends up at website.com.

What I would like it to do is end up at website.com/es so that the users have Spanish language immediately without having to use the language switcher.

My question: Can I do this within Drupal or do I need to get my hosting company to change their configuration?

Thank you!


texts: I get "You are not authorized to access this page" when I try to load a view with Ajax

texts:
I am trying to load a view with Ajax, showing it in a specific
. I always get the Ajax message, "You are not authorized to access this page." My code is the following one:

/**
* Implementation of hook_menu().
*/
function custom_api_menu() {
  $items['ajaxgettip/nojs/%'] = array(
    'page callback' => 'custom_api_test_ajax',
    'type' => MENU_CALLBACK,
    'access callback'   => TRUE,

      );
  $items['ajaxgettip/ajax/%'] = array(
     'delivery callback' => 'ajax_deliver',
     'access callback'   => TRUE,
  );
  return $items;
}

function custom_api_test_ajax($nid) {

   $viewName = 'tip';
   $args = array($nid);
   $displayId = 'block_1';
   $view = views_embed_view($viewName, $displayId, $args);
   //return drupal_json(array('test'=>$res));
   ajax_deliver($view);
}

I am creating a link as follows:

<?php
    $link = array(
        '#type' => 'link',
        '#title' => t('something'),
        '#href' => 'ajaxgettip/ajax/114', #Hard coded nid at the end of path, just for testing
        '#ajax' => array(
            'wrapper' => 'ajax-response-goes-here',
            'method' => 'replace',
            'effect' => 'fade',
        ),
    );

$output = "
Some HTML and stuff
" . drupal_render($link);
print $output;
?>

I don't have an idea about what I did wrong, and I have read a whole lot of documentation. Who can help me?


texts: Checkbox Form Element: Displaying checkboxes value based on on/off

texts:
I have a checkbox form element that uses taxonomy terms via variable_get as #default_value; storing the result. I don't want to overwrite value, I just want the form to render/display checked initially.
  $form['search_block_topic'] = array(
    '#type' => 'checkboxes',
    '#options' => $topic_options,
    '#default_value' => variable_get('search_topic_options', $topic_options)

I tried
'#return_value' => "checked"
which doesn't work.


texts: Addressfields hide when I come back from review page

texts:
I am facing a issue for several days & trying to resolve it but couldn't get any way through it.

At first I thought it's issue with commerce_postal_filter module but it's not.

So the real issue is, when ever user click back button from review page in checkout process address-fields vanish from the page.

I have 3 steps in checkout -

Order Summery
Account Info & Address(Billing & Shipping)
Review

Billing has got one more field "Phone Number", that doesn't go but only dynamic address-field hide.

Does anybody have clue why it can happen ?

Note - This is happening with Billing Profile only not with Shipping.


texts: How to make multiple selection filter in views in drupal 7?

texts:
I am using drupal-7. I have created a views with expose filter with multiple selection .. I have 3 fields in expose (small,medium and large) its working fine.
when I select small its give small related data..
Note: But I need when I clicked on small then I need to small data and if i checked medium then I need both data Means small and medium.


texts:
I have a view using taxonomy CONTEXTUAL FILTERS.

taxonomy vocab 1 terms AND
taxonomy vocab 2 terms

Both are set to get the taxonomy id from the url, limited to a specific taxonomy vocabulary and share any of the terms.

But on taxonomy vocab 2, I would like to have an additional filter to pull content without any vocab 2 terms at all.

something along the lines of

has taxonomy vocab 1 terms AND
has taxonomy vocab 2 terms OR
has NO taxonomy vocab 2 terms

I can do this with two separate views:

VIEW 1

has taxonomy vocab 1 terms AND
has taxonomy vocab 2 terms

VIEW 2

has taxonomy vocab 1 terms AND
has NO taxonomy vocab 2 terms

but I would like to combine the results.

Edit: if I have this set of content with terms, and the Contextual argument is term 1 I want the first and third to be shown in Views results:

content 1 | term 1
content 2 | term 2
content 3 | no term selected


texts: What does it take for field in an entity to be able to be used in cotexetual filter, or relationship?

texts:
I am using a view for an entity.  I had it working until I changed the cardinality of a taxonomy field.  Now that field is no longer available for relationships, or contextual filters.  Every other field defined is available as a contextual filter.

So this makes me wonder what determines whether a field can be used in a contextual filter?


texts: Display the node edit form on a node view page

texts: Can we show the node edit form in a custom block and show that on a node view page?


texts: Using computed field to calculate total hours for a datetime field but to exclude all weekend hours

texts:
Please please if can anyone help I would really appreciate it!

I have managed to get total hours between value 1 and value 2 of my datetime field however I really want to exclude any hours which are in the weekend. I am creating a timesheet for a group of carers and some people will work from a friday night to a saturday morning etc.

this is my code I use atm for calculating the total hours:

$start_value = $entity->field_work_hour_date[LANGUAGE_NONE][0]['value'];
$end_value = $entity->field_work_hour_date[LANGUAGE_NONE][0]['value2'];
$timezone = $entity->field_work_hour_date[LANGUAGE_NONE][0]['timezone'];

$start_date = new DateObject($start_value, $timezone);
$end_date = new DateObject($end_value, $timezone);

$duration = $start_date->difference($end_date, 'hours');
$entity_field[0]['value'] = $duration;

I am still quite new to drupal and php so I would really appreciate any help.

Cheers


texts: How can I import/rewrite settings/content types/blocks/etc from live with the newly developed features on dev?

texts:
I have a site that's already up and running. On my local dev environment I occasionally develop new features for that site.

I have certain configs(blocks, settings, etc) that I need to add to the live site. However, I can't seem to figure out a way to import them without deleting the current blocks/settings/etc that already exist on the live site.

Is there some way that I could import them on the live site without deleting them beforehand?


texts: Taxonomy term via Rest API returns 406 Not Acceptable

texts:
I can't get the Taxonomy terms to work with the Rest API. I've used the Rest UI module to enable the Taxonomy Term for the Rest API, and enabled all formats.

When I request http://www.domain.com/taxonomy/term/1?_format=json though, I get the message:

{"message":"Not acceptable format: json"}

Same for for hal and xml. Everything works fine for nodes, so I suspect a bug somewhere. Using 8.2.6 .


texts:
I would like to have the ability to prevent cron from running based on a variable set in the database. I have created a hook_cron implementation in a module with an extremely low weight so it will presumably run before all other module's cron hooks. Within that function I then check the variable and call exit() to abort PHP's execution. This seems to work but is there a more elegant way to prevent cron from continuing? Calling exit() seems a bit harsh and I am concerned about unintended consequences. Example code below.

function ex1_cron() {
  if (variable_get('ex1_var', 1) === 1) {
    watchdog('ex1', 'Cron is being aborted.', array(), WATCHDOG_WARNING, NULL);
    exit();
  }
}


texts: How to print multi step webform current step number from webform page template?

texts:
I have template named page--webform.tpl.twig which is kind of wrapper for multistep webform. I would like to print current step of the webform from that template.

Is there a way to access current step number from this template?


texts:
I'm learning Drupal, and I want to develop a website where the main thing is its database.

I already have the Extended Entity-Relationship Model of the database (kind of complex).

What's the right direction to take when creating a database to be used by Drupal, create it manually and do the queries in Drupal using PHP, as it were a PHP+MySQL site from scratch?
Does Drupal provide an easier way to do this?

Edit:
I'm not a Drupal experienced developer. What I want to know is:

When working with databases, is any better way of doing this that querying the database using SQL syntax, like if I were developing a PHP+MySQL single page?

I just want to know what Drupal developers usually doe when they want to create a database, insert data, modify data, or do some queries and show the data to the users.


texts:
The user tabs are:

View

Edit

My content (created with Views with path user/%/track)

Every user can edit his profile with the user tab "Edit".
When registered user enters other profile the two tabs "View" and "My content" are available, without "edit" (that's fine), but what about anonymous users?

When I enter from anonymous user into /user/1/track I see the content but without the tabs(View and My content).

How can I make these tabs displayed from anonymous users?

Do I have to use hook_menu_alter for this core element?

EDIT:
"View user profiles" is already activated for anonymous users in permissions page and user/1 and user/%/track are accessible for anonymous users, but the tabs are missing.


texts:
I've created a view for a node which shows the content as rendered entity. Among others, I output the body field in the twig template:

{{ content.field_body }}

Now, I'd like to limit the text to 200 characters and put three dots. I've tested three different ways to do that, but nothing has worked. The problem is, that each way counts and trims the HTML characters too.

1: I've added the format "Trimmed" in "Manage display" => The text is limited but not correct. And I do not have the three dots.

2: I've trimmed the text in the twig template. But to count the text I have to render it first. Thereby, twig outputs the text as HTML (I see HTML tags on my page!)

{% set text = content.field_body|render %}
{{ text|length > 200 ? text|slice(0, 200) ~ '...' : text }}

3: I've tried to solve the problem in template_preprocess_node(). Here I have the same problem with counting the HTML markup too.

$body_text = $node->get('field_body')->getValue()[0]['value'];
$trimmed_text = substr($body_text, 0, 200) . '...';

How can I trim my text right?

Thank you very much for your help!


texts: feeds module cannot handle csv files exceeding 8gig?

texts:
I am trying to import a very big CSV file into my Drupal 7 site using the Feeds module, but I get the following error:

  Warming: POST Content-Length of 40245470 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

How can I fix this?


texts: Can access arguments only be specified once for all sub-routes?

texts:
For example:

I would start off by setting this.

$items['admin'] = array(
 'access arguments' => array('administer users'),
 'type' => MENU_NORMAL_ITEM,
);

But the anytime after I use admin in my menu hook it would take on the same access arguments. So below would take on the same access argument as the above.

$items['admin/users'] = array(
 'page callback' => 'drupal_get_form',
 'page arguments' => array('get_users_page'),
 'title' => 'Users Listing',
 'type' => MENU_NORMAL_ITEM,
);

EDIT: To put in better words, thanks Jaypan. Can access arguments be inherited from their parent's access arguments?


texts: How to work with .install files and hook_enable etc... when developing a module?

texts:
I'm writing a module which utilises a .install file to create and configure things - specifically I'm creating a custom line item based on the commerce_example module. Turns out it's quite a bit of code and will take a bit of time to get right.

This is all good, but how can I go about testing this as I'm going? I'll inevitably want to add fields to the install function later on, but to do this I'll need to disable (and uninstall?) the module, deleting the existing line-items, and re-enable every time I need to test if it's working which seems so slow. Is there a better way of working when doing this?


texts: Smart paging rendering pager different from the Devel model

texts:
I am on Drupal 7 and I have the Smart Paging module enabled. When theming my module, I want the page numbers to appear as regular links. This seems to be the natural behavior. Here is the HTML available on the Devel module on the render section for [smart_paging]:

Páginas

1

2

3

próx ›

fim »

The problem is that the links to the pages 1, 2, 3... are being replaced with a select list box with the options Page 1, Page 2, Page 3. I don't know how to change that behavior and make the links render as... links, exactly the way the HTML is showing.

I am using the Omega theme and I know it is not the theme replacing my pager because if I switch to another theme, the same change is applied to the pager... Do you know where I can configure the pager display? Do I have to go to template.php? Thank you.


texts: How to reload page after ajax form submit

texts:
I'm using FAPI #ajax to make the form more user friendly (it reloads in-place on validation). Works like a charm. However I would like to reload the page after form is submitted. How to that?

Obviously if I call for example drupal_goto(current_path()) inside submit handler it won't do anything since this function is called via AJAX call. The actual page that user is on is not reloaded.

Is there some neat Drupal AJAX API trick that will allow whole page reload after AJAX form submit?


texts:
I am using the Bartik theme in Drupal 7.15 and would like to have the header logo centered rather than left-aligned, is there some little piece of CSS I can add in with drupal_add_css() that will center the logo image? I need it to center correctly based on the width of the header image, so fake centering just using left padding isn't an option.

Thanks in advance.


texts:
I want to do some tasks with ajax in drupal, in client side I passed data with

                jQuery.ajax({
                    url: '/rest/session/token',
                    method: 'GET',
                    success: function (token, status, xhr) {
                        var postData = {}
                        postData= {'name': 'user','pass': 'pass'};
                        jQuery.ajax({
                            url: "/mylogin",
                            method: "POST",
                            data: postData,
                            dataType: "json",
                            headers: {"Accept": "application/json", "X-CSRF-Token": token, "Content-Type": "application/json"},
                            success: function (data, status, xhr) {
                                console.log(data);
                            }
                        });
                    }
                });

and  ccording How to get $_POST parameters in my controller I try to catch posted data with

public function login(){
    //return new JsonResponse( \Drupal::request()->request->all()); // form param);
    return new JsonResponse( \Drupal::request()->request->get('name')); // form param);
}

I reutrn empty, ( JsonResponse work correctly, I test it with example data ).

what is the problem and why I can't get Posted data in my controller's method?


texts: Workflow and Organic Groups. How can you email the next state changer when content is posted?

texts:
I would like to notify someone with editor permissions that a user has posted content in the workflow.  I found a token for the current state updating user ([workflow-current-state-updating-user-mail]]), but nothing for the next user in line.

I've seen reference to using rules to send email to all users of a particular role, but I need something more like 'send email to users of a role who belong to the current group'.

Is this possible?


texts: Parsing XML files to populate form fields

texts:
I need conceptual clarification. I have fields of a form that I want to populate by letting a user use an XML file so my custom form module can parse and assign XML to form fields. I do not need to keep the XML file permanently.

First question: When using the file field widget on my form, after I select my file and the file name appears on the form, Drupal or the browser seem to have it stored in memory somewhere. It is possible to parse the XML file from this location in memory with a submit handler that populates the form? (So 2 submit handlers on the form, one to submit the XML to populate form and the other to submit the form to create node.)

Last question: Would this be easier if I have a form with a single file widget that uploads an XML file to a temp directory and builds + renders a form on the node after it has parsed the data?

Thanks all!


texts:
I've been trying to figure out this problem of allowing the user to dynamically create project request forms (add his own fields including drop downs, multiselects, etc...). The user needs a way to create multiple project request types (bundles, perhaps?), for different business units. I figured the entity / bundle relationship would be perfect for this. So here is my idea:

Use the Schema API to define my base table "project". Use the Entity API hook_entity_info() to tell Drupal about my new entity, pointing it to the "project" table. Now in this hook I can define bundles - which is great. But I need for the user to be able to create a bundle. Where is the entity_create_bundle($entity_type, $bundle) call?

Example:

Entity TYPE: Project (with common fields defined in DB, and it is fieldable)

Bundle: IT Project, HR Project - which share the common fields from Project

A project_type table will store additional grouping I need (project requests for business units).

Now I've been reading Drupal 7 Module Development which has been great, and in chapter 6 they define an entity "artwork" that has a couple of bundles, "sculpture" and "painting". The way they describe the steps, is as if they are building an admin interface to create additional artwork types, but this is not true (from what I can tell). After finishing the chapter, I can only create entities of type "painting" or "sculpture".

How can I allow users to create bundles of the "project" entity type?

Am I missing something or is the functionality not there [yet]?


texts:
How do I get the user Profile form?
I tried the following:

$form = \Drupal::formBuilder()->getForm(ProfileForm::class);

but this results in :

  Fatal error: Call to a member function getEntityTypeId() on null in
  /www/project/docroot/core/lib/Drupal/Core/Entity/EntityForm.php on line 77


texts: How to compute fields from different content types and then show the result in Views table

texts:
Is there a way to compute fields from different content types then display the result in Views table?

I will use those fields in a given formula.


texts:
I am building a Drupal 7 site, and using the Hybridauth module. On my site, users can register with Facebook and Twitter (through the Hybridauth module), or regularly through the registration form.

When I am using a view, and add the field "User: Name", if the user registered through Hybridauth, it will show the full name; if the user registered on the site, and entered the full name in two dedicated fields, the view will show only the first name.

How can I present always the full name in both the cases?


texts: How to use Drag & Drop dnd:removeFile event?

texts:
I'm using Drag & Drop module to let users upload an image in their profile (I'm using a custom profile tpl).

In that custom profile, I'm using in-place editable fields with AngularJS, so there isn't any form submit button (each field has it's own one).

That's why I need to save the uploaded image automatically in the user account, which I've achieved by using the "dnd:send:complete" javascript event.

Now I need to use "dnd:removeFile" event to remove image automatically from user account when the "Remove" button is clicked, but I can't get it to work.

I apply "dnd:send:complete" event to the Drag & Drop upload element itself, but... to which element do I have to apply "dnd:removeFile" (since when default image is shown, system is using the default managed_file system to remove the image).

I don't know if I'm misunderstanding upload element and I can hardly find any documentation about it.

P.D. Please, note that the problem is not removing the image itself, but removing it's relationship with the user account.


texts: Elysia cron Execution time vs Shutdown time

texts:
While looking to the Cron Status Tab, I can see this information above every cron channel :

Last run: 14/06/2013 - 02:00
Last execution time: 597s (Shutdown: 597s) (Avg total: 307.16s, Max total: 834s)
Execution count: 137

What does the Shutdown seconds stands for ?


texts: How do I get Rules to see my custom entity?

texts:
From what I've read in the past few days, Rules will gather all information it needs from hook_entity_info.  I still can't get my custom entity to appear in the data selector to make things work though.  Here is my implementation of hook_entity_info:

function badge_entity_info() {
  $info = array();

  $info['badge'] = array(
    'label' => t('Badge'),
    'base table' => 'badge',
    'class' => 'DrupalDefaultEntity',
    'controller class' => 'DrupalDefaultEntityController',
    'entity keys' => array(
      'id' => 'bid',
      'label' => 'name',
    ),
    'module' => 'badge',
    'access callback' => 'badge_access',
    'admin ui' => array(
      'path' => 'admin/structure/badge',
      'file' => 'badge.admin.inc',
    ),
    'uri callback' => 'badge_uri',
  );

  return $info;
}

Everything else is working perfectly, I just need to understand how to make Rules recognize my custom entity.


texts:
I noticed 3 issues with my site and I feel they are all related:

The context link is absent from admin/structures. When i type www.example.com/admin/structure/context, it redirects back to www.example.com/admin/structure.
Also Views is missing from the structure menu

Both the Context and Views U.I modules are enabled.

When I go to the /admin/reports/dblog page, the message and operations column are blank as in the image below.

The UI issues started after i re-enabled the modules. I previously disabled them on my site but now need to make some edits.

I have tried clearing cache a couple of times. I have also manually emptied the cache menu table in the Database.

I am logged in as User 1.

I would be grateful if anyone could point me in the right direction.

Thank you.


texts: How to get all records of a view with paging?

texts:
I have a view with 20 records, displaying 10 records on each page. I have a field check-box with custom handler to check and uncheck each record. I am using the $this->view->results to loop through all the records of view to check or uncheck on different events. This logic is working fine.
Now, I have added a new button to select all the records of view i.e. 20 records of both pages. Is there a way I get all the records of view with paging. In my case I want to get/select all the 20 records which are displayed on two pages. If I print $this->view->results, it has only 10 records which are displayed on page 1. Is there any view array element which have all 20 records?


texts:
So I have a view of a calendar with some events listed on it.  I also have this calendar setup to be a block on a page.

The block is on www.example.com/subsite

When I click the block it takes me to the month view of the calendar at
www.example.com/subsite/month

Now, on this view, there are tabs at the top of the calendar in the following order with their respective links:

Month - www.example.com/subsite/month
Month - www.example.com/subsite
Week - www.example.com/subsite/week
Day - www.example.com/subsite/day
Year - www.example.com/subsite/year

So... That second Month link is obviously wrong.  How do I get rid of it and/or change the title to Home?  If I make the Month view not show on the settings page, it removes the Month link that actually goes to the Month view.

Any help would be awesome, thank you.


texts:
I'm primarily a designer and I've been working on Drupal themes for some time now. At this point, I'm comfortable enough converting my designs to Drupal themes reasonably quickly but I continue to have doubts about how to use the template.php file... I've read up about it quite a bit, but my understanding of its usefulness is theoretical at best.

Clearly it's not a required file since it's never stopped my themes from working in the past, but is it advisable to have one in all cases? Are there functions (or anything else for that matter) one would automatically include in template.php?


texts:
I would like to use Views to create content for custom content type pages.  This seems to be consistent with the use of Views in the Admin pages of Drupal 8.  I'm running into problems integrating Views (the page content) with the page layout of the page.  This should be simple -- but it does not seem to be.  In all of this I would like to use the base features of Drupal 8 without custom or contributed modules.

The key functions that I am working to implement is being able to embed a View anywhere I would like in a page.  Said another away, I would like to embed several Views (page content) into specific portions of a complex page structure (page layout).

In Drupal 6 we have a content type and associated template file. Embedding a View in the template is straight-forward -- we use PHP code.
I tried creating Views as Blocks and placing them in different Block layout areas.  This became complicated quickly -- to much so.  The problem is the page layout must become part of the Views. There may be a solution involving the creation of custom Block layout regions and make the Views part of these new region.  The page design has several layers of content for mobile devices.  We would need Block layout regions for "Layer 1", "Layer 2" and "Layer 3" which are all part of the page Body.  I don't know if this will work.
I created a custom module that creates a Block for the page.  I can render whatever I want including layout elements and embedded Views content.  The problem is I am quickly generating a lot of custom code -- one of my goals is to avoid this.
I'm starting to look at Page Manager and Panels for a solution.  Bringing these modules into the design for a seemingly simple problem does not seem like the correct answer.
It seems there should be a simple way to embed a View into a Twig file associated with a content type.  This is where we started -- the Drupal 6 approach.  This simple solution has been difficult for me to achieve.

Any ideas?

The content we want to create has four parts. All four portions of content is a part of the "content" region of the page -- the top and three overlays. Here is a rough prototype: raystedman.org/d8/landing


texts: How to use expert class settings for display suite for images?

texts:
I've tried different combinations, but it's now working or showing up in chrome inspector...

I'm also using Bootstrap template, could that by a problem?

Or maybe I'm not filling out the information correctly in the field boxes?


texts: How do I use rules scheduler to disable and enable a commerce product entity based on certain date fields?

texts:
I have a commerce product type (entity not display node) with two date fields (enable_date and disable_date). What are the steps to create a rule/component and use rules scheduler to schedule these to disable and enable these products, based on the value of these two fields?

The use case is that I have an event node (product display) that needs to always be viewable but the attached registration (product entity) needs to be disabled on a specific day/time. i.e. Registration is now closed, but users can still see the event info, like location, map etc. Using rules scheduler I am sure I can do this. I have tried with mixed results but I am still learning the rules module. Any help would be appreciated.


texts: How to print the node body in a custom block?

texts:
I am trying to print the node body in a custom block, but it's not showing up. I'm I doing this correctly?

$refer = $_SERVER[HTTP_REFERER];
$parsed = parse_url($refer);
$alias = array_pop($parsed);
$dst = \Drupal::service('path.alias_manager')->getPathByAlias($alias , $langcode);
$nid = array_pop(explode('/', $dst));
$dest_node = node_load($nid);

$body = $dest_node->get('body')->getValue();
print $body; //have tried other printing methods also but invain

Thanks


texts: I have a node that people can flag to indicate their attendance/interest in that node's activity. However, I would like to show a list of users who have flagged a given node on that node's page. While I can find a way to show a user's current flag state or a flag count for that node in a view, I can't find a way to do this for the node representation itself.


texts:
I try to make link 'Mobile version' on site page site.com/page. This link leads to this page but on subdomain m.site.com/page.
I use page.tpl.php. I try to write this.

<a href="http://m.site.com/<?php print drupal_get_path_alias();?>">Mobile version

<?php print drupal_get_path_alias();?> prints nothing. What's wrong? Maybe there is some more elegant and right way to solve this?


texts: Using a node editing form on a page that not a node edit page

texts:
I have created a menu item, as reported below. I have taken the form ID from the page source (form id=listorious-list-power-100-node-form) but when I go to the specified URL, I get the following error:

  call_user_func_array() expects parameter 1 to be a valid callback, function 'node_form' not found or invalid function name in drupal_retrieve_form() (line 771 of /var/www/drm6/drm001/site/includes/form.inc).

The form is the standard node form found on node/add/listorious-list-power-100.

$items['admin/config/listorious/settings/add'] = array(
  'title' => 'add Listorious List item',
  'description' => 'Add list item information.',
  'page callback' => 'drupal_get_form',
  'page arguments' => array('listorious_list_power_100_node_form'),
  'access arguments' => array('administer site configuration'),
  'access callback' => TRUE,
  'type' => MENU_NORMAL_ITEM,
);


texts: Pass positional arguments to drush via drushrc.php?

texts:
drush allows you to pass default arguments in a drushrc.php-file like:

    $command_specific['command'] = array(
      'argument' => 'value',
      …
    );

This seems only to work for named options. Is there a way to also pass positional arguments via drushrc.php (like the installation-profile for drush site-install)?

I tried to use $command_specific['site-install'][0] = 'profile'; but that didn't work.


texts: How to make custom taxonomy pages per term based on fields?

texts:
I have a bunch of taxonomy terms, one for each county in a state.

I am going to use the taxonomy pages as landing pages in a Google Adwords campaign that is customized per county.

So, I have some boilerplate text that I want to use on all term pages, but I want to substitute the county name (which is the term name) and the biggest city in the county (which is input as a text field on the taxonomy term).

What's a quick way to do this in Drupal 8?  I tried to edit the Taxonomy Term view, but this is showing the content tagged by the term; in my case, there is no content tagged by the term. I want to use the term name and field data on the term to customize the boilerplate text.


texts: Callback on 'save' on 'new node form' doesn't fire

texts:
UPDATE:
Approach showed bellow has the same results -> doesn't work.

$new_form['#submit'][] = '_fmu_new_firm_under_user';

Separate button with only that callback doesn't work either. And what's weird, even if it has only the '_fmu_new_firm_under_user' callback it actually works the same way as 'save' button -> it saves the node and doesn't fire my callback.

$new_form['actions']['submit_and_create'] = array(
    '#type' => 'submit',
    '#value' => t('Vytvořit firmu'),
    '#submit' => array('_fmu_new_firm_under_user'),
  );

Original message

I've created a page with a 'myContentType_node_form' and attached a callback to the save button. The problem is that the callback is not fired when I press the button. To be more specific the default callback is fired - the node is saved - but my callback is not fired.

function _fmu_register_new_user_firm_callback($uid, $control_hash) { //a callback function for a menu item
      include_once(drupal_get_path('module', 'node') . '/node.pages.inc' );
      $new_form = node_add('fm_firm');
      $new_form['uid']['#value'][] = $uid;

      $new_form['actions']['preview']['#access'] = false;
      $new_form['actions']['submit']['#submit'][] = '_fmu_new_firm_under_user';

      dsm($new_form);
      return $new_form;
  }

function _fmu_new_firm_under_user($form, &$form_state) {

  $user = user_load($form['uid']['#value']);
  $user->fmu_users_firm[LANGUAGE_NONE][0]['target_id'] = $form->nid;
  user_save($user);

  dsm($user);
}

DSM of the form before returning it:

actions (Array, 16 elements)

    #type (String, 7 characters ) actions
    submit (Array, 23 elements)
        #type (String, 6 characters ) submit
        #access (Boolean) TRUE
        #value (String, 4 characters ) Save
        #weight (Integer) 5
        #submit (Array, 2 elements)
            0 (String, 16 characters ) node_form_submit | (Callback) node_form_submit();
            1 (String, 24 characters ) _fmu_new_firm_under_user | (Callback) _fmu_new_firm_under_user();
        #input (Boolean) TRUE
        #name (String, 2 characters ) op
        #button_type (String, 6 characters ) submit
        #executes_submit_callback (Boolean) TRUE
        #limit_validation_errors (Boolean) FALSE
        #process (Array, 1 element)
        #theme_wrappers (Array, 1 element)
        #defaults_loaded (Boolean) TRUE
        #tree (Boolean) FALSE
        #parents (Array, 1 element)
        #array_parents (Array, 2 elements)
        #processed (Boolean) TRUE
        #required (Boolean) FALSE
        #attributes (Array, 0 elements)
        #title_display (String, 6 characters ) before
        #id (String, 11 characters ) edit-submit
        #ajax_processed (Boolean) FALSE
        #sorted (Boolean) TRUE
    preview (Array, 23 elements)
    #theme_wrappers (Array, 1 element)
    #process (Array, 2 elements)
    #weight (Integer) 100
    #defaults_loaded (Boolean) TRUE
    #tree (Boolean) FALSE
    #parents (Array, 1 element)
    #array_parents (Array, 1 element)
    #processed (Boolean) TRUE
    #required (Boolean) FALSE
    #attributes (Array, 1 element)
    #title_display (String, 6 characters ) before
    #id (String, 12 characters ) edit-actions
    submit_and_create (Array, 3 elements)
        #type (String, 6 characters ) submit
        #value (String, 15 characters ) Vytvořit firmu
        #submit (Array, 1 element)
            0 (String, 24 characters ) _fmu_new_firm_under_user | (Callback) _fmu_new_firm_under_user();


texts: How to create a special autoincrement field?

texts:
I have a "Property" content type created for a real estate web site. The Property content type has a taxonomy field called "Type" where type can be House, Office, Apartment and so on...

I want to create a "code" field that has to be something like "H-1" where H is for Home and 1 must be an incremental number, so houses will have each a different code: "H-1", "H-2", "H-3" ... "H-188", etc. And so on for Offices "O-1", "O-2"..."O-479". I see that there is a Serial module, but that module helps me only creating autoincremental numbers for each content type, not based on other fields of that content type.

I was planning to use auto_nodetitle + serial module + rules to create the letter+number format for my field, but I will have the same problem: If I create "H-1" and then create an Office, it will have "O-2" code, and not "O-1" code.

Is there a module than can help me? If not, how can I make it?


texts: Is it possible to change the field type in a node form afterwards?

texts:
I have an instance here where an existing textfield in a node form should be limited to enter only three possible values. I though it might be possible to alter the field to #type => 'select' and attach my '#options' as well. So I altered the form to:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'MYCONTENTTYPE_node_form') {
    // dpm($form);
    $form['field_MYFIELD']['#type'] = 'select';
    $form['field_MYFIELD']['#title'] = 'Enter a value';
    $form['field_MYFIELD']['#options'] = array(
      1 => 'Value 1',
      2 => 'Value 2',
      3 => 'Value 3'
    );
  }
}

But when I now try to create a form like that, all I get is this error:

Fatal error: Cannot create references to/from string offsets nor overloaded objects in /Users/Shared/www/drupal.dev/includes/common.inc on line 6606

Is it even possible to change an existing field type like I want with a small custom module? Do I have to alter the submit function then as well? Please help!


texts: How to pass current selection to entity browser select view

texts:
I am using an Entity Browser (2.x-dev in Drupal 8) as form widget for a custom entity's entity reference base field. The entity browser is configured

as a modal display,
with single widget,
and no selection display,
using a view with entity browser bulk select field as widget, and
to append chosen entities to the current selection of the reference field.

Selecting the entities is working fine. But the entity reference field shall not have any duplicates.

In order to ease selecting of entities without duplicates, I'd like to filter already chosen entities from the entity browser view results. So users will see unselected entities only.

For this purpose, I created a custom views argument_default plugin that exposes the entity browser selection storage as context default argument for the entity ID:

<?php

namespace Drupal\my_module\Plugin\views\argument_default;

use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * The entity browser selection argument default handler.
 *
 * @ViewsArgumentDefault(
 *   id = "entity_browser_selection",
 *   title = @Translation("Entity Browser Selection")
 * )
 */
class EntityBrowserSelection extends ArgumentDefaultPluginBase {

  /**
   * The selection storage.
   *
   * @var \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface
   */
  protected $selectionStorage;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, KeyValueStoreExpirableInterface $selection_storage) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->selectionStorage = $selection_storage;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('entity_browser.selection_storage')
    );
  }

  /**
   * {@inheritdoc}
   */
  public function access() {
    return $this->view->getDisplay()->pluginId === 'entity_browser';
  }

  /**
   * {@inheritdoc}
   */
  public function getArgument() {
    $argument = NULL;
    $current_request = $this->view->getRequest();

    // Check if the widget context is available.
    if ($current_request->query->has('uuid')) {
      $uuid = $current_request->query->get('uuid');
      if ($storage = $this->selectionStorage->get($uuid)) {
        if (!empty($storage['selected_entities'])) {
          $argument = $storage['selected_entities'];
        }
      }
    }
    return $argument;
  }

}

The issue I face, is that the current selection within the selection storage is always empty, no matter how many entities have been selected at the entity reference field, and even after I complete the modal selection and open the entity browser again.

What do I have to do to have the current selection exposed in the entity browser's selection storage?


texts: One facet page (not solr) of users and block of rating based on count of entity referense fields (nodes) for each user

texts:
Drupal 7
for each user Example what i need:

I have views page with list of users (facet api (not solr)

Filter  1 = vendor (facet by taxonomy term)

Filter 2 = location (facet by taxonomy term)

Etc…

List of user

User 1 profile  : field vendor (term) | field location (term) | !  block of rating user 1 (count nodes (refense nodes by type) to current user (for example “complited project” which user made by vendor and location by current selected facet filters )

User2 profile : field vendor (term) | field location (term) | ! block of rating user 2 by current active filter

User3 profile : field vendor (term) | field location (term) | ! block of rating user 3 by current active filter

If I use page only with user list (without block of rating)  – it’s no problem but if I want use on the same page blocks with rating for each user - it’s big problem

For block of rating I tried to use field Global View field in which insert block with count of entity reference nodes (also tried use just value of reference field  (nodes) – it’s always show all value – not by active filter)

Solutions which I tried (not work as I want) for block of rating:

search api filter work only by unique field, situation looks like

Example  filter for vendors:

First indexed field for user: (field in search api index)

user -> user profile -> vendors

Second indexed field for nodes of current user (for count rating)

user-> user profile -> entity reference (node) -> vendor

in page list of user – if use only First filter (by user -> user profile -> vendors)  - > second indexed field (nodes) not work

it’s need two filter in same page (for first and second field – so I have duplicate of filter – but I need just one filter – by user profile -> vendor)

(may be exist way to insert  value from one filter to another and hide second filter but I don’t know how to do this)

I tried to use the same name of field (it’s not good for my project)

First indexed field (index of users)

User profile -> vendors

Second indexed field (index of nodes)

Node-> vendor

Now I can use one filter for user and block of rating in same time but -  if user has not vendor and in node of user have vendor  - > page empty  (because filter show term of user and node in same time – I need to show only terms of user -  not terms of nodes in filter to search by user)

I tried module Group for facet – but it’s not working
I tried to take tid from url in contextual filter  of block (usual block and facet block) (to get term of current selected facet filters value) – not work

Please help how to find solution?


texts:
I work on a  news site that has hundreds of articles and all the article urls are written by hand. eg. example.com/world-news-today-28-march-2018
The site has various news categories like: business, economy, technology, etc
but they are named taxonomy/term/1 and so on.
Is it too late now to activate pathauto module on a live production site that has tons of content?
All I want to do is change the urls of the news categories and make them more human friendly, so example.com/taxonomy/term/1 becomes example.com/business
without touching the article urls which are in each category.
Any ideas how can I do this and if it's safe at this stage?


texts: Template suggestions with page argument is not working - Drupal 7

texts:
I have created a page with name news, Page id is 25

Now I created a page in template with name page--node--25.tpl.php which is also working fine

I have created a view as a block with Contextual filters.  and assign that block to news page

I am passing argument as

news/1 . here 1 is for contextual filter.

Now when I am accessing example.com/news/1.

It is showing page not found.

Any idea?


texts: Showing different page layouts based on form data

texts:
I'm trying to build a multi step form. Before the second step I have to process the data inserted in step one and render different layout and form fields based on the results.

I use "drupal_get_form" callback in _menu hooks to display the form, but I think I have to use a different approach, because I can't find a way to specify a template and\or HTML code this way.

What can I do? Thanks!

MENU DECLARATION:

/**
 * Implementation of hook_menu().
 */
function clientform_menu() {
    $items['clientform/step1'] = array(
        'title' => "Estimate",
        'type' => MENU_CALLBACK,
        'access arguments' => array('access content'),
        'page callback' => 'drupal_get_form',
        'page arguments'=>array('clientform_step1'));

    return $items;
}

function clientform_step1($form, &$form_state){
    if(isset($form_state['values'])) {
        $currstep = $form_state['step'] + 1;
    }else {
        $currstep = 0;
    }

    $form_state['step'] = $currstep;
    $allsteps = getForm();
    $currform =  $allsteps[$currstep];

    return $currform;
}

function clientform_step1_submit($form, &$form_state){
    $form_state['storedvalues'][$form_state['step']] = $form_state['values'];
    if($form_state['step'] + 1 != getNumberOfSteps()) {
        $form_state['rebuild'] = TRUE;
    }else {

        //Reached end of multipage form

    }
}


texts: Drupal 7 - How do I disable media queries for selective pages?

texts: I have a custom theme and currently have media queries setup for my site and I want to disable media queries on certain pages on my site. How can this be done?