texts: views_query_alter Matching all values in IN clause

texts:
I have a content type with a list(text) field. In which the admin can set multiple values on the field for the content type. Using a view the information is exposed to the end user. The views has a exposed filter to filter the list(text) field. However multiple options can be selected and need to be checked against the values set by the admin. The way Drupal views does this is by joining the table as many times as the amount of values being searched for, resulting in a very slow query.

I am now looking to do this with the query adjustment below inspired by this post:
https://stackoverflow.com/questions/11636061/matching-all-values-in-in-clause

However I have no clue on how to include the HAVING combined with COUNT as suggested in de post from the link above within Drupal.

$field_values - array(1, 4)
$query->where[1]['conditions'][0]['field'] = 'field_data_field_listtext.field_data_field_listtext_value';
$query->where[1]['conditions'][0['value'] = $field_values;
$query->where[1]['conditions'][0['operator'] = 'IN';

Suggestions on solving the SQl query performance in other maners for exposed filters on list(text) are also very wecome.


texts: I need to add captcha for node edit form, not for the front-end form. please can any one help me?


texts: How to show first X items and add and ellipsis [...] if there is more items?

texts:
I have a View that displays books and authors of each book.

BOOK 1

Author 1, Author 2, Author 3, Author 4, Author 5

BOOK 2

Author 6, Author 7

What I want to do is to show only first 3 authors of each book and add an ellipsis [...] if there is more authors. It's easy to display first 3 items (Multiple Field Settings) but how to add an ellipsis to it?

BOOK 1

Author 1, Author 2, Author 3 ...

BOOK 2

Author 6, Author 7

How can I do that?


texts:
I've looked far and wide and am unable to resolve why my article images are not appearing on the Front Page. (Even disabled my CSS to see if that was interfering with it, but no.)

I have created a simple test Article and uploaded an image, yet when it's promoted to the front page, the image does not display.

Only the title, and body displays. When I click on the article, it displays the image, is there a setting I'm missing for this to display?


texts:
According to the Form API, you control the number of columns in a textarea with the #cols attribute. However, setting this seems to have no effect when I use it inside a $form array (the companion #rows attribute works as expected).

This is question is already on stack overflow however the answer utilizes css instead of the cols attribute which seems like a cheat.

    $form['message'] = array(
        '#type' => 'textarea',
        '#title' => t('Message'),
        '#resizable' => FALSE,
        '#cols' => 20,
        '#rows' => 10,
    );


texts: How are custom classes auto-discovered and picked up?

texts:
I've been trying to get this sub module working for the better part of 8 hours, but I cannot get any debug/log statements to fire inside the sub module.

Since its only 3 files, I copy pasted the code out into an enabled custom module, changed the namespace and tried to see if I could figure out what was going on. In short, this code extends:

modules/contrib/better_exposed_filters/src/Plugin/better_exposed_filters/filter/DefaultWidget.php with
modules/contrib/selective_better_exposed_filters/src/Plugin/better_exposed_filters/filter/DefaultWidget.php

and

modules/contrib/better_exposed_filters/src/Plugin/better_exposed_filters/filter/RadioButtons.php with
modules/contrib/selective_better_exposed_filters/src/Plugin/better_exposed_filters/filter/RadioButtons.php

However, despite heavily modifying both the these files in both better_exposed_filters and selective_better_exposed_filters I couldn't get any debug or log information to show.

Now, better_exposed_filters DefaultWidget.php file extends another file called FilterWidgetBase.php. If I modify THIS file I can change what appears in the form. However, if I copy/paste this exact file into an equivalently named file in my custom module and change the namespace, nothing happens.

It 'feels' like Drupal simply isn't discovering these custom classes that extend the better_exposed_filters core classes. Without error output I cannot know for sure, does anyone know if this is the issue? Any best practices for debugging this sort of thing?


texts: Add validator and description to file upload form

texts:
I want to check the min width of a picture when using the file upload form (file_entity_add_upload).

normally I would do

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

  // Adds a description to the upload field.
  $form['file']['#description'] = t('Min width @limit pixels', array('@limit' => 768));

  // Specific validations.
    $form['#validate'][] = 'budg_eu_project_file_entity_add_upload_validate';
}

but that doesn't work.

How should I declare the description and the validator?


texts: Custom input text field by using field handlers

texts:
I'm beginner in Drupal 7. I've searched and wasted my time a lot but unsuccessful to find the solution.

I have to add a custom input text field by using field handlers in the views?

Kindly guide me to the right track?


texts: Adding the is_front variable to a Paragraphs template

texts:
Is the is_front variable not available in a Paragraphs template override?

I'm trying to do the following:

          {% if is_front and content.field_section_title %}

{{ content.field_section_title }}

          {% elseif content.field_section_title %}

{{ content.field_section_title }}

          {% endif %}

          {{ content.field_text }}

          {{ content.field_section_image }}

However, when I set a node that uses this paragraph type as the homepage, it doesn't take the is_front condition and just uses the h4 tag instead of the h2 which is what I would like for it to do.

Is there a way for my paragraphs templates to use the is_front condition? Or is there a different way to go about this?


texts: Insert value to field programmatically and remove cache from field

texts:
I have content type feature and i have field hit_count in this c.type, also i have db table - hit_count - example:

nid   hit_count

1     434
2     233
3     512

I want to output hit_count inside my field - hit_count on current node(also should appear on node edit). So for example if node id is 1, field hit_count = 434, and if admin want to edit this field i want to update field value to my table hit_count with current nid and field value hit_count.

To save value into my database table i will use hook_node_update and just get fields nid and hit_count values and update my table.

But i don't know what hook should i use or how to insert this value from database to my field. There are lots of nodes with content type feature.

UPDATE

  My first thought is - why do you use a separate db table for this rather than simply using an integer field in the content type?

Hit count module was created long time ago, client wanted to disable/enable statistics for every content type, so default statistics module does not fit our needs. And now client want to manage this hit counts for certain nodes etc...

Also i managed to insert value to edit form on hook_exit updated custom hit count module.

function hit_count_exit($destination = NULL) {
    if ($node = menu_get_object()) {
        $selected_types = array_filter(variable_get('hit_count_content_types', array()));
        if (!empty($selected_types)) {
            if (in_array($node->type, $selected_types)) {
                db_update('node_hit_counter')
                        ->expression('totalcount', 'totalcount + 1')
                        ->condition('nid', $node->nid)
                        ->execute();
                if($node->type == 'feature') {
                    $val = db_query("SELECT * FROM {node_hit_counter} WHERE nid='$node->nid'")->fetchAll();
                      db_merge('field_data_field_hit_count_node')
                        ->key(array('entity_id' => $node->nid))
                        ->fields(array(
                                'entity_type' => 'node',
                                'bundle' => 'feature',
                                'deleted' => 0,
                                'entity_id' => $node->nid,
                                'revision_id' => $node->nid,
                                'language' => 'und',
                                'delta' => 0,
                                'field_hit_count_node_value' => $val[0]->totalcount,
                        ))
                        ->execute();
                }

            }
        }
    }
}

But right now i see next problem. I need to get rid of Drupal field cache, cuz i see cached value every time i reload page, and if i clear all caches i get current value of hit_count.


texts: No welcome email sent when users register via profile2 registration path

texts:
I am using profile2 registration path for two different types of roles. The roles are auto-assigned when users register via one of the paths. I have used mail logger to check and the emails are not sent. Other types of emails are sent. I can block the new users then unblock them and registration emails are sent.

When a user is registered via the regular user registration (/user/register) an email is sent.

I am using Drupal core 7.59, profile2 7.x-1.4, profile2 registration path 7.x-1.13.

Any ideas about how to fix this?


texts: What are the differences between Search API/Views and regular Views?

texts:
What are the differences between setting up Search API (with the Search Views module) and creating a particular set of results with Search Views against using Views is the normal manor?

The big difference I can see straight away is the Search Facets and being able to easily create the blocks that filter/facet the search results.


texts: Migrate users datas to the profile module

texts:
I’m able to migrate users datas from a csv file with migrate, migrate_tools, migrate_source_csv and drush

Now, i’m trying to import datas from the same csv file to the Profile module (which provides configurable user profiles).

Here is my configuration file for user import. Obviously, i I add the profile fields in it (here field_profile_last_name, it doesn’t work).

id: user_migrate
migration_tags: null
migration_group: null
label: 'User migration from CSV'
source:
  plugin: csv
  path: /path-to-csv/users.csv
  header_row_count: 1
  keys:
    - weblogin
process:
  # user fields with custom fields : works !
  name: weblogin
  mail: email
  roles: roles
  field_last_name: nom_salarie
  field_first_name: prenom_salarie
  field_password_web_services: weblogin
  status: status
  field_profile_address: adresse1
  field_code: code
  field_date_de_naissance: date_naissance
  field_numero_societe: numsoc
  field_profile_function: qualification
  # profile fields : doesn't work
  field_profile_last_name: nom_salarie
destination:
  plugin: 'entity:user'
migration_dependencies:
  required: {  }
  optional: {  }

How can i migrate datas to the profile module ? What is the entity for this module.


texts: Moving a div down if a zone is present using jQuery

texts:
I'm trying to move a <div> down if a zone is present, but I'm having a little trouble targeting the right classes, etc.

// See http://jsfiddle.net/xgbzm/.
(function ($) {

  if (!$(this).hasClass('responsive-layout-normal')) {
    if ($('.page .section-header .zone-ticker-wrapper', this).length < 0) {
      $('.qtip .qtip-wrapper', this).css('margin-top', '65px');
    }
  }

})(jQuery);

How can I achieve it?


texts: How to allow content tagging by anonymous users?

texts:
I have a site, where the main purpose is the involvement of the public in their history. However, we all know some just don't want to register for a user profile with websites. In our case, there are some who would like to participate in tagging photograph nodes, without having to register.

So that is my question: how to allow anonymous users to tag photographs how they see fit, along with the obvious review process that would need to take place just in case? I've seen this feature on other sites, and have tried to contact the web admins, but have yet to hear back.

I know there is the module "Community Tags" and that works all fine and all but there are currently two problems I see with it (and if you know a solution that is staring me in the face, please let me know):

The anonymous users are allowed to post, but there is no review.
The tagging by the anonymous user does not sync at all with the only term reference field in the content type, so if I type one tag into one, it won't show up in the other. Both will post correctly to the list of taxonomy terms, but won't sync for the same page.

Any solution to my problem? Or maybe even an entirely better way of doing this altogether?


texts: How to put a node in a menu using an URL parameter?

texts:
While creating a new node, I'd like to pass a parameter in the URL: node/add/page?plid=123 in order to put the newly created node in this menu item as its child.

I tried to hook_form_alter() the node form but I couldn't populate the menu part, also I'd like to hide this part to the end user as they shouldn't alter it.

Should this be done in a hook_node_insert() with something like this answer: How to enable menu link when creating a new node ?


texts: Can I aggregate all stylesheets core, contrib and custom into one single stylesheet?

texts:
Is there any way to avoid Drupal from serving multiple stylesheets and instead bundle them together? I am going to look into https://www.drupal.org/project/webpack

I want to avoid all the multiple @imports if possible that get created by the modules. Reason I want to do this is I am archiving my site with wget and I want to have less stylesheet links to monitor.


texts: Define config schema on an installation profile

texts:
I have a custom installation profile, which has a profiles/foo/config/install/foo.settings.yml.

I try to declare a schema in profiles/foo/config/schema/foo.schema.yml but it seems that file is not picked up upon installation (it doesn't appear in config-inspector).

Is there a special way to declare the schema for the profile


texts: How can I configure drupal to share modules between two installations on the same server?

texts:
Say I want to run siteA.com and siteB.com from the same remote server. How can I share the modules but not site specific configuration. I don't want them to have the same titles use the same modules but it seems a waste of space to be installing the same modules if they are running on the same server.

Please note: I selected the answer below because it looked like an answer. However, seems to be useful only if the server is local? I do not use the terminal to connect to my site. I wouldn't be sure how to go about that either other than trying to do it via some shh connection.


texts: How do I create content of the day/week/month?

texts:
I have a (growing) number of articles. I want to display one on the homepage as article of the week, although that week will probably be a day in the beginning and a month later on. I also want a specific editor be able to choose which of those articles will be the chosen one for a given time period. There will only be one chosen article for any given time. What is the best way to do this (preferably without programming)?

I first thought of creating a vocabulary (with a date field and an entity reference to an article field) for this where the editor can simply add days/weeks/months as they come and select from the articles. The bad part here is that the name field is required and I cannot ui wise set it to take the name from the actual date field.

Making it then a custom content type instead would probably work, but seems overkill.

Adding an article of the timeperiod date field to the article content type would also seem to encapsulate all the necessary information, but how do I expose this to the editor?

I want the editor to see a list of the coming say 20 months and assign to each an article on the same page (a single save operation from the editor's point of view). I also want the editor to be able to override that for specific shorter time periods.

I'm using Drupal 7.


texts: How to conditionally display field contents in Views

texts:
I want to edit my View so that it only displays a certain contents if some field in my content type had been set. I installed the Views PHP plugin, but it's currently not producing the desired results.

This is the current example I have - using the custom php field, where field_link_to_page is a checkbox field in my content type that decides what contents are to be displayed:

<?php
// Field is configured to return "1" if it's checked, or "0" if it's unchecked.
if ($row->field_link_to_page =="1") {
    echo $row->body."
[NID]
<?php
echo "\">more...";
}
else
{
    echo $row->body;
}
?>

Removing this code, and doing a var_dump() on the field, returns something like this:

object(stdClass)#250 (7) { ["field_year"]=> string(3) "113" ["field_month"]=>
string(3) "113" ["field_day"]=> string(3) "113" ["title"]=> string(73)
"Forecast opening day for Talking Rock Golf Course (conditions permitting)"
["body"]=> string(3) "113" ["field_link_to_page"]=> string(3) "113" ["php"]=>
NULL } 113

which is confusing because the contents get rendered nicely by Views but here it only looks like it's handles to something (113). How can I render the contents correctly in php?


texts:
Basically, How to port following function in Drupal 8?

drupal_add_http_header('Content-disposition', 'attachment; filename=' . $filename);

Note: I went through "Replacement for drupal_add_http_header()", but my requirement is different. I need to download a file on form submit button.


texts:
I have been puzzling for weeks now and still cant find how to change a newsletters layout in simplenews in D7.
Must say I inherited the website and, as the owner wants to create a blog and send these updates, i was looking for a solution.
At the moment i created 2 newsletter categories: blog and newsletter.

Mail System settings are:

Site-wide default MailSystemInterface=>defaultmailsystem

HTML Mail module class: HTMLMailSystem

Mime Mail module class: HTMLMailSystem

Maillog / Mail Developer module class:HTMLMailSystem

Simplenews module class: HTMLMailSystem

Theme to render the emails: =>custom theme

under /admin/config/system/htmlmail the custom theme as also been enabled.

All code is in page.tpl.php and when I change something there it has effect on everything.
I can send out mails with the current setup but I do not know how to theme according to the different newsletters.

I'd like to change only 1 image in the whole system but still cant find how to do this. At this moment this image is set as a fixed path in the page.tpl.php file. I tried to create a block and use it as header, but it always remains that same image when sent.

I've also tried to:

 create page--blog.tpl.php and a page--blog--blogpost.tpl.php yet without any result.

created an htmlmail--simplenews--[23].tpl.php file...without results.

What is it that I cannot see? Can anybody hand me a solution?
Thank you in advance


texts:
Im developing a module which shows a bar (fixed, top, z-index 99999) with some content. When im in the admin interface with overlay, I want to hide the module, right now the bar is overlapping the overlay.

This code is working well if the overlay is not activated

if (arg(0) == 'admin' || arg(0) == '#overlay=admin') { $output = NULL; }

only the arg(0) == '#overlay=admin' part is not working,

any ideas?

Thanks in advance


texts: Why can't I add a condition and exclude unpublished nodes from search?

texts:
I have this code for searching nodes:

$index = search_api_index_load("node_index");
$qry = new SearchApiQuery($index);
// $qry->condition('status', '1', '=');
$qry->keys($keywords);
$data = $qry->execute();
$node_results = $data['results'];

This code works only if condition is commented. If I uncomment the condition I get a fatal error:

  SearchApiException: Unknown field in filter clause: status. v SearchApiDbService->createFilterCondition() (riadok 1668 z C:\xampp\htdocs\gelightcz\sites\all\modules\search_api_db\service.inc).

What could be wrong?


texts: How to hide a block enitirely which has empty content (unless for a specific role)?

texts:
I have a custom block and I want to limit it only to one role. The position of this block is administrator->dashboard.

I have set the visibility settings of block to be shown only to role editor, but when I sign in with a user whose role is something else, such as a photographer, it shows the block with a text in it: "(empty)".

It truly does not show any content, but I WONDER why it shows the block's structure? I expect it to be totally invisible as if no such block ever exists.

What's wrong with it?


texts: Display taxonomy term description when mouse hovers

texts:
I created a taxonomy and added vocabulary with terms(each term has a description). Included the vocabulary to an auto-complete field. It all works good.

In the auto-complete field, terms appear in a drop-down menu as a list without any description.

Here, I want to add a feature for the field in such a way that when the user hovers through the terms in the drop-down menu it should display its corresponding description.

And, Also have an idea of implementing the stackexchange Tags drop-down feature. I like the SE approach of displaying the tags (as buttons) and its corresponding description (below the button). I'm loving it.

Either way is ok, displaying the description when mouse hovers and SE drop-down feature.


texts: How do I print a specific meta tag attribute value in html.tpl.php?

texts:
I am trying to create WebSite schema condition output in html.tpl.php in Drupal 7, so installed schema.org module, but it doesn't come with all the fields that my project required, for example, description. How do I get the description value from "admin/config/search/metatags/config/global%3Afrontpage"?
What I have so far.
<?php if(drupal_is_front_page()) {
$logoSchema = theme_get_setting('logo');
$urlSchema = $GLOBALS['base_url'];
echo '
<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "'. $urlSchema .'",
  "name": "Company Name, Inc.",
  "image": "'. $logoSchema .'",
  "description": "**NEED HELP GETTING THE VALUE**",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "'. $urlSchema .'/search/{search_term_string}",
    "query-input": "required name=search_term_string"
  }
}
</script>';
} ?>
</head>


texts: How can I remove the "Your vote was recorded." message in the polls?

texts:
I need to delete the message "Your vote was recorded." when a user votes in a poll.

I tried comment the line containing drupal_set_message(t('Your vote was recorded.')) in the Poll module, but if I do this, the Poll Enhancements module doesn't work well.

What other way has Drupal 7 for deleting specific messages?


texts: Pager disappears when adding "GROUP BY" in the SQL query

texts:
Drupal pager disappears when I add GROUP BY to the query.

This code works.

$countSql = "SELECT  COUNT(*) FROM journal ";
$sql = "SELECT  * FROM journal";

$result = pager_query($sql, 1, 0, null, $countSql);
theme_pager(NULL, 10)

This code doesn't show the pager.

$countSql = "SELECT  COUNT(*) FROM journal ";
$sql = "SELECT  * FROM journal GROUP BY id";

$result = pager_query($sql, 1, 0, null, $countSql);
theme_pager(NULL, 10)

What is it wrong with the latter code?


texts: Cannot use drupal_set_messages in a custom controller module

texts:
In a custom controller, when I try to use drupal_set_message() in a custom Module Controller it works only if I put :

drupal_set_message('Test error', 'error');

return array(
   '#type' => 'markup',
   '#markup' => "Welcome",
);

=> the message is shown via {{ page.highlighted }}

If I put :

drupal_set_message('Test error', 'error');

return array(
   '#type' => 'page',
   '#markup' => "Welcome",
);

It doesn't work... I need to put a type page to be able to inject custom variables. Does anybody can help me to understand how it works ? I try to read the docs and a Drupal 8 book but I really don't understand how that works.

Thanks !


texts: Content Translation : Language filter not available in views

texts:
I use a view to show a list of nodes flagged by a global flag (any user, any language) and would like to return only current language related nodes.

For that I should be able to add a filter in the View which is something like "Content Translation: Language". However no such filter seems to be available. Any idea why this filter is missing?


texts: How to rearrange View fields in different order

texts:
I have a View with 4 rows & 2 columns. Each item is composed of an image & title. The left column needs an image on top & title on bottom,
the right column needs to invert that order.

How can I do that for 2 different fields?

Left Column Order:

Right Column Order:

Is this possible with views?


texts: Only display profile edit button on personal profile page

texts:
I'm using the profile module and am trying to display a profile edit button on your personal profile page.

my profile.html.twig:

{% if is_current_user %}

        {{ "Edit profile"|t }}

  {% endif %}

          {{ content|without('field_image', 'field_extra', 'field_tags') }}

{{ content.field_extra }}

      {{ content.field_image }}
      {{ content.field_tags }}

The a-container div may only be displayed if the current user id is equals to the user id of the user linked to the profile that's being displayed.

I'd like to make this check in a preprocess function and return a bool 'is_current_user' to profile.html.twig but I'm stuggling to find the right hook for the profile page.

I'm on drupal 8.7.1.

Thanks in advance!


texts: How do I change the overridden feature to default

texts: I got "overridden" for two settings. I wanted to know why this is happening, and how to get rid of it in a proper way.


texts: Mini pager work with ajax but not full pager?

texts:
I don't know if someone has ever expected this error but i can't find "why" it's not working.

In the same page, i have 2 blocks. Each block represent a different view.

The first have mini pager, the second, full pager.

Mini pager is working well, full pager reload the page each time (Yes, i have Use AJAX to Yes).

The only differences i can see are into the HTML (The mini pager UL have class "pager" and the LI have class "pager-prev" and "pager-next"). In the full pager, UL have no class and LI have classes "next" and "prev".

Full pager is suppose to use ajax?

Thanks for your help folks!


texts:
I created a custom tpl file for one of my content types and I would like to check the users profile as well if they were the publisher and if it all checked out then proceed to the tpl file.

Here is an example

if(publisher and profile){
   proceed to tpl file
}else{
   You are not authorized to view this page.
}

If someone can point me in the right direction that would be great, thanks.


texts: how to remove WIDTH and HEIGHT from img-tag in Drupal 8

texts:
Does anybody know how to remove width and height?

I want that the img tag looks like this


texts: Is it possible to style the new node page?

texts:
Is it possible (with Drupal 7) to style the new node page?

I can add content by going to node/add/article, but I want this to be on its own URL and styled like my site's theme.

Is this the correct way to go about this? Or is it better to create a new module with validation to submit data back to the database?


texts: How to create a view that searches nodes and users at the same time?

texts:
I'm creating a custom search to my site using Views.

I want to search both nodes and users at the same time, with exposed filters like this:

[ ] events
[ ] bands
[ ] products
[x] users

But when creating views I have to specify if I want to list nodes, or users, or files etc.

How can I search through two tables at same time?


texts: Why does my newsletter keep sending the same copy our time and time and time again?

texts: When I send a Simple News newsletter out in Drupal 6, subscribers get as many as ten copies of the same newsletter. The only way I can stop it is by deleting the page. This problem did not happen in Drupal 5 and only started when upgraded to 6. Any ideas?.


texts:
I have a view that outputs list items as links. Like so

Link 1
Link 2
Link 3
Link 4

I need to be able to wrap those items in

And close them. However when I attempt to do this in the template. Or in a basic page that is using a function to display the view.

When I attempt

        <?php print views_embed_view('mobile_slide_menu','block');?>

I end up with

Link 1

Link 2

Link 3

Link 4

Which doesn't work for my list. Is there any way to take only the list items and prevent it from being wrapped in all those containers. And if not is there a way to append the opening and closing tags of 'nav' and 'ul' within the view?


texts: Configuration variable inside a hook take always the default value in a PHPUnit test

texts:
I'm trying to create a Functional test for the dev version of the No Autocomplete module to test that if the configuration is set then an autocomplete attribute=off will be added to the password edit in the user login form.

<?php

namespace Drupal\Tests\no_autocomplete\Functional;

use Drupal\Tests\BrowserTestBase;

class FormTest extends BrowserTestBase {

  protected static $modules = ['no_autocomplete'];

  public function testUserLoginForm() {

    $account = $this->drupalCreateUser(['administer no_autocomplete']);
    $this->drupalLogin($account);

    $this->drupalGet('/admin/config/people/no_autocomplete');

    $edit = [
      'no_autocomplete_login_form' => 1,
    ];
    $this->drupalPostForm(NULL, $edit, 'op');

    $this->drupalLogout();
    $this->drupalGet('/user/login');

    $this->assertSession()->elementAttributeContains('css', '#edit-pass', 'autocomplete', 'off');
  }

}

So basically I'm trying to test this hook after that the configuration is set:

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Turn off autocomplete on key forms.
 */
function no_autocomplete_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  // Add to the user_login.
  if (\Drupal::service('config.factory')->get('no_autocomplete.settings')->get('no_autocomplete_login_form')) {
    $form['pass']['#attributes']['autocomplete'] = 'off';
  }
}

The problem is that the module works as expected, but when I run the test this line inside the hook:

\Drupal::service('config.factory')->get('no_autocomplete.settings')->get('no_autocomplete_login_form')

Always return FALSE, because this is the default configuration value that comes in the no_autocomplete.settings file, if I change the value from FALSE to 5, the 5 is returned. But when I check the value of the config in the test it assert correct with TRUE, inside the test the value is TRUE but inside the hook the value is FALSE (or whatever the default value of the variable is) I check the value in the test with the following lines:

$config_factory = $this->container->get('config.factory');

$no_autocomplete_login_form = $config_factory->get('no_autocomplete.settings')->get('no_autocomplete_login_form');

$this->assertSession()->assert($no_autocomplete_login_form == TRUE, t('The default configuration value for no_autocomplete_login_form should be TRUE.'));

$this->assertSession()->elementAttributeContains('css', '#edit-pass', 'autocomplete', 'off');
  }

}

So, the configuration variable have TRUE as value, but inside the hook the value is always FALSE, so the autocomplete=off attribute is never added to the form element en the test fail.

I'm trying to read in the wrong way the variable inside the hook or I'm missing something here?

EDIT: It seems a cache problem, if I clean the cache inside the hooks the test is OK, but the only problem is that I really don't need to clean the cache for made the module works.

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Turn off autocomplete on key forms.
 */
function no_autocomplete_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  // Add to the user_login.
  drupal_flush_all_caches();
  if (\Drupal::service('config.factory')->get('no_autocomplete.settings')->get('no_autocomplete_login_form')) {
    $form['pass']['#attributes']['autocomplete'] = 'off';
  }
}

So I don't know now if this is a Drupal or PHPUnit issue. Any ideas?


texts: How to make booking calendar for accommodation facility

texts:
I have web, let's call it AccomovationInSkyResort.com. It has 2 facilities with 3 entities which can be booked out (reserved):

Appartment house:

a) 1th floor (1)

b) 2nd floor (2)
Cottage (3)

How to make "booking (reservation) calendar" for accommodation facility?

By "booking calendar" I mean calendar showing available (not booked out) nights. I need 3 calendars at all.

I did some experiments with calendar module but it isn't so nice solution.

How did you solved this problem?


texts: Pasting text from GoogleDocs into D7 Body field causes imagestyle error?

texts: Super strange - I'm copying and pasting text from a GoogleDoc into a D7 article post. When I do this and publish my article, it drops onto the main page into a slider that I've created via a View. This works seamlessly usually, however when I paste the text from the googledoc, it actually distorts my entire main page - seemingly stripping the image styles from my other article posts in the slider, thus, ruining my slider? Any idea why this is and how I can fix it?


texts: Update cart on checkout page with tax rule

texts: I have a tax rule which applies when a user uses Utah as shipping place.But it takes a review order page in between to make it work. Is it possible to update the cart on checkout page soon a user chooses Utah as state.


texts: Drupal.behaviors js code executes mutiple times (depends on active modules)

texts: I have two almost similar websites (one was a test project) and second one is more like final version. On both of them i have quite simple custom module with js and on first web site it works fine, but on the second one - problem is that code in js executs many times (6-10 times), it depends on active modules - i uninstaled some modules and amount of times that js is execute drops down... js file is simple like alert("hi");   and it gets printed like 10 times... i gues that one module couse this issue but i dont know whitch one. maybe someone had such issues? or some advice on how to find out whats wrong.


texts: Let Composer place a Git repo into a custom path

texts:
How to place git repo to a custom path? I am using composer/Installer. and I have develop a module on git repo. I would like to add it to composer.json but after pull it should be placed web/modules/custom directory. How can i do that.

I added this parts in my composer.json

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/miteshmap/axelerant_custom"
    }
],

"require": {
    "miteshmap/axelerant_custom": "*"
},
"extra": {
    "installer-paths": {
        "web/core": ["type:drupal-core"],
        "web/modules/contrib/{$name}": ["type:drupal-module"],
        "web/modules/custom/{$name}": ["type:drupal-module"],
        "web/profiles/contrib/{$name}": ["type:drupal-profile"],
        "web/themes/contrib/{$name}": ["type:drupal-theme"],
        "drush/contrib/{$name}": ["type:drupal-drush"]
    }
}


texts:
I posted JSON array from my script using jQuery.post , to get the posted data in my drupal module function I am using

$json = file_get_contents("php://input");

but is there a better way or a 'drupal-way' to get posted data in a drupal function?


texts: How do I apply different css files to different viewports with Omega subthemes?

texts:
I´m working with an Omega 3.x Subtheme in Drupal 7.
I´ve been reading the handbook of Omega, specially about the layered css files.

Even if I do understand that the layer structure of the default responsive css files is (from bottom to top): global → default → narrow → normal → wide, I can´t mach that to the Grid Settings UI, and I just can´t understand how "default" css file works, and for what layout.

These are the css files that I´ve got:

  global.css = global

  yoursubthemename-alpha-default.css = default

  yoursubthemename-alpha-default-narrow.css = narrow

  yoursubthemename-alpha-default-normal.css = normal

  yoursubthemename-alpha-default-wide.css = wide

And these are the different default layout settings at the UI (/admin/appearance/settings/mytheme):

Narrow Layout (weight 1) --> media query: all and (min-width: 740px)
and (min-device-width: 740px), (max-device-width: 800px) and
(min-width: 740px) and (orientation:landscape).
Normal Layout (weight 2) --> all and (min-width: 980px) and
(min-device-width: 980px), all and (max-device-width: 1024px) and
(min-width: 1024px) and (orientation:landscape).
Wide Layout (weight 3) --> all and (min-width: 1220px).

How about default css file?
I´ve also noted that all mediaqueries are set: orientation:landscape, so how do I manage to apply different css files for portrait viewports?

Example:

I´ve got a phone (480 x 320), a Nexus 7" Tablet (1280x800), a 10" netbook (1024x600) and a 19" pc monitor (1366 x 768).

I´ve customized global, normal and wide css files, applying global.css to my phone (portrait and landscape), normal.css to my laptop and wide.css to my pc monitor.

  cellphone orientation: portrait and landscape ---> css global file.

Works ok. It just takes the global file.

  tablet orientation portrait ---> css ?? file.

It takes the global file, and it looks as the pgone, but bigger. I would like another template. I´ve tried the "default" css file, but it´s not "taken".

  tablet orientation landscape ---> css ?? file.

I´ve copied all contents of "normal" to "narrow" css files, but that won´t work, because it´s a weird narrower result, even if its a copy of the normal css file.

  netbook orientation landscape ---> css normal file

It works fine, it just takes the normal css file.

  desktop monitor orientation landscape ---> css wide file

It works fine, it just takes the wide css file.

So, in other words, how do you apply the css templates to tiny viewports (cellphone), smaller ones (7" tablet), small ones (10" netbook), and bigger ones (big desktop monitor and maybe tv)?

Thanks for your help!


texts: How to disable/remove node listings on taxonomy term page in Drupal 8?


texts: reCaptcha is not display correctly in the Bootstrap Login Modal registration form

texts:
I am using the Bootstrap Login Modal module release 7.x-3.2 to create a modal registration form. Unfortunately, the reCaptcha does not display on the registration form until the registration button is clicked. Afterwards the form will close. When you reopen it, reCaptcha will be displayed.
It looks like it is incorrectly added to the form.
If I switch to using default Math captcha it loads first time without problems.

Does someone know how to solve this problem?

reCaptcha doesn't display on the registration form

reopened form reCaptcha is dispayed


texts:
In preset views like the Taxonomy Term one (/taxonomy/term/%), it can be done by adding a custom block to the footer, but it is not controllable as block layout on /admin/structure/block.

Is it possible to add a region to a custom view template?


texts: How to create an unsubscribe link via mail in simplenews?

texts:
UPDATE

I updated my code to helderco's answer:

$mail = $form['mail']['#value'];
$subscriber = simplenews_subscriber_load_by_mail($mail);
$context = array(
    'category' => $form['newsletter']['#value']->name,
    'simplenews_subscriber' => $subscriber->snid
  );

but

debug(token_replace('[simplenews-subscriber:unsubscribe-url]', $context, array('sanitize' => FALSE)));

prints:

'https://mywebsite.com/newsletter/confirm/remove/'

is this correct?

I am writing a small module to extend the simplenews module, because as it seems, once a user has confirmed to be subscribed, no email is being sent. So I wrote a module which does exactly that.

Within the mail I am sending I would like to provide an unsubscribe link directly (or to a form). How would you do that? Simply adding the token within the mail text does not work.

<?php

function simplenews_apag_form_simplenews_confirm_add_form_alter(&$form, &$form_state, $form_id) {
  $mail = $form['mail']['#value'];
  $form['question']['#markup'] = '<p>'. t('Do you really want to subsribe your e-mail adress (%mail) to get a notification via e-mail as soon as ...', array('%mail' => $mail)) . '</p>';
  $form['#submit'][0] = '_simplenews_apag_simplenews_confirm_add_form_submit';
}

function _simplenews_apag_simplenews_confirm_add_form_submit($form, &$form_state) {
  simplenews_subscribe_user($form_state['values']['mail'], $form_state['values']['newsletter']->tid, FALSE, 'website');

  $path = variable_get('simplenews_confirm_subscribe_page', variable_get('site_frontpage', 'node'));
  drupal_set_message(t('Thank you very much for your interest. You will receive a confirmation mail.'));

  $params = array();
  $address_default = variable_get('site_mail', 'info@example.com');
  $params['from'] = variable_get('simplenews_from_address', $address_default);
  $params['to'] = $form_state['values']['mail'];

  drupal_mail('simplenews_apag', 'subscription_complete', $params['to'], language_default(), $params['from'] );

  $form_state['redirect'] = $path;
}

function simplenews_apag_mail($key, &$message, $params) {
  switch ($key) {
    case 'subscription_complete':

      $message['subject'] = 'Thanks';
      $message['body'][] = 'Bla Bla. Click the link beneath to unsubscribe: ';
      // how to provide unsubscribe function?
      $message['body'][] = '[simplenews:unsubscribe-url]';
      $message['body'][] = 'Regards';

      break;

    case 'unsubscription_complete':
      break;

    default:
      return false;
      break;
  }
}
?>

Any idea is greatly appreciated. I am using drupal 7


texts: How to hide authoring information on webform for Drupal 7

texts:
I went to Administration > Structure > Content Types > Webform > Manage Display where I am supposed to find a check box to hide or display author information but there is nothing there. Any idea how I could hide this?

Thank you for your thoughts

Drupal 7
Webform 3


texts:
I'm looking at making a site that provides a different 'experience' (to use the marketing term) depending on who the visitor says they are, without authentication. The functionality I'm thinking of using is to programmatically change the role from anonymous to something else.

So the from the launch page, client wants the site to look different depending on whether the visitor clicks "I'm a floor manager", "I'm a purchaser", "I'm a decision maker" and a perhaps few other choices. They are going to see different promotional material and copy depending on which link they choose, and the client wants it to appear that the whole site is geared towards them -- in other words, menus, pages, and promotional material not 'for' that user will be absent when they make that choice. It should look like several different sites, after they click out of the initial page.

So I thought that a way to do this would be to make all the content, menus, images, pdfs,  and then assign access by role. That way, if you're looking at the site as that role, you only see the things relevant to you. But we don't want the users logging in -- they just click on a button to declare what role they are, and if they are tricking us, we really don't care.

Will I be able to do this in the way I am imagining?


texts: How to remove reference field value after delete its reference node

texts:
Let say, I have 2 nodes.
In first node, I add a reference to an existing node, e.g. Test node [nid:2];   I delete the referenced node. When I edit the first node,the reference field shows [nid:2].

How can I make that reference field empty, once the referenced node is deleted?


texts: How to add multiple images to a node using node.save service?

texts:
I am using the services module along with the json server module to add a node to my drupal web site from an external application.

One of the cck fields is an image field which can accept multiple values. In my javascript application I'm calling the node.save service with node object like:

node_obj.field_image = [{ "fid": fid }];

This successfully adds the image value to the cck field. But how do I add another image value to this field? Calling the service again overrides the old image vale with the new one.


texts: Accessing text of a field with type "Text"

texts:
I fear that my question could be covered in detail already somewhere, but I did not find something useful. So appologies if this is the case.

I added a field of type "Text" to content type "Article". Now, I want to access the string of this field.

I want to access this in file template.php of the theme I use. To be precise, I want it to access in function "tb_corpal_preprocess_page". (File from themebrain theme "tb_corpal".)

I can see that in another function the "field_image" is accessed like this:

if(isset($vars['content']['field_image']))

If I now want to extract my field_banner, which is a field of type "Text", how do I do that? I guess it should also be stored in $vars, right? If yes, how do I access the string?


texts:
I want to create a landing page for my Google Ads on my site so that potential customers will be able to download and see the page very quickly. My site can be a bit heavy with CCS and javascript and other stuff sometimes.

All I want is to avoid losing potential clients due to a slow website. So I wonder if there's a simple way of the landing page being a light version of my site (with links to the "real" drupal site).

Many thanks

Oli


texts: Adding classes to menu items to signify what level they are

texts:
How can I add classes to the  or
 tags of the main menu to signify which level they are in the menu hierarchy (e.g. "level-1", "level-2", etc.)? The code below shows the first link has 3 sublinks (dropdown):

    Top link

Dropdown 1

Dropdown 2

Dropdown 3

    Another top link


texts:
Views are normally formatted as unformatted list. I would format a view as HTML list, and choose between <ul> or <ol> markup.
Since I use the DraggableViews module, I need to format the view as table. I would like to have some automatic numbering for the view's table rows, similar to the HTML list, which uses <ol> and <li> markup.
How could I get each row in the view table to have a number that is automatically increased?


texts: Configure contextual filter: Content: Nid

texts:
I have two content types called product and product_feature
I am on something like www.something.com/product_name/product_feature_name
I am on the product_feature landing page and I want to display product_name and product ID


texts: How to correctly check the value of boolean in D7?

texts:
I have a boolean single check-box field. and inside my node--content-type.tpl.php Idothe following check:

  <?php if($content['field_hide_1st_line_of_the_addre']['und'][0]['value'] == 0): { ?>
    <?php print render($content['field_images']['#object']->field_location['und'][0]['street']) . t(', '); ?>
    <?php } else: { ?>
    <?php print t(''); ?>
    <?php } endif; ?>

And it returns loads of "Notice: Undefined index: und in include() (line 80 of node--content-type.tpl.php"

Any idea what is going on?

UPDATE

  <?php if (isset($content['field_hide_1st_line_of_the_addre']['und'][0]['value'])): { ?>
    <?php print render($content['field_images']['#object']->field_location['und'][0]['street']) . t(', '); ?>
    <?php } else: { ?>
    <?php print t(''); ?>
    <?php } endif; ?>

is not the doing the check correctly: the Street field disappears forallteasers,while it should only disappear for those that have the boolean check-box ticked.

UPDATE 2
This code didn't work either. Pave me a Parse error: syntax error, unexpected $end

<?php
  if (isset($content['field_hide_1st_line_of_the_addre'][LANGUAGE_NONE][0]['value'])) :
  if($content['field_hide_1st_line_of_the_addre']['und'][0]['value'] == 0): { ;
    print render($content['field_images']['#object']->field_location['und'][0]['street']) . t(', ');
  }  endif;
?>

UPDATE 3

I deleted that old field and created a new identical one.  Tried many things,but it turns out that for some unknown reason it just didn't like the 0 and preferred 1 instead.So I used 1,and just changed the wording of the field from "Hide full address" to "Display full address".  This is the code that worked for me.  If you seeany syntax mistakes,pleaselet me know.

<?php
    if (isset($content['field_hide_address']['#items'][0]['value'])) :
    if($content['field_hide_address']['#items']['0']['value'] == '1'):
    print render($content['field_images']['#object']->field_location['und'][0]['street']) . t(', ');
    endif;
     endif; ?>


texts: drupal 7 on submission of form respective form should open

texts:
in my form i have to show two radio button and one submit button,please see below my front form is like this:

candidate(radio)

organization(radio)

submit button.

my requirement is that

if user click/check on candidate radio button and click on submit then candidate form should be open on candidate page.

or

if user click/check on organization radio button and click on submit then organization form should be open on organization page.

my code:

<?php
/**@file
*donation.module*/
/**
*Implements hook_menu()*/
function donation_menu(){
$items['donate'] = array(
'title' => 'Donate',
'page callback' => 'drupal_get_form',
'page arguments' => array('donation_donate_form'),
'access arguments' => array('access content'),
'access callback' => TRUE,
);
return $items;
}
/**
*Implements hook_form().
*/
function donation_donate_form($form, &$form_submit){
/*the options to display in our form radio buttons*/
$options = array
'candidate' => t('Candidate'),
'organization' => t('Organization'),
);
$form['officials'] = array(
'#title' => t('OFFICIALS'),
'#type' => 'radios',
'#options' => $options,
'#default_value' => $options['candidate'],
);
$form['name'] = array(
'#title' => t('NAME'),
'#type' => 'textfield',
);
$form['submit'] = array(
'#value' => t('PROCEED'),
'#type' => 'submit',
);
return $form;
}


texts:
I have the following alias group set in the setA.aliases.drushrc.php:

  $aliases[‘site1'] = array(
      'root' => '/var/www/site1',
      'uri' => '88.88.88.11/site1',
      'remote-host' => '88.88.88.11'
  );

  $aliases[‘site2’] = array(
      'root' => '/var/www/site2',
      'uri' => ‘88.88.88.22/site2',
      'remote-host' => '88.88.88.22'
  );

  $aliases[‘site3’] = array(
      'root' => '/var/www/site3',
      'uri' => ‘88.88.88.33/site3',
      'remote-host' => '88.88.88.33'
  );

Now, I have updated @site1, and would like to sync with other sites in setA alias group, can I just use the following command "drush rsync @site1 @setA"?

Or how can I exclude @site1 from destination @setA as it is actually the source?


texts:
I can't login from the front-end with varnish installed.
Here's what I think it is issue

sub vcl_recv {

 # Do not cache these paths.
 if (req.url ~ "^/status\.php$" ||
  req.url ~ "^/admin$" ||
  req.url ~ "^/admin/.*$" ||
  req.url ~ "^/admin/?" ||
  req.url ~ "^/user" ||
  req.url ~ "^/user/.*$" ||
  req.url ~ "^/users/.*$") {
  return (pass);
 }

and the session cookies

if (req.http.Cookie) {
    set req.http.Cookie = ";" + req.http.Cookie;
    set req.http.Cookie = regsuball(req.http.Cookie, "; +", ";");
    set req.http.Cookie = regsuball(req.http.Cookie, ";(SESS[a-z0-9]+|NO_CACHE)=", "; \1=");
    set req.http.Cookie = regsuball(req.http.Cookie, ";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=", "; \1=");

If I try to login directly from apache port:8000 it works as expected.
Here's the whole default.vcl file: http://pastebin.com/qPRyFEjP

I don't get why it's not piping to the authenticated users. Why wouldn't it login in?
Thanks.


texts:
I have drush 6.0 and recently installed drush7 as well with composer. Now i would like to update drush 6.0 to latest release in drush version 6. Is there any work around to achieve?

Thanks,
Swaroop.


texts: Deployment of full database dump still causes error

texts:
I want to deploy my local DB to a staging server.

The local DB dump was exported with all tables. Including the "cache_" prefix table structures with no data exported.

After deployed to staging (with Jenkins), I got exceptions like Plugin missing error or field missing.

  Uncaught PHP Exception RuntimeException: "Unable to determine class for field type 'daterange' found in the 'field.storage.node.field_date_range' configuration" at /var/www/html/lightnest/releases/20200227152907/docroot/core/modules/field/src/FieldStorageConfigStorage.php line 164

I cannot run update.php or rebuild.php because this error will popup again.
I also cannot run drush commands as I have no direct access to the staging.

Am I missing anything?


texts:
On my Drupal 8 I have a blog, which should have a comment function. I added the comment field in the content type of the blog posts and I also checked the checkbox that the comment input field is shown. But the comment section is not displayed. Even in my template file in my theme_preprocess_node function I could not find the comment field. I also tried it with the Bartik theme, but that also didn't work.

My question now is: How can I display the comments section on my blog articles?


texts: How to summarise different date ranges using this week, last week, etc?

texts:
I would like to display a table or graph showing revenue over the last year with sums divided into weeks or months.

I record every sale/value in an entity, and can show ie "total this week" or "total this year" with Views and aggregation, but I would like to show it like "this week", "last week", "last week -1" without having to make a view or attachment for each value.

Is this possible without making a new entity ?

Notes:

I want to use Views, but I wonder if there is a way to group/aggregate values without having to make a new view for each aggregation (week or year). Then I will have to make 52 views/attachments for showing weeks and 12 to show the year.
I can create a date field in my view and format it as year-month eg 2014-12 and then group by that and use aggregation. But then I will have to make one for 2014-11, 2014-10, 2014-09, etc


texts: How to change client session variables during a functional browser test?

texts:
I have a session variable, that once set changes block output of the system branding block. Normally this variable is intercepted from the query string by an inbound path processor, however that is a different test. In this test I just want to make sure the output is as expected.

So I set up my test as follows:

class ConfigOverrideCacheTest extends MyLabelTestBase {

  protected function setUp() {
    parent::setUp();

    $this->tokenOwner= $this->drupalCreateUser(['my permission']);
    $this->drupalLogin($this->tokenOwner);
  }

  public function testNotoken() {
    $this->drupalGet('<front>');
    // Check site name is Drupal.
    $this->assertSession()->elementTextContains('css', '.block-system-branding-block', 'Drupal');
  }

  public function testToken() {
    // Set session variable.
    \Drupal::service('session')->set('my_session_key', 'value');

    $this->drupalGet('<front>');
    // Check site name is NOT Drupal.
    $this->assertSession()->elementTextNotContains('css', '.block-system-branding-block', 'Drupal');
  }

}

This second test keeps failing, and the output is the same as in the first test. Which I suspect to be because it is set in the testrunner session, rather than the actual testing session.

How so set (or synchronize) session variables from the testrunner to the site that gets tested?


texts: Why doesn't skip_on_empty work when migrating from a text field?

texts:
I'm trying to migrate Drupal 7 users to Drupal 8.  In Drupal 7, there's an additional text field representing the user's group.  In Drupal 8, it's a taxonomy vocabulary.  So I'm using the following pipeline:

  field_user_group:
    -
      plugin: skip_on_empty
      method: process
      source: field_directorate
    -
      plugin: extract
      index:
        - 0
        - value
    -
      plugin: entity_generate
      value_key: name
      bundle_key: vid
      bundle: groups
      entity_type: taxonomy_term
      ignore_case: true

field_directorate is the source field in D7, and field_user_group is the target in D8.

Records without that value set should be caught by the skip_on_empty plugin, and left blank, but that plugin seems to be failing (letting the process continue to the next plugin in the pipeline) as I'm getting errors from the extract plugin saying:

  Array index missing, extraction failed.

According to the documentation,

  The skip_on_empty process plugin checks to see if the current input value is empty (empty string, NULL, FALSE, 0, '0', or an empty array). If so, the further processing of the property or the entire row (depending on the chosen method) is skipped and will not be migrated.

How is the processing even getting to extract if skip_on_empty is supposed to skip values with an empty array?

It works fine for records with the value set.


texts: Detect if its first time that user accesses the page

texts: How can I detect if users access a page for the first time? I want to redirect them to their language using GeoIP.


texts:
I need to print the current nodes submenu somewhere on the page. Inside my page.twig.html file I have this markup:

<div id="children-menu">
  {{menu_children}}
</div>

Inside my mytheme_preprocess_page() function I have this which rendering all the submenus.

function mytheme_preprocess_page(&$vars) {
  if ($vars['node']->id()) {
    $menu_tree = \Drupal::menuTree();
    $menu_name = 'main';
    $parameters = $menu_tree->getCurrentRouteMenuTreeParameters($menu_name);
    $tree = $menu_tree->load($menu_name, $parameters);
    $manipulators = array(
      array('callable' => 'menu.default_tree_manipulators:checkAccess'),
      array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
      array('callable' => 'toolbar_menu_navigation_links'),
    );
    $tree = $menu_tree->transform($tree,$manipulators);
    $subtrees = array();
    foreach ($tree as $element) {
      $link = $element->link;
      if ($element->subtree) {
        $subtree = $menu_tree->build($element->subtree);
        $output = drupal_render($subtree);
        array_push($subtrees, $output);
      }
    }
    //dpm($subtrees);
  }

}

I was looking into using manipulators, but that wasn't working. How can I render JUST the current nodes submenu using this function? Again, what I have now is rendering all the submenus and I need just the current one.


texts: Show Webform Confirmation message in popup window

texts:
In my drupal7 site i have buit a contact form using Webform.

I like to do two things.

I want to show webform confirmation message in popup window.I have searched net found some popup module but the problem is they all belongs to drupal 6
When i submit the webform i am getting this error message

  Notice: Undefined index: #webform_component in theme_webform_display_select()
  (line 522 of /var/www/www.example.com/www/example/sites/all/modules/webform/components/select.inc).

Can you help me to solve this two things.Thank you friends


texts:
I'm on an updated Drupal 7 core site with PHP filters enabled. I have tried all possible best to embed Amazing Slider on Drupal using this code without any luck:

<?php echo amazingslider1_output(); ?>

On the amazing slider  website, they say to input code to theme file.

I don't know the exact file. I tried template.php and .info with all the tpl.php files. I also tried using same code on article, page, and block but still not working.


texts: What is the reason to define indexes in hook_schema?

texts:
How do I choose what fields to index and which ones not to? Is the index useful for when I set a condition in the database query for a quick look up of the rows? I guess this is an SQL question but I really want to know what indexes are used for Drupal entities.

What are all these indexes in the node table for?

  'indexes' => array(
    'node_changed'        => array('changed'),
    'node_created'        => array('created'),
    'node_moderate'       => array('moderate'),
    'node_frontpage'      => array('promote', 'status', 'sticky', 'created'),
    'node_status_type'    => array('status', 'type', 'nid'),
    'node_title_type'     => array('title', array('type', 4)),
    'node_type'           => array(array('type', 4)),
    'uid'                 => array('uid'),
    'tnid'                => array('tnid'),
    'translate'           => array('translate'),
  ),


texts: Update from 6.35 to 6.37 No errors but still showing as 6.35

texts:
I read the other questions on here and I've searched google for an answer but without luck. I don't have SSH access to the server so I'm stuck updating the site manually. I used the process explained on How To Update Drupal Core on drupal.org.

Quick synopsis

Backup
Maintenance mode
Delete old files on server (not /sites)
Copy in NEW files
Run update.php
Take out of Maintenance mode

There were NO errors when the update finished and no issues with the site. When I check in the admin (under available updates) it still says 6.35 with  6.37 as the recommended update.

How can I fix this?


texts: selected option on drupal form not coming up first

texts:
I added a '#default_value to my drupal7 form , and it says

<option selected="selected" value="81">Service</option>

(this is the option I want selected) but I want it to come out first in the list and it isnt .

how can I get it to come out first?


texts: Template file not loading for block view

texts: I have a block view in the header. The suggested tpl files are block__mens_header (block--mens-header.tpl) as well as node--mens-header.tpl For some reason the more general tpl files are working but I need to get specific here. Is there a preprocess function I need before these will be seen?


texts: How can I theme the Bootstrap base theme search block?

texts:
I've created a sub-theme of the Drupal 8 Bootstrap base theme. My problem is that I'm using a customized version of the Bootstrap CSS Framework that does not include Glyphicons. Instead of Glyphicons, my project is using fontAwesome icons.  What I've realized though, is that the Bootstrap theme uses a Glyphicon Search Icon for the Search Form. Since I'm not using glyphicons and the CSS files are not included, I get a search form button that looks like this.

It should appear like this.

If i inspect the HTML markup using my browser, my theory is correct.

<button type="submit" value="Search" class="button js-form-submit form-submit btn-primary btn icon-only" name="">Search</button>

if I change the following markup, the button shows up correctly because it can find the icon.

  to

What I want to do is to be able to change the icon or the code in the base theme that generates this snippet of code.

My assumption is that I should use a preprocess function to alter the form block and output/replace the Glyphicon span with the Fontawesome span.

I believe that the input--button.html.twig in the bootstrap base theme is responsible for outputting the icon classes because of this code.

{% block input %}
    {% if icon_only %}
      <button{{ attributes.addClass(classes, 'icon-only') }}>
        {{ label }}
        {{ icon }}
      </button>
    {% else %}
      {% if icon_position == 'after' %}
        <button{{ attributes.addClass(classes) }}>{{ label }}{{ icon }}</button>{{ children }}
      {% else %}
        <button{{ attributes.addClass(classes) }}>{{ icon }}{{ label }}</button>{{ children }}
      {% endif %}
    {% endif %}
    {{ children }}
  {% endblock %}

Apparently, it is used to alter the button of many elements instead of only the search form.


texts: Is there an equivalent of drupal_set_message which will write to the block?

texts:
I have some custom functionality running in hook_block_view such that when a user loads a page, different status messages may need to be displayed from multiple blocks in the page. At present I am outputting the messages via drupal_set_message so that they appear at the top of the page.

It would be more elegant if I could display the messages within the individual blocks. I could hack this and output the messages in divs with the relevant Drupal classes attached, but that seems like a bad idea. Is there some Drupal functionality I could call to achieve what I want? (a nice Drupal style message in each block, complete with coloured background and tick/cross icon as appropriate).

Thanks in advance,

MB


texts: How to override Bootstrap theme files in sub-theme

texts:
I'm creating a sub-theme based off Bootstrap. I've followed the instructions here and is working ok.

Now I want to override the tpl files in theme/block, theme/system, etc.

In my sub-theme I've created the folder structure mimicking the one on Bootstrap (at least for the ones I want to override), yet it seems my files are not being used.

How can I override the aforementioned files (preferably) using the same structure?

Thanks for your help


texts: Is the AJAX from image fields and multi-line fields breaking my JavaScript?

texts:
We have added tooltips to our node form using this method: https://inclusive-components.design/tooltips-toggletips/

It includes a JavaScript/jQuery snippet that works perfectly except...

If the tooltip is inside an image file upload, it works, but if you upload an image and that field updates, then the tooltip no longer works.
If the tooltip is inside a multi-line field, it works, but if you add a new item, the tooltip no longer works.

The other tooltips keep working. It's as if those tooltips were removed from the document.querySelectorAll. Would this have something to do with Drupal 8's AJAX updating those fields?

Here is the JS:

(function ($) {

  $(document).ready(function() {
    console.log("dom is ready");
    // Get all the toggletip buttons
    var toggletips = document.querySelectorAll('[data-toggletip-content]');

    // Iterate over them
    Array.prototype.forEach.call(toggletips, function (toggletip) {
      // Get the message from the data-content element
      var message = toggletip.getAttribute('data-toggletip-content');

      // Get the live region element
      var liveRegion = toggletip.nextElementSibling;

      // Toggle the message
      toggletip.addEventListener('click', function () {
        console.log('clicky');
        liveRegion.innerHTML = '';
        window.setTimeout(function() {
          liveRegion.innerHTML = ''+ message +'';
        }, 100);
      });

    // Close on outside click
    document.addEventListener('click', function (e) {
      if (toggletip !== e.target) {
        liveRegion.innerHTML = '';
      }
    });

    // Remove toggletip on ESC
    toggletip.addEventListener('keydown', function (e) {
      if ((e.keyCode || e.which) === 27)
        liveRegion.innerHTML = '';
      });
      // Remove on blur
      toggletip.addEventListener('blur', function (e) {
        liveRegion.innerHTML = '';
      });
    });
  });
})(jQuery);

Note: I know absolutely nothing about AJAX other than it seems to be what's updating the fields's HTML.


texts: Problem with theme registry rebuild and drupal_get_form in a block

texts:
I'm calling a form from a custom block and having real problems getting it to function with theme registry rebuild on each page load turned off.

With the registry rebuilding every page load this form is called and functions fine within the block, however once rebuild is off drupal_get_form() doesn't appear to call the form at all, I've place debugging within the form function to confirm this.

I'm completely stumped as to why this would be, I've tried wrapping drupal_get_form in a drupal_render, same problem, the form just doesn't get called once registry rebuild is off. The form is also called in hook_menu and the block was created so I could place it in some panels within other pages. I can see no reason why this would interfere  with calling the form from a block.

I've pasted some abstracted code below to see if anyone can see an obvious issue that I'm missing, it really is infuriating. As it stands at the moment I've resorted to using a custom pane with PHP to call the module file and invoke drupal_get_form from there, this works fine with the registry rebuild off, so it seems it must have something to do with the block.

/**
 * Implements hook_block_info()
 */
function example_block_info() {
  $blocks = array();
  $blocks['example_form'] = array(
    'info' => t('Hello world'),
    'cache' => DRUPAL_NO_CACHE,
    'status' => TRUE,
    'visibility' => BLOCK_VISIBILITY_LISTED,
  );
  return $blocks;
}

/**
 * Implements hook_block_view()
 */
function example_block_view($delta = 'example_form') {
  global $user;
  if (isset($user) && $user->uid != 0 && !empty($user->mail)){
    $example_form = drupal_get_form('example_page_form', $user, 'arg');
    $block['subject'] = t('Example block form');
    $block['content'] = $example_form;
    return $block;
  }
}

The form I'm calling also requires two arguments that I am passing to it, I don't see why this would cause an issue however.


texts:
The main menu comes with 5 items.

How can I hide one items from the < front > page, i.e. 4 items are shown on front page, 5 items are shown on other pages?


texts: Search button with 'lens' icon on the exposed view's filter - Drupal 7

texts:
I can't figure out how to make a search button on the view's exposed (as a block) search filter to be styled similarly as in Drupal standard search form, with a 'lens' icon. The examples for hook_form_alter() I found using:

$form['submit']['#type'] = 'image_button';
$form['submit']['#src'] = base_path() . path_to_theme() . '/images/search-button.png';

-don't seem to work correctly, as image on the button just doubles (png file includes both 'active' and 'inactive' images of lens). Could there be a straightforward way for the search button 'lens' styling, not including CSS/templates modifications?


texts:
Site 1: http://bit.ly/qrMXdg - Drupal 6 + Quicktabs
Site 2: http://bit.ly/pQMTRf - Drupal 7 + Quicktabs

Brief: In Site 1 if I hover on the TABS and copy URL I can get a direct link to that TAB. I can use this link to navigate from anywhere on the site to a specific TAB already selected.
I.E. I can use "/equity?quicktabs_fundsperformancetabs=1#quicktabs-fundsperformancetabs" can link me to MANAGERS TAB

The problem is that in Site 2 the when I right click and copy URL it adds a "%23" and the link is unusable. I.E. link for Performance is "/%23tabs-1?quicktabs_fundx_submenu=1#quicktabs-fundx_submenu"

If I take out the %23 it goes to invalid page
If I replace %23 with # it just goes to the homepage

Any Ideas on how I can fix this and link directly to the TAB like I can easily do in Drupal 6 with Site 1?


texts: Is there any way to redirect page to front page, if it isn't translated?

texts:
Is there any way to redirect page to homepage if its translated page not found.

Suppose my page url is /en/node/237, If I switch translation from English to German /ge/node/237, if it's translated page not found, URL should redirect to homepage of its native language like: /ge/home

Here is my code:

 use \Drupal\node\Entity\Node;

   $elements = [];
 $ids = \Drupal::entityQuery('node')
  ->condition('type', 'intro_2')
  ->condition('langcode', 'fr')
  ->condition('nid',1218)
  ->execute();

 $nodes = Node::loadMultiple($ids);
  $language = 'fr';

 foreach ($nodes as $node) {
 $translation = $node->getTranslation($language);
$elements[] = [
 'node' =>$translation->nid->value,
'title' => $translation->title->value,
'url' => $translation->url(),
];
  }
dpm($elements);

Above code working fine i have checked on /devel/php,but i am having only following issues:

1)How to get current page node type dynamically in database query

2)How to get current page language dynamically in database query

3)How to get current page node dynamically in database query

Can anyone modify the above code?


texts:
I am using the Service links module in my Drupal 7 site.

When using the Facebook "like" widget, I get the word "error" (in red color), in the place where the Facebook "Like" button should be.

When clicking on the word "Error", a Facebook popup window is opened with the error like so:

  The href URL must be absolute

Note: I am using the Service links widgets inside a view. Other Services links widgets are working great, such as the Facebook share widget, Twitter, Google+ and Pinterest widgets.

What is the problem of the Facebook "like" button?


texts: How to import a CSV with list field labels using Feeds?

texts:
I have a content type "Car". The fields are "Title", "Body" and "Gearbox". The "field type" of the field "Gearbox" is "List (integer)", and the "Allowed values list" for this field (in the "key|label" format) are:

1|manual
2|automatic
3|semiautomatic

I want to import content from a CSV file using a standard node import with Feeds. My CSV is as follows

GUID,Title,Body,Gearbox
1,Lexus NX,blabla,automatic
2,Porsche Cayenne,bloblo,manual

On importing this CSV file, the value for "Gearbox" is not copied over. Instead, it appears as empty in the content. If I replace the values for "Gearbox" by their keys, as in this modified CSV file

GUID,Title,Body,Gearbox
1,Lexus NX,blabla,2
2,Porsche Cayenne,bloblo,1

then it works correctly.

Nevertheless, I'm not the end user and I need to leave the CSV file in its more human-friendly form that uses the "labels" instead of the "keys" (as in the original CSV above).

How can I do this? I.e. how can I have the import recognize the labels "manual", "automatic", etc instead of their corresponding keys?


texts: I want to have anonymous users to have a pop up displayed after they visit first page and moving to second page. The pop up should have a Name and email and after submission user gets registered to our website. I'm confused which existing module can achieve it. I tried using popup module.  Or do I have to custom code to achieve it?


texts: How can I render a token within a token via rules mail action?

texts:
I want to send a node via rules. I can send it using the [node:body] token. However, I want to be able to use tokens in the actual node body as well. (Note: These are not global tokens)

Think of it like a newsletter and in the body field I am using

Dear [field_ef_first_name], ...

I can get the token to render if I put it directly in the rules action mail message body, but if it is in the node body field itself, it doesn't render.

The name field is coming form a views rule loop.

Rule exported:

{ "rules_send_newsletter_when_published" : {
"LABEL" : "Send newsletter when published",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_insert--blog" : { "bundle" : "blog" } },
"DO" : [
  { "VIEW LOOP" : {
      "VIEW" : "entityforms",
      "DISPLAY" : "views_rules_1",
      "ROW VARIABLES" : {
        "field_ef_email" : { "email" : "Email" },
        "field_ef_first_name" : { "first_name" : "First Name" }
      },
      "DO" : [
        { "mail" : {
            "to" : "[email:value]",
            "subject" : "[node:title]",
            "message" : "[node:body]",
            "language" : [ "" ]
          }
        }
      ]
    }
  }
]

}
}


texts:
I want to send a reminder email to the users to log in to my website with their username and password. My mail script is ready with the login ID, but I don't know how to decrypt the user's password.

Can anyone tell me how should I get the password associated with a user account?


texts:
I've defined a proxy in my settings.php:

$settings['http_client_config']['proxy']['http'] = 'http://ip:port';
$settings['http_client_config']['proxy']['https'] = 'http://ip:port';
$settings['http_client_config']['proxy']['no'] = ['127.0.0.1', 'localhost'];

In real I've replaced ip and port with nummeric values.

In a custom module I've defined:

$client = \Drupal::httpClient();
//$request = $client->get($this->source_url.'service=wms&request=getcapabilities');

These works, when Im not behind a proxy. How, can I add the proxy settings to this request?

$set =\Drupal\Core\Site\Settings::get('http_client_config');
$proxy = $set['proxy'];
//Get GetCapabilies.
$client = \Drupal::httpClient();
$request = $client->get($this->source_url.'service=wms&request=getcapabilities');

I don't find any way to add the proxy settings.


texts: What hook runs on all filtered input text of all filter types?

texts:
This is one of those, "Looked everywhere in the API for a hook, can't find it" questions. There must be a hook like I'm looking for, but none of my searches have found anything.

I'm looking for a simple hook in D7 that lets me edit text filtered content, after it's gone through a text input filter, before it's saved: regardless of which input filter, and regardless of entity type (i.e. not just nodes).

I can't find a suitable hook. The new-style hook_filter() alternative hook_filter_info() isn't suitable because I want this code to run on all input filters, so I don't want to define a new one.

hook_node_save() is too specific. I could maybe hook on hook_entity_presave() then load field info, then look through all fields looking for fields that are longtext fields, then act on those, but I'm hoping there's something more direct. That sounds like a lot of extra work for something simple. I'd prefer not to have every single entity save load all the field info and check every field (unless there's a very low-overheads way to do that).

What's the simplest, cleanest way to get code to run on all text that has gone through an input filter, regardless of the input filter?


texts: Automatic alias pattern to accommodate node hierarchy and menu items

texts:
I've got a site where some parent menu items are nodes and some are dynamically generated with views and panels. I'm using Node Hierarchy and Pathauto to manage the structure but I'm having some difficulty with Url replacement patterns.

If the parent item is a page, this pattern gives me the correct Url:

[node:nodehierarchy:parent:menu-link:?]/[node:title]

but it doesn't work when the parent item is a view. Likewiswe, if the parent item is a view, this pattern gives the correct Url:

[node:menu-link:parent:url:path]/[node:title]

but it doesn't work when the parent item is another node. I guess I could solve the problem by having separate content types for pages whose parent is a menu item and pages whose parent is another node. Or by using menu items for everything, or maybe by writing a custom module. But before I take any of these steps I wanted to ask, is there any replacement pattern that will fit both of the above situations, i.e. that will generate the correct Url whether the parent is a node or a view/panel.


texts:
I installed Drupal on my VPS, but it seems that all input on website doesn't work from web interface. What I mean by that:

I cannot login by using web interface
I CAN login by using one-time login link generated by Drush, but then strange things happen, I guess consequences of not working input - like Admin Menu disappears after refresh, and editing any content is impossible, after sending change - the edit page simply refresh with old values,
I have Redmine installed on this server and it works ok, so it seems to be Drupal specific.
The problem doesn't exist with "?q=/user/login" - it exists only with rewritten links. I'm pretty sure I have unmodified .htaccess.
The problem exists when I remove from .htaccess everything, with the exception of: ErrorDocument 404 /index.php and RewriteEngine on (which is bare minimum for rewriting to work it seems).
There are absolutely no errors in logs of Drupal, Apache and MySQL.

My Virtual Host: http://pastebin.com/R5hRQMWc

My .htaccess: http://pastebin.com/xM5Kj1yd

System: Ubuntu 14.04, Apache 2.4.7, PHP 5.5.9-1ubuntu4.2 , mysql Ver 14.14 Distrib 5.5.37

Any ideas what is going on and why only Drupal is affected?


texts:
I want to remove the logo from my site.

I found some instructions on Disabling the Drupal logo in your Drupal 8 theme. My problem is that the instructions say to unselect Logo in the toggle section of the theme settings page. I only get four options: User pictures in posts, User pictures in comments, User verification status in comments, and Shortcut icon.

I've checked in two sites. One has the vanilla Bartik theme, and the other has a subtheme of Bartik with no changes other than CSS.

How can I remove the logo?


texts: Composer doesn't see that updates are needed

texts:
My Drupal version is 8.5.1, and yet when I run...

composer outdated drupal/*

It says "nothing to install or update".

What to do?

This is the relevant part of my composer.json...

"require": {
        "composer/installers": "^1.0.21",
        "wikimedia/composer-merge-plugin": "~1.3",
        "drupal/core": "^8.5"
    },

Looks fine to me, but composer says no update is available.


texts: Custom contextual filter on views using Group module in Drupal

texts:
I need to add a custom contextual filter in my view for the logged in user who is also a member of a Group specified in field_groups of my node. field_group is an entity reference field referencing group entity provided by the https://www.drupal.org/project/group module.

What is the simplest way of doing it? I am open to suggestions.


texts: Creating a view which lists all taxnomy terms and the number they appear in a content type?

texts:
So i have a taxonomy called Product Warnings, and it has around 10 terms. This taxonomy is referenced in several content types (Small products, Large products, etc), and can be selected multiple times (so a user can select in the content type 1 or up to all 10 terms from the Taxonomy).

I want to create a view which lists all terms from the given taxonomy (that's the easy part), and also count the number of times each terms is referenced in a specific content type (i.e. Small products)

So it would look like:

Eye damage: 44
Skin irritation: 13
Hair lose: 1
.
.
.

Now, this is fairly easy to do with a db_query and custom code, but the trick is to do it in a view (if it's possible)


texts: Drupal 7 Does “New Node Creation” initiate/prepare the Fields for different Content Types?

texts:
In Drupal 7, i need to Programmatically create the Nodes. As usual, there are Different Fields set for Different Content Types.

For very simple example:

Content Type: "car"
Fields: "Model", "Engine", "GearType"

Content Type: "article"
Fields: "Title", "Author", "Media"

What i want to be confirmed here is, while i am creating a new node, for e.g by using:

$node = new stdClass();
$node->type = "car";

Then..

Is that (currently creating) new $node has been initiated/loaded with its related/corresponded fields, already before get saved?
To be more clear, if i just suddenly Save a node node_save($node) (without filling any other related fields) will that node be still having (following) its proper Content Type structure?


texts: When adding Custom Blocks the weight is changed for the rest of the blocks

texts:
We are using custom blocks very extensively. We are also using block visibility groups and Domain Access. At this point when we make a new block it changes the weight of many of the other blocks at what seems to be random intervals.

Has anyone else had this issue?


texts: Create a view to show comments on a user ONLY from that user

texts:
Am using comment as reviews for a content type. Now am trying to create a block in views that will appear on the user profile page. I want to show ONLY comments (reviews) that are from the specific users page i'm on. If the user has no comments made, then the block would be hidden. What settings in views would allow this to happen?

I've tried using content filters and relationship filters but I haven't been able get the right settings. Example: Am on User A's Profile page, I want to display all comments from User A on his profile page.

EDIT: Since my answer really didnt receive anything that can help. I will try to better word the question. I just need to create a block with comments from a specific content type in context to the user profile I'm on. I've created my view and added a contextual filter base off the author uid. But it still shows all the comments not just the ones from the current profile user.


texts:
I created View "Places" consisting of 3 fields (image,date and title) filtered by content type.

This is to create a page showing thumbnails.

I created another view "Gallery" showing images and I need this View to be linked to the corresponding thumbnail image.

Any idea how i can achieve this?
Thanks to everyone...


texts:
I want to have two different templates for the same field on a node template.

For example:

{{ content.field_section }}

    // uses paragraph--section.html.twig
    // Only want to print the titles from paragraph sections

{{ content.field_section }}

    // uses paragraph--section2.html.twig
    // Want to print the body and titles from paragraph sections

How can I do this? Is there a way to flag one instance or force a specific template?


texts: How can I authenticate against a non-drupal database?

texts:
We have a non-Drupal intranet system built on php/mySQL. We're adding a Drupal install to handle some social functions, and would like (if possible) to not duplicate all of our login information. Is there a module (or technique) that would let us authenticate against our existing users table, rather than needing to create separate user records in the new Drupal install?

I did find this, but it's been abandoned for 6 years, so I don't know how relevant it is anymore.

We have not started the new install yet, so either 6 or 7 is possible - if there's a module that would work for only 6, we're perfectly willing to do that.


texts:
I have installed the Webform Localization module but it's unstable and doesn't seem to work yet (it's in dev)

Ideally, I would like to replicate the behavior of other content types: create a new node that is linked to the original so the user can switch.

Any thoughts or similar experience?


texts: How to save content type before saving an exported view through code?

texts:
I am using a module that defines a content type and view. When I install my module, the view is saved before the content type. So, my view states that fields of that content type are not available.

Is there any way to save content type first and then view?

.install

function _productcustomtype_installed_fields() {
    $t = get_t();
    return array(
        'example_date' => array(
            'field_name' => 'example_date',
            'label' => $t('example Date'),
            'type' => 'date'
        ),
        'example_slot' => array(
            'field_name' => 'example_slot',
            'label' => $t('example Slot '),
            'type' => 'list_text'
        )
    );
}

function _productcustomtype_installed_instances() {
    $t = get_t();
    return array(
        'example_date' => array(
            'field_name' => 'example_date',
            'type' => 'text',
            'label' => $t('example Date'),
            'widget' => array(
                'type' => 'date_popup'
            ),
            'date_format' => 'Y-m-d',
            'display' => array(
                'default' => array(
                    'label' => $t('example Date'),
                    'type' => 'date_popup'
                )
            )
        ),
        'example_slot' => array(
            'field_name' => 'example_slot',
            'type' => 'text',
            'label' => $t('example Slot'),
            'widget' => array(
                'type' => 'list_text'
            ),
            'display' => array(
                'default' => array(
                    'label' => $t('example Slot'),
                    'type' => 'list_text'
                )
            )
        )
    );
}

function add_custom_fields() {
    foreach (_productcustomtype_installed_fields() as $field) {
        field_create_field($field);
    }
    foreach (_productcustomtype_installed_instances() as $fieldinstance) {
        $fieldinstance['entity_type'] = 'node';
        $fieldinstance['bundle'] = 'example_calendar';
        print_r($fieldinstance);
        field_create_instance($fieldinstance);
    }
}

function example_install() {
    node_types_rebuild();
    $types = node_type_get_types();
    add_custom_fields();
}

.module file

/**
 *
 * @return type
 * Implements hook_node_info
 */
function example_node_info() {
  return array(
    'example_calendar' => array(
      'name' => t('example Calendar'),
      'base' => 'example',
      'description' => t('A example content type'),
      'has_title' => TRUE,
      'locked' => FALSE,
    ),
  );
}

/**
 *
 * @param type $node
 * @param type $form_state
 * @return type
 * Implements hook_form
 */
function example_form($node, $form_state) {
  $type = node_type_get_type($node);
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => check_plain($type->title_label),
    '#default_value' => !empty($node->title) ? $node->title : '',
    '#required' => TRUE, '#weight' => -5
  );

  return $form;
}

/**
 *
 * @return type
 * Implements hook_views_api
 */
function example_views_api() {
  return array(
    'api' => 3.0,
  );
}

/**
 *
 * @return type
 * Implements hook_views_default_views
 */
function example_views_default_views() {
//node View code goes here
}


texts:
I am a newbie to Drupal, and I really don't understand the difference between sub-theme and base theme. Why can't I directly edit the base theme?

I am working on a website which is live and has bartik as default theme. I don't know where to start.


texts:
I have created a custom filter which displays some select options to the user in order to filter a view. However, I am uncertain how to add this using the hook_views_data() hook, being that the table which the filter is being applied to is a CCK table called content_type_sm_mention.

Currently I have the following, which I am not sure is right. What is missing?

function smd_views_data()
{
    $data = array();
    $data['content_type_sm_mention']['sentiment'] = array(
      'title' => t('Sentiment'),
      'help' => t('Filter by mention sentiment.'),
      'real field' => 'field_mention_sentiment_value',
      'group' => t('Content'),
      'filter' => array(
        'handler' => 'views_handler_filter_sentiment',
      ),
    );
    return $data;
}
function smd_views_handlers() {
  return array(
    'info' => array(
      'path' => drupal_get_path('module', 'smd') . '/includes/views',
    ),
    'handlers' => array(
      'views_handler_filter_sentiment' => array(
        'parent' => 'views_handler_filter',
      ),
    ),
  );
}


texts: Views Auto-Refresh giving ajax error after some time

texts: After creating views and implementing the views auto refresh on that it works fine for 8-10 minutes but after that giving error in alert "An AJAX HTTP request terminated abnormally.Debugging information follows.Path: /?q=views/ajaxStatusText: errorResponseText:ReadyState: 0" and stop refreshing then. why it is happening and how to resolve it?


texts: Are there any disadvantages in placing form elements in custom containers?

texts:
I've got a form layout in which form elements are separated between 2 divs: one with float: left, the other with float: right. I have to keep it that way.

Is it fine to place form elements in different containers? Could I get any troubles with form validation or submitting?

What's the best way to do it, via hook_form_alter(), or something else?

P.S. I'm not developing a custom module, but a theme. Here is an example of the form HTML; it's not precisely what it's going to be, but it gives an idea.

            <input type="text" id="name" />
            First name:

            <input type="text" id="surname" />
            Surname:


texts: Removing the "File Browser Tab" for certain roles

texts:
How would I go about removing the "File Browser Tab" from the user profile page for certain roles?

I only want authors, editors and administrators to be able to browse through and upload the files.


texts: How to hand over value of field 1 to class array of field 2 programmatically in .theme

texts:
Motivation

Context between template variable arrays is an old problem already known in D6 and 7 on theming level. What about D8 now? Any light on the horizon? Any chance to make this avaible without using Views module tweaks and work arounds?

Let's use an example:

Default standart content type Article has 4 input fields:

label (title)
body (main text area)
image
tags (terms, entity reference)

This content type also has an alternative Manage Fields Display setting for the Teaser view mode, where the image field formatter is set up using a smaller Image Style and with the option to link to the file or full node page. This creates an  element with url but without title or any other attributes around the Article image markup in Teaser view mode.

The question:

How can I hand over e.g. the first value of the tags (input terms) programmatically to a classes array of the wrapping  element?

In node--view--frontpage.html.twig this ...

`<a href="#" class="image icon fa-{{ (content.field_tags['0']['#title']) }}">{{ content.field_image }}</a>`

... works. Sure, because we grab it from the page variable. But image-formatter.html.twig is deeper nested inside the whole template system and it would be an overload to have the whole page variable array available here. Of course it is not there.

My assumption was to use the following preprocess functions:

function theme_preprocess_field(&$variables) {} and or
function theme_preprocess_image_formatter(&$variables) {}

The problem:

It seems - even if _preprocess_image_formatter has been suggested in the twig comments of the image-formatter.html.twig - there is 1.) no place to pass a string to any kind of attributes array for the  element in this twig file since the array has no given place for that. 2.) The hand over. How? Global vars are mostly not the best solution.

The core template code of image-formatter.html.twig:

{% if url %}
  {{ image }}
{% else %}
  {{ image }}
{% endif %}

The drafted alternation to demonstrate the needed effect:

{% if url %}
  {{ image }}
{% else %}
  {{ image }}
{% endif %}

NOTE: adding values manually and directly in the twig theme file like

{{ image }}`

shows that this is the right twig template. But it seems there is no way to get other values handed over (here), since _preprocess_image_formatter $variables array doesn't know any values of other fields of course (like of tags term field). And _preprocess_field() doesn't reach the image formatter level so that an addition to the attributes array rather affects the surrounding div but not the  element.


texts: Create order in drupal commerce programmically with product cost change in order

texts:
I have a shop with one product, I want have a feature that user only determine how much he/she want to pay and then pay it.after complement payment manager of site according of amount money he/she paid, create a custom product and sent it.
My idea is create custom porduct with 1$ cost and then create a form and get the  amount value from user,then I want create an order programmically and in order update the price with the value that user entered.
How can Implement this?

I want something like this enter link description here


texts:
I have not been able to determine whether Drupal supports multitenancy:

  Multitenancy refers to a principle in software architecture where a
  single instance of the software runs on a server, serving multiple
  client-organizations (tenants).

Specifically, I am interested in a single Drupal installation supporting multiple user organizations that would share the same environment but be able to have separate interface configurations and settings, and otherwise being totally unaware of other tenants (users).

An example would be a single install of Drupal being used to serve up multiple organizational websites in a SaaS type offering.

Does anyone have any information on this?


texts: How to implement ORDER BY SUBSTRING in db_query

texts:
I am migrating comments from a Drupal 6 site into Drupal 7 - but I am importing into the Reply module https://drupal.org/project/reply because the comments were on a Profile node in Drupal 6 but now I'm using Profile2 entities in D7.

I am trying to connect to my legacy database and so far my query is like

$query = $this->sourceDbConnection()
  ->select('node', 'n')
  ->fields('n', array('nid', 'title', 'uid',))
  ->fields('c', array('cid', 'pid', 'nid',  'uid', 'subject',
    'comment', 'hostname', 'timestamp', 'status', 'format',
    'thread', 'name', 'mail', 'homepage',
));
$query->innerJoin('comments', 'c', '(n.nid=c.nid)');
$query->where('(n.type=:type)', array(':type' => $this->LEGACY_CONTENT_TYPE));

However, I wish to add an ORDER BY to the query similar to how it is used in the comment_render function https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/comment_render/6 i.e. ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))
and I don't know how to do this.


texts: Create a kind of coupon with a entity references or node reference and no autocomplete

texts:
I should create a webform with a field which is related to a node.
With webform seems no possible to add a node reference, so probably I should create a content type (coupon) instead of using the webform module.
Basically, when they complete the form they can fill the field "coupon" and if the coupon exists they can go through.

The most important thing is that the node reference should be a text field with NO AUTOCOMPLETE I don't want them to see the the other coupon. How do I create it?

I've already installed the module reference and entity reference and using drupal 7.12.

Thanks in advace


texts:
I'm trying to hook into a view header for custom output but cannot get anything to output:
function MYTHEME_views_pre_view(&$view, $display_id, array &$args)
{
    if ($view->id() == 'videos') {
        if ($display_id == 'assigned_categories') {
            $options = array(
                'id'           => 'area_text_custom',
                'table'        => 'views',
                'field'        => 'area_text_custom',
                'relationship' => 'none',
                'group_type'   => 'none',
                'admin_label'  => '',
                'empty'        => true,
                'tokenize'     => false,
                'content'      => 'TEST',
                'plugin_id'    => 'text_custom',
            );
            $view->setHandler('assigned_categories', 'header', 'area_text_custom', $options);
        }

    }
}

This is based on this answer. Nothing is output in my template tho in the {{ header }} field.