texts: Get tid as integer from tid array returned by EntityFieldQuery

texts:
I am using an EntityFieldQuery to return an array of taxonomy terms matching a provided custom field value. Using the example given in this question, I wrote a function that accepts the vocabulary, field name, and field value as arguments and returns an array of matching terms. That works perfectly, but what I really want to get back is just the integer values corresponding to the matching terms, not the array of terms.

The problem is, the data structure that's being returned looks like this:

Array
(
    [6] => stdClass Object
        (
            [tid] => 6
            [vocabulary_machine_name] => features_of_interest
        )

)

for one item, and for another:

Array
(
    [79] => stdClass Object
        (
            [tid] => 79
            [vocabulary_machine_name] => features_of_interest
        )

)

Because of this, I can't see how to isolate the [tid] value (6 or 79 in the examples). I'd like to be able to say

$int_tid = $terms[XXX]['tid'];

but I can't get my head around whatever syntax is needed.

I've pasted my function below in case it helps. Ideally I would like to loop through the array of items, isolate each term ID value as an integer, and push it onto an array which the function would then return.

  function get_tids_from_custom_field($vocabulary, $field, $value) {

    $vocab_machine_name = taxonomy_vocabulary_machine_name_load($vocabulary);
    $query = new EntityFieldQuery();
    $query
      ->entityCondition('entity_type', 'taxonomy_term')
      ->entityCondition('bundle', $vocabulary)
      ->propertyCondition('vid', $vocab_machine_name->vid)
      ->fieldCondition($field, 'value', $value, '=');

    $terms = $query->execute();
    $int_ids = array();

    foreach ($terms as $term) {
      dpm($term);
      array_push($int_ids, $term);
    }
    return $int_ids;
 }


texts: Unable to log in due to session cookies not being passed in

texts:
I have an html5 app which logs the user into drupal via services 3.11 but I am unable to connect.

Using the Chrome Postman plugin I can connect as expected.
The difference between Postman and my code is that the cookie session is not being passed from my app.
From what I have read the withCredential: true is supposed to pass the session cookie but it's not working for me?

api/user/login.json - Logs the user in as expected
api/user/token.json - returns the token as expected
api/system/connect.json - Always returns the data for Anonymous user 0

The system/connect code sent after login and token is:

                jQuery.ajax({
                    type: "POST",
                    url: connectUrl,
                    xhrFields: {
                        withCredentials: true
                    },
                    success: function (result) {
                        dosomething();
                    },
                    error: function (result) {
                        dosomething();
                    },
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader('X-CSRF-Token', Session.user_token);
                    },
                });


texts: No body text saved when creating a node with I18n and specific language set

texts:
Drupal 7

I'm creating a event type nodes, using data from an external database.  It's a multi-lingual site, and the primary language is english.

My code creates the node correctly, when the language is set to LANGUAGE_NONE, but when it is set to "en", the body text is not saved in the database.

foreach ($results as $record) {
  echo '<br/>Creating event: ' . $record->name;

  $node = new stdClass();
  $node->type = 'event';
  $node->uid = 1;
  node_object_prepare($node);

  $node->title    = $record->name;
  $node->language = "en";
  //$node->language = LANGUAGE_NONE;

  $node->body[$node->language][0]['value'] = 'This is a body text for '.$record->name;
  $node->body[$node->language][0]['summary'] = 'Here goes a summary for '.$record->name;
  $node->body[$node->language][0]['format'] = 'raw';

  $path = 'content/programmatically_created_node_' . date('YmdHis');
  $node->path = array('alias' => $path);

  $instance = field_info_instance('node', 'body', 'event');
  print_r($instance);

  $node = node_submit($node);
  node_save($node);
  dpm($node);
}

When $node->language = LANGUAGE_NONE, a record is created in the fields_data_body table. I can see the body text, but cannot translate it.  I guess this is correct.

But when $node->language = "en", no record is created.  This is my problem.  I need this set to "en" as it's a multi-lingual site, and without it, there is no "translate" tab when editing the node (Internationalization module drupal.org/project/i18n)

There is some back history to this issue here..  No "body" when creating a node programatically, with Internationalization ..but it's not essential to read it.


texts:
I added some fields to the "Article" content type. I want to output them in a page--front.tpl.php. How do I get the field label value?

When I use the following code in page--front.tpl.php, it doesn't show the name of the field label. Why? What code should I use to print the field label?

$node = node_load(1);
print_r($node);

The output is similar to the following:

    [field_sq] => Array(
      [zh-hans] => Array(
        [0] => Array(
          [value] => 250
        )
      )
    )


texts: Pathauto module doesn't translate urls generated by l(), url() to aliases, should it?

texts:
Pathauto readme says:

  If you use the "system path" (i.e.
  node/10) for menu items and settings
  like that, Drupal will replace it with
  the url_alias.

But in my case links stay the same:

echo l('test', 'node/329'); // returns: node/329, should return: about-us

It is first time I'm using Pathauto, I was expecting it to work out-of-the-box as I followed all the instructions and there was nowhere mentioned any special url-translation activation procedure or something (is there one?).

When I paste domain.com/about-us into the browser address bar it manages to load proper page. But it doesn't translate my links.

Any idea what could be wrong or where I should I start to repair it?


texts: How best to implement a custom variable in the content creation form in D7?

texts:
I'm creating a sports league site.

I want to have a variable behind the scenes containing the current league standing. In a content type 'result', upon saving, I first want a field (previous standing) to be populated with this variable, and then for the variable to be updated with the new standing. But I have no idea where to even begin with this!


texts: How to Install multiple version of Drush?

texts:
I have Drush 6 installed in my system.

I need to install Drush 5 too (hosting doesn't support Drush6), how do I install Drush5 without uninstalling Drush6 and use both of them simultaneously, Drush6 for local development and Drush5 for SFTP.


texts: How to get a drupal path in a modal form?

texts:
I would like to have a specific path in a modal form. I tried several things but cannot get i work.

Modal_form

I installed the module, clear cached and added into a body tekst the example of the module:

Link to click

When I click on this link I will get ajax error 200.

Colorbox and Colorbox Node

Maybe it is working with this module...installed module. After installation I Enabled the Colorbox load option and clear cache.Put the below link in a body text.

colorbox test

After clicking the link I will see node/2 in the browser but not in a modal form.
The filters in the editor is full html

Ctools automodal module

Installed the module. Put node/2 into the extra modal links box. Pushed the submit button but it is not saved

So probable I do something not good but what? Any suggestion?
Using chrome.

Console errors: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/ with jquery

Any investigation says that this is a ajax call but I'n not sure.

set jquery update to 1.9 for front end. But no luck :-(

Any suggestion?


texts: Changing blocks based on visitor's country

texts:
On a Drupal 6 site I am trying to display blocks on my site based on user's country.

To do this I had to install  'IP to Country' module
Updated IP to Country
Created a new block and added the following code into the block body to print the user's country code:

<?php
$co=module_invoke('ip2cc','get_country',$_SERVER['REMOTE_ADDR'];);
print($co->country_code);
?>

Then, under 'Show block on specific pages' selected 'Show if the following PHP code returns TRUE (PHP-mode, experts only).' and then added the below mentioned code, so that the block is displayed based on the country ID.

<?php $co->country_code == "IN" ?>

After doing all these the block is getting disabled for the ID mentioned, eg: If 'IN' is mentioned the block should only be displayed for Indian visitors, but the block is actually being disabled.


texts:
On my website, the user first fills out a questionnaire. Based on the answers given, I want to generate a view. The answers correspond to taxonomy ids. The problem is that I can't seem to find any option to filter by taxonomy id, which I am passing to my view as an argument.

Is there any way to do this? Preferably through the GUI, but code is no problem.

There was an option in drupal 6 that could do this on a regular page (taxonomy_render_nodes), but this has disappeared in drupal 7, which is why I'm looking to create a view now.


texts: Why are there module files like [modulename].pages.inc?

texts:
I start to learning moding Drupal and I have a look for the current ones. There are files like [modulename].pages.inc or [modulename].api.inc and I can't find why it exists? I read that base files are only [modulename].module, [modulename].info, [modulename].install in Drupal book.

Can somebody explain me these files or post names all this kind files?


texts: How can I access the raw value of a view in a template?

texts:
I am looking for a way to get the url of an image dynamically to put it as a background.
So I created a view that get the image field of the node or taxonomy term, which is supposed to output the url only (I have tried only with the node so far). I have been cleaning as much as possible everything inside the view and also the template of the view looks basically like {{rows}} and that's it.
But there is still a wrapper div that I can't trim:

/sites/default/files/2018-08/bg_image.jpg

How can I trim the twig variable created in the theme to get rid of the html tags ?

When I try strip_tags() function in the theme preprocess or |striptags or |trim directly in the template, it's not working and I have a lot of errors starting with Warning: strip_tags() expects parameter 1 to be string, array given in __TwigTemplate for example


texts:
On this site I implemented the Multi Level Push Menu. All works fine, but the menu disappears on small screens (tablet width and below). I use Bootstrap 3 und Drupal 7 in this project.

I already tried it with increasing the z-index on #menu, but it didn't worked.

I'm thankful for any suggestion.


texts: How to render a view in an ajax callback

texts:
I am trying to develop a custom module to ajaxify the commerce form block. I tried using dc_ajax_add_cart and ajax_add_to_cart but they were not addapted to my project.
I have the following callback function
function tb_ajax_cart_reload_offcanvas_cart(array $form, FormStateInterface $form_state){

$response = new AjaxResponse();

// get current order id
$cart_provider = \Drupal::service('commerce_cart.cart_provider');
$cart = $cart_provider->getCart('default');
$order_id = $cart->get('order_id')->getString();

// tried this
$cart_block = views_embed_view('commerce_cart_block', 'default',$order_id);
$response->addCommand(new ReplaceCommand('.commerce-cart-block', $cart_block));

// and this
$args = [$order_id];
$view = Views::getView('commerce_cart_block');
if (is_object($view)) {
    $view->setArguments($args);
    $view->setDisplay('default');
    $view->preExecute();
    $view->execute();
    $content = $view->buildRenderable('default', $args);
    $response->addCommand(new ReplaceCommand('.commerce-cart-block', $content));
}

//Alternatively I can reload the whole cart bloc but it is not what i am trying to do
$block = Block::load('cart');
if ($block != null) {
    $cart_block = \Drupal::entityTypeManager()
         ->getViewBuilder('block')
         ->view($block);
    $response->addCommand(new ReplaceCommand('.navbar-cart>div', $cart_block));
}

return $response;
}

However it doesn't work and I get stuck with the following error:
 Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function.
I've read this post and others but I couldn't figure out how to properly load the view inside my callback.
Any help is welcome. Thanks


texts: How can pass a data of a node's field to entityform field

texts:
I have a field named "code". This hidden field stores some alfa_numeric values.

Nodes with using this data field have an entityform type as a block in page.

How can I pass node's data values to entityforms data field as prepopulated.


texts:
Have a page on website where exposed filter is hierarchical taxonomy (Country/City). Works fine with few terms, just for test. Page loadtime is 1.5ms, choosing terms goes in blink.

Now i imported all Europe countries and cities, around 5000 terms. Page loadtime is 21s.
Choosing first term (parent/UK) took 8 seconds. Choosing 2nd term (child/London) took 8 seconds.
I am using views exposed filter http://drupal.org/sandbox/ser_house/1832320.

I am aware that this module is far from done but from what i found out reading about taxonomy is that Drupal handles large taxonomies very bad.

All countries and cities will be around 20.000-30.000 terms and i except several users using the filter at same time which is not an option with loadspeed so high.

Any help how to handle this (maybe another module?) would be greatly appriciated.


texts: How to override thumbnail generation of file type media?

texts:
In admin/content/media I need to show file type related icons instead of generic file icon.

From this:

To this:

I tried to edit the related thumbnail field in "media" view but no option is present.

Thanks


texts: How can I restrict access to my website via web services only?

texts:
I am getting lots of spam in my website. Here are some modules I tried as a remedy:

Honeypot
Http BL

No luck yet however.

Now I decided to make the site available only for web services only, whereas the web services are done with Services module.

So how can I allow access to my website via services only? Is there something I can achieve this from .htaccess ?


texts:
On our company website we have a people page which amongst others has an image field called 'field_photo'

This is being rendered using the following:

<?php print render($content['field_photo']); ?>

However I need to be able to add some attributes to the img tag outputted, to do this I figured I would have to use a custom template and add in the required bits like so:

$item['#item']['attributes']['class'] = 'photo';

Problem I am having is no matter what I do, I don't seem to be able to get this to work no matter what I name the template (eg field--field_photo--image.tpl.php). I'm not used to working with Drupal at all, so any help would be great!

Ta


texts: how to manually add a node in drupal 7 in the database

texts:
I have managed to display the title but im missing the body of the title. i cant find in the database which table i missed to edit.

here's the list of tables i editted:

node
node_revision
node_comment_statistics
taxonomy_index

for the body i assume that these fields are responsible for it:

field_data_body
field_revision_body
field_data_taxonomy_forums
field_revision_taxonomy_forums

The node i made has no comments so no comment table is editted.

Am i missing other tables to edit here?

SO i assume i have editted all the necessary tables but i seemed to have missed something here cause ONLY THE BODY IS MISSING.


texts:
I work on an drupal 8 application that use the group module with the restriction of only one group per user. i want to be able to modify the menu items so that the id of the user's group is always in the url. this way i can use views with a group id in the url.

I search and i always go to the same pages with the same example that doesn't work for me.


texts: How do I change a theme based on the URL?

texts:
I have a Drupal instance running on example.org. Which has a theme X installed and activated. Now for a limited period an event is supposed to be held on the site for which a special section has been "carved out." All the things related to that event will go to example.org/event2011.

I want to have a different theme to be shown whenever a page under this section is viewed (e.g. http://example.org/event2011/about, http://example.org/event2011/node/123). How do I do that?

I have gone through many modules, but none of them is supporting Drupal 7. Preferably, I would like it to be done using modules and don't want to change anything my self at the code level.


texts: How to get SMS as send method in the Messaging&Notification module (D7)?

texts:
I cannot find anything for D7, only D6.
Anyone knows howto?
Alternatively; any way to send SMS via views-send-module?


texts: Setup a view to show most recent post or a post promoted to front page

texts:
I setup a view that displays published articles from a specific content type. I want to guarantee an article always displays, so I'd like to order the results to show the most recent post.  That is easy enough to do using Filter Criteria and Sort Criteria in the View Block.

What I also want to do is if my authors decide to promote an article to the homepage, I'd like that article to get priority over the date sort criteria so that the article marked promote to homepage is the one that displays.

In the event that two or more articles are marked promoted to front page, I'd like the most recent article marked as promote to front page to be the one that appears.

I tried to create a new block in the same view that displays the most recent post and I tried to add that block entity to the No Results Behavior, but I am not sure if I was doing that right because it always showed blank.  Was I on the right track by doing it that way?

Is there a way to do this in a view block in Drupal 8?


texts:
Using the multiblock module, I haven't been able to retrieve the $edit variable my custom hook_block_configure() or hook_block_view(). According to the readme:

add an optional $edit
argument to your hook_block_view and hook_block_configure functions.

I have, like so:

function donation_form_block_configure($delta = '', $edit = array()) { ... }

But alas, $edit is all ways null. I'm simply looking for the multiblock id during the configuration and viewing.


texts:
I found a solution that replaces the default reset functionality by an AJAX , It's working fine in my Bootstrap Theme , but I have one problem ! when I click the reset button the dropdown select list don't back to the Field Label but it's look empty ??!!
what can i change to make it work ?

I'm using Drupal 7

/**
* Implements hook_form_alter().
*/

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

// Get the submission button ID
$submit_btn_id = $form['submit']['#id'];

$form['reset']['#attributes'] = array('onclick' => "javascript:jQuery(this.form).clearForm();jQuery(this.form).find('#$submit_btn_id').trigger('click');return false;");

}


texts: How to add/reference user specific data on/for each node?

texts:
I have a content type for which there is a user reference field,I can select multiple users for every node.
For each node I want to save some extra information for each selected user.
Like another dependent select field,which has multiple colors.

For example,
for node "X", user 1 and user 2 are selected.For user 1 I want to select color red,black.For user 2 I want to select color pink,green.

All the color data with user and node reference can be saved on the same node,or maybe somewhere else, How do I do that?

Any suggestions and help will be appreciated,Thanks.


texts: Make node/field text input format available to Views

texts:
The standard Content list in Drupal 7 (displayed with the Find content menu item) gives me a table of nodes in the system with various attributes, such as the type. I want to add the text type (e.g. Filtered HTML).

How can I do this? Installing the Administration views module has made the table much more configurable, but there seems to be no way to include data from the field_data_body database table, which contains the information. The Table Wizard and Data modules apparently provide this functionality, but are not done for Drupal 7.

Is there a way to do this without coding?

If I have to code it, do you recommend creating a new module (with which I have no experience) or patching up an existing one until it works well enough, and if so, which one?

PS: this can be regarded as a special case of a (frequently asked) related question.


texts: How to share content title, image and body on Instagram?

texts:
I want to share content's title, image and body on Instagram of my Drupal website,

But I am not able to find the solution.

Any suggestions?


texts: Show default image when no uploaded image

texts: I have a view with a thumbnail of the image uploaded by user. I would like to setup a default image which appears in place of thumbnail in case the user did not upload any image. Is that possible? Any advice appreciated.


texts:
I am trying to set a master-slave environment for a Drupal 7 website. My concern is if the slave fails (with the current config) the site won't be accessible anymore.

So, how can an automatic mechanism detect this and set a flag (sick) so that for further requests that server won't be used anymore (something like what varnish does with backend probing)?

My current config does a Round Robin selection of the db connection to use for each select query.


texts:
I would like to show interval time for nodes were last modified. I am using the following code:

<?php print "Last Modified" . format_interval($node->changed, $langcode, "short"); ?>

I am using $langcode as proposed here to display it in Arabic, but it is not working and I am not sure if I am using it the right way because I get this error Notice: Undefined variable: langcode in include()

Whenever I update any content; interval time still set to 0 sec, so what is wrong with the code?


texts:
I have a list of items. By clicking on an item I open a form at /items_form/123 where 123 is the itemid. When filling the form I use the arg() function to get the 123 and read some data from the database. No problem.

My problem is, when submitting the form, the default submit handler is not called.
When I open the form without the arg e.g. /items_form and submit this form, the submit handler is called.
Where is my missing link?
Here is my hook_menu:

$items['items_form'] = array(
'title' => 'Item Form',
'page callback' => 'drupal_get_form',
'page arguments' => array('get_item_form'),
'access arguments' => array('access items_form content'),
'type' => MENU_NORMAL_ITEM, //Will appear in Navigation menu.
);

Any ideas?


texts:
As an ability the user might choose gift wrapping option for some of his/her products on add to cart form , what I did is creating a new product type called gift wrapping item, so site operators can add different kinds of wrapping options with different prices. I also altered the add to cart form so a new form item is added which gives the costumer the ability to choose a wrapping type, so far so good, user choice then is saved as a line item property (product ID of wrapping option is save in 'field_wrapping_option' which is added to product line item), and wrapping price is added to line item base price.

The problem is raised when user want to add 2 item from same product but he/she wants wrapping only for one of the two. In this case both products are stored in same line item and wrapping price also is added for them both.

I used hook_commerce_cart_product_comparison_properties_alter to force drupal create different line item when 'field_wrapping_option' are different on line items, but it didn't make things better, now every add to cart operation lead to new line item even when same wrapping option has chosen by user, and even worse situation happens when user first add a product without gift wrapping first and then adds a product with wrapping option which cause the first line item change into a product with gift wrapping.

Now the question is : How to Separate line items when line item details are different?


texts:
I Want to open node preview in popup,

Is it possible to display Node Preview in a pop up like colourbox or light box?

If anyone has solution Please let me know

Thanks..!!


texts:
I have a region with menus, a menus displays depending on the url example if on the about page(sitename/about-us), display about menu and links as a sub menu.

It works, but the problem is after navigating through the site a couple of times, the region caches. is the anyway i can clear the regions cache on page reload.

I tried the below in my .theme

   /**
   *  Implements hook_preprocess_HOOK() for block.html.twig.
   */
  function themename_preprocess_block(&$vars) {
    //the menu block id name in the region
    if ($vars['derivative_plugin_id'] == 'submenu') {
      //-- This stops the block being cache in drupal 8
      $vars['#cache']['max-age'] = 0;

    }
  }

also tried

  /**
   * Implements hook_preprocess_HOOK() for block.html.twig.
   */
  function themename_preprocess_block(&$vars) {
    if ($vars['derivative_plugin_id'] == 'theme-block-branding') {
      //-- This stops the block being cache in drupal 8
      $vars['#cache']['max-age'] = 0;
    }
  }

not sure what steps I can follow to achieve the above


texts: Language switcher to non-source language not working

texts:
I have a Branch content type, which also happens to be an Organic Group. I use the Pathauto module to set the URL to:

branch/[node:menu-link]

I have created a content, and a Menu with a menu item which linked to said content. Everything works well up until now.

Next I enabled Entity translation and translated it into two different languages (French and German). Since, with entity translation, the node ID will be the same, I don't need to change the link in the menu item.

When I go to the English (the default and source language) page, I see that in the 'Language Switcher (Content)' block, the other two languages are not linking. However, manually changing the language prefix in the URL worked. So, the page actually exists.

/en/branch/my-branch ----> /fr/branch/my-branch

When I am on the French page, the language switcher shows 'English' as clickable, but German is disabled. The same for the German page.

So it appears that the language switcher doesn't link to non-source languages. Is this a bug? Any pointer are appreciated!


texts: hook_breadcrumb() doesn't show breadcrumb

texts:
Hello Drupal community,

I am trying to alter the breadcrumb in my site with the hook_breadcrumb($variables). I've used drupal_set_breadcrumb() function without any result. Here's my function in template.php :

/**
 * implements theme_breadcrumbs
 * @param unknown $variables
 */
function MYFUNCTION_breadcrumb($variables) {
  // On récupère les items de la page s'ils existent
  dpm($variables['breadcrumb']);
    if ($item = menu_get_item ()) {
      if (isset ( $item ['page_arguments'] )) {
        foreach ( $item ['page_arguments'] as $argument ) {
          // Keeping the name of the taxonomy in $field_name
          if (isset ( $argument->field_article_type )) {
            $field_name = "field_article_type";
          } elseif (isset ( $argument->field_type_remontee_document )) {
            $field_name = "field_type_remontee_document";
          } elseif (isset ( $argument->field_lien_type )) {
            $field_name = "field_lien_type";
          } elseif (isset ( $argument->field_type_de_contenu )) {
            $field_name = "field_type_de_contenu";
          } else {
            $field_name = "  ";
          }
          // retrieving the field and then the link to the taxoomy in the form term/taxonomy/%
          if ($field = field_get_items ( 'node', $argument, $field_name )) {
            foreach ( $field as $taxonomy ) {
              $taxo = taxonomy_term_load($taxonomy['tid']);
              $nom_taxo = $taxo->name;
              foreach ( $taxo->field_taxo_list as $taxo_link ) {
                foreach ( $taxo_link as $link ) {
                  $lien_taxo = $link ['value'];
                  $title = $item ['title'];
                  $crumbs = array ();
                  $crumbs [] = l ( t ( 'Accueil' ), '<front>' );
                  $crumbs [] = l ( $nom_taxo, $lien_taxo );
                  $crumbs [] = l ( $title );
                  dpm($crumbs);
                  drupal_set_breadcrumb ( $crumbs );
                }
              }
            }
          }
        }
      }
    }
}

Can anyone help ?

Thank you,


texts: Custom Rules Actions to set content to unpublished

texts:
Is there a way to write a custom Rules Action with this conditions.

Default: Content Type X is set to create unpublished content.

RULES

Event: After saving new content
Condition: when a content of type X is created
Action: Set status to published


texts: remove Anonymous user from "Entity Reference" users list

texts:
in my case a project has a technical team, so project content type has a user reference field which is created by Entity reference module. but in node creation form, an "Anonymous" user is available to select.

how can I remove it?


texts: The send function does not work in a custom form

texts:
I have a module that creates a form in a block with a template.
But when I press the submit button, it does not execute the submitForm function.
Instead if in the template only {{form}} if you do.

To clarify, in the template the fields are customized and I call them: {{form.date}}, {{form.submit}}

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

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

    $form['name'] = [
        '#type' => 'textfield',
        '#size' => 60,
        '#placeholder' => 'Votre nom',
        '#maxlength' => 128,
        '#required' => TRUE,
    ];

    $form['tel'] = [
        '#type' => 'number',
        '#default_value' => "",
        '#placeholder' => 'Votre numéro',
        '#size' => 20,
        '#maxlength' => 20,
    ];

    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => $this->t('Réserver'),
        '#button_type' => 'primary',
    );

    return $form;
}

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

foreach ($form_state->getValues() as $key => $value) {
  drupal_set_message($key . ': ' . $value);
}
 }


texts: hook_form_alter function does not call the validate function?

texts:
i'm creating a unique field module which restrict a user with specific role to create one node per year. it works first but after installing some modules Automatic Nodetitles, Cancel Button, Field Permissions, View profiles permissions, More Buttons Content my custom module does not work. its hook_form_alter function works but hook_form_validate function does not work.

function uniquefield_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'target_achieved_node_form' || $form_id ==  'target_node_form') {
    $form['#validate'][]  = 'uniquefield_form_validate';
  }
}
function uniquefield_form_validate($form, &$form_state) {
  $user = user_load_by_name($form_state['values']['name']);
  if ($user) {
    if($form_state['values']['type'] == 'target_achieved' &&  in_array('vidyakjatha', $user->roles)) {
      $query = new EntityFieldQuery();
      $query->entityCondition('entity_type', 'node')
     ->entityCondition('bundle', 'target_achieved')
     ->propertyCondition('status', 1)
     ->propertyCondition('uid', $user->uid , '=');
     if ($form_state['values']['nid'] != '')
       $query->propertyCondition('nid', $form_state['values']['nid'] , '<>');
       $query->fieldCondition('field_achieved_year', 'value', $form_state['values']['field_achieved_year'][LANGUAGE_NONE][0]['value'], '=');
       $result = $query->execute();
     if (isset($result['node'])) {
       form_set_error('field_achieved_year', t('You have already added target achived status for year !year.', array('!year' => date('Y', strtotime($form_state['values']['field_achieved_year'][LANGUAGE_NONE][0]['value'])))));
     }
   }
  }
}


texts: Custom Password validation on Drupal 7 form

texts:
I am using the Drupal Form API for a customized Login System. It has the password field which needs to be validated. We have a custom criteria of Uppercase, Lowercase, numeric and special characters to validate the password.

The one way I see is to write the RegEx inside the Validate function. Is there an alternate way in Drupal to do this via an existing function or module?

(I am aware that the Webform Validation Module can do this for the webforms.)

Thanks.


texts:
Hi I've been struggling with this issue for a while, look for it from google to the official Drupal Commerce documentation without any luck. So i have a cart and I am customizing the looking and the behaviour, tpl and preprocess function have been my friend until now.

I need to custom the bottom actions of the cart

But I haven't been able to look for a tpl and I still don't know how to change the behaviour of this actions if you can give a hint of how to:

Change the value of the  of both of this action
How to add more actions.
How to change the behaviour of the items.

BTW. I look for it on the setting of the Views without any luck, but I'm kind of noob in drupal. Thanks!


texts: Is it possible to dynamically set Views' pager settings?

texts: Say for instance, you have a view that displays when viewing a certain node type, but you want the pager settings to be different for each individual node. I was thinking of making a CCK field like "pager setting" and then give it an integer option of x-y. But I don't know if it's possible to somehow dynamically plug that field into the Views' settings. Or is there another way to do this maybe?


texts: How do I get the Google Analytics module settings to show up? I am unable to configure

texts:
I have installed the Google Analytics module and enabled it. But I am unable to configure the settings for it.

More specifically when I click on the configuration gear it just brings me to Home/admin/config/system and lists in this order: Site information - statistics - actions - backup and migrate - special menu items - cron.

In all the videos I have watched on installing this module. This page is where the Google Analytics settings tab should be.

I have also opened up the main configuration page and it brings this error message at the top. "One or more problems were detected with your Drupal installation. Check the status report for more information" It tells me Google analytics isn't configured yet. Then gives me a link to Google analytics settings. But when I click on it, it just brings me back to the page I mentioned above.

What do I do to get the Google Analytics settings tab showing up?


texts: Pass along field delta value to a rendered entity in an entity reference field

texts:
I have a field on a node type that references another node type. On the display side, I am setting it to a view mode to be rendered.

What I want to do is add a zebra stripe class. Every other node needs an extra class on its wrapper. I figure this should be done at the field twig level, but how do you pass in a value when it is rendered?

field--field-related-content.html.twig:

{% for item in items %}
  {{ item.content }}
{% endfor %}

In the node view mode template:

      {% include "@mytheme/svg/general/how-to.html.twig" %}

How-To

{{ label }}

      DESCRIPTION HERE

The node is unaware of where it is, so, whats the best way to pass a class? Is that possible? The field.html.twig file in classy wraps the field with a div, but thats not what I need to do here.

I suppose one way to do it is change the field twig to something like:

{% for item in items %}
  {% set classes = '...' %}

    {{ item.content }}

{% endfor %}

But that feels dirty, and doesn't really make it reusable, not to mention I would have to inject the background image url through a field preprocess instead of just handle it in the node rendering.


texts: Setting Values for TableSelect checkboxes

texts:
Is there anyway to set the default values for checkboxes? What im trying to do is set a specific value for each checkbox so it will delete the selected row in my db, however table select seems to just go off of its own value instead of the one I am trying to assign them with.

    function auto_form_records($form, &$form_state) {
//Table header
    $header = array(
        '',
        'First Name',
        'Last Name',
    );

//DB query
    $dbresult = db_query("SELECT * FROM {auto}");

        foreach ($dbresult as $dbrow) {

            $select_id[] = array(
            $dbrow->id
            );
            $rows[] = array(
            $dbrow->firstname,
            $dbrow->lastname,
            );
        }

//Table select Form
    $form['checkboxes'] = array(
        '#type' => 'tableselect',
        '#header' => $header,
        '#options' => $rows,
        '#empty' => 'No Records were found.',
        '#default_value' => $select_id
    );

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

//Delete row in db.
    function auto_form_delete_row($form, &$form_state){
        $id = $form_state['values']['checkboxes'];
        db_delete('autoleads')
      ->condition('id', $id)
      ->execute();
    }

//Submission
    function auto_form_records_submit($form, &$form_state){
        $data = drupal_set_message(t(dvm($form_state)));
        //auto_form_delete_row($form, $form_state);
        return $data;
    }

I would think that me passing the string into default_value would atleast give me the values I am trying to pass through, but its not...

Any suggestions is appreciated.


texts: I have found this awesome jQuery Timelinr that I have customized for my Drupal site but am now at a loss at how to insert it. It is only going to be on one page. Does it need to be in a block? Do I have to make a custom module? Any assistance would be greatly appreciated!


texts:
I've got a fresh install of the Drupal 8 Beta 12. I'm trying to install the REST UI module:

$ drush dl restui-8.x-1.x-dev

PHP Fatal error:  Class 'Drupal\Core\Session\AccountInterface' not found in /var/www/html/drup/core/includes/bootstrap.inc on line 64
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Class 'Drupal\Core\Session\AccountInterface' not found in
/var/www/html/drup/core/includes/bootstrap.inc, line 64

Does anyone know what's going on here?


texts: Drupal 7 - Display Content type as Block and Block Naming Convention

texts:
I have created a content type which has some fields, and I want these fields to be displayed as a block.

I've tried renaming a block in my 'theme/template' as block--[machine-name].tpl.php but is of no use.


texts:
I generate a simple module "myformtest" with a simple Class form "MyformtestForm". I want to use a different theme for the form.

I followed this great tutorial. I added a "_theme_suggestions_alter" hook in my "myformtest.module", I activated twig debugging and I loaded the form page.

My "suggestion theme" is present and its name is "form--myformtest-form.html.twig". Then in my module directory:

I added a sub-directory "templates"
I added the twig file "form--myformtest-form.html.twig" in the sub-directory "drupal/modules/custom/myformtest/templates"

In the twig file, I added this simple code. (I copied it from the drupal/core/themes/classy/templates/form/form.html.twig and added the h1 html element for override)

TEST

<form{{ attributes }}>
    {{ children }}
</form>

I clear caches (drush cr) and I reloaded my form page. But the html element h1 ("TEST") doesn't appear! Where is my mistake?

UP

I did it ! I added the hook theme in my .module file :

function myformtest_theme($existing, $type, $theme, $path)
{
  return array(
    'form__myformtest_form' => array(
      'render element' => 'form',
      'template' => 'form--myformtest-form',
    ),
  );
}

But.... ! When I load my form page, the html element h1 "test" is displayed but not the form :/ I thinked my .twig file override the form.html.twig default theme.

Did I miss something ? Why the form doesn't displayed, how can I fix it ? And how can I pass a custom array from my build method of form Class to my twig template ?


texts:
I'm trying to find out any example of adding new conditional field using ajax in Drupal 8 form API, but I can't find it.

This is my code.

$form['name'] = array(
    '#type' => 'textfield',
    '#title' => $this->t('Name'),
    '#maxlength' => 64,
    '#size' => 64,
    '#default_value' => $name,
);

$form['floor'] = array(
    '#type' => 'textfield',
    '#title' => $this->t('Floor'),
    '#default_value' => $floor,
);

$form['flat_per_floor'] = array(
    '#type' => 'textfield',
    '#title' => $this->t('Flat Per Floor'),
    '#default_value' => $flatPerFloor,
    '#ajax' => array(
        'callback' => 'Drupal\bms_flat\Form\FlatForm::flatGenerate',
        'effect' => 'fade',
        'event' => 'change',
        'method' => 'replace',
        'progress' => array(
            'type' => 'throbber',
            'message' => "Generating..",
        ),
    ),
);

if ($form_values['floor']) {
  $form['flats'] = array(
    '#type' => 'checkboxes',
    '#title' => $this->t('Content Type'),
    '#options' => node_type_get_names(),
  );
}

$form['submit'] = array(
    '#type' => 'submit',
    '#title' => $this->t('Submit'),
    '#default_value' => $this->t($submit),
);

This is the callback function.

public function flatGenerate(array &$form, FormStateInterface $form_state) {
  // …
}

How do I add a new field after filling-up my Flat Per Floor field?


texts: How to display jquery ui accordion and drupal 7

texts:
the jqueryui accordion it only takes the first item from the list. I copy into my theme views-view-field--field-summary.tpl.php file and add this code

    <meta charset="utf-8" />

  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <?php print '';?>
  <?php print '';?>
  <link rel="stylesheet" href="/resources/demos/style.css" />

<?php print '
';?>
     <?php print '
Show summary
'; ?>
         <?php print '
'; ?>
           <?php print '
'; ?>
             <?php print $output; ?>
           <?php print '
'; ?>
        <?php print '
'; ?>
   <?php print '
'; ?>

   <?php print '';?>

The output is what you show in the picture.
Why remaining elements take no accordion effect?


texts: Use Composer to manage sub-theme Bootstrap LESS dependencies when using LESS starterkit

texts:
In Drupal 8 let's say I want to use a Bootstrap subtheme and the LESS starterkit described here:
http://drupal-bootstrap.org/api/bootstrap/starterkits!less!README.md/group/subtheme_less/8

The Instruction there is to:

  Download and extract the latest 3.x.x version of Bootstrap Framework Source Files into your new sub-theme. After it has been extracted, the folder should read ./subtheme/bootstrap.

Unfortunately this puts the Bootstrap source outside the ambit of my composer.json where I am managing my site dependecies and upgrade etc... more on why I want to do this here:
https://bojanz.wordpress.com/2015/09/18/d8-composer-definitive-intro/

So how can I include the bootstrap source required by my subtheme in the composer.json?


texts: feeds_ex module tests returns me fatal error

texts:
When I am running feeds_ex test i got an error that says:

PHP Fatal error: Class 'TUnit' not found in /sites/all/modules/contrib/feeds_ex/src/Tests/FeedsExUnitTests.test on line 11

I am looking around in google and forums but nothing similar found.

Any solution appreciated!


texts:
I'm somewhat new to module development.

Is there a way to currently output what hooks have been run on certain nodes?

Would this be done with xdebug?


texts: How to make filter criteria fieldset in a view to be collapsible by clicking on a link using tpl file overriding default file?

texts:
I am trying to create a collapsible fieldset of filter criteria on click of a link
the code I tried is as follows:
    ';
    ?>

<fieldset class="collapsible collapsed">
<legend class="collapse-processed">
Error : Uncaught TypeError: Object [object Object] has no method 'drupalGetSummary' jquery.min.js:16
Edit Search Criteria
</legend>
<fieldset>

But when I click on the link I dont get the collapsed or collapsible feature

The error I am getting is as follows:
Error : Uncaught TypeError: Object [object Object] has no method 'drupalGetSummary' jquery.min.js:16

In the resources of the page the collapse.js is present which indicates that the js  file is loaded.

After updating the jquery version from 1.5 to 1.7 the old error disappears and new error is displayed as follows: Uncaught TypeError: Object [object Object] has no method 'drupalGetSummary' collapse.js:70


texts: How to render a menu_block in a specific language (i18n)

texts:
I have a special menu that is part of the page. I include it in the template like

$block = module_invoke('menu_block', 'block_view', DEF_BOOKLETS_MBID);
print render($block['content']);

Menu's are part of the interface, not of the content. If I use i18n, the translated menu will appear fine if the interface language switches.

However, the client does not want that. The interface is supposed to be one language, but the content can switch languages. That works too - apart from the menu block inside the content.

Is there a way to render a menu_block inside a template in the current content language ?


texts: drupal_add_js causes blocks to be executed twice

texts:
I added this code to template.php (in Zen subtheme):

function mytheme_preprocess_page(&$vars) {
  if ($vars['is_front']) {
    drupal_add_js (libraries_get_path('jquery.cycle') . '/jquery.cycle.all.js', 'file');
  }
}

Just after adding it, each block (e.g. drupal search block, my custom blocks etc) and also this preprocess function are executed twice. I checked it using a debugger. The output on pages is OK, but executing blocks twice has performance implications.

By the way, the same happens if the JavaScript file is added in mytheme_preprocess_html() instead of mytheme_preprocess_page.

Is hook_preprocess_page() the right place to add JavaScript code? (I guess not.) Is there another way of adding JavaScript to a specific page other than the above? (I know I can add in mytheme.info, but it will add to each page, whereas it's needed only on front page.)


texts: Images show up once, then have to clear styles folder to see again?

texts:
So I'm trying to get a site setup with a template (global news), which requires Drupal 7.x, so I'm using 7.41. Anyway, I have all the modules set up and the general layout as it should be. However, I'm having a problem with getting the images to render.

It seems as though if I delete the /default/files/styles folder, the images will generate and show up on the website, however if I refresh the page the images fail to load until I delete the folder again. If I don't delete the folder I get a 403-forbidden for each image I'm trying to load.

It's weird, and I've almost driven myself crazy trying to get this figured out.

Any advice?


texts:
How do I display pager using EntityFieldQuery for fetch results?
I can't find complete example.

I am doing simmilar to:
Sortable, paged table retrieved using EntityFieldQuery

But I miss part to output simple pagination links (1,2,3... for every next page).


texts: Conditional code in preprocess_page function?

texts:
I need to add a conditional code in a my_theme_preprocess_page function.

The conditional should be like:

if the loaded node has a field called background_image and the value for this field is not empty, then is true


texts: Given that I have a node in English as default language and Danish as a translation, is it possible to set the Danish translation as default language for the node?


texts:
Currently drush points it commands to /domains/steve_public/sites/default. I actually want drush to point its commands to /public_html/sites/default.

Can anybody advise me to how achieve this? Do I need to do this?


texts:
I have a simple example the uses an entity reference field that references taxonomy terms (e.g. "Arranger"). On import I need feeds to see if the term exists, reference it. If it doesn't exist, create and then reference it:

My CSV:

My Feed Mapping:

It imports everything else but not the entity reference field. It doesn't create the term either.

What do my feed mapping need to look like to allow entity reference to check for and if the term doesn't exist, create it (and then reference it)?


texts: FieldPluginBase: How to test based on views field raw value?

texts:
I know that the render method is not the right place to do conditional logic but I have no clue where I should implement my tests.

This is my render method I want to access the raw value of a field to do a test on it (conditional field):

  public function render(ResultRow $values) {

    $field_abnormal_category = $this->view->field['field_abnormal_category']->original_value->__toString();

    if($field_abnormal_category == 'No') {
      $field_category_image = $this->view->field['field_category_image']->original_value->__toString();
    }
    else {
      $field_category_image = '';
    }

    return [
    '#type' => 'inline_template',
    '#template' => $field_category_image
    ];

  }

The original_value object is returning the translation not the original string.

How can I access the original value of my field (not translated)?


texts: When I click a radio button its value should display in textfield

texts:
Above is the sample screenshot of my form where I would like to do is:

When I click/check on radio button "One" then its value should display in  textfield of "Display".

Code:

function test_radio_menu() {
  $items['test_radio'] = array(
    'title' => 'test_radio',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('test_radio_form'),
    'access arguments' => array('access content'),
    'access callback' => TRUE,
    );
  return $items;
}

/**
* Implements hook_form().
*/

function test_radio_form($form, &$form_submit){

/* the options to display in our form radio buttons */
$options = array(
  'one' => t('One'),
   'two' => t('Two'),
);

$form['count'] = array(
  '#title' => t('Count'),
  '#type' => 'radios',
  '#options' => $options,

);

$form['display'] = array(
'#title' => t('Display'),
'#type' => 'textfield',
'#value' => ,
  );

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

return $form;
}


texts: Problem installing Knowledge base module

texts:
I installed Drupal using the Bitnami stack.
I'm trying to install the knowledge base module from https://www.drupal.org/project/kb .  I have installed and enabled the modules upon which it is dependent but when I try to enable the knowledge base module itself I get the error

Unable to install KnowledgeBase due to unmet dependencies: core.entity_form_display.node.kb_content.default (field.field.node.kb_content.body)

Obviously I am still missing a dependency and it's telling me what it is but what is but how do I fulfill the requirement?

Further, I can see the core.entity_form_display.node.kb_content.default yml file in C:\Bitnami\drupal-8.7.2-1\apps\drupal\htdocs\modules\kb\config\install when I use file explorer.

Is the yml file in the wrong place?  Or do I need to do something with it so the knowledgebase install knows about it?

Can someone tell me what I need to do?  Please excuse if it's obvious I am a newbie to Drupal.

Thanks for any help, Roscoe


texts:
I just created a web form containing questions and answers for my website; when I click on the "Submit" button, the following error appears:

  The requested page "/node/12/done?sid=20" could not be found

The error occurs is followed by this one, when I try to go to results-submissions-view, or delete submitted data.

  The requested page "/node/12/submission/20?render=overlay" could not be found

I checked the permissions, and the webform settings, but I can't figure this out.


texts: Custom php code using the site header and footer

texts:
I have a very complex page (Multiple Ajax calls and access to other three other mysql databases) that i would like to create within Drupal or find a way to embed it into Drupal. Now I do not want Drupal to manage the page, i would only like to just pull the header, navigation and footer  from Drupal and manage the "content" with my own code manually. In Wordpress this is very easy to do but in Drupal it does not seem to be straightforward.  What is the best way to accomplish this in Drupal.

can custom modules handle that?
can views handle that?
what are my best options?

Note that i just want to know if it is possible and how do i embed my own code into Drupal without having Drupal manage the code.


texts: Is there a module equivalent for Suggest a Friend for Drupal 7?

texts: I am creating a social networking site for which I need the Suggest a Friend module, but it is not available for Drupal 7. Is there a similar module for Drupal 7?


texts:
I had to restore a drupal 7 site from scheduled backup using backup & migrate. Since then I seem to have problem with date/timestamp.
I have a view (3.6) filtering on node created date with options between "today" and "tomorrow".
All users are in GMT+7 timezone.
It is now 18:01pm here and the sql query generated has:
node.created BETWEEN 1375959700-25200 AND 1375959700+61200

So "today" is current time instead of today at 00:00:00

Any suggestion ?


texts: Avoid access denied page after user logout

texts:
I am using Drupal 7. It is good that when user is logged out and again he access the

user/logout

link he is redirected to Access denied page.

Now I want that instead of Access denied page, i want to redirect to the specific page.

Can i achieve it using rules module or i have to write the code for that


texts: Register an anonymous user when entity form is submitted with rules

texts:
I have created an entityform called "Order Request". This form has fields for the user to enter their first name, last name, email address, and their order contents. I would like to register this anonymous user when they submit this form. I have this working, configured with the Email Registration module and Rules to use these fields to create the new user.

However, the problem is this:
Both anonymous and registered users (with the role: customer) need to be able to use the form. I need to prevent an error if there is already an account created using the email address submitted in the form. I would like to check that and not fire the rule to create a new account. How can I create this conditional in my rule?
Hope that's clear. Thanks


texts: Whats the most effective way to intergrate a javascript cost calculator to a specific node

texts: I'm going to use a  JavaScript cost calculator for perspective customers to calculate costs. I was wondering what was the most effective way to integrate the script within a node.


texts:
My story is:

I use module Domain Access for Multi domain feature and Internationalization, Domain Variable for the multilingual features. I have these domains:

www.domain-a.com (main domain)
www.domain-b.com
www.domain-c.com

All is set to use www. prefix.

Now I have www.domain-d.com.au replacing www.domain-c.com. So I delete www.domain-c.com from Domain list in Drupal and add www.domain-d.com.au.

I also set redirect. So when user visit www.domain-c.com or domain-c.com, they'll redirected to www.domain-d.com.au. I add a rule in .htaccess:

RewriteCond %{HTTP_HOST} ^www.domain-c.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domain-c.com$ [NC]
RewriteRule ^(.*)$ http://www.domain-d.com.au/$1 [L,R=301,NC]

Result is:

Visit www.domain-d.com.au. Page opened OK.
Visit domain-d.com.au, redirected to www.domain-d.com.au
Visit www.domain-c.com, redirected to www.domain-d.com.au
Visit domain-c.com, not redirected (fail).

Question is:

How to make domain-c.com to redirect to www.domain-d.com.au? Is here something wrong with my .htaccess.

I uncomment the with www. prefix in Drupal .htaccess and add the rule right below the

...

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

...


texts: how to use ctools Wizard (custom modal) to show my custom form?

texts:
I look at the ctools ajax demo. there I look at the form wzards. They are so nicely displayed in popup window. I want the similar functionality for my comment form.
So how can I use this functionality of ctools module to display the comment form like ctools Wizard (custom modal)?

I am using drupal 7.


texts: Drupal 8, include a subtemplate in a form

texts:
I created a Class form, then I can access to the page form and submit it. My form use the default template of my website.

When I submitted the form, I want redirect the user to the form page (the same page) and display some elements in front of page. Theses elements depends on the results of the form has been submitted.

I can easily do that with simples drupal messages, but instead, I would like to show more complex messages.

I think I can create a little template file and include it in my form. But I haven't any ideas how can I do that in Drupal 8, can you provide me a very simple example or tell me how I can include a sub-template in my form ?

I think my sub-template looks something like this (Pseudocode, not twig :) ) :

// the form return an array
    foreach formarray as element

element1

property1 : {element[property1}

property2 : {element[property2}

        ...
    end foreach
// I include this template in the form, if the formarray is empty, nothing is displayed (when the user load the forme the first time)

Thanks for help !


texts: hook_preprocess_views_view_fields not being invoked

texts:
This is a problem that is very hard to debug, so any help on how can I bite it - will be appriciated. I have custom theme based on tao that I named "clear" . I put it in sites/default/themes/clear . I'm using simple_timeline module. After creating "event" content type for simple_timeline, I decided to "panelize" an "event" node, so it will show the timeline on a side pane. I wanted to highlight on timeline, the currently opened event, so I decided to use template_preprocess_views_view_fields to preprocess rows and add class to proper row of timeline view. To my template.php I added function clear_preprocess_views_view_fields(&$vars) but it is not being invoked. Both clear_preprocess_views_view_field(&$vars) and clear_preprocess_views_view(&$vars) works just fine, only one not being invoked and needed for me is clear_preprocess_views_view_fields . I'm not using any custom modules. The list of enabled modules as given by drush pm-list --type=Module --no-core --status=enabled is:

 Administration    Administration menu (admin_menu)                        7.x-3.0-rc4
 Administration    Administration menu Toolbar style (admin_menu_toolbar)  7.x-3.0-rc4
 Administration    Module filter (module_filter)                           7.x-2.0-alpha2
 Chaos tool suite  Chaos tools (ctools)                                    7.x-1.4
 Chaos tool suite  Page manager (page_manager)                             7.x-1.4
 Chaos tool suite  Views content panes (views_content)                     7.x-1.4
 Date/Time         Date (date)                                             7.x-2.7
 Date/Time         Date API (date_api)                                     7.x-2.7
 Date/Time         Date Popup (date_popup)                                 7.x-2.7
 Date/Time         Date Views (date_views)                                 7.x-2.7
 Development       Devel (devel)                                           7.x-1.5
 Development       Devel generate (devel_generate)                         7.x-1.5
 Features          Features (features)                                     7.x-2.0
 Fields            File (Field) Paths (filefield_paths)                    7.x-1.0-beta4
 Fields            Title (title)                                           7.x-1.0-alpha7
 Fields            YouTube Field (youtube)                                 7.x-1.2
 Mail              Simplenews (simplenews)                                 7.x-1.1
 Multilingual      Localization update (l10n_update)                       7.x-1.0
 Other             Advanced help (advanced_help)                           7.x-1.1
 Other             Menu Block (menu_block)                                 7.x-2.4
 Other             Pathauto (pathauto)                                     7.x-1.2
 Other             Security Review (security_review)                       7.x-1.1
 Other             Token (token)                                           7.x-1.5
 Panels            Panel nodes (panels_node)                               7.x-3.4
 Panels            Panels (panels)                                         7.x-3.4
 Spam control      CAPTCHA (captcha)                                       7.x-1.1
 User interface    jQuery Update (jquery_update)                           7.x-2.4
 User interface    Wysiwyg (wysiwyg)                                       7.x-2.2
 Views             Simple Timeline (simple_timeline)                       7.x-1.0
 Views             Views (views)                                           7.x-3.8
 Views             Views UI (views_ui)                                     7.x-3.8
 Webform           Webform (webform)                                       7.x-3.20
 Webform           Webform Clear (webform_clear)                           7.x-2.0

Anyone have any ideas how can I bite it?


texts:
I've attached an image field to my custom file type to add additional information to my uploaded PDFs. The file field is attached to the node entity. But everytime I upload a PDF for my custom file type and add an image to it, Drupal overrides the filename and the filemime of the image with the ones of the PDF. Therefore I cant open the image anymore. I tried some things to reverse this but I had no success:

function mymodule_entity_presave($entity, $type) {
  if($type = 'file') {
    if(($entity->type == 'mytype') && ($entity->origname != $entity->filename)) {
      $entity = $entity->original;
    }
  }
}

function mymodule_file_presave($file) {
  if(($file->type == 'mytype') && ($file->origname != $file->filename)) {
    $file = $file->original;
  }
}

The file properties stay overridden. I even tried to load the file in hook_node_update(), change the properties manually and save the file again. But the file is destroyed then (file size just returns FALSE).

I would welcome every advise!

Many Thanks.
Daniel


texts: Get Media entity field values in custom validation handler

texts:
I am trying to put a custom validation on node form which has paragraph attached to it. The problem is I am not getting paragraph field values available in form_state of my validation handler.

I just see the delta of entites when I do a debug on form_state

As in the screenshot field_asset the entity_reference_revision referencing a media entity, I only see two entities attached in form_state in custom submit handler on node_form but how can I get value of those refernced entities?

Update: I realised it was not paragraph entity but media entity.


texts: How do I programatically create a node, add a menu item, and add a path alias?

texts:
I am using Drupal 6. I have an external database that I need to somehow turn into nodes so that our Drupal site can display the content and search the content with Solr. I currently have a module which displays pages and queries the database directly each time these pages are viewed. This is not an optimal solution because these pages are not found when a user uses our search.

I know that I can iterate through the database items, create a $node object and use node_save() to create nodes.

1) Can I set a specific NID such as $node->nid = 9999999 . $some_database_key so that I know these nodes can be referenced later for updating?

I could not get this to work, but I did figure out this solution:
I created a database table for my module similar to the one in the node_example module. Using this and a custom content type, I could create nodes. I could not get it to work properly until I used

$node = node_submit($node);

prior to calling

node_save($node);

2) How do I create menu items for these new nodes?

Solution

$link = array();
$link['menu_name'] = 'custom_menu'; // Fill out your menu name or just use navigation
$link['link_title'] = 'Title Here'; // What appears in the menu link
$link['link_path'] = 'node/' . $node->nid; // Or you can use a path alias as well
$link['plid'] = 12; // Optional - if you want it to nest under an item you'll need its mlid (menu id)
menu_link_save($link);

See: http://api.drupal.org/api/drupal/includes--menu.inc/function/menu_link_save/6

3) How do I create aliases for these nodes such as node/856 goes to programs/some-program-type/some-program-title

SOLUTION
Similar to the menu solution above, you can use

path_set_alias('node/' . $node->nid, 'path/alias/here');

Thanks for any suggestions!


texts: How to render all the contents of a view in a custom module?

texts:
I have created a view with 4 blocks. Rose,lilly,sunflower,jasmine. All the blocks have common fields. Now i want to display all the contents of the view in my custom module.  When I tried the below code, I can access only the first block (ie)Rose. How can i get all the values of a view in my custom module?

$view = views_get_view(myblock_block');
$view->set_display('Rose'); // page_1 or block_1 ... block_n, ...page_n
$view->set_items_per_page(0);
$view->execute();
$result = $view->result;


texts:
I need to edit the hook_menu function in my  module.  I need to add a new link to a menu, and edit the path for an existing link.  Is this possible without creating a whole new module?

The only example in the docs for when hook_menu runs is when the module is enabled.  Is there any other time it runs?


texts:
I am getting url example.com/?= and I want this example.com
I have tried .htaccess method but nothing happened.
I have also gone through may link like clean urls but nothing happened
My clean URLs test fail.

Please help.


texts: Drupal commerce products performance when switching between many variations

texts:
In my website I have around 5000 products and 40 products variations (like, color, size, type taxonomy etc). A single product display (node) may contain 1200 to 1800 products. When switching between the product variations, the page takes around 28 to 35 seconds to output the results. I tried commerce_entitycache module. But it doesn't help. Is there any tricks to improve the performance in this situation?

Thanks is advance.


texts: How to pass an argument from the URL to a views exposed filter?

texts:
I have a view with an exposed filter as a select list.How can I pass to the exposed filter an argument from the URL?The argument is the Taxonomy ID (tid).I want the exposed filter to show every time the same Taxonomy Id as the Tid that exists on the URL.Is this possible?
Thanks


texts:
I have chosen the Danland theme for my drupal site.
The theme is licensed as GPL (from the license attached to theme). At the bottom of the theme on my website, there's "Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer", and I'd like to ask you if I can remove it (I won't derive and publish the theme).

I think I can, but I'm not sure.


texts: How to access form elements in table via getValue()?

texts:
I'm trying to do so using array indices. Say, we have

$form['mytable'] = array(
'#type' => 'table',
'#header' => array(t('a'), t('b')));

$form['mytable'][1]['a'] = array(
'#type' => 'textfield',
'#required' => true));

$form['mytable'][1]['b'] = array(
'#type' => 'textfield',
'#required' => true));

What am I doing: $form_state->getValue('mytable[1][b]');, and it's not working. And how to pass such a field to setErrorByName?


texts: How to create a form, using a function, located inside a class

texts:
Usually when we need to create a form we create a function inside module and call:

$form = drupal_get_form('function_name');
drupal_render($form);

Now I started using entities and created a subclass of EntityDefaultUIController. With a form generating function:

class transactionUIController extends EntityDefaultUIController {
  public function overviewForm($form, &$form_state) {
     //blah blah
     return $form;
  }
}

I need to get this from in an external module. What should I pass to drupal_get_form function?


texts: Error throwing for user field populated through Views: Filter by an entity reference view

texts: I am working on a ticket system in my current project (Drupal 8) where user can assign a ticket to particular user. The user field is populated through entity reference and it is filtered using 'Views: Filter by an entity reference' (users belonged to a particular role need to be shown there). For normal users its resulting in 500 Internal server error. It works perfectly if I give 'Administer users' permission to current user role. But without that it will break. I have given 'view user information' permission to all users. Is there any work around without giving 'Administer users' permission to all users as it is not a viable option.


texts: How to hook_views_query_alter arbitrary field and use it in view GUI

texts:
For the life of me I can't figure this out.

I have vast and complicated drupal 7 site and among other things I'm using profile2 module. Not sure why, but a few years back I've added field directly to 'profile' table. It is used to store some number and adding it looked like quick fix back then.

Now I need to get some info using views and all is fine except this one field which I absolutely have to take into account, but I am not able to.

What I did so far is:

function modulename_views_api(){
    return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'modulename'),
  );
}

in my custom module,

function modulename_views_query_alter(&$view, &$query){
    if ($view->name == 'viewname') {
        $query->add_field(NULL, 'some_field', array());
    }
}

in modulename.views.inc

What I'm trying to do is either add this field to display directly, or add it to the list of fields, or replacement patterns, or anything I could use.

modulename_views_data() isn't useful for me, because I would have to recreate whole table structure created (and frequently changed) in GUI.

I tried _views_pre_view, _views_pre_render, relationships, query rewrites, all to no avail. I've run out of ideas...


texts:
I'm working on a site (new to Drupal) that is for an organization with several official rules documents (for different departments and events). I would like to store these documents locally and have individual pages not link to them but display their content in text fields. These pages will have other content and various combinations of the rules. I'm not entirely sure how to approach this problem. I would like to minimize Content Types and feeds dosen't seem quite set up for this.

For instance, if I have two documents on my computer and I have two pages on my site that each have their own content (just some text and a title) but also the first document has the text from the first document displayed and the second page has the first and second documents' text. Also, I would like to easily add more pages, document, and combinations.

Is there a way (I was thinking with feeds perhaps something else would work) to have a field that I could assign to content types so that the field is filled with text from a local file? Or is there something else that would get the job done?
Thanks!


texts:
Hello i have been trying for many a moon to create this View and i cant go on any longer its destrying my life (honest)

I want to show Related Terms (not content) on my taxonomy/term/* page. Example.

White Setter and Black Setter are both in a dogs vocabulary. I have 'related' them via the
taxonomy/term/*/edit-term page.

I want to create a block view that will show Black Setter on the White Setter page and vica versa. I have tried every relationship and every argument with no success at all. Does anyone know if this is possible to make?

Relationships
Taxonomy: Related terms
Arguments
Taxonomy: Term ID

Thanks

Before i post i see that i have asked ths on other peoples posts (and one of mine) they where never resolved. People keep talking about adding nodes in the view but i was wanting to use a term View.


texts: Image gallery with content below each image

texts: I have created an image gallery using views and a custom content type, Photo. It has 2 rows of three images each. I have uploaded the 6 images via the Photo content type, added a body describing the images and then used the views module to create the gallery. However in the gallery only the images and their titles are visible. What i want is that the title should be displayed below and also the description for images should appear. Part of the problem may be solved through CSS, atleast that is what i think but how to get the description/ body (2-3 lines) to get displayed below each image in the gallery.


texts:
Is it possible to allow pdf uploads to be split automatically by drupal?

Example1: If I upload a PDF with 4 pages. Drupal will split it into pdf(page1), pdf(page2),etc...

Example2: I upload a pdf that is 10mbs, It can logically split the files into a limit. So if the limit was 5mbs. It would split the file into 2 even parts...


texts: "You are not authorized to access this page." in Chrome after returning from offsite payment

texts:
After concluding checkout flow on site I'm redirected to offsite payment service (Datatrans).
There if I finish payment and I get redirected back to:
/checkout/order_number/payment/return
or I cancel payment and get redirected back to:
/checkout/order_number/payment/cancel
on site I get the message:
You are not authorized to access this page.
At that point I'm not logged out - if I just reload the page (click on browser address bar and hit enter to open page again. I get redirected to:
/checkout/order_number/order_information
Important - this happens only in Google Chrome. In Firefox this works well.


texts: Users unable to view orders even with permissions set

texts:
I have a Drupal 7 site with Ubercart.  When users log in, and check their "My Orders" tab, it says there are no orders even when their should be.  Users are showing correctly for admin, and permissions are set correctly for them to view.

Any ideas what could be causing this?


texts: How to copy data from Profile2 form to a new node using Rules.

texts:
I'll try to explain what I need to achieve:

User submits profile data during the registration proces (using Profile2 module).
Rules trigger event "After saving a new user account" that creates a new node, and then copies Profile 2 data fields to a new node.

Any ideas how can I get this working? Guess I need to use Action "Create a new entity" but not sure how can I pull data from Profile 2 and then save it to a new node?

Thanks a bunch!


texts: Commerce payment for Rooms reserveration only after the order is confirmed

texts:
I want to use Commerce + Rooms and wonder if there’s a configuration/module for the following procedure:

User reserves a room, checks out, but isn’t allowed to pay yet.
The room owner gets an email and confirms/declines the order.
If confirmed, the user gets an email and can now start the payment process in the checkout.

Rooms offers an "enquiry mode" (instead of the mode for booking directly), but as far as I understand it, this only sends an email (no order is created), so this enquiry never reaches Commerce.


texts:
I have installed Login Destination and set the redirect URL as node/5.
Then I got the following message. Can anyone let me know what is this about? the functionality is also not working.

Your settings: (double-check them)
[ld_url_type] => 'static'
[ld_url_destination] => 'user'


texts: Changing output format of displayed body text

texts:
I imported node and comment body fields as "Full HTML" (they are coming from a trusted site).

Now I want to display those body fields differently, for example strip certain HTML tags. Do I just change the filters for "Full HTML" and use "Full HTML" as my "custom" input format? I could change the name of it, just want to make sure it have special significance in Drupal.

Or do I have to manually change them in the DB?


texts:
I have installed devel kint module on my drupal 8. Everything is fine with the module.

But my problem is how should I interpret the output of kint correctly. Especially when I want to render field within file entity.

Here is the scenario:

I have a form created with YAMLForm in my front. In that form user can upload image.
User submit the form.
When I debug data with kint, I can see the url of the image, but I am
unnable to display it thru .

Please find below a screenshot of the kint output

I have tryied with the following but no chance :

{{ file_url(data.picture['#value']['#file'].entity['#values'].uri['x-default']) }}
{{ file_url(data.picture.0['#item'].entity.uri.value) }}
{{ file_url(data.picture.entity.fileuri) }}

I've Googled for hours but couldn't find any clues.

Thanks in advance for your help.


texts: How do you set a node reference field's default value when creating a node programatically?

texts:
I use this:

$values = array(
  'type' => 'competition',
  'title' => 'my title goes here',
);
$node = \Drupal::entityTypeManager()
  ->getStorage('node')
  ->create($values);

This works perfectly. But the problem is, I also have a node reference field called "field_competition_node_reference". But this doesnt work:

$values = array(
  'type' => 'competition',
  'title' => 'my title goes here',
  'field_competition_node_reference' => 1,
);

How would one go about doing this? The value on the object is "target_id". Maybe that's why "create()" doesnt work?


texts:
In your MODULENAME.module file:
$testVariable = 'himanshu';
drupal_add_js(array('MODULENAME' => array('testvar' => $testVariable)), array('type' => 'setting'));
drupal_add_js(drupal_get_path('module', 'MODULENAME') . '/MODULENAME.js');

In MODULENAME.js file:
(function($) {
  Drupal.behaviors.MODULENAME = {
    attach: function (context, settings) {
      alert(settings.MODULENAME.testvar);
    }
  };
})(jQuery);

this way you can pass your php variable in drupal javascript file and use the variable :)
How can I implement the above in Drupal 8?


texts: How do I replace a string when using hook_node_view()?

texts:
I am trying to use hook_node_view() to replace, in the front page, <div>:placeholder1:</div> with the content of $string.

function mymodule_node_view(&$node, $view_mode, $langcode){
  $string = "I am here";
  $node->field_column_second['und'][0]['value']['#markup'] = array(
     '#markup' => str_replace(':placeholder1:', $string, $node->field_column_second['und'][0]['value'])
);

I also cleared Drupal cache, but I don't see any change.

What am I doing wrong?


texts: How to resolve 'Unknown data property commerce_product' when adding a product in Drupal Commerce?

texts:
I'm wondering if someone can help: I'm trying to add Drupal Commerce into an existing Drupal site, so I've followed the steps in this video about this topic and managed to install all modules without problems.

The issue I'm having is when I view a product I've added. Please note that I've added the product type. I can also add the node, but every time I try to view it I get this error (in the reports/error):

  EntityMetadataWrapperException: Unknown data property
  commerce_product. in EntityStructureWrapper->getPropertyInfo() (line
  336 of
  /my/local/server/php/mysite/sites/all/modules/entity/includes/entity.wrapper.inc).

I did follow all the steps in the tutorial. When I tried to view the product like in the video I get the error.

Any ideas?


texts:
I am currently using theme_menu_link() but it themes every menu in Drupal. I only want to theme my main menu. How can I check for a specific menu?

function theme_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

//if(id == main_menu){ theme it different }

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";

}


texts: How can I track stale content and alert content owners to it?

texts:
I'm building a new version of a corporate web site, and want to make it easy for content owners to keep their content updated regularly.

In the current site, most of the content has not been updated for years, and it's unclear who is responsible for various pieces of content.  In the new site, each part of the site (usually a section but in some cases individual pages) will have a person or group of people designated as the owners of that content, and responsible for keeping it updated.  I'm pretty certain, however, that they won't do anything unless they are prodded.

One possibility is to add a Dated boolean to all nodes to flag certain content as something that will go out-of-date regularly, such as an About Us page that says "we currently have 127 locations across states X, Y, and Z in the U.S. and provinces A, B, and C in Canada.  Then there would need to be some mechanism to send e-mail notifications to the designated owner of that content after (for instance) 3 months, including the content and a link to edit it, and asking them if it is still accurate.   Content not marked "Dated" could have e-mails sent out after (say) 9 months, or whatever time frame seems logical.

I've searched for a module that helps solve this problem, but have found nothing.  How would you go about doing this, or something like it (if you have an alternate idea to solve the problem)?


texts:
Though I am able to add items via ajax into a drupal jcarousel, the new items are not being registered and lack the jcarouselindex="N"  I've tried jQuery(target).reload but no luck.

Does anyone know what I need to do to get them recognised as new items in jcarousel? Here is the code in node-type.tpl.php:

<?php
jcarousel_add('.audioforumtable',
  array('vertical' => false, 'skin' => tango,'scroll' => 1)
);
?>

And here is the javascript:

Drupal.behaviors.ajaxlinks = function (context) {

    jQuery('.audioforumtable').jcarousel;

$('.morelink:not(.togg-processed)', context).addClass('togg-processed').each(function () {
    $(this).click(function() {
    var target = $('.newthing');
    var toLoad = Drupal.settings.basePath + 'replies/' + mynid;
          xhr = $.ajax({
          url: toLoad,
          success: function(data) {
    $(target).html($(data));
    jQuery('.audioforumtable').reload();
    Drupal.attachBehaviors(target);}
  });
});
}


texts: How to set a contextual filter based on an entity reference field

texts:
I am currently working on a radio website.
Here is the basic information to keep it simple.

I have two content types: [emission] (programme) and [podcast].
The [emision] content is merely a general presentation with the broadcasting time. The [podcast] content has a field [field_emission] in which I can make a reference to the [program] you can hear (it works with entity reference).

I have a View displaying all podcasts.
I have another display of that View, a block, shown only on the [emission] pages.
I want to restrict to results of the view to all [podcast] concerned with the displayed [emission]. How should I set the contextual filters.
Here is how I tried so far. Up to now, nothing shows up.


texts: Is drush.wrapper used anymore for Drush 8? How to use for Windows?

texts:
We have 3 devs working on a Drupal 7 site. Drush 8 is provided via a local composer file drush/drush:~8.0. A drush.wrapper exists in the project root containing:

cd "`dirname $0`"
DRUSH_ALIAS_FILE="./drush/MYPROJECT.aliases.drushrc.php"
DRUSH_LAUNCHER="./vendor/bin/drush.launcher"

if [ ! -f $DRUSH_ALIAS_FILE ]; then
  echo "No Drush alias file was found at ./drush/MYPROJECT.aliases.drushrc.php"
  exit;
fi

if [ ! -f $DRUSH_LAUNCHER ]; then
  echo "Drush Launcher was not found at ./vendor/bin/drush.launcher. Have you ran 'composer install' from the project root?"
  exit;
fi

$DRUSH_LAUNCHER --local --alias-path=./drush "$@"

This works for everyone; except the one user on Windows. They get an error along the lines of "drush.php was not found". If he removes the file, drush works (but then it is using the globally installed drush). This of course would break it for everyone else.

I am confused by the docs. How does one properly supply Drush 8 with a Drupal 7 project via Composer and have 'drush' work as a command from the project? I see issues saying the wrapper file is not needed anymore and other posts saying you need one.

edit: We started over and installed drush launcher per the documentation with the Windows .bat file. It still gives the error:

"Could not open input file /usr/local/bin/drush"


texts: Configuration successful but never gets imported

texts:
I have some changes in core.entity_form_display.node.news.default.  When I run drush cim -y it says it is successful but it actually never imports it.

drush cim -y
Collection  Config                                      Operation
             core.entity_form_display.node.news.default  update
Import the listed configuration changes? (y/n): y
The configuration was imported successfully.            [success]

The changes are removing field groups from the form display.

If I try to import via UI it also says it is successful but it never gets imported.  I don't get any errors in my error log.

I tried to make some other configuration changes like changing the site name and it works. It seems to be an issue with Field Group or at least when deleting a field from from a form display.


texts:
I have a basic File field set up to allow my users to attach files to nodes.

However, the File field widget in the node edit form displays files as a link to the file, and the URL contains #overlay-context=. Thus when users right click to copy the URL to the file, the URL includes the overlay context, and the link doesn't work (or images don't display).

How do I stop the Overlay module from adding that on to the File URLs on the node edit form?

I have the Insert module, IMCE, and IMCE WYSIWYG bridge enabled to provide users with other options, but some users (including myself) still prefer to right click the file name and copy the URL.


texts: Move the location of "Notify user of new account" from bottom to custom section of admin/people screen?

texts: Is it possible in Drupal 7 to move the location of "Notify user of new account" checkbox from the bottom of the page to another location on the admin user screen? I have a custom module with hook_form_user_alter. I have no problem hiding it from appearing, but I didn't know if I could move it to another location on the form and how would I go about doing that if it can be done.


texts: Site name cannot be changed for different languages and domains Drupal 7

texts: I have installed Domain Access, Domain Variable, Variable + i18n integration, etc. I have been able to change the value of site_lema for different domains and languages, but I cannot override the value of site_name, which is taken, apparently, from the Domain Access human readable name. I don't understand if that is a limitation, if I have something wrong in my Drupal (I have tested in two different installations), or there is some conflict with other module? Someone has achieved to have site_name changed for every possible domain/language combination?


texts: How should I handle container form elements?

texts:
I have added some custom fields to the register user form and I'm discovered that they are sent back, packaged in a form element of type "container". My code needs to handle all kind of different custom register fields.

How should I parse these objects and extract the fields from them? Should I look into the arrays and what can I expect to find there?

I can't seem to find any good documentation on these objects.

Edit:

A regular fields received through user registration might look like this:

name
... (Array, 10 elements)
#type (String, 9 characters ) textfield
#title (String, 10 characters ) Username
#maxlength (Integer) 60
#required (Boolean) TRUE
#attributes (Array, 1 element)
class (Array, 1 element)
0 (String, 8 characters ) username
#default_value (String, 0 characters )
#access (Boolean) TRUE
#weight (Integer) -10
#fb_registration_field (String, 4 characters ) name

A form container looks e.g. like this:

field_birtyday
... (Array, 6 elements)
#type (String, 9 characters ) container
#attributes (Array, 1 element)
#weight (String, 1 characters ) 7
#tree (Boolean) TRUE
#language (String, 3 characters ) und
und (Array, 13 elements)
0 (Array, 12 elements)
#entity_type (String, 4 characters ) user
#bundle (String, 4 characters ) user
#field_name (String, 14 characters ) field_birtyday
#language (String, 3 characters ) und
#field_parents (Array, 0 elements)
#columns (Array, 2 elements)
0 (String, 5 characters ) value
1 (String, 6 characters ) format
#title (String, 8 characters ) Birthday
#description (String, 0 characters )
#required (Boolean) FALSE
#delta (Integer) 0
#weight (Integer) 0
value (Array, 16 elements)
#entity_type (String, 4 characters ) user
#bundle (String, 4 characters ) user
#field_name (String, 14 characters ) field_birtyday
#language (String, 3 characters ) und
#field_parents (Array, 0 elements)
#columns (Array, 2 elements)
0 (String, 5 characters ) value
1 (String, 6 characters ) format
#title (String, 8 characters ) Birthday
#description (String, 0 characters )
#required (Boolean) FALSE
#delta (Integer) 0
#weight (Integer) 0
#type (String, 9 characters ) textfield
#default_value (NULL)
#size (String, 2 characters ) 60
#maxlength (String, 3 characters ) 255
#attributes (Array, 1 element)
#theme (String, 25 characters ) field_multiple_value_form | (Callback) field_multiple_value_form();
#field_name (String, 14 characters ) field_birtyday
#cardinality (String, 1 characters ) 1
#title (String, 8 characters ) Birthday
#required (Integer) 0
#description (String, 0 characters )
#prefix (String, 42 characters ) <div id="field-birtyday-add-more-wrapper">
#suffix (String, 6 characters ) </div>
#max_delta (Integer) 0
#after_build (Array, 1 element)
0 (String, 30 characters ) field_form_element_after_build | (Callback) field_form_element_after_build();
#language (String, 3 characters ) und
#field_parents (Array, 0 elements)


texts: How can I enforce a minimum length for private messages?

texts:
I previously asked how to enforce a minimum length for fields and received some great answers.

Now, I would like to enforce a minimum length for private messages only when it is the first message in a conversation (the private message module calls "threads" of messages conversations).

Use case: I don't want users to be able to send messages consisting only of "hey" or "hi"; thus, I need to enforce a minimum length for the first message.  However, once users are talking to one another, it is completely possible that a reply could be "yes" or "no", etc., so follow-up messages should not be limited in length.

Looking through the Privatemsg API, it looks like this might be able to be done with hook_privatemsg_message_validate(), but I'm not much of a coder and I'm at a loss about how to proceed from here.


texts: Can I change the location of the cached Twig templates?

texts:
By default, the Twig template cache appears to go into /files/php/twig.

I was wondering if it's possible to change this location? I use a shared file mount which is shared between multiple developers and my concern is that the Twig cache will be in competition with another developer.

Alternatively we can disable caching but this is not always appropriate.


texts: Correct way to render an custom entity and its custom field?

texts:
In my module, I have a custom entity LocationEntity and it uses a custom field type CoordinateItem which has 2 sub fields X, Y.

So what is the correct way of Drupal 8 to:

1) Render this LocationEntity in a twig template?

What I'm doing is just send the entity to twig template '#loc1' and manually render its each field value using getter method {{ loc1.getName() }}. It works but I'm sure this is not the correct way to do.

2) If question 1 has another correct way then how to have more than one templates for rendering the entity?

For example, one simple layout with less fields and one detail layout with all fields.

3) In the entity, I defined to use the custom field CoordinateItem. But now what to do with its getter and setter, because it's not a single sub field inside?

Getter if $this->get('coord') -> a FieldItemList object.
Getter if $this->get('coord')->value -> null.
Setter? What type is the parameter?

4) I wrote a formatter for CoordinateItem to show its sub fields. But again I don't know how to use this formatter to render this custom field in the main (entity) template?

Maybe this is related to question 1 and 2?


texts: Block with the same function as page of Taxonomy term view

texts:
Is there any way to replicate as block which displays all nodes associated with the end of the url, like page view ( Taxonomy term view -A view to emulate Drupal core's handling of taxonomy/term.)  but in a block.
Example in url news/term1 the block should be able to show all nodes with the term term1.

Thank


texts: Can Colorbox browse admin/content/media from Media rather than file uploads?

texts:
Is it possible to configure Colorbox for Drupal D7 to use content already stored by the Media module (in admin/content/media) rather than use a file upload? The alternative is either:

Upload duplicate images per node (e.g. article, page...)
Link to the original image which requires the author to search nodes to find the image and copy/paste the URL while risking a broken image if the original node is deleted (i.e. the image is deleted with the node).

Thanks


texts: Drupal views get fields after filters without html markup

texts:
I have a question about Drupal 7 and Views. Let's assume that I have views where I extract 2 articles ordered by post date. I want to extract only title and trimmed introduction (trim configured in field settings in view)

Now I would like to extract this data programmatically without HTML markup. So the result will be similar to this:

array(
    0 => array(
        'title' => 'Lorem ipsum',
        'introduction' => 'Lorem ipsum dolar solor...'
    ),
    1 => array(
        'title' => 'Lorem ipsum2',
        'introduction' => 'Lorem ipsum2 dolar solor...'
    )
)

Is it possible to extract such information from views?
I tried to do something like this:

$view = views_get_view('view_name');
$view->set_display('display_id');
$view->execute();
$data = $view->result;

But $data contain two elements with full nodes (all additional fields that I don't want to grab from database)

In addition for instance introduction is grabbed fully (must be trimmed somewhere in PHP).

Is it possible to do something like this:

$view->applyFilters(); //Like trim etc
$data = $view->getResults(); //return title + trimmed introduction but without HTML markup

Do You have any tips how to solve this problem? Is it possible for instance to pass template that will be rendered (where I could display only raw result without any HTML tags) or something?

Any help would be appreciated:)


texts: Getting Drupal to work with Mercury Mail Server on Local Machine

texts:
I've successfully set up Mercury Mail Server on my local machine using the XAMPP stack to send mail through a remote SMTP Server by following the configuration directions posted at:
https://www.zoe.vc/2008/mercury-mail-transport-system-fur-externe-mail-konfigurieren/
If mail is sent to either local or external email addresses via a regular mail client, e.g. Thunderbird, Mercury Mail processes the mail appropriately and the mail arrives in the expected mail boxes.

However, sending mail through my local Drupal 7 site does not work.

For example, the site includes a set of rules built with the Rules module that are configured to send mail to a set of email address when triggered.
Drupal reports that it successfully sends mail to the targeted addresses when the rules are fired.
But Mercury Mail doesn't show any evidence that the mail is being processed -- and the mail never shows up in at the addressed mailboxes.

In summary, mail from Drupal is not getting to the server, but Drupal thinks that it has been successfully sent.  Note, as per the directions from zoe.vc, the [mail function] configuration in php.ini is setup as:

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = localhost
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = postmaster@localhost.com

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.

; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
sendmail_path = "C:\xampp\mailtodisk\mailtodisk.exe"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\php\logs\php_mail.log"

I've spent countless hours trying to figure this one out.  Any help getting this to work via   drupal so that I can continue development will be greatly appreciated. Thanks in advance.