texts: Is there a core method in views that can pad numbers with leading zeros?

texts:
Setup
I am building a view that outputs human usable id's. These ids would look best if padded to 3 characters. For example the episodes of a tv show may look best if they are formated:
01-01 (Season 1 episode 1)
10-05 (Season 10 Episode 5)
03-22 (Season 03 Episode 22)
Problem
In my node I'm storing a simple integer (1-100). I want to keep the value as an integer not a string. How do I pad the integer with leading zeros on output.
Using simple php would be a simple str_pad($value, 2, '0', STR_PAD_LEFT); but I do not want to execute php in my views or even enable the php module/filter.
Solution
The solution must:

Use a core ability of views
Not require me to execute php stored in the database (not enable php module or anything equivalent)
Must allow me to maintain the field as an integer input/storage

I could probably write the views plugin for this but I was hoping their was already something available like a views integer format or something like that.


texts: How to import content for content types with user-defined fields

texts:
I've got a large amount of data I would like to turn into pages in Drupal. Most of the data to import correspond to custom fields I created in a new content type (let's call it directory).

For example, I have things like zip code, address, state, etc. that I would like to import as directory content.

I've been working with the feeds module, but so far I haven't been able to figure out if it can map to custom fields in a content type (I'm beginning to suspect that it cannot).

I'm using Drupal 7


texts: Views: How can I show a list of users who have a taxonomy term attached via a term reference field?

texts:
I'm using the views module's built-in "Taxonomy term" view which overrides the way Drupal displays taxonomy by default and makes it accessible to views.  However, this only works for content, not users.

I tried creating a new view that lists users but there is no contextual filter like "User: has taxonomy term", just "Content: has taxonomy term."  In my case, however, some of the fields I want to display are term references stored on the user profile; they don't exist on any content.

Ideally, this is what I want: if a user visits the page taxonomy/term/oranges, it will show all users who have "oranges" in a taxonomy reference field.  How can I do this?


texts: Set up varnish, but is the content really from cache?

texts:
I set up varnish in my site and after the set up, checked the http header for an anonymous user. This was the response:

  Status: HTTP/1.1 200 OK
  Server: Apache/2.2.15 (CentOS)
  X-Powered-By:   PHP/5.3.3
  X-Drupal-Cache: MISS
  Cache-Control:  max-age=0, no-cache
  Content-Language:   en
  Link:   http://www.website.com/; rel="canonical",http://www.website.com/; rel="shortlink",https://plus.google.com/u/0/b/randomnumber/randomnumber/; rel="publisher"
  Vary:   Accept-Encoding
  X-Mod-Pagespeed:    1.6.29.7-3566
  Content-Encoding:   gzip
  Content-Type:   text/html; charset=utf-8
  Content-Length: 15365
  Date:   Sat, 08 Feb 2014 20:53:08 GMT
  X-Varnish:  658699528
  Age:    0
  Via:    1.1 varnish
  Connection: close

This is what isvarnishworking.com has got to say on this:

  Varnish appears to be responding at that url, but the Cache-Control header's "max-age" value is less than 1, which means that Varnish will never serve content from cache at this url.

This means that the purpose of me setting up varnish is not served. Is this correct? Varnishstat shows a hit to miss ratio of 50% which is good enough to start with:

83  Client connections accepted
     230  Client requests received
      21  Cache hits
      49  Cache misses
     210  Backend conn. success
     164  Fetch with Length
       1  Fetch wanted close
      39  N struct sess_mem
       1  N struct sess
      37  N struct object
      37  N struct objectcore
      26  N struct objecthead
      90  N struct smf
      16  N large free smf
       1  N struct vbe_conn
       2  N worker threads
      12  N worker threads created
  375315  N worker threads limited
     104  N overflowed work requests
       1  N backends
      12  N expired objects
       8  N LRU moved objects
     184  Objects sent with write
      82  Total Sessions
     230  Total Requests
     160  Total pass
     209  Total fetch
   84600  Total header bytes
 1377549  Total body bytes
       8  Session Closed
     223  Session Linger
     224  Session herd
   19641  SHM records
    1662  SHM writes
       1  SHM MTX contention
     213  allocator requests
      74  outstanding allocations
  409600  bytes allocated 10439155712  bytes free
     210  Backend requests made
       1  N vcl total
       1  N vcl available
       1  N total active purges
       1  N new purges added
      70  HCB Lookups without lock
      35  HCB Lookups with lock
      35  HCB Inserts
     752  Client uptime
      44  Fetch no body (304)

Here is a screeshot of the admin/configure/development/performance page:

http://awesomescreenshot.com/01e2bplzef


texts: In Commerce 2, how can I load an order item's 'purchased entity' object given its ID?

texts:
I have need to load an order item's 'purchased entity' object so that I can object the base product's title for an order item.

In my scope, I have the order_item object and, from there I have access to the 'purchased entity' ID number. But I can figure out how to load the 'purchased entity'object from this ID number.

EDIT:

Thanks to Chance G I was able to achieve what I needed by:

  $product_variation = $order_item->getPurchasedEntity();
  $product_id = $product_variation->product_id->getString();
  $product = \Drupal\commerce_product\Entity\Product::load($product_id);
  $product_title = $product->getTitle();


texts:
I want to get a menu similar to the one shown on net.cn; under the logo there is a navigation bar with 6 menu items; when you hover the mouse over one of the menu items, the bar under it shows the child menu items.

Is there a module to obtain something similar? Which code can I use to obtain the same effect?


texts: What are the alternatives to the Calendar module?

texts: I have a requirement to add a calendar to my Drupal 7 website. Currently the Calendar module has an alpha version. This is a little subjective, but I was wondering if the Calendar module is stable enough for my needs. Are there alternatives?


texts:
In order to install oauth2 server module, I have added oauth2 server library in drupal-8 as instructed in https://www.drupal.org/node/1938218

Now oauth2 library exist in path/to/drupal-8/libraries/oauth2-server-php, but I still get the oauth2 server library unavailable error.

>

I tried changing libraries folder permission to writable, moving the libraries folder path to sites/all/libraries and sites/default/libraries, without success.


texts: Passing extra parameters to Feeds Importer

texts:
I have multiple books and have CSV files per book containing the chapters and their content.
The CSV columns are called "Chapter Number" and "Text".
On the Drupal website I have created a node for each book. I want to import the chapters so the chapters also get an entity reference to the right book when they are saved.
Creating an importer for each book is not an option since there will be more added frequently.

For each imported node an entity reference field is required. This data does not exist in the uploaded CSV data, but should be provied by the Drupal website.

Essentially I want a View listing all my books with an import button next to each row.

I was able to pass this data as a GET value in the URL, but unfortunately this value is lost when the batch starts after clicking the submit button.

I hope someone can point me to the right direction! I've been searching the web for many hours and was not able to find anything related to this issue.


texts: Custom basic .js from theme dir prevents Splashify module from working

texts:
I am using latest Drupal 7 with latest Splashify version. Splashify (Splash in D6) is a simple module that uses jStorage js (from libraries/ dir) to add a splash/intro page for your Drupal site. So i.e. user enters my site and it gives him some intro splash page with like links to Enter site or Leave and etc. And that page is any node who's path/alias is chosen as a splash page. More about Splashify drupal.org/project/splashify

Now I found out that this module is not working because of some basic js my theme has. I tried on default Bartik and the module works just fine.

The problem is I am not js developer and don't know what's the problem. So I only managed to track down the problem.

There's the code, maybe someone knows what might be the issue, it's jQuery:

(function ($) {
  /* Slideshow */
  Drupal.behaviors.MYSITE = {
    attach: function (context, settings) {
      $(".carousel").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev"
      });

      /* Rollover info */
      $(".block1").hover(function(){
        $(this).find("span.info").stop(false, true).fadeIn("fast");
      }, function(){
        $(this).find("span.info").stop(false, true).fadeOut("fast");
      });

      // Class for every 3rd row.
      $(".view-flavor-listings .views-row:nth-child(3n-3)").addClass("diff-margin");
      $(".view-content-inner .views-row:nth-child(5n-4)").addClass("diff-mrg");

      /* slidePager */
      $('.pages').slidePager({
        last:6,
        borders:1,
        change:function(n){
          var els=$('.thumbs li').removeClass('mrk')
          els.eq(n).addClass('mrk')
          els.eq(n+1).addClass('mrk')
          els.eq(n+2).addClass('mrk')
          $('.thumbs li').css('opacity',1)
          $('.thumbs li:not(.mrk)').css('opacity',1)
        }
      })
    }};

    // Make Plupload default.
    $('.filefield-sources-list').each(function() {
      $('a.filefield-source-plupload', this).trigger('click');
      $(this).hide();
    });
  })(jQuery);

To be exact it's that part:

/* slidePager */
$('.pages').slidePager({
  last:6,
  borders:1,
  change:function(n){
    var els=$('.thumbs li').removeClass('mrk')
    els.eq(n).addClass('mrk')
    els.eq(n+1).addClass('mrk')
    els.eq(n+2).addClass('mrk')
    $('.thumbs li').css('opacity',1)
    $('.thumbs li:not(.mrk)').css('opacity',1)
  }
})

Maybe its missing some () or {} or something like that. I remember I built that .js from surfing Google throughout.


texts: How can I load webform content inside a custom webform composite element?

texts:
I am using Drupal 8.7.3 and Webform 8.x-5.2.

I created a custom composite field in a multistep webform by extending WebformCompositeBase. My users select a subject in an earlier step. In this step I want to take the key of the user selection and request data based on this key.

class OtherExpectationsComposite extends WebformCompositeBase {
    public static function getCompositeElements(array $element) {
        return [
            'depending_content' => [
                '#markup' => 'content depending on earlier selections'
            ]
        ];
    }
}

How can I load the data insert to the form by the user in the earlier steps? $element doesn't contain anything helpful.


texts: Render a list of all translatable strings that appear in a page / node?

texts:
I am looking for a PHP code / Drupal 7 hook which provides a list of all translatable strings that appear in the displayed page or node (i.e. all t('strings') with their id's).

Update

I need that list as an array for admin / moderator usage only in order to render links to string translation path (within node view page) so it becomes easier to translate those particular strings which appear in a given page.

I have inspected Drupal's 7 API for a function that provides such a list but could not find one yet.


texts: Does a form submit button field name and element name have to be unique?

texts:
I have a single form that I am displaying on the same page twice in different areas. They each have a unique form id provided by getFormId().

However, only the first instance of the form works. The second instance doesn't submit via AJAX at all and doesn't adhere to validation.

I found that if I took out the first instance of the form, the second one works just fine.

My second step was to create a new form class, again with its own unique form ID. The second form still did not submit correctly.

I found out that I had to do a few things to get this to work, and now I have one form class again with the same form on the page twice:

$form['submit_' . $this->getFormId()] = [
  '#name' => 'submit_' . $this->getFormId(),
  '#type' => 'button',
  '#value' => $this->t('Sign up'),
  '#limit_validation_errors' => [],
  '#submit' => ['::submitForm'],
  '#attributes' => [
    'class' => [
      'hl__button',
      'hl__button--small',
      'hl__button--inline',
    ],
    'data-twig-suggestion' => 'newsletter_signup_submit',
  ],
  '#suffix' => '</div>',
  '#ajax' => [
    'wrapper' => $wrapper,
    'method' => 'replace',
    'callback' => '::validateEmailSubmission',
    'progress' => [
      '#type' => 'none',
    ],
  ],
];

I had to add both a unique #name and give the form item a unique name instead of just $form['submit']. When I did that, everything worked as expected.

Did I do something wrong here, or is this a potential core bug? Can you not have different forms with $form['submit'] as the submit name? I feel like I did this a lot in D7, but it does not work here at all. Even with two different form classes and unique form IDs, this problem persisted until I added the above code.

What would be the proper way to do submit buttons to avoid this?


texts: Where is the entity in code field? [Display suite module]

texts:
I create a code field in Display Suite module and I need to insert a format_plural in it like

print format_plural([node:comment-count],  '1 Comment',  '@count Comments');

but token do not work in php block so I tryed:

dsm($node);
dsm($entity);
dsm($object);

but they do not work because 'Undefined variable' error.
Where is the node variable in display suite code field?

How can I achieve this output?

There is the screenshots


texts: Get user register form fields in edit profile form page

texts:
So the user register form fields are not displaying in the corect order in the edit profile form page. I have set the order of the fields from admin panel user manage fields admin/config/people/accounts/fields

The fields are rendering properly in the register form however in the edit profile page, the order is messed up.
Is there a way to get the register form fields by using drupal_get_form('user_register_form') in the edit profile page and then render it from the from array? I have tried loading the register form fields but it gives me no result.


texts:
I have need to send pdf via drupal mail. I want to use tcpdf library but when im trying to use example i have error:
http: //..../tcpdf_example/download/simple

Fatal error: Call to a member function DrupalInitialize() on a non-object in C:\xampp\htdocs\drupalac_gw\sites\all\modules\tcpdf\tcpdf_example\tcpdf_example.pages.inc on line 55

  $html = theme('tcpdf_example_basic_html');

  // Never make an instance of TCPDF or TCPDFDrupal classes manually.
  // Use tcpdf_get_instance() instead.
  $tcpdf = tcpdf_get_instance();
  /* DrupalInitialize() is an extra method added to TCPDFDrupal that initializes
  *  some TCPDF variables (like font types), and makes possible to change the
  *  default header or footer without creating a new class.
  */
  $tcpdf->DrupalInitialize(array(
    'footer' => array(
      'html' => 'This is a test!! Bottom of the page',
    ),
    'header' => array(
      'callback' => array(
        'function' => 'tcpdf_example_default_header',
        // You can pass extra data to your callback.
        'context' => array(
          'welcome_message' => 'Hello, context array!',
        ),
      ),
    ),
  ));

then somehow...

  ...
  $attachment = array(
  'filecontent' => $tcpdf->Output('', 'E');
  'filename' => 'test.txt',
  'filemime' => 'text/plain',
  );

  switch($key) {
  case 'notice':
  $langcode = $message['language']->language;
  $message['subject'] = 'example submission from' . $account;
  $message['body'][] =''. $account .' has submitted an example.';
  $message['params']['attachments'][] = $attachment;
  break;
  ...

What i need to correct to get rid of error?


texts: Hi is it possible to remove black bars in media-vimeo plugin? There is line in player.css style which controls it, but I can't edit it, because this file is loaded inside of iframe.


texts:
i created a User flag call (follow). user can follow eachother.
i want create a views show flagged nodes + user added nodes,like facebook when you login in your facebook profile you can see your Posts and your friends posts.

I found this View of users flagged by a user, users flagging a user, and nodes from users flagged by a user  but ways on that questions just  follower list node.


texts: I get an exception when re-installing a module

texts:
I have re-installed modules before, but I can't get it this time. These are the steps I take:

Uninstall the modules (by deselecting them on the module list and clicking submit changes)
Remove the Module Files from the module folder
Check the database for any potential left over tables (specifically sms_feed)
Check the system table for any left over rows dealing with my modules
Delete anything related to my modules in the database
Clear the cache
Reinstall the modules

I always get the following error:

  DatabaseSchemaObjectExistsException: Table sms_feed already exists. in DatabaseSchema->createTable() (line 657 of C:\xampp\htdocs\amaware\includes\database\schema.inc).

Do you have any idea?


texts:
First, let's describe what I have already:

Vocabulary: "Categories" with some terms added(cat1, cat2, cat3)
New content type "custom_page" where I added a new field of type "Term reference" using vocabulary "Categories";
Widget type for previous field is "Check boxes/radio buttons" because a custom_page can be part of multiple categories;

It is possible when adding a new custom_page, to add additional fields for each category selected?

Assuming, I checked "cat1" and "cat3" -> it is possible to add 3 more fields inline (new_field1, new_field2, new_field3) with every category selected?

Thanks,
Alex


texts: What can I do with content types that I can't with taxonomies?

texts:
I'm starting with Drupal and comparing taxonomies and content types and from what I see, they both:

offer a URL via the Name/Title field
have the same list of field types (images, double-field, text...)
can refer each other (with node/term reference)
have translation (with the proper translation modules enabled)

Therefore I seem able to create the same content via taxonomies as with content types.

However, taxonomies seem tightly integrated with views, offering categorization and filtering, unlike content types, which brings me to the following question:

What's the point of using content types at all, is there anything we can do with content types that we can't do with taxonomies?


texts: Render field collection multiple times on node.tpl.php

texts:
I have created a custom view mode for field collections with this code:

/**
 * Implements hook_entity_info_alter().
 */
function view_modes_entity_info_alter(&$entity_info) {
  $entity_info['field_collection_item']['view modes']['myviewmode'] = array(
    'label' => t('My view mode'),
    'custom settings' => TRUE,
  );
}

And I'm trying to render the field in the node.tpl.php using the view mode with this code:

$display = array(
  'label' => 'hidden',
  'type' => 'myviewmode',
);
$output = field_view_field('node', $node, 'field_page_collection', $display);
print render($output);

But the field is rendering with the default view mode, not with the custom one I created. Is there a way to render it using the new view mode??

Thanks a lot!


texts: Creating a list of node-options in different node

texts:
I am looking for a way to list nodes in a different node. Not sure how to explain this, so I will do it with an example.

Let's say I'm for example making a website for a Tennis tournament, this is not the real purpose, so if you have a different solution for this, it's probably not what I need, I want to achieve what I'll say in this example:

I have the following nodes:

Player
Match

In player I have:

Player name
Player age
Player ranking
etc...

In the node match, I have a few settings, including:

Player 1
Player 2

What I want to achieve is that in the node "match" I can choose 2 players from the node "player". In the list it shows the player name, however, I should be able to get the extra information as well when rendering the match node.

Any ideas if a certain module excists that could help me out?

Thank you very much!

Edit 22/07/2014:

As an addition, I would also like a different list to inherit his items depending on a previous selected item.

So for example I have 3 nodes:

Car
Brand
Model

The first thing that I would do is:
I make different brands as "Brand" nodes content:

BMW
Mercedes
Volvo
...

Afterwards I make a Model. In model I make the models
- 'Z4' => And in the list I choose "Brand: BMW"
- 'S60' => And in the list I choose "Brand: Volvo"
- 'V70' => And in the list I choose "Brand: Volvo"
- ...

Now I want my third node "car" to be for example for a seller of cars.
So the seller sells a car. He makes a car node and enters the following information:

Buyer: Person A
Address: Address X
Age: 99
Licenseplate: 1 XXX 999
Brand: ....
Model: ....

So what I'm trying to achieve is that the seller has a list of all brands.
If he chooses brand "Volvo" for example, then the Model list should appear and show all models for the chosen brand.


texts:
I have a whole bunch of nodes (all the same type), and I'd like to turn comments on for all of them (the client changed their mind about commenting after all of the data was added).

I've found notes that suggest that if I do something like:

update node set comment = 2 where type = 'foo'

then it should turn commenting on for all the nodes of type foo. However, this doesn't seem to work in Drupal 7, and the notes on drupal's site only specify 5 and 6.

I tried flushing caches and bouncing apache after making the change, and still can't see comments coming back on. Did this change in Drupal 7?


texts: How to override the /taxonomy/term/% for specific terms?

texts:
I would like to override the standard /taxonomy/term/% view for certain terms in a given vocabulary in two situations: one is for a given term, another is for all childs of a given term (so if and only if the current term has XXX has parent, the view must be triggered°.

When one of the condition above is met, then this view must be triggered, the standard view must be displayed otherwise.

What is the proper way to achieve this?

EDIT

Example:
Standard taxonomy page orders teasers by published date and it is generally what I need except for all the children of the term "Regions" (Africa, Asia, Caribbean,...) where I need to order them by Country and provide exposed filters.

I don't want to create a view for each of those terms. I would like to create a view that is triggered only when the parent term is Regions. In all other cases, the standard /taxonomy/term/% view must be rendered.


texts: this hook_uninstall isn't deleting fields in my module!

texts:
I've trying to make a simple module that creates a node-type and adds a few custom fields to it with the Field API.

Here is my module's .install

Here is my module's .module

The module installs just fine. After changing some things in my hook_install_fields, I disabled the module and uninstalled. When I try to re-enable the module, drush prompts me that one of the fields already exists and is active. My problem is that hook_uninstall doesn't seem to be deleting the fields from the database. If I manually delete the field tables from the database, I'm able to re-enable the module without error.

Can anyone point me in the right direction on this?


texts: how to manipulate entity field values in drupal 7 in custom module

texts:
I am creating a Payroll entity in which I have to manipulate different field values based on another field value (see below).

I have the following fields and I want to calculate the bottom four field values from the value of the basic salary field. Is there any function/hook available for this or do I have to write my own custom function?

basic salary field
da salary(daily allowance)
ta salary(travel allowance)
epf salary(Employee provident fund)
save_salary(Save salary)


texts: I need to remove manually a display from a view

texts:
While I was testing an organic groups view it caused a block display in the same view to come up with an error message every time I try to edit it.
I could re-created the block view but can't delete the old block view through the UI.
Is it safe to delete it manually from the views_display table?


texts: How to output node fields of referenced nodes as plain-text key/value pairs?

texts:
I've got a super content-type that contains at least 4 node references.

The first three references aren't always the same node-type but they contain just one referece.

The third reference can contain multiple references which are all of the same type but the type of these references my differ from time to time.

The forth reference references only one node each, which hast always the same type.

So I have a super node which references a few other nodes where number and node-type are not always the same. That's my starting point.

Now I have to send the whole content e.g. the custom fields I've created in the content-types of the sub-nodes via e-mail every time new content is created. The email should be plain text and should contain key/value pairs of the custom fields.
The format is "key: value". This is fix my customer requires it and I can't change this at the moment.

To do this I want to use rules + views + rules_views (Rules Views Integration) and this is the point where I'm unsure what is the best way to continue. I pass the node-id from rules to views to render the just created node.
If I tell views to use "row style: node" and choose "full node" as "display", I got my super node with all the sub nodes inside fieldsets.

Basically thats very close to what I want and it looks like I just have to theme my node to get rid of all the HTML an plain text but how?

Do I have to use my standard node-'node-type'-tpl.php files or can I add tpl.php-files just for this specific view?
Or is it possible to add a different display besides 'teaser', 'full node' and 'rss' that views will recognize and that I can theme to my liking?
And if one of these is the way to go, how can I pass arguments from views to my tpl.php-file to decide how to lay out my node (for display on the site or for the email via rules)?

I hope this all makes enough sense and you can help me out.

Thx in advance.

mantuko


texts: Webform: how to display warning message, when clicking upload, and no file is chosen?

texts:
I have a webform, in which I have file upload.

However, when user chooses no file, he is still able to click upload and nothing happens. I would like to have there similar message like when he chooses file with extension which is not allowed.
How can I achieve this?


texts:
Retrieve a node based on condition:
$query = \Drupal::entityQuery('node')
->condition('type', 'my_content_type')
->condition('title', 'my node title');
$nid = $query->execute();

The result of $nid is the correct node ID but the format is a string, (es: "123")
When I want to load the node by its ID, I write:
$node_id = Node::load($nid);

Doing this, the result I get is NULL because the variable $nid is holding a string (not integer).
If I write the code like this:
$node_id = Node::load(123);

I get the node loaded.
How can I convert the variable string ($nid) as an integer ?
I tried:
$nid_int = (int) $nid;
$node_id = Node::load($nid_int);

also I tried:
$nid_int = intval($nid);
$node_id = Node::load($nid_int);

But I alwas get result NULL
Thanks for your help


texts: How to default a content type's Language field to the authenticated user's language?

texts:
We are using Entity Translation so that content can be created in several language. One item we noticed is that on the basic page, for example, has a language field that you can set when you create a piece of content. As of right now, any users regardless of if their profile's preferred language is set to French (for example), the French user is still able to create a content in English.

Ideal scenario:

If a French user logs in and creates content of type basic page, then the language field should be set to French. If a German user logs in and performs the same actions, the language should be restricted to just creating content using the German language.

Any thoughts on how I would set this up?


texts: How do I get a list of primary links by language?

texts:
I have been digging different drupal 6 functions such as menu_primary_links(), menu_tree_page_data(), menu_tree(), menu_get_item() etc but I can't find how it is done.

Does anybody have an idea? I need it badly :(

Thanks.


texts: Exclude current node from entity reference view (for related news)

texts:
In Drupal 7 I have a news content type with a simple related news selection list. This works like a charm, I use an entity reference view to fill the list and new news-items are created just like they should be. But once the news-item is published it will of course be shown in the list. If you select it, the standard behaviour will be to render its full content view, resulting in a recursive content error.

How can I create an entity reference view that excludes the current node? I have found a lot of related issues, but nobody seems to answer the question of using parameters at all in this special kind of view. I tried to add an argument to the filter using the token syntax which says "AND Nid not equals [node:id]" but that turns out to be ignored. I also found that when you include the view it is possible to send parameters to it, but I was unable to find documentation for how to use them.

Does anybody have more information/documentation about this?


texts:
I'm trying to display an iframe (google maps) on my node. I allowed "iframe" with the "plain text" format and unchecked "Display any HTML as plain text": http://www.diigo.com/item/image/fgah/3hc0?size=o

I select the text processing option  "Filtered text (user selects text format)" for the field:
http://www.diigo.com/item/image/fgah/dmeh?size=o
I enter the iframe code with the "plain text" selection
http://www.diigo.com/item/image/fgah/7svw?size=o
The iframe renders fine.

I changed the text processing option for this field to "plain text": http://www.diigo.com/item/image/fgah/04e2?size=o

Now the iframe won't render (just shows the iframe HTML code).
Why would it not work, isn't it the same "plain text" option?


texts: Access denied to all profiles of a certain type

texts:
I am migrating from D7 to D8. I've had success with everything but the profiles from D7's profile2 module.
Four profile types have to be migrated. One of them is being migrated without issue: I can view and edit them. The other three, however, are giving me "Access Denied" errors when I try to view them. There is no difference in the parameters for the individual profile type migrations, aside from the names of the fields and the names of the profiles themselves.
When I view the list of profiles at admin/people/profiles, only one type of profile as an option to edit it. The others just have a button that says "Devel."
My user has permission to view, edit, and create profiles of all types, so it does not appear to be a permissions issue. I know for a fact that the data is being migrated, because I can see it in the MySQL DB. I have also cleared the cache, updated the db, and rebuilt the permissions.
I'm stumped, and I really need to have access to those profiles.

Drupal Version: 8.9.6
PHP Version 7.3.22
MariaDB Version: 5.5.5-10.4.14

Incidentally, using the patch at https://www.drupal.org/project/profile/issues/2957256 made the migration of profiles possible in the first place.


texts: Properly bootstrap drupal for standalone PHP file?

texts:
This is what I have right now:

<?php
    define('DRUPAL_ROOT', '/var/www/clients/client1/web15/web');
    include_once(DRUPAL_ROOT . '/includes/bootstrap.inc');
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
//  drupal_flush_all_caches();

    $users = views_get_view_result('userlist', 'uid_list');
    $i = 0;
    foreach ($users as $user) {
        $filename = 'sites/default/files/generated_pdfs/individual_pdf_report_' . $user->uid . '.pdf';
        generate_employee_pdf($user->uid, $filename);
        error_log('Generated ' . $filepath);
        $i++;
    }
    // create object
    $zip = new ZipArchive();
    // open archive
    if ($zip->open("sites/default/files/generated_zips/individual-reports.zip", ZIPARCHIVE::CREATE) !== TRUE) {
        die ("Could not open archive");
    }
    // initialize an iterator
    // pass it the directory to be processed
    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("sites/default/files/generated_pdfs/"));
    // iterate over the directory
    // add each file found to the archive
    foreach ($iterator as $key=>$value) {
        $zip->addFile(realpath($key), $value->getFilename()) or die ("ERROR: Could not add file: $key");
    }
    // close and save archive
    $zip->close();
?>

I'm getting a bunch of errors from the above when run standalone. Works fine in my module. Some of the errors are:

Warning: Invalid argument supplied for foreach() in drupal_depth_first_search() (line 56 of /var/www/clients/client1/web15/web/includes/graph.inc).
Warning: Invalid argument supplied for foreach() in _module_build_dependencies() (line 229 of /var/www/clients/client1/web15/web/includes/module.inc).
Warning: include_once(sites/all/modules/views_bulk_operations/actions/archive.action.inc): failed to open stream: No such file or directory in views_bulk_operations_load_action_includes() (line 56 of /var/www/clients/client1/web15/web/sites/all/modules/views_bulk_operations/views_bulk_operations.module).


texts:
I'm new to the command line, having trouble understanding why the uli drush command is taking me to the wrong domain.

On Pantheon, the dev site address is: dev-example.pantheon.io

I've successfully installed drush and all the aliases I need. However, when I enter this command:

drush @pantheon.example.dev uli

It takes me to wrong domain: wrongsite.com/user/reset/1/1....A/login

It should be: dev-example.pantheon.io/user/reset/1/1....A/login

I can login as user1 if correct the domain in the address bar. But what's happening here and how do I fix default domain?

Thanks!


texts: How Do I change existing theme to a new one without losing content?

texts:
Can someone lead me to documentation that explains how I can change an existing Drupal theme to a new one without losing all of my existing content?

The blog I manage is currently set up on the Omega 7.x 3.1 framework, with a semi-custom subtheme. We would like to install a new theme with more out of the box capabilities and a better design but it is important that the two years of published articles are maintained in the current chronological order and with their image content, etc.

Any help finding the instructions on how to accomplish this will be a great help.

Best wishes from Spain!


texts: Make a field in a Views block visible ONLY to the acccount/profile owner

texts:
The profile owner (currently logged in) sees this (contextual filtered Views block):

CURRENTLY, the other logged in users who visit test_user2's profile page see this:

What I want to achieve, is for the other logged in users who visit test_user2's profile page to see this:

In other words, I want only the account/profile owner to see the Edit field (/user/[nid]/edit) on their own page and to be able to edit his/her profile info. How to do this?


texts:
Can't seem to get hook_menu to work at all. I'm using the following code:

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

  $items['node/%node/mymodule-product'] = array(
    'title' => 'Edit Product',
    'page callback' => 'mymodule_product_redirect',
    'page arguments' => array(1),
    'access callback' => 'edit any commerce product entity',
    'weight' => 6,
    'type' => MENU_LOCAL_TASK,
  );
  dsm('check');
  return $items;
}

dsm() from the devel module is outputting fine when I clear the site cache, so the hook is firing, however for whatever reason the link is refusing to display on the node tabs.

Visiting any of the node tabs already displaying, outputs the following errors:

Notice: Undefined index: access in _menu_translate() (line 778 of includes/menu.inc).
Notice: Undefined index: access in menu_local_tasks() (line 1892 of includes/menu.inc).

And manually going to a page that would be defined in hook_menu outputs a load more errors in the same vein:

Notice: Undefined index: access in _menu_translate() (line 778 of includes/menu.inc).
Notice: Undefined index: access in menu_get_item() (line 464 of includes/menu.inc).
Notice: Undefined index: access in menu_execute_active_handler() (line 499 of includes/menu.inc).
Notice: Undefined index: access in menu_tree_page_data() (line 1167 of includes/menu.inc).
Notice: Undefined index: access in menu_tree_page_data() (line 1167 of includes/menu.inc).
Notice: Undefined index: access in menu_local_tasks() (line 1845 of includes/menu.inc).
Notice: Undefined index: access in menu_tree_page_data() (line 1167 of includes/menu.inc).
Notice: Undefined index: access in menu_tree_page_data() (line 1167 of includes/menu.inc).
Notice: Undefined index: access in menu_tree_page_data() (line 1167 of includes/menu.inc).

While these are all only PHP Notices, I assume they still may be relevant.

Thanks!


texts: How to re-order a mini-panel in a Panel generated page?

texts:
I've inherited a site and have been slowly unraveling certain aspects of its construction. Specifically right now, I want to change the order/region a page is loading a mini-panel in a page that I believe is being styled as a Panel due to the css-markup and lack of a template file.

I believe the content type and associated fields and panels were all loaded into the site structure via Features. The general layout of the pieces I want to change right now is like this:

    X

Where X is what I want to move to the div below, or another div below that so that I can display it on mobile devices below the main content. If I go to look at the admin/structure/mini-panels/list/mini_panel_name/edit/layout no matter how I change the location of the content, it doesn't seem to impact its layout in the nesting of the page overall.

There does not appear to be a Panel Page that is content-type/node% for the content type the panel and mini-panels are attached to or a template doc, so I'm not sure where to look to impact this. Neither are there published blocks associated with these.

I'm not very familiar with the Features module, but it's set to prevent rebuild and revert. Could there be something that's interfering with? Could there be something buried in the imported Features module that's controlling this layout outside of normal theming locations? This also all lives in Pantheon.


texts: Views PHP Field - Comparing two date fields

texts:
I'm trying to compare two date fields in a php field inside a view

I already have this working so far so good...

The php field looks like this:

$nid = $data->nid;
$node = node_load($nid);

$start_value = $node->field_tria['und'][0]['value'];
$end_value = $node->field_data_de_resoluci_['und'][0]['value'];
$timezone = $node->field_tria['und'][0]['timezone'];

$start_date = new DateObject($start_value, $timezone);
$end_date = new DateObject($end_value, $timezone);

$difference = $start_date->difference($end_date, 'days');
return $difference;

This returns me the day difference value, but always in positive.
The desired result should be something like this:

Day difference:

Example 1 (negative value):

2 days ago (or -2)

Example 2 (positive value):

2 days

It also looks like loading every node first doesn't seems to be the most efficient way to do this... but it works.

Thanks a lot

Here is my final code:

$nid = $data->nid;
$node = node_load($nid);
$timezone = $node->field_tria['und'][0]['timezone'];

$start_value = $node->field_tria['und'][0]['value'];
$day = substr($start_value,8,2);
$month = substr($start_value,5,2);
$year = substr($start_value,0,4);
$date = "$year-$month-$day";
$value1 = new DateObject($date, $timezone);

$end_value = $node->field_data_de_resoluci_['und'][0]['value'];
$day2 = substr($end_value,8,2);
$month2 = substr($end_value,5,2);
$year2 = substr($end_value,0,4);
$date2 = "$year2-$month2-$day2";
$value2 = new DateObject($date2, $timezone);

$difference = $value1->difference($value2, 'days', FALSE);
return $difference+1;


texts: How do I use dpm() or kint() to debug a block plugin I created?

texts:
I created a custom module which implements a block plugin. The code was generated with Drupal Console. When I try to debug the code within the build function, I get a function not found error.

Why doesn't my code print the value of $build?

namespace Drupal\my_module\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides a 'DefaultBlock' block.
 *
 * @Block(
 *  id = "default_block",
 *  admin_label = @Translation("test block"),
 * )
 */
class DefaultBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $build = [];

    $build['default_block']['#markup'] = '1:Implement DefaultBlock.';
    dpm($build);
    //kint($build);
    return $build;
  }

}


texts: Drupal 7 pass a custom form fileds input as arguments to the url on submit

texts:
How can I pass fields input as arguments to the url on custom form submit? I tried the following:

function custom_form_form($form, &$form_state) {

  $form['location'] = array(
    '#type' => 'radios',
    '#title' => t('Location'),
    '#options' => location_options(),
    '#default_value' => '',
    '#required' => TRUE,
  );

  $form['#submit'][] = 'custom_form_submit';
  return $form;
}

function location_options() {
  return array(
    'to' => 'To USA',
    'within' => 'Within USA',
  );
}

function custom_form_submit($form, &$form_state) {
  // I need a function here to redirect to a url with something like
  // move-quote?location=to
  // I tried $form_state['redirect'] but didn't work
}


texts: Setting #element_validate in a form (not form alter) removes original #element validation

texts:
I have an element with set #element_validate (in hook_element_info) and I use this element in a custom form. The problem is that when I try to add an additional #element_validate to the element in the form it overrides the original validate callback (the one set in hook_element_info).

So my question is, is there any way how to add an additional #element_validate in a custom form without having to use form_alter?

hook_element_info:

'ELEMENT_NAME' => array(
  '#input' => TRUE,
  '#tree' => TRUE,
  '#process' => array(..),
  '#element_validate' => array('original_validate'),
),

form:

$form['TST'] = array(
  '#type' => 'ELEMENT_NAME',
  ...
);
$form['TST']['#element_validate'][] = 'new_validate';

And then only new_validate is present when on 'process' callback of the element (as well as when the form is build). When I don't set the 'new_validate' the 'original_validate' is still present on 'process'.

Other elements (tried a few date ones) seem to behave the same way. E.g. #element_validate added in form declaration overrides the own element's one defined in hook_element_info.


texts: How do I combine two content types in one Views block and get them to sort correctly?

texts:
On my site, I have content types for Tradeshows and Webinars. I would like to have a block that shows the next 5 upcoming events by date, coming from either content type. I have Views set up to retrieve items from both types, and have the sort criteria set up with the date field from each type (they are different fields), in ascending order.  Ie., the Sort Criteria section looks like: Webinar Date (asc), Tradeshow Date (asc).

If I set the Views pager to display all items, I see a list of all the tradeshows, followed by the webinars.  It looks like Views retrieves the items from each content type, and sorts them correctly within their own group, but doesn't weave the two sets together, according to date.  This means that if I set the pager down to 5 items (the goal), then I'll only see tradeshows, since there are more than 5.

Is there a way to get Views to shuffle the two types together, and show the next 5 events, combined?

Edit: attaching screenshot


texts: How do I add a password field during registration?

texts: i am using Drupal 8. I want to set the password field and confirm password field during registration. On admin/configuration this option is not available. Is there a setting to achieve this?


texts: File value is NULL in custom file field type

texts:
I am creating a Custom field type for "file upload" functionality that contains a File form.

This is the code I am using.

/**
 * Plugin implementation of the 'AkamaiUpload' field type.
 *
 * @FieldType(
 *   id = "AkamaiUpload",
 *   label = @Translation("AkamaiUpload"),
 *   description = @Translation("Akamai File"),
 *   category = @Translation("Custom"),
 *   default_widget = "AkamaiUploadWidget",
 *   default_formatter = "AkamaiUploadFormatter"
 * )
 */
class AkamaiUpload extends FileItem {

  /**
   * Field type properties definition.
   *
   */
  public static function propertyDefinitions(StorageDefinition $storage) {

    $properties = [];
      unset($properties['display']);
      unset($properties['description']);

      $properties['target_id'] = DataDefinition::create('string')
          ->setLabel(t('Target'));

      return $properties;
  }

  /**
   * Field type schema definition.
   *
   * Inside this method we defines the database schema used to store data for
   * our field type.
   */
  public static function schema(StorageDefinition $storage) {

    $columns = [];
    $columns['target_id'] = [
        'description' => 'The ID of the file entity.',
        'type' => 'int',
        'unsigned' => TRUE,
    ];

    return [
      'columns' => $columns,
        'indexes' => [
            'target_id' => ['target_id'],
        ],
        'foreign keys' => [
            'target_id' => [
                'table' => 'file_managed',
                'columns' => ['target_id' => 'fid'],
            ],
        ],
    ];

  }

  /**
   * Define when the field type is empty.
   *
   * This method is important and used internally by Drupal. Take a moment
   * to define when the field fype must be considered empty.
   */
  public function isEmpty() {

    $isEmpty =
      empty($this->get('target_id')->getValue()) ;

    return $isEmpty;
  }

} // class

My Widget class is below:

/**
 * Plugin implementation of the 'AkamaiUploadWidget' widget.
 *
 * @FieldWidget(
 *   id = "AkamaiUploadWidget",
 *   label = @Translation("AkamaiUpload"),
 *   field_types = {
 *     "AkamaiUpload"
 *   }
 * )
 */
class AkamaiUploadWidget extends FileWidget {

  /**
   * Define the form for the field type.
   *
   * Inside this method we can define the form used to edit the field type.
   */
  public function formElement(
    FieldItemListInterface $items,
    $delta,
    Array $element,
    Array &$form,
    FormStateInterface $formState
  ) {
      $class = get_class($this);
      $validators = array(
          'file_validate_extensions' => array('pdf'),
      );

      $element['akamai_file_upload'] = [
          '#type' => 'managed_file',
          '#name' => 'my_file',
          '#title' => t('File *'),
          '#size' => 20,
          '#description' => t('PDF format only'),
          '#upload_validators' => $validators,
          '#upload_location' => 'public://my_files/',
     ];

      return $element;
  }

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

        if (!$form_state->isValueEmpty('akamai_file_upload')) {
            $file_value = $form_state->getValue('akamai_file_upload');
        }
        kint($form);

    }

    /**
     * {@inheritdoc}
     */
    public function submitForm(array &$form, FormStateInterface $form_state) {
        parent::submitForm($form, $form_state);
        $akamai_file_upload = $form_state->getValue('akamai_file_upload');
        if ($form_state->getValue('akamai_file_upload') == NULL) {
            $form_state->setErrorByName('akamai_file_upload', $this->t('File.'));
        }
        else{
        // add File upload logic here
        }
    }
} // class

$form_state->getValue('akamai_file_upload') is always NULL in both submitForm and validateForm methods.

In the form I built, I have a Save and Publish button. How can I link the submitForm() method to that button?


texts: How to reference a content-region block in node template?

texts:
Scenario:

I have a basic node content type that has some fields. I also have a custom block that will appear in the content-region of this node content type.

How can I (is it possible) reference the rendering of the block from within the theme node--mycontenttype.tpl.php file?


texts: How to access Vertical Tabs from Contrib Modules in Panels?

texts:
Drupal node forms have a vertical tabs area, which provides options such as "Revision Information", "Authoring Information", "Publishing Options" etc.
Contrib modules such as Node Hierarchy and XML sitemap can add custom tabs to this area.

How do you access these tabs from contrib modules in Panels.

In the past, with Drupal 7 & Panels, you could access them via the "Form" section of "Panels > Add Content".
However, I am creating a new Drupal 7 site and I can no longer access Vertical Tabs from Contrib modules. Only the tabs from Code Drupal modules are shown.

Steps I have tried to overcome the problem:

1) I have made a fresh install with just Panels and Node Hierarchy.
I have made a second fresh install with just Panels and Xml Sitemap.
In both cases, Vertical Tabs from Contrib modules are not accessible.

2) I have tried installing Node Vertical Tab Elements. It too only gives access to core tabs (and not tabs added by Contrib modules).

3) I have tried upgrading my older Drupal 7 sites to the latest versions of Drupal 7. In these older sites, the Vertical Tabs from Contrib modules are still accessible, so I am not sure if this means a special setting is required to access the tabs. I have disabled all custom themes and modules on the site, so I know the tabs are not coming from custom code.

Any help would be most appreciated.


texts:
On my Drupal 8.9 (with Twig Tweak module) home page I integrated a block with the following code :
{{ drupal_view('accueil_page_liste_des_taches_boutique', 'block_1') }}

This block displays the rendered entity (with display mode tasks-frontpage) of the stores of the current user.
I rewrote the display mode of the stores with by creating the following file :
commerce-store--professionnel--tasks-frontpage.html.twig

Here is the file code. All views included in this code have a context filter with the path of the current store :
Vous avez
{% set dangers = 0 %}
{% if drupal_view_result('boutique_page_liste_des_taches_aucun_produit', 'block_1') is empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_aucune_variation', 'block_1') is not empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_commande', 'block_1') is not empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_mode_de_livraison', 'block_1') is empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_passerelle_de_paiement', 'block_1') is empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{{ dangers }}
tâches importantes dans votre {{ store_entity.type.entity.label }} "{{ store_entity.name.value }}".
Voir la liste

MY PROBLEM :
When the {{ drupal_view('accueil_page_liste_des_taches_boutique', 'block_1') }} block is rendered on my home page, the blocks in the commerce-store--professionnel--tasks-frontpage.html.twig templates do not work. This is normal because I think it searches for the store ID in the URL.
How do I fix this ? There is an EVA module, but is there another way to do this directly with TWIG ?
THE OBJECTIVE :
The goal is to create a list of tasks in stores and display it on the user's home page.
The blocks views in the commerce-store--professionnel--tasks-frontpage.html.twig template are used to control this :

If the store has no product.
If one of the products in the store has no variation.
If the store has an order in progress.
If the store does not have an associated delivery method.
If the store does not have an associated payment gateway.

It may be possible to control this directly in a store template without using views ?
SOLUTION :
Vous avez
{% set dangers = 0 %}
{% if drupal_view_result('boutique_page_liste_des_taches_aucun_produit', 'block_1', store_entity.id()) is empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_aucune_variation', 'block_1', store_entity.id()) is not empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_commande', 'block_1', store_entity.id()) is not empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_mode_de_livraison', 'block_1', store_entity.id()) is empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{% if drupal_view_result('boutique_page_liste_des_taches_passerelle_de_paiement', 'block_1', store_entity.id()) is empty %}
  {% set dangers = dangers + 1 %}
{% endif %}
{{ dangers }}
tâches importantes à traiter dans votre {{ store_entity.type.entity.label }} "{{ store_entity.name.value }}".
Voir la liste


texts:
I am working with Drupal Commerce to create an e-Commerce store. However, I am having some trouble with my client's gateway of choice, First Data.

I have everything set up as directed (I believe) but when I try to submit an order the page times out and I am given this error message. (This happens if I am testing a transaction live, test authorized, or test denied)

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away:

INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location,
referer, hostname, timestamp) 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, :db_insert_placeholder_8, :db_insert_placeholder_9);
Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => php
[:db_insert_placeholder_2] => %type: !message in %function (line %line of %file).
[:db_insert_placeholder_3] => a:6
{s:5:"%type";s:6:"Notice";s:8:"!message";s:27:"Undefined index:
order_num";s:9:"%function";s:33:"firstdata_cc_submit_form_submit()";s:5:"%file";s
87:"/home/betads/public_html/sites/all/modules/commerce_firstdata/commerce_firstd
ta.module";s:5:"%line";i:380;s:14:"severity_level";i:5;}
[:db_insert_placeholder_4] => 5 [:db_insert_placeholder_5] =>
[:db_insert_placeholder_6] => https://beta.designsenseinc.net/checkout/7/review
[:db_insert_placeholder_7] => https://beta.designsenseinc.net/checkout/7/review
[:db_insert_placeholder_8] => 166.147.79.6 [:db_insert_placeholder_9] =>
1330630525 ) in dblog_watchdog() (line 157 of
/home/betads/public_html/modules/dblog/dblog.module).

Any idea what could be the issue? To test for yourself, you can visit http://beta.designsenseinc.net/product/853 and add the product to cart.

Any help appreciated.


texts:
I have a eva which contains a view in a node. What I want to do is adding prefix and suffix to wrap around the eva field.

I tried to do that in hook_node_view(), but the $node does not contain any info about the eva field.

So how can I do that?

Thanks for any suggestions.


texts: How I can intercept an image field upload and validate it?

texts:
I have a content type with an image field. I need to validate this field because I need to check if user upload a real image or only a file with image's extension (like jpg, gif, png etc). I have tried and readed 100+ things but none resolve my problem.

I have tried via "#upload_validators" with this code:

foreach ($form['field_all_images'][$form['field_all_images']['#language']] as $k => $v) {
  if (!is_integer($k)) continue;

  $form['field_all_images'][$form['field_all_images']['#language']][$k]['#upload_validators']['check_image_correct'] = array();
}

where "check_image_correct()" is a my custom function that checks via imagegetinfo(). My problem, in this "try/case", is that the function works/is called only for the first image. I have tried to move this function from hook_form_alter() to an #after_build function, without result (only the first time it works).


texts: Views 2, Setting argument via php code validator and negating the logic

texts:
I use to validate view's (block display) filter with PHP code to push argument(s) to view. e.g. Providing a related content list on the base of taxonomy terms is done by creating a taxonomy term id filter and setting a PHP validator as:

$node = node_load(arg(1));
$terms = array();
if($node) {
  foreach($node->taxonomy as $id => $tax) {
    $terms[] = $id;
  }
  return join('+', $terms);
}

This filter lists all such nodes which have any association to the term id(s) that is/are associated with the node being viewed.

I know this approach is a hack but it works for all inclusive arguments.

How to use this approach for exclusive arguments. e.g. Excluding the node (on the behalf of id) from the list that is being viewed. Means every related to this but not this.


texts: Drupal Commons: notify all users on creation of new group

texts:
In Drupal Commons (D7) I'd like to have all users notified by email when a new group is created.

Is there a way to do that?


texts: How do I apply a patch with Composer workflow?

texts:
I need to include a patch in my project. I have included cweagans/composer-patches in composer.json and added the following lines in the extra section (example is from when trying to enable distribution in the Configuration installer).

"patches": {
        "drupal/config_installer": {
            "Enable distribution for Configuration installer profile": "patches/config_installer_enable_distribution.patch"
        }
    }

Afterwards, I run composer update.

- Installing drupal/config_installer (1.5.0): Loading from cache
- Applying patches for drupal/config_installer
    patches/config_installer_enable_distribution.patch (Enable distribution for Configuration installer profile)

So I get no errors and the patch seems to have been applied successfully. Also the file PATCHES.txt is successfully created in the package's root directory. Still, the patch hasn't been applied.

I've tried this method with other packages which come from Github and it works, however every time I try this with a module or a profile from drupal.org then the patch isn't being applied.

Am I missing anything?

When I ran composer update -vvv, I saw the command which is running for the patch is indeed with Git.

git -C 'web/profiles/contrib/config_installer' apply '-p1' '/path/to/project/patches/config_installer_enable_distribution.patch'

I've tried running the command by itself; again, it didn't change the file.


texts:
form IDs for my entity forms is not listed in the catchpa general settings.
Can anyone explain how I add the catchpa?


texts: How to specify a separate theme for one specific panel page

texts:
Is there a way in Panels 3 (or an add-on that integrates into the Panels UI) that lets you specify a different sub-theme to use on a given panel page?

I've looked through the UI for both the regular Panel pages, as well as in the Panels Everywhere site template -- but can't find any mention of theme selection.

I know the ThemeKey module would be the traditional recommended solution here, but I don't want to add another heavyweight module for one single page on the site. And would prefer not to write a custom module with a hook_init() that changes the theme.

My understanding is that Panels handles layout -- not theme selection -- but there seems like no reason Panels couldn't also provide the ability to specify which theme to load, in addition to the layout to display.

What am I missing?  Thanks!


texts: `composer require` fails because "Source directory docroot/core has uncommitted changes"

texts:
Symptom: You have a script that fails while executing a composer require command, resulting in output like the following:

$ ./example.sh
Gathering patches for root package.
Removing package drupal/core so that it can be re-installed and re-patched.
  - Removing drupal/core (8.6.x-dev)

In VcsDownloader.php line 242:

  Source directory docroot/core has uncommitted changes.

Attempting to execute the offending composer require command manually results in output like the following:

$ composer require drupal/examples
Gathering patches for root package.
Removing package drupal/core so that it can be re-installed and re-patched.
  - Removing drupal/core (8.6.x-dev)
    The package has modified files:
    M core.services.yml
    M includes/install.core.inc
    M includes/install.inc
    M lib/Drupal/Core/Config/ConfigInstaller.php
    M lib/Drupal/Core/Config/ExtensionInstallStorage.php
    M lib/Drupal/Core/Config/InstallStorage.php
    M lib/Drupal/Core/Entity/EntityViewBuilder.php
    M lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php
    M lib/Drupal/Core/Extension/ExtensionDiscovery.php
    M lib/Drupal/Core/Extension/ModuleExtensionList.php
    19 more files modified, choose "v" to view the full list
    Discard changes [y,n,v,d,?]?

Conditions: You are using Composer to manage your Drupal site dependencies and applying patches with cweagans/composer-patches. You may be using Acquia BLT.


texts: How to to render a webform (or any configurable form) in a node edit form?

texts:
I have a weird use case, where I was looking to perform the following:

In a node edit form, allow a user to entity reference a collection of webforms
When a user selects an appropriate webform from the entity reference autocomplete, render that form in the current node edit form
User fills out fields in these webforms then proceeds to save the node.
On node save, the webform submit data is stored in a particular field in the node (perhaps in json format).

Is this even possible with webforms, or do any other form modules exist that support this use case?


texts:
Is the a way to allow downpayment for customer-preoders.
I can create a content type that allows customers to place orders(pre-order) but I wish they could commit a certain fee, like 30% of the original price.
Is there a way to achieve this?


texts: View output that goes from list to three-column grid?

texts:
I'm working on a news site, which has a front page generated via Views.

Originally I was told it was just a straight list of stories, so I used the unformatted list display type, using on of the fields ("section") to group rows. Now, however, I'm being told it'd be nice to have the first ten stories display as an unformatted list, then have the next ten display in some sort of three-column configuration (similar to the "grid" display type).

Any idea how I'd do that? Thanks!


texts:
I'd like to relocate the pager generated by views and put it, in my page.tpl.php part, in order to display it at the very bottom of the page.

Is this possible?

I tried copying this code from a view to page.tpl.php but it didn't work:

  <?php if ($pager): ?>
    <?php print $pager; ?>
  <?php endif; ?>


texts: Open Atrium: How to add an action button on a view node

texts:
I can add a button on the node edit form using a hook_form_alter and adding a new element to $form['actions'].

However, I would also like to add a button to the node view, next to + Create. I assume there's an api for this but I can't seem to find it in the code or in documentation.


texts: Why Drupal won't remember "use search" permission settings for roles?

texts:
I want to make search available to everyone who uses the site, including anonymous users.
Now, if i go to /admin/people/permissions and and try to enable "use search" for anonymous and authenticated users, the systems seems to act okay, but when I look at it again, nothing's changed. The settings seemingly won't remember my settings.
Any ideas? I hope that there's something totally simple I forgot

EDIT: in fact, it does not keep any changes in the permission system.

EDIT 2: I made it work by editing permissions through /admin/people/permissions/roles. Does anyone has any ideas why it was possible in one way but not the other?


texts: Authenticated users can't edit their own content even with permissions set accordingly

texts:
As an authenticated user, I've created a node. The Tasks menu is completely absent. If I try to access it via node/476/edit, I see "Access Denied".

The Task menu (edit, view, revisions) is seen by the Administrator but Authenticated users. How can I bedug this further?

However, I have permission set for this Content Type as follows below. I've included another Node TYpe called Event as well.

I even tried looking into the table node_type to see if anything was off

       type: user_posted_content
       name: User Posted Content
       base: node_content
     module: node
description: Postings by users
       help:
  has_title: 1
title_label: Title
     custom: 1
   modified: 1
     locked: 0
   disabled: 0
  orig_type: user_posted_content

Other Modules
I previously had tried both Content Access (content_access) and Node view permissions (node_view_permissions) but ended up deactivating both.

Digging deeper
It appears I may have some residual from one of those modules.

MariaDB [s7data]> select * from node_access where nid = 476;
+-----+-----+-------+------------+--------------+--------------+
| nid | gid | realm | grant_view | grant_update | grant_delete |
+-----+-----+-------+------------+--------------+--------------+
| 476 |   0 | all   |          1 |            0 |            0 |
+-----+-----+-------+------------+--------------+--------------+


texts: How to speed up Drupal 8 when pages are not cached yet (1st time visit after clearing cache)?

texts:
D8 has awesome core caching and opens pages very quickly in second-third and so on visits.

But when I clear caches (making design improvements) the response is too long. Very long response during first time page visit in my shared hosting.

I want to move on VPS, so please what to do with my server to speed up drupal 8?


texts: theme ALL form elements in a tpl through hook_preprocess_HOOK

texts:
Trying to theme a form into all the pieces available, passed my $form and $vars through hook_preprocess_HOOK but in my tpl i would like the exact render() representation of the fields and variables and the form itself like:

print $form_tag.
      $form_input1.
      $form_input2.
      $theme_var1.
      $form_closure; <!-- build_id,token_id -->
 ?>

Where there are declared in the preprosess_HOOK as

$form = $variables['form'];
$variables['form_tag'] = render($form);
$variables['form_input1'] = render($form['input1']);
$variables['closure'] = drupal_render_children($form);
...

Is it possible to have all this variables of produced HTML in my tpl?
 like form start tag and closure and render correctly all the inner fields?
Thank you


texts: How to add two fields on one add another items?

texts:
I have 2 fields with unlimited values both fields show its own add another items button.
i am trying todo is add both fields add with one add another items button.


texts: Problem installing Devel module onto site

texts:
I went to drupal.org, copied the link for the Devel module, went to my site, New Module (under extensions) paste the link into the "Install from a URL" and when I hit Install it gives me the following error message: "Failed to fetch file due to error "cURL error 77: SSL: can't load CA certificate file /Applications/DevDesktop/common/cert/cacert.pem (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)"
Unable to retrieve Drupal project from https://ftp.drupal.org/files/projects/devel-8.x-1.0-rc1.tar.gz."

How can I fix this?


texts: How do I move more link to title of views block?

texts:
I am using Drupal 7 and Views, I created a block and a "more link" for showing on the frontpage.

How can I move the "more link" next to the title of views block?


texts: How to change default query plugin for views?

texts:
By default Views uses 'views_plugin_query_default' plugin.
How can I alter something so that Views could use another class for building queries?

I found one good example how to write Views query plugins:
building views query plugins

But this example is for custom tables. But I need to have my own query builder for ordinary node, terms and users tables.


texts: Moving content from dev directory to production server

texts:
When developing websites for clients, each developer has all sites under a relative path in his htdocs dir:

/client1site/
/client2site/
/clientsite/ and so on

Most links within the drupal installation, in content or image srcs have to be absolute to this path: /client1site/en/a-nice-article/ in order to work.

But when client 1's site goes to production, links stop to work because now the structure looks like www.client1site.com/en/a-nice-article.

The situation is general, in the sense that you can develop under a path /X/ and have to go to production under a path /Y/.

Can this be solved with an easy way without having to edit all content or image srcs by hand? Can some mod_rewrite wizardry save the day?


texts: How do I migrate a custom field from WordPress?

texts:
I'm working on migrating a fairly large blog type site from WordPress into Druapl 7. The WordPress Migrate module has imported the basic blog content very well (title, body, tags, etc), however there were custom fields set up in WP that do not import.

Looking at the xml file, there's really just one extra piece of info I need. A line for a video file (which is a code for a youtube video).

Here's how the code for this looks in the XML file:

    <wp:postmeta>
        <wp:meta_key>Video_File</wp:meta_key>
        <wp:meta_value><![CDATA[8ENbMuVQCYE]]></wp:meta_value>
    </wp:postmeta>

I have decent PHP experience, but the only customizing I've done in Drupal are relating to themes. Can I write a little addition to the WordPress Migrate module to insert this extra piece of info? Since the module migrates everything else nicely can I create a new little module that would go through the same xml file, find the matching node (by post date/time, title, some distinguishing piece of info from the xml file) and then add in the video info (assuming I would first create another row in the DB table)?

I'm at a bit of a loss, and since I need to bring in close to 1000 posts (most of which have the video code), I really need to fine a solution that doesn't involve me editing every single node by hand to add in the dang code.

I should also mention I currently don't have a CCK field in Drupal for the video code... that just dawned on me, so I'm off to create one and then re-migrate a portion of the blog (I downloaded it in multiple xml files for testing).

Update: Created that CCK field, re-imported the blog, and sadly it didn't work :) Not that I thought it would to begin with (nothing is ever that easy).

Update: I've been attempting to modify the WordPress Import module with little success thus far. This meta field is just some text, so I'm hoping to figure out where to add in the info I need to have it process correctly. I'm sure I need to tell it which cck field to insert the new data, just have to find it!

Another Update:
Working on adding a WP plugin to export all the content as a CSV, then going to use the Feeds module to attempt to import everything.

My backup is going to be to use the wordpress_migration module to import the basic stuff (title, body, tags, etc), then write a custom php page to add the video links... I'm basically thinking to find the title in the node table, grab the nid, then create the entry in the video_field in the db table. At least that's how it's currently laid out in my head, whether or not that works in real life remains to be seen.

Course hopefully Feeds works just fine and I won't have to try the backup!


texts: How to display discount for each product in checkout page?

texts:
I am trying to display in checkout table the initial price, the discount and the final price of each product. I followed this and this but with no result because I cannot find the fields mentioned in the first article in the checkout view.
How is it possible to achieve that?


texts:
I have a module with a menu which I build like this:

in moduleName.module

function moduleName_menu() {
  $items = array(
    'title' => 'whatever',
    'page callback' => 'something_callback',
    ...
    'type' => MENU_NORMAL_ITEM
  );
  return items;
}

Now I want certain items to be disabled (Clicking them should do nothing, similar to using disabled="disabled" on a <input type="button">). I tried adding '#disabled' => true, as I would do for form items, but that didn't work. How can I disable menu items?

UPDATE

I tried using myTheme_menu_link to disable the menu items. So in the code above, I add 'disabled' => true or 'disabled' => false to certain menu items. Then, my theme_menu_link function looks like this:

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

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  if (isset($element['disabled']) && $element['disabled']) {
    error_log('Hoping to see this somewhere in the log');
    $output = '' . $element['#title'] .  '';
  }
  return '
' . $output . $sub_menu . "
\n";
}

I test it by emptying all caches, which rebuilds the menu, but still, the error I'm trying to log never get's logged. It seems as though my 'disabled' => true never makes it to this function...


texts:
I am using the latest Entity Translation module in order to provide a couple of translatable fields for some of my content types. I have a content type which has a translatable field which is called "title_field".

I am using the Migrate module (version 2.0) in order to fill in the Drupal scheme with data from an old database. Normally, in a single language, the line would be:

$this->addFieldMapping('title_field','name')

Now the problem is that I have two translations of this field in my old database, which I want to create through the migration API.

$this->addFieldMapping('title_field','name_el')->arguments(array('language','el'));
$this->addFieldMapping('title_field','name_en')->arguments(array('language','en'));

Unfortunately this last one does not work. Any idea how I can go further with this?


texts: Views webform filter based on the current node field value

texts:
I have a Webform where it's used to get product comments. This webform is exposed in a node page and has a field that is populated automatically with a value from the current node, lets say "Manufacturer" and this is just a plain text field. So there are multiple products with the same manufacturer. For example Intel i5 2500k and Intel Motherboard Model-No-1.

I'm using the Webform 7.x-4.x for this. What I have done is use the Webform Submission Data field in Views to display the different data but now what I'm trying to do is when I go to a product, I want the view to filter all the Webform submission by the current product's manufacturer. So when I go visit the i5 2500k page, the view will list also the Webform submissions for the Intel motherboard.


texts: Where is the documentation for core associative arrays?

texts:
I have been using Drupal for a few months now at work. I love the developer documentation, but I have to say, I feel like its incomplete -- either that, or I just don't know where to find the other half.

I see documentation for functions and hooks everywhere, but I don't see any documentation for the format of core data structures.

Example one: this page from the official docs has extensive explanation on hook_wysiwyg_editor_settings_alter, but it gives no complete disclosure what the $settings parameter can contain.

Example two: this page from the official docs has great explanation of the concept of "Render Arrays" and the functionality thereof, but has no description of the format of the associative array passed to the render() function, causing me to var_dump($user_page) for hours and come up with monstrosities like: <?php echo $user_page["system_main"]["nodes"][$first_key]["field_objective"]["#object"]->field_targets["und"][0]["safe_value"]; ?> on my custom .tpl.php files.

Is this information in the code itself, or somewhere else?


texts: How to grant access to a user to all content created by certain users?

texts:
I've been looking all the options commented on Controlling Acces to Content Overview but I don't see any that allow one particular user to access all content created by other particular users.

Something like: User A have permissions to see all nodes created by users B, C and D.
(No need to include a reference or a taxonomy term to each node).

Any insights?

Thank you so much!


texts:
Okay, I am using the qTip (Stylish jQuery Tooltips) module to add tooltips to my page that has been laid out using inline styles (due to a consistency across browsers issue with the original theme css).

Question:  Is there a way to apply complex html inside of qtips tooltips?

I tried inserting HTML and destroyed my page, with just text qtips works perfectly.


texts: Prepopulate field collection programmatically

texts:
I have a content type with field collection field (unlimited cardinality). Each collection has image field (required) and long text field.

How can I prepopulate node form with multiple collections? I need node creation form to have lets say 3 collection widgets (+1 blank) with already uploaded images.

How can I generate field collection widgets? I tried to manipulate with $form_state['values'] and $form_state['field'] in hook_field_attach_form - but have no effect.

Module code at Github


texts: How can I hide the active language in the language switcher block?

texts: I have a site with two languages, but it's pointless to show the name of the currently selected language in the language switcher block.  How can I hide it?


texts:
Possible Duplicate:
  Check if current page is taxonomy term

For now, I use something like this to decide, if I'm on a taxonomy page.

if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
   $tid = intval(arg(2));
   $parents = taxonomy_get_parents($tid);
   $term = $parents[0];

   ...
}

Is there a more elegant way to decide, if I'm on a taxonomy page than this arg(0), arg(1), arg(2) thing?
Same would apply to a node page if (arg(0) == 'node' && is_numeric(arg(1))).

I didn't find any reference in the net. But maybe I ask the wrong questions.


texts:
I am planning to make blogging platform using Drupal 7. In which I am going to allow user to create his own site using my subdomain. Is this possible with Drupal 7?

Which modules I am going to need?


texts: How to translate the title, axis labels and legend of a chart?

texts:
I have successfully created a grouped bar chart using the Forena module.
My application supports English, Portugese and Spanish.

But I am not able to translate my chart to Spanish and Portugese.
I need to translate the chart title, labels on each axis and the legend.

Here is the chart I created so far:

I wonder how I can translate the following strings in this chart:

Biological and chemical indicators
Average of indicators
Positive biological indicators
non responsive chemical indicators


texts:
I'm looking for a way to add an extra class to a specific menu item in my main menu. I see ways to add classes to the entire menu, but not one specfic item.  Can someone point me in the correct direction.

This is for Drupal 7.


texts: Can't find cookie for validation in EventSubscriber

texts:
There's this module Splash Redirect in which src/EventSubscriber/SplashRedirectEventSubscriber.php is supposed to check if the cookie $config_cookie exists or not, if it already exists then the user continues onto the requested node ($config_source), but if it does not exist then the user is sent to $config_destination and it creates the cookie ($config_cookie).

It succeeds in creating the $config_cookie and the redirect to $config_destination but it never seems to acknowledge the existence of the cookie once created and continues to redirect the user to $config_destination.

Any clues? On Drupal 8.6

<?php

namespace Drupal\splash_redirect\EventSubscriber;

use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Routing\TrustedRedirectResponse;

/**
 * Splash redirect Event Subscriber.
 */
class SplashRedirectEventSubscriber implements EventSubscriberInterface {

  /**
   * Triggered when system sends response.
   */
  public function modifyIntercept(GetResponseEvent $event) {
    $config = \Drupal::config('splash_redirect.settings');
    $config_enabled = $config->get('splash_redirect.is_enabled');
    $config_source = $config->get('splash_redirect.source');
    $config_destination = $config->get('splash_redirect.destination');
    $config_cookie = $config->get('splash_redirect.cookie_name');
    $config_duration = $config->get('splash_redirect.duration');

    // If splash config is not enabled then we don't need to do any of this.
    if ($config_enabled == 1) {
      // Current request from client.
      $request = \Drupal::request();
      $current_uri = $request->getRequestUri();
      $http_host = $request->getHost();
      // Current response from system.
      $response = $event->getResponse();
      $route = (\Drupal::routeMatch()->getParameter('node')) ? \Drupal::routeMatch()->getParameter('node')->id() : null;
      $has_cookie = $request->cookies->has($config_cookie);

      // If splash-cookie has not been set, and user requesting 'source' page,
      // set cookie and redirect to splash page.
      if ($config_source == $route) {
        // Kill cache on this route or else cookie might not be read with VCL.
        \Drupal::service('page_cache_kill_switch')->trigger();

        if (!$has_cookie) {
          // Set redirect response with cookie and redirect location.
          $redir = new TrustedRedirectResponse($config_destination, '302');
          $cookie = new Cookie($config_cookie, 'true', strtotime('now + ' . $config_duration . 'days'), '/', '.' . $http_host, false, true);
          $redir->headers->setCookie($cookie);
          $redir->headers->set('Cache-Control', 'public, max-age=0');
          $redir->addCacheableDependency($config_destination);
          $event->setResponse($redir);
        }
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    // Listen for response event from system and intercept.
    $events[KernelEvents::REQUEST][] = ['modifyIntercept'];
    return $events;
  }

}


texts: How do I include ? and = in a form redirection?

texts:
I have a form and I would like to take the value from it, and use it as input for a page view which is created using exposed filters.
I have created a submit handler for my first form. I then redirect to the page view. The challenge is that I want to include search keys in the redirection. I can't figure out how to get this to work because the characters ? and = are converted.

I have created this function.

function my_module_my_button_submit($form, &$form_state) {
  $url = 'some-path/search?keys=' . check_plain($form_state['values']['input']);
  $form_state['redirect'] = $url;
}

The URL that is created from this is 'http://site/some-path/search%3Fkeys%3Dtest'; the URL I want is 'http://site/some-path/search?keys=test'.


texts:
I have installed the Linkit module to a test site.

I have created a profile, set Matchers and created attributes. I have gone into the CKEditor configuration and chosen my Linkit profile, added the Linkit button, saved the configuration and then liberally cleared the cache on my test site (Vagrant running a lamp stack and Drupal 8.)

When I attempt to use the Linkit feature on either a new piece of content, or an existing one, the dialog box appears with all the desired options, however, other than the standard CKEditor link behaviour none of the other attributes work. I cannot set the title, I cannot set the target attribute.

No errors are appearing in the log and I can find no similar problems on line.

Can anyone suggest a reason this is occurring?


texts: How to remove the webform title field on add/edit form?

texts:
I am using bartik responsive theme. I made a sub theme of the theme. I enabled the sub theme as the default theme. I have given access to anonymous users to add webform content at xxx.com/node/add/webform. Users see the title field as required. I like to remove the title field of web form so users dont need to enter the title.

I found this link but I could not follow it all the way:

link.

"You need to have both node.tpl.php and node-webform.tpl.php in your theme directory for this to work. Also make sure you clear your Drupal caches after copying the files in."

I went to theme directory(theme/xx/templates) and I see bartik, engines, garland, stark, seven. I dont see my sub theme and bartik responsive there. What would be my theme directory in my case?

I simply went to theme/bartik/template> copied node.tpl.php to node-webform.tpl.php and then added

<?php if ($page == 0): ?>

<a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?>

<?php endif; ?>

I still see the web form title field for public users at xxx.com/node/add/webform.

Do you know how I can remove the title field for web form module?


texts: The EU Cookie Compliance module doesn't display the message

texts:
I just downloaded the EU Cookie Compilance module 8.x-1.0-beta4 and the legal message doesn't show in my page.

First, I configured the module, and then set the Display EU Cookie Compliance popup permission for the anonymous user, but the message doesn't appear.

Why? What do I need to do to make it appear?


texts: AJAX submit ignored if comments form is loaded with AJAX

texts:
In D7, I have a custom module enabling AJAX form submission on comments forms.  That is working great.

I also have comments being loaded in the commentsblock module using block_refresh with the below snippet.  That works great to display comments and the form.  However, the AJAX form submission stops working.

I tried calling $Drupal.attachBehaviors() (seen below) and $Drupal.attachBehaviors($('#comment-form')) but it won't add AJAX handlers.

<script type="text/javascript">
  (function ($) {
    Drupal.behaviors.loadFirstSlideComments = {
      attach: function (context, settings) {
        $('#block-block-1 .content').once('load-first-slide-comments').load('/block_refresh/commentsblock/comment_form_block/node/2',
            function() {
              Drupal.attachBehaviors();
            });
      }
    };
  }(jQuery));
</script>

Any ideas?


texts: I have a taxonomy with lots of nodes in it. Each node contains a large image. I want that image to be linked to the next node within the taxnomy. How can I do this in Drupal 7?


texts: How to set up Apache solr search for Book Specific search

texts:
I have two books in my website (Drupal 7) and i am using Solr search.

I want to implement book specific search so that, if user is searching for Book1 content then it should show results from Book1 and not from Book2 and also let me know how to provide option of Book1 and Book2 near search bar so that we can filter the results.

I didnt find any module for this in drupal.Please provide me suggestions.


texts: How can I make a view that shows users all the who have flagged a single user?

texts:
Background

I want to add a tab to the user profile that shows the logged in user which other users have viewed his/her profile.  I want to control this list in Views.

Until recently, I have been using the User Visits module.  However, this module does not integrate with Views and is no longer actively maintained.

I started building this using Views, Rules, and Flag.  Specifically, I created a flag Viewed profile, and then made a Rule to automatically flag a profile when a user visits another user's profile.

I then created a view of users with two displays.

My View

The first display, Profiles I visited, has a relationship to the Viewed profile flag and simply lists all profiles flagged (visited) by the current user.  Easy.

Now I want to create a second display, Users who have visited me.  In this case, I want to display all the users who have flagged the  current user.  However, I can't figure out how to do this.

I can add a relationship, Flags (by any user), but there could quickly be 10,000+ such flags on my site, so I am worried about the performance implications of loading all the flags like that.  Also, even if I load all the flags, I don't see how to easily filter them to users who have flagged the current user.

Instead, it seems like it would be easier to create a second flag, User who viewed me, and attach both flags (Viewed profile and User who viewed me) with a rule at the same time when a user visits a profile.  However, this seems like unnecessary duplication of information to me, since both flags link the same two users at the same time.  Is there a more elegant way to display this data in Views that will not lead to performance issues down the line?


texts:
I am trying to create an online catalog of products, that could be filtered, sorted, etc, and I followed these steps:

I have created a content type (product)
I have created a view where I can view and filter/sort these products

Now, the major problem is to manually enter hundreds of products!
I have product descriptions in Excel, and image files with links, but I don't know how to upload everything in bulk.

How could I do this?


texts:
I want to return a "global" variable from a field template file

Assume I have a content type called "basic_page".  Basic Page has a field called "my_field".  In the template for basic page (node--basic-page.tpl.php), I render "my_field" by calling:

$fieldMarkup = drupal_render($content['field_my_field']);

In field--field-my-field.tpl.php I do whatever I need to do to return the field HTML / markup - no problems here.  But I want to return a variable to node--basic-page.tpl.php as well.  Is there a way to insert this variable into the node render array, or something of the sort?

I do not want to do this in a hook_preprocess function.  If there is no other option I will, but was hoping I can avoid this.


texts: "Drush cannot find your database connection details"

texts:
I'm having an issue that is baffling to me as a new user and I'm hoping someone here can answer me how to fix the error.  I'm trying to clone an existing drupal installation into a place on my mac with the commands

echo "Pushing private files"
/usr/local/bin/drush core-rsync @hpc.dev:%private @hpc.local:%private
echo "Pushing webroot files"
/usr/local/bin/drush -y core-rsync @hpc.dev @hpc.local
echo "Pushing database"
/usr/local/bin/drush -y sql-sync --no-cache @hpc.dev @hpc.local
echo "Clearing Drupal cache"
/usr/local/bin/drush -y @hpc.local cc all

This works fine until with the sql-sync piece, where I get the error:

... stuff stuff stuff
Command dispatch complete                                                             [notice]
Copying dump file from Source to Destination.                                      [ok]
Starting to import dump file onto Destination database.                            [ok]
/usr/bin/php /usr/local/drush-master/drush.php --php=/usr/bin/php  --backend=2        [notice]
--verbose --yes --strict=0 --root=/Users/cook47/Sites/drupal-test/html
--uri='http://localhost/~cook47/drupal-test'  sql-query
--file=/tmp/hpc-drupal-dev_20160302_005939.sql.gz --file-delete 2>&1
exception 'Drush\Sql\SqlException' with message 'Unable to find a matching SQL     [error]
Class. Drush cannot find your database connection details.' in
/usr/local/drush-master/commands/sql/sql.drush.inc:591
Stack trace:
#0 /usr/local/drush-master/commands/sql/sql.drush.inc(419):
drush_sql_get_class(NULL)
#1 [internal function]: drush_sql_query()
#2 /usr/local/drush-master/includes/command.inc(366):
call_user_func_array('drush_sql_query', Array)
#3 /usr/local/drush-master/includes/command.inc(217): _drush_invoke_hooks(Array,
Array)
#4 [internal function]: drush_command()
#5 /usr/local/drush-master/includes/command.inc(185):
call_user_func_array('drush_command', Array)
#6 /usr/local/drush-master/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#7 /usr/local/drush-master/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#8 /usr/local/drush-master/drush.php(12): drush_main()
#9 {main}

Something appears to be awry with my database on the localhost or perhaps with my alias.

Here is my alias for localhost:

$aliases['local'] = array (
  'root' => '/Users/cook47/Sites/drupal-test/html', //CHANGEME
  'uri' => 'http://localhost/~cook47/drupal-test', //CHANGEME
  //'remote-host' => "localhost",
  //'remote-user' => 'cook47',
  'path-aliases' => array (
    '%drush' => '/usr/local/bin/drush', //CHANGEME
    '%site' => 'sites/default/',
    '%files' => 'sites/default/files',
    '%private' => '../private',
    '%dump' => '/export/www/hpc-drupal-dev.llnl.gov/drush-dump.sql',//CHANGEME
  ),
  'target-command-specific' => array(
    'sql-sync' => array(//CHANGEME
      'enable' => array('devel'),
      'disable' => array(
      ),
    ),
  ),
  'command-specific' => array(
    'rsync' => array(
      'mode' => 'vrlzOk',
      'exclude-conf' => 1,
    ),
  ),
  'databases' => array (
    'default' => array (
      'default' => array (
        'database' => 'hpc-drupal-dev', //CHANGEME
        'username' => 'hpc-drupal-dev', //CHANGEME
        'password' => 'xxxxxx', //CHANGEME
        'host' => 'localhost',
        'port' => '',
        'driver' => 'mysql',
        'prefix' => '',
      ),
    ),
  ),
);


texts: Whats the correct way to programmatically include unpublished content in entity reference fields? (without views)

texts:
I have a node reference field whose options get reduced to those nodes in which the current user is referenced:

function mymodule_process_form_field_project_ref(&$field) {
  $field['#required'] = true;
  $field['widget']['#required'] = true;
  $options = $field['widget']['#options'];

  $project_nids = mymodule_user_get_referenced_projects();

  foreach ($options as $key => $label) {
    if (is_numeric($key)) {
      if (!in_array($key, $project_nids)) {
        unset($options[$key]);
      }
    }
  }

  $field['widget']['#options'] = $options;

}

The problem is, in $field['widget']['#options'] unpublished nodes are being removed in the first place. How to keep those? Do I have to define an own ServiceProviderBase class using the alter function?


texts: Connect to Intersystems Cache DB via ODBC

texts:
I'm trying to connect to an external data source within out intranet site. The database is Intersystems Cache. Our web-servers are running Cent OS 6.4, so I have setup the necessary unixODBC drivers to connect to it and this is successfully working. What I'm struggling to work out is how I access this data from within Drupal.

I know I could just call odbc_connect within my code, but this isn't the Drupal way. I also loose the benefits of Memcached etc.

Would it be possible to use PDO's ODBC driver, which I think Drupal uses anyway?

Thank you.


texts: How set specific input format for specific field like in Drupal 7?

texts:
I am in a need of the Drupal 7 functionality where I could select specific input format for specific field whereas in Drupal 8 this is based on permissions and I really dislike it and for a specific project I need the good old D7 behavior.

Right now I have to alter the input format's static cache during page load to achieve the goal of providing specific input format but it is very bad approach but I haven't found an easy way to do this yet.

Better yet, I need this for my custom form, not even a field but the permissions still apply so Field API has nothing to do with it but rather how the input formats and the text format element are tied together.

FYI this is my solution right now(it is ES service):

    $route_name = $this->routeMatch->getRouteName();
    $routes = [
      ...
    ];

    if (in_array($route_name, $routes)) {
      filter_formats($this->user);
      $formats = &drupal_static('filter_formats', []);
      $formats['user'][$this->user->id()] = [
        'my_format' => $formats['all']['my_format']
      ];
    }
  }


texts: How to modify if a field is required in a form?

texts:
Use case: I have added a required field for users. When user 1 (or an administrator) adds a user, the field should not be required.

Code that doesn't work (in Drupal 8):

function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'user_register_form') {
    if (\Drupal::currentUser()->id() == 1) {
      $form['field_fieldname']['#required'] = FALSE; // No effect
      $form['field_fieldname']['widget']['#required'] = FALSE;
    }
  }
}

Changing the widget "works", but the validation fails. The solution for Drupal 7 doesn't seem to be usable anymore.

$form['field_fieldname'][<lang>][0]['value']['#required'] = FALSE;


texts:
Ok, I need a bit of help with this one.

I have a website where I created a newsletter using Simplenews - works just fine, I'm sending some welcoming text + attached views of new things on site. But now I need to make something more with it.

I want to create new type of newsletter, that would be sent irregularly - or manualy as some would say. That is not a problem. Question appears here: I want admin to be able to create groups of users (manually again adding mails to the group etc.) for example, let's say I want to have two new groups for start:

group a
group b

And from time to time, admin needs to send a mail to all the email addresses in the selected group. How can I achieve that? Is even Simplenews a good idea in this situation? Or maybe there's some better tool?

Thanks in advance