texts: How to filter audience in organic groups?

texts: I am using drupal commons. When i create an organic group I have the option of placing it within an existing group using the audience list. The audience list displays ALL groups (regardless if they are set to private). How can i make it so that the audience list only displays groups that belong to the creator (udid)?


texts:
On my Drupal site, there's a specific type of content with a right panel (Documents), in which I add files (Field Type - file, Widget - file).

For that particular type of content, I wanted to change the way those files are displayed. Someone asked for help in this post, but I'm now quite sure it is the right way to go, since the solution mentions Views (I'm not using a View here) and Linkable Icon (never seen this option before).

I understand I might have to insert custom php code, but I'm not sure where. Is this a theme issue or module issue?


texts: Field text not getting translated sometimes

texts:
As in the image(of German node), I'm outputting a text link in English: "Report an Issue" using Computed Field module so it looks like: $text = t("Report an Issue"); in the php code.

I've then translated it by going to admin/config/regional/translate/translate in all supported languages.

The problem is that sometimes I see the English version: "Report an Issue" in the non-English nodes. Many times it looks fine. But when I clear all caches, it shows fine. While all the node title, fields, labels show correct translation only except this field. The url is see is mysite.com/de/title which is as expected.

I'm only using i18n and not Entity Translation.

What could be the problem?


texts: I've built a custom field into the view which displays the menu name a node is assigned to, but I want to filter on the menu name. How can you filter on this computed field? The only examples I have found are for updating the SQL query to filter on existing values in the table.


texts: How do I safely get the internal path to the current site in a multisite setup?

texts:
I'm working with a multisite Drupal 7 install with many sites. The site accepts both "www." and without via Apache. I'm developing a themes in /sites/all/themes which is used by many of these sites and I want something like this:

$apple_icon =  array(
    '#tag' => 'link',
    '#attributes' => array(
      'href' => '/' . path_to_site() . '/apple-touch-icon.png',
      'rel' => 'apple-touch-icon',
    ),
  );
  drupal_add_html_head($apple_icon, 'apple-touch-icon');

where path_to_site gives like /www/drupal7/sites/blah.com etc. depending on the site being used. I need this since each site will need a different icon.

I guess something like '/sites/' . $_SERVER['HTTP_HOST'] and then I can use symlink aliases for the "www." variant.

How can I do this properly?


texts: Creating a View of Only Childless Comments

texts:
We have a support system in which one user can request help or insight from another user by selecting that user from a dropdown list, which is an additional field in each comment. I am attempting to create a view which will display only those comments which have both:

requested the authenticated user's attention
have not been responded to by the authenticated user.

In essence, I want to create a view of comments which haven't been replied to by the authenticated user. (The first filter is simple and I already have working.)

The problem I'm encountering is, although Views has a Parent-Comment Relationship, it has no Child-Comment Relationship. So I can use that relationship to either gain access to comments who have or do not have parent comments, I can not use this to determine if the comment itself is a parent (that I know of).


texts:
I'm testing the creation of user accounts on the new website and I get a general database error after attempting to create an account. The error log shows:

  Sep 14 09:06:01 test drupal_www_example_com:
  https://test.example.com|1505379961|php|97.120.1.69|https://test.example.com/user/register|https://test.example.com/user/register|0||PDOException:
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
  'user-203409-0-0-und' for key 'PRIMARY': INSERT
  INTO {field_data_field_name_first} (entity_type, entity_id,
  revision_id, bundle, delta, language, field_name_first_value,
  field_name_first_format) VALUES (:db_insert_placeholder_0,
  :db_insert_placeholder_1, :db_insert_placeholder_2,
  :db_insert_placeholder_3, :db_insert_placeholder_4,
  :db_insert_placeholder_5, :db_insert_placeholder_6,
  :db_insert_placeholder_7); Array#012(#012
  [:db_insert_placeholder_0] => user#012
  [:db_insert_placeholder_1] => 203409#012
  [:db_insert_placeholder_2] => 203409#012
  [:db_insert_placeholder_3] => user#012
  [:db_insert_placeholder_4] => 0#012    [:db_insert_placeholder_5]
  => und#012    [:db_insert_placeholder_6] => betachristia556#012    [:db_insert_placeholder_7] => #012)#012 in
  field_sql_storage_field_storage_write() (line 514 of
  /var/www/html/example/docroot/modules/field/modules/field_sql_storage/field_sql_storage.module).

I looked in the user table and there is no user for the ID 203409.


texts: Drop down of site pages for admin to choose

texts:
I have a content type which has a link (text type), and admin can manually insert his link. My site pages consist of the pages that work with views module (views page), and also pages that are rendered from node--mynodename.tpl.php.

Can I create this select box for site pages for admin to select?

consider I have these pages in my site :
1) homepage  2) contact page  3) about page  4)services page

so I have 4 page ! right ?
so If I need to have a button in my home page for example which I want to link that to contact page ??
in admin should I manually fill the link like: http://www.blabla.com/contact ??
or in drupal and it's modules I have an option to select in my site pages for button link??


texts: Display field's label only when any value added to it

texts:
For example Taxonomy Terms field Label is always displayed even if no tags added to it. How can I show Taxonomy Terms field's Label and its values (tag's links), only when there have been a value added to it?

I try to achieve that by adding conditionals based fields, something like below code to node template:

{% if content.field_tag is not empty %}
{{ content.field_tag }}
{% endif %}

or

{% if content.field_tag %}
{{ content.field_tag }}
{% endif %}

According to the article:Comparison of PHP Template and Twig theming paradigms but whatever I try I can't get any result.


texts: Home page links are not working , admin login not working via http://localhost/bi/?q=admin/modules link

texts:
I moved a drupal installation from one server to another. Steps I followed:

Copied whole directory structure from old server.
Exported database from old server.
added files to newdomain/drupal
Imported database
edited settings.php with new database information.

As of right now the home page is working (Except for some broken non-db images, but I know the reason for that and can fix it) But none of the links to any of the nodes or any of the admin paths I know seem to exist. I get a 404 File Not Found error.

I wonder if it's related to the fact that this installation is in a subdirectory and the other one was not, but is that enough to make every page except the homepage not function?


texts:
I have downloaded nexus free theme and I want to change the title
in all pages of my site.

Is there a way to do it editing the template.php?

thanks...


texts:
I new in Drupal 8 and I have an a problem, i want to change de look of my user_login_form, reading about that i knew that i could use the hook_form_alter for my purpose but I can't access the form variables in the template of Twig. My hook is the next:

function halcones2_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  switch ($form_id) {
    case 'user_login_form':
      //Altera el formulario para añadirle una plantilla y poder imprimirlo
    $form['#theme'] = 'halcones2_user_login';
      break;
  }
}

To render the form to my template, that works but the form variables doesn´t appear like {{ form.name }} or {{ form.pass }} only I a can see de divs that i have in my template of twig.
My source to do that is the link https://nireneko.com/articulo/2018/05/personalizar-formulario-plantilla-drupal-8 but my problem is the form variables.
Someone can help me please??


texts: add/change div wrapper around specific radio button?

texts:
By default, the HTML markup for radio buttons looks like (Drupal 7):

  <input id="edit-SOME_ID" class="form-radio" type="radio" value="SOME_VALUE" name="SOME_NAME" />
  MY LABEL

I need to change/add some css classes in the outer
 OR add a wrapper
. How do I do that?


texts: I want to ask about how to update Drupal 7 sites. My site is divided into 2 phases, after launching and adding data in the first phase, I now want to update the second phase. I have a lot of new content type, Views and panels. I added a new language and blocks, a lot of things. I can export panel and view but what about the content type, language and any permission or configuration that saved into database.


texts: Available approaches for moving userpoints from one user to another

texts:
Using the User Points module, I have this use case to design:

"move user points from User A  to User B"

What are the possible approaches we have here?


texts: Sort the products by SKU when seeing order details

texts:
I have an Ubercart commerce website in Drupal 7.

I'm trying to sort the products listed inside a given completed order by the SKU value.

This is the link: /admin/store/orders/1 or /admin/store/orders/300

I tried to edit uc-order--admin.tpl.php but it did not work. I tried everything but nothing works. Maybe I'm doing it wrong.

I'm new to theming and templating so the code I wrote or the place I did might have been wrong also.

Any ideas on how to sort the products by the values in the SKU field in an order that was already placed?

Inside uc-order--admin.tpl.php I added the following code:

$order_output = array();
$order_info = new stdClass();
$order_id = '';

$array_key_modifier = 0;
foreach ($products as $product) {
    // organize products by sku
    // make an array with stuff I need
    // sku => array(item,model,price,quantity,subtotal)
    // then sort keys by alphabetical value, output to table
    $array_key = '';
    if (!isset($order_output[$product->model])) {
        $array_key = $product->model;
    } else {
        $array_key = $product->model . $array_key_modifier;
        $array_key_modifier++;
    }

    $order_output[$array_key] = array("title" => $product->title, "model" => $product->model,
        "price" => $product->price, "quantity" => $product->qty, "subtotal" => $product->total_price);
    //  "price");
    $order_info = $product->order; // each product has complete built in order info. Maintain a reference to it
    $order_id = $product->order_id;

    if (!empty($product->data['attributes'])):
        $order_output[$array_key]["attributes"] = $product->data['attributes'];
    endif;
}

ksort($order_output);


texts:
I have two languages:

french
arabic

I want to completely translate the arabic interface. If there a way to export the englisch translations, add the arabic one and reimport the file?


texts:
Running seige (load tester) without memcache enabled I see stats similar to this:

Transactions:                    560 hits
Availability:                 100.00 %
Elapsed time:                  59.42 secs
Data transferred:               6.25 MB
Response time:                  1.56 secs
Transaction rate:               9.42 trans/sec
Throughput:                     0.11 MB/sec
Concurrency:                   14.71
Successful transactions:         543
Failed transactions:               0
Longest transaction:           10.57
Shortest transaction:           0.00

Notice that I'm getting about 560 transactions in 60 seconds, 9.42 trans/sec.

When I enable memcache (using the PECL memcache module) and re-run siege I see much worse performance:

Transactions:                    133 hits
Availability:                 100.00 %
Elapsed time:                  59.94 secs
Data transferred:               1.34 MB
Response time:                  6.43 secs
Transaction rate:               2.22 trans/sec
Throughput:                     0.02 MB/sec
Concurrency:                   14.27
Successful transactions:         129
Failed transactions:               0
Longest transaction:           12.22
Shortest transaction:           0.00

Notice that I've decreased my performance significantly. I was only able to process 133 hits in 60 seconds and the throughput is 2.22 transactions per second.

I have memcache setup on its own dedicated system with 4GB of RAM and here are the parameters:  memcached -d -p 11211 -u memcached -m 2560 -c 2048 -P /var/run/memcached/memcached.pid

I noticed that if I go to /admin/reports/memcache I get the following PHP errors:

Notice: Undefined variable: stats in dmemcache_stats() (line 244 of /www/sites/all/modules/memcache/dmemcache.inc).
Warning: Invalid argument supplied for foreach() in dmemcache_stats() (line 244 of /www/sites/all/modules/memcache/dmemcache.inc).
Notice: Undefined variable: stats in dmemcache_stats() (line 263 of /www/sites/all/modules/memcache/dmemcache.inc).
There are no statistics being reported for this bin.

I'm not sure if that's related to the issue or not?

This is what I have in settings.php:

/**************************************************
 * MEMCACHE
 **************************************************/
// the path to the core cache file
include_once('./includes/cache.inc');
// the path to the memcache cache file
include_once('./sites/all/modules/memcache/memcache.inc');

$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['memcache_servers'] = array(
        'memcache.domain.local:11211' => 'cluster'
);

$conf['memcache_bins'] = array(
        'bin1' => 'cluster'
);

$conf['memcache_key_prefix'] = 's-drupal';

Why is memcache slowing down my site instead of speeding it up? Would switching to PECL memcached help?


texts: Can not unset rows of a view programmatically

texts:
I created a view of terms using views_tree module. I need to remove some of the terms under some conditions. This is my code

function THEME_views_pre_render(&$views) {
    for($i = 0 ; $i < sizeof($views->result) ; $i++)
       unset($views->result[$i]);
}

But it still prints all of the terms and doesn't delete any of them. I tried this code

function THEME_views_pre_render(&$views) {
    for($i = 0 ; $i < sizeof($views->result) ; $i++){
        $views->result[$i]->taxonomy_term_data_name ="Hello";
    }
}

It successfully renamed every term, But when I tried the following code, every name turned back to what it was from the beginning and nothing removed.

function THEME_views_pre_render(&$views) {
    for($i = 0 ; $i < sizeof($views->result) ; $i++){
        $views->result[$i]->taxonomy_term_data_name ="Hello";
        unset($views->result[$i]);
    }
}

How can I remove some terms ?


texts: preprocess_field() not working - what am I doing wrong?

texts:
I am trying to use mytheme_preprocess_field() to alter how a field is displayed. Here is the code I added to my theme's template.php:

function creative_responsive_theme_preprocess_field(&$vars) {
$element = &$vars['element'];
if ($element['#field_name'] == 'field_myfield') {
   $element['#items'][0]=[];
   $element['#items'][0]['value'] = 'replaced value';
   $element['#items'][0]['format'] = 'filtered_html';
   $element['#items'][0]['safe_value'] ='';
   $element['#items'][0]['#markup'] = 'replaced value';
   return;
 }
}

I confirmed that the code is being executed, but the rendering of the page does not reflect what I have done in the code. The field is being displayed as usual. I am using display suite. Not sure if that effects anything, but searching online, I see no indication that above should not work. And I added the #markup part because I read that is truly what one has to do...

Ideas?

regards


texts:
I use Drupal7. I want to create some dozens of dummy fields in my test node quickly. But, it will take long if I do at "manage fields page"(admin/structure/types/manage/CONTENT_TYPE).

Unfortunately, I couldn't find any modules to do it(Devel Generat can create contents, but not fields). Any suggestions to do it?
Thank you.


texts: Topics are not getting associated with forum

texts:
I am testing out the Drupal 8 core Forum module.  I am using a theme that I based off of Acquia Lightning.  I have successfully installed the module and added Containers, Forums and Topics.  My issue is that the Topics I create don't seem to get associated with the Forum taxonomy.  In other words, when I go to /forum I see my containers and forums but every forum has Topics: 0, Posts: 0, Last Post: n/a.

I have tried clearing cache, running cron, looking at the watchdog logs but nothing seems to indicate why it isn't working.  I am not receiving any memory errors, white screen of death, etc.  All other site functions seem to work properly: I can save content and taxonomies, create new views, assign blocks, etc.

See the attached screen grab.  I could use some ideas on what might be causing this.  Any assistance would be greatly appreciated.


texts: How can i make a new node title into a taxonomy term?

texts:
I have a Drupal 7 content type that, when a new instance is created, its title becomes a new taxonomy term in a vocabulary. How can I do this?

Additionally, if the Title is changed, or the node deleted, then the corresponding Vocabulary should be updated accordingly.


texts:
The documentation states:

  The argument passed to the getForm() method is the name of the class
  that defines your form and is an implementation of
  \Drupal\Core\Form\FormBuilderInterface.

How do I find out the name of the class that defines the website feedback form provided by the core contact module (the form id is: feedback_contact_message_form).

When I dpm() the form I can see that there is a class defined:

$input array(30)
  →'#attributes' => array(1)
    →'class' => array(3)
      string(29) "feedback-contact-message-form"
      string(20) "contact-message-form"
      string(12) "contact-form"

I tried various forms of this as the parameter to pass to:

\Drupal::formBuilder()->getForm();

but no luck. Thanks


texts: Why does updating newly added field collection on hook_field_collection_item_insert fail?

texts:
The main goal is to create product & product display using drupal 7 &
drupal commerce when a user with a certain role add a new field collection.

What I'm trying to do is when a new field collection is added :

access host entity fields and retrieve some datas
do some custom stuff
update 1 value of a field collection which is a field
reference to product

Steps followed :

I'm using hook_field_collection_item_insert to access newly created field collection.
I call a function which create a product (using commerce modules suites). Above steps works just fine.
Then I call a function that update the current field collection field by adding a value which is a reference of product created in function my-module-create_product().

$fc_wrapper->save(TRUE); is failling to save with the following error :

Exception: Unable to save a field collection item without a valid reference to a host entity in FieldCollectionItemEntity->save() (line 520 of ../mysite.local/docroot/sites/all/modules/contrib/field_collection/field_collection.module)

I've done some search so far without any success.

I can't figure out the fix for this, some direction or any information that will help to solve this issue will be much appreciated.

Below a simplified code that I'm using :

function my_module_field_collection_item_insert($field_collection_item) {

    $item_id = $field_collection_item->item_id;
    //dpm($item_id);

    //Check the field collection bundle & if it's just have been created
    if ($field_collection_item->field_name == 'field_my_field_collection' && $field_collection_item->is_new == TRUE) {

        //Access host entity
        $node_wrapper = field_collection_item_get_host_entity($field_collection_item);

        //Do custom stuff with host entity fields
        //...
        //set $product_type, $price, $extras values

        //Call a function that create product
        $product = my_module_create_product($product_type, $price, $extras);

        //Product creadted
        if ($product) {

            $product_display = my_module_create_product_display($product, $item_id);

        } else {
            throw new Exception('Product creation as failed...');
        }
    }
}

//Function that create product
function my_module_create_product($product_type, $price, $extras) {
    //create product
    return $created_product;
}

//Function that create product display
function my_module_create_product_display($product, $item_id) {

    //Note that loading existing field collection here works but it not what I need
    //Loading created field collection
    $fc_wrapper = entity_metadata_wrapper('field_collection_item', $item_id);

    if ($fc_wrapper) {

        if ($fc_wrapper->field_product_ref->value() == NULL) {

            //Setting product reference
            $fc_wrapper->field_coaching_product_ref->set($product->product_id);

            //Only need to save the current field collection
            $fc_wrapper->save(TRUE);

            //I've tried bellow still don't work either
            //$fc_wrapper->save();
            return $fc_wrapper->getIdentifier();

        } else {
            //Product display already exist
            return FALSE;
        }
    } else {
        throw new Exception('Exception... ');
    }
}


texts: How To Wrap Drupal Form API in html div structure [in my Drupal theme files (.tpl file)]

texts:
I have a webpage which is being rendered from my page.tpl.php , it has a login page at top - right of page.
I am kind of struggling to wrap my LOGIN HTML FORM in Drupal Form API

Below Links did not help me that much even though it gave me general idea

1. should-i-put-input-tag-inside-label-tag

2. drupal-7-forms-how-do-you-wrap-an-input-in-a-label

3. how-to-put-two-form-elements-in-a-row-using-drupal-form-api
 Below image shows my Login form

theme_form_element , drupal-form-api-prefix-suffix, using-prefix-and-suffix-form-api-layout and drupal-form-wrap-div-tag-custom-html-prefix-suffix gave me some idea but I am still puzzled about this things.

{
found some more helpful links for this :

how-to-create-multiple-forms-in-drupal-7.html
page-user-login.tpl.php
page-template-for-custom-form
Printing a form on a page with drupal_get_form
}

Can some one guide me for this.

I am not sure if I should go with Drupal form or just use the normal HTML Login in PHP way.

For Better Understanding of the scenario I am adding screen shots and details of my task below, it is purely just for example, all I am looking for is some guidance for the task I am doing, answer does not have to be exactly FORM API of my HTML but I need to know how to achieve this in page.tpl.php.

[Do I have to create new custom module or I can manage this in my page.tpl.php- sorry if it is very simple question, I am little new here in drupal ]

  Here is the HTML

            <button class="primary_btn">Download Guidelines</button>
            <button id="loginPopup" class="primary_btn">Login</button>

Email address

<input type="text" placeholder="Enter your email address">

Password

<input type="password" placeholder="Enter your password">

Not registered?

<input type="checkbox" vlaue="ss">Tick this box and click 'Register'

                    <button class="primary_btn">Login</button>
                    <button class="primary_btn">Register</button>
                    <button class="primary_btn">Cancel</button>

I need to create a Login and Registration Module. I have this whole form in basic html not in form, I am struggling to convert this to Drupal From

Also I am not sure if I should go for Drupal Form or not. Since my requirement is to show the error message in the same place
 . see below

Thanks :)


texts: Need help with superfish module on Bartik theme

texts:
Need your help on this subject.
Pretty like Bartik theme but as you know can’t have sub menu on Main menu on Bartik theme, so I would like to use Superfish module on it.

I have searched internet to find solution but failed, and I don’t think there is same post here, so please allow me to post it here.

What I have done:

Have installed superfish module successfully, I am sure.
Have created subtheme of Bartik successfully, I am sure too. (name is subtheme3)
Added a region calls superfishmenu to subtheme3.info below header region.
Copied page.tpl.php to sbuntheme3 folder and change some code to it.
Disabled Main menu in Menu Setting, so there is only Superfish menu shows.

My problem:
No.1, Superfishmenu block shows but the width is not like others short and at the center of screen. I would like to make it as same wide as other regions like featured region.

No.2, the sub menu of superfish menu doesn’t show sub menu but if I flush all the cache and the message shows, which give a lot padding space, then the sub menu shows. When the message is gone, the sub menu can’t show again.

I am not good at CSS and PHP, and I believe the problem is CSS and the PHP code in page.tpl.php.

Is there anyone can give me the correct codes for them?


texts:
I'm trying to display a photo as background image for a Drupal 7.7 website.

After reading a doc on subthemes, I have created a directory called "pasture" in the same directory where "bartik" resides (i.e. in ~/public_html/drupal/themes/pasture).

I have created the pasture.info file.

name = pasture
base theme = Bartik
stylesheets[all][] = pasture.css
files[] = pasture.jpg
core = 7.x

I have created the pasture.css file.

#header {
        background:url(/drupal/themes/pasture/pasture.jpg) top left no-repeat;
}

I have saved a public domain image as pasture.jpg. The image is the following one.

Unfortunately, my site appears completely broken, after I activate that theme, and I see numerous warnings:

  Notice: Undefined index: Bartik in method drupal_theme_initialize() (line 98 inf file /usr/www/users/simplex/drupal/includes/theme.inc).
  Notice: Trying to get property of non-object in method phptemplate_init() (line 12 in file /usr/www/users/simplex/drupal/themes/engines/phptemplate/phptemplate.engine).


texts: Drupal modules to display external RSS feed

texts: what Drupal modules should be installed and enabled to display external RSS feed? I mean not default Drupal Aggregator module, but another, more flexible way to display feed in any page as content. (I had all this preconfigured, but a long time ago)


texts: How can I trigger a Drupal Core action without writing any PHP code?

texts:
On my D8 site I have configured an action of type "Send email" using the Drupal Core "Actions" module (module can be installed under "Administration > Extend"). I want this Drupal Core action to trigger when a new comment is submitted.

In D7 there was another Drupal Core module named "Trigger" which allowed me to configure the desired trigger. In D8 there's no longer a "Trigger" module, nor can I find any other means to configure any Drupal Core action triggers. In the D8 docs I have found this not-very-helpful paragraph:

  In D7, there are triggers defined, supporting the core Trigger module. This is not supported in D8.

My general question therefore is: How can I configure a D8 site to trigger an action that was defined via the Drupal Core module "Actions" when a certain event occurs? Specifically in my case: How can I trigger a "send email" action when a comment is submitted?

As the title of this question mentions, I don't want to write PHP code to achieve this. I am willing to install a stable third-party module, though, as long as it cooperates with the Drupal Core "Actions" module.

In a wider sense, I am trying to understand what the Drupal Core "Actions" module does. To me, the module seems to be quite useless if as a site admin I cannot configure triggers for its actions.


texts: Fatal error: Maximum execution time of 240 seconds exceeded in sites/all/modules/memcache/memcache.inc on line 353

texts:
I am using multidomain site .
After adding a new domain record,
I was asked as follows: Content access permission needs to be rebuilt on this page.

When I clicked on Rebuild Permissions button,
the progress bar started the batch operation of rebuilding but in the midway it stopped and gave an error given below

  Rebuilding Content Access Permissions

  An error has occurred. Please continue to the error page An HTTP error
  0 occurred. /index.php?q=batch&id=433&op=do

I then searched an found an issue similar to the above in the link given below

https://www.drupal.org/node/399572

I found many solutions from above like :

Run rebuild permission via cron (did not try)
change theme  and move to older jquery version   (did not try as its live site)
I checked the settings for jquery update and had "minified" instead of "none", once set to the correct setting, it worked within seconds.

I was using jQuery update module with jQuery 1.4. This causes the batch to not update.

(did not try) To fix it, you have to prevent newer jQuery from loading when the URI contains "batch".

<?php
function node_access_rebuild($batch_mode = FALSE) {
  db_query("DELETE FROM {node_access}");
  // Only recalculate if the site is using a node_access module.
  if (count(module_implements('node_grants'))) {
//      if ($batch_mode) {
      if (FALSE) {
      $batch = array(
        'title' => t('Rebuilding content access permissions'),
        'operations' => array(
          array('_node_access_rebuild_batch_operation', array()),
        ),
        'finished' => '_node_access_rebuild_batch_finished'
      );
      batch_set($batch);
    }
?>

Not sure why this is happening to me, but I've found that I can just force node_access_rebuild() to not use batch mode by changing line 2314 of node.module from:
In node.module this piece of code, is setting time limit to 240 secs which might be still low than ur php.ini. You can try increasing set_time_limit arg to 1000 and then changing it back to 240 to keep code consistent.

 if (!ini_get('safe_mode')) {
        set_time_limit(240);
      }
      $result = db_query("SELECT nid FROM {node}");
      while ($node = db_fetch_object($result)) {
        $loaded_node = node_load($node->nid, NULL, TRUE);
        // To preserve database integrity, only aquire grants if the node
        // loads successfully.
        if (!empty($loaded_node)) {
          node_access_acquire_grants($loaded_node);
        }
      }
    }
  }

What I tried was increased the max_execution_time from 30 to 1000?
But still it did not solve the problem
Then finally I tried rebuilding permissions via drush

using drush command

drush php-eval 'node_access_rebuild();'

But that gave me the following error as shown below

PHP Fatal error:  Maximum execution time of 240 seconds exceeded in
sites/all/modules/me                                                                                mcache/memcache.inc on line 353

Does the above error means this is something to with memcache and will it be worth trying to disable the memcache and then perform rebuilding node access?

http://example.com/index.php?q=admin/content/node-settings/rebuild


texts:
I'm displaying a custom table in a view with Data & Schema module.
One of my field in that table is created_date, int of unix timestamp.
The view's page shown as table, how can I display it in a readble format?


texts:
Hello Drupal enthusiasts,

any idea why in my theme I cannot see that gear icon with contextual links for left menu? Module enabled, I see them for views and blocks used in Panels. But in left menu, where main navigation is, they're not being displayed. Switched back to default theme - here they are, switched to my theme - disappeared.

Any help?


texts:
I'm trying to trigger a javascript function after specific types of form submission on my site, as I want it to do something with the submitted data. I'm much more familiar with D7 than I am D8, and hence less familiar with the way D8 is object oriented so I'm just trying to check I'm going about it the right way.
In my module file
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\InvokeCommand;
use Symfony\Component\HttpFoundation\Request;

/**
 * Implements hook_page_attachments().
 */
function mymodule_page_attachments(array &$attachments) {
    $attachments['#attached']['library'][] = 'mymodule/mymodule';
}

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
    switch ($form_id) {
        case 'comment_comment_form':
            $form['actions']['submit']['#submit'][] = 'mymodule_form_submission';
        break;

        default:
            break;
    }
}

function mymodule_form_submission(array $form, \Drupal\Core\Form\FormStateInterface $form_state){
    $ajax_response = new AjaxResponse();
    $ajax_response->addCommand(new InvokeCommand(NULL, 'myTest', ['test']));
    return $ajax_response;
}

In the libraries.yml file
mymodule:
  version: 1.x
  header: true
  js:
    js/bootstrap.js: {}
    js/actions.js: {}
  dependencies:
    - core/jquery
    - core/drupal
    - core/drupalSettings

In my actions.js file
(function ($, Drupal, drupalSettings) {
    Drupal.behaviors.mymodule = {
        attach(context, settings) {
            $.fn.myTest = function (data) {
                console.log('My Test Has called');
                alert(data);
            };
        }
    };
})(jQuery, Drupal, drupalSettings);

I've modified the code to make it more readable on here, but I've gone through and tested each part, eg, my library is being added to the page, I've tested it being there by just writing to the console, I've tested the form_alter is being run and adding my extra submission action to the page by doing kint() or dpm() for the values, which also works, but at the moment I just don't seem to be able to trigger the AJAX Response to do my javascript command
I've been following this example on how to pass webform data to javascript, but in that code it seems to enforce ajax submission of the form (which I don't necessarily want to do, unless it's the only way this will work)
Basically, I'm just trying to take the data within the form submissions and trigger a javascript command, is this the right way to do it?


texts:
I know I can insert a view using the following code:

 <?php
    $view = views_get_view('VIEWNAME');
    print $view->preview('default');
 ?>

In my view I have a contextual filter of user: name

When I insert this view using the Display Suite module I have this option from Display Suite:

I was wondering if there is a way to pass this context to the view, like Display Suite does, using php code only.


texts: How to set the profile picture validation in profile 2 module in drupal 7?

texts: I am using profile2 module in my site. I want to hide the profile picture upload option at the time of registration. And after click on confirmation mail, i want to upload at least one profile picture means want to apply validation here. How to set the validation in profile picture that validation shows inside not at the time of registration. Please help. Thanks in Advance


texts: Google translate service not available on Translation Management module(Drupal 6)

texts:
When I using the translation management to translate my node, I got "Google translation failed to Chinese, Simplified: Google returned error #403: Quota Exceeded. Please see http://code.google.com/apis/language/translate/overview.html", anyone know what happen and how to fix it?

Thanks


texts: How to define an image style where images are the exact same dimensions (e.g. grid of square images), without cropping or distorting the image?

texts:
On my site, images of any shape can be uploaded, for example:

I want these to display in a grid where every image is the same size and shape (in my case, square) - due to the nature of the images, I don't want to use cropping and I don't want any distortion of the aspect ratio, but the backgrounds can be extended. This also needs to be applied to the image itself, not a CSS wrapper.

For example, I'd like the end result to look like this:

Everything I've tried using various combinations of "scale" and "resize" either doesn't give consistent final sizes depending on whether the original was tall or wide, or distort the image. Cropping isn't an option. How can I do this?


texts: How to create a log in and register link in the secondary menu

texts: I am trying to configure my login block on the front page such as that it appears on a separate page. I want the links to this page (that is, login and register) to appear in the secondary menu. I am using Zen with Drupal 7.


texts: How do I get the number of nodes using terms from a vocabulary on the same line together the link to the term page?

texts:
I created a view of taxonomy terms, and then followed these steps to add the number of nodes using each term listed in the resulting view.

As Format, I selected HTML List showing Fields
As relationship, I added Content using field_blog_category, where field_blog_category is the field I added to a content type I created
I checked Use aggregration
I added ID (listed under the Content category) as new field
I set Aggregration type to Count for the new field (by clicking on Aggregration settings for that field)

It works as expected, except the fields are not in the same line.

I checked the settings for both the fields, but I could not find a way to make them appear on the same line; even changing the settings for Rewrite results didn't help me.

Is it possible to have those two fields on the same line, without using Table as Format?


texts: How to costumize the input fields but only in the page /user?

texts:
I want to create a particular style with css for input style in the field of login, register and request new password.
The css if i see it width firebug is only one and i must adding a type only for the form of the /user page, but not for all page that containes form.
Thank you for help!


texts: Access denied: 'view published content' permission

texts:
When I look into admin/people/permissions: 'View published content' is checked for anonymous users.

Yet the following code:

function test_menu() {
  $items['test'] = array(
    'title' => 'Test',
    'access arguments' => 'view published content',
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

returns 'Accessed denied' when I navigate to /test as an anonymous user. I know I can do:

'access callback' => TRUE,

but the other code seems a lot neater. I've experienced this issue a few times before.

Thanks.


texts: I created a custom box on the Open Atrium dashboard. The box contained PHP code, I forgot a comma and now I got a blank page. The problem is that I don't know how to remove that box now. It is not there on the database and on the Drupal admin I can't find an option to remove it. Any help would be much appreciated.


texts: Do any comment modules play well with revisioning?

texts:
I'm faced with a situation where we need to keep track of which node revision a comment was made for, so that we can display whether the comment was made for a newer/older revision, or for the one currently being looked at. Do any comment modules allow this in D7?

Use cases

Not the actual use case, but a decent, easy-to-follow approximation of the idea: imagine a bookstore, where users can post comments about books. Typically, when a user asks to see a book's page, he sees the page about the book's newest edition, but in some cases a page for an older edition of the book is presented. In the list of comments for the book, comments are annotated with whether they were made about a different edition than the one being currently looked at, since the comment might not be applicable for other editions.
The actual use case is: teacher A creates learning material LM.v1 and then revises it to LM.v2; teacher B starts using LM.v2 with her class; when A revises LM.v2 to LM.v3, we still need to allow B and her class to use LM.v2, because LM.v3 might not work for B's needs at all (and changing a learning material mid-project is a big no-no); so, when looking at LM.v2, we want to be able to see all comments made about it, but with an annotation if the comment was about LM.v1 or LM.v3, since these may or may not be applicable in the LM.v2 case.


texts:
In Drupal 8. I noticed that I can create a new node or edit a current node and delete the "Authored By" name, it's blank and when I hit save the node is authored by Anonymous.

How can I make this Author field required to be a current user in the system?

And the page will show a message and will not save until a name is entered. I tried this but it does not work:

use Drupal\Core\Form\FormStateInterface;

function demo4_form_alter(&$form, $form_state, $form_id) {
$form['author']['name']['#required'] = TRUE;
}

I also tried this:

function demo4_form_alter(&$form, $form_state, $form_id) {
if ( $form_id == 'page_node_form'){
$form['author']['name']['#required'] = TRUE;
}
return $form;
}

This works only in Drupal 7 not in Drupal 8, And I changed page_node_form to node_page_form for Drupal 8

function demo4_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'page_node_form') {

$form['author']['name']['#required'] = TRUE;
 }
   return $form;
}


texts: How to avoid calling FieldCollectionItemEntity::deleteRevision

texts:
Sorry about the confusing name. I have the following problem. I have a migration for a content type that has a multivalue field-collection-item (~50 items there in average per content). The migration is fairly quick, 150 items/min. However the migration-update is very slow, 10 items/min. I've checked with xhprof and 95% of the time it spends inside FieldCollectionItemEntity::deleteRevision - basically deleting the old field collection items when re-populating the node with the new ones.

The content type has the revisions turned off, so the number of related revisions should be 1 all the time, not more. Is there any smart way to avoid this massive time that it takes?

I'm wondering if the Entity API has a queue system to save these delete operations for later. Or somehow removing revisions completely?

Thanks you


texts: Service connect, Response for preflight is invalid (301) redirect.

texts:
I'm trying to authenticate with headless drupal (hybride app running localy on my computer) to a drupal (7.34) website. I installed cors en services en enabled all the necesary endpoints to authenticate en connect to the drupal website.

I managed to get it to work on a previous project. But on this, i get stuck at the connect step (see pictures below). Response for preflight is invalid (redirect). I have absolutly no clue where to look to solve this problem. Can someone point me in the right direction? Couldn't find much information about this error on my good friend google.


texts: Change the url path of /sites/default/files/myfile.pdf

texts: When you click to view a pdf file on a page the url is always this: http://yoursite.com/sites/default/files/myfile.pdf. You can modify this path in the field setting and add tokens, dates. But what if you wants the url to be simple and not give out the fact that this is a Drupal site. Can you change it to be this: http://yoursite.com/files/myfile.pdf. Does this require htaccess url rewrite or Apache redirects?


texts: View nodes in a listing only, not on their own?

texts:
I have created two node-types: 'match' and 'set'. When a 'match' node is viewed it displays a listing of several 'set' nodes. I've acheived this by calling node_load_multiple in hook_node_view. That's all 'set' nodes do: they are listed by a match node. 'Set' nodes can be created, edited and deleted, but I only want the user to be able to view them in listings.

So, I want to deny access to viewing 'set' nodes on their own page at node/1 or whatever. I've denied access to 'set' nodes using the node access mechanism, but then they don't appear in my listing either.

How can I set these nodes so that they can only be viewed in my listing?

The only thing I can think of is not to call node_load_multiple but to write by own db_select query to retrieve all the necessary 'set' nodes to list in a match 'node': a bit messy.

Hope this makes sense. I open to any suggestions. Thanks.


texts: How can an address database be converted to an account profile?

texts:
I imported an address database into Drupal as a content type and I want to convert into an account profile, with users having the ability to make changes it, and use some of the fields in it to link to other content. Are there some modules which can help accomplish that?

At the very least, after creating a Drupal account for each entry of the database, I should be able to link the user account to a particular record of that content type, or import some of the records fields into the profile.


texts: How can you prepopulate a field based on another field's value?

texts:
this one was easy in Drupal 7. I defined a condition "If field A has value B, then field X will automatically get value Y".

How can I get this working for a Drupal 8 webform?


texts: User Revisioning and Workbench moderation modules only on certain content type

texts:
Is it possible to limit the revisioning and Workbench Moderation modules only on certain content types?
On my site there are different content types that can be created but i need the features of these 2 modules to be used only on 1 of these types. Is there some way to do this?


texts: Possible to make admin's flags worth more points?

texts:
I'd like the admin's flagging of a node to carry more clout than with regular users. Is it possible to either;

Insert the count into the mysql database as a number larger than 1
whenever admin flags a node.
Allow flag counts to be additive, ie: Admin can flag a node many
times with each count being added to the total.

Perhaps it can be done using rules and php? If so what would be the procedure in rules?


texts: Send push notifications by limit per user

texts: I have configured multiple rules to send push notifications to multiple users with no limit (because push notifications does not provide any limit how much notifications system send to user). I would like send push notification to particular user with limit of 4 notification for some extent of time. If user get lot more notification he remove app from mobile or frustrate. Anybody have any idea how this can be achieved.


texts: Customize Ubercart checkout page CSS when certain products are in cart?

texts:
On my Drupal 6 / Ubercart 2.9 cart website, I have the need to modify the CSS of the checkout page when a certain product is in the cart. For instance, if the customer is ordering red flowers, the background would change to a red flower background image. Is this possible via CSS? If not, any other ideas on how it can be done?

Thanks!


texts: How can I add a direct link to the edit account settings page in a menu?

texts: Ok, I must be missing something obvious, but I'm having trouble adding a link to user/%/edit to the main menu.  In the Menu UI, I clicked "add link," set the title to "Account settings," and then was at a loss about what to put for the path.  I know how to generate a link to the account edit page using views, which is what I've always done before, but this time I actually need to add the link to the "Main Menu."


texts:
I'm in need of a little help here. I've recently begun my first website (ncpbc.us) and I began with building a Slideshow on my front page. However, the content that feeds into the slideshow uses nodequeue and will hold potentially hundreds of articles. Right now the queue holds 10 articles. The problem I'm having is that the slideshow pager only shows 5 thumbnails at a time and any new content simply makes the oldest content drop off. I'm trying to find a way that allows the user to advance the pager to the next set of 5 thumbnails.

Examples of this are at yahoo.com and http://joomlakave.com/joomla-modules/responsive-news- slider-like-yahoo. How would you suggest I go about this?


texts: Rewriting output of existing content block

texts:
I've added a content block via the administration panel, and placed and themed it - but now I realise I need to add some extra logic to output different things depending on what user is logged in.

What hook would I use to do this, and does using a hook guarantee it will overwrite whatever content has been put in via the Block admin panel?


texts: Drupal nested ajax call not working correctly

texts:
I got this nested ajax call issue,

/**
 * Problems
 * 1). When I click "Add one more" to add more file, I need to click the button
 *     Twice to get one 'Name'/file element available. I click once, no file
 *     field shows. Click again, one file field will show.
 * 2). When one file field shows, as long as I click 'upload' button of the 'managed_file'
 *     field, this file field will disappear immediately. I upload another file, this
 *     file will be fine. Then another uploaded file will disappear.
 * 3). When I click "submit" to submit the form, all previously disappeared file fields
 *     will show. Because, as you see, the submit function only rebuild the form.
 * 4). If container of multiple file fields are not triggered by ajax, i.e,
 *     $form['test']['names_fieldset'] is not triggered by "select" field, then
 *     tihs "Add one more" function works perfectly.
 *
 * So, why this happens with the ajax triggered container:)?
 */
function agl_jira_new_test_form($form, &$form_state) {
  $form['select'] = array(
    '#title' => 'select',
    '#type' => 'select',
    '#options' => drupal_map_assoc(array('man', 'woman')),
    '#required' => TRUE,
    '#default_value' => isset($form_state['values']['select']) ? $form_state['values']['select'] : NULL,
    '#ajax' => array(
      'callback' => 'agl_jira_select_callback',
      'wrapper' => 'names-fieldset-wrapper',
    ),
  );
  $form['test']['names_fieldset'] = array(
    '#markup' => '

',
  );
  if (isset($form_state['values']['select']) && $form_state['values']['select'] == 'man') {
    $form['test']['names_fieldset'] = array(
      '#type' => 'fieldset',
      '#prefix' => '
',
      '#suffix' => '
',
      '#tree' => TRUE,
    );
    $form['test']['names_fieldset']['text'] = array(
      '#title' => t('name'),
      '#type' => 'textfield',
    );
    $form['test']['names_fieldset']['attachment'] = array(
      '#title' => t('File'),
      '#type' => 'fieldset',
      '#prefix' => '
',
      '#suffix' => '
',
    );
    if (!isset($form_state['num_names'])) {
      $form_state['num_names'] = 1;
    }
    for ($i = 0; $i < $form_state['num_names']; $i++) {
      $form['test']['names_fieldset']['attachment']['name'][$i] = array(
        '#type' => 'managed_file',
        '#title' => t('Name'),
      );
    }
    $form['test']['names_fieldset']['add_name'] = array(
      '#type' => 'submit',
      '#value' => t('Add one more'),
      '#limit_validation_errors' => array(),
      '#submit' => array('agl_jira_example_add_more_add_one'),
      '#ajax' => array(
        'callback' => 'agl_jira_example_add_more_callback',
        'wrapper' => 'agl-jira-file-attach-wrapper',
      ),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'submit',
  );
  return $form;
}

function agl_jira_select_callback($form, $form_state) {
  return $form['test']['names_fieldset'];
}

function agl_jira_new_test_form_submit($form, &$form_state) {
  //dsm('form has been submitted!');
  // do something.
  $form_state['rebuild'] = TRUE;
}

function agl_jira_example_add_more_add_one($form, &$form_state) {
 // dsm('submitted');
  $form_state['num_names']++;
  $form_state['rebuild'] = TRUE;
}

function agl_jira_example_add_more_callback($form, $form_state) {
  return $form['test']['names_fieldset']['attachment'];
}

Any help will be appreciated.


texts: How do I enable a features module in the setup of a simpletest testcase

texts:
I'm trying to test some permissions that are related to custom node types and Organic Groups that I've built and packaged as a feature using the features module.

I'm trying to enable the feature (and create all the content types and taxonomies that are part of the feature) in the setUp method of my simpletest test case class like this:

class PermissionsTestCase extends DrupalWebTestCase {
  public function setUp() {
    parent::setUp(array(
      'addressfield',
      'ctools',
      'date',
      'entityreference',
      'features',
      'file',
      'list',
      'node',
      'og',
      'og_field_access',
      'og_ui',
      'options',
      'strongarm',
      'taxonomy',
      'text',
      'my_custom_feature',
    ));
    debug(module_list(TRUE));
    debug(features_get_features());

    // More setup stuff that depends on content types and taxonomies in my feature
    // ...
  }
}

However, when I look at the output of module_list it doesn't include my feature or the dependencies and subsequent setup tasks that rely on a taxonomy that's part of my feature don't find the taxonomy vocabulary.

Can I enable a module created with features in the setUp method? What's the best way to do this?

Do I have to explicitly specify the dependencies of my feature in the call to parent::setUp?  What about the dependencies of my dependencies? Does the order matter?


texts: How can I get a list of content types with drush?

texts:
How can I get the existing content type list with drush? This will allow me to quickly produce a list.

I've tried with:

$ drush @d6 @sites genc --types

But I need the devel_generates module enabled for this.

  Command genc needs the following module(s) enabled to run: devel_generate.


texts:
I need to do some advanced analytics for my site. I need the basics Google Analytics stats (nb visits, bouncing rate, etc) and how many times each particular users came back in a specific period of time.

For example, I need to answer these specific questions:

How many users came back more that 2 times during the last week?
How many users added two nodes or more in the last month?
Graphs showing users repartition between fans, average users, first time users, etc

Is there any module implementing that kind of funneling in Drupal? Ideally, it should interface with Google Analytics (with Google Analytics events tracker) and/or Mixpanel.

Any thoughts or ideas?


texts: I have an inherited website that uses panels, and the menu is not coming out on certain pages . how can I find out and fix it so that the menu comes out on all of the pages.


texts: Display nested relationships on a single view

texts:
Context

I have three custom node types (Batch, Item, Order) that I use to track orders (I don't need the power of full-blown Commerce). These are linked through the following entity reference fields:

Batch->Item through field_items on Batch

Order->Item through field_items on Order

I have a table view set up which shows Items by Batch.

The Question

Is there a way I can display, on the same view, the Order name (if any) that each Item is allocated to?


texts: How to link one given Image field to a specific view?

texts:
I would like to link an Image field to a specific view (created with Views) in a given view mode, under "Manage fields" tab, making this opportunity available only within a given content type and only one specific field.

I could also "hack" it into a given theme_image_... function, but I think it would be nicer to make it easily modifiable via the admin interface like this:

Maybe this could easily be done with a given or a custom module, but I don't know what would be a nice solution to this.


texts: How do I get the taxonomy term name of the current taxonomy term page.tpl.php?

texts:
Im on d7. Im trying to get the taxonomy term name of the the taxonomy page that I am on. Since Im not on a "node" page, I can't get it by the $node->tid. What should I do?
Thanks.


texts: Extra menu_block showing on one page only

texts:
I have a single page that is rendering an additional menu_block that repeats my sub-navigation link (which are displayed in a side column). I have a Primary Link in the main navigation that has two sub pages: Teacher Resources and Instructional Materials. Teacher Resources works as expected (menu_block output is empty), but when Instructional Materials is selected, it outputs AN ADDITIONAL menu_block duplicating the sub-navigation links.

These two pages use taxonomy terms, which I'm not too familiar with. I've compared each of these pages in the various menu and taxonomy settings, and the configurations look to be the same. Any Suggestions as to where to look next?

I'm using Drupal 6.16 and a theme based on Zen 6.x-1.1.


texts: How to use set() on a field within a field collection?

texts:
I have a custom entity type, and I'm defining its form, which extends ContentEntityForm. During my save() function, I want the form to conditionally unset fields based on the values of other fields. (example: unset the value of a list select field if a certain checkbox is checked off)

I can't seem to accomplish this with $form_state->setValue() or $form_state->setValueForElement(), in both cases my code is seemingly ignored and the select widget is not unset upon finishing saving (although a var_dump of $form_state->getValues() at the end of the function shows that the values array is indeed being modified the way I want it to be).

However, the following code seems to work nicely for the title field (defined via baseFieldDefinitions(), is not inside a field collection):

$entity = $this->getEntity();
    $entity->set('title', array(array("value" => "aaaaaaaa")));
$entity->save();

My title for the newly saved entity does indeed show up as "aaaaaaaa"

Is it possible to target fields inside field collections in this way using this $entity object? Or is this the totally wrong approach?


texts: How to add meta tag to a hook_menu page which return json output?

texts:
I have a custom page which I have created using hook_menu

$items['list'] = array(
    'page callback' => 'page_callback',
    'type' => MENU_CALLBACK,
    'access arguments' => array('access content'),
);

I want to add the meta tag to head section of this page to prevent it from indexing. I have tried the following code.

function page_callback() {
  $arr = array('test1', 'test2');

  $element = array(
    '#tag' => 'meta',
    '#attributes' => array(
      'name' => 'robots',
      'content' => 'noindex',
    ),
  );
  drupal_add_html_head($element, 'test');

  // Return the list in json format.
  drupal_json_output($arr);
}

But when I inspect the page, I can't see anything in the head section of page.

When I try to return some string instead of the json, I can see that meta tag.

function page_callback() {
      $arr = array('test1', 'test2');

      $element = array(
        '#tag' => 'meta',
        '#attributes' => array(
          'name' => 'robots',
          'content' => 'noindex',
        ),
      );
      drupal_add_html_head($element, 'test');

      // Return the list in json format.
      return 'something';
    }

How can I add it to the page which outputs json?


texts: How to add custom Filter and Sort plugin that operates after the Query is executed?

texts:
I have added my own custom (purely virtual - non-existing in DB) field to my View. Let's call it Hotel Count (it just prints some integer value based upon other
fields). This Field is implemented by View Plugin Handler (my custom class that
extends views_handler_field) - This works just fine.

The problem appears when I try to Filter by this custom Field or Sort by it...
It seems that Filter and Sort By handlers only operates on Query and fields that actually exist in DB...

How can I Filter by this custom Field and use Sort By on it after the Query is executed ?

Or maybe there is some way for the Filter and/or Sort By handlers to access
my customly added field ?

Please help!


texts: how to just print the value of author in node template

texts:
There are some variables like author_name in node.html.twig of Drupal 8. {{ author_name }} will print something like below:

Basic

I tried using codes like below:

{{ author_name.0 }} plan to print: Basic

or

{{ author_name|field_value }} plan to print: Basic

Above codes NOT work. How can I achieve above result?


texts:
I'd like to display only 1 comment (the most recent one) in node page.
And I don't want the pager to be displayed too.

Is there any way to do it without writing custom module?

Could I use mytheme_preprocess_page($variables){} for that?

Thanks in advance.


texts: LDAP Role Mapping - Working, but not Assigning

texts:
I have setup the ldap module for Drupal 7 - everything is working as it should, apart from when a user logs into the site the role defined for that person isn't been assigned to their profile, they remain just an authenticated user.

When I run a test on their username it shows that the user should be part of the correct role.

In the error log I can see it is failing when granting a single authorisation with the following error:

LdapAuthorizationConsumerDrupalRole.grantSingleAuthorization() failed to grant xxx the role Delegate because role does not exist

However the Delegate role is setup and present.

Has anyone else come across this problem?

--

Just to note that I found the solution - don't use capitals in your roles.  Changing Delegate to delegate fixed it.  I will put this as the answer when my 8 hour self answer delay lapses.


texts:
I'm creating a menu programatically using this code
$this->menu = $this->entityTypeManager->getStorage('menu')->create(
    [
      'id' => $properties['id'],
      'label' => $properties['label'],
      'langcode' => $properties['language'],
      'status' => TRUE,
    ]
  );
  // Save the menu.
  $this->menu->save();

When visiting the block ui I see the block is already created. It appears that I do not have responsibility for creating this block, although I don't seem to be able to load the block straight after creation of the menu. I need to place this block in a specific region programatically. What would be the preferred method of doing this be?


texts:
I'm looking for a way to alter the variables before a rule is executed. Specifically, I'm trying to add a list of users who should be notified of a new comment so that I can create a loop and send an email to each.

I have implemented hook_rules_event_info_alter as follows:

function mymodule_rules_event_info_alter(&$events)
{
    $events['comment_insert']['variables']['affected_users'] = array('type' => 'list<user>', 'label' => 'Anyone that should be notified about a new comment.');
}

However, I am at a loss as to which hook needs to be implemented in order to fill in this variable before it is used. (On my site the default will be the node author, however there are some nodes where several users should be notified).


texts: How can I create the views pager on top and bottom of the view?

texts:
I need two view pagers / pagination to sandwich the view content or view results.

Is it possible to duplicate view pagers/pagination ?

What i've done is just printed out the pagers in the template twice; however, that requires me to hardcode the pager.

I need a little more flexibility because I'm required to build / place the top pager in different spots on different pages.

Could this be accomplished with views display (suite) somehow and a code field? I've attempted one and had no luck.


texts: form_alter hook in a ctools content-type plugin not called

texts:
I'm writing a ctools content-type plugin to use it as a panels pane. In my plugin code I try to use the form_alter hook at render for the login_form (not for the edit forms). But the hook seems not to be called. It makes no difference if I use the generic form_alter hook or the particular with the form-id in the function name. Both work neither.

/**
 * Modify the User Login form
 */
function justloginpane_content_type_form_user_login_alter(&$form, &$form_state, $form_id) {

  drupal_set_message("Form ID is : " . $form_id);

  $form['description'] = array(
    '#type' => 'item',
    '#title' => t('A form with a fieldset'),
  );

    // Enable AJAX
    $form['actions']['submit']['#ajax'] = array(
                                  'callback' => 'ajax_example_submit_driven_callback',
                                  'wrapper' => 'box',
                              );
    $form['actions']['submit']['#value'] = 'TESTSUBMITTEXT';

}

I thought it worked once, but I'm not really sure.


texts: Views Select Photos from the album to flag for printing

texts:
I have created a Content Type Album and added an image field with the value unlimited.

Created a view page which displays all the images added to a node.

Now I want that the user can select / flag the pictures from the album to print. Keep in mind that I am using pager so the results are divided into several pages.

Admin can get the list of the photos which the user has flagged to print.

Please suggest how this can be achieved.


texts: How to get search results sorted by language in solr?

texts:
We have used Apache solr multilingual module for language specific search.
But we want the other language results to be shown below the current language search result.
How we can achieve it using solr?

Is there any module needed or any custom coding require?

Below is the example for displaying search results :-

  If I am currently using site in german and searched for any content
  then german results needs to be appear first and then other language
  content.


texts: How to programmatically change the weight of children in a taxonomy vocabulary?

texts: I am trying to edit an existing vocabulary to change the weight of the children. Any idea?


texts: Userpoints Karma - Is it possible to only charge user points for down votes?

texts:
I'm using the User Points, User Karma, Vote Up/Down modules. I wonder if there is a way you can configure it to only deduct user points when you vote something down and not up.

Similar to Stack Exchange's reputation system: if you vote something up, you don't get docked, but if you vote something down you get docked reputation points.

Using the Reputation User Points -> Karma Points -> Voter Points Cost setting, I am only able to configure it to charge if you vote at all, regardless of the direction of the vote. Any ideas?


texts: Need "carat" for currently active Superfish menu item

texts:
I have a Drupal 7 Superfish menu (from the Superfish module) that I would like to add a "carat" to for the currently active menu item.

Here is my current menu:

But I would like a menu where the currently active menu item has a "carat" instead.
Here is what I would like: (altered in photoshop to give carat)

I'm looking for the easiest way to do this in Drupal 7.
Any ideas?


texts:
On admin/config/system/site-information, one can specify "Error pages" for 403 (No access) and 404 (Page not found).

It would make a lot of sense to specify different pages here, depending if you are logged in or not.

Currently my idea is to show my custom login + registration page for anonymous users, but something else (not sure yet) for logged-in users.

Is there any solution for this in contrib?


texts: Alter render (array) of a field in a View?

texts:
How do I alter the rendering of a field in a View?
Where can I access the render array before the html is generated for output?

For example, if I have an image field included in my view, where can I add to the attributes of the image before the image is rendered using theme_image?  Assuming that the field is eventually still rendered using theme_image.

I want to add attributes to the image tag and NOT the surrounding divs that Views inserts into the markup.

EDIT based on answer by Jimajamma:

Editing the $view->result as suggested is causing the View to crash.  Page doesn't render correctly anymore:

function MYMODULE_views_pre_render(&$view) {
   if ($view->name=='viewyouarelookingfor') {
      foreach($view->result as $row) {
         $row['field_body'][0]['rendered']['#markupe'] = '
Test!
'; // causes View to crash
      }
   }
 }


texts: How can you show taxonomy child terms on the parent term page?

texts:
I am trying to figure out if there is a way to modify the default taxonomy view so it shows nodes tagged with that particular term (already done) plus all children of the taxonomy term you are viewing.

I have seen solutions for D7 but nothing for D8.


texts: How to make breadcumbs grab taxonomy terms and use tokens

texts:
I have tried about 4 different breadcrumb modules now and none of them seem to do what I want. I want them to act in a similar way to Pathauto whereby I can mix and match tokens. There seems not to be a way to do this, for some reason or another. Example, I have a school that belongs to a country name and city name. City and country are part of a taxonomy, so:

/united-states/los-angeles/school-name

I want this to be:

Home > Destinations > Parent Term > Child term > Node title

I even might want to add my own text for one of these breadcrumbs.


texts: Why are JavaScript files read from an external URL?

texts:
Drupal adds the following markup to pages.

<html class="js" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:og="http://ogp.me/ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:dc="http://purl.org/dc/terms/" xmlns:content="http://purl.org/rss/1.0/modules/content/" dir="rtl" version="XHTML+RDFa 1.0" xml:lang="fa" xmlns="http://www.w3.org/1999/xhtml">

I need to remove it and force my site not to read from an external URL.

How can I achieve this? Is it really bad, or doesn't it need to be changed?


texts:
I have tow custom fields field_city and field_priority for a user profile.
Now I want to fetch the priority for a city like chicago. ( all I want is max priority for a city but first trying to fetch all )

I am trying with following queries but they are not giving me any result, I am getting a blank array. it works when I remove WHERE clause but not with WHERE for a city.

$query = "SELECT p.field_priority_value, p.entity_id, b.field_city_value FROM field_data_field_priority p LEFT JOIN field_data_field_city b on p.entity_id = b.entity_id WHERE b.field_city_value='chicago'";
    $result = db_query($query);
    $res = $result->fetchAll();

Tried following code with drupal query function.

$query = db_select('field_data_field_priority', 'p');
    $query->join('field_data_field_city', 'd', 'p.entity_id = d.entity_id');
    $query->fields('p');
    $query->condition('d.field_city_value','chicago','=');
    $result = $query->execute();
    $res = $result->fetchAll();


texts: how to give the same style as the back-office theme for people allowed on edition?

texts:
Allowing some roles to edit content, these people get the css from the front theme.

How to set to use the back-office theme for ?

 /admin/content

and

 /node/add/article


texts: How to export cck field list from Drupal 6 to CSV files for import in Drupal 7?

texts:
I am migrating a D6 site to D7 using migrate_d2d_ui but find that the cck fields for my various content types are not automatically migrated.

I would like to build a csv file containing the D6 cck field structure (name, type, length, #values, help text, etc) so that a csv file can be built for each content type and imported into D7, perhaps using feeds, to build out the full D7 content type and field structure.  Hopefully, migrate_d2d-ui can be mapped to bring over the content once the full D7 structure is built out.

I have investigated Features, Views Data Export, Feeds, Content Copy, and Bundle Copy, but have not found a combination that works with both D6 and D7 platforms.

Any suggestions for creating and importing this csv file or do I need to manually recreate each field in D7?

Thanks.


texts: Webform token for select field value (not key)

texts:
I have a webform select field called tour and I have set up an email to go out, using the default template:

Submitted on [submission:date:long]
Submitted by user: [submission:user]
Submitted values are:
[submission:values]

The results of this submission may be viewed at:
[submission:url]

When the email goes out, it sends the key (nid):

Tour: 8349

rather than the value of the option:

Tour: 10-Jan-16 - Awesome Tour

I have tried the following tokens:

[submission:values:tour:label]
[submission:values:tour:value]
[submission:values:tour:withLabel]

I am looking for the proper token to output the value in the key/value pair of a select field.

For the tour field, I am replacing the options via a hook. I only mention this step for completeness sake as I don't think it has any impact on my issue.

function MODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'FORM_ID') {

    // get all tours
    $query = db_select('node', 'n');
    $query->fields('n', array('nid', 'title'));
    $query->condition('n.type', 'tour');
    $query->join('field_data_field_tour_type', 't', 't.entity_id = n.nid');
    $query->fields('t', array('field_tour_type_value'));
    $result = $query->execute();

    // group by tour type
    $options = array();
    while ($row = $result->fetchObject()) {

      // tour type 1
      if ($row->field_tour_type_value == 1) {
        $options['Type 1'][$row->nid] = date('d-M-y', strtotime($row->field_event_date_value)) . ': ' . $row->title;
      }

      // tour type 2
      else if ($row->field_tour_type_value == 2) {
        $options['Type 2'][$row->nid] = date('d-M-y', strtotime($row->field_event_date_value)) . ': ' . $row->title;
      }
    }

    ksort($options);

    // set the tour options correctly
    $form['submitted']['tour']['#options'] = $options;
  }
}


texts:
I have the facebook like box in a block position and i want to make this block popup for first time visitors only. The popup will open only if the user visits the website for first time and will open once for every visitor.

Is it possible to implement this feature with existing modules? I am not a programmer.

Thank you


texts: Creat new menu items link in menu like create new Content Type does

texts:
When create a new Content Type, several new menu links will created and show in the management menu, such as node/add/article and admin/structure/types/manage/article.

Add content
    -- Article
    -- Page

How can I implement similar functionality within my custom module?

Sites
  -- Site Name A  (link to site/1)
  -- Site Name B  (link to site/2)

My hook_menu() implements code:

$items['site/%'] = array(
  // ...
  'page callback' => 'mymodule_site_view',
  // ...
);

I have tried to use _load() and _to_arg(), but doesn't work or maybe I just not use them correctly.

function mymodule_menu() {
    $items['site/%mymodule_site'] = array(
        // ...
        'page callback' => 'mymodule_site_view',
        // ...
    );
}

function mymodule_site_load($sid) {
    // load site object from database
    $site = ...
    return $site;
}

function mymodule_site_to_arg($site) {
    // I guess here I can use site object, but just get %
    return $site->name;
}

Can anybody give me on example?

I know I can create/delete menu links when create/delete my site object manually. I just want to know if I can user _load(), _to_arg() or others to implement it.


texts: How to delete a content type field without deleting the whole view?

texts:
I was trying to delete a field from a content type . But it's deleting all the views which have that field in it.

I have some pages inside that view. I even checked in all the pages that this field is present , but not found.

Any idea to delete a field without deleting the whole view ??


texts: Proper approach to two different address data sets on the system

texts:
I have a certain design problem here. The web site I'm working on will need to have 2 sets of address details

under user account, as an indication of user's business address
at the commerce checkout, as billing address

For commerce checkout I've been using built-in customer billing profile and it works ok. But I'd like to maintain a similar format for user address. The plan is to populate the billing address form during checkout with user's business address by deafult but also allow to modify billing address without changing business one

At the moment I'm concerned that I'm mixing different structures too much. I have billing profile for commerce, profile2 for users but also couple of custom fields created under Account Settings. What approach would you suggest to setup the user account fields so it's clean, easily referrable to each other and not confusing?


texts: Event Response not firing anonymous user

texts:
I have a module in drupal8 which only job is on an event response is to redirect a URL. It works fine for everyone except anonymous users. How do I give the module privileges to fire on every user no matter if the are logged in or not.

This is the geographic_me_redirect.services.yml

services:
  me_redirect.process_me_request:
    class: Drupal\me_redirect\EventSubscriber\ResponseSubscriber
    arguments: []
    tags:
      - { name: event_subscriber }

This is the response

class ResponseSubscriber implements EventSubscriberInterface
{

    /**
     * Constructor.
     */
    public function __construct()
    {

    }

    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents()
    {

        ///$events[KernelEvents::REQUEST][] = ['onRouteMatch', 27];
        //-- fires the event in the kernal early oo page load 20
        $events[KernelEvents::RESPONSE] = ['process_language_request',0];
        //-- For redirecting to another domain

        return $events;
    }

    public function process_language_request(FilterResponseEvent $event)
    {

    return my logic

    }
}


texts:
I would like users on my site to write "feedback" of other users.

My thought is to have a content type called Feedback, and create a view of it, to preview at the foot of the user page. I can also put the main display of comments on its own views page.

Well, that's the display of them covered, but how do I enable them to be written? ie, link from the profile to create Feedback, and have it relate to that profile.

Also, Profile2 looks lacking, because you cannot control URL output.


texts: Stuck. Installing Drush via Composer not working

texts:
It looks like I installed Drush, following the directions in the documentation.

Here's what I did.

Jens-MacBook-Air:~ jensimmons$ composer --version
Composer version 1.0.0-alpha8 2014-01-06 18:39:59
Jens-MacBook-Air:~ jensimmons$ composer global require drush/drush:dev-master
Changed current directory to /Users/jensimmons/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing pear/console_table (1.1.5)
    Downloading: 100%

  - Installing symfony/yaml (v2.2.1)
    Downloading: 100%

  - Installing d11wtq/boris (v1.0.8)
    Downloading: 100%

  - Installing drush/drush (dev-master a2c7030)
    Cloning a2c703071e2c3374e1b3855e24d29468b9069b5c

pear/console_table suggests installing pear/Console_Color (>=0.0.4)
d11wtq/boris suggests installing ext-pcntl (*)
Writing lock file
Generating autoload files
Jens-MacBook-Air:~ jensimmons$ drush help
-bash: drush: command not found

When I change directories, to inside a Drupal installation, I get the same result. drush: command not found.

What am I missing??


texts:
im just new on drupal, i noticed that some posts in my content of my website are submitted by anynomus ( not verified ) user , it came with no type or author .
is it hacked ?? or how can i stop these posts on my website.
the role at my website required to be verified   before publishing BUT these posts came published already

plz help here is a screenshot with the black rectangle arround the posts which i mean.


texts:
I am using FAQ Ask along with the FAQ module. Everything works well but the emails are coming all bunched up. I need to be able to re-arrange the layout as I want (simple text with active links).

Below is what I see:


texts: Redirect to page after Simple News subscription

texts:
I wish to redirect the user to a specific page once they have inputted their email and pressed subscribe. Does anyone know how to achieve this please?

I have found the setting to achieve this but upon deeper digging it is not working. An issue has been opened here -> https://www.drupal.org/project/simplenews/issues/2822420


texts: Dropping options of exposed filters breaks when user is logged

texts:
I have a weird problem with Views exposed filters.

When I click on some exposed filters the dropping options are appearing, but when I hover with the mouse, dropping options are immediately dissapearing without letting me choose any of them. This problem only occurs when user is logged, no matter what role is using.
I've disabled the administration module, but the problem still remains.

Using exposed filter as a block doesn't have this problem and anonymous users too.

The same problem I've experienced in my other website too.


texts: Leaflet - Possible to go straight to node instead of popup on click?

texts: I'm using the leaflet module in drupal and would like the user to go directly to the node instead of a popup when clicking upon a marker or polygon. Is there a way to do this?


texts: Select list field type as sorting order criteria

texts:
I have a view which uses a custom field called article type as it's sorting criteria to sort articles. This article type field, has the following options:

0Editorials|Editorial
2Feature|Feature
5Spotlight|Spotlight
6Special|Portraits
3Perspective|Perspective
8Research in Translation|Research in Translation
7Columns|Column
4Interviews|Interview
1PhotoEssay|Photo Essay
0Introduction|Special

The reason I have a number preceding the text in every option is so that, when I use this field as a sort criteria and choose the order as ascending, Views actually looks for the key text and arranges the results in that order (0 to 8 in this case).

Now, I want to achieve this same order without having to tamper with the key|value pairs like I have done. I have heard of Draggable Views, but I'm not sure that solves the issue here, since this view takes a contextual filter value and the results are always dynamic based on the filter value that is passed to it from the URL.

So is there another way to use a select list's options as a sorting criteria, but in an order that we want it to be in?


texts: Is there a way to supress particular messages or a class of messages on the screen?

texts:
Is there a way of suppressing a particular class of messages from being displayed on the screen, such as the one displayed below?

  Deprecated function: Methods with the same name as their class will
  not be constructors in a future version of PHP; GeSHi has a deprecated
  constructor in require_once() (line 837 of
  {site_root}/sites/all/modules/libraries/libraries.module)

It comes up all the time and it belongs  to the php and severity debug class of error messages.

I don't want to turn off the display of messages on the screen, just a particular class of message which come so often they are a nuisance.

It is possible to toggle their display on and off when required but still log them to the database?


texts: Is there any incompatibility with PHP 7?

texts:
How well does Drupal 7.56 run on PHP 7?

I've done some testing locally using Drupal 7.52 PHP 7.0.10 and haven't noticed problems. The system requirements page on Drupal.org says it works, but there is also a long discussion about a patch.


texts: How to invalidate a views cache based on custom criteria?

texts:
I have a custom content type (story) with a datetime field which determines if a story shows up in a the views that list the nodes of that content type; if the datetime defined for a node is newer than the current datetime, it will not show up.

My problem is that I have to go and empty admin/config/development/performance and click Clear all caches or uncheck Cache pages for anonymous users.

I would like to keep caching pages for anonymous users, so I am looking for other options.

Any help is much appreciated.


texts: Drupal 7 - Call the default/base template implementation

texts:
I am overriding node.tpl.php for a specific node (node--news.tpl.php) to display it differently in the front page. Instead of copying node.tpl.php code into node-news.tpl.php to display the node with the default rendering when we are not on the front page, I would rather prefer calling the base template implementation (node.tpl.php).

if ($is_front)
  // ...
else
  base_template(/* ... */);

Is that possible ?

Thanks,

Solution :

function template_preprocess_node(&$variables)
{
  if (drupal_is_front_page() && $variables['node']->type == 'news')
    $variables['theme_hook_suggestions'][] = 'node__news__front';
}

Then, simply edit the template file node--news--front.tpl.php


texts: Why should I not put content in the development environment?

texts:
I've previously been told that I should not put content on Pantheon in the development environment.

The reason was not explained.

Can anyone think of any reason that this should be advised?

I can see that pulling/pushing a lot of content form the /files directory could be and issue but is there any other reason that anyone can think of?


texts: How can I bypass the login screen during checkout in Commerce 2?

texts:
I'm building a site where I want to allow guests to purchase without creating a user account. This appears to be default behaviour in Commerce 2.1 (the message stating that the user can create an account at the end of checkout is currently not implemented although I know work is being done on that in this issue https://www.drupal.org/node/2857157).

However, I also don't want to offer guests the option to log in, which is what currently happens.

So, I want to simply bypass the Login page and go straight to the checkout page.


texts:
I can't insert a block into an article on Drupal 8.

I installed the module, created a custom block, created an article using the Full HTML input format, inserted [block:block=1] into the article body, and saved it.
Nothing happened. [block:block=1] appears in the text instead of the desired block. I tried to find something in admin/config/content/formats/manage/full_html to make Drupal recognize the inserted blocks, but I found nothing.

Am I doing something wrong?


texts: HTML being removed when rewriting field in Views

texts:
I have completely stripped all my views/blocks down so they only produce exactly what I put into them..but I created a view and rewrote the fields and this part of my code will not print exactly as it is here:

Instead, when the block is rendered I get:

So it strips away come of my code. Does anyone know how I can get round this problem?


texts: So I am using the Meta tags module and really would love if search would index the meta tag keywords of nodes. How would I go about this?


texts: Anonymous sessions breaking login for Drupal 7

texts:
This is my first official post so bare with me if i do not have all the information you may need.

Being a beginner of Drupal from a PHP background I am struggling with SESSIONS.

First, there are conflicting information I am reading on how one should set sessions, some say it we should use a unique key, like so:
$_SESSION["uniquekey"] = array();
$_SESSION["uniquekey"]["variable"] = 1;

Others say this is sufficient:

$_SESSION["variable"] = 1;

Secondly, I have managed to set Anonymous sessions without problems, this sets the UID to 0 in the sessions table, the problem I am experiencing is when I login.

Login is succeeding but I am getting "you have no authentication etc" and therefore unable to access the CMS.  FYI in the session table, it has inserted another session with UID set as 1.  I am having to destroy the anonymous session to access the whole CMS but from what I understand the login form should regenerate?

I am setting the sessions in template.php and logging in user /user

Would appreciate if some people can share some light on how one can set sessions without breaking the login?

Your help would be much appreciated

Cheers


texts:
I'm trying to return the results of a db_query as a raw text file. The php solution uses header() to instruct browsers to download content. I've attempted using header() in an AJAX callback function, but the following error code is always returned:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /system/ajax
StatusText: OK
ResponseText: this is just a test

I'm looking for a way to save a php string value to a file client-side, ideally without requiring the file to first be saved on the server. Alternatively, if I could pass a value from an AJAX callback directly to javascript for post-processing, that would work too (haven't found an AJAX callback with this capability).

Here's my test code (that produces the above error):

<?php

function test_download_form($form, &$form_state) {

  $form['form_wrapper'] = array(
    '#prefix' => '
',
    '#suffix' => '
',
  );

  $form['form_wrapper']['download_submit'] = array(
    '#type' => 'button',
    '#value' => 'test download',
    '#id' => 'download_submit',
    '#ajax' => array(
      'callback' => 'test_download',
    ),
  );

  return $form;
}

function test_download($form, $form_state) {
  $dateFile = rand(10000000, 99999999)."_test.txt";
  $dataString = "this is just a test";

  //header() and drupal_add_http_header() behave the same
  header('Content-Type: application/text');
  header('Content-Disposition: attachment; filename="'.$dateFile.'"');
/*
  drupal_add_http_header('Content-Type', 'application/text; utf-8');
  drupal_add_http_header('Content-Disposition', 'attachment; filename="'.$dateFile.'"');
  drupal_send_headers();
*/
  echo $dataString;
  exit;
}


texts: Easiest way to get term entities from a term reference field?

texts:
I always end up with lots of juggling to get seemingly simple things, like "All term names".

$field_terms = field_get_items($entity_type, $entity, $tags_field);

if ($field_terms) {
  $tids = array();
  foreach ($field_terms as $field_term) {
    $tids[] = $field_term['tid'];
  }
  $terms = taxonomy_term_load_multiple($tids);

  $tags = '';
  foreach ($terms as $term) {
    $tags .= $term->name . ',';
  }
  $tags = rtrim($tags, ',');
}

Can anyone share any neat tricks for making the above easier?

The part that really annoys me is the first loop, that I need just to untangle the field api array.


texts: Easiest way to add popup dialog with snippet of html/text using a wysiwyg editor?

texts:
My client isn't too technical and cannot code, but she wants a popup dialog when the user clicks on a link to show a snippet of html or text.

What solutions are there for the end user to be able to add and edit text popups like this using only a wysiwyg editor without having to code in stuff?


texts: How do I add managed images to the Media Module browser stored locally through a remote URL?

texts: This question has been asked lots of other places and I was quite determined to make it happen. The use case is copy and paste a URL for an image on the web into the Media Module file browser. The Remote Stream Wrapper module does something similar except the images are not stored on the local server. Instead the metadata about the image is stored in the database while Image Cache stores images locally. I really wanted to import images I have access to onto my server.


texts: Restricting Field List Entries Based on User Role in Drupal 7

texts:
I'm using the Field permissions module in Drupal 7 to restrict access to a list field I created based on the user's role and that works great.  But is there a way to restrict the content of that list based on the user role?

For example:

for user role 1, I want the custom field list to show:

Apple
Banana
Grape
Orange

for user role 2, I want the custom field list to show:

Apple
Grape


texts: Rendering renderable arrays in an item_list

texts:
I'm struggling to get a render-array constructed, and I think it's because of how theme_item_list works. I would be grateful if anyone could help find the problem (or tell me to implement it without item_list!)

  The context: This function is called from my module's
  hook_block_view() to render the content of the block. The module is
  an example module showing how to use a new API. I hope nothing of that
  is needed to answer this point, except that these calls are not made
  from a theme.

The code I have is:

function example_render() {
  $block = array();

/* fill $providers[] ... */

  $items = array();
  foreach ($providers as $metric => $provider) {
    $value = $provider['value'];
    $class_link = $provider['name'];
    $name_link = $provider['name'];

    // Construct a renderable array wrapper for the template invocation.
    $items[$metric] = array(
      '#type' => 'container',
      '#attributes' => array('class' => array('provider')),
      'info' => array(
        'providername' => array(
          '#prefix' => '',
          '#markup' => $name_link,
          '#suffix' => '',
        ),
        'providervalue' => array(
          '#prefix' => '',
          '#markup' => $value,
          '#suffix' => '',
        ),
        'metricname' => array(
          '#prefix' => '',
          '#markup' => $class_link,
          '#suffix' => '',
        ),
      ),
    );
  }

  // Finally, bring it all together.. a container with the via text then a list
  // of the providers.
  $block['content'] = array(
    '#type' => 'container',
    '#attributes' => array('class' => array('example')),
    'ttl_text' => array(
      '#prefix' => '
',
      '#markup' => $record['title'],
      '#suffix' => '
',
    ),
    'via_text' => array(
      '#prefix' => '',
      '#markup' => $via_text,
      '#suffix' => '',
    ),
    'metrics' => array(
      '#items' => $items,
      '#theme' => 'item_list',
      '#attributes' => array(
        'class' => 'providers-list',
      ),
    ),
  );
  return $block;
}

and this is what I get when run with 9 items in the list:

A bacterial sulfonolipid triggers multicellular development in the closest living relatives of animals
via Lagotto article information courtesy of Lagotto

not very inspiring!

The three 'Array' under 'info' in the html here obviously correspond to the providername/providervalue/metricname arrays in the code i.e. the $items array isn't being interpreted as a render array at all.

How can I make this work?


texts:
Apologies if this has been asked before, but I'm on my first week working with drupal and twig.
I have the following code:
{%
  set container_classes = [
    'paragraph',
    'paragraph--type--' ~ paragraph.bundle|clean_class,
    view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
    not paragraph.isPublished() ? 'paragraph--unpublished',
    'container'
  ]
%}
{% set image_classes = [
  'col-12'
]
%}
{% block paragraph %}

  {% block content %}

          {{ content.field_two_column_image }}

          {{ content.field_two_column_copy }}

  {% endblock %}

{% endblock paragraph %}

My issue is the nested attributes.addClass. When I look at the HTML, I'm also seeing the container_classes classes, which is not what I'm looking for.
So how can I separate the two?


texts:
I wonder which files are being considered to go through hook_file_download. When this function is triggered, what are conditions ?

(Generally, how I can track myself hooks conditions ?)

I am trying to put some custom created download links (files are not uploaded via drupal, but link to them are defined manually, as described in this issue.)

EDIT: For those searching for hook_file_download related issue, it seems that it is triggered (also) whenever you try to access a valid link to a file in private filesystem.


texts: Using an authentication provider to keep a user permanently logged in eventually causes session problems

texts:
Because I got fed up of having to log in to my local development sites every however long, I tried making a simple custom module that just has an Authentication Provider service that always returns user 1, like this:
  /**
   * {@inheritdoc}
   */
  public function applies(Request $request) {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function authenticate(Request $request) {
    return $this->entityTypeManager->getStorage('user')->load(1);
  }

The idea being that with this module enabled, every page load considers the authenticated user to be user 1. In theory, I'd be logged in for ever!
However, after a few weeks of this working fine, all my form submissions broke! Every form submission fails with:

The form has become outdated. Press the back button, copy any unsaved work in the form, and then reload the page

This turns out to be because CsrfTokenGenerator::validate() fails. Specifically, the $seed in this bit is just NULL:
  public function validate($token, $value = '') {
    $seed = $this->sessionMetadata->getCsrfTokenSeed();
    if (empty($seed)) {
      return FALSE;
    }

I presume it's because the session has expired in some way? The time this has taken to stop working is roughly the amount of time it would have taken the site to log me out automatically.
How can I fix this?


texts: Variable containing HTML is not rendering when sent by message notify

texts:
I am trying to send e-mails with message notify and rules, everything is running pretty well, but there's one variable which contains a "HTML code", It describes a table of items that were bought for someone.
I NEED to pass it as a HTML table, but it renders like these on the users E-mail Inbox:

Peep Toe Colorido (34, Marrom) (415-01612--11163-11184)
1
10990

Sandália Clássica (34, Nude) (577-02357--11163-11186)
2
19980

and the tags which were entered in the message type  and  are rendered right, showing not the markup tags but the table itself.

How can i make the HTML generated by a variable render properly when sent by message notify?


texts: How to require one of two fields to be filled out?

texts:
Let's say i have two fields in a content type. An integer field and a text field (two options with select list widget) and i want the user to fill out one of the two.
Can someone help me achieve this ?

Thanks