texts: "Rendered" View style for a Taxonomy Term?

texts:
When creating a View for content Nodes, the "Format > Show" options includes "teasers" and "full posts" in addition to "fields". But for Taxonomy Terms, the only option appears to be "fields". I have Taxonomy Terms that have additional fields attached, and have the Display Preferences set to show/hide various fields for a teaser/full display of that term. Since different Taxonomy Terms have different fields, I want to use the Term's configuration rather than hard-code it into the View.

Is there a way to add a rendered View of a Term itself? Or do I need to create a separate View for each Term I want to summarize and define the "teaser" display again in the View?


texts: Why is this code to programmatically create a content type failing?

texts:
<?php

            function news_article_install() {

                // Define node type
                $news_article = array(
                    'type' => 'news_article',
                    'name' => 'News Article',
                    'base' => 'node_content',
                    'description' => 'A news article content type',
                    'body_label' => 'Article Text',
                    'custom' => 1,
                    'title' =>  1,
                    'title_label'   =>  'Headline'
                );

                // Save content type
                $news_article = node_type_set_defaults($news_article);
                node_type_save($news_article);
                node_add_body_field($news_article);
            }

?>

Edit: I've simplified the function as much as possible, still having errors. The errors now are...

Warning: Cannot use a scalar value as an array in _node_types_build() (line 689 of /Users/ryan/Sites/Drupal/modules/node/node.module).
Warning: Cannot use a scalar value as an array in _node_types_build() (line 689 of /Users/ryan/Sites/Drupal/modules/node/node.module).
Warning: Cannot use a scalar value as an array in _node_types_build() (line 689 of /Users/ryan/Sites/Drupal/modules/node/node.module).
Warning: Cannot use a scalar value as an array in _node_types_build() (line 689 of /Users/ryan/Sites/Drupal/modules/node/node.module).


texts:
I'm looking for a way to allow members of a specific role to share a control panel/settings page.  These users do not have admin level access and I would like to use the field api to store data.

Currently I'm leaning towards the Profile2 module, but this doesn't feel very robust.

Is there a common way to accomplish this that I've missed, a module that is better suited for this use case or am I on the right track using the Profile2 module?


texts: How to fetch views field label in hook_views_pre_render?

texts:
How to fetch views field label to modify in hook_views_pre_render ?

  function mymodule_views_pre_render(\Drupal\views\ViewExecutable $view) {
  if($view->id() == 'mytype'){
    // Here I want to fetch the field label but I am not getting how to fetch field label
  }
}


texts: How to schedule the execution of a Rules Action based on a webform submission date field?

texts:
How do I schedule the execution of a Rules Action based on a webform submission date field?

I have installed Webform Rules so I am able to use the Rules Event Webform submitted  to trigger the execution of a Rules Action. In my case, I want to schedule the execution of the Rules Action based on the date input of a webform field.

I have no problem scheduling the execution using node:creation time, but I need to use the date the user inputs.

I have not found any data-selector that let's me do this.

Any hint's will be much appreciated.

EDIT: I have found a link on StackOverflow that seems related to what I want to achieve.

https://stackoverflow.com/questions/5192108/how-do-i-schedule-a-rule-using-fields

That would reduce my question to : how do I use the Entity has field on a webform in order to make the field available ?


texts: How do I inspect mail messages in Behat tests?

texts:
I am  writing a Behat Scenario that checks that an email generated by the Drupal system under test is sent to the correct recipient but I [could not] capture the mail messages from test_mail_collector. How do I do this?

[Update]
The code below is essentially my current working version and should work for you ... at least as long as you don't have an anti-spam module interceding ... in which case see the extra code in my answer.

In FeatureContext.php I switch over to the mail system sender test_mail_collector in the @BeforeScenario tagged with @email and revert to the site's original mail system sender in the @AfterScenario tagged with @email.

However, [before I discovered my answer, there were] never any messages in the array returned by \Drupal::state()->get('system.test_mail_collector') when a scenario should generate them,

Here's a typical scenario:

...
@email
Scenario: Send an email when a user resets her password
Given users:
  | name    | mail           | status |
  | Jo User | jo@example.com | 1      |
When I visit "user/password"
And I fill in "name" with "jo@example.com"
When I press the "Submit" button
Then an email should be sent to "jo@example.com"

And here are the FeatureContext.php snippets:

...
/**
*  @Then an email should be sent to :recipient
*/
public function anEmailShouldBeSentTo($recipient)
{
  // Reset state cache.
  \Drupal::state()->resetCache();
  $mails = \Drupal::state()->get('system.test_mail_collector') ?: array();
  $last_mail = end($mails);
  if(!$last_mail) {
    throw new Exception('No mail was sent.');
  }
  if ($last_mail['to'] != $recipient) {
    throw new \Exception("Unexpected recpient: " . $last_mail['to']);
  }
  $this->lastMail = $last_mail;
}

/**
 *  @BeforeScenario @email
 */
public function beforeEmailScenario(BeforeScenarioScope $scope)
{
  $this->m_config = \Drupal::configFactory()->getEditable('mailsystem.settings');
  $this->saved_mailsystem_defaults = $this->m_config->get('defaults');
  $this->m_config->set('defaults.sender', 'test_mail_collector')->save();
  \Drupal::state()->set('system.test_mail_collector', array());
}

/**
 *  @AfterScenario @email
 */
public function afterEmailScenario(AfterScenarioScope $scope)
{
  // revert mail system after scenarios agged with @email
  $this->m_config->set('defaults.sender', $this->saved_mailsystem_defaults['sender'])->save();
}

The website is normally set up to run with swiftmailer enabled but I have tried all the other available mail system formatters and senders - like Default PHP Mailer - without success.

As a kind of "proof of setup" within FeatureContext.php, I can send test messages to the test_mail_collector:

$language_interface = \Drupal::languageManager()->getCurrentLanguage();
\Drupal::service('plugin.manager.mail')
    ->mail('test', 'test', 'jo@example.com', $language_interface->getId());

This shows me that the test_mail_collector is working - but messages generated from the website [were] not being collected.


texts:
I'm using the core Book module for organizing meeting notes and documentation. How do I create a list of books with the views module? That is, I'd like a list of only the top-level Books, not all the book pages.

An example of what I want in core is at admin/content/book which looks like this:

Thus far, all I've been able to get is a hierarchical list of books and all book pages. Current view:


texts: Custom module for adding CSS file in admin section

texts:
How do I include admin.css in my theme so that it's loaded in the admin section (and preferably only the admin section)?

Right now when I add admin.css via the x.libraries.yml file, it's only loaded on the front-end.

Update:

So... based on your comments/answers I've created a module admin-css. But nothing happens. The file isn't loaded. What am I doing wrong?

Inside admin_css.info.yml :

name: Admin CSS
description: Alters the Admin CSS for better usability.
package: Custom

type: module
core: 8.x

Inside admin_css.libraries.yml :

admin-css:
  version: 1.x
  css:
    theme:
      css/admin.css: {}

Inside admin_css.module :

<?php

function admin_css_attachments(array &$attachments) {
    $is_admin = \Drupal::service('router.admin_context')->isAdminRoute();
    if ($is_admin) {
      $attachments['#attached']['library'][] = 'admin_css/admin-css';
      return;
    }

}


texts: Fivestar being cached for anonymous users!

texts:
On enabling caching for anonymous users, it appears that the fivestar votes are also being cached, which is super-weird.

On disabling caching for anonymous users, things work great.

We use memcache, could that be a problem? Any suggestions about how I should go about this?

From https://drupal.org/node/285855

  "When "Caching mode" is enabled (admin/settings/performance),
  anonymous users don't see changes in rating. Every anonymous user see
  rating as it was when first anonymous user visited node.

  When cache is disabled anonymous users see rating correctly.

  Is there some way how to use Drupal caching and at same time make
  fivestar working for anonymous users?"

Fix -:

  "Change caching time to 1-5 minutes, will make it seem that as the
  amount of time it took for his vote to register."

Is this the only possible fix?


texts: How to use multiple text fields in widget "image" in content type

texts:
I'm new in Drupal and I'm working on a website built in Drupal. I want to use multiple text fields like title, medium, photo credits with image widget in content type. I have attached two screen-shots to make clear what I really want to do.

Please help to find out the way to do this. I'll be thankful to you.


texts: How can I programatically get the cart's dollar sum of drupal commerce?

texts:
For future users <?php echo  '$' . number_format(( $total['amount'] /100),2); ?> is how.

Following this guide http://kahthong.com/2012/08/programmatically-show-number-items-drupal-commerce-shopping-cart I got the cart item total using

<?php
global $user;
$quantity = 0;
$order = commerce_cart_order_load($user->uid);
if ($order) {
    $wrapper = entity_metadata_wrapper('commerce_order', $order);
    $line_items = $wrapper->commerce_line_items;
    $quantity = commerce_line_items_quantity($line_items, commerce_product_line_item_types());
    $total = commerce_line_items_total($line_items);
    $currency = commerce_currency_load($total['currency_code']);
}
print format_plural($quantity, '1 item', '@count items');
?>

however when I try to get the dollar total using <?php print $total; ?>, it just returns 'Array'.

I used Devel on the page, but the cart is just a bunch of markup in ['content']['system_main']['main']['#markup']. What I want is $106.00, is there a way I can grab that class specifically with php somehow? Or maybe there's another way to go about this.


texts: Recover the field from one Drupal page to another

texts:
What I want to do is recovering the avatar picture the Avatar Selection module generates, and present it elsewhere in my Drupal installation, specifically in pages where it is not appearing.

I have been referred to the dsm() function, but not being a programmer, I am utterly lost with this. I haven't got a clue.
I know that I need to know the field's name, where the picture is showing and then I can render it, but while I know all this, I have no clue as how to do it or if this is all I need.

I haven't found (or haven't understood) any dsm() tutorials out there.


texts: Organic groups automatic audience selection

texts:
I am working with organic groups. Within each group, permitted users are allowed to create their own pages.

What my problem is that I need to set the audience for a new page automatically as the group the user is currently in.
This is so that the user cannot manually change the group the post should go into but instead it's automatically and permanently set ( unless an administrator changes it ).

Does anyone know of a way that I might accomplish that?


texts: How to display previous and next arrows in views

texts: I am trying to create a views block that will display one item on a page. I like to display next and previous arrows but I see the next arrow by default and I do not see the previous arrow until I am on 2nd page. I can remove the numbers but how can I display only next and previous arrows by default?


texts:
I'm doing a D7 to D8 custom migration. In Drupal 7, I have a multi-value formatted text field that I am trying to map to a Drupal 8 multi-value Paragraph entity reference field.

I've separated this into two migrations. One for the paragraphs, and one for the nodes themselves. I've got the multi-value field to paragraph migration working (although I think there might be an issue with the way that I have done the IDs). I have the node migration working as well, with the exception that none of the references to the already migrated paragraph entities are being migrated.

I realize that right now, this seems unnecessary, but it's part of a feature upgrade.

Below is the code from my migration classes/plugins.

This is from migrate_plus.migration.presentation_node.yml.
Field_slide is the paragraph reference field.

'field_slide/target_id':
  plugin: migration
  migration: presentation_slide
  source: entity_id

This is the getIds function from PresentationSlide.php. This is the plugin for the paragraph migration.

public function getIds() {
  return [
    'entity_id' => [
      'type' => 'integer',
      'alias' => 'lt',
    ],
  ];
}

This is also from PresentationSlide.php. Here I am combining the entity_id and delta to form a unique id. I realize that this is a terrible way to do this, but I couldn't figure out anything better. Any tips on this are welcome.

public function prepareRow(Row $row) {
  $nid = $row->getSourceProperty('entity_id');
  $delta = $row->getSourceProperty('delta');
  $slide_id = (string) $nid . (string) $delta;
  $slide_id = (int) $slide_id;
  $row->setSourceProperty('entity_id', $slide_id);

  return parent::prepareRow($row);
}

And this is from PresentationNode.php. Here I am fetching all of the referenced fields, and passing that as an array to the migration class.

public function prepareRow(Row $row) {
  $nid = $row->getSourceProperty('nid');
  $query = $this->select('field_data_field_learning_text', 'lt')
    ->condition('entity_id', $nid);
  $query->addExpression('CONCAT(entity_id, delta)', 'target_id');

  $slides = $query->execute()->fetchCol();

  if (!empty($slides)) {
    $row->setSourceProperty('entity_id', $slides);
  }

  return parent::prepareRow($row);
}

The main issue here is that I can't figure out how to properly use a multiple column key. It seems to me that all of my issues are due to my doing this improperly.

Thanks in advance. I realize this is a lot.

[Edit]

Thanks Berdir for the help. I've taken a stab at implementing your processing plugin. However, I'm having an issue where the migration seems to be skipping right over and ignoring the process plugin.

field_slide:
  plugin: paragraph_process_base
  source: field_body_value

Feel like there is something super simple that I'm missing here.

[Edit 2]
And I had a typo... Thanks a ton!


texts:
I've this layout:

This is perfect on large-small screen. But not adapt for what i want to displayed on mobile.
Displayed:

col1 col2 col3

 col4

How can i get this: col3 and col4 reodered on mobile.
Like this:

col1 col2 col4

 col3

So col4 change from row2 -> row1, col3. And cal3 get from row1 -> row2, col4. Just on mobile.
Note: This is to be applied just on mobile/small screen. For the display is fine for midle and large screen.


texts:
I've created a @RestResource plugin to provide a REST endpoint to get some data, but when I try a GET from Postman it shows this error:

  {
      "message": "The 'restful get ez_share_document_resource' permission is required."
  }

I thought it was because I need to add something else, so I decided to enable the Watchdog database log REST resource to prove it, but I got the same error:

  "message": "The 'restful get dblog' permission is required."

Rest module has set bc_entity_resource_permissions  as false.

This is the annotation of the plugin.

/**
 * Provides a resource to get view modes by entity and bundle.
 *
 * @RestResource(
 *   id = "ez_share_document_resource",
 *   label = @Translation("Ez share document resource"),
 *   uri_paths = {
 *     "canonical" = "/ezshare/{ezshare_id}"
 *   }
 * )
 */
class EzShareDocumentResource extends ResourceBase {

And this is my get method:

public function get($ezshare_id = NULL) {
    if ($ezshare_id) {
      $record = ['It Works!!'];
      if (!empty($record)) {
        return new ResourceResponse($record, 200);
      }

      throw new NotFoundHttpException($this->t('EzShare doc with ID @id was not found', ['@id' => $ezshare_id]));
    }

    throw new BadRequestHttpException($this->t('No EzShare doc ID was provided'));
  }

Drupal core is recently updated to 8.8.1.


texts: 'hook_field_widget_form_alter' but for markup

texts:
I have content type which has term reference as a field.
I want add some html attributes to each option in select on form (when adding new node of that content type).

'hook_field_widget_form_alter' is right place for custom code but not for HTML markup. How I can change display of this select?


texts: \Drupal::currentUser() returns admin account info instead of logged in user

texts:
The following function resides in a .module file:

function user_menu_avatar_menu_links_discovered_alter(&$links) {

    $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
    $name = $user->get('name')->value;
    $userMenuAvatar = $user->get('user_picture')->entity->url();

    $links['user.page']['title'] = $name;

}

When logged in as another user, I am only getting the account info from the Admin user account. User name, email, etc..

What am I missing?


texts:
I'm new to apachesolr/solr/drupal so please be patient (:

I have running solr-4.10.3 inside tomcat 8 and have "successfully" connected to it from drupal 7 via apachesolr.

The solr core that I've set up is already populated with external data and I can search it successfully from the SOLR web interface. The population was not done through drupal/apachesolr indexing mechanism, but directly into solr.

How can I search my data?

I can see my fields when I go to

http://localhost:8080/site/#overlay=admin/reports/apachesolr/solr

but they are all listed as "NOT INDEXED"

I'd appreciate any help or advice.

Nat


texts: Same menu display only a couple of levels down when used normally but when used within the "Site map" module it would display all the levels?

texts:
In order to display all the links using the "Site map" module I am adding everything we want in our site map to the primary links menu, going in as many levels deep as I need. Then I don't actually display all the levels in our menu but the site map will display all the links within the primary links menu.
Is there a way to have the same menu display only say a couple of levels down when used normally but when used within the "Site map" module it would display all the levels?


texts:
I put this function in my inc file

function getLanguage(){
  $url=url() ;
  $language="";
  $pos=strpos($url,"/es");
  if ($pos===false){
    $language="en";
  }else{
    $language="es";
  }
  return $language;
}

And then I try to call that function from the module, but the module says Fatal error: Call to undefined function getLanguage()

What am I doing wrong? thanks


texts: Problem with Views 7.x-3.0 - Column not found

texts:
I just updated the views from 7.x-3.0-rc1
 to version 7.x-3.0 and now I'm getting the following error when executing my view:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_category.nid' in 'on clause'

The generated query looks like this:

SELECT node.title AS node_title,
       node.nid AS nid,
       node_field_data_field_category.title AS node_field_data_field_category_title,
      'node' AS field_data_field_color_node_entity_type,
      'node' AS field_data_field_image_node_entity_type,
      'node' AS field_data_field_sale_node_entity_type
FROM {node} node
LEFT JOIN {field_data_field_category} field_data_field_category ON node.nid =
                                      field_data_field_category.entity_id AND
                                      (field_data_field_category.entity_type = 'node' AND
                                      field_data_field_category.deleted = '0')
LEFT JOIN {node} node_field_data_field_category ON field_data_field_category.nid =
                 node_field_data_field_category.nid
LEFT JOIN {field_data_field_gender} field_data_field_gender ON node.nid =
                                    field_data_field_gender.entity_id AND
                                    (field_data_field_gender.entity_type = 'node' AND
                                    field_data_field_gender.deleted = '0')
WHERE (((node.type IN  ('product')) AND (node.status = '1') AND
        (field_data_field_gender.field_gender_value IN  ('0', '1'))));

I see that the field_data_field_category.nid should be field_data_field_category.field_category_nid, but how do I solve this without using something like hook_query_alter?


texts: Link to user edit form within a GUI made menu

texts:
I have a menu created through admin/structure/menu.  I would like to add a link to the logged in users edit profile.

I am attempting to do this via module.links.menu.yml but it is not working.  The following two iterations are at least throwing errors, previous iterations did not throw errors or add the item to the menu.  The errors are thrown when I visit admin/structure/menu/manage/account

Note that I'm only using the account for menu_name during testing.

dashboard.agent.edit:
  title: 'A new edit link'
  route_name: entity.user.edit_form
  menu_name: 'account'
  route_parameters: {user: ''}

This one throws the error Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "user" for route "entity.user.edit_form" must match "\d+" ("" given) to generate a corresponding URL.

dashboard.agent.edit:
  title: 'A new edit link'
  route_name: entity.user.edit_form
  menu_name: 'account'

This one throws: Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("user") to generate a URL for route "entity.user.edit_form"

Am I missing something that would allow me to accomplish this?  Is there a different way I should be doing this?


texts: D7+ i18n: What is the normal way: a single node with 2 translations or a different node for each translation

texts:
I am having a difficult to understand this issue:

My D7 + Internationalization create a different node for each translation. Is this the normal way? Than how does Drupal know they belong to a same article.
I remember in D6 was one node and one editing page for all the translations of the articles.

I think the normal way is to keep a single node and different paths with different prefix: /fi or /en.

What do you think?


texts:
I have a field in my content type for blood pressure which, as you may or may not know, is measured ##/###. Currently, I have one text box and I ask the users to enter data in the form ##/### which works well but, on phones the '/' characters is annoying to navigate to. I was wondering how I could split up the field some that it would be 2 input fields separated with a '/' like:

Blood Pressure
[   ] / [   ]

Where [   ] represents a input field.

Any other suggestions to solve this problem would be great as well.

Thanks


texts:
I have a form built and need a fieldset to collapse/expand based on the value of another checkbox field.

The checkbox code is:

$form[$serving_key] = array(
        '#type' => 'checkbox',
        '#title' => t($serve_size)
);

The fieldset is:

$form[$fieldset_key] = array(
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#states' => array(
            'expanded' => array(
                ':input[name="' . $serving_key . '"]' => array('checked' => TRUE)
            )
        )
);

These are in a foreach loop, and $serving_key at any point is 'serving_large', 'serving_small', etc.  The corresponding $fieldset_key is 'fieldset_large', 'fieldset_small', etc.

This looks like it should work in the form_example_states_form example code.  What am I missing?


texts: How db_query works when I pass query parameter directly

texts:
I have one doubt for db_query in drupal 7, as in documentation db_query syntax is like

$result = db_query('SELECT n.nid, n.title, n.created
FROM {node} n WHERE n.uid = :uid', array(':uid' => $uid));

But what happens when I write query like.

$result = db_query("SELECT n.nid, n.title, n.created
FROM {node} n WHERE n.uid = $uid");

Is it still convert in PDO prepared statements?
Is it still reliable as first query?
Will it handle SQL injection?


texts: Show a block if the page content has a specific taxonomy term

texts:
I've got a content type (Brands) and a taxonomy vocab (Product Type) with a few options, so you can "tag" a brand with a specific product type. Using Views I'm filtering my content on my pages depending on the taxonomy term.

I've got a Views block (I'm also using this block as a dropdown in my navigation with the Menu Views module) that lists all the brands tagged with a specific taxonomy term. What I want now is that this block also shows up in my right sidebar on all the pages that display content of 'Brands' and are tagged with a specific term from my taxonomy vocab.

Example (menu structure):

* Product Type A
  - Brand 1
  - Brand 2
  - Brand 3
* Product Type B
  - Brand 2
  - Brand 4
  - Brand 5

If I'm on the 'Brand 1'-page, the 'Brands' list under Product Type A should show up in my right sidebar.

I can't filter using the 'normal' way since its the same content type, and the same taxonony vocab. And by the 'normal' way I mean using a URL pattern for the content type and then use
contenttype/* on my block config page.

Sidenote: I'm also adding a class to my <body> using hook_preprocess_html() for all the brand pages. So all the brands tagged with Product Type A have a class of product-type-a on their <body> field. Is there a way so show/hide blocks depending on a class through code?

Thanks.


texts: Reset frontpage after changing it to user

texts:
I wanted my drupal site content to only be accessed by users who login.
I have a front-page which works fine:   "mysite.com/"
I want users to be re-directed to:
"mysite.com/user"  or   "mysite.com/?q=user"

So, I went into the Admin > Site Configuration > and changed the front page to be /user

Unfortunately, my home page is exactly the same, no change there, and now I can't access the login to get back in as an Admin.

So, there are two questions:

1) How do I go into the database to reset this setting by hand, or is there a php file I have to go into?

2) Once I get my home page back, and the /?q=user page working again, how can I force users to that page to login before anything that happens.

This is Drupal 7 ... I remember Drupal 5 and 6 being so much easier to manage.

I am also using the MD Apline theme if that matters ....

Thanks for any help!
                               Tom


texts: How do I display a help text with field form?

texts:
Is there a way to bring up a help message next to a form field as below?

FooForm.php

$form['field_foo'] = array(
    '#type'          => 'textfield',
    '#title'         => t('Foo'),
    '#required'      => true,
    '#default_value' => 'foo',
    '#help_text' => 'Help text for Foo field',
);


texts: Creating multiple custom blocks in drupal 8

texts:
├── hello_world
│   ├── hello_world.info.yml
│   ├── hello_world.module
│   ├── hello_world.routing.yml
│   └── src
│        ├── Controller
│        │   └── HelloController.php
│        └── Plugin
│             └── Block
│                  └── HelloA.php
│                  └── HelloB.php

I have used the above file structure to create blocks in Drupal 8. Both the blocks, HelloA as well as HelloB works, but only one at a time. I see block HelloA, if I remove HelloB.php and see Block HelloB when HelloA.php   is deleted. I am trying to create multiple blocks. Please guide me. Thank you very much.


texts: Drupal adding some sort of hash on end of clean URL?

texts:
The site is working normally otherwise, but junk like this: #.ULQf0OOe90s is added onto the end of every URL.

Any ideas why this might be?

Thanks


texts: Feeds tamper to find element in text and replace it with part of the element or 0

texts:
I have a set of HTML pages that I'm importing (regularly) into a Drupal site using Feeds and Feeds Tamper.

One of the elements in the feed can take one of two forms:

Birth 1869 Location Merthyr Tydfil, Glamorgan, WalesG

or

Marriage Calculated 1894 (i.e. without a Location section).

The feed contains an unlimited number of these elements which will be imported into a multivalued Field Collection attached to a node.

I need to extract part of the Location section (a latitude) or if there is no Location provide a default value of 0.

I'm using the Find Replace Regex plugin to extract the latitude and add a pipe character (to allow me to Explode the results into an array).

My find regex currently looks like:

.*?Location.*?"gs-pl".*;q=(.*?),(.*?)".*|.*

which either identifies the latitude or returns the full string if there is no Location element.

My replace regex looks like:

\1| which works fine for the case where the Location element exists.

However, I can't see how to replace any empty string returned (i.e. when the capturing group is emtpy) with a figure 0.

Is this possible using the Find Replace Regex plugin, on its own or in combinations of other tampers as well? I wondered if I could process the original element to add a Location element with the values required as a default if it was missing but that still involves a conditional replacement so it's essentially the same problem.

I can't set insert missing Location elements in the HTML before the import, and setting the default value in the String Collection doesn't work because of the way field collections are imported (basically the method I'm using puts the data in the wrong field collection item if there are any empty fields)


texts: Hooking in to the email verificatin process

texts:
In Drupal 7 (7.22), we'd like to hook into the email verification process for new users.  Perhaps the one time password node.  We need to do a test on the email address and set a value in a custom user field based on what we find.  This will allow us to give software activation terms to users with email matching certain business partner domains, for example.

Extra credit: we'd also like to enable a particular role for these users.  The first step, though, is to figure out where to hook in our php to do a regex test of $user->mail.


texts:
I have a site which is setup with 2 languages. Primary language is English.
If I do a search in English then I can find all content and get search results. When searching in the second language I only get results if the search term is present in content in both languages.

So if Node23 has the word "plant" in both English and the translation in the 2nd language too then I will have a search result in the 2nd language. Result shown is in the 2nd language.

If node23 contains the word "plant" only in the 2nd language then I get no results.
What can I do to fix this issue? Looks like indexing only takes place on the primary language and when found it is displayed in the second language.

I tried built in search, Display suite search and Search configuration module.
Very strange behavior if you can build a multilingual site but can not search.


texts: How to determine screen size using the context module programatically?

texts:
I have created a node template that needs to display content differently depending on screen size. Basically I have quicktabs being rendered horizontally when in desktop mode and then would like to display those quicktabs in accordion mode when in mobile view.

I have the context and context breakpoint module installed. I would like to know what the current screen resolution is so that I can display the quicktabs accordingly. The module talks about cookies containing that information but I when I look at the cookie, there is no information there. I was wondering if there is a function call to get this information.


texts:
I'm trying to implement two rows rather than one in the JCarousel module in Drupal. I have tried hacking the module, but only achieve some level of success thanks to some codes online. The problem I have is separating the first row from the second, the current situation is they are joined together so they look like one column. Below is the code. I use wrapper divs and applied padding and margins but no success. Maybe someone with a bit more knowledge could assist me.
     ">

<?php $i=0; $rows_number=2; //you can change the number of rows ?>
<?php foreach ($rows as $id => $row): ?>
<?php if($i%$rows_number==0) : ?>
<li class="<?php print $row_classes[$id]; ?>">
<?php endif; ?>

<?php print $row; ?>

<?php if($i%$rows_number==($rows_number-1)) : ?>

<?php endif; ?>
<?php $i++; ?>
<?php endforeach; ?>
<?php if($i%$rows_number!=0) : ?>

<?php endif; ?>


texts: How can I programmatically delete a custom menu?

texts: I'm writing a hook_deploy_N that moves a bunch of menu items from a deprecated custom menu to some newer ones. So far, so good. After moving the items, I want to delete the old menu, but can't figure out how. \Drupal\Core\Menu\MenuTreeStorage has a delete function that may be  what I'm looking for, but the \Drupal\Core\Menu\MenuTreeStorage object is housed inside the \Drupal\Core\Menu\MenuLinkTree, which I can at least load, but has protected status, and I don't see a way to get to it. Plus, I'm not not 100% convinced that's what I want any way.


texts: How do I remove the information section available below the comment box?

texts:
As shown in the image, below the comment text-area there is an information section I do not want to show. How do I remove the part highlighted in red?

I want the comments to appears as they do on StackExchange, where user just have a text-area for entering their comments.


texts: how to render profile2 type fields with default user registration form in custom block?

texts:
i installed profiel2 type module  and make different profile types.Now i make a custom module and wants to display that profile type fields in custom block of that custom module.
the main problem is that i also wants to display default user registration field with created profile type fields in my custom block.


texts: Database Connection error by giving specific IP address

texts:
I have created database and user and give all the privileges to the user. When I give the IP as database host, it will show the following errors. Giving database host as localhost it will work fine.

I am using phpmyadmin 3.3.2...

The error message is given below.

  Failed to connect to your MySQL database server. MySQL reports the
  following message: Can't connect to MySQL server on '192.168.85.10'
  (111)


texts: How do I execute my custom submission handler before any other submission handler?

texts: I want to execute my custom submission handler for a button before any other submission handler associated with that button. How could I do this?


texts: How to remove the Day field from the Date drop down?

texts:
on this page http://dev.amnesty.io1developer.com/donate-now
under the section of the Credit card,I want to remove from the date the Day field.
It is a webform.How to achieve this?
Thanks


texts: How to implement question/answer functionality with following feature?

texts:
I would like to create a question/answer website using Drupal7, where a user can ask a question and other users can answer that question. This one is very simple to implement in Drupal 7. But what additional feature i want is when a user asks a question he will set the expiration period also by choosing from a select list (5Days, 7Days and 15Days etc). Within this duration the STATUS of the question should be shown as "OPEN for Answer". After this period, the STATUS should be changed to "Finalizing Best Answer" automatically and now no new answer can be submitted by any user and after the best answer is selected by the asker, the STATUS should change to "CLOSED" automatically. But the asker of the question can change this STATUS at any time from "OPEN" to "CLOSED" even befor the expiry set by himself, but he can not change any other field of the question form once a question is published. How should i implement this type of functionality in my content type? Please provide your views for this type of functionality.
Thanks!!


texts: Get node url alias/path when loading the node using node_load()

texts:
Does the node_load() does not return the node url alias in the node object or am I missing something.

I know one way of getting the url alias/path is using the drupal_get_path_alias("node/NODE_ID"), however I was hoping the object return by node_load should contain node url alias as well.


texts: how to display our custom profile link when drupal installation setup

texts:
I'm working on custom profile making in drupal 8. That's my first custom profile. It's completly done with module installation & entity created. But when I'm running installation it doesn't ask me for selecting profile like standard, minimal, custom profile.

How could I do that please help.


texts: Should we document AJAX-callback parameters?

texts:
Considering the PHPCS warning:

  phpcs: Hook implementations should not duplicate @param documentation

Is there any way to tell PHPCS that the function is an AJAX-callback (so that such warnings are generated)?

Or, Should we document all AJAX-callback parameters, with @param PHPDoc?

Background:

There was a discussion in our company about the below AJAX-callback function:

/**
 * Prevents popup's redirection from dashboard to another link.
 *
 * Users were redirected to another page as soon as the Event-creation
 * popup form was submitted, just added an AJAX handler to submit button
 * which prevents the redirect using ajax,
 * and when there is any error on the form, the message is sent to the popup.
 */
function _MYMODULE_popup_submit(array &$form, FormStateInterface $formState) {
  // ...
}

Where one developer insisted on adding @param PHPDoc comments to each AJAX-callback like:

/**
 * Prevents popup's redirection from dashboard to another link.
 *
 * Users were redirected to another page as soon as the Event-creation
 * popup form was submitted, just added an AJAX handler to submit button
 * which prevents the redirection using ajax,
 * and when there is any error on the form, the message is sent to the popup.
 *
 * @param array &$form
 *   All data of the form.
 * @param \Drupal\Core\Form\FormStateInterface $formState
 *   State of the form.
 *
 * @return \Drupal\Core\Ajax\AjaxResponse
 *   Returns the data back as AjaxResponse object.
 */
function _amt_dayview_popup_submit(array &$form, FormStateInterface $formState) {
  // ...
}

And the other considered it as understandable and that it should not be documented:

  ... remember that PHPCS will warn you every time we use @param on any hook, like "phpcs: Hook implementations should not duplicate @param documentation", and just because PHPCS can not differ AJAX-callback from normal functions it does not mean that we should do this ...

Edit: The feature request is created for this on Drupal.org.


texts:
I'm a little bit new in Drupal but experienced in PHP.
I would like to migrate data from CSV and assign to existing nodes in DB.

My question is about the possibility to match processing rows with existing data from the database.
I mean, I have CSV file with data and with foreign key called: SERVICE_ACTION and now I would like to assign that data to existing NODE which hasn’t SERVICE_ACTION key but has different KEY which is assigned to another specific entity with Service Action key. How can I get ID of that entity in migration script to assign?

Perhaps, I need target_id to assign newly created paragraph to the specific node. I’m not sure what I’m working bad.

langcode: en
status: true
dependencies:
  enforced:
    module:
      - xxx_migration
      - paragraphs
id: xxx_release_notes
migration_tags:
  - custom-migrate
  - soap-apis
migration_group: xxx_soap_api
label: 'xxx release notes'
source:
  plugin: csv
  data_fetcher_plugin: file
  path: modules/custom/xxx_migration/artifacts/releases_notes.csv
  header_row_count: 1
  keys:
    - id
  column_names:
    -
      id: 'Unique Id'
    -
      title: Title
    -
      body: 'Post body'
    -
      service_action_code: 'Service Action Code'
process:
  type:
    plugin: default_value
    default_value: people
  field_service_action_code:
    plugin: migration_lookup
    migration: xxx_release_notes
    source: service_action_code
destination:
  plugin: 'entity_reference_revisions:paragraph'
  default_bundle: release_note
migration_dependencies:
  required: {  }
optional: {  }

here is my CSV file:

id,title,body,service_action_code
1,TITLE,example body,PassengerDetailsRQ
2,TITLE2,example body2,ePaymentRQ


texts: Ctools content type- How do I access a context that is provided by a panel page?

texts:
I'm trying to add a ctools custom content type to the user profile override provided by panels.

I have added a context, Logged-in user.  I can access the values of this variable in my custom content type like this:

dpm($context['context_user_1']);

However, I also want to access the values for user-being-viewed, which is available in the user profile page by default.  With the devel module, I can see the variables are in $context under argument_entity_id:user1, but I can't access them like this:

dpm($context['argument_entity_id:user1']);

How can I access the variables of a context provided by default in Panels?


texts:
After releasing Drupal8-beta-15 we decide to migrate some of sites to Drupal8.
I read this article about how to migrate to Drupal 8, But I have some problem with it, I know when I want use a views in another website ( in Drupal 7) I can export/import it  or also use Features but now I don't know how I can migrate my views from Drupal 7 to Drupal 8.

How can I migrate a view from Drupal 7 to Drupal 8?


texts: Insert data in table using drupal form alter submit

texts:
I am currently work with a drupal's inbuilt form which is coming from it's system function.
Now I added a extra field with value in the form with Drupal's custommodule_form_deal_node_form_alter().
It is working perfectly.
But my problem is How to insert the value in the database with the default form's value. As the form's has its own default submit function.  I know it may be done using custommodule_form_deal_node_form_alter_submit($form,$form_state)
But dont know how to merge my value with the default form's submit function.
Please help me.


texts:
I would like to print out the result of this method and check out what the input is.

  public function handleAutocomplete(Request $request, $target_type, $selection_handler, $selection_settings_key) {
    $matches = array();
    // Get the typed string from the URL, if it exists.
    if ($input = $request->query->get('q')) {
      $typed_string = Tags::explode($input);
      $typed_string = Unicode::strtolower(array_pop($typed_string));

      // Selection settings are passed in as a hashed key of a serialized array
      // stored in the key/value store.
      $selection_settings = $this->keyValue->get($selection_settings_key, FALSE);
      if ($selection_settings !== FALSE) {
        $selection_settings_hash = Crypt::hmacBase64(serialize($selection_settings) . $target_type . $selection_handler, Settings::getHashSalt());
        if ($selection_settings_hash !== $selection_settings_key) {
          // Disallow access when the selection settings hash does not match the
          // passed-in key.
          throw new AccessDeniedHttpException('Invalid selection settings key.');
        }
      }
      else {
        // Disallow access when the selection settings key is not found in the
        // key/value store.
        throw new AccessDeniedHttpException();
      }

      $matches = $this->matcher->getMatches($target_type, $selection_handler, $selection_settings, $typed_string);
    }

    return new JsonResponse($matches);
  }

}

It is quite difficult to print it out because it's deep in the code. And in a form, when you post, the page is loaded 2 times.

Generally, print_r() or var_dump() is enough for me to debug, but in this case, I can't just simply use them, so debugging this code is a bit challenging.

Is there any helper class/function I can use to trace/inspect the code?


texts: How to Filter Node Reference Field Values Using Multiple Views?

texts:
I have a node reference field called field_parent_dept. I re-use this field in several content types.  The list of nodes that can be referenced are provided by a view.  The values are filtered based on logged in user.

I'd like to add this field to a new content type, but the departments need to get filtered in a completely different way.  I need a new view to accomplish the filtering.  It appears I need to create a new field, because the view is a field setting.  Field settings apply to the field everywhere it is used.

Are there any other options?


texts: I'm building a site with two webforms on one page, both with AJAX enabled. While the first form works perfectly fine, the second page refreshes after submission (it doesn't refresh if there's an error in the input). What should I do so that the two forms never refresh the page?


texts: Custom Block - How to get additional variables

texts:
I am new to Drupal and slowly getting my head around it.
I'm using Pay to Publish module on my site, I've setup a custom block that gets recent posted advert (very simple) now I want to style the block to look a bit different which isn't too hard. I've managed to create a new .tpl.php for my specific block.
However past here I cannot figure out how to gain access to the variables for each post.
This is what I have currently and what I want:
http://gyazo.com/e91c01cd9b64d4a31a01c9e5039c7362

So i'll need to gain access to the price and picture url from each post. If anyone can point me in the right direction that would be great, being new to Drupal I'm not entirely sure I've been using the right keywords in my searches on Google.

Much appreciated, Ross.


texts: Get field value from referenced entity in twig loop

texts:
I have a content type with a multiple referenced field and I need to iterate trough each item and display the item information in a table but I don't know and didn't find a way to access the content field information like the value of a specific field.

Example:
I have a content type called Task and in Task I have multiple Entity Reference to Worker content type, Worker has title, name and phone. How can I iterate each worker and display the information in a table?

What I want to do is to override node--task.html.twig to do something like this:

Assuming that we have a field_workers field in task content type.

         Name

         Phone

    {% for worker in content.field_workers %}

        {{worker.field_name.value}}

         {{worker.field_phone.value}}

     {% endfor %}

Is it possible? Thank you!


texts: Where do I add my own javascript or jquery so that it executes after the DOM is ready in Drupal 7?

texts:
The site I'm working on is here.  The theme is modified Bartik theme.

Here is the code I ended up with.  The actual script inside the function works in Chrome console.

//Scripts that are required to run after DOM is ready
jQuery(document).ready(function)() {

    // Make the parent menu item of the active sub-menu item also active.
    jQuery('#block-system-main-menu li.active-trail > a').addClass('active');
}

I read a few articles and eventually ended up making a new file here:
/sites/all/themes/brainfx/js/brainfx.js

And I call this file from the theme's template.php file inside the brainfx_preprocess_html function with this code:

drupal_add_js('sites/all/themes/brainfx/js/brainfx.js');

You'll see it shows up in the head tag on the site.  But its not working.  What do I need to do to correct this?


texts: How to add flash message to custom installation profile?

texts:
I have a custom installation profile and I want to display flash message by using drupal_set_message on home page after install.

How can I do it?


texts: Safe and elegant way to access nested entities via fields

texts:
I've seen a variety of approaches to access entity values in the theming layer. The code below is just a simple example using magic methods. It assumes all values are set - if any part of that returns a NULL, then in my experience errors ensue.

$value = $node->field_paragraph
    ->entity->field_media
    ->entity->field_file
    ->entity->field_text->value;

There are methods like ->hasField and ->count() to check things, and i have a variety in my themes. I can get the job done but sometimes it feels ugly. I'm interested the coding patterns that devs use to safely and elegantly drill through entity references.


texts: I'm building a huge form with Webform module and need advice for a way to save not fully submitted forms even without Showing "Save draft" button options is enabled and button is visible (which is another PITA).


texts: How do I per-variation add to cart button In Views with no selection?

texts:
I have a table that displays rows of products with there attributes, the last item on each row has the variation add to cart form.
The view's self sorts on the product id to display all the variations for the product.

The issue is it can't select the variation for each row automatically, it always expects the user to choose the right variation from a dropdown.

Any changes that do not have the drop-down displayed defaults to only the first product item in the table.
I have tried the relationship to the product and product id and variation cart form modules but these also failed to deliver.

I there a way in views to add a per-variation add to cart button with no selection in views table?


texts: Can we use one product for multiple display nodes in Commerce D8?

texts:
I used to work with Drupal 7 Commerce and now I need help to work on D8 Commerce.

I have nodes on my D8 website and I need to sell them through Drupal Commerce.
Each node can be sold in the same conditioning with four variations, based on customer types.

I have created a store, a product variation type, an attribute, a product type and one product with four variations, considering that one product would be enough.

Each node needs to be available as an order item.
For that, I have added an entity reference field, linked to the product type.
I have thus filled the default value with the product created.

Now on each node page, I have my add to cart button (through Commerce block or custom Views block, it works).

My problem :

Viewing the node A, I choose the variation and add the product in the cart and everything is fine.

Viewing the node B, I choose the exact same variation and add the product and there I need a second order item line with the node title (added through Views with relation to the entity reference field, not the issue here).

Unfortunately I get one order line item with quantity 2 (if I add the node title, I get two order line items with quantity 2 for each).

It may look obvious but I need to know if I really have to create one product with four variations for each node (2000+)?

Or is there a way to achieve this with D8 Commerce with only one product?

My concern here is to use properly Drupal Commerce and of course avoid the long multiple creation of products, especially in the future for my end user.

Related threads:

Automatically generate product variations


texts: Get/modify taxonomy term info in node edit form field?

texts:
How do I modify the taxonomy terms that are listed as a field in my Node edit form?

I need to be able to hide/unpublish/disable my taxonomy terms.  Since there is no way to "unpublish" taxonomy terms the way you can unpublish a node, I have created a boolean field in my taxonomy term that holds its status (enabled/disabled).

I would like to use the value of this boolean field to determine whether or not to add a warning text in the taxonomy term name (eg. Termname [DISABLED]) so that users choosing that taxonomy term are properly warned.

If it matters, I'm currently using the select list widget.

I know I can look up each term in hook_field_widget_options_select_form_alter since the tids and term names are available in the $element, but I hope there is a solution which won't require me to re-load/re-fetch the term from the database again.


texts: How do I fill the authors name in a term reference field?

texts:
Content type stock contains the term reference field field_producer. What is the rule for Rules in order to fill this field with the node author name on creation?

In detail

The form looks like:

-- Content type Stock (stock)

---- field Producer (field_producer); of field type Term reference; of widget Autocomplete term widget (tagging); number of values: 1; Vocabulary: Producer

The goal is:

When a user creates a node of the type Stock, his user name should automatically be filled/(pre-)populated in the field Producer.

Why Rules:

Since tokens aren't working for the autocomplete term reference field and a text field isn't available, rules might be a workaround. I've tried Prepopulate, Entityreference prepopulate, and other modules, but none of them supported the aim.

Where I am struggling with Rules:

Event: After saving new content, Restrict by type Stock
Condition: Entity has field, Data selector node:field-producer, Field Value field_producer
Action: Set a data value, Data (to be modified) node:field-producer, Value (to set for the specified data): HERE REMAINS THE PROBLEM. I can't choose node:author or other tokens that display the user name. I get the restriction: "Data types: Select data of the type Taxonomy term."

That's why I am not able to successfully create this rule.

What am I doing wrong? How should this rule look like?


texts:
I am trying to uninstall the modules that are part of the Relation module, after I tested it on my test site.

The Relation Endpoints Field module is not selectable because Drupal says the field implemented by that module is being used.

When I click on the "Field list" link, I get the following list of fields currently used.

None of the reported fields is implemented by that module; they are standard Drupal fields.

What should I do, in such cases? The content type that used that field has been already deleted.


texts: Does disabling a views features module remove the view from the DB

texts:
Inherited a site with 3 features modules, one is just a collection of views. i disabled it in the features interface. expecting it to disable all the views that were defined in that features module. but nothing happened... the site is huge (full publishing house)

I disabled it because theme hooks were not being applied think this has something to do with the way features is implemented.

I would like to know if once you've imported a views only features module it is imported to the db. and i can continue believing that i've broken nothing.


texts: How to get node.tpl.php to display different content for different nodes?

texts:
I currently display some database content through PHP code written directly in the body of several nodes.

I would like to shift this code into node.tpl.php (as I have seen from the Zen examples that code to modify a node should be in node.tpl.php). However, I have multiple nodes, each displaying different kinds of database content.

How should I structure the code in node.tpl.php so that if it is Page A, then I display database content A and if it is Page B, then display database content B?

As an example.

Currently I have the following in one of my node body:

<?php
  $db = mysql_connect('localhost', 'root', '');
  mysql_select_db('sage', $db);
  $query = "show tables";
  $db_query = mysql_query($query, $db);
  echo "
";
  echo "
";
  echo "TABLE NAME	";
  echo "
";
  while($row = mysql_fetch_array($db_query)) {
      $tableName = $row[0];
      echo "
";
      echo "$tableName	";
      echo "
";
  }
  echo "
";
?>

Do I copy and paste this code directly into node.tpl.php?


texts: How can I filter/sort a Drupal view in this way?

texts:
I have created a content type called PDF Publication with two fields - a pdf file upload field that allows one file to be uploaded and a term reference field where the user selects an area e.g. area1 area2 or area3

I now need to create a view block that shows just the latest pdf uploaded for each area. so the block will show three pdfs - one for each area

I have followed instruction from here and other forums on the Internet but am struggling to do this.

I would be really greatful for some help, thank you so much for reading.


texts: How to use tokens in a filtered text field

texts:
In Drupal, when you create a field, there is the option "Text Processing". You can select either "plain text" or  "Filtered text".

When I create a field with "Filtered text", I am unable to use it as a token.

For example, on my content type "content_page", I have a long_text field called "intro_text". The "Text Processing" is set to "Filtered text".

If I use this field as a token, it just won't work. This happens in a variety of modules including Meta Tag and Path Auto.

Even if I set the text format in the token, it still does not render. (e.g. [node:field-intro-text:plain_text]).

If I change the "Text Processing" to "Plain text", it works, so the problem lies with "Text Processing".

How can I get the token to work when it set to "Filtered text"?


texts: How can write reffering page node or url in a field of entity form

texts: I have an entity form and need to know which page refered to form. How can write refferer url or node id to a field ?


texts: Combing View Formatters with Custom Formatter

texts:
So I'm tearing out my eyes for a solution here. I have a view,and all I want to do for the image content is to use two different formatters effects. Example I want to use Adaptive Image formatter and Lightbox2 formatter. I started tinkering with custom formatter html+token but I guess I'm not that advance to figure out how to combine html + token variable to create a custom formatter of two formatter effects.

Are there any examples of combing two formatter effects to create a Custom Formatter?


texts:
I am trying to translate articles/nodes on my site. I installed all required modules.

I have a custom node type.

This custom node type has some fields that are translatable and not translatable.

I checked this checkbox

I created custom view for the front page that contains nodes of custom type.
But when I switch the language translation doesn't work.

Menu translation works. But the view nodes are not translated.

The interesting thing that if I visit my node by a full url path like this

http://test.net/node/1

Translation works fine.

I am outputting node properties in my template in the following way

          {{ node.title.value }}
   {{ node.field_description.value|raw }}
    {{ node.field_custom_body.value|raw }}

What can be wrong ?

EDIT

I have no option Content language selected for page

My view looks like this now

P.S I am using language switcher block to change language and it sets the session variable


texts: Alternative ways to programmatically add user fields?

texts:
Currently i use this to programmatically add user fields:

function openid_connect_entity_base_field_info(EntityTypeInterface $entity_type) {
    if ($entity_type->id() === 'user') {
        $fields['field_family_name'] = BaseFieldDefinition::create('string')
          ->setLabel(t('Family Name'))
          ->setDescription(t('Add a description'))
          ->setRevisionable(TRUE)
          ->setTranslatable(TRUE)
          ->setDisplayOptions('form', array(
            'type' => 'string_text_field',
            'weight' => 30,
            'default_value' => 0,
          ))
          ->setDisplayConfigurable('form', TRUE);
      }
return $fields;
}

but it results in the admin of the site unable to uninstall my module as shown:

Are there any alternative ways to programmatically add user fields without causing the admin of the website to be unable to uninstall the module that programmatically added the user fields?


texts:
I'm very new to Drupal and I'm receiving the error:

Cannot use object of type stdClass as array

in the following code:

$toolbar = $page['toolbar'];
foreach( $toolbar['menu_menu-smart-resources'] as $id => $object ) {
  $toolbar['menu_menu-smart-resources'][$id]['#localized_options']['attributes']['data-role'] = 'foo';
}
print render($page['toolbar']);

Can someone help.


texts: How do I send http authorization header in GET request in drupal?

texts:
How do I send http Authorization header in http GET request in drupal ?

Every things else works except the authorization part.

My custom module code:

/*
 *Implements hook_menu
 */
function mymodule_menu() {

$items['demo'] = array(
    'title' => 'Demo API integration with Drupal 7',
    'page callback' => 'demo_page',
    'access callback' => TRUE,
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
    );
return $items;
}

//page callback
function demo_page() {

$options = array(
  'method' => 'GET',
  'data' => '',
  'timeout' => 15,
  'headers' => array('Accept' => 'application/json',
                    'Authorization' => 'Basic SomeKey23412lkjdfadjfadfasd'),
);

$result = drupal_http_request('https://api.examlesite.com/test/', $options);
var_dump($result);
drupal_set_message("Result is processing");
return "hello world";
}


texts: How would you preprocess a field to print a different label?

texts:
I have a field on a content type (let's call it Label1). I want the label to be displayed on the node, but I want to use Label2 as the label instead (without renaming the field). I am trying to preprocess the field using a preprocess field function, but am having trouble getting anything to work. Does anyone have any idea on how I would do this?

Also, I'm using D7.

Thanks!


texts: how should I hide the menu and url setting in from alter?

texts:
I have a node/add/blog form,
there are some things I don't want show it.
I give the elements

$form['author']['#access'] = FALSE;
$form['options']['#access'] = FALSE;
$form['comment_settings']['#access'] = FALSE;

but I cann't find what's the element name for menu and url setting in message of dpm($form);


texts:
In Drupal 6, I want to customise some CCK field data with some added HTML, but am not sure of the best/easiest way to do this. I couldn't find a CCK module to do this.

For example, I want to enter a URL (which is stored in the field), and then when it is displayed, it is embedded in some HTML. eg.

CCK Field data: filename.jpg

Output HTML:

Picture


texts: Is there a way to track or record users entered taxonomy?

texts: Is there a way to track, flag, or record a users entered taxonomy even if perhaps they may have changed it (tagging). So basically I am trying to set up a list of all the taxonomy tags a user created. The thing these tags can be changed and manipulated by the user so I am wondering if the originals can still be added to my list after they may have changed to a new tag. For example, a user recording places of employment.


texts: how to load all products images in views

texts:
I am using Drupal Commerce, I have a content type."Product display" and a commerce product entity,"Product", when I create a node I create some product type inside it (it have product entity reference field with multiple value field),some of products not have any image(product entity has a image field),this is all I have. I want to create a list of product display  ( as a product list that each row has one image,title , .... ).

Problem: When I try to do this with views, I create a content type views set a relation to product, then when try to load only one image, I add image field and in Multiple field settings  I check Display all values in the same row and set display number to "1" , but Drupal only try to load first product images that exist in node , it's mean if first product image (I drag them in edit but nothing change and its load images from lower product id only),and if there is not any image it is not load anything, that project using drupal 7.20 and views 3.

Where is the problem? How can I achieve loading one image from product images and maybe some product reference not have image? Maybe it is because of left join and if it was right join work correctly


texts: How to get a forum container with contextual filter in a block?

texts:
I am using advanced forum module, organic group module and organic forum d7 module. I have created several groups, that all will have the same pages (group-blog, group-documents, group-members, group-wiki etc.). These pages are created as group content and do have the path-pattern:[node:og_group_ref]/[node:title]
For these pages I am creating views as block with all the needed content types (blogs, wiki, material etc) and I am setting a contextual filter to group id, and provide default value from og context.

Now, I also would like to add a group forum container. I manage to create a forum container for this group, but I can't get it as a block on such a page like the other content with the current contextual filter from the organic group.

Any ideas how to manage this?


texts: is using [current-page:query:service_name] token is safe from SQL Injection?

texts:
I'm using [current-page:query:service_name] token in my project to get parameters from the url into the database (using webforms and tokens).

I was looking in the code to check if there is some kind of sanitazing but i can't find one.. I need to know if it is safe to use it, without being worried about SQL Injection, and if it is not safe, I would like a help of how to sanitize this token with some kind of preg_replace sentence.


texts: Drush 9 pulling incorrect site information on Multi-site

texts:
We have a multisite set up with Drupal 8.6.1 and Drush 9.4.0.  This is set up on two servers that were set up identically.

The issue we are running into is that Drush is only detecting defaultsite, no matter what directory we are in.

This is creating two issues:

On server #1 - defaultsite no longer exists.  Drush is still trying to use it's URI and DB variables, so is throwing an "unable to bootstrap the Drupal database" error, and we cannot run any database-related commands.

On server #2 - defaultsite exists, so it is able to run commands.  But, when we try to enable a module, it enables the module on defaultsite no matter what site's folder we are in.

Here is what drush status outputs (whe inside of the directory: gtest.ng.evenvision.com):

 Drupal version   : 8.6.1
 Site URI         : default
 DB driver        : mysql
 DB hostname      : localhost
 DB port          : 3306
 DB username      : defaultuser
 DB name          : defaultsite
 Database         : Connected
 Drupal bootstrap : Successful
 Default theme    : ev_base_child
 Admin theme      : ev_seven
 PHP binary       : /usr/bin/php
 PHP config       : /etc/php.ini
 PHP OS           : Linux
 Drush script     : /usr/bin/drush
 Drush version    : 9.4.0
 Drush temp       : /tmp
 Drush configs    : /var/www/nginx/vendor/drush/drush/drush.yml
                    /var/www/nginx/drush/drush.yml
 Install profile  : minimal
 Drupal root      : (removed)
 Site path        : sites/default
 Files, Public    : public
 Files, Private   : private
 Files, Temp      : /tmp

And, this is what settings.php for gtest.ng.evenvision.com contains:

$databases['default']['default'] = array (
  'database' => 'gtest2018',
  'username' => 'gtest2018',
  'password' => '54352432346greg433',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);


texts: How to allow authenticated user to view others data?

texts:
My sales staff fills in a webform with uploaded pics
The Service department needs to view the submitted pics for the installations.
Wondering if a module is needed to allow an authenticated user to view the submitted data entered by someone else.  Currently my view only shows up when the user is an administrator. Webform Views Integration works Great... if only my Service Dept users could see the data.


texts: why doesnt Drupal recognize my route name?

texts:
I have a module I am upgrading  from 7 to 8. I am working on the mymodule.routing.yml file

mymodule.admin:
  path: '/admin/structure/mymodule'
  route_name:mymodule
defaults:
  _controller: '\Drupal\mymodule\Controller\QuicktabsController::adminOverview'
  _title: 'mymodule'
requirements:
 _permission: 'administer mymodule'

Now when I try to enable my module the log shows this error

Uncaught PHP Exception Drupal\\Component\\Plugin\\Exception\\PluginException: "Plugin (mymodule.admin) definition must include "route_name"" at /srv/www/appdocroot/releases/20150428151557/core/lib/Drupal/Core/Menu/LocalTaskManager.php line 161

I assume this error means that the snippet of code from my routing.yml file is the offending piece.

I have gone through the upgrade tutorial on the drupal site and it does not include the  "route_name" field in the section.  I originally tried it without and later put it in when I discovered the error.

Am I correct in my assumption of where the error is coming from?  If thats true what is wrong with my route_name field?


texts:
I have done lot of things with Drupal 7. Now I have something to do that can't be done with view interface (in my opinion) and I need to ues php and SQL. Now I am testing in view php field.

I have many node types, i.e. students, past_study etc., with many custom fields.

the first problem I faced was the name of table, I though "node type name" i.e. students, past_study should be use in FROM but after lot of hours wasting I discover each filed has its own table so have to open so many table like this

FROM field_data_field_this, field_data_field_that

Now the main problem is with WHERE clause I have student_code in students node type and a reference field s_code_ref field in past_study. I am not sure how to compere student_code in student node type with s_code_ref.

WHERE student_code = s_code_ref

when s_code_ref is a reference entity field in past_study

What I am doing is to adding a field with complicated calculation from the field of two node types and have to add this in a view with various other field from two node types.

my SQL is something like this

<?php
$result = db_query ('
  SELECT SUM((pstd.field_studyDate_value2 - pstd.field_studyDate_value) + (std.field_joiningDate_value - now()))  AS duration
  FROM field_data_field_past_study pstd, field_data_field_student std

  ');

std has single record for each student, and pstd may have 0 or more records for students.
students name, code, etc are being displaying in the view with relationship of two node type.

my problem is that how to refer the student_code in record line displaying in view and then using that in where clause to calculate the sum for that particular student_code.

so I need something like

WHERE pstd.s_code_ref = the student_code of the current row.

besides I want to know if my approach to calculate this way is right or there is other better ways?

in short I have to calculate total past study duration from one node type (past_study) then add duration of current study from another node type (student) and bringing the total study duration in a field for each student in a view.

Any help guidance will be appreciated.


texts: Select Entity Field, with view entity reference, display error on edit submission form

texts:
Problem/Motivation
I'm not sure if this is really an issue or if it's me making an error...
I've configured two forms field, A and B. Both field are entity select fields, referencing nodes throug an entity reference view.
The B field receives as argument the value of field A. I've controlled this in the create submission form with an ajax call, and its working fine.
The problem is that in the Edit Submission Form the field B only displays the submitted value ID (not the title) by default, and no more options to select, and the value is not changing with the ajax call.
Field B is not receiving the View argument in the Edit Submission form although it's displayed in the $form['elements']['fieldB']['#selection_settings']['view']['arguments']. Same result if the field value A is changed and the ajax callback is fired.
Steps to reproduce
The Entity Reference View Argument of field B is configured to returns "Page not found" if the argument is not received. If i configure it to "Display all values" then it display all the content titles, but it don't refresh on ajax callback.
This is my code on hook_form_alter to get the default argument to the field B view:
    switch($form_id){
    case 'webform_submission_mywebform_add_form':
    case 'webform_submission_mywebform_edit_form':
        if(!empty($form_state->getValue('field_A'))){
            $field_A=$form_state->getValue('field_A');
        }
        else{
            $field_A=$form['elements']['field_A']['#default_value'];
        }
       if(!empty($field_A)){
            $form['elements']['field_B']['#selection_settings']['view']['arguments'] = [
                $field_A
            ];
       }
       break;

I've omitted the ajax callback and other lines.
I'm with Drupal 9 and Webform 6.0.0-alpha16


texts:
Can drush delete individual nodes? And if so, can use drush to delete all nodes of a particular Content Type?

Background info: I'm not trying to delete the Content Type but all nodes of that type. Also this site is a dev install with a copy of a working database. I'm experimenting with feeds and imports and creating tons of nodes form RSS imports.


texts: How can I restrict that only sender and receiver can download the attached file with the private message?

texts:
I am using drupal 7. I created a new file field in private messages for attachments and I want that only sender and receiver should be able to download the file attachment.

I apologize if this question is duplicate but I didn't find the answer for this.

EDIT: Just one addition. I am using Custom Field permissions module as well. And authenticated users are unable to see the attachment until "View anyone's value for field" is enabled for them.


texts: Is it possible to use the Forena module in conjunction with the Flot module?

texts:
I need to plot based on some data that will be fetched from an external (non-drupal) database. I have found the Forena module, but in the part I do not like about the graph utility it uses by default.

Is it possible to use the Flot module in conjunction with Forena?

The Forena module says: "Virtually any JavaScript library may be used with Forena to produce amazing displays".

How is it implemented?


texts: Taxonomy terms not showing up in drupal 6

texts: I updated the drupal 6 site via drush, moved all of the modules into the correct places, but the taxonomy terms saved using the form attached to the content type does not appear on the node afterwards.


texts: Passing arguments to a URL with view blocks and contextual filters

texts:
I have a page that displays nodes of awards. These awards have taxonomy Year added to them. The url to them is : url.com/aboutus/awards.  I have a block view created that pulls the awards and I've set a contextual filter that filters the awards by year.

When I type in a URL such as url.com/aboutus/awards/2013, I want only the 2013 awards to be listed.  I've been trying to accomplish this with a dynamic field but the argument isn't passing.

Does anyone have any idea how I can solve this? (I am a newbie to Drupal, so apologies if my vocabulary isn't completely accurate.)


texts: How to disable text format options in CKEditor

texts:
I wish users don't have the option which text format they want to use as shown here:

I have been playing around with the better formats module, Currently only works on Field API fields on fieldable entities implementing core style text processing. So this module only makes sure with which text format they will start off editing with, so this dCurrently only works on Field API fields on fieldable entities implementing core style text processing.oesn't do anything at all, as the users still have the option to choose which text format they would like to choose.

Besides hiding this option with CSS, is there another way to disable this option for specific users?


texts: Using to user_profile_form being used on a page thats not /user/#/edit

texts:
I've found the post How to display one of Drupal's default forms which talks specifically about this issue. however I wanted to post comments on it to get more info, It didn't seem to let me. Mabey I missed a button somewhere.

Anyway, I have section of my Drupal 7 site for all account and user stuff. /my/ This is a portal so to speak, /my/account is a menu handler that originally called drupal_get_form('user_profile_form', $user); Everything works, except when trying to upload, My profile is customised with a field to upload a file and field to upload an image.

Neither field works, it just returns errors. after the ajax kicks in.

Using the method found in the above linked post my entire form refuses to save and gives me validation errors. Thew above link mentions that custom callbacks and/or validators may have to be added due to referencing issue so i was hoping that someone could point me in the direction of what those custom things are.

Thanks.


texts:
I just read the Drush Topic - A Wealth of Information article about the topic section in drush commands and I have added this topic to my drush commands:

  $items['docs-onlyone'] = array(
    'description' => 'Info about Only One.',
    'hidden' => TRUE,
    'topic' => TRUE,
    'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
    'callback' => 'drush_print_file',
    'callback arguments' => array(dirname(__FILE__) . '/README.txt'),
  );

The problem is that the only way to see the new topic in the topic list once I use the drush topic command is if I place my onlyone.drush.inc file inside the .drush folder.

Is this normal? I can't see the topic if I have my onlyone.drush.inc file inside my module folder.


texts: How can I force the user to register/login first before being redirected back to the current URL?

texts:
I'm displaying a form using the Form API under a given URL. User gets this URL and accesses it. But before the user fills out the form, they need to be registered or logged in.

How can I send the user to the login page, or present the login form, then subsequently direct them back to the form under the given URL?

This is not a Webform -- I'm using the Form API.


texts: Page redirect in custom WebformHandlerBase

texts:
I have written a custom WebformHandlerBase and attached it to the Mulitpage webform. With this I'm able to get the values into the custom handler as soon as user clicks on Next Page> button

class MyFormHandler extends WebformHandlerBase {
     public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {

         $form_id = 'webform_submission_' . $webform_submission->getWebform()->id() . '_form';

         if($form_id == 'webform_submission_registration_content_form') {
            $values = $webform_submission->getData();
            /* custom code to calculate the score based on the values */
             $eligible_to_participate = 1;
             if ($score >= x && $score <= y) {
                  $eligible_to_participate = 1;
              }
             else
             {
                 $eligible_to_participate = 0;
             }
             if($eligible_to_participate == 0) {
                  // This user is not eligible so redirect to 'finish page'
                  /* The below code is not working
                   * how-ever the same code is working in hook_form_FORM_ID_alter()
                   */
                  $url = Url::fromRoute('entity.node.canonical', ['node' => 78]);
                  $response = new RedirectResponse($url->toString());
                  $response->send();
              }
          }
      }
 }

Based on the user selected values I need to redirect the user to a different page and the code for doing the same is as follows

 use Drupal\Core\Url;
 use Symfony\Component\HttpFoundation\RedirectResponse;

 $url = Url::fromRoute('entity.node.canonical', ['node' => 78]);
 $response = new RedirectResponse($url->toString());
 $response->send();

Now the problem is, this code is not working in custom handler function. If I write the same code in hook_form_FORM_ID_alter() it is working fine.

Any idea where am I doing wrong? Any help much appreciated.


texts: Image styles not generated with Drupal 7 on IIS 6

texts:
I've developed a site that uses various image styles to export images to an iPhone (linked from a XML export document). This worked perfectly fine on my own development server with Linux/Apache.

The site is now currently hosted on a shared hosting environment, which uses Windows/IIS6. (yeah, strange; it is not my decision as you can assume ;).)

The problem now is that the image_style URLs for new images (existing images work) lead to a 404 error page, which is directly served by IIS. However, clean URLs worked fine out of the box and "normal" 404 pages are displayed by Drupal.

So, an URL like http://example.org/does_not_exist shows the typical site not found error, served with Drupal but http://example.org/sites/default/files/styles/command_image/public/Chrysanthemum_0.jpg shows the IIS 404 page.

The site is using the public file system for these images and the path is correct; it does work fine for existing images, which I uploaded together with the rest of the site during the initial deployment on that server.

Do you have any idea?


texts: How to customize the widget type of a field collection on Order Edit pages (/admin/commerce/orders/[order-number]/edit) in Drupal Commerce?

texts:
I have a field collection inside the customer billing profile. Some orders have so many field collections (500+) that visiting /admin/commerce/orders/[order-number]/edit results in a white screen and this PHP / PDO error:

Viewing the order with 500+ field collections works fine, so my current approach is to simply to hide the field collection from being viewed when editing orders. Changing the field collection widget manually from "embedded" to "hidden" at /admin/commerce/customer-profiles/types/billing/fields/my_field_collection/widget-type hides the field collection and allows me to edit the order; however, this hides the field collection everywhere. I need it to only be "hidden" from the order edit page, but "embedded" everywhere else.

I've been stuck on this for a few days, so I would appreciate your assistance.


texts: How to add the placeholder in view exposed filter

texts: I am just created a block-view with exposed filter in view,, now i want to give the placeholder to auto-complete widget type same as label name , how can i do this ?


texts: Group By Taxonomy term on view but show all articles containing it

texts:
I am trying to generate a view that groups nodes by a taxonomy attached to them but only shows the Taxonomy term once then all the titles under it.

Term 1
Article
Article
Article
Article

Term 2
Article
Article

Term 3
Article
Article
Article

An example of what im trying to solve.


texts: Fatal error: Call to undefined function media_filter

texts:
I've upgraded Media module from 2.0-alpha2+6-dev and 2.0-beta1, however now I've the following error on some random pages:

( ! ) Fatal error: Call to undefined function `media_filter()` in my_module.module on line 224

My code in hook_field_formatter_view in my module is:

$element[0]['#markup']
  = '

'
  . media_filter($text_summary)
  . '' . $read_more_text . ''
  . '

';

The code of that media_filter function was:

function media_filter($text) {
  $text = preg_replace_callback(MEDIA_TOKEN_REGEX, 'media_token_to_markup', $text);
  return $text;
}

What is the current replacement for that function which I can use instead?


texts: Is there a common method to password protect registration pages?

texts: The site I am working on requires that affiliates register on the site. I've created a profile type for affiliates with corresponding permissions and a registration page. I'd like to give access to this and the site's main registration pages without having to deal with all the spam account registration attempts. Is there a standard way of allowing only users that you want to register to have access to registration pages?


texts: Link taxonomy terms to view filtered on term?

texts:
I am trying to do something that is probably quite common but I'm not sure where to start. I have a view of content types with several taxonomy fields. There are exposed filters for users to filter the content.
When on the node page for one of these nodes I would like the taxonomy terms to go to that view, already filtered on that taxonomy term. I am thinking maybe a GET request somehow.

Does anybody know how to accomplish this?
Let me know if this needs clarification.


texts:
I have the site (multi site), it have Views, which displays a list of articles on a page.
When I try to change something in Views or add a new field, Views removes most of the existing fields .
When I try to import Views, it displays an error :
"Field handler field_data_field_date.field_date is not available."
"Field handler field_data_field_news_type.field_news_type is not available." etc.
Every fields exist.

Someone saw this before ?
Thank you


texts: Is drupal bootstrap phases will be called for each page request or its only once on site load?

texts: All drupal bootstrap phases will be called on each page load or only one time  when site will load.


texts: Changing color of form html with Javascript

texts:
I have some custom HTML and CSS added to a form module I've created. It looks fine; the css is styling it correctly with a drupal_add_css() stylesheet. But I also want to add some Javascript using drupal_add_js() so that when a user is on the first page of the form it changes the text color in the HTML I set up. But I can't get it to work!

Here's the Javascript in step-one.js:

document.getElementById("step-one").style.color = "#769EDD";

Here's the code it will be changing:

    $form['progress bar'] = array(
        '#title' => t('Module Tool'),
        '#prefix' => '

Experience Level  >
Primary Role  >
Topics of Interest  >
Recommendations
',
    );

And I'm trying to add the javascript call ABOVE the previous code, right after I do the drupal_add_css() call (which works). Note that this is all within my module_form() function. Here's the relevant code:

function modulename_form($form, &$form_state) {
      drupal_add_css(drupal_get_path('module', 'modulename') .'/modulename.css');
      drupal_add_js(drupal_get_path('module', 'modulename') .'/step-one.js');
      // more code around building the form itself...until eventually
      I get to my $form['progress bar'] = array( // see code above.

Any ideas why this might not be working?


texts: How to use php filter for "contact page" in drupal 6?

texts:
How can I set the PHP filter for the "contact page" in Drupal 6?
I want to insert some PHP code in the description of the contact form page.
Thanks


texts: How can I disable image resizing in CKEditor?

texts:
Our site is responsive and when editors use the resizing handles after uploading an image into the editor, it puts in fixed width and height on the image. We don't want them resizing images at all, due to the responsive nature of the site. Is there a way to disable image resizing in the editor?

If I can write a simple Drupal custom module to get the job done, that would be preferable. I can't seem to find any clear instructions on modifying the CKEditor's configuration dynamically in Drupal, though.


texts:
Whenever I try to save the bucket name I get these errors:

Notice: Use of undefined constant CURLOPT_CLOSEPOLICY - assumed 'CURLOPT_CLOSEPOLICY' in RequestCore->prep_request() (line 626 of /Applications/MAMP/htdocs/clickbus-cms/sites/all/libraries/awssdk/lib/requestcore/requestcore.class.php).
Notice: Use of undefined constant CURLCLOSEPOLICY_LEAST_RECENTLY_USED - assumed 'CURLCLOSEPOLICY_LEAST_RECENTLY_USED' in RequestCore->prep_request() (line 626 of /Applications/MAMP/htdocs/clickbus-cms/sites/all/libraries/awssdk/lib/requestcore/requestcore.class.php).
Warning: curl_setopt() expects parameter 2 to be long, string given in RequestCore->prep_request() (line 626 of /Applications/MAMP/htdocs/clickbus-cms/sites/all/libraries/awssdk/lib/requestcore/requestcore.class.php).
Notice: Use of undefined constant CURLOPT_CLOSEPOLICY - assumed 'CURLOPT_CLOSEPOLICY' in RequestCore->prep_request() (line 626 of /Applications/MAMP/htdocs/clickbus-cms/sites/all/libraries/awssdk/lib/requestcore/requestcore.class.php).
Notice: Use of undefined constant CURLCLOSEPOLICY_LEAST_RECENTLY_USED - assumed 'CURLCLOSEPOLICY_LEAST_RECENTLY_USED' in RequestCore->prep_request() (line 626 of /Applications/MAMP/htdocs/clickbus-cms/sites/all/libraries/awssdk/lib/requestcore/requestcore.class.php).
Warning: curl_setopt() expects parameter 2 to be long, string given in RequestCore->prep_request() (line 626 of /Applications/MAMP/htdocs/clickbus-cms/sites/all/libraries/awssdk/lib/requestcore/requestcore.class.php).

And the configuration is not saved.
The bucket name contains "-", would this be a problem?


texts: How to bulk delete Orders in Drupal Commerce module

texts:
I need to delete 200 Drupal commerce orders. Is there any way to do this in a bulk action?

Orders are at:   /admin/commerce/orders

Same with Customer profiles. I need to delete them with a bulk action. Can I accomplish with this?

Customer profiles are at:   /admin/commerce/customer-profiles/list


texts: How do I export data into yaml with mapping?

texts:
I am exporting module's libraries from PHP in modulename.libraries.yml. I am using the YAML parser.

\Drupal::service('serialization.yaml')->decode($data)

The issue I have encountered is that I cannot indicate JavaScript or CSS files to be minified because instead of filename: { minified: true } I will end up with the following.

filename:
  minified: true

Basing on a brief IRC chat, I get this is not possible. Is that correct? If it is so, is this a bug? Differently, can anybody tell me how can I achieve this?


texts: how to set value of autocomplete field and trigger search event with jquery

texts:
I am setting the value of an autocomplete field from a jquery event:

$('input#edit-myfield').val(mynewvaluethatIwant)

That works, but the associated drupal autocomplete search does not fire.

My use case is I have a working autocomplete, but as well as typing a few letter into the field, I want to give users the option of clicking a link to populate the field.

My automcomplete field AJAX handler runs several commands as part of its response, so I'm just wanting to fool the form into thinking the user has entered the value.


texts: How can I allow editors to manage many taxonomies while choosing which terms to boost and which to make visible?

texts:
The system I am working on has about 15 taxonomies. It may have 30 or more eventually.  We didn't want to add a field for every taxonomy since the editors would have hated that. Initially we went with one field called "Search term(s)" aka field_search_terms that lets editors reference multiple taxonomies.

Now the editors also want to be able to

Mark some terms as primary and others as secondary (Let them control which terms to boost in search)
Mark some terms as visible tags on the page while most will be hidden.

I can think of two options:

Make separate fields on the nodes for primary, secondary and visible_terms.
Unfortunately the editors will have to select visible terms/tags twice.
Make a custom "search_term_reference" entity with fields: {field_search_term, is_primary, is_visible} and then provide something like inline entity form to edit them.

Can anyone offer any practical guidance based on experience with the issue of allowing editorial control of search boost for individual terms? Feedback on how much custom code was needed for example?


texts: Update Node Problematically is not working fine

texts:
I am using Drupal-6 . I am trying to update single field using following code.

    $nodnew->id=14;
    $nodenew->field_site_url[$array_id]['value']=$website_url;
   $nodenew->revision=1;
   $nodenew->changed = $node->created;
   $nodenew->comment = 0;
   $nodenew->type ='product';
   node_save($nodenew);

It updates field_site_url sucessfully. But it also changes other fields to blank.
like title, body etc. i want to add only field_site_url.

Any idea how to do this?


texts: Is it possible to call a function but disable that functions hook calls?

texts:
In this answer I wanted to alter a URL using hook_file_url_alter(), and within my implementation of that hook I needed to convert the URI to a URL.

Normally this would be done with a call to file_create_url() but that is not possible here as it would trigger my hook causing an endless loop.

I can see at the top of drupal_alter() it is using the static variable $drupal_static_fast which makes me think maybe there is a way of using this to temporarily disable a hook being called, but I'm not sure.


texts: Add some custom fields in Views exposed filters and preserve their data to Url (GET)

texts:
I have a Views list of Boats and every Content Type 'boat' has a location. So I have created an exposed form that already contains a location <select>, and when changed, the boats are successfully filtered by the location selected.
I want to put other inputs in this form, like:

Check in Date
Check out Date
Number of visitors

But these data are not filters, they are just input that can be used in the next step (explained later).

Is there a simple way to add these custom fields in the exposed filter form (or look like being inside it somehow)?
How to retrieve this information, so when a specific boat is selected (that's the next step) the number of visitors,check in/out dates, etc will be shown in a similar form (Webform) which finally sends a mail..

Thanks in advance!

PS: I am a newbie on both Drupal and Drupal Answers!
I've searched but I am confused whether I should create a custom module or use an existing one that I currently am unaware of.


texts: Views oddities - global fields won't show up

texts:
I'm experiencing a bunch of oddities related to Views 3.3 (D7.12). This makes me wonder whether I run short of Views education or it's just an oddity of my installation. Let me list the annoyances:

A title set up for a View (page display) won't show up in the output. Not even in the markup. Another - very similar view, row-themed as well, does not suffer from that.
A view with exposed filter has two header Global: Text fields - set up to display: one with empty results, the other - for non-empty results only. Neither will ever show up.
The same view has a Global: Result summary field, set to display @total of result set. To no avail. (I know there are raw PHP ways to do that, but why resort to raw code if there's a built-in feature supposed to do just that.)

none of these views uses aggregation or grouping, pretty
I have googled and searched through Drupal Answers almost all last night long and did not find a working answer. Anyone been hit by any of the above?

My understanding is that if I use a row-style theming with tpl files like: views-view-fields--[view-name]--page.tpl.php, I'm only making myself responsible for the "foreach" part of the output, and the global fields (title, header, footer) should be rendered by the core Views engine. To verify, I tried to remove the tpl file, rescan, flush cache - the global fields did not show up whatsoever.

So, what is the secret...?


texts: Block caching not working for anonymous users despite setting cache contexts

texts:
I have a block plugin that displays different dynamic content depending on whether you're logged in or not. I attempted enabling this by setting the max-age setting in the #cache attribute of my render array to 0 like so

    if ($user->hasRole('anonymous')) {
            if ($loginrequired) {
                $content = [
                    '#markup' => '
 Login required. Click Here to Login
',
                ];
                return $content;
            }
    }
    $content = [
        'header'   => [
            '#markup' => $header_text,
        ],
        '#cache'   => [
            'max-age' => 0,
        ],
        $webform,
    ];
    return $content;

The dynamic content updates for logged in users, but for anonymous users it just displays exactly what the logged in user saw, instead of showing the login required message.

After doing some research it seems that drupal ignores max-cache for anonymous visitors and cache contexts would be required, according to this page

Disable form or block cache for anonymous users?

So I changed my code to reflect this

        '#cache'    => [
            'max-age'  => 0,
            'contexts' => ['user.roles']
        ],

I used user.roles since the content depended on whether the user was logged in or not. This had no effect. I then tried.

        '#cache'    => [
            'max-age'  => 0,
            'contexts' => ['user.roles:anonymous']
        ],

This also had no effect. Why does my method not work? What cache settings are required in order for the cache to be disabled even for anonymous users? Or is there a completely different method I should be using?

Note: I do not want to disable caching site wide. I would like to be able to disable caching on a plugin to plugin basis.

UPDATE: Looking at examples I also tried

   '#cache' => [
            'max-age'  => 0,
            'contexts' => ['url.path', 'url.query_args']
    ],

but that didn't work either.


texts:
I've found that my site is showing duplicated content, I think it was when I installed Pathauto. The nodes are not duplicated though but seems to be multiple aliases.

I've since tried using Global Redirect but it hasn't solved the issue. And even worse, some items are showing up three times now!

For example

http://biosphericproject.php5.demo.faelix.net/content/what-we-mean-forest-gardening-1
http://biosphericproject.php5.demo.faelix.net/content/what-we-mean-forest-gardening
http://biosphericproject.php5.demo.faelix.net/content/what-we-mean-forest-gardening-0

Confused,
Alex