texts: How to convert a D7 db_query object to string?

texts:
I am trying to perform the following:

$office_ids = db_query('SELECT OFFICE_ID FROM sage.OFFICE');
foreach($office_ids as $office) {
  ...
  $path = 'office-' . (string)$office;
}

However, I am getting the following error:

Recoverable fatal error: Object of class stdClass could not be converted to string in main() (line 31 of /var/www/drupal7/create_nodes_office.php).

How can I cast an object returned by 'db_query' into a string?

Thanks.


texts: How can I let users rate content with half stars in Fivestar?

texts:
This is a quite regular feature request on the Drupal website (see for example this article), but there hasn't been provided a full answer anywhere and the answers only cover Drupal 6.

Instead of rating content with whole stars, I'd like my users to be able to vote with half stars (0.5, 1, 1.5, 2, etc.). On my website, voting on nodes happens via comments.

How can I achieve this? Which CSS and/or PHP changes do I eventually have to make to the Fivestar module?


texts: Programmatically enable another language

texts: I'm trying to programmatically enable/install another language? (Through install profile).. Any suggestions, please?


texts:
I want to add a language on my drupal 6 site but I want that Google doesn't index every page in this language (fr).

Can I use robots.txt and and add something like this?

Disallow: /fr/*


texts: Adding classes to individual list items in a site map

texts: I am using the Site Map module in my site but I need to style my list items individually. Is there a way to add a different class to each list item in the site map?


texts: Content created using field and content created using , and effect on website performance?

texts:
I am using the field collection module to create my Content. I have 10 text content. For ease of CSS class, I put each content in separate fields and apply the class using the field formatter module, So I have 10 fields and putting 10 text content in each one.
Now same thing I can achieve by just making

 10 times in body of CKEditor (just one field), For example,

Text content 1

Text content 2

Text content 3

.
.
.

Text content 10

Now, in terms of performance  will it affect the speed/loading of webpage of drupal 7 sites, if I go by 10 separate field or with one html code with 10 div? I am preferring 10 separate field method, because it is easy to handle editing and updating if needed.

Kind Note:   To Moderators, please do not categories this question as opinion based, because i do not have experience with in-terms of performance of website, so I need suggestion/Comparison between this two methods from more experience Drupal developers. Thanks


texts: Is there a way to import Paragraphs with Feeds module (no code)?

texts:
Given a Content Type (a Node), which has a Paragraph field, which in turn has some fields on it, is there a way to import the Paragraph fields into the Content Type using Feeds (or some other method, but not involving coding)?

Example:
The Content type Photograph includes a Paragraph field called 'Inscription' that has these fields:

field_inscription (text)
field_inscription_type (term reference)
field_inscription_location (term reference)

How do I import these three fields into the Paragraph field of a Photograph Content Type?

Note: There will be multiple instances of the Inscription field on some photographs.

I'm currently in Drupal 7, but would consider working in Drupal 8, if there's a solution that works in Drupal 8.


texts: How to specify a twig template for a custom Drupal 8 page?

texts:
I'm trying to create a custom Drupal 8 route with predefined content, like /about-us, which is not a node, just a standalone page.

The following tutorial is good only up to the point where I need to add the page content using #markup: https://www.drupal.org/node/2116767

How can I specify a twig template that I would like to use for page content?


texts: views exposed filter to have dropdown of entity reference in cutstom entity

texts:
I generated with drupal console utility my own module and content entity code. After I added a user entity reference field and a taxonomy term entity reference field.

Now I'm listing my content with views, I don't do nothing with the code generated the integration is done.

But, when I expose a filter by taxonomy field and user field it doesn't give me the option to show as a dropdown, it directly appears as a textfield.

In others views, listing nodes with entity reference fields, if I add exposed filter of entity reference  offers to me a dropdown or autocomplete widget.

What I have to change to my entity to have dropdown select for my entity reference field as exposed filter in a view?

Here is the field definition in the Entity class

    $fields['term_id'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('Log type'))
  ->setDescription(t('The term ID of the Log entry type.'))
  ->setRevisionable(FALSE)
  ->setSetting('target_type', 'taxonomy_term')
  ->setSetting('handler', 'default:taxonomy_term')
  ->setSetting('handler_settings',
    array(
      'target_bundles' => array(
        'logs_type' => 'logs_type'
    )))
  ->setTranslatable(FALSE)
  ->setDisplayOptions('view', array(
    'label' => 'inline',
    'type' => 'taxonomy_term',
    'weight' => -2,
  ))
  ->setDisplayOptions('form', array(
    'type' => 'entity_reference_autocomplete',
    'weight' => -2,
    'settings' => array(
      'match_operator' => 'CONTAINS',
      'size' => '60',
      'autocomplete_type' => 'tags',
      'placeholder' => '',
    ),
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

Update:

I achieve to have a dropdown in the exposed filter in my view creating the file mymodule.views.inc and puting this code:

function log_activity_views_data_alter(&$data) {
  $data['log']['term_log_tid_depth'] = array(
    'help' => t('Display content if it has the selected taxonomy terms, or children of the selected terms. Due to additional complexity, this has fewer options than the versions without depth.'),
    'real field' => 'term_id',
    'argument' => array(
      'title' => t('Log type (with depth)'),
      'id' => 'taxonomy_index_tid_depth',
      'accept depth modifier' => TRUE,
    ),
    'filter' => array(
      'title' => t('Has taxonomy terms (with depth)'),
      'id' => 'taxonomy_index_tid_depth',
    ),
  );
}

But when I choose a term to filter the view, it does not return any item and it should do so.


texts:
While trying to configure Drupal for Facebook, I followed the readme and copied their code into my settings.php and placed the facebook-php-sdk file into the stated location under sites/all/libraries but I still get this error:

  Failed to find the Facebook client libraries at sites/all/libraries/facebook-php-sdk/src/facebook.php. Read the README.txt and follow the instructions carefully.

I went to publichtml\sites\all\libraries\facebook-php-sdk-master\src and www\sites\all\libraries\facebook-php-sdk-master\src to check if facebook.php exists to be sure and it's there.


texts: Which is the best way to create an entity?

texts:
I would like to use entity concept in my next project.So , is it good to use Entity Construction kit for creating entities ?
How about Model Entities ?
Which is better ?


texts: Add preview button on Taxonomy add/edit term form

texts:
As we know that entity type node has preview button option which can be used during adding or editing of a node, to preview content.

Same feature is missing in case of Taxonomy entity.

If I want to add this feature where should I look into or is there any module available to achieve this?


texts: How can I hide a nodereference url link for users who have already created a node

texts:
I am working on a job listing site and wants users to be able to apply for jobs on the site.
I created 2 content types "Job posting" and "Job Application".

I used the nodereference_url module to add an apply now link on the job posting node that directs the user to the "job Application" form.
This works fine but i would like to make each user to be able to apply for a particular job only once.

Is there a way i can achieve this with my current setup? Is there a different way to go about this that will give me the desired result?

Thank you for the help


texts: Change default date format in input mask: Is it possible?

texts:
I adapted the default date formats to the German needs, and I created a new date format for output. This works fine.

For the input, the Y-m-d format persists. How do I change this?
I've created a content type: "events".
I defined a field type of DATE:

In the manage form display I've set its witget to "Date and Time. There's no wheel to define dmY or other.

The result in input mask:

The only thing that works at the moment, is the widget switching to "date as a list" to get german notation.


texts: D8 - Can 2 Entities share the same name?

texts:
I have written a module that has an entity type of name "redirect.php".
So the object is actually called redirect.

As far as I know there is a module called like that. There are also entities with this exact name. The DB base field has a longer name that will not create issues.

Is Drupal smart enough to look at the namespace or will two classes / objects with the same name create issues?

Thanks


texts: how can i get Drupal webform confirmation message on popup?

texts:
I have been surfing for a solution since yesterday, got hell lot of irrelevant solution.
My requirement is very simple,

  I just want to get the conformation message(Thank you, your submission has been received.) in a popup window.

tried several modules not satisfied. Friends please help me out, its urgent for me.


texts: How do I effect the page that a menu item redirects to?

texts:
I am trying to do something that seems simple, but I have yet to have to do it with my development because I have always dealt with forms and views.

On the page that I get redirected to when I click on a menu item, I want to have a page with a href on it.

So for example, I have created a menu item as follows:

$items['admin/vendor/auth-stripe'] = array(
        'title' => 'Authenticate Stripe Account',
        'description' => 'In order to receive payments, you must authenticate your Stripe Account.',
        //'page callback' => '_bh_vendor_auth_stripe',
        'access arguments' => array('vendor administration'),
        'type' => MENU_NORMAL_ITEM,
);

When I click on this menu item, I am taken to a page.  I want to add items to this page.  Namely an href link.

Do I need to create a block that only shows up on this page?  If so, how do I add a link on the page.  I know how to create a block programmatically using hook_block_info, but I am not exactly clear on putting content in this block programmatically.


texts: Is this the proper way to add a 'class' attribute to a form date element

texts:
$form['stop_date'] = array(
  '#type' => 'date',
  '#title' => t('Stop Date'),
  '#default_value' => date("Y-m-d"), // default to today
  '#id' => 'stop_date',
  '#attributes' => array('class' => array('dateSel-Fld')),
  '#required' => true,
);

When using the #attribute property the form is not being rendered successfully.


texts: How to theme maintenance page for omega subtheme?

texts:
Drupal's "Theming the Drupal maintenance page" gives a good overview for theming the maintenance page for 'normal' themes:

Copy modules/system/maintenance-page.tpl.php to your theme's templates directory
In the settings.php file, enable the $conf['maintenance_theme'] variable
Copy you page.tpl.php contents into maintenance-page.tpl.php and edit as necessary

But my site uses an Omega subtheme, so I don't have a page.tpl.php (well, it's not quite the same as these instructions are anticipating).  I'm a little lost among all the omega templates & regions.

How do I theme my omega subtheme's maintence page to look like the rest of my site?


texts: Is there a drush command to set permissions to true on ALL modules for administrator?

texts:
I'm getting tired of having to go in the backend and click on some new module's permissions so that I can use them...

Is there a drush command to enable permissions to true on ALL modules in on shot?

This happens on some modules and also when creating content types or using beans or new panels.


texts: Hierarchical Select and Panels modules: Any conflict?

texts: I developed a content type having a field using "Hierarchical Select" module widget. I then developed its page using "Panels". Now "Hierarchical Select" loads the first dropdown list e.g. "Car Make" but not loading the subsequent dropbox of "Car Models". Any bug, or conflict between "Hierarchical Select" and "Panels" module??? Or I need to do any extra configuration. Plz help...


texts: Add multiple friends at once with user relationships

texts:
I am using the  User Relationships module and I created a table in Views with all of the site users.

There is a field where you can add or remove a friend. But (especially the first time) the users must be able to add multiple friends add once.
For example with check boxes and a "send friend request" on the bottom of the page.

I have tried to accomplish that with Views Bulk Operations but there is not a integration with that module.
What can I do?


texts: Can I call drupal_goto in form #submit handler?

texts:
I've a node type Person and want to attach a new submit handler.
Will it be fine if I call drupal_goto to another URL from within this new submit handler?

What I want to do is to ask for some confirmation message and then save the node using drupal_execute.

In the submit handler I'll save $form_values in session using key form #build_id
and then in it I'll redirect it to another url with this build_it in the url as GET parameter. In the redirected form url I'll be doing some checks on the node data( if same title node already present etc) and asking for confirmation. If yes then I'll create/save the node myself using drupal_execute.

Will it work this way?


texts:
I'm constructing a view and i need the column "edit link" to be possible to sort (put empty fields first or last). Has anyone ever done it before ?

Thank you all


texts: Will groups with more number of users cause the page to load slower?

texts:
Anonymous page takes 1 to 2 secs to load
After the successful login, we are showing the same page but with some menu. I have disabled that menus too. But the page load takes 10 secs to load with same content.
We have groups. To check,have disabled the groups assigned to the user, then the page loads faster 1 to 2 sec. At first we though that, assigning groups might cause the issue. But the scenario is like, if I add single group which have more content(700) and  users like (1500) cause the issue.Except dat grp,if I add more  groups to the user,the page loads faster.
After disabling organic subgroups, and adding that single group causes the page to load faster.
Can you share your thoughts?


texts: unblock ip address after failed login attempts?

texts:
I have a custom login page that I'm testing the javascript on. The events I'm testing happen after a failed login.

After running a couple tests, I've managed to get my ip blocked because of numerous failed logins!

I have access to the database. How can I unblock my ip so I can continue to test my features without interruption?


texts: Static field works, dynamically modified element gets lost

texts:
I'm new to Drupal forms - trying to figure out a maddening problem.

I have a content type of 'doc-upload' with various fields including 'publisher_code'.

When I define the 'publisher_code' field type to 'text', and go through my upload process, yada yada yada, the value appears in my $node structure later as expected.

When I change 'publisher_code' to "field type: List (text), widget: Select list", and I try to dynamically populate that element with:

function mymodule_form_doc_upload_node_form_alter(&$form, &$form_state) {

  $publishers = array( 'pub1' => 'Publisher 1', 'pub2' => 'Publisher 2' );

  $form['field_publisher_code'] = array(
    '#title' => t('Select a publisher'),
    '#type' => 'select',
    '#options' => $publishers,
    '#multiple' => FALSE,
    '#empty_value' => '',
    '#empty_option' => '- None -',
    '#required' => TRUE
  );
}

The form displays properly, but when the form is submitted, the 'field_publisher_code' doesn't come out the other side - presumably it's getting filtered/invalidated somewhere, but I can't seem to find where?


texts:
I'm receiving the following error message in my log

Notice: Undefined index: und in include()(line 56 of /sites/all/themes/mysite/node--recipe.tpl.php).

Here is the line off code

$node->field_recipe_skill_audio[$node->language][0]['filename']

This error message is well documented  but i've been unable to get the fixes working. I have try the following request.

$node->field_recipe_skill_audio['en'][0]['filename']
$node->field_recipe_skill_audio['und'][0]['filename']


texts:
is there anyway to customize checkout form and add this to form? Will be helpful! :)

<form data-count="$orders">


texts:
I want to collect user personal information like first name, last name, and home address in in user registration, and I also want user to make the profile pubic or private.

I am using Drupal 7.


texts: View author field (image) in a node view

texts: I have created a image field in the user account. How can I add the image of the author to the display of each node?


texts: Performance and optimisation when using panels with views and content pane

texts:
I would like to know if there is a best practice when we use panels with views and content pane?

Some explanation:
I have a layout with multiple blocks (related to the taxonomy etc.) and a main content.

I'm asking myself what is the best way to have the better result in term of performance: I made many content pane for my views (as many as there are blocks, see my picture for a better understanding)

But i don't know if it's very good to do that.

I would like to know if it's not better to do just one content pane and to check or uncheck the fields that i want in each block.

My site i slow so i try to optimize it. I don't know how panels works "behind the scene".

Thanks


texts:
I have a field on a content type which is an optional override for another field. I want the value to only be either 0, 1, or empty, the last meaning "no override". What field type should I use for this? I was looking at a select list for a good user experience, but I was unable to get empty as a value in the list.

I also need another field that can only have values "img", "txt" or "". How should I accomplish this? I want to avoid having users type in "img" or "txt" in case they misspell it.


texts:
I try to load a node at a view using the node_load() function which takes an integer argument. I take the node id by $nid=$fields['nid']->content; and I try to load the node by calling node_load($nid) but it fails. After experimenting i figured out that $nid is String instead of integer so I try to cast to an int but it returns me 0. Can anybody help me?

$nid=$fields['nid']->content;

print gettype($nid);

print $nid;
print intval($nid);
print (int) $nid;

Output:

string 3 0 0

I am within a view and I want to load many node as is to put them in a bootstrap tab where it when you click the node name the node will be shown above it.


texts:
I'm building some modal pages using the use-ajax class plus the data-dialog-type="modal" attribute on link tags. It worked great as an admin user, but logging in as a different role(call it parent) and the links go directly to the pages.

It's pretty obvious from the sources panel in web inspector that the parent role isn't being served the necessary javascript (dialog.jquery-ui.js, dialog.js, dialog.position.js, etc).

There's nothing in the permissions that looks like it would limit the javascript added to the page.

I've tried this in my custom theme and in bartik, same result.


texts: Creating config schema file for mutable data

texts:
I have a custom module where I need to have a couple different types of configuration, both immutable and mutable. The immutable portion contains a feed URL for a couple different sites, so I have /my_module/config/install/my_module.settings.yml set up like this:

sites:
  site1:
    channel_url: 'http://www.site1.org/feed/channels'
  site2:
    channel_url: 'http://www.site2.com/feed/channels'
list_time: 24

That works fine, and I can read from it via $config-get();.

The second part of my settings involves mapping of tids between the two sites (used for importing video nodes from one site to another. My initial thought was to modify the settings like so:

sites:
  site1:
    channel_url: 'http://www.site1.org/feed/channels'
    mappings:
      1: 1
      2: 2
      3: 3
  site2:
    channel_url: 'http://www.site2.com/feed/channels'
    mappings:
      7: 7
      8: 8
      9: 9
list_time: 24

However, since this is mutable, it appears that this isn't allowed (based on the error messages I get when I try to run $config->set().

From what I'm finding, it looks like I need to have a separate schema config file for my mapping data. I'm still wading through docs, but if someone could verify if I'm correct in my thinking and maybe provide a sample of what my schema should look like, I'd appreciate it.

UPDATE: Reading through this change record, it appears that I can write to my settings file if I declare it in my form class in getEditableConfigNames(), which I've done:

protected function getEditableConfigNames() {
  return ['my_module.settings'];
}

It also appears that, according to the error message I get, I need to retrieve it with \Drupal\Core\Config\ConfigFactoryInterface::getEditable()

Drupal\Core\Config\ImmutableConfigException: Can not set values on immutable configuration my_module.settings:sites. Use \Drupal\Core\Config\ConfigFactoryInterface::getEditable() to retrieve a mutable configuration object in Drupal\Core\Config\ImmutableConfig->set() (line 27 of core/lib/Drupal/Core/Config/ImmutableConfig.php).

Just keep swimming....

UPDATE2: Base on @berdir's comment below, I'm showing what I have, since in my original question, I didn't state that I am already using the ConfigFormBase class:

class MyModuleAdminForm extends ConfigFormBase {

  /**
   * {@inheritdoc}.
   */
  public function getFormId() {
    return 'my_module_settings';
  }

  /**
   * {@inheritdoc}
   */
  public function buildform(array $form, FormStateInterface $form_state) {
    $form = array();
    $channels = array();

    // build form here

    return parent::buildForm($form, $form_state);
  }

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

  }

  protected function getEditableConfigNames() {
    return ['my_module.settings'];
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $values = $form_state->getValues();
    $config = $this->config('my_module:settings');

    foreach($values as $site => $mappings) {
      if (is_array($mappings)) {
        foreach ($mappings as $source_channel => $target_channel) {
          $config->set('sites',[$site => ['mappings' => [$source_channel => $target_channel]]]);
        }
      }
    }
     $config->save();

    parent::submitForm($form, $form_state);
  }
}

However, this still gives me the same error. Am I using $this->config() incorrectly? Or do I still need to use getEditable() somewhere?


texts: Dropping host part of the url when loading resources

texts:
I have a particular problem with the site here. It's a b2b site and it has a word 'advertise' in the domain name. When Drupal loads resources (css/js) it refers to the full url, including that domain name. And those resources are getting blocked by AdBlock on Chrome so as a result site is broken.

Is there a way to refer to css/js locations as local urls (without the host part)?


texts: finding a route to form mode and add it local tasks

texts:
I have a content type named "film" and a form mode named "film_artistic"

in my_module.routing.yml, I have added this entry:

my_module.film.artistic:
  path: 'node/{node}/artistic/edit'
  defauts:
    _entity_form: node.film_artistic
    _title: 'Edit artistic info'
  requirements:
    _permission: 'access content'

But when I try to reach, let say "/node/6/artistic/edit" I got a "Page not found" result

I don't know what I am missing...

My ultimate goal is to have several form mode for my film content type (ex: Artistic, Technical,...) and for each of them, I would like to create a "Local Task" sharing the same base_route: "entity.node.edit_form".
For my first local task, I have to add the following in my_module.links.task.yml:

film.artist:
  route_name: my_module.film.artistic
  title: Edit artistic info
  base_route: entity.node.edit_form
  weight: 20

But of course I can't test it as my main route is not working (node/{node}/artistic/edit)


texts:
The module filter makes managing modules from the UI very easy to manage. Live update with the search query and grouping. I've been looking for a similar module for the more messy permissions table. A similar module would definitely make it easier to manage that monstrous table :D

Does anybody know if a module exists for this?

I did try searching but I might not have used the right terms just like when I searched for user spoof and it resulted to a module named Masquerade.


texts: Why am i getting PDO exception while running the following test from console?

texts:
I am writing a module to return common parent of 2 revision in a linear entity. For example : After editing a node 5 times, we get a graph similar to 1->2->3->4->5 where 1 is the actual node and 5 is the last revision. I wrote a function which would return the common parent of 2 revision ID. It would return 3 for (4,5) and 2 for (3,4). The code is the following one.
namespace Drupal\conflict;

use Drupal\conflict\ConflictManagerInterface;
use Drupal\conflict\ConflictAncestorResolverInterface;

class ConflictManager implements ConflictManagerInterface {

    protected $resolvers = [];

    public function applies() {
        return TRUE;
    }

    public function addAncestorResolver(ConflictAncestorResolverInterface $resolver)
    {
        $this->resolvers[] = $resolver;
    }

    public function resolveLowestCommonAncestor($revision1, $revision2)
    {
        foreach ($this->resolvers as $resolver) {
            if ($resolver->applies()) {
                return $resolver->resolve($revision1, $revision2);
            }
        }
        echo "No revision found";
        return -1;
    }

    public function resolve($revision1, $revision2) {
        if ($revision1 < $revision2) {
            return $revision1-1;
        }
        return $revision2-1;
    }
}

To test the above written code, I have written a test case:
namespace Drupal\conflict\Tests;

use Drupal\Tests\UnitTestCase;
use Drupal\Core\Entity\Entity;
use Drupal\conflict;

class SimpleLcaTest extends UnitTestCase {

    public function basicTest() {
        $entity = EntityTest::create(['label' => 'revision 1']);
        $entity->save();
        $entity->label = 'revision 2';
        $entity->save();
        $entity->label = 'revision 3';
        $entity->save();

        $revision2 = entity_revision_load('entity_test', 2);
        $revision3 = entity_revision_load('entity_test', 3);

        $manager = Drupal::service('conflict.manager');
        $revisionLca = $manager->resolveLowestCommonAncestor($revision2, $revision3);
        $this->assertTrue($revisionLca->label() == 'revision 1');
     }
}

When I try to run test via console using run-test.sh, I get the following error:

Exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'file' cannot be null


texts: Obtain the total (count) of the contents associated with a nested taxonomy (only in the parent taxonomy)

texts:
It is possible to count the contents associated with a nested taxonomy in Drupal 8 views, but the difference of this is that the taxonomies are of two levels.

For example:

I have these taxonomies:

Now, I have three created contents in which I associated the terms of the taxonomy, I stay like this:

I need something like this:

What I need to get in the view is, the total post associated with the parent taxonomy.

For example, I would like to see something like:

Backend: 2

Frontend: 1

What I have tried so far only shows me the totals independently(using aggregation), for example:

Backend - Post One - Total: 1

Ruby- Post One - Total: 1

Backend - Post Two- Total: 1

Python- Post Two- Total: 1

Frontend- Post Other- Total: 1

Is it possible to do this in Drupal 8 views?


texts: Custom installation profile with standard content

texts:
For a school project I'm trying to use a custom installation profile to pre-install a couple of modules such as Drupal Commerce.

The problem I'm running into is the fact that although my installation extends the standard installation it doesn't seem to install things like the standard content types, frontpage, etc.

I can't seem to find anything about this by googling or reading the official documentation, so I think I'm just missing something super obvious.

Note: I used Drupal Console to generate a profile to which I added all the needed modules and themes. And in the .install file I use code to set Bartik and Seven as the themes for the page and admin respectively. So what I'm missing might be the things in the config files?


texts: Schedule a rule to repeat every week at specific time not working

texts:
I am sooo close to getting this to work, but cannot figure out why I cannot get my rule to repeat. It's driving me nuts.

I created a component that has an action item to generate send a newsletter using the simplenews module. It works just fine when I execute it manually, but I need this to repeat weekly.

I've read a ton about having it repeat by using the action "Schedule component evaluation" and this makes total sense, but it just isn't firing after the initial rule. Right now I am testing it with +2 minutes so that I can see if it works or not. Eventually I want to have it be +1 week. But if it's not working with 2 minutes it won't work with 1 week.

EDIT: Right now I am running cron manually to check to see if it's working and it's just not.


texts:
I'm using Search API and Fuzzysearch in D7, and it's unable to search for three letter words. Unfortunately, we have a TON of 3-letter acronyms at work, so these need to be searchable. I've looked in the Search API and Fuzzysearch settings, but can't see where to change the length of the search keys.

I get the following error message when searching:

  The following search keys are too short or too common and were
  therefore ignored: "api".


texts: How to render field of one type of node to another type node

texts:
I have two types of nodes: metals and prices.

Metals has two fields:

field_gold

and

field_silver

How to render this fields on node--prices.html.twig (not node--metals.html.twig)

Please, help me!


texts: How to comment out yml file for docker4drupal to install Drupal 7 on Windows 10 64bit

texts:
I followed all instructions and got the code for yml file here:

https://github.com/wodby/docker4drupal/blob/master/docker-compose.yml#L4

I commented out line 33:

image: wodby/drupal:7-5.6-3.3.2

Then I tried to install on:

  http://drupal.docker.localhost:8000/core/install.php

Then I got this errors:

  Parse error: syntax error, unexpected ':', expecting ';' or '{' in /var/www/html/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php on line 50

Drupal 8 install works fine, but I need this for Drupal 7 what am I doing wrong?

And are there any other yml files I can use that has D7, php and Sql all ready to go  in a consolidated container like the wodby docker4drupal?


texts:
I am using Display Suite and have followed the instructions below exactly:

Enable the sub module Display Suite Extras at Administration >
Modules (admin/modules) Go to Administration > Structure > Display
Suite and click the secondary tab "Extras"
(admin/structure/ds/extras)
Select the vertical tab "Others"
Check "Region to block"
Click "Save configuration"
Go to Administration > Structure > Display Suite
(admin/structure/ds/layout) and choose "manage display” for the
desired content type (e.g., "Article").
Select a custom view mode (e.g., "Compact teaser")
Ensure a layout is selected in the vertical tab "Layout for … in ..."
Click "Save"
Choose the vertical tab "Block regions"
Enter a name for the region that will be rendered as a block
Click "Save"
The region is now available in the manage display screen and you can
assign fields to it.
The block is now available via Administration > Structure > Blocks (admin/structure/ds/blocks) where you can enable it.

I am able to enable the block, however, I can only enter the title and none of the fields I placed in the new region I created can be configured. Has anyone else tried this approach to adding fields to a block?


texts: Drupal automatically create hardcoded links and do such links impact performance?

texts:
I have a site which is being developed in Drupal. My developer was developing in the live site directly. No one knew of our existence, so we didn't bother.

I had to change developers midway through the project. When the new developer wanted to develop locally, he had a lot of issues: links not functioning etc. We have found around 25,000 instances of the original site URL.

So what he did was to find and replace all 25,000 URLs with the local site URL in the database itself. Now everything worked fine.

Once the site was perfect locally we moved to live site again by replacing all URLs back to the original URL.

When I checked with my original developer why he had hardcoded, he mentioned that as we wrote a lot of custom code, Drupal automatically created these links. Is this possible?

Will this affect performance or have any long term issues?


texts: How do I debug with Xdebug in Visual Studio Code?

texts:
When I try to debug Drupal 8 (8.6.11) using Xdebug in VS Code (I'm on Win 10 but I doubt it is relevant in this case) I get the following error:

  Exception has occurred. Dotenv\Exception\InvalidPathException: Unable
  to read the environment file at /app/.env.

The problem is either with VS Code or with Drupal as someone has reported exact same behaviour on High Sierra and they were using Drupal 8.6.10:
https://github.com/lando/lando/issues/1501

I did not find anything in drupal docs about the neccessity of creating a .env file to use Xdebug, so I suspect a bug eihter in Drupal 8 or VS Code.

Has someone encountered similar behaviour?
Should I file a bug report on Drupal site?


texts:
Here is my source:

function sc_delete_user_confirm_form_submit($form, &$form_state) {
   //...
      $batch = array(
        'operations' => array(),
        'finished' => 'user_delete_tickets_batch_finished',
        'title' => t('Processing delete user tickets'),
        'init_message' => t('Deleting user tickets is starting.'),
        'progress_message' => t('Processing...'),
        'error_message' => t('Deleting user tickets has encountered an error.'),
      );
      $batch['operations'][] = array('user_delete_tickets_batch_process', array());
      batch_set($batch);
  //...
}

function user_delete_tickets_batch_process(&$context) {
  watchdog('my_module', 'user_delete_tickets_batch_process ENTER!', array(),  WATCHDOG_ERROR);
  //...
}

function user_delete_tickets_batch_finished($success, $results, $operations) {
  watchdog(my_module', 'user_delete_tickets_batch_finished ENTER!', array(), WATCHDOG_ERROR);
  //...
}

I see progress bar but it not call my callback method user_delete_tickets_batch_process (I didn't see log in /admin/reports/dblog), also it not call user_delete_tickets_batch_finished.
What is wrong in this my source.


texts: How to check if field in Field Collection is required?

texts:
I'm running into a problem of programmatically checking fields in a field collection.

What I want to do is loop through all fields within a field collection and check which ones are required.

I've tried these codes so far but haven't got any positive results.

$collections = field_collection_item_load_multiple($collection_ids);
foreach ($collections as $collection) {
   foreach($collection as $key => $va) {
        if (strpos ($key, 'field') !== false) {
            if (isset($va['und']) && is_array($va ['und']) && isset($va['und'][0]['value'])) {
                print "Field ".$key." ".$va['und'][0]['value'];
            }
        }
    }
}

This shows me the data and the label of the fields, not really their properties.

Thank you for your help.


texts: Is it possible to let a user change value of a single field in their account profile without going to the user edit page?

texts:
On my site, users have several single-value boolean checkboxes as part of their profiles.

In various places on the site, I want to let users toggle one of these fields on or off without going to the user edit page.

I'm using Panels, so I'd like to somehow embed a way to edit just the value of a single field into a given page/panel.

What I tried:

Use the Field Permissions module to block access to the field.
Create a flag with the Flag module.
Let users flag or unflag themselves.
Make rules with the Rules module to set the value of the field based on the user flag.

This works, but it's very cumbersome to set up and tricky to maintain.  It also prevents users from editing the value on the user edit page; they have to use the flag instead.  So I'm wondering if there is a more straightforward way to do what I want.

This is similar to my question from a couple years ago, but that question is about modifying the user account page.


texts: How can I manually send order details email to customer in Ubercart?

texts:
I have a cron job to read orders from the Ubercart database table, and manually send the order email to the customer.

Usually, when customers checkout in Ubercart, they will get their order email straight away. But in my situation we don't want to automatically send the order to customer because we have some process that needs to be completed before we programmatically send the order email to customers.

How can I manually send the customer's order email in Ubercart?


texts: Relation: add button to create node related to current node

texts:
I have 2 Content types called Schools and School News and i want to add a add News Button to those School pages, so editors can create a new post for this specific school. I thought about using relation module as i am using it already for other things.

Would it be possible to create such a button that adds a hidden field with the ID of the specific school into the news form? That way i could add this relation while saving the node. Is there any other way to get this kind of functionality with relation?


texts: Upgrading from 7.22 to 7.28, htaccess file in /tmp

texts:
I get this error :

My .htaccess file in that directory looks like this now (I copied it from the url):

# Turn off all options we don't need.
Deny All
Options None
Options +FollowSymLinks

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
  php_flag engine off
</IfModule>

I still get said error. Why?


texts: I've installed Omega 4 but drush cannot find the omega help set or the omega command set -- nor can I. Where are these supposed to be located? Without them, I cannot easily create a subtheme with drush, or do any of the drush goodies in omega 4.


texts:
Using Drupal (v7.22) I'm creating a site that lists different cars. The editor of the site wants to be able to add different stats to the cars. But they don't know exactly which stats they will need so want the ability to add stat themselves. So for example they can set up two different stats where they fill in values:

Content
  Content Type (Stat)
  Title = Stat A
  Default Value = 10
  Min Value = 0
  Max Value = 50

Content
  Content Type (Stat)
  Title = Stat B
  Default Value = 20
  Min Value = 0
  Max Value = 40

Then they can add those stats to a new Content Type that they have created. When they add a type of Stat it will include the Default Value but it can be changed:

Content Type
  Title = Car
  Stat A Value = 10
  Stat B Value = 20

Content Type
  Title = Lorry
  Stat B Value = 30

Finally they can create Content of that Content Type and the Stats will use the value for that Stat by default but they can change it. I will create rules so that the entered values must be within the min/max set by the Stat.

Content
  Content Type = Car
  Title = Car Name
  Stat A Value = 15
  Stat B Value = 18

Can this be done with Drupal?


texts: How to use number fields for drupal commerce attributes

texts:
I am using Drupal 7 with Drupal Commerce (not kickstart).  My products are boxes setup in Series varying by height.

Examples:
Series 500 has 3 boxes
box 1 has dimensions of 120x20x10
box 2 has 120x20x20
box 3 has 120x20x30

Everything else about the boxes are the same, so "height" is my product attribute.  Drupal Commerce attributes by default need to be an options_select field, but I have over 1000 products of varying heights and I really didn't want to have to build and maintain a gigantic array of heights down to a thousandth of a inch (whether in the gui or in code).

My original thoughts were to build a module that has a sql table to store product heights.  Then add two fields to the product, a decimal and an options field and hide the options field.  When the user enters a decimal in the height field on the product page, on save the module will check to see if the value exists and if not insert the value into the sql table.  The options field will be setup to use an allowed values function to query the sql table to build the "heights" array so again on save after the module stores the decimal in the sql table, it will then set the value in the options field keeping the two in sync.

This would allow me to have an options field I don't have to maintain, but seemed a little hacky so wondered if there was anyone else out there that found better way (as I have googled and had no luck).

Thanks!


texts: How can I ensure that our RSS feed contains all changed nodes?

texts:
I am far from an expert in this area so excuse me if I do not use the correct terminology.
I want to create an RSS feed containing nodes that do not get updated directly. They use D3.js javascript scripts that references files which are used to create the charts. I update the files daily by uploading them to the host. I store the new file names in blocks which are included in the relevant nodes.
Is this possible? Do I need to update the Updated date and if so is there a way to do this without editing each node?


texts: how to hide the adminblog link in the teaser

texts:
how to remove admin`s blog in footer of teasers i can remove the add comment link with this code :

function  mytheme_node_view_alter(&$build){
if ($build['#view_mode'] == 'teaser')
{
    // remove "add comment" link from node teaser mode display
    unset($build['links']['comment']['#links']['comment-add']);

    // and if logged out this will cause another list item to appear, so let's get rid of that
    unset($build['links']['comment']['#links']['comment_forbidden']);
}

but i cant remove admins blog what can i do ?!


texts: How to remove empty option from select Drupal 8 forms

texts:
How to remove empty option from the select list in drupal forms.

$form['property'] = [
    '#type'          => 'select',
    '#id'            => 'property',
    '#attributes'    => ['class' => ['form-control']],
    '#title'         => $this->t('Hotel'),
    '#options'       => $properties,
    '#empty_option'  => t('Select Category'),
    '#required'      => TRUE,
    '#validated' => True,
];

I have removed the line '#empty_option'  => t('Select Category') from the code but in the front end it shows blank for the first option. I need to select the first element of the $properties array to be selected as default.


texts:
I'm making my first steps into Panels (yeah, shame on me I waited so long)... I immediately ran into a problem with the column-resize widget which did not want to obey. So I thought maybe there i a programmatic workaround for my need.

What I need is a 5-row layout:

1: 1 column
2: 3 equal columns
3: 1 column
4: 2 columns (2:1 ratio)
5: 1 column

How do I add a custom layout (with own icon, name and php template) so that Panels recognizes it?


texts: Migrate user-data from a non-drupal site

texts:
I have to migrate 9000 users (name, address, email, tel, photo...) from a non-drupal-site into a new drupal7-site.

How can I programmatically mimic the registration process and push the data in corresponding fields? And is there a way to change the original password, stored as a MD5-hash, to the drupal7-format while processing the data?

Thanks!


texts: How to create dynamic multi column forms using native form module?

texts:
I am looking to find out how I can create a form which the definition of the form is coming from a REST API as a JSON object. The form can be 1 column, 2 columns or 10 columns.

I have been able to do this by just using the native table theming option, but I want to be able to do this with the native form options so that I can utilize all the validations and everything else etc.

Does anyone have an idea as to how I can accomplish a multi-column dynamic form?

Thanks in advance!


texts: How to set the value of a field "reference to a term" with the use of entity_metadata_wrapper?

texts:
In a content type with a have taxonomy field "reference to a term" which I want to connect to a webform submission.

I have the following code in rules:

$brancheid = $submissions[$sid]->data[1][0];
$oplossingsid = $submissions[$sid]->data[2][0];
$nodeid = $submissions[$sid]->data[3][0];

$node = node_load($nodeid);
$node_wrapper = entity_metadata_wrapper('node', $node);
$node_wrapper->title->set('done');   // this is working
$node_wrapper->save();
$node_wrapper->field_sector->set($brancheid);
$node_wrapper->field_dienst->set($oplossingsid);
$node_wrapper->save();

After submission of the webform the title is saved. But field_sector and field_dienst (taxonomy reference to a term types) and are not saved. I tried several combinations but do not get it.

What should I do?


texts: Adding dynamic and multiple fields for user profile using profile2 module in Drupal 7

texts:
I am creating profile like linkedin.
Where user can have multiple education fileds and he can add/modify dynamically.
Is there any plugin which suits my requirements.

The nearest I found is profile2 which is promising but does not provide me multiple entry functionality.

Can Drupal help me out how to fix this problem?

Thanks in Advance.
Yatendra

Edit : I want profile types like linkedin education wizard. i.e. if user had entered education detail one time then there should be two option first one for editing education detail and second one for adding more education detail.


texts:
I attempted to create a custom module that automatically creates a node upon submission. I used the second response in this post: How to create a node out of a webform submission?

Per the instructions, I added a php file to a new custom module created through Drupal console. It has an info.yml and .module files.

I took the code from the second comment and altered to suit my module, and add dependencies. (For some reason, the dependencies were incorrect.)

My PtcWebformHandler.php file contents:

<?php

namespace Drupal\ptc_node_from_form\Plugin\WebformHandler;

use Drupal\Core\Annotation\Translation;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\Entity\Node;
use Drupal\webform\Annotation\WebformHandler;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform\Plugin\WebformHandler\EmailWebformHandler;

/**
 * Create a new Article node from a webform submission.
 *
 * @WebformHandler(
 *   id = "add_new_company",
 *   label = @Translation("Create a node on submit"),
 *   category = @Translation("Content"),
 *   description = @Translation("Creates a new Article node from Webform Submissions."),
 *   cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_UNLIMITED,
 *   results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 *   submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_REQUIRED,
 * )
 */

class PtcWebformHandler extends WebformHandlerBase {

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission)
  {
    // Get an array of form field values.
    $submission_array = $webform_submission->getData();

    // Prepare variables for use in the node.
    $title = $submission_array['subject'];

    // Create the node.
    $node = Node::create([
      'type' => 'company',
      'status' => FALSE,
      'title' => $title
    ]);

    $node->save();
  }
}

Before enabling the module, I added the email handler (the other post doesn't specifically say to, but it says a handler is required. And the code references an email array.)

After enabling the module, I submited a form, and checked for the node. And... no node.

I'm still getting used to Drupal 8 module development. I tried my hand at creating a service. But I doubt it is necessary (if I understand services). In any regard, it still doesn't create a new node upon form.  submission.

I tried to use xdebug to see what the data was being passed to the method inside the PtcWebformHandler class. It didn't hit anything.

What am I missing.

(It worked when I added the router from the first comment in the aforementioned post.)

Source: https://www.drupal.org/project/reroute_email


texts: create layouts without the use of embedded regions

texts:
from my experience with Drupal, I could understand, that you can thematize the page.tpl.php file, adding the appropriate html / css and entering regions with php.
So far so good ....
but my approach I'm following this project is to thematize the file. tpl.php corresponding to each of my content type. Now I need a page to bring them all together, I did it successfully using the "Panel". But I would adopt the approach in my opinion the most flexible layout with html / css.
On which page should gather instances of my various themed content type?


texts: Keep link to content even if private content

texts:
All my posts have a "group content visibility" field. So, when the content is private, if the user is not member of the group, the post will not be accessible.

In addition, if there is a link to this post, it will not be displayed in the menu for example. However, what I want is to keep this link even if the post is private. So, when the user clicks on the link, he will get a message like "you need to subscribe to the group to get access to that content".

For example, the website drupalize.me is exactly doing that. If you click on non-free links, then you get a message to subsribe.

Any help will be greatly appreciated ?


texts: Writing a patch on a sandbox/dev install using a git branch

texts:
I'm working with a Sandbox/Dev hosted VM with Drupal 7 and Commons 3. I want to write and perhaps contribute a patch. Having the site under local version control with git, I create a new branch write and test the code.

However, I'm at a loss how to create the patch file between the two branches (master and writing-patch).

Do I switch back the master? How do I compare two branches and properly put that into a patch file with the intention of sharing with a module maintainer? I'd like to do this properly and put as little work on the maintainer as possible.


texts:
I'm debugging a Drupal 7 system I didn't setup, and I'm trying to understand how Drupal loads its modules.

This system appears to have modules nested within one other -- here's one example.

modules/custom/modulename/modulename.info
modules/custom/modulename/modulename.install
modules/custom/modulename/modulename.module
modules/custom/modulename/modulename_statistics/modulename_statistics.drush.inc
modules/custom/modulename/modulename_statistics/modulename_statistics.inc
modules/custom/modulename/modulename_statistics/modulename_statistics.info
modules/custom/modulename/modulename_statistics/modulename_statistics.module

It appears there's one module named modulename, and inside this module there's another named modulename_staticstics.

Is this a "legal/normal" setup?  Does nesting one module within another confer any special features between the two modules?  Where in the drupal source code are modules searched for/loaded?  Is there any canonical piece of documentation that covers how module loading works? (my googling didn't turn up a lot)

(experienced software engineer here, but only passingly familiar with Drupal)


texts: How do I examine an entity's update SQL statement in order to write a unit test?

texts:
I have a core patch (https://www.drupal.org/node/2342699) which ensures that SQL updates do not include the primary key in the field list. I need to write a unit test for this issue and EntityApiTest.php looks like the ideal place for this. This test class has a section

$entities = array_values($storage->loadByProperties(['name' => 'test']));
$entities[0]->name->value = 'test3';
$entities[0]->save();

The way I see it, I will need to examine the entity schema to find the database column name of the 'id' entity key, and then examine the SQL update object to ensure that the entity key is not in the field list. Any advice on how to do either of these steps?


texts: Render values directly in a twig paragraph template

texts:
I'm working with the paragraph module and I've created a paragraph type called Image Teaser Block wich is an entity reference to a content type (Image Teaser, multiple references possible). This content type has 5 fields (Image, list, 2x text + link) and I'd like to render the values directly in the paragraphs template (paragraph--image-teser-block.html.twig).

What I could do is using {{content}} or {{content.field_image_teaser}} to render the HTML in the paragraph template and then change the field templates. But because I have many different paragraph types and each has a lot fields I would end up with tons of templates (imagine 10 different paragraphs with 6 fields each -> 60 different template files) and that's not really efficient to work.

So how can get the values (not rendered HTML) in the paragraph--image-teser-block.html.twig file like that:

    {% for item in imageTeaserBlock %}

{{item.listLabel}}

{{item.title}}

{{item.subtitle}}

    {% endfor %}

I think the same issue applies also to content types wich are entity references to other content types.


texts: How to get the content owned by the currently logged-in user?

texts:
A user is the owner of only one node, and I want to redirect the user, at login time, to his only owned node.

How can I get the node content if I know only the logged-in user?


texts: When doing a page preprocess, how do you know if the page is a form?

texts: When doing a preprocess on a page (I need to conditionally change something at the page template level) is there a way to tell if the page is going to render a form? The xdebug output didn't show any variables that would tell me this in an obvious way.


texts: Fix 404 error when adding conditional action to Rule?

texts:
Subsequent to what I saw in the question 'Don't calculate shipping for specific item', I tried to create a rule with a conditional action (screen capture below), but it causes 404 error:

The export for the rule looks like so:

{ "rules_test_please_delete_" : {
  "LABEL" : "Test (please delete)",
  "PLUGIN" : "reaction rule",
  "OWNER" : "rules",
  "REQUIRES" : [ "rules_conditional", "rules" ],
  "ON" : { "node_delete--page" : { "bundle" : "page" } },
  "DO" : [ { "CONDITIONAL" : [] } ]
}
}

How can I fix the 404 error?

Related resources:

Conditional Rules bug report
Rules feature request


texts: Speed-up loading multi-valued fields on Admin side?

texts: I am having multi-valued text field, which has nearly 200 values inside. On Admin side when editing node it takes HUGE amount of time to load all those values (30 seconds or more). I am trying to figure out how to speed this up - is there any possibility to load the field only as Collapsed and load insides just after clicking on the field? Values inside are being imported by feeds module so I highly doubt someone will edit them, but I also want to give them the possibility to edit.


texts: How to generate a Commerce order from a CSV?

texts:
I'm using Drupal 7 with commerce. Is there a way to generate an order from a csv or similar? the idea is that users could upload a csv (sku and quantity for now) with the items they want and the system generate an order with that.

i'm trying with feeds and the entity processor but i can't import the line items and create de order in the some process (they have to be related with an order). If this is the way, it's not clear to me how to do that.


texts:
I've set up the default Flag (bookmark) and have added the proper links to my node.tpl.php pages so that the flags show up properly.  Is there any way to add the same link to a rendered view (page?) I tried using views-view.tpl.php and adding the following code:

<?php print flag_create_link('bookmarks', $node->nid); ?>

But that doesn't work because the rendered view is not a node, of course.  What I'm trying to do is allow users to bookmark a rendered page view just like they can do with any other node.


texts: How to place blocks in code with zen theme?

texts:
I've been tasked with maintaining a site I didn't make and I don't have access to the original developers.

The site is built with a custom zen theme. The block that I'm interested in is listed in the disabled section of blocks and is configured to the "None" region of the enabled themes and is set to be displayed on all pages with no restriction for users or content types. There doesn't appear to be any obvious settings in the page that the block is on or in the block itself that would determine it's placement. So, I'm a little lost as to how to proceed. Any advice would be appreciated.


texts: Drupal 7 check logged in user has both roles in tpl file?

texts:
I want to print in a page--node--17.tpl.php a code to check for roles from the logged in user and then determine what should be shown, so basically a user must have BOTH roles A and C and if they do i print xxx
If they have roles A and B i write yyy
if they have roles B and C i print zzz

So the code below can check for one role, but how do i do both.. its important that BOTH roles need to be there, a user with just one of the roles will not qualify.

thank u

<?php
  global $user;
  // Check to see if $user has the administrator user role.
  if (in_array('administrator', array_values($user->roles))) {
    // Do something.
  }
?>

also i have this code but i think this is only checking one of the roles, so it checks for either A or B

<?php
global $user;
$check = array_intersect(array('moderator', 'administrator'), array_values($user->roles));
    if (empty($check) ? FALSE : TRUE) {
    // is admin
    } else {
    // is not admin
    }
?>


texts:
I need to set a limit on the number of times a field can be edited.

use case: the name of the user (field_name_user) can only be edited once or twice.

I tried node edit limit and field permissions but neither won't fit the task. Is ther any other module out there or a way to achieve this?


texts: I Can't alter the file upload with #upload_validators

texts:
I am writing because I am trying to alter a Drupal 7 field called Uploaded Files (field_uploaded_files) on a node type called Documents (documents).  I need to check files uploaded by their magic bits. I have my my_app_form_alter in place that is working.

In fact I have tested and $form['field_uploaded_files']['#prefix'] = 'This is a test'; works just fine.

The site is multilingual but I am trying to use this for a form that is only in English.

$form['field_uploaded_files'][0]['#upload_validators']['_my_app_magic_number_validator'] = array($form_id);

The _my_app_magic_number_validator does not appear to be called at all. I have added a Watchdog function in _my_app_magic_number_validator and it is not showing up in the logs at all.

I think I know what to do once I get into the validator function but I have no idea why the function is not being called in the first place.


texts: Different urls for front page depending on language

texts:
I'm using entity translation module and want to have different urls for front page in accordance with languages.

For example:
front-eng
fr/front-page-for-france
pt/front-page-for-portugal
etc.


texts: How can I programmatically create a link/URL with querystrings set from parameters?

texts:
In Drupal 8 I customize the filter in the block in the sidebar menu. When the user clicks on the option in the block, I need to pass his choice to the URL.

$this->args = \Drupal::request()->query->all();
$args[$id] = $value;
$url = $this->url = Url::fromRoute('<current>');
$url->setOptions(array('query' => $args));
$link = 'toString() . '">' . $label . '';

And in the end, my URL looks like

 drupal/page_view?content_type=type

but I need my URL to look like

drupal/page_view?content_type%5Btype%5D=type

Do you know how can I modify my code?


texts: How can I get single keys in multi-item config objects using debug:config?

texts:
For example, in drush I can run

drush cget search_api.server.iges_solr backend_config.connector_config.port

and get a useful answer.

('search_api.server.iges_solr:backend_config.connector_config.port': 8988)

In Drupal Console, I've tried the same formatting as in the drush command, I've tried a colon between the main config item, and the sub item

(drupal dc search_api.server.iges_solr:backend_config.connector_config.port)

I've tried a fair number of other things, and I've read the docs to no avail.  Is it possible to do without just grepping?


texts: How do I handle an incoming POST request in a module?

texts:
I am really new to Drupal but I have to do a project using it and I was just wondering how to handle an incoming POST request in a module:

I am creating a module that will get incoming data from a Webform, process the data by running an R script on it, and then return the result of the R function on the data to the url path specified in the module, but I am not sure at all how to begin handling POST requests - can someone give me some insight? In Webform settings you can specify a URL to send a POST request with the form data upon submission, but if I can figure out how to handle that data I will be golden!


texts: Unable to choose an installation profile on a multi-site installation

texts:
I installed drupal 8 with the open social installation profile using composer. Now I want to turn this drupal install into a multi-site installation where some of the other sites don't use this installation profile. But when creating a new site (I know how to do this from my D6/7 days) I can't select an installation profile. Instead the Open Social installer is always run and it's installation profile always gets applied.
I figured out it is probably due to the vendor stuff that composer does when installing drupal and open social. It changes some things in the vendor folder that change the drupal 8 installation procedure. But the question that remains is if it is possible to still use this install with the standard drupal installation profiles.

Or a perfectly acceptable alternative for me would be to make a base install of drupal8 and afterwards add the opensocial installation profile so I can still choose my installation profiles. I guess that would mean ditching composer? Or maybe not? I don't really know because I am not familiar with how composer changes the drupal workflow from the way I used to work with it in d6/7.


texts:
I have created a view, which displays different content types. I have added some fields for dispalying (image, title, description). The issue for me is that not every node has an image. When it doesnt have the Drupal renders only title and description. How can I force adding image field for all nodes, even when it doesnt exist?

In my css I am using an :empty selector to add default background image.


texts: 'Set the unit price to a specific amount' doesn't work

texts:
I'm trying to set unit price amount to some value when order state is changed to canceled. The order always contains only one line item. I want to set total amount of order to $charge's value.

The exported rule. $charge holds correct value. But unit price and total price is not changed.

{ "rules_order_cancel" : {
    "LABEL" : "Order cancel",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "10",
    "REQUIRES" : [ "rules", "php", "commerce_line_item", "commerce_product_reference" ],
    "ON" : [ "commerce_product_calculate_sell_price" ],
    "IF" : [
      { "data_is" : { "data" : [ "commerce-line-item:order:status" ], "value" : "canceled" } }
    ],
    "DO" : [
      { "php_eval" : { "code" : "if($commerce_line_item-\u003Etype == \u0027insurance_search_line_item\u0027) {\r\n  $def_num = count($commerce_line_item-\u003Efield_defendant[\u0027und\u0027]);\r\n  $amount = $def_num * 75 * 100;\r\n}\r\n\r\n$_SESSION[\u0027msi_charge\u0027] = $amount;" } },
      { "commerce_line_item_unit_price_amount" : {
          "commerce_line_item" : [ "commerce-line-item" ],
          "amount" : {
            "select" : "site:current-user:uid",
            "php" : { "code" : "$charge = $_SESSION[\u0027msi_charge\u0027];\r\nunset($_SESSION[\u0027msi_charge\u0027]);\r\ndsm($charge);\r\nreturn $charge;" }
          },
          "component_name" : "base_price",
          "round_mode" : "1"
        }
      }
    ]
  }
}


texts: Drupal 7 Ajax Form, add elements dynamically to a fieldset

texts:
I have the following form:

  $form['#tree'] = TRUE;

  $tasks = array(
    'Julia',
    'John',
  );

  foreach ($tasks as $task_key => $task) {

    $form['task_fieldset'][$task_key] = array(
      '#type' => 'fieldset',
      '#title' => $task,
      '#prefix' => '
',
      '#suffix' => '
',
    );

    if (empty($form_state['num_todos'][$task_key])) {
      $form_state['num_todos'][$task_key] = 1;
    }

    for ($i = 0; $i < $form_state['num_todos'][$task_key]; $i++) {
      $form['task_fieldset'][$task_key]['todo'][$i] = array(
        '#type' => 'textfield',
        '#title' => t('Todo'),
      );
    }

    $form['task_fieldset'][$task_key]['add_todo'] = array(
      '#type' => 'submit',
      '#name' => 'add_todo_' . $task_key,
      '#value' => t('Add more'),
      '#submit' => array('custom_mod_example_ajax_collection_add_todo'),
      '#ajax' => array(
        'callback' => 'custom_mod_example_ajax_collection_callback',
        'wrapper' => 'task-' . $task_key . '-fieldset-wrapper',
      ),
    );

  }

  return $form;

These are the callbacks:

function custom_mod_example_ajax_collection_callback($form, $form_state) {
  $name = $form_state['triggering_element']['#name'];

  $task_key = (int) substr($name, strpos($name, "_") + 1);

  return $form['task_fieldset'][$task_key];
}

function custom_mod_example_ajax_collection_add_todo($form, &$form_state) {
  $name = $form_state['triggering_element']['#name'];

  $task_key = (int) substr($name, strpos($name, "_") + 1);

  $form_state['num_todos'][$task_key]++;
  $form_state['rebuild'] = TRUE;
}

And the form looks like this: http://imgur.com/a/ZJ0ky
The problem is that when I click on "Add more" on John fieldset, it changes to Julia. What have I done wrong?

It works as expected when I try Add more on Julia, however.


texts: Drupal Doesnt Load after Installing Theme

texts:
I had installed Omega Theme in drupal. I enable and set it as a default theme.I also disable it's former default theme "Bartik". Now I didnt see changes taking place in my Drupal site. Because of impatience I exit the browser and  loads drupal again but it doesnt work like before. I cannot access drupal anymore and shows only white page just like the image below.

What shall I do to fix it?


texts:
Once I've created different Effects under Image styles. How do I flip between them in the Manage Display/Manage Fields windows for the content type?

I can't figure it out.

Or am I just meant to create Different Image styles for each different effect I might like to use?


texts: How to change the style of the pages title in a view?

texts:
I've created a content type view using teasers. The titles are all H1s. How to change that to H3, for example?

Is this just a case of CCS?


texts: Calculate field value based on another field value with Rules

texts:
I am using Drupal 7 and Commerce.

I have Product display where is custom field called Stock (field_stock). This field holds stock value (integer) for Product.

In Product display I have Product Variations. Variations has custom field called Stock Value (field_stock_value).

When adding new Product display and setting field Stock to value 10. And then adding first Variation and setting field Stock Value to 6. And to second Variation field Stock Value to 4.

I need to have rules which decreases Stock field from Product display. So it is simple: take value from Stock Value field and reduce that amount from Stock field.

But I have not succeeded to make working rules for that. Any help needed. Thanks!


texts: Why isn't the access check being called at all?

texts:
I have the below code. I have set up the business logic and it works fine in a .module file, but not in an access controller. What am I doing wrong?

// nodeaccess.routing.yml

nodeaccess.people:
  path: '/user/{user}/edit'
  requirements:
    _custom_access: '\Drupal\nodeaccess\Access\NodeaccessCustomAccessCheck::access'

// nodeaccess/src/Access/NodeaccessCustomAccessCheck.php

<?php

namespace Drupal\nodeaccess\Access;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\user\Entity\User;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;

/**
 * Class NodeaccessCustomAccessCheck.
 *
 * @package Drupal\nodeaccess\Access
 */
class NodeaccessCustomAccessCheck implements AccessInterface {

  /**
   * A custom access check.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   Run access checks for the logged in user.
   */
  public function access(AccountInterface $account) {
    $current_user = User::load(\Drupal::currentUser()->id());
    $user = User::load(explode("/", $_SERVER["REQUEST_URI"])[1]);
    if ($current_user->field_department->target_id != $user->field_department->target_id) {
      throw new AccessDeniedHttpException();
    }
    return AccessResult::allowed();
    }

}


texts: How to get my custom checkout pane to save to order?

texts:
I am having a hard time with the commerce examples module. Specifically, I am having a problem with the Checkout Pane Example module

I am trying to understand how I get the values from the fields in example pane to a field on the order

I realize, I must be missing something fundamental here.

In the example checkout pane, they have a field called Nickname

I created a field Nickname on the order, and I get the checkout pane for Nickname

I noticed that my custom field is field_nickname, does that have any bearing on this?

The only other topic I have been able to find about this is here - http://www.drupalcommerce.org/discussions/2401/custom-checkout-pane, an no one has answered this question either.

Thanks in advance!

As a site builder looking to learn how to better understand the code, I think a solution to this would help a lot of people.


texts: I am getting a PDO error which seems related to the Media module

texts:
After Drupal 8.8 upgrade media module is not working.
In admin media links are not working e.g /admin/content/media
Error :
The website encountered an unexpected error. Please try again later.

  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'media' doesn't exist: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {media} base_table GROUP BY base_table.vid, base_table.mid) subquery; Array ( ) in Drupal\media\MediaListBuilder->getEntityIds() (line 158 of core/modules/media/src/MediaListBuilder.php).


texts: Wich template name do I need for the advanged forum teaser view mode?

texts:
I have two different view_modes for a adv. forum post: in the node (full) and in a view_block with the teaser display suite view mode.
With template advanced-forum-post.tpl.php I can change both view_modes.

I can't find a way to make two seperated tpl.php templates, one for full_mode and one for teaser_mode. E.g node--contentype--view_mode.tpl.php is not working. I tried What is the template suggestion for node 'teaser' view mode?: with no result.
Does anybody knows the answer?


texts: Add properties to an entity hook_schema_alter

texts: I need to implement a custom module that adds fields and properties to an entity defined in another module. I felt the best way to do this was using hook_schema_alter and hook_update_n to achieve the data structure updates. However, I do not see these new fields on my entity. Is there another step to take to attach these to the entity via code?


texts: Inheritance value from the exposed filter

texts:
I've got content-type with two double-valued fields field_price1 and field_price2. There are interior names. I've also got page view (its machine name is search) displaying contents. I've got search with some filters. I decided to create one exposed filter connected with field_price1 field with between operator. Second filter isn't exposed and it is connected with field_price2 field.

I want to display content in the view only if its field_price1 or field_price2 is between values given by user in the search. So that, filter for field_price2 field has to inherit the value from the first exposed filter. I created custom module named customSearch with code posted below in customSearch.module file.

function customSearch_views_pre_view(&$view) {
  if ($view->name == 'search') {
    $filters = $view->display_handler->get_option('filters');
    $filters['field_price2_value']['value']['min'] = $view->exposed_input['field_price1_value']['min'];
    $filters['field_price2_value']['value']['max'] = $view->exposed_input['field_price1_value']['max'];
    $view->display_handler->override_option('filters', $filters);
  }
}

Unforntunately, I've got errors.

  Notice: Undefined property: view::$exposed_input in
  customSearch_views_pre_view() in line
  $filters['field_price2_value']['value']['min'] =
  $view->exposed_input['field_price1_value']['min'];

  Notice: Undefined property: view::$exposed_input in
  customSearch_views_pre_view() in line
  `$filters['field_price2_value']['value']['max'] =
  $view->exposed_input['field_price1_value']['max'];

Could someone help me, please?


texts: How do I show BAT (or BEE) availability calendar on front-end?

texts:
I previously built a site in D7 which showed the availability of two apartments for rent, using the availability_calendar module . The client easily selected dates and marked them available, booked or unavailable, and the result showed in 3 months of full-calendar on the front-end.

I have now rebuilt the website in Drupal 8, but I fiund that the availability_calendar module has not been ported, and there is no real alternative.

As suggested by the availability_calendar developers, I have tried to rebuild the entire availability system using BAT, which proves extremely complicated (and overkill for what I need). I have also tried BEE, which leads to the same main problems I find in BAT.

Both BAT and BEE provide a back-end, but I can't figure out how to display the availability on the front end. I tried Views and PHP code from the back-end, but I get either an empty full-calendar or a title and blank space or error messages.
Both BAT and BEE seem to focus on things being bookable at the front-end.  All I want is a simple system where clients can mark the two apartments as available/booked/unavailable. No need for visitors to be able to book online. I only need the client-set availability displayed in a calendar. How do I switch the displayed availability to read-only?
All bookings my client takes run from 12 noon of the first day to 12 noon on the last day. However, neither BAT nor BEE seems to be able to give me half day display? Switching from daily availability to hourly does change the way the calendar in back end looks, but I still can't get half days booked. For example, if I have a first booking ending 12 noon on Saturday, and a second one starting from 12 noon that day, I get two full Saturdays displayed, with the second booking underneath the first. Ideally I'd like triangles on first and last day, so bookings nicely fill up the calendar and don't separate onto a new line.


texts: Permanently disable Auto Preview in views?

texts: Is it possible to make views stop defaulting to Auto Preview on? It's really slowing down my workflow.


texts:
is there a way to make this message controllable from back end which appear after user registration.

   $message = t("Thank you for registering at $site_name. Your application for an account is currently pending approval.<br/> Once it has been approved, you will receive another e-mail containing information about how to log in, set your password, and other details.");

because it contains HTML it can't be done by string override.


texts:
I'm using the Dashboard module that comes with Drupal core. For roles that are not administrator, it is empty (permissions are set). I'm pretty sure it is because the theme isn't viewable. (Other roles do not see the backend theme.)

How can I change the dashboard theme to a custom theme?


texts:
Is it possible somehow to completely disable the /comment/ path on a Drupal 6 site?

Our site really doesn't need comments and despite having disabled comments on all content types and removing any comment hooks in our theme (someone else developed the site with comments in mind, but we have found that we don't need them, users don't use them, and they only bring in spam to clean up)  we still get pretty regular stream of spam hitting the /comment/reply/[some_content_id] paths and while we have a Mollom taking care of the spam for us, I am wondering if its possible to turn those bots away before they have a chance to leave their droppings.


texts: Redirect module does not allow redirection for existing node's path alias

texts:
I installed fresh Drupal 8 and after that the Redirect module with proper settings. After adding the redirect rule for a path alias it does not work but it saves data properly into the database.

But it works if I add internal path like node/{id}. In this case it works for internal path as well as path alias.

I just wanted to redirect it on the basis of path alias only. Is it possible to add only path alias for the redirection?


texts: How to add special character validation on specific field in form registration process

texts:
I want to add a special character validation on a specfic field.
Here I have my code but it does not work and there is no error.

function mymodule_form_alter(&$form, &$form_state, &$form_id) {
   if ($form_id == 'registration_node_form') {
        $form['#validate'][] = 'mymodule_form_validate';
   }
}

function mymodule_form_validate($form, $form_state){
    if(isset ($form['field_employer_name']['und'][0]['value']['#default_value'])){
        $special_character_list = '[\'^£$%&*()}{@#~?><>,|=_+¬-]';
        if (preg_match($special_character_list, $form_state['field_employer_name']['und'][0]['value']['#default_value'])== 0) {
            form_set_error('field_employer_name', t('The specified form name contains one or more illegal characters. Spaces or any other special characters except dash (-) and underscore (_) are not allowed.'));
        }
    }
}

Please help. Thank You.


texts:
I wanted to hook node/add/patient-history form because I wanted to add ajax in that form.

Before adding Ajax I wanted to get field names correctly. So I tried this:

function ajaxify_form_patient_history_node_form_alter(&$form, &$form_state, $form_id) {
  $form['field_history_patient_id']['und'][0]['#value'] = "Hello";
  // I also tried
  $form['field_history_patient_id']['#value'] = "Hello";
}

They are not working.

I am not sure if I am taking the field names incorrectly or missing something else.

Hook name seems to be correct because this one works:

  $form['actions']['submit']['#value'] = t('Save History');

I found some similar questions on stackexchange but with no answers.

Any advice/links appreciated very much. Thank you.


texts: Good method/approach in improving advanced Drupal development skills

texts:
This might be a bad place to post this, but here it goes.

I'm looking for a good approach in bettering my knowledge/skills to Drupal. I have been using it since D5 and I still feel like I am so 'unskilled' in doing advanced development. I still struggle with how to create a custom module or hook alter methods properly (with 1 try and not 10) through the template.php file. I have seen others create some insane modules or scripts and I just boggles me on how they come up with it.

It's always been trial-and-error for me, and sometimes I get it to work but never can get an answer on 'Why that worked'.

I have been a php developer for over 10+ years, touched a bit of C#, Ruby, and Java but nothing hugely professional. I have always been driven to continue pursuing Drupal development. Just so incredibly overwhelming still at times. I have high hopes to make the next DrupalCon in Austin, Texas.


texts:
I'm trying to use a custom javascript event when certain actions are performed on my site, specifically things like Webforms, or Node Comments being submitted (both of which are setup to submit via AJAX), but what I'd like to do is allow the webform and comment to both perform their own internal validation before I try to act on the data.
eg, If someone tries to submit a comment on a node, but it fails validation, I don't want to react to that event, but so long as their submission is valid, then my action fires.
Originally I'd wondered if it was possible to inspect the drupalSettings code to see if I could find the AJAX commands and insert my own success code into it for example, but I don't know if this is better to do from a module, and include my own code in there to do my callback


texts: How to disable links for anonymous users for SOME, but not all link items?

texts:
The link issue here is video links, which are for brightcove.com hosted videos. Now some important background:

  The site is a directory of company-produced videos. It requires login in order to view anything.
  However the user can assemble a list of videos (like a cart or wish list) and send a URL for that list to a non-authorized person; that person can view the video links and read text info about the video, but can't access other parts of the site.
  But some of the videos are designated as "not shareable." So even though it's OK to share links to most of the video pages and for anonymous users to play the video link, we need to exclude the "non-shareable" videos from being playable.
The link field is only one of the fields in a node of this content type. The node itself must remain accessible to the anonymous user; it is only the video link that needs to be variably accessible or not accessible to anonymous.

Can anyone suggest a strategy for making some but not all video links not accessible to the anonymous user?


texts: Can visit the page but can't see the tab it should have

texts:
Not sure how to word it and I am sure plenty of other people have run into this problem, so I apologize in advance.

I have the following code:

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

  $items['admin/config/content/authoring/messages'] = array(
    'title' => 'Messages',
    'description' => 'Configure what messages are displayed for the differing content types and who has permission to see them.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('content_type_message'),
    'access arguments' => array('administer content type messages'),
    'type' => MENU_NORMAL_ITEM,
  );
  $items['admin/config/content/authoring/messages/settings'] = array(
    'title' => 'Settings',
    'description' => 'Configure who has permission to see them.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('content_type_message_roles_form'),
    'access arguments' => array('administer content type messages'),
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}

The second page I can access when I go to 'admin/config/content/authoring/messages/settings' but I do not see a tab on the first page ('admin/config/content/authoring/messages') to go to this second page. Anyone know what I might be doing wrong?


texts: CKeditor Media Edit: AJAX HTTP error 500

texts:
How can I fix the AJAX HTTP error 500 to make the "Edit media" button in the body of the CKeditor work?
I am trying to use the "Edit media" function to edit an image, which was directly uploaded in the CKeditor with the Media button. The image itself can be easily uploaded directly or inserted from the Media Library. However an AJAX HTTP error 500 occurs and prevents the server from loading, as soon I click on the Edit button. This affects all image sizes, and occurs both locally and on production.

I used Mac OS X El Capitan Version 10.11.6 to set up this Drupal 8 page with the core-dev 8.8. The site was built with composer on MAMP Pro 5.3.
Php 7.0.8 is used. The modules involved in the issue are Paragraphs, Language and Media. I tested this in Chrome 85.0.4183.121 (Official Build) (64-bit), Firefox 75.0 (64-bit), Firefox Developer 78.0b9 (64-bit).
This is the log message that accompanies the issue:

The full error message is as follows:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /editor/dialog/media/full_html StatusText: 500 Service unavailable (with message) ResponseText: The website encountered an unexpected error. Please try again later.Symfony\Component\Routing\Exception\MethodNotAllowedException:  in Drupal\Core\Routing\MethodFilter->filter() (line 46 of core/lib/Drupal/Core/Routing/MethodFilter.php). Drupal\Core\Routing\Router->applyRouteFilters(Object, Object) (Line: 127) Drupal\Core\Routing\Router->matchRequest(Object) (Line: 92) Drupal\Core\Routing\AccessAwareRouter->matchRequest(Object) (Line: 150) Drupal\Core\Routing\AccessAwareRouter->match('/editor/dialog/media/full_html') (Line: 138) Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin->isAdminPath(Object) (Line: 104) Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin->getLangcode(Object) (Line: 186) Drupal\language\LanguageNegotiator->negotiateLanguage('language_interface', 'language-user-admin') (Line: 131) Drupal\language\LanguageNegotiator->initializeType('language_interface') (Line: 218) Drupal\language\ConfigurableLanguageManager->getCurrentLanguage() (Line: 92) Drupal\language\EventSubscriber\LanguageRequestSubscriber->setLanguageOverrides() (Line: 74) Drupal\language\EventSubscriber\LanguageRequestSubscriber->onKernelRequestLanguage(Object, 'kernel.request', Object) call_user_func(Array, Object, 'kernel.request', Object) (Line: 111) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.request', Object) (Line: 127) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708) Drupal\Core\DrupalKernel->handle(Object) (Line: 19) "


texts: Upload a file by Ajax without submitting the form

texts:
I want to upload a file by Ajax (without submitting the form) than process in backend, and clear the field to allow to add another file. Is it possible with Drupal 8? Can anyone provide an example?

I tried this one but without success.

$form['input']['file'] = array(
  '#type' => 'managed_file',
  '#upload_location' => "public://$file_dir/",
  "#upload_validators" => array(
    'my_file_validator' => array(),
  ),
);

My questions are:
1. How to add an extra process callback (backend) ?
2. How to clear the field (Front end) ?

Thank you
Thank you


texts: Is there a way to pass custom data to a form template?

texts:
I have been tasked to customize a view, and I have been struggling with its exposed form, because I need to display some informations. Here is how it should look:

These elements act as a checkbox, but the number on the right is the number of nodes that have this tag linked.
So far, I have nothing code related, because I simply don't know how to handle this. The theme itself would accept an array of array, each of them containing the checkbox's text, its value, and this number, like so:
tabs: [
    {
      label: "Topics",
      filtersType: "tag",
      filterName: "loremField[]",
      filters: [
        {
          id: "lorem1",
          label: "Loremi",
          items: "5"
        },
        {
          id: "lorem2",
          label: "Loremi",
          items: "15"
        }
    }
]

However, I'm not able to either pass this "items" key to either the form, and I'm not sure at all that I can customize the input from the hook form alter. For a reference, here is the template:

  {% for item in filters %}

      <input id="{{item.id}}" name="{{ filters.filterName }}" class="c-tag-filters__item__input" type="checkbox">

        {{item.label}} {{ item.items }}

  {% endfor %}

So, how should I proceed in this case?
Thank you in advance


texts: How to show a variable of node in page template

texts: I have created a content type with some fields in Drupal 7. It output in node.tpl.php of course. But I wonder if I want to display some fields somewhere within the page.tpl.php, how to go about it. e.g. output a content types' field in the header/footer in page.tpl.php or anywhere.


texts:
Flag a node using scheduler & Rule. But not getting the way how to achieve that.

Scenario:

I have a Content type "xxx" and I have set a flag with this content type.
So, whenever a user creates a content,I want to use scheduler so that user can specify at which particular date & time it should be flagged.

(Scheduler provides when to publish and unpublish content,I want to Flag the content)

Let me know if anyone having any idea about this.

Thanks in advance.


texts: How to create a checkbox to turn-off/on email notifications each time when a node is published or updated?

texts:
How can I make a checkbox for turn-off/on sending e-mail notifications to users each time when I publish or change a node (in Drupal 7)? I mean, I don't need to send notifications each time I changed a node (or published it).

I used an editor interface in Drupal 6 (maybe earlier) and it included a similar checkbox: I could turn-off/on sending email notification to users. Here is a picture of it (last checkbox):


texts:
Is there a module for Drupal that would allow me to perform redirects based on parts of the URL?

For example, if the URL contains this-string-to-redirect, e.g. example.com/this-string-to-redirect/node/content, then redirect to another path.


texts:
I need to have a field with user's picture URL. I'm trying to build it with a Views PHP field.

The field's value is defined

$account = user_load($row->uid);
$uri = $account->picture->uri;
$url = image_style_url('avatar', $uri);
return $url;

It returns value I expect, but returns also a warning

  Notice: Trying to get property of non-object in __lambda_func() (line 2 of /home/testwww/web/informator/sites/all/modules/views_php/plugins/views/views_php_handler_field.inc (131): runtime-created function).

Do you have any idea on how to solve the issue or what exactly is the cause?

From what I've found out:

it seems that the notice concerns uri attribute of $account->picture..
The result of print_r($account->picture) is

        stdClass Object
        (
            [fid] => 168
            [uid] => 58
            [filename] => picture-58-1310836862.jpg
            [uri] => public://portrait/picture-58-1310836862.jpg
            [filemime] => image/jpeg
            [filesize] => 49505
            [status] => 1
            [timestamp] => 1310836862
            [rdf_mapping] => Array
                (
                )
        )


texts: Module version is not available in the list of the installed modules

texts:
I was using Drupal 6 and 7 before. I'm now trying with Drupal 8, but in admin/modules I don't see the module version.

Why don't I see the module version? Is that information that Drupal doesn't show anymore, do I need to change settings, or is there any other reason?


texts: how do I load a single page in a sub theme?

texts: I am creating a page in a Drupal website of mine so that I can use it for a custom iframe in a Facebook app. The reason for this is that Facebook uses 520 instead of 960, and I was wondering if there is a way to create a separate sub theme that would be used for a single page on my Drupal site.


texts: How do I rewrite the ID of an exposed filter field element?

texts:
I am desperately trying to a way that I can rewrite the ID of an exposed filter field element.  I've gotten so far as to set up hook_form_alter where I can get the specific $form array that I need.  When I look at that array using dpm($form) I can see where other info for that input element is contained, but there is no ID element in the array that I can see.

This is the current output that I'm concerned about from my exposed filters form:

Location Type

            <input type="checkbox" name="field_location_type_tid[]" id="edit-field-location-type-tid-370" value="370"  /> Parks

            <input type="checkbox" name="field_location_type_tid[]" id="edit-field-location-type-tid-371" value="371"  /> Historic Sites

            <input type="checkbox" name="field_location_type_tid[]" id="edit-field-location-type-tid-372" value="372"  /> Marine Conservation Areas

            <input type="checkbox" name="field_location_type_tid[]" id="edit-field-location-type-tid-735" value="735"  /> Urban Parks

            <input type="checkbox" name="field_location_type_tid[]" id="edit-field-location-type-tid-736" value="736"  /> Other

Specifically, the markup I want to change is the following:

<input type="checkbox" name="field_location_type_tid[]" id="edit-field-location-type-tid-370" value="370"  />  Parks

I want to be able to rewrite the id of the input element and the for of the label element.

This I've got the following in my template.php file:

function parks_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if($form['#id'] == 'views-exposed-form-photo-gallery') {
    dpm($form);
  }
}

Looking at what dpm returns for the $form array I can see where in that array the info for these check boxes exist, but there is nothing in there that makes any sense in terms of rewriting the ID.  What I'm seeing is the following:

form
  field_location_type_id
    #type
    #multiple
    #options
      370
      371
      372
      735
      736
    #size
    #default_value
    #theme

I was hoping there would have been an obvious ID element in that array, likely as a child to the child elements of the #options element but no such luck.

I've been looking for a solution for this for a couple of days now and I'm just spinning my wheels.  Everything I can find is people customizing the wrapper classes and stuff, but no one getting this granular.  Any help is greatly appreciated.


texts: View of taxonomy with node count grouped by another taxonomy

texts:
I have a taxonomy foo with a fixed number of values (6).
E.g. [A1, A2, A3, A4, A5, A6]

I have nodes related to this taxonomy (from 0 to n).
This nodes are classified with another taxonomy bar, with 3 values possible (X, Y, Z).

I have a view, based on the foo taxonomy, with this results

**A1**
34 nodes

**A2**
29 nodes

**A3**
40 nodes

etc.

I would like to have a view with this results:

**A1**
20 X
11 Y
3 Z

**A2**
9 X
10 Y
10 Z

**A2**
12 X
20 Y
8 Z

etc.

What can be the best approach?


texts: "Expand all menu links" Menu Block selection shows all menu items in block not just active trail items

texts:
I have a menu block that I have setup with Initial visibility level = 2 and Number of levels to display = Unlimited. When I check the "Expand all menu links" checkbox and view my menu block it is displaying ALL menu items at visibility level 2 VS the menu items in the active menu trail.

What's the be way to display only the active trail menu items without going into each menu item and setting them as "Show as expanded" individually.

I'm using Drupal 8 and a customized Bootstrap theme


texts:
I installed colorbox module and I'm showing images as thumbnails. Each image is in on new line. Is it possible to set it that images will be in the grid similar as here?

I have exactly the same settings as here but don't see any settings to view images as grid, but I have a feeling I saw this somewhere else, but don't remember where.

thank you


texts: How to sync a taxonomy between Drupal and a 3rd-party system?

texts:
I have a custom made system (non Drupal) that has a taxonomy like:

Element 1
   Element 1.1
   Element 1.2
   Element 1.3
Element 2
   Element 2.1
   Element 2.2
Element 3
   ...

And I have a Drupal site that I would like to be able to:

Use this taxonomy for tagging content, and
Add more terms that the non-Drupal system can use too.

Is there a popular way to sync a taxonomy in a Drupal system with an external system?