texts: Views, User type page view ignoring Omega content grid

texts:
I have created a view of users with a page display.  When I navigate to that page it isn't rendering Omega's usual id or grid classes.  Instead it is just using Views classes.

For example here is the HTML output for a normal content type views page:

And here is the HTML output for a user type page view:

Has anyone come across this?

--

Just to add that if you add a block to the content region then the omega template seems to work normally.


texts: how to change value of submit button of comment form?

texts:
I wanted to change the default value of submit button in comment form from "Save" to "Post". I wanted to do that using a module , not javascript. So I wrote the following code in my module.

 function mymodule_form_comment_form_alter(&$form, &$form_state, $form_id){

     $form['actions']['submit'] = array(

      '#value' => t('Post Comments'),
     );
     }

But instead of changing the value of submit button, this module is making the submit button hidden. If I add return $form  , then the submit button displays but with the same default text "Save". Any suggestions please. Thank you.


texts:
I have a very simple form that has a select box of the terms in a vocabulary, and renders the selected term below it.  It seems that the first time I change the value in the select it renders the appropriate term, however every subsequent "change" event it uses what ever term I selected the first time.

The code is as follows

function jms_industry_lens_form($form, &$form_state) {
    $values = array();

    // Load the vocabulary and collapse into an array that form api understands
    $vocabulary = taxonomy_vocabulary_machine_name_load('industry_lens');
    $terms = taxonomy_get_tree($vocabulary->vid);

    foreach($terms as $term) {
        $values[$term->tid] = $term->name;
    }

    $form['industry_lens'] = array(
        '#type'             => 'select',
        '#options'          => $values,
        '#default_value'    => 0,
        '#required'         => TRUE,
        '#ajax'             => array(
            'callback'  => 'jms_industry_lens_form_ajax',
            'wrapper'   => 'edit-industry-lens-term',
        ),
    );

    $form['industry_lens_term'] = array(
        '#type'     => 'item',
        '#markup'   => _jms_render_term($terms[0]->tid),
    );

    return $form;
}

/**
 * Ajax callback to change the rendered industry lens taxonomy term
 */
function jms_industry_lens_form_ajax(&$form, &$form_state) {
    $form['industry_lens_term']['#markup'] = _jms_render_term($form_state['values']['industry_lens']);
    $form_state['rebuild'] = TRUE;

    return $form['industry_lens_term'];
}


texts: git post-receive hook to trigger drush rsync without prompt or with predefined answer

texts:
I have set up post-receive hook on my staging server, so whenever I push from dev server a master branch, it updates staging webroot and triggers drush rsync to update live site.

#!/bin/bash

    while read oldrev newrev ref
    do
      branch=`echo $ref | cut -d/ -f3`

      if [ "master" == "$branch" ]; then
    git --work-tree=/var/www/drupal/ checkout -f $branch
    drush rsync --delete --exclude='.htaccess' --exclude='io' --log-file=rsynclog.txt --exclude-files @stage @live

        echo 'Changes pushed live.'
      fi

      if [ "dev" == "$branch" ]; then
        git --work-tree=/var/www/drupal/ checkout -f $branch
        echo 'Changes pushed to staging.'
      fi
    done

Or i hoped to do so :) I have ssh keys in place and that is not the problem, what i can see is that it hangs on destroy yes no question. Output after git push origin from dev machine:

  Counting objects: 15, done.

  Delta compression using up to 4 threads. Compressing objects: 100%
  (8/8), done. Writing objects: 100% (8/8), 762 bytes, done. Total 8
  (delta 5), reused 0 (delta 0)

  remote: Already on 'master'

  remote: You will destroy data from mydomain.com:/var/www/drupal/ and
  replace with data from /var/www/drupal// remote: Do you really want
  to continue? (y/n): Aborting. [cancel]

  remote: Changes pushed live. To root@dev:/git/drupal 65abd19..7205946
  master -> master

So I would need somehow to tell script that answer is y, or I need a way to  avoid that question at all.

Also, I am not pro bash scripter ;) , are those commands being excecuted in line,  like in php, so one is not executed before other finishes ? (to make sure changes are propagated on staging webroot first, then rsynced all to live).


texts: How to do taxonomy based css styling using template.php?

texts:
I'm looking forward to implement taxonomy terms based CSS styling; especially for the body tag which I want to add the current terms.

Here is what I have so far:

function _phptemplate_variables($hook, $vars = array()) {
  global $node;

  switch ($hook) {
    case 'page':
      // die ('test');
      $vars['body_class'] = '';
      if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
        $vars['body_class'] = 'theme' . arg(2);
      }
      if (arg(0) == 'node' && is_numeric(arg(1))) {
        $node = node_load(arg(1));

        if (is_array($node->taxonomy)) {
          foreach ($node->taxonomy as $term) {
            $vars['body_class'] .= 'theme'.$term->tid;
          }
        }
      }

      if (drupal_is_front_page()) {
        $vars['body_class'] .= ' front';
      }
      break;
  }

  return $vars;
}

I think the code is OK, but it never get called (see my 'die' function); using simple phptemplate engine and minimal Drupal 6 install.

What obviousness am I missing here?


texts: Drupal 8 : Render a field collection item in a Twig template

texts:
In Drupal 8, I have a content type which use Field Collection Module like that :

field_body (FieldCollection, repeatable)

field_image_alignment(Boolean)
field_picture (Image)
field_free_text (Long Text)

I want to theme this fields.
I overrided the field template with a file named field--node--field-body--news.html (news is the content type that contains theses fields.).

Default template is this :

{% for item in items %}
    <div{{ item.attributes }}>{{ item.content }}</div>
{% endfor %}

And my template overrided is like that :

{% for item in items %}
  {% if item.content['#field_collection_item'].field_image_alignment.value == 1 %}
    {{ dump(item.content['#field_collection_item'].field_picture) }}
    {% endif %}
{% endfor %}

How can I render "child" fields field_pictures, field_free_text ?
I used item.content['#field_collection_item'].field_image_alignment.valueto access to the plain value but I would like to have the rendered view.

Thanks a lot.


texts: Cannot use object of type stdClass as array error in node save

texts:
I built a custom form and one of them is of  type geocode with lat/lon fields. When I try to save the node I receive the following error:

  Cannot use object of type stdClass as array in
  /var/www/vhosts/example.com/httpdocs/modules/field/field.attach.inc on
  line 208\n'.

The error disappears when I put comments in this field. My question is how can I solve this since it is very important field (I try to create nodes with geocode locations)

Here is how I declare my field:

$form['field_locationmap'] = array(
    '#title' => 'geofield',
    '#type' => 'geofield_latlon',
  );

It seems that the error occurs when I m trying to pass the values to the object:

$location->field_locationmap->und->{0}->geom->lon=$form_state['values']['field_locationmap']['lon'];
$location->field_locationmap->und->{0}->geom->lat=$form_state['values']['field_locationmap']['lat'];


texts: How to pass an array to drupal7 form select as value of #options?

texts:
This problem makes my head burn all day. Please see the code below.
I got a variable $region_value contains the region value with the same structure listed in the code. However different page has a different region value, so I have to use a variable to store it, it's not static.

$region_value = array(0 => 'US', 1 => 'EU')
//form code details have been left out.
//the below code define the form.
$form['region_options'] = array(
                '#type' => 'select',
                'prefix' => 'Region',
                '#options' => $region_value,
                               );

now I get the problem, cuz drupal can't accept the value of $region_value, something wrong happened cuz the $region_value's can not be passed into the form function itself in template files, it might be caused by the drupal core settings. I know it's not a good choice to write functions or other customer variables in the template files, but it's convenient for simple test, you don't have to dump the cash.

So my problem is, is there a mean to pass a variable value into the form function?

//variable set here
$options = array('foo' => 'bar',...)
//form define function goes here
function region_form($form, &$form_state) {
            $form['submit'] = array(
                                   '#type' => 'select',
                                   '#options' => $options,
                                   );
            return $form;
          }

Much appreciated for all advises.


texts: How to disable core JS aggregation and AdvAgg just for admin paths

texts:
I help look after a site which uses $settings['file_public_base_url'] to serve files from a different subdomain on the frontend, but on the backend (admin paths like node/add and node/edit) this causes our JS to be loaded with absolute rather than relative URLs which seems to cause an issue with JS loaded via AJAX not executing correctly. There are no JS errors in my devtools console, but I suspect the cause is that the JS is being loaded from differing subdomains, as turning AdvAgg and core's JS aggregation off makes the JS files load via relative paths and function as intended.

Without any errors showing in my console or server logs I'm not sure I'm going to be able to get to the bottom of the AJAX issue, so for now a compromise seems to be to turn off aggregation for admin and content editing routes.

What would be the best way to do that? I know I can set $config['system.performance']['js']['preprocess'] = FALSE; and presumably a similar config key for AdvAgg's own setting (we have AdvAgg set to optimise/compress JS, so even with system.performance.js.preprocess turned off AdvAgg will still manage the files and use absolute paths to include them. Can config settings be altered on a per route/path basis?


texts:
I have a drupal 7 installation with apache solr search: But I need to use a custom search like this:

2 TextBox fields with:
What -> Any word of the apache index.
AND
Where -> A term reference in the content type.


texts: Prevent the loss of EXIF using imageCache does not work

texts:
I want to limit image dimensions on upload, but obviously the exif information gets lost then. I am using the imagecache actions module resp. the imagecache autorotate, which actually works fine when I don't restrict image dimensions on file upload.

How do I set a maximum image resolution on upload and keep the exif so that imagecache can rotate images afterwards?


texts: In Drupal 8, how can you have CKEditor load additional stylesheets when using a configured filter format? In Drupal 7, you could give the WYSIWYG module paths to CSS sheets to load, which made the editor text reflect the theme as much as possible. I am not seeing this option.


texts: Returning custom array in lazy builder callback

texts:
I have to return a custom array from a lazy builder callback and then loop through that array in a Twig template for a custom block. Here is my code so far:
Custom block:
public function build() {

return [
  '#theme' => 'custom_theme',
  '#variables' => [
    '#lazy_builder' => [static::class . '::lazyBuilder', []],
    '#create_placeholder' => TRUE,
  ],
];
}

The callback
  public static function lazyBuilder() {

  //code above
      foreach ($vars as $var) {
        $arr[] = [
          'title' => $var->getTitle(),
          'body' => $var->body->value),
          'summary' => $var->summary->value,
        ];
      }
    }

    sleep(3); // For testing only
    return $arr;
  }

In my twig template
{% for var in variables %}
  <div>{{ var.title }}</div>
{% endfor %}

For each item I want to display its title, body and summary. Everything works fine if I return from the callback an array which has #markup inside, but I need to return my custom array.
If that's not possible it would be also OK if a lazy loaded the whole block not just the content inside it.
Thank you.


texts: Commerce - Theme Add-to-Cart form on Product Display page

texts:
I have a Drupal Commerce project setup on top of D7-22. I've overridden the template file for my product display (node--product-display.tpl.php), and have managed to render the product fields, as well as the Add-to-cart form with all of the attributes. I know that <?php print render($content)?> will actually render the <form> for the attributes and Add-to-Cart button, but I would like to customize the HTML layout of the form and add some other elements to it. For example:

I'd like to position the Add to Wishlist button next to the Add to Cart button
I'd like to add some HTML next to one of the attribute fields that is rendered (the Size select box).

Using the Devel module, I was able to pick up fields like product:commerce_price and product:sku, but none of the attributes or buttons within the actual <form>. I'm currently using jQuery to inject HTML into the form...but it's a hack am not all that comfortable with pushing into production.

Is there any way in my tpl.php file to print out the form attributes, quantity textbox and buttons individually?

Cheers!


texts:
I have an image field inside the content type 'Article'. I have two view mode: "teaser" and "full". I have a view page ('Homepage') showing all 'Article' nodes using "teaser" view mode.

In the 'Homepage' view, I'd like to display a default image if the image field is not setted.
In the "full" view mode I'd like to hide image field if is not set.

It's possible to do that?


texts: How to print paragraph field values in paragraph template?

texts:
I'm trying to output paragraph field values in a sample paragraph template, but it does not work. I created a twig template in paragraph/paragraph--article--default.html.twig

I have a field called field_action and I tried:

{% block paragraph %}
    <div{{ attributes.addClass(classes) }}>
      {% block content %}
        {{content.field_action}}
        {{content.field_action.value}}

      {% endblock %}
    </div>
{% endblock paragraph %}

Nothing happens.

If I write {{content}} everything is fine, but I would like to customize output.


texts: How to display block to the nodes of specific content type?

texts:
I have created a content type "test". I also created a block "Search". I like to display the block only to nodes of the content type.

I configure the block and under Show block on specific pages >  Only the listed pages > Entered

  test/*

. It did not work. How can I display the block only to the nodes of the "test" content type?

Thanks,
D


texts: Simple Hierarchical Select starting at vocabularies

texts:
I am using Simple Hierarchical Select module with my Drupal 8 site. What I want to do with this module is in view, I want to allow choosing one of vocabularies first, and second dropdown will show up with a list of terms of selected vocabulary.

Basically, Simple Hierarchical Select module requires selecting vocabulary first when creating an exposed filter. But, I want clients to be able to choose vocabulary first then terms.

Based on my question, is there any way to do so with this module or other modules?

Thank you, in advance.


texts: how to remove selected items in the select option in webform matrix component

texts:
I have 10 values in the select option component (i.e dropdown box)

for example
1
2
3
4
5
6
7
8
9
10

Once I have selected 1 value, That value should not repeated again in the select option (i.e dropdown box)
Example
2
3
4
5
6
7
8
9
10

Please guide me how to find the solution for this
Thank you


texts:
I have a problem that has been discussed a lot, but I still fail at dealing with it.
I need to get and set the the value of the field by Rules. I put my conditions allright, then I define "Set a data value" as a desired action. At this point, the direct input is disabled, I can only point to another field (as far as I can understand): "switch to direct input mode" is disabled (does not appear, in fact).
Now,I've seen a number of discussions related to the issue. It seems to be related to the way the Date module handles things.

The issue seems widely discussed:
Date module:
https://drupal.org/node/1431952 (Date field will only set in Rules if it already has a value)
https://drupal.org/node/1153766 (provide a property setter callback)
Rules Module:
https://drupal.org/node/1611666 (Action "Set a data value" is not working for   date field)

There are also more general guides
Drupal 7, Rules, Convert text to date and set a date field (as setting the date supposedly works for timestamps)

While most of the problems seem solved, I can't achieve the simple (I assumed)  goal I want to get to. Can anybody explain how to connect the pieces of information and make it work as intended?


texts: Limit Teaser to display only the first value of a Field

texts: I have a Content Type with an Image Field. This field will typically be populated with 0 to 4 values. By default the teaser for this Content Type outputs all 0 to 4 images. How can I adjust the Teaser to only display the first image?


texts: I have two tables on my page and have added sorting to headers of both the tables. When I click on the header of the upper table, I observe sorting in the table below rather than in the table where I clicked the header.


texts: Programmatically add items to the menu - not hook_menu

texts:
We're redesigning our site and getting rid of the sidebar. The main reason for the sidebar to exist was to hold Organic Menus (og_menu), which we have hundreds of groups, each with 2 or 3 menus. I want to move OG menus to the main menu.

What I would like to do is when a user visits a particular OG

load the menus for that OG (trivial)
programmatically make the menu's name the top level links linked to # (Trivial - we use bootstrap)
add the menu's links below those top level links (this is where it gets tricky)
and append them to the main menu as the last to links (no clue)

So the top level would look like this only when the user hit the group

Home Communities Forum Group-Menu-1 Group-Menu-2

Home, communities and forum are always there the group menus are appended when they're in that group. I don't need code I just need direction on which parts of the API will facilitate this.


texts:
I created a content type called informational, that has only one field in it, the default body textarea, I added into it <?php echo 'test';?>, and chose the PHP Filter option, in my page--informational.tpl.php all I'm doing is printing that field, and it's printing it as 'plain text' format. I checked in the DB and it's saved as PHP code.

P.S. I'm an administrator of the site, and I have all permissions.


texts: How to display all when input argument is wrong

texts:
I create a view display a books depend on url argument (book type name) ... And when book type name is not exist in book types list ... view be empty .. how can I when the url argument is wrong, display all books?

thank you


texts: Best way to integrate "customization" to the front page

texts:
#First question

We are making a Drupal 7 theme for one of our customers.
The company wants to be able to edit the frontpage easily, without any coding skills.

Atm we got this:

Image 1

Image 2

But this is totally not user friendly.
We made a block, and put block content in it, for this one it was just html.
But what we want is more like a wordpress "customizer" or something?

Maybe this is something that is totally basic in Drupal 7 but we just missed it?

#Second Question

The people (Employes of our client) that will manage the website when launched. Will they have to work in de basic Drupal 7 dashboard, or is there a way to make your own dashboard in the style of your website?


texts: Customize output style of views filter fields

texts:
I have a view associated with many filter fields:

Checkboxes
Listboxes
Three date fields of textbox type.

In admin theme(seven), the date filter fields aligned improperly and I would like to show the three date range filters aligned horizontally next to each other.

I couldn't add any class for filter fields from the admin UI.

Any help/ideas please?


texts: Where in Drupal database do I store additional file properties?

texts: I have an (architectural) problem with D7 and don't know what would be a good solution to it. Here is what I'm trying to do: I have an article with a sound sample attached to it. I thought it would be great to calculate sound sample duration and bitrate and store it somewhere in the database. What would be the proper place for that? I thought of node fields first, but number of sound samples for one article is not restricted and it seems I'll need to define a field with unlimited number of values to hold durations and then somehow match samples with their respective durations. Don't think it's a proper solution here. So what's the common practice in such cases?


texts:
I have created views with a node type (Property) that has term reference to vocabulary (Cities).
Vocabulary (Cities) has a terms in a hierarchical order (City-Street).

I need to do the views in which I have two combobox for vocabulary terms (City-Street) with the following behavior:

When user select a City I would like to automatically fill the second
combobox(Street).
When user select City I need a list all of the
streets for that terms. Now I have a list only when user select an
item from combobox Street. I have tried the Hierarchical Select
module and it didn't meet my needs.

Do I need to make my own module, and which hook or hooks to use, or is there another solution?

I hope that I was clear.

Best regards,

Goran


texts:
I am looking for modules that can extend drupal 7 comment admin.
For example, I want to be able to set different statues for comments, like Approved, pending, spam and unapproved.
And maybe comment moderation history, in comment admin it should show a log of who changes the text, who changes status of a comment. the only module i can find is for drupal 6.


texts:
When trying to create new invite type from admin/structure/invite-types/add I get this response:

  Sorry no Invitation Type modules available in the system.

I has been researching and there is no info referral to this. And I can not create that invitation type from anywhere, also there is no info to do it programmatically.
I get lost into code module but this is the line that returns that message.


texts: Is it possible to put callback function here $items['callback?'] ? I need to change this field every time when user make some changes. The biggest problem for me is that hook_menu() is cached and menu is rarely updating.


texts: How to get all the fields defined by a particular module?

texts: Suppose i have a module1 where i define fields and i get list of all the fields in module2 using module1_fields_info(); this is done in D7. How to get list of fields defined by module1 in module2 in Drupal 8?


texts: How do I use a preprocess function to add custom classes to a view fields?

texts:
I have a View that outputs several fields per row. I'd like to use a preprocess function to add a class to one of the fields, depending on the value of another field. How do I do that in Drupal 8?

Note, I do not want to add a class to the entire row -- just a specific field in that row. The output would be something like:

 ...

 ...


texts: How to use a glossary exposed filter in search api views?

texts:
I have a search api views. I want to display a glossary filter on title.

I have searched many articles to implement it using a contextual filters. But the options of context filters can be seen in a normal view but not in search api views. i-e When the filter value is not available, display a summary
I also tried this  module Search API AZ Glossary but I do not want it as a facet.
So my questions is, Is this possible with a normal views exposed filter or with a contextual filter etc?
I don't see the summary options here as this is present in a normal view.

Nor these settings are present in search api views.


texts: Object undefined in jquery, plus my links are pointing elsewhere

texts:
I asked this question on stackoverflow earlier, not realizing this site existed.  Seems that this would be a better place for it.

In a nutshell, I've restored an existing drupal 7 site under the public_html/migrated_site folder on my hosted site.

When I browse that URL however I'm getting errors from jquery that the Drupal object doesn't exist, and all my links and images point to public_html/migrated_site/sites/someothersite...

..where someothersite is the name of the old subdierctory under public_html on the prior host.

I changed my settings.conf values to point to the migrated MySQL database, and that bit appears to have worked, in that the site is coming up, albeit unstyled and with the above jQuery and links errors.

However I'm not sure what could be going on above?  I've tried a few RewriteBase settings in .htaccess in both public_html and public_html/migrated_site (particularly, adding RewriteBase /~hisusersite/migrated_site) but nothing seems to have made a difference.


texts:
I would like to show the two latest facebook-posts on my Drupal page.
I found these two modules: https://www.drupal.org/project/facebook_pull and https://github.com/mysequel/Drupal-8-Facebook-Feed-Module. Unfortunately there is no working Drupal 8 compatibility yet. The first one is in Dev Status and I can't even get it to work. The second generates an error when activating.

What is the Drupal 8 way to import this data from Facebook?


texts:
I'm creating an input filter that is quite expensive, as it makes a call to a remote service as part of the processing of the output.

In Drupal 7, I'm pretty sure that the filtered output of an input filter was cached by default, but I'm finding in D8 that it is not being cached, and the content is being passed through the filter on every page load.

I've tried setting the generated text with FilterProcessResult::setProcessedText(), however it's still being loaded.

Code:

class FilterRemoteUrlTitle extends FilterBase {

  /**
   * {@inheritdoc}
   */
  public function process($text, $langcode) {
    $result = new FilterProcessResult($text);

    // Do some stuff to $text (not shown)

    // Set the processed text.
    $result->setProcessedText($text);

    return $result;
  }
}

Any ideas?


texts: How can I send emails with drupal_mail() and hook_mail()?

texts:
I have this code for send a simple notification email.
function mymodule_commerce_checkout_complete($order){
  $buyer = user_load($order->uid);
  if(in_array('wholesale', $buyer->roles)){
    $params['buyer'] = $buyer;
    $params['order'] = $order;
    drupal_mail('commerce_mayoreo_workflow', 'new_order_mayoreo', 'myemail@gmail.com', user_preferred_language($buyer), $params);
  }
}

This is the hook_mail() implementation.
function mymodule_mail($key, &$message, $params){
  switch ($key) {
    case 'new_order_mayoreo':
      $langcode = $message['language']->language;
      $message['subject'] = t('New Quote request', array('langcode' => $langcode));
      $message['body'][] = t("New Quote request has been created\n\nYou can download the CSV format of the request here:\n\nhttp://bbheperfumes.com/download-order-csv/@order_id",array('@order_id' => $params['order']->order_id), array('langcode' => $langcode));
      break;
  }

}

It's not sending the email, and Im checking in recent log entries and there is not anything about a failed delivery, anything about system tried to send a mail.
I could not figure out why it's not sending the email, so I want to ask if mimemail has something to do with this issue?
I just have the MimeMailSystem in the 2 first select lists that are displayed in the configs of mail system.
By the way, I am using a fresh install of Commerce Kickstart.


texts: How to get a custom block form in another custom block?

texts:
I have a custom block
/**
 * Provides block A.
 *
 * @Block(
 *   id = "block A",
 *   admin_label = @Translation("Block A"),
 * )
 */
class Block A extends BlockBase implements ContainerFactoryPluginInterface {

  public function defaultConfiguration() {
    return [some_value]
  }

  public function blockForm($form, FormStateInterface $form_state) {
    // Configuration form
  }
}

Now I have another block
/**
     * Provides block B.
     *
     * @Block(
     *   id = "block B",
     *   admin_label = @Translation("Block B"),
     * )
     */
    class Block B extends AnotherClass {

      public function defaultConfiguration() {
        return [some_value]
      }

      public function blockForm($form, FormStateInterface $form_state) {
        $form = BlockA->buildForm()
        return $form;
      }
    }

The AnotherClass extends BlockBase.
Is it possible to display the Block A configuration form in Block B?
Like $form = BlockA->buildForm()?
The problem with @Clive comment is that Block A is from the contrib module. So I can't change its base class.


texts: Theming / modifying the markup of default search block form

texts:
I'm trying to modify the basic search block form that comes with Drupal 7 core. I have a custom theme and inside my templates folder I copied the search-block-form.tpl.php and modified it like so

<form action="/fi" method="post" accept-charset="UTF-8" class="ng-pristine ng-valid form-inline" novalidate role="form">

        <input
            title="<?php print t('Type in your search terms'); ?>"
            type="text"
            name="search_block_form"
            value=""
            maxlength="128"
            class="form-text" />

    <?php print $search['hidden']; ?>

<button
    type="submit"
    name="op"
    class="btn btn-default">

</button>

But when I look my rendered markup on page it is totally different.

<form action="/fi" method="post" id="search-block-form" accept-charset="UTF-8" class="ng-pristine ng-valid">

            <input title="Type in your search terms" type="text" name="search_block_form" value="" maxlength="128" class="form-text">

    <input type="hidden" name="form_build_id" value="">
    <input type="hidden" name="form_id" value="search_block_form">

<button type="submit" name="op" class="btn btn-default">

</button>

</form>

Why is there an extra div inside the form and where is my form-inline class and who put that id on my form? Why isn't my markup rendered as I wrote it? I also tried to remove all unnecessary preprocessing by overriding xxx_preprocess_search_block_form and xxx_form_alter but nothing seems to work.

And yes I have tried to clear theme cache many times.

This is driving me insane about Drupal. All this "magical" stuff that keeps happening when I'm trying to accomplish even the most simplest templating tasks. Could someone please explain what is going on? Thanks!


texts: If two modules both defined the same menu path in 'hook_menu', which one Drupal will choose?

texts:
For example, "moduleone" defines the path 'admin/hello', which output print_moduleone_stuff().

/**
 * Implements hook_menu()
 */
function moduleone_menu() {
  $items['admin/hello'] = array(
    'title' => 'Module One Hello World',
    'page callback' => print_moduleone_stuff,
  );
  return $items;
}

"moduletwo" defines the path 'admin/hello', which output print_moduletwo_stuff().

/**
 * Implements hook_menu()
 */
function moduletwo_menu() {
  $items['admin/hello'] = array(
    'title' => 'Module Two Hello World',
    'page callback' => print_moduletwo_stuff,
  );
  return $items;
}

Both modules defined 'admin/hello' path for different result. With these two module enabled, how does Drupal select one than another? How does Drupal solve the conflict?


texts: How to get $nid inside hook_menu_alter function

texts:
I'm trying to show or hide a menu tab based on whether my node meets a certain condition. In my hook_menu_alter I can't seem to get the $nid even though I was under the impression that the menu_alter fired after node load...

I've been googling for a day now and trying different solutions, but just can't seem to access the $nid.

When I print arg(0) or $_GET['q'] I get the result "admin_menu/flush-cache" instead of "node/62" even though I'm on a node page... what am I missing?


texts:
The social button module allows us to use tokens so the share button can target the node url instead of the page url, when we are using views to display content. However, I'm not sure how the code and tokens should be used to achieve this.
My code for the addthis button is as follows:

The code I'm currently using (as shown above) shares the entire page instead of the node which the button is attached to. Social buttons module allows the addition of a field to the content type so the button is tied to the particular content node and I'm trying to get the button to share the content in the node rather than the page, which is a view listing.

So my question is, how do I use tokens in the code for the share button?


texts:
I'm trying to render one div before another.

I've tested the js on my local machine to make sure it works by creating a simple page. The code is as follows:

<!DOCTYPE html>

IMAGE

BODY

I've added the following code to a js file on my Drupal site:

(function ($, Drupal, window, document, undefined) {

    $('.content .body').insertBefore('.content .field-name-field-image-one'); // check before() examples

})(jQuery, Drupal, this, this.document);

My .info file links to the js and it is loading. Other elements that require javascript are working too. I've even tried adding the script in the html.tpl file, but that did not work either.

The divs I am trying to affect are nested deep within the html markup, and have several classes applied to them, compared to the simple version I have made. Could that be the reason? Am I not being specific enough?


texts: Field that links to a path/url defined with Tokens, is it possible?

texts:
I would like to create a few fields in a content type that will link to certain paths defined with Tokens, in my particular case the node author uid. I am using a number of user related modules including Flag, User Relationships, Heartbeat etc which define user specific paths for a number of tasks that users can do (eg. view their flagged content, manage their relationsships etc). Hence my need to use Tokens to define the paths as oppose to just writing the static path myself. The paths would need to be auto generated for each node based on the Tokens, like Pathauto except for field links.

The Link module would be perfect for this, but in my experience, it does not fully support Tokens for the url. Are there any alternatives?


texts: I am trying to setup a site within lando and need to import the database. How do you import a database through lando?


texts: How to change programmatically exposed filters in views

texts:
I have a page view with exposed filters. One of the filters is term vocabulary, and that's dropdown list, user can select only one category (term).

I want to set programmatically one term from dropdown list when I came from specific URL. I tried with views_query_alter where $category is tid.

 $set_exposed_input  = array();
 $set_exposed_input['field_category_tid'] = $category;

 if ($set_exposed_input) {
    $view->set_exposed_input($set_exposed_input);
 }


texts: ImageFlow module doesn't find its library in Drupal 7

texts:
I have downloaded and installed ImageFlow module and also the library library from here and placed its content in \sites\all\libraries . this is screenshot:

but when I'm trying to enable ImageFlow it reports this error:

You need to install the Imageflow library. The js file should be readable at sites/*/libraries/imageflow/imageflow.js. You can find the library at http://finnrudolph.de/ImageFlow/Download. (Currently using Imageflow library Library required for Imageflow)

imageflow.js is in the directory. I have tested both uppercase and and lowercase for ImageFlow directory but it doesn't work. why it doesn't find the ImageFlow directiry in /libraries?


texts: How to use custom block view mode in View?

texts:
We have a custom block type block_countries and we are using a View(my_view_custom) to display the all the blocks where type = block_countries. Under block_countries view mode, we setup a "Full" view mode where we display certain information.

The view is displayed as a block and placed into a region (i.e. content region) from the theme. We want to style the block_countries "Full" view mode and setup a preprocess hook to do some processing, however we cannot find the way to do this.

We need help figuring out the proper twig template and preprocess_hook to call in order to get the desired out below. How can we do this?

Block type fields (block_countries):

body
language
country (Entity reference: taxonomy term)

Full view mode (fields shown):

body
country

View settings:

Format = unformatted list
show: custom block: Full (where full is the view mode)
Filter Criteria: custom block : block type = block_countries

We have tried the following but they do not work

Twig

views-view-unformatted--my-view-custom--block-1.html.twig

Hooks

mytheme_preprocess_views_view(&$vars)
mytheme_preprocess_views_view__my_view_custom(&$vars)

Desired output (per row returned from view):

<div data-country="{{ country }}"> {{ body }} </div>


texts: List all tags associated from specific content type only?

texts:
I'm trying to make a view which is listing all taxonomy tags associated from nodes of a specific content type only.

How can I make this?

I can make a view which is listing all taxonomy tags, but I can't figure out how to filter it with a specific content type only.

Any ideas?

\Thomas


texts: Why is my theme library load on every page?

texts:
I'm beginning with D8, but I work a lot with D7 and Magento. I follow the developer documentation to add a library in my theme, and I don't understand why it's loading it on every page. I only want attach it to a brunch of page with a preprocess hook. Could you help me please?

In my theme.libraries.yml I add this at the end:

hover3d:
  js:
    js/hover3d.js: {}

In my theme.info.yml I add under libraries "theme/hover3d".

Here is specific information:

I deactivated JavaScript/CSS compression in the back office and in my settings.local.php file
My theme is a sub theme of bootstrap_barrio
My Drupal version is 8.6.3
There is no custom / contrib modules yet
I discover it by inspecting my page

I don't really understand how JavaScript parts are loaded, but I suppose it's with lazy builders which are called placeholder and in D8 for rendering JavaScript there are two (or more) which are js-placeholder and js-bottom-placeholder. I see in my HTML structure that in the js-placeholder is only loaded modernizer and in the js-bottom-placeholder all the others. I don't know if this is a correct JavaScript rendering procedure, so I keep it here if it can help you.


texts:
From time to time, there will be minor and major updates to Drupal core. If the release is designated as a security update, we should apply the update as soon as we can. Otherwise, we may choose to apply the update at any time to receive the bug fixes it contains. There are also major release upgrades; we may want to apply these, so we have all the new and powerful features.

How do I upgrade using GIT?


texts:
I'm use YSlow to optimize my web pages it says:
This page has 34 external Javascript scripts. Try combining them into one.
This page has 5 external stylesheets. Try combining them into one.
but all I have in this page is some blocks and menus and a nivo slider which I think is the main reason of this issue!!
so I think nivo slider sends all this requests!!
How can I improve it?


texts: drupalSettings object not showing for anonymous users. core/drupalSettings is added as a library dependency

texts:
I'm stumped on this one. I’m having an issue where the drupalSettings object is empty when not logged in. Works fine when I am authenticated. - core/drupalSettings is in theme’s *.libraries.yml file.

I've tried

Cleared cache (1million times).
Triple checked the YAML indentation
Verified that the settings are being added when stepping through via Xdebug
The JS file that I'm adding is via ['# attached'] works great

What am I missing here? Where to start troubleshooting? I'll owe  if someone can help point me in the right direction.

themename.libraries.yml

views-load-more:
  js:
    js/views-load-more.js: {}
  dependencies:
    - core/drupalSettings

In my themename.theme

function themename_preprocess_views_view(&$variables) {
  if (!empty($variables["pager"])) {
    $view_selector = '.view-' . $variables["id"] . '.view-display-id-' . $variables["display_id"];
    $view_content_selector = $view_selector . ' .view-content';
    $view_pager_selector = $view_selector . ' .pager';

    $variables["view_array"]["#attached"]["library"][] = 'themename/views-load-more';
    $variables["view_array"]['#attached']['drupalSettings']['themename']['viewsLoadMore']['viewSelector'] = $view_selector;
    $variables["view_array"]['#attached']['drupalSettings']['themename']['viewsLoadMore']['viewContentSelector'] = $view_content_selector;
    $variables["view_array"]['#attached']['drupalSettings']['themename']['viewsLoadMore']['viewPagerSelector'] = $view_pager_selector;
  }
}

Note that the themename/views-load-morelibrary does get attached when anonymous (I can see the JS file within it).

And also note that this works perfectly when authenticated. This tells me that the drupalSettings dependency isn't working even though I'm declaring this.

How do I troubleshoot this?


texts:
I'm trying to add "fa" language in a Drupal 8 installation. I added it from admin/config/regional/language. Everything is OK and the language added successfully and added in language switcher in front-end. But when I click on it, I get this error:

InvalidArgumentException: Invalid translation language (fa) specified. in Drupal\Core\Entity\ContentEntityBase->getTranslation() (line 748 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).

Note: This is not a clean installation. The Drupal I have is a working site with some modules which I want to add Persian as its 6th language. Any suggestions?

Thanks.


texts: Creating 'index' content views for L1-LX within a taxonomy

texts:
Note: This is a follow-on question from Creating a displayable 'index' of content nodes within a path

Ok, starting to find my feet again within Drupal, and still getting up to speed with views.

What I'm needing help with

How do I update my view for /documentation, to display the results in a proper HTML ordered and numbered list that follows the taxonomy structure? (i.e. 1. SOP, 1.1 HR and People, 1.2 HACCP, and so on)
How do I then easily duplicate the view's functionality to the L2, L3 and beyond, so this kind of display runs at every level of the taxonomy when it is accessed - i.e. /documentation/hr-people, /administration/fleet/maintenance etc. Does doing this require a content view to be created for every single level/tree in my Content zone taxonomy (which I would think is cumbersome and laborious), OR is there a way to have only a single view with the intelligence to know what page it's being run on within the taxonomy and only display the relevant results at that level?

(I hope the way I've framed this question and the supporting materials below make perfect sense)

Explanation

Following on from the assistance of Hodba Khalaf, I've been able to create my documentation taxonomy (called content zone) for my site, which looks a little something like this:

I've also been able to create a View (called Content zone), targeting the Content zone taxonomy:

This works fine at L1 (/documentation) - with the exception that I'm not entirely sure how to make display the resulting information in an ordered and numbered list relevant to how the taxonomy is laid out, rather than the alphabetical order in which it is displayed.

And from there, clicking on one of the links for a L2 within my taxonomy (say /documentation/marketing) will show all the content assigned to that L2 within the taxonomy; but won't show the L3 headers and links (i.e. /documentation/marketing/advertising, /documentation/marketing/email-waf) of the taxonomy associated with the L2 of Marketing

I hope what i'm trying to achieve has made sense, and appreciate all and any help to point me in the right direction for achieving this.


texts: Redundant log settings between Drupal and Apache

texts:
I'm trying to discover how I can reduce the redundant logs (PHP errors, Drupal messages, debug logs, whatever) that are stored in Drupal's database and in Apache's log folders. I'm primarily a designer, certainly not a sysadmin, but I'd like to use whatever logging methods are most efficient, from a performance perspective as well as a disk space perspective.

I'm not sure if it is relevant to this issue, but I am using Drupal 6.

Is there anywhere I can find an ideal configuration for what to log on which of the two systems? If not, how can I find out exactly what is being logged in which locations, and how to turn off one or the other?


texts: Why I've got Fatal error of undefined validation function in my form?

texts:
I get the error in below code, it is strange, why it occurred?

In hook_menu

$items['share/%'] = array(
    'page callback' => 'drupal_get_form',
    'page arguments' => array('ym_alter_sharing_content'),
    'access callback' => 'user_is_logged_in',
    'type' => MENU_CALLBACK,
);

and:

function ym_alter_sharing_content($form, $form_state) {
  module_load_include('inc', 'node', 'node.pages');
  $nid=arg(1);
  $form = node_add('share');

  //$form['field_nid']['und'][0]['value']['#value']=$nid;
  //$form['#submit'][]='ym_alter_sharing_submit';
  //form_load_include($form_state, 'inc', 'node', 'node.pages');
  return $form;
}

but it return me:

  Fatal error: Call to undefined function node_form_validate()

Where is the problem?


texts:
I have managed to cause this error while working with exposed filters weighting in views.
Any idea how I can correct it? I am running Sqlite for database. Is it possible to clear transactions or something?
Thanks

Additional uncaught exception thrown while handling exception.
Original
PDOException: SQLSTATE[HY000]: General error: 1 cannot rollback - no transaction is active in node_save() (line 1152 of /home/site/public_html/modules/node/node.module).
Additional
PDOException: There is already an active transaction in dblog_watchdog() (line 154 of /home/site/public_html/modules/dblog/dblog.module).


texts: I downloaded the social media module and I found this token: [socialmedia:sm-twitter_username]. I want to show it where the Read more / Add new comment section is, under an article. Since I can't find a block that is for that sections how can I just insert it into the code?


texts: How to replace flag text with custom icon?

texts:
I am using flag and views to show a "like" flag in a view. The machine name of my flag is "like". I want to replace the text of the flag with a heart icon. When it is not flagged, it is empty and when flagged, it is filled with red color as happens generally. I do not want to show icon besides text and neither I want to transform my flag into a button. If you have used instagram, you must know that there is a heart icon for a "like" flag. When someone clicks it, it becomes red. Like when you favorite a tweet on twitter.

I found this code, but do not know how to use it for my case. I am not sure whether it is the right code to use.

function Your_theme_preprocess_flag(&$vars) {
  $class = ($vars['action'] == 'flag') ? '<i class="fa fa-heart-o">   </i>' : '<i class="fa fa-heart"></i>';
  $vars['link_text'] = $class;
  $title_wishlist = ($vars['action'] == 'flag') ? 'Add to wishlist' : 'Remove from wishlist';
  $vars['link_title'] = $title_wishlist;
}

Note: I know I have to put it in template.php file of my theme. If you see the post, I took this code from there, but I have multiple flags on my site for example "like" "follow" "bookmark" etc etc. So I want to use this code for the "like" flag. How can i do that
I am also interested in learning how to add any icon other than heart and any flag I want.


texts: hook_views_query_alter does not work when filters get applied

texts: I used the function hook_views_query_alter and altered the sql to get desired result. This works fine when the view loads for the 1st time. I have some exposed filters also. As soon as i apply exposed filers, the query alteration does not happen. Anything i have to do, if exposed filters have been applied..?


texts: How to add menu links to a node created within a test?

texts:
I want to create a test where a few nodes are created, and on those nodes are menu links.

The most I have found so far is:

    $options = array(
      'menu_name' => 'menu_test',
      'bundle' => 'menu_link_content',
      'link' => [['uri' => 'internal:/']],
    );
    $link = MenuLinkContent::create($options);
    $link->save();

How do I tie it and the node together? Just provide the node uri in the 'link' property? Would that just be internal:node/(nid)?


texts: Pre-Populating a CCK Flexifield/Multigroup?

texts:
I'm using a repeating fieldset module (Flexifield, somewhat similar to CCK3 Multigroup) to create a measurement sheet content type. In this, the user is allowed to create an unlimited number of rooms, each defined by five fields: name, level, width, length, area.

It would be really useful to pre-populate about ten of these rows (e.g. "Kitchen," "Bathroom," "Living Room").

How would one go about programmatically creating and filling CCK fields with number of values set to "Unlimited"?


texts:
I need to send asynchronous and non-blocking POST HTTP requests from a Drupal service.

Using Drupal 7, I used HTTP Parallel Request which worked fine.

But this module is not available on Drupal 8. And it seems that the default D8 HTTP Client, Guzzle, doesn't allow to do this : https://stackoverflow.com/questions/35956516/send-asynchronous-request-without-waiting-the-response-using-guzzle.

Is there some way I can achieve that with Drupal 8 ?

Edit: If I don't find how to do it with Drupal mechanisms, I will go with this fsockopen...


texts:
We have a view that displays indexed nodes and we would like to add the ability to filter by proximity to a user-input zip code.

I know this can be achieved with Solr and the Search API Location module (https://www.drupal.org/project/search_api_location) but we are not using Solr.

Is there some other way to implement a proximity search on indexed nodes?


texts: How can I rewrite an "edit" operations link in Views?

texts:
On Drupal 8, I'm trying to modify /admin/people to have the edit button read  edit username instead of edit.

What's the easiest way to do this?


texts:
Working in the issue queue on any busy project can be quite a bit of work.

Lots of files (patches) to manage, interdiffs, and ideally a branch for piece of work, moving patches forward with rebase etc.

What (if any) automated workflows are there to ease these tasks? This could either be code, such as some form of git wrapper, or perhaps just an explanation of how to use existing tools.


texts: Omit blank lines when trimming fields with views

texts:
I have made a views gets the body field and select:
    Formatter ->summary or trimmed

but the field have blank lines which calculated in the length so I may get empty.

Despite selecting  Remove whitespace but still count the blank lines as it is full of text and so I get empty preview.

Please help .

thanks


texts:
In a custom module I have defined a display suite field like so:

namespace Drupal\custom_dsfields\Plugin\DsField;
use Drupal\ds\Plugin\DsField\DsFieldBase;
//Views
/**
 * Plugin that renders the field.
 *
 * @DsField(
 *   id = "total_hours",
 *   title = @Translation("Total hours"),
 *   entity_type = "node",
 *   provider = "custom_dsfields",
 *
 * )
 */
class MyField extends DsFieldBase
{
    /**
    * {@inheritdoc}
    */
    public function build(){

        $node = \Drupal::routeMatch()->getParameter('node');
        $entities = [];
        $hours = [];
        foreach ($node->field_hours as $key => $value) {
            array_push($entities, $value->target_id);
        }
        $entities = entity_load_multiple('user_entities', $entities, $reset = FALSE);
        foreach ($entities as $key => $value) {
            array_push($hours, $value->field_hours->value);
        }
        $hours_sum = array_sum($hours);

        return array(
            '#markup' => 'Total hours for this day ' . $hours_sum . ''
            // '#theme' => 'item_list',
            // '#items' => $hours_sum
            );
        }
    }

In the default display this works perfect. (open to improvements
But when I use a view, and display the teaser display with this field in it then the field is not working. Why is this?

Some things I am questioning...

Am I loading the node in the correct way as I am not entirely sure what routeMatch() is doing.
Should I be doing this in a view template (hope not)

Thanks DSE!


texts: how to make a content type that ties to the user and user can only add one?

texts:
Drupal 8

So I want users to add a actor profile or crew profile or both.
I am thinking both would be content types.  The user should only be able to add one of each and it ties to the user.

Anyone know how I would do this?


texts: AJAX: Form API Dependent Drop Down with more options

texts:
Started with the example here:
https://api.drupal.org/api/examples/ajax_example!ajax_example.module/function/ajax_example_dependent_dropdown/7

However, I then wanted to add a third option that was depended on the first two (which is not in the example given)

The problem I first ran into was that when I updated the first dropdown it would update the second, but not the third.

So I changed the callbacks from

function ajax_example_dependent_dropdown_callback1($form, $form_state) {
  return $form['dropdown_second'];
}

and

function ajax_example_dependent_dropdown_callback2($form, $form_state) {
  return $form['dropdown_third'];
}

to

function _ajax_example_dependent_dropdown_callback1($form, $form_state) {
  $commands[] = ajax_command_insert('#dropdown-second-replace', drupal_render($form['dropdown_second']));
  $commands[] = ajax_command_insert('#dropdown-third-replace', drupal_render($form['dropdown_third']));
  return array('#type' => 'ajax', '#commands' => $commands);
}

function ajax_example_dependent_dropdown_callback2($form, $form_state) {
  $commands[] = ajax_command_insert('#dropdown-second-replace', drupal_render($form['dropdown_second']));
  $commands[] = ajax_command_insert('#dropdown-third-replace', drupal_render($form['dropdown_third']));
  return array('#type' => 'ajax', '#commands' => $commands);
}

Which got me most of the way, but I still have one problem left.  It seems that when I update the first dropdown, it updates the options in the second box but doesn't send the updated value into my options function to get the new options for the third box.

Here is my code:

function cquiz_create_exam($form, &$form_state) {
  $subjects = _cquiz_get_subjects();
  $selected = isset($form_state['values']['dropdown_first']) ? $form_state['values']['dropdown_first'] : $subjects[key($subjects)];

  $form['dropdown_first'] = array(
    '#type' => 'select',
    '#title' => 'Select Subject',
    '#options' => array_unique($subjects),
    '#default_value' => $selected,
    '#ajax' => array(
      'callback' => '_cquiz_create_exam_callback_first',
      'wrapper' => 'dropdown-second-replace',
    ),
  );

  $type = _cquiz_get_type($selected);
  $selected2 = isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : $type[key($type)];

  $form['dropdown_second'] = array(
    '#type' => 'select',
    '#title' => t('Exam Type'),
    '#prefix' => '
',
    '#suffix' => '
',
    '#options' => _cquiz_get_type($selected),
    '#default_value' => isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : '',
    '#ajax' => array(
      'callback' => '_cquiz_create_exam_callback_second',
      'wrapper' => 'dropdown-third-replace',
    ),
  );

  $form['dropdown_third'] = array(
    '#type' => 'select',
    '#title' => t('Number of Questions'),
    '#prefix' => '
',
    '#suffix' => '
',
    '#options' => _cquiz_get_number($selected, $selected2),
    '#default_value' => isset($form_state['values']['dropdown_third']) ? $form_state['values']['dropdown_third'] : '',
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}

In the $form['dropdown_third'] section you can see that the options are defined by another function.  That function doesn't get redone after changing the first drop down box.  How do I get it to reload those options using the new select values?


texts: Is it possible to add multiple fields within a single component?

texts:
$form['value'] = array(
        '#type' => 'textfield',
        '#title' => t('Webservice URL'),
        '#default_value' => $component['value'],
        '#description' => t('The default value of the field.'),
        '#size' => 60,
        '#maxlength' => 1024,
        '#weight' => 0,
    );

I want to make a second textfield in my component where I can specify the second part of my Webservice URL and then concatenate them in my rendering. How can I add a second textfield to my webform_edit?


texts: Views does not show all images (as a field)

texts:
I use Drupal 7 and Views module.
I make Content views with several fields, one is image. I set medium image style (220x220) for it.
Views generates 12 items in one page (12 images) and not all images are visibles. Some of them are missed. If I reload the page - another become missed.
I use Chrome as a browser.

Additional information

The problem stil not solved. I think that reason is that Imagecash (I use drupal 7, so it is built inside) does not have enought time to resize all images which I want to show in Views page. Each originakl image is in its own size, but I ask Views to show them all like 220 by 220.
So when I render views, some images are not shown (Chrome can not find 220 by 220 picture, because Imagecash did not do it), but then I refresh page - Imagecash do not need to convert all pictures again, it just convert some, that were not ready in previous time. So they become visible in my View.

How to fix it?


texts: Multiple submits form and Ajax: Select which submit button is triggered

texts:
As I can't find a way to split a Drupal Commerce pane into several forms (so far it creates several field-sets) I had to create several submit buttons in the same form. But it's the same submit button that always gets triggered.

I have these 2 "forms":

- Field 1.1
- Field 1.2
-> Submit 1

- Field 2.1
->Submit 2

I believe this would not be a problem if I would not use ajax to submit the forms, but I do by using 'event' => 'click' so that the form is submited when ENTER is pressed.

My problem is that if I press ENTER from the field 2.1 it's the Submit 1 that gets triggered.

Any idea on how to select the right submit button with the click event?


texts:
I'm looking at migrating a site to Drupal. This site is an interactive site where selector controls in two side bars control the content in the main content area. So there's flash games in the main area, and there is a main 'menu' on the left sidebar, which controls which game is in the main area, and then there's a 'control panel' on the top bar which has some additional select boxes which also change the main content. All these changes happen through AJAX calls.

What module(s) should I use to re-create this functionality? I was thinking of making the controllers blocks, and the games pieces of content. So what should I use to have a block control the display a piece of content? Something that implements standard AJAX calls?


texts: How to delete the bulk of custom data when the associated user is deleted

texts:
I'm one of the maintainer of Statuses(Social Microblog), As of now we are storing the status messages and comments to it in custom tables. We are also having hooks which needs to be invoked for the deletion of every status message,

Since this just  a status update, we will have bunch of messages(even 2k+ also possible) associated with one user.

So when the user is deleted, we need to delete all the status messages and comments associated to that user. The problem I could see that I need to perform these deletions in hook_user_delete, so if I have more number of deletions it may give timeout error and also I need to consider performance here.

If I directly loop through the status messages to delete one by one then it will be a hectic process, because when a status message is deleted it needs to invoke several hooks.

I want a guidance on handling this situation.


texts:
I have a really strange issue occurring within a view I've created. I have the same code base on two servers, one is a stage server one is on a Vagrant instance on my local machine.

The view displays messages for a user (the UID is retrieved from the currently logged in user via a contextual filter). If I pass the UID of a user I know has messages into the contextual filter preview box in the Views admin panel while logged in as root then the view returns a record. If I try the same with another user it does not even though I am specifying the same UID, and the other user has the "administration" role checked in their profile so they should have the same permissions.

Does anybody have any ideas as to what may be causing this? I have a feeling it's something to do with configuration as like I said, the code base is mirrored yet works on one site but not the other.


texts: How much time does it take to manage sites within a multisite architecture as compared to multiple single installs?

texts:
A service my company offers is similar to managed hosting where we help keep a server, Drupal, related modules, and backups up to date on behalf of clients who can't or don't want to do that in house, and typically this averages out to be about 30 to 90 min of work per site per month.
A client has asked me to manage their entire portfolio of 70 Drupal sites, all of which are part of a multisite architecture with site files on one server and DB on another.
I can't imagine that this is 70 hours of work, but I'm not familiar enough with multisite installs of this size to understand fully what this would entail.
To ensure that I estimate time correctly, what would I need to take into consideration when comparing management solutions for single server / single site installations as compared to the same number of sites in a multisite installation?


texts: Cannot edit my views.. I get a JSON string?

texts:
I'm using Drupal v7.22 and whenever I try to Modify the Display on views, and press the 'Add and configure' button on adding a field, or any button that sends data to the server, the page reloads and I just get a long JSON String returned in Chrome, or IE will try to download the return...  Sometimes it'll accept my change, but more often than not, it won't.

It was doing this on 7.21 and then I updated to 7.22 and it stopped for a day or two, now it's doing it again.  I am extremely new to Drupal, but I am a quick learner and most things are going smoothly.

What did I break and how can I fix it?


texts: views.view.unformated.html.twig taxonomy conditional if/else

texts:
I am trying to get to the field_news_type term_id/label. I can print the field and I get the term label. Need guideance to be able to select which one I want to use.
{{ fields.field_news_type.content }} //prints the term 'Grid 2' which is correct.

I am trying to get either the label or term_id, so I can do a conditional. The below does not work. I have tried many variations. I have not found an answer that has produced a working result. Can someone guide me to finding the correct way to print this out in a views template page?
{% if fields.field_news_type.target_id == '2871' %}

I can use this for a node template page and it works...but not in the views twig file.
{% if content.field_research_focus_areas['#items'].getValue() %}


texts:
I manage a Wordpress site for a football team, and I created therefore a SQL Query to calculate the standings.
Now I want to switch over to Drupal and for the calculation of the standings I thought to use the views module. Is it possible to integrate my SQL Query into Views?

Query :

$sql="SELECT
  teamname AS Team, Sum(Played) AS Played, Sum(Won) AS Won, Sum(Draw) AS Draw, Sum(Lost) AS Lost,
  SUM(Gfor) as Gfor, SUM(Gagainst) AS Gagainst, SUM(Gdiff) AS Gdiff, SUM(Pts) AS Pts

FROM(
  SELECT
    teamhome Team,
    1 Played,
    IF(homescore > awayscore,1,0) Won,
    IF(homescore = awayscore,1,0) Draw,
    IF(homescore < awayscore,1,0) Lost,
    homescore Gfor,
    awayscore Gagainst,
    homescore-awayscore Gdiff,
    CASE WHEN homescore > awayscore THEN 3 WHEN homescore = awayscore THEN 1 ELSE 0 END Pts
  FROM matches
WHERE homescore IS NOT NULL AND awayscore IS NOT NULL
AND division='1' and season = '2015-2016' AND matchtype='C'
  UNION ALL
  SELECT
    teamaway,
    1,
    IF(homescore < awayscore,1,0),
    IF(homescore = awayscore,1,0),
    IF(homescore > awayscore,1,0),
    awayscore,
    homescore,
    awayscore-homescore Gdiff,
    CASE WHEN homescore < awayscore THEN 3 WHEN homescore = awayscore THEN 1 ELSE 0 END
  FROM matches
  WHERE homescore IS NOT NULL AND awayscore IS NOT NULL
  AND division='1' and season = '2015-2016' AND matchtype='C'
) as tot

JOIN teams t ON tot.Team=t.teamid
GROUP BY Team

ORDER BY SUM(Pts) DESC, Sum(Won) DESC, SUM(Gdiff) DESC";


texts: Custom PHP code as a Panels selection rule

texts:
Panels allows selection rules to be created with custom PHP code (disclaimer: I know this approach is insecure and should be avoided).

When adding PHP code as a selection rule, the helpful description states:

  Access will be granted if the following PHP code returns TRUE. Do not
  include . Note that executing incorrect PHP-code can break
  your Drupal site. All contexts will be available in the $contexts
  variable.

I made a function in a custom module to use for the selection rule:

function mymodule_selection_rule_is_location_set() {
  global $user;
  $user_fields = user_load($user->uid);
  if (isset($user_fields->field_acc_location['und']['0']['lat'])) {
    $location = $user_fields->field_acc_location['und']['0']['lat'];
  }
  if (empty($location)) {
    return FALSE;
  }
  else {
    return TRUE;
  }
}

However, when I set the selection rule as shown below, the selection rule is not triggered even when there is a value for $location and the function returns TRUE (confirmed with devel module).

Evaluates false as a selection rule even when the function returns TRUE

mymodule_selection_rule_is_location_set()

To get it to work, I had to write the selection rule like this:

Evaluates correctly

if (mymodule_selection_rule_is_location_set()) {
  return TRUE;
}

My question is why do I have to write it like the latter rather than the former?


texts: How to make the content fills the space after the sidebar ends in a drupal site?

texts:
The client I work for won't accept the fact that the sidebar region continues until the footer. If that happens, the client wants the sidebar to stop when the sidebar content is finished, and the main content should fill the space that the sidebar is using now.

How to make the content fill the space after the sidebar ends in a Drupal site?


texts: How to add a javascript function after uploading file

texts:
I make a form using FAPI, and this form contains a file managed field. I want to show an alert after uploading the file ("uploaded successfully"), and a confirmation ("Are you sure you want to delete file") when deleting the file.

This my code.

$form['my_file_fid'] = array(
  '#type' => 'managed_file',
  '#title' => t('Files'),
  '#default_value' => variable_get('my_file_fid', ''),
  '#upload_location' => 'public://',
);

I tried to add #file_value_callbacks, but I don't know how to use it.

I tried to make a javascript just to alert when I click upload,remove button but it doen not work I tried to make it general to all input to check that js is correct now all inputs are clickable but upload and remove button not

jQuery(document).ready(function() {
         jQuery('input').bind('click',function() { alert("hi") });
 });

I make this js to check jquery ajaxSuccess function


texts: How to show order total components in a block?

texts:
I would like to create a block that shows the current user's order totals including all components, as follows:

 - Subtotal
 - Discount or coupon
 - Sales tax
 - Total

I would be happy with a block that simply renders the footer of the shopping cart view. I've played around with commerce-line-item-summary.tpl.php, but it only renders the number of items in the cart and the total amount. It doesn't have to be a form, just a summary of the shopping cart totals.

I would like to show this block during the checkout process in a sidebar region.

Any ideas how to create this?


texts: How can we show the difference between values in consecutive rows in views

texts:
I am building a site where users will fill webforms (these are quality of life questionnaires). Users will fill the same form several times. I want to show the change in the value of fields in the webform. For example, if there is a field, say score 1 which has a value of 10 on 13 May 2020, and 15 on 14 May 2020, I want to show that the value has changed by 5 points.

I want to show this using Views as it will allow us to filter by dates on which the form was filled as well as the users (and use contextual / exposed filters).

The Views Aggregator field allows us to calculate the range for a column and using the a modified range formula (which the maintainer kindly developed very quickly) we can show the difference between two values. However, this is constrained to be displayed as a table row and not a field.It also has the disadvantage that the value is always maximum - minimum of the two values.

Is it possible that we can get this as a field in Views (so that I can apply custom css code). The motivation for doing this is to show the value in different colors depending on the value (e.g. red color if the value is more than 10 and green if it is less than 5).

It is noteworthy that each questionnaire can have many different scores computed and I would like to make a display for each. Note that for the display of the change we are looking for change of the recent value as compared to last filled.

Any pointers will be appreciated.


texts:
I'm building a sidebar for my taxonomy and node pages.

I've got it as

Show (View Setup): Taxonomy Terms
Unformatted List
Show: Fields
Relationship: Taxonomy term: Representative node

Fields:

Taxonomy term: Name
(Representative node) Content: Title

This works pretty well, each row starts with the taxonomy term name as a link and is followed by a node from that term. The trouble is, it'll only show the first node. How do I get it to display all nodes?


texts: Multiple billings for one user in one day for Monthly Recurring (Drupal commerce)

texts:
Our Monthly Recurring Billing has been working successfully for more than 1 year. However, there are two customers are charged multiple times on February 28, 2018, once an hour.  Other 3 customers (monthly recurring) are charged correctly on the same day.

The cron "commerce_recurring_cron" runs every hour, and created a new order of recurring billing for the same user.

ORDER NUMBER    UPDATED NAME    USER    TOTAL   ORDER STATUS
8181    February 28, 2018 - 6:43pm  J* C*   j*  $4.99   Completed
8182    February 28, 2018 - 7:09pm  J* C*   j*  $4.99   Completed
8184    February 28, 2018 - 8:09pm  J* C*   j*  $4.99   Completed
8186    February 28, 2018 - 9:11pm  J* C*   j*  $4.99   Completed
8188    February 28, 2018 - 10:11pm J* C*   j*  $4.99   Completed
8190    February 28, 2018 - 11:00pm J* C*   j*  $4.99   Completed
8192    March 1, 2018 - 12:00am J* C*   j*  $4.99   Completed
8183    February 28, 2018 - 8:09pm  L* L*   l*  $4.99   Completed
8185    February 28, 2018 - 9:11pm  L* L*   l*  $4.99   Completed
8187    February 28, 2018 - 10:11pm L* L*   l*  $4.99   Completed
8189    February 28, 2018 - 11:00pm L* L*   l*  $4.99   Completed
8191    March 1, 2018 - 12:00am L* L*   l*  $4.99   Completed

All above payments of orders are charge successfully in Authorize.net.

System: Drupal 7.56; Authorize.net Gate Way.
Related modules: commerce 7.x-1.13, commerce_recurring 7.x-2.x-dev, commerce_order 7.x-1.11, commerce_payment 7.x-1.11, commerce_authnet 7.x-1.4, commerce_cardonfile 7.x-2.0-beta5+3-dev.

I have spent days on doing research,  and debugging the Drupal log and system log.  But I can't find any useful info.
I cannot repeat the problem on our DEV site.

I will deeply appreciate it if someone knows some clues about it by chance.

Thank you very much!


texts: Can I hide date field if older than a certian time using Rules?

texts: I want to know if I can hide the values of a date field if the values are older than a certain time. The website is built with Drupal 7, and Display Suite.


texts:
Using Drupal 8.5 and Webform 8.x-5.0-rc10.

I want to programmatically change the confirmation URL on a temporary basis and have it not affect the original confirmation URL if the form is being rendered somewhere else. For example, on a particular node I want to render webform "my_form" and set the confirmation url to http://example.com whenever that node is displayed, but if that same webform is rendered on some other page I want the original confirmation URL to be in effect.


texts: enabling users to upload pictures from their harddrive in wysiwyg

texts:
I have wysiwyg module with IMCE enabled so I can browse the server of my site is located for pictures I can upload to add to my content. But the idea now is to have users that are bloggers to be able to upload pictures from their harddrive on to the site using a wysiwyg editor (in this case CKEditor).

Anyone experience with that and know how to do that or know of a good tutorial for this. When searching for an answer online I found info that explained how to add CCK fields to my content type but this is not what I want. I want bloggers to be able to choose where they put the pictures in text and how many.


texts: How do I preprocess templates in a theme file?

texts:
I have created two custom templates (header-before-login.html.twig and header-after-login.html.twig). I would like to get data from the database to pass to these templates using variables.

How can I overwrite this templates as preprocess in xyz.theme?

These are the paths of the files.

drupal/docroot/profiles/custom/project/themes/xyz/xyz.theme
drupal/docroot/profiles/custom/project/themes/xyz/templates/header-before-login.html.twig
drupal/docroot/profiles/custom/project/themes/xyz/templates/header-after-login.html.twig


texts: form API : date format is not applied in the input

texts:
I use the Form API to build forms in custom module.

Forms works fine but my custom date format is not applied.

Here is an extract of my form code :

$form['date_debut'] = array(
            '#type' => 'date',
            '#title' => $this->t('Date de début'),
            '#date_date_format' => 'd/m/Y',
            '#description' => t('Cliquez dans le champ et sélectionnez une date de début de congé dans le calendrier'),
            '#required' => TRUE
        );

The date format is d/m/Y

But i still see Y/m/d in the input :

In the DOM, the date format is d/m/Y data-drupal-date-format="d/m/Y"

<input type="text" data-drupal-selector="edit-date-fin" aria-describedby="edit-date-fin--description" data-drupal-date-format="d/m/Y" class="form-date required form-control hasDatepicker" id="edit-date-fin" name="date_fin" value="" required="required" aria-required="true">

When the form is validated, i display a message with the date picker value and the date format is Y/m/d

drupal_set_message($this->t('Vous avez choisi comme date de début : @date_debut', array('@date_debut' => $form_state->getValue('date_debut'))));

See :

Am i missing something? How can i modify this date format visible by the user in the input and in the Drupal message ?


texts: Can I control what caches are flushed via "Flush all caches"?

texts: I use the module Boost and anytime I click "Flush all caches" it deletes all the cached pages already built. Is there any way to make "Flush all caches" to flush all cache instead of the Boost-created .html.gz cached pages?


texts: Why are spaces in the file path rendered with %2520 instead of %20?

texts:
I have a custom content entity (service) with a 'file' field defined by:
$fields['file'] = BaseFieldDefinition::create('file')
  ->setLabel(t('File'))
  ->setSettings([
    'file_extensions' => 'pdf',
    'file_directory' => 'sel',
    'description_field' => TRUE,
  ])
  ->setDisplayOptions('view', [
    'type' => 'file',
  ])
  ->setDisplayOptions('form', [
    'type' => 'file',
  ])
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

A classic CRUD form allows me to create a service:

Lets say I upload a file with spaces in its name. As you can see if I hover the file name in the form, the link appears to be http://jdp8:8888/sites/default/files/sel/name%20with%20spaces.pdfwith space replaced by %20 and the link works:

So far, so good...
I have a View to display this content entity:

The 'file' field is rendered as a '•' with a link to the file that allows to open the content of the file (a .pdf file) in another window.
When the file name contains spaces, it is rendered as http://jdp8:8888/sites/default/files/sel/name%2520with%2520spaces.pdf with %2520instead of %20.
And of course the links leads to a The requested page was not found error.
I have recently updated Drupal to 8.9.13.
Before I was running Drupal 8.9.1 and I am pretty sure that it was working.
Any idea on what is going wrong? Is it Drupal? Is it Views?
As I suspect Views (everywhere else, it works), here is the way the file field is handled in the view:


texts: How to install a module from an archive file with drush?

texts:
To install a module available on drupal.org, I do drush dl modulename && drush en modulename. However, when I have module available as an archive file on my local disk instead (.zip or .tar.gz), how can I still use drush to install it?

The archive file could come from downloading a sandbox project snapshot, from a self-developed "custom made" module or similar.

I know I could unpack the module into sites/all/modules/, then enable it with drush en modulename. But I'm looking for nice scriptable commands to do both these steps with drush. (Bit silly, but I like to keep a drush workflow.)


texts: How do I select an image from a directory of images uploaded with the image field, in the same way done in Joomla?


texts:
Drupal 8.5 requires jQuery 3, which has some site breaking features. I would rather like to use version 2.2.4. I have tried the libraries-override approach suggested in How do I use a jQuery version different from the default one used by core? After applying that answer, the theme.libraries.yml file content is the following one.

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

jquery-custom:
  remote: https://github.com/jquery/jquery
  version: "2.2.4"
  license:
    name: MIT
    url: https://github.com/jquery/jquery/blob/2.2.4/LICENSE.txt
    gpl-compatible: true

global-scripts:
  js:
    js/plugins.js: {}
    js/drupal-main.js: {}
    js/vendor/modernizr-3.3.1.min.js: {}
    js/jquery-2.2.4.min.js: { minified: true, weight: -20 }

  dependencies:
    - core/drupal
    - core/jquery
    - core/jquery.once

The theme.info.yml file content is the following one.

libraries:
  - theme/global-styling
  - theme/global-scripts
libraries-override:
  core/jquery: theme/jquery-custom

However, it gives me a reference error saying that jQuery is not defined. I have checked the path and there is no problem there. What am I missing here?

Is there any other way to downgrade from jQuery 3 to jQuery 2 in Drupal 8?

I also tried using the following code, but I still getting a reference error.

jquery-custom:
  remote: https://github.com/jquery/jquery.js
  version: "2.2.4"
  license:
    name: MIT
    url: https://github.com/jquery/jquery/blob/2.2.4/LICENSE.txt
    gpl-compatible: true
  js:
    js/jquery-2.2.4.min.js: { minified: true, weight: -20 }

global-scripts:
  js:
    js/plugins.js: {}
    js/drupal-main.js: {}
    js/vendor/modernizr-3.3.1.min.js: {}


texts:
In order to get the Newsletter (Simplenews module) to send out emails correctly (in HTML format) I selected HTMLMailSYstem in the mail system settings. Having the DefaultMailSystem setting instead, does not work, in a sense that it only sends out plaintext newsletters, not html.

The status report however is giving me the following error:

Printer, email and PDF versions - Send by email
Incompatible Mail System setting detected
The send by email module requires the use of the DefaultMailSystem, please configure it in the Mail System Settings page.

Is it possible to have different mail system settings for different modules? Or is there another way for me to make this work?


texts: How to get a variable from FieldWidget in the same modules Template

texts:
I have module that is currently setup like this

module
  -signature.module
  -signature.info.yml
  -src
    -Plugin
      -Field
        -FieldWiget
          -SignatureWidget.php
  -templates
    -signature.html.twig

Everything in the module works correctly as is. I'm trying to pass a variable $field_name = $items->getName(); from SignatureWidget.php to signature.html.twig (or signature.module so that I can then pass it to signature.html.twig). I'm trying to do this in order to apply ids generated from a variable in the widget to some of the markup in the template. How would one do this?

I understand how to do this from the .module file (Use a twig template instead of a render array in a custom module admin page), but can't seem to figure it out when it comes to plugin variables.
The hook_theme in module associated with the widget looks like this.

function signature_theme() {

  $theme = [];
  $theme['signature'] = [
    'render element' => 'element',
    'variables' => array('sign_src' => ''),
  ];
  return $theme;
}

The widget code from SignatureWidget.php looks like this

<?php

namespace Drupal\signature\Plugin\Field\FieldWidget;

use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\ElementInfoManagerInterface;

/**
 * Plugin implementation of the 'field_signature_widget' widget.
 *
 * @FieldWidget(
 *   id = "field_signature_widget",
 *   module = "signature",
 *   label = @Translation("Signature Data"),
 *   field_types = {
 *     "field_signature"
 *   }
 * )
 */
class SignatureWidget extends WidgetBase {

  /**
   * {@inheritdoc}
   */
  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {

    $value = isset($items[$delta]->value) ? $items[$delta]->value : '';

    $file_upload_help = array(
        '#theme' => 'signature',
        '#sign_src' => $value,
      );
     $sign_thumb = array( '#type'   => 'html_tag',
                          '#tag' => 'img',
                          '#attributes' => array('src' => '', 'id' => 'signature_thumb', 'class'=>array('align-right'), 'width' =>'120px', 'height' => '60px' ));

$field_name = $items->getName();

    /*function getFieldName() {
      return $field_name;
    }*/

$text_area_id = 'signature_field_' . $field_name;

    $element += array(
      '#type' => 'textarea',
      '#default_value' => $value,
      '#attributes' => array(
        'id' => array('signature_data'),
                        ),
      '#attached' => array(
        'library' => array('signature/signature_pad'),
                        ),
    );
    $element['#attached']['library'][] = 'signature/signature_pad';
    $element['#description'] = \Drupal::service('renderer')->renderPlain($file_upload_help);
    $element['#suffix'] = \Drupal::service('renderer')->renderPlain($sign_thumb);

    return array('value' => $element);
  }

}

The template from signature.html.twig looks like this.

    <canvas width="450" height="200" class="sign-canvas">SIGNATURE CANVAS</canvas>
{% if(sign_src != '') %}

{% endif %}
     <button type="button" id="clear-sign" class="button clear" data-action="clear">Clear</button>

I'm trying to return the string value from $text_area_id in SignatureWidget.php from within signature.html.twig


texts: data export import module how to keep alias drupal

texts:
I found data_export_import module very useful, however. It does not import/export url aliases and block content. Why I could live without the block content, I really would like to have nice way to import/export url aliases. Which module or which approach would you recommend to handle import/export url aliases? the same for blocks.

Thank You.


texts: Pseudo-fields and custom entity properties from additional schema

texts:
I'm trying to add property information to an entity which uses the entity API. Working from the commerce_product module I am trying to manage additional information outside of fields and in my own database that ends up attributed with the resulting product object when the entity is loaded. I've been looking into the hook_entity_property_info_alter and hook_entity_load functions to get the additional custom or "pseudo-fields" loaded. I'm having issues when saving/creating the new entity (product) and information submitted from the form is not accessible. Am I supposed to alter the form and tack on an additional form submit handler? During a call to hook_commerce_product_insert I was expecting the $product object to have form field values included that I could work with. What would be the recommended way to approach this? I want to end up with data from my own database schema added to the entity and be editable through the entity's creation/edit forms.

I found this relevant solution but that approach deals with editing the original schema which is definitely something I want to avoid.


texts: Populate second node reference based on what first node reference is selected

texts:
I have 2 content types. Destinations content type and regions content type.  In regions content type i give reference to destinations node reference.

I am building another content type called product where i give node reference to Destinations and along with it i give node reference to regions content type.

My problem is that i need to filter out the regions(node reference to regions) drop down based on what destination is selected from previous destinations drop down.

So how do i do this ? please give me some idea for this. Hope my question is clear.


texts: Looking for a module similar to "Read and Understood" that I can use for Drupal 7

texts:
I would like to be able to create a "Book" on my site and have the users check each and every single page of the book they read; without being able to skip pages and locking them on the page they are.

I found the module Read and Understood to be good for this, however, it is only supported on Drupal 6.x.

I also found Sign for acknowledgement but does not have the "No return" functionality like Read and Understood" does ("No return" option so users are locked into their agreement).

Any idea of any other module that I could use instead, that is supported on Drupal 7.x sites?

Thank you!


texts: How to get term ID from translated term name?

texts:
I have a custom argument validator for Views, which expects a term name input and outputs the tid for the query. This works great in English, but I'm not sure what to do for translations. Is there any way to search for a term id from the translated term name?

Here's my code:

public function validateArgument($argument) {

  if(strpos($argument, '-')){
      $argument = str_replace('-', ' ', $argument);
  }
  $term = taxonomy_term_load_multiple_by_name($argument);
  $termId = key($term);
  $this->argument->argument = $termId;

  return TRUE;

}


texts:
I've just cloned a full functioning website with its database.

But on localhost:

The index page shows a white page
When I go to the login page, it shows a login form with basic HTML, without CSS styles, and no template.
When I try to log in, it redirects me to https://localhost/sitename/user/admin, which I am not allowed to access.
I've tried to compare another page just now and it isn't white, but it doesn't show what it needs to show too. It shows the following code.

[t001_01_main.tpl.php] var addthis_config = addthis_config||{}; addthis_config.ui_email_note = 'verbind: test setting E-mail text'; */?>

I'm running the localhost on a Macbook Pro without MAMP. Other Drupal installations work fine.

I have tried putting the following code, but it gives the same result.

error_reporting(-1);  // Have PHP complain about absolutely everything
$conf['error_level'] = 2;  // Show all messages on your screen, 2 = ERROR_REPORTING_DISPLAY_ALL.
 ini_set('display_errors', TRUE);  // These lines just give you content on WSOD pages.
ini_set('display_startup_errors', TRUE);

I've looked into WPOD, but I can't access anything on the site. In /etc/apache2 there isn't any error.log file.

The problem isn't with one page; the user page is plain HTML and when logging in my site keeps redirecting to https:// (like said in the second paragraph). So many solutions found about WPOD can't be tried because I can't login.

The Drupal version of this project is 7.36, php version of my localhost is 5.6.19

I've tried updating the drupal version to 7.51
I've tried using php 5.4 (oldest version I have installed)
There are no new errors in the watchdog table

Live site works like a charm , other local websites that I've imported to localhost allso work


texts: what will be the cause of redirection loop while accessing view settings page

texts:
I have drupal 7.14 setup installed with views module.
Whenever i am trying to access "admin/structure/views" the
site goes into redirection loop and not opening the views setting page also same behavior is showing for Linkit Profiles settings page.

I can add views by directly calling this url "/admin/structure/views/add" but not able to edit as they are not listing but i need to know why the views settings page not showing.

Solutions which i already tried:

Uninstalled views module and again installed.
run update.php
cleared views cache from database

But it doesn't give me any result any guesses why this is happening.


texts: Add custom field in exposed form in view

texts: I have a view with exposed form. I want to add some custom select field in this exposed form. I have tried with hook_form_alter() but the field is rendered in form submit button wrapper which is strange. How can I add a custom field to another one filters ?


texts: How do I control the file appearance using File Entity?

texts:
By installing File Entity module I was hoping to be able to control the way all file items are rendered, for instance I need: file rendered as a link wrapped inside an <li> element, or a link with a given class to force display: block. I must say I have now more disorder among the widget, formatters and displays than I used to have before, and I can see no way to control the markup.

Please shed light on me, I assume it's my ignorance rather than the module imperfection. Thanks.


texts: I have exported certain items with features module and have my *.tar file, where do I go in drupal to import this Feature in my destination site???


texts: "Order items" view displaying removed items (variations)?

texts:
I'm dynamically removing items from cart with this function:
  static function _remove_product_variation_from_cart($variationId) {
    $orders = \Drupal::service('commerce_cart.cart_provider')->getCarts();
    if (empty($orders)) {
      return 0;
    }
    $items = reset($orders)->getItems();

    foreach ($items as $item) {
      $quantity = $item->getQuantity();
      $itemVariationId = $item->getPurchasedEntity()->id();
      if ($variationId == $itemVariationId){
        foreach ($orders as $order) {
          $order->removeItem($item)->save();
        }
        return $quantity;
      }
    }
    return 0;
  }

And during checkout process it's all fine - removed items are not displayed. But page:
/user/user_id/orders/order_id

is listing also removed items (that's view "Order items"). Sum (order total) is correct however.
On other hand i.e. view "Checkout Order Summary" is returning order items correctly (without removed ones).
Am I removing cart item wrong way or something? Why is this happening?


texts:
How can I add archive state to drupal forums so that:

  They are not visible in search results
  They are shown in a different container
  They are visible only to some users based on user-roles

I don't want to unpublish them-

I also want a spam state to differentiate unpublished and spam posts


texts: I need a Drupal workflow solution where I can edit live/published nodes and save without the edits going live until commited

texts:
I need a module or method that can allow a PUBLISHED node to be edited in the admin and saved without the changes being made live until it is committed.

Site Example: http://bit.ly/p70f7E

1. User with EDIT permission logs in and edits this page/node - They make a copy edit such as changing the title "Litman Gregory Launches Alternative Strategies Fund" to "Litman Gregory Has Launched the Alternative Strategies Fund" or some kind of edit.
2. The user cannot publish the change but can save the revision or checkout/checking the file.
3. User with PUBLISH permission logs in and checks the edits for accuracy and then hits publish.
4. The page/node never gets unpublished, but the edits are made in the back-end without updating the live copy.

Any ideas?


texts: Is the field item delta in the database reliable?

texts:
Use case / background:

A node type "product".
A taxonomy vocabulary "feature". E.g. "color" and "size". (forgive the name, it has nothing to do with the features module)
Every product can have up to one value for each feature. E.g. color = green, size = big.

At first, this sounds like I should be using one (single-valued) field per feature, instead of a taxonomy. But this really does not scale, because there are going to be many many features, and new features can be dynamically added.

Another option would be a new entity type or bundle "node feature value". Or a new field type with two database columns, which stores both the tid of the feature, and the value.

But I thought, what if I use a regular text field with a custom widget? I would use the "delta" to store the feature tid, and the text value for the value.

Because, let's face it, the delta would be redundant anyway, if there can be only one value per product x feature.

The only question is, how reliable are the deltas? Can it happen that something will "normalize" the deltas to a regular continuous integer sequence 0..n ?


texts:
I am creating a stats page for a football (american) team in Drupal 7 and I am having issues summarizing the data.  I have the following fields aggregated in a views table. Each is a summary of the individual players for each game.

Game 1 , Passing Yards, Long Pass, Rushing Yards, Long Rush, etc

Game 2 , Passing Yards, Long Pass, Rushing Yards, Long Rush, etc

I want to print a summary line at the bottom that totals up the season.

I have tried the views_calc module, but I would rather print the summary as one line instead of a separate line for the sum and max fields.

Any help would be greatly appreciated


texts: How do I set permissions for a subdirectory that Drupal creates when uploading a file?

texts:
I'm using Drupal 8 and the Flysystem module to configure remote file storage via SFTP. My question probably applies in general, though.

When a file is uploaded, and the file directory setting has a value, then Drupal creates a subdirectory if it doesn't already exist in the remote location. For example, the file directory defaults to [date:custom:Y]-[date:custom:m] to organize files by month. I need to set the permissions of these subdirectories. Currently, they're defaulting to 744. How do I change this? I'm hoping there is either a global setting, a hook, or a way to set the permissions in a module.

Thank you in advance for your help!


texts:
I want to override the block.html.twig 'classes' variable in my block--system-branding-block.html.twig which extends block.html.twig. I tried to set the 'classes' inside block--system-branding-block.html but this didn't work.

block.html.twig

{%
 set classes = [
  'block',
  'block-' ~ configuration.provider|clean_class,
  'block-' ~ plugin_id|clean_class,
]
%}

 {{ title_prefix }}
 {% if label %}

{{ label }}

 {% endif %}
 {{ title_suffix }}
 {% block content %}
   {{ content }}
 {% endblock %}

block--system-branding-block.html.twig

{% extends "block.html.twig" %}

{% block content %}
  {% if site_name %}

     <a href="{{ path('<front>') }}" title="{{ 'Home'|t }}" rel="home">{{ site_name }}

  {% endif %}
  {% if site_slogan %}

{{ site_slogan }}

  {% endif %}
{% endblock %}

I want to put another entry in the classes variable just for the block--system-branding-block.html.twig witch extends the block.html.twig


texts: Site-wide altering of access behavior in Drupal site

texts:
I have a website that has 3 different types of users: anonymous, registered, elite registered. I have setup the appropriate permissions but my problem is the following: if a user does not have the appropriate permissions to see a piece of content, the content does not appear anywhere on my listings. For example, it does not appear in the results of the Search API, it does not appear in the entity reference listings or the Views.

I want the nodes to appear in various listings but when you try to access the actual node, to get a message that prompts you to register/upgrade your account.

Is this a way to configure such a behavior site-wide? Or would I have to handle the permissions on a per-item basis (e.g. setup the views or override the entity reference permission handling to show the results regardless of the permissions and redirect the Access Denied page to an "Upgrade your account" page)?