texts: views_get_view_result additional parameters not working

texts:
I'm trying to call views_get_view_result from a block class to load in a view. My view has two contextual filters (one for a year, one for state of node). So I'm trying to call views_get_view_result like so:
views_get_view_result([view_machine_name], [view_display_name], $arg1, $arg2);

All I get back is an empty array. The view does have default values set for the contextual filters, and when I remove the extra arguments, ex:
views_get_view_result([view_machine_name], [view_display_name]);

I get values back from the function as I would expect. What am I doing wrong with the additional parameters?


texts: Out of memory error in composer when requiring drupal/bootstrap

texts:
I currently set up a Drupal 8 website using Composer like described here.
Drupal is already running. Now I want to add Bootstrap theme by calling

composer require drupal/bootstrap

But I get

  Using version ^7.3 for drupal/bootstrap
  ./composer.json has been updated
  DrupalProject\composer\ScriptHandler::checkComposerVersion
  Loading composer repositories with package information
  Updating dependencies (including require-dev)

  mmap() failed: [12] Cannot allocate memory

  mmap() failed: [12] Cannot allocate memory
  PHP Fatal error:  Out of memory (allocated 515907584) (tried to allocate 20480 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Pool.php on line 221

  Fatal error: Out of memory (allocated 515907584) (tried to allocate 20480 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Pool.php on line 221

Im using Composer version 1.2.1 2016-09-12 11:27:19


texts: How reset $form_state on ajax call for get real value in submit?

texts:
I have see some post about that,but i still have no real answer.

In my form, user can select a register address in a select field.
When he select an address, the ajax set value on some other fields :

  The code :

  if($form_state->getTriggeringElement()['#name']=="mes_adresses")
  {
      $listAdresse = $this->adresse_service->getUserAdresseById($form_state->getValue('mes_adresses'));

  }

  $form['containerGeneral']['livraison']['adresseComplete']['nom_livraison'] = array(
      '#title' => 'Nom de livraison',
      '#type' => 'textfield',
      '#value' => $listAdresse['nom'],
  );

  $form['containerGeneral']['livraison']['adresseComplete']['prenom_livraison'] = array(
      '#title' => 'Prénom de livraison',
      '#type' => 'textfield',
      '#value' => $listAdresse['prenom'],
  );

  $form['containerGeneral']['livraison']['adresseComplete']['pays_livraison'] = array(
      '#title' => 'Pays de livraison',
      '#type' => 'select',
      '#required'=>true,
      '#options'=>$this->taxonomy_service->getTermsByVid('pays_livraison'),
      '#value' => $listAdresse['pays'],
  );

  $form['containerGeneral']['livraison']['adresseComplete']['adresse_livraison'] = array(
      '#title' => 'Adresse de livraison',
      '#type' => 'textfield',
      '#value' =>  $listAdresse['adresse'],
  );

  $form['containerGeneral']['livraison']['adresseComplete']['adresse2_livraison'] = array(
      '#title' => 'Adresse de livraison',
      '#type' => 'textfield',
      '#value' =>$listAdresse['adresse2'],
  );

  $form['containerGeneral']['livraison']['adresseComplete']['cp_livraison'] = array(
      '#title' => 'Code postal de livraison',
      '#maxlength'=>5,
      '#type' => 'textfield',
      '#value' => $listAdresse['code_postal'],
  );

  $form['containerGeneral']['livraison']['adresseComplete']['ville_livraison'] = array(
      '#title' => 'Ville de livraison',
      '#type' => 'textfield',
      '#value' =>$listAdresse['ville'],
  );

  And the callback :

public function ajaxChangeAdresseCallback(array &$form, FormStateInterface $form_state)
{

    $form_state->setRebuild(TRUE);
    return  $form['containerGeneral']['livraison']['adresseComplete'];

}

So there are 2 things :

  #value

If you set value like that, user can never change the value because

$form_state->getValue()

ll keep the value set by the ajax.

  #default_value

If you set the value like that, that doesn't work because the #default_value parameter if use just the first time the form is loaded.

  The main problem is with $form_state.

If you kint when you submit your form $form_state->getValue() and $_POST, $_POST is good but not the $form_state.

But the issue are in the validate function too, if user select the option new address, ajax reload the form, set empty everywhere, and when you submit, the validate function ll tell you you have empty value.

I know on D7 some people unset the $form_state['values];

But on D8 ?

So how reset the $form_state value ?


texts: Autofill fields on profile form based on previous fields

texts:
I have a particularly long user profile form on my client's site. Some of those fields can be autofilled using information already entered (such as spouse last name). The filling out needs to be done dynamically on the page. How can I do this?

[Edit]
Adding code for a problem that I experienced (anonymized):

function foo_profile_autofill_form_profile_node_form_alter (&$form, &$form_state){
    foreach(array('field_first_name', 'field_last_name',
            'field_spouse_first_name','field_spouse_last_name') as $fieldName){
            $form[$fieldName]['#attributes']['class'][] = "combname";
    }

    drupal_add_js(drupal_get_path('module', 'foo_profile_autofill').'/foo_profile_autofill.js');

}


texts: Is it possible to add a wildcard in template.php to apply function to multiple items

texts:
I have a webform with 20 different select options under different fieldsets and they all need to have a custom drop down select field title. To achieve that you use this:

function theme_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'webform_client_form_653') {
    $form['submitted']['products']['product_1']['quantity']['#empty_option'] = t('Qty');
  }
}

Now each form is identical except the ['product_1'], so to make that custom title work on every field is that you have to copy paste 20 lines of same code and just rename the ['product_1'] to ['product_2'], ['product_3'] and the etc.

I was thinking is there some method like in CSS where you can use wildcards, e.g. (to get the idea): https://stackoverflow.com/questions/5110249/wildcard-in-css-for-classes

So you could achieve all that with just one line of code and apply it to all quantity fields in the webform.

So instead of spamming:

$form['submitted']['products']['product_1']['quantity']['#empty_option'] = t('Qty');
$form['submitted']['products']['product_2']['quantity']['#empty_option'] = t('Qty');
$form['submitted']['products']['product_3']['quantity']['#empty_option'] = t('Qty');
And so on...

You could do something like

$form['submitted']['products']['*']['quantity']['#empty_option'] = t('Qty');

But it doesn't work.


texts: How to configure ckeditor for different toolbars?

texts:
In D7 I would like to use ckeditor with a specific profile for a user role. The user is only allowed to use bulleted listed. How to do this?

I did the following:

Configured in drupal a ckeditor profile call "builder"
For a role say"Client" I added a text format say "Bullitsformat"
for a field in a content type "testfield" I configures user can choose own filter.

If I test the edit form no toolbar is displayed when user selects Bullitsformat.

What to do?


texts: Add a meta content="noindex,nofollow" tag on a node created programmatically

texts:
Is it possible to add a meta content="noindex,nofollow" tag to the head on the page of a node created programmatically (and onl this node)? I have created the node like this:

function MODULENAME_install() {
  $bodytext = 'Some Text';

  $node = new stdClass();
  $node->type = "page";
  $node->title = "New title";
  $node->language = LANGUAGE_NONE;
  node_object_prepare($node);
  $node->body[$node->language][0]['value'] = $bodytext;
  $node->body[$node->language][0]['summary'] = '';
  $node->body[$node->language][0]['format'] = 'full_html';
  $node->path = array('alias' => 'new-title');
  node_save($node);
}


texts: Implement javascript inside body, error: jQuery is not defined

texts:
In Drupal 7, I had js-output template.

I define the template output as javascript. This is used for our front end person that can easily input javascript without touching backend.

<script>
<?php if(isset($content['field_custom_javascript'])) print $content['field_custom_javascript']['#items'][0]['value']; ?>
</script>

In Drupal 8, I am trying to do the same thing by define twig file:

{% if content.field_custom_javascript is not empty %}
<script>
    {{ content.field_custom_javascript }}
</script>
{% endif %}

But when I put js in the customize_js_output field, as the following:

(function ($, Drupal) {
 $( document ).ready(function() {
    console.log( "ready!" );
 });
})(jQuery, Drupal);

Or

 $( document ).ready(function() {
        console.log( "ready!" );
  });

Have jQuery is not defined or $ is not defined error.
Got all of jQuery libraries load correct in the footer.

My question:
Is this a good way to do it? If not, do you have any suggestions?

If i only want to write js inside my body field in the source or even php filter as content editor, can I do it?


texts: How to use a custom block template when the block is embedded in a panel pane?

texts:
I have a block that I have templated and want to use in and out of a panel layout in various parts of my site.

So to template the block I opted to install the block_machine_name module which gives a good anchor point for the template so the block id is not relied upon (as this changes between my dev and prod sites).

Then I theme the block and it works just great using a template name like block--sweet-name.tpl.php

Then I also use the block in a panels layout and things start to go wrong.
The block template is now ignored.

So I am trying to find a way to get panels embedded block to respect block templates.

Is this possible?


texts: How to use Docker for a drupal development site and then deploy to online provider?

texts:
I am operating a Drupal website with two installations:

a development site on my local machine (dev)
a live site at my ISP offering an Apache httpd, with PHP and MySQL (live)

For dev, so far I have just installed software on my local machine (httpd,  php, mysql, drupal) and deployed updates to live by copying changed PHP files and uploading a database backup.

I am considering to use Docker for my dev installation (e.g., docker4drupal). However, due to ISP limitations for the live site I will still have to deploy updates by uploading PHP files from the webserver and database images from MySQL/MariaDB.

What is the best way to extract PHP files and DB snapshots from a docker4drupal installation (or similar Docker based set-ups)?


texts:
I've been asked to add the following to a page :

<script id="dsxc_script" type="text/javascript" src="https://www.docserver1.co.uk/dsxc/client.js?acc=xx&integrated=true"></script>

However I don't think the drupal_add_js() function will allow me to set an 'id' attribute.

How should I proceed ?


texts: Create node fields populated with an API

texts:
I want to create a drop-down field on a content type, but I need this drop-down to be populate by an external API.
I think I need to have custom module, get data from API in module controller, after this steps I'm a bit lost, how can I populate my drop-down with API data?
This is an example of what I want.

After back-end users fill all the fields, I need to save them on the database and show them on the front-end.


texts:
The kpr line in the function works – It outputs the author of the node's full name. But setting the author_name variable does not. Why isn't that replacing the author_name variable in my template? (It's just blank.)

If i remove this, it will display the username.

function theme_preprocess_node(&$variables) {
  // die(kpr($variables['node']->getOwner()->get('field_full_name')->getValue()));
  $variables['author_name'] = $variables['node']->getOwner()->get('field_full_name')->getValue();
}


texts: I know how to do it in Drupal 6/7, but I cannot find where to export/import views in Drupal 8. From which admin page is possible to do it, in Drupal 8?


texts: Where should I begin in creating a page to allow authenticated users to submit a short story that will become it's own independent page?

texts:
I have installed the most recent version of Drupal on my computer using xampp as the local host.

I would like to allow authenticated users to be able to publish content (ie a short story & accompanying imagine) that would appear on a stand alone page, not like a blog; for example, if a user submits 3 stories, then each story could be accessed independently.
Ultimately, during the submission process I would like the user to identify the category of the story (adventure, romance, sci-fi, etc) that would then appear in the appropriate section of the website.
In my mind it would be similar to a user submitting a recipe on a cooking site. I imagine the submission page would not be dissimilar to the page I'm on now to submit this question.

All of which is to say, where do I begin? What modules will best assist me? Can I develop the submission page and then institute the taxonomy?


texts: problem migrating my drupal site PDOException: SQLSTATE[42000] [1044] Access denied for user

texts:
I have just loaded my drupal 7.32 site to JustHost from my pc (running xampp) copied the files across, and exported and imported the database to JustHost cpanel, i browse onto the website and I get the error message below. I have triple checked my database name and username of the database and password and they are correctly specified in my settings.php file. My database was called 'school2' on the pc, but I'm not sure that will affect anything.

I get this error message:-

PDOException: SQLSTATE[42000] [1044] Access denied for user 'caerleon_prim'@'localhost' to database 'caerleon_prim' in lock_may_be_available() (line 167 of /home4/caerleon/public_html/includes/lock.inc).

Can anyone help?


texts: How to disable a module and its dependents modules with Drush?

texts:
Is there any way to disable a module and its dependents modules with Drush.

Let's say I need to disable views but I have enable views_accordion as well.

If I run $ drush pm-disable views I don't get the views module disable.


texts: Earliest hook to generate content during user registration

texts: During the user registration process in Drupal 7, at which point can I access the newly created UID to create 'default content' for that user?  I would like to do this as early on as possible.  Preferably before the user has been approved by an admin or before they have verified their email address.


texts: How do I remove the authoring information?

texts:
I want to publish some static pages, but when I try they always show the publishing date and author, which makes them look more like a blogs.

I have looked at a way to disable the feature "authoring information" for this page, but the best I can find is how to make it anon, which is not what I want either.

The content types I have on the site are:

Article
Basic page
Blog entry
Book page
Forum topic
Poll

The theme I am using is Bartik 7.15, if that makes any difference.


texts: which views template controls the field div sections

texts:
I have created a view which displays the fields of different node types. Therefore, visually, the user will see apple fields bunched together and orange fields bunched together, and the page makes sense.

However, for each view row, a div is created for EVERY field in the view, orange or apple. For particular reasons, I need to be able to get rid of the divs which don't apply to that row.

I would imagine doing something like:

if($row->_field_data['nid']['entity']->type == '[node-type]'):

but I can't figure out which template to do this in. I tried in views-view-unformatted.tpl.php and views-view.tpl.php, and in views-view-fields.tpl.php (which are the outer wrappers) but none seemed to do it.

I thought it would be in views-view-fields.tpl.php, but when I tried inserting this into the (overriding) template

drupal_set_message("wrapper-prefix:" . $field->wrapper_prefix . " wrapper-label:" . $field->label_html . " wrapper-content:" . $field->content . "  wrapper-suffix:" . $field->wrapper_suffix);

the only thing which came back with info was $field->content


texts: In my administration content editing page (drupal 7), I have a little red "new " or "updated" next to some items.  How can I make these red labels come out in my views listing?


texts: Creating an email newsletter using simplenews

texts: I need to create an email newsletter template using simplenews. Can anyone point me to a simple, clear tutorial on how to do so?


texts: Views PHP: Getting "Available Variables"

texts:
I am using Views PHP and having problem in doing a very basic thing.

In my view I added a field which I have to "Exclude from display" and show it only when there is a specific content type being called on Page.

So I used Views PHP, which checks the content type. The only problem is that I don't know how to output this field.

I used

$row -> myfield_name;

but that doesn't work.

So basically, I just need to use "Available Variables". But the $row->myfield_name doesn't work.

I can't use the following as this gives raw field.  I only want to use how this is intercepted in my view and how my view shows it. This is because this field is a video and my view is formatting it with JWplayer and hence calling it will call it as JWPlayer.

$value-> _field_data["body"] ["entity"] -> myfield_name ["und"][0]["value"];

Thanks


texts: How to use EntityFieldQuery with a simple text field?

texts:
I have a content type called foo and it has a textfield called field_bar. I have one that has a value set to baz.

I'd like to use the EntityFieldQuery object to find all foos that have field_bar with the baz value.

$nodeQuery = new EntityFieldQuery();
  $nodeQuery->entityCondition('entity_type', 'node', '=')
    ->entityCondition('bundle', 'foo')
    ->fieldCondition('field_bar', 'value', '12345', '=');

The problem is that I get no results or error back. If I remove the fieldCondition, I get all foos including the one I am looking for.

As the documentation is vague and only for experts, I googled a lot, but can't find any reason for my query not returning my node.

I also tried with

->fieldCondition('field_bar', 'value', array('12345'), '=');

to see if that matters, but its the same. I dd-ed the $nodeQuery but can't see the executed SQL.

Is there anything special with textfields?


texts:
I'm asking in this forum because there are some specific Drupal 8 rules that might need to be applied.

I am looking for the correct way to add .htaccess rules that allow for:

domain.com/specific/  to be domain.com/script.php

I would first have to allow the request for /specific/ to happen without Drupal taking it, and then point /specific/ to /script.php

The closest I have been able to get is:

  RewriteCond %{REQUEST_URI} "/specific/"
  RewriteRule (.*) $1 [L]

  RewriteRule ^specific(/|$) script.php [L]

This is not ideal though, as the user ends up at:   domain.com/script.php


texts: How To Force Search API To Reindex a Node / an Entity

texts:
I'm working on Sear API. My entity has many items and data change by action of the user. I don't want to reindex all items of data. So I want to reindex an entity after user does the action. I found the topic but just for Drupal 7. So with search API for Drupal 8, how to I can implement force search API to reindex an entity? The way or snippet code I can use? Please help!

e.g. I have search index with some basic field like this:

I want to update the number of comment value after use add a new comment. Default search api doesn't not support that. And I don't want to wait for a cron to update value. Imagine one field very important not like the number of comment. That field needs to update immediately.


texts:
I created 2 roles on my site: Buyer and Seller

I used auto assign role to allow the user choose a role on sign up.

I then created an additional profile for seller using profile 2. (The buyer is supposed to be logged in immediately he signs up)

Using rules, i tried to redirect the user who chooses the seller role to the page setup with profile 2, but it comes up with access denied, you are not authorized to access this page.

Kindly assist.


texts:
So I was wondering how to utilize this new addition to Drupal.
For example, should I use TypedData to set default value, description or required attributes in (entity)forms?

What is the usage of computed(), setReadOnly(), setTranslatable(), is/setQueryable(),.. ?


texts: Dynamically link /sites/default/css/css_***.css file for WordPress template header

texts:
FYI, I don't know Drupal at all. What I've done is stick a WordPress install at /blog/ and pull in the /sites/default/css/css_randomstring.css and static html from the Drupal page - and along with the WordPress loop in the index.php file of Wordpress - somewhat integrate WordPress into Drupal. (I don't want to use the Drupal WP module).

The problem is that the Drupal CSS link changes when there are small edits from time to time on the Drupal end. (The php/html of the Drupal site isn't slated to change.)

Question: are these randomstring CSS files a cache or the active CSS file? How can I dynamically pull in the sites/default/css/css_(randomstring).css file when the string changes? Or is there a different CSS file I should be linking to?


texts:
I am trying to understand what the role of Memcache is. A few of my friends who have been working with Drupal for more than a year tell me that Memcache would only work for logged in users, and I would have to look to Varnish or Boost for caching the content shown to anonymous users.

While I understand that varnish acts as a reverse proxy, and caches a copy of the page, I wanted to know if anonymous users make a request, and if varnish does not have a cached copy of it, would the webserver route the request to Memcache, or would the request directly go to the database?

Architecture example: Varnish/Boost, web server, Memcache, database.


texts: PUT or POST not working with Services UUID

texts:
So after installing UUID, the service module no longer has 'create' with the entity type 'node'.

On looking at UUID documentation, it says that I can use update to both create or update content.

Now update works via PUT, right?

So I got the cookie, X-CSRF-Token which work, and am trying to make a put call
to http://d7.local/test/node/e9e521e2-1717-4a5e-a7f8-26f7d9012154. (test is the endpoint.)

I don't like this method as I have to generate a random UUID on my end (client), and on the offchance that the UUID is already present on the server, I would update something else instead of creating a new node.
The bigger problem is that it doesn't work at all. In fact, on further debugging I find that _uuid_services_entity_update() is not even able to function.

Now I'm sure I'm screwing up on major areas, so please help me out, and tell me how I should go ahead with creating a node using the UUID Services module.

function content_submit($form, &$form_state) {
  $cookie = retrieve_session_cookie();
  $server_url = variable_get('server_url');
  $token = drupal_http_request($server_url . '/services/session/token',array('headers'=>array('Cookie' => $cookie)))->data;
  $params = array(
    "type" => "article",
    "language" => "en",
    "title" => $form_state["values"]["question"],
    "body" = "This is the body"
   ),
  );

  $args = array(
    'method' => 'PUT',
    'headers' =>array('Content-Type' => 'application/json','Cookie' => $cookie, 'X-CSRF-Token' => $token),
    'data' => drupal_json_encode($params),
    );
  //Desperate man hoping any of them will work
  $response = drupal_json_decode(drupal_http_request($server_url . '/test/node/e9e521e2-1717-4a5e-a7f8-26f7d9012154', $args)->data);
  $response = drupal_json_decode(drupal_http_request($server_url . '/test/node', $args)->data);
  $response = drupal_json_decode(drupal_http_request($server_url . '/test/node', $args)->data);

  return;
}

function retrieve_session_cookie() {
  $login_details = '{"username" : "' . variable_get('server_username') . '", "password" : "' . variable_get('server_password') . '"}';
  $url = variable_get('server_url') . '/test/user/login';
  $options = array(
    'method' => 'POST',
    'headers' =>array('Content-Type' => 'application/json'),
    'data' => $login_details ,
    );
  $result = drupal_json_decode(drupal_http_request($url,$options)->data);
  $sessid = $result["sessid"];
  $session_name = $result["session_name"];
  $cookie = $session_name . '=' . $sessid;
  return $cookie;
}

I figured out what the issue was, but I am far from being pleased: In the JSON, I also had to pass the uuid (e9e521e2-1717-4a5e-a7f8-26f7d9012154) and then it works.

I have no idea which UUID is present on the site. If I am using an existing UUID, won't some content get updated? Generating the UUID on the second site doesn't look like a good idea.

Surely there must be a better way to go about this. Can anyone guide me on this?


texts: I use the Commerce Stripe module to make charges on my website, but I need to be able to subscribe through Stripe, and I have no idea how to do it. The charges I make and without problem but I would need someone to show me the way on how to change the charge to subscription through Commerce Stripe. Thank you.


texts: How to show a content without creating node for it on Drupal site?

texts:
I am creating a custom node page called node--mynode.tpl.php.
The code I'm putting in is <p> test</p>

Unfortunately nothing shows up on my Drupal site.
I have also added a node.tpl.php on the same folder as my node--mynode.tpl.php.
However I'm not sure if I have to add any code to the node.tpl.php?

Is it anything I need to add on my template.php?

Many thanks


texts:
I want to build a PDF with fields of a node. I installed Views PDF. Now I try to create a node tpl file. But Views PDF doesn't use my template.

How can I create a template, that is used by Views PDF?

thanks :)


texts:
I am using Ubercart and stripe and enabled  this module its working great for my dev version which is HTTP but when I use similar at live site having HTTPS I get below error.

Please suggest what I am doing wrong or what i need to resolve it, I tried searching it tried support but not able to find any solution.

Please suggest!

  Payment failed for order 32: Stripe Customer Creation Failed for order
  32: Invalid response object from API: (HTTP response code was 0)

Thanks!


texts:
Like in the given picture

I would like to find and print the sum along with view results. How can I do that?


texts: Any chance for alter system settings form via hook_form_alter?

texts: I would like to create module based on other custom module. One thing that will be nice to able to do is to alter module settings form fields. Is this possible?


texts:
I have a user registration form, which requires one of the fields (select list) to be populated pro grammatically from a third party service.

  // NOTE: Customize the exiting area drop down programmatically from aquarius tables
  $lang = $form['field_area']['#language'];
  $form['field_area'][$lang]['#options'] = array_merge($form['field_area'][$lang]['#options'], $rows);

This works - at least renders fine - however when I submit the form if I select anything other than the default (hardcoded) item I get a validation error:

Area: illegal value

How do I circumvent this check for this single field

Alex


texts: Form API Ajax trigger callback with size of input

texts:
I use the API Form of Drupal 8 to create my form.
I had an ajax callback on a field:

$form['association']['numero'] = array(
        '#type' => 'textfield',
        '#title' => t('foo'),
        '#size' => 10,
        '#maxlength' => 10,
        '#suffix' => '

',
        '#ajax' => [
            'callback' => '::fetchApiData',
            'event' => 'change',
            'prevent' => 'click',
        ],
    );

with my callback function :

public function fetchApiData(array $form, FormStateInterface $form_state)
{
    return 'foo';
}

It's all working fine, but i want to trigger the callback when the user writes 10 characters precisely. Does anyone has a solution for that?


texts: Query that converts a timestamp to a date

texts:
Is it possible to convert a timestamp to a date format in a query?

This is the code I am using.

$query = db_select('my_submissions', 's');
$query->fields('s', array('sid','name','company','email','phone','is_customer','submitted','count'));
$entries = $query->execute();

$rows = array();
foreach ($entries as $entry) {
  $row = array_map('check_plain', (array) $entry);
  $row['submitted'] = $row['submitted'] ? date('d.m.Y H:i', $row['submitted']) : "";
  $rows[] = $row;
}


texts: Dynamic Page Cache not working for my controller?

texts:
I have a module that defines route /x and assigns it the controller ViewNodes::show. This takes no parameters and the show method simply returns a nearly blank render array:

[
'#theme' => 'view_nodes',
'#cache' => ['tags' => ['node_list'], 'max-age' => Cache::PERMANENT, 'bin' => 'render'],
'#pre_render' => [[$this, 'buildNodeListView']]
];

The buildNodeListView then takes care of doing all the expensive logic and SQL queries to build the array. This all works fine and the page displays as expected, but devel's WebProfiler shows the SQL queries for building the render array are still being executed even when they should have been cached. This suggests buildNodeListView is always being called, which means #pre_render is always being called, which means the render array is always a miss. Am I mistaken here?

The route shows up under "bin dynamic_page_cache" and is always marked as MISS. And in the HTTP headers, there's always X-DRUPAL-DYNAMIC-CACHE: UNCACHEABLE

Is there something I'm doing wrong, or things I should check to further debug this? My settings.local.php has

//$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

and

 //$settings['cache']['bins']['render'] = 'cache.backend.null';

They're both commented out so the caching should be enabled. The Dynamic Page Cache module is also enabled. And my routes do not have the "no_cache" option.


texts: How can I print debug info in custom module?

texts:
I need to edit parts of a custom module that I didn't make, and I don't really have much experience editing/coding custom modules. How do I print debug info in functions in a custom module?
In the custom module it overwrites the buildConditions function from Entity API QueryAccess, and I need to have the function add role-related conditions only if one of two views is being viewed but I don't know how to do that, and I can't figure out how to print debug info in the function that will show up on the page so I can figure out how to do what I need to do. Do any of y'all have an idea on how I can fix this?


texts: External class (migration class) not found

texts:
I have a module for my migration. My .info is:

name = "Migrate from MHT"
description = "Module to migrate my old site content to Drupal 7"
package = "ZbLabs"
core = 7.x

dependencies[] = migrate

#  include the files that contain your Migrate classes
files[] = migrate_mht.migrate.inc
files[] = migrate_mht.module
files[] = migrate_mht_author.inc
files[] = migrate_mht_author_update.inc
files[] = migrate_mht_eventi.inc

In the migrate_mht_author_update.inc I have a class with this code:

$this->map = new MigrateSQLMap($this->machineName,
  array(
    'id' => array(
      'type' => 'int',
      'not null' => TRUE,
      'description' => 'ID utente',
    )
  ),
  MhtAuthorDestination::getKeySchema()
);

The MhtAuthorDestination class is defined in "migrate_mht_author.inc" file.

class MhtAuthorDestinationMigration extends MigrateDestinationUser {

  public function __construct(array $arguments = array()) {
    dd("MhtAuthorDestinationFin __construct");
    dd($arguments);
    parent::__construct();
  }
  [....]
}

Now when I exec "drush ms" I receive this error:

Error: Class 'MhtAuthorDestination' not found in /MY/PATH/sites/all/modules/zblabs/migrate_mht/migrate_mht_author_update.inc, line 38

In "migrate_mht.migrate.inc" file I have:
function migrate_mht_migrate_api() {

 $api = array(
    'api' => 2,
    //'migrations' => array(
      //'MhtAuthorDestination' => array('class_name' => 'MhtAuthorDestination'),
    //),

  );

  return $api;
}

I have tried without comment (//) but the error remain.

Where is my error ?


texts:
I want to create a view which shows all items of the current week based on the publication date.
The week starts on Sunday and ends on Saturday.
I tried the relative date filter in the Views module with 'between last Sunday and this Saturday'
This works. But on Sunday, it shows all the items of the past week, so, on Sunday, the view is not correct.
Could anyone help me with an solution?


texts: Restrict creation of content type by user reference

texts:
I have two content types, Location and Event. The Location has a user reference field containing the owner of the Location. The Event type has a node reference field containing the Location node it belongs to. Now I want the owners to be able to create Events only for their Locations based on this reference field.

Currently I "solved" this by having a Views reference in the Event type that only shows Locations where the author is "Drupal"-owner of the nodes. But this has two downsides:

Administrators get an empty Views reference and thus can't save Events
I have to change the author of the Location node instead of using the user reference field I added

So, is there a way to solve this?


texts: Add property to ProductVariationType via hook_entity_type_build()

texts:
Hy guys,

I'm trying to implement a simple stock management in my e-commerce. The ProductVariation will have a stock_quantity field used to track product availability.

I would like that stock_quantity field is shown only if user checks an enable_stock_management checkbox on ProductVariation bundle edit page. I.e. /admin/commerce/config/product-variation-types/default/edit

In other words I would like to mimic Submission form settings, Menu settings, Display settings functionalities of Node's bundles.

By Google-ing a bit I think that hook_entity_type_build() is the hook to use. But, once I'm in the hook what I'm supposed to do in order to add the property I need and display it in the edit form?

 /**
  * Implements hook_entity_type_build().
  */
 function commerce_warehouse_entity_type_build(array &$entity_types) {
     /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
     $entity_types['commerce_product_variation_type']-> # ... And now?;
 }


texts:
I have a view that displays nodes in fields format.

I have a Global text field in which I want to display the URL of images contained in nodes; however, I can't find how to get the URL of the images.

What I've tried:

I added the Image field and chose "Content" as the option for "Link to."  This is the link I want, but this prints out the image too (I don't need the image) and I can't use this field as a replacement pattern.
I added a link to the content itself, but then this gives me a link to a node, not the image.

In Views, how do I get a link directly to an image file (not the node containing the image file)?


texts:
I'm looking for a better way to update a set of taxonomy terms. It's currently causing cron to hang which slows down the site substantially.

    //Look through all of the stocks
    foreach ($terms_data as $symbol => $data) {
        //Check to see if term exists in the default vocabulary
        $matching_terms = taxonomy_get_term_by_name($symbol, __DEFAULT_VOCAB_MACHINE_NAME);

        //Loop through existing term(s)
        foreach ($matching_terms as $term) {
            //Load the new vocab term
            $new_term_data = taxonomy_term_load($term->tid);
            foreach ($data as $k => $v) {
                //Add in the new data
                $field_name = substr("field_".$k, 0, 31);
                $new_term_data->{"$field_name"}['und'][0]['value'] = $v;
            }
            taxonomy_term_save($new_term_data);
        }
    } //endforeach

The only way I could figure out how to get it to work was to:

Find the term that matches the $symbol variable
Loop through the matching term (1 term)
Create a new term
Update the exact fields
Save overtop of the old term

I know there has to be a better way to do this. Any ideas? Thanks in advance!


texts: Using CCK or Taxonomy with Custom Fields in Drupal 7

texts:
I am building a site that will contain data about athletes. I'm trying to decided wether to represent the athletes as CCK or Taxonomy Terms with custom fields. Athletes will contain information such as name, DOB and image, each athlete will have a page.

News articles, sports, venues, events, and teams will be other content within the site, these could be tagged with the athlete terms if we use the taxonomy solution. The alternative would be to use node reference if athlete as a custom content type.

The Taxonomy route seems more flexible and seems like a good route to take according to this article http://www.juliakm.com/how-decide-between-using-taxonomy-terms-and-cck-field-classify-content-drupal-site I just wanted to check with people in the community if there are any drawbacks to this approach or advantages of using CCK instead?

In Drupal 7 CCK and Taxonomy Terms with Fields are in the core. The two seem incredibly similar, I was wondering what is the reasoning behind having both?

Thanks,
Pete


texts: Adding PHP function code to a node returns Eval error

texts:
I activated the PHP filter and it works fine, except when I declare a function.
I keep getting the following error.

  Fatal error: Cannot redeclare test_function_test() (previously declared in /web/htdocs/www.example.org/home/modules/php/php.module(80) : eval()'d code:3) in /web/htdocs/www.example.org/home/modules/php/php.module(80) : eval()'d code on line 1034

First, I tried with the following code.

function test_function_test() {
  echo "test";
}

Then, I tried using function_exists().

if (!function_exists('test_function_test')) {
  function test_function_test() {
    echo "test";
  }
}

In both cases, I keep getting the same error message.

How can I use a define a function in the code passed to the PHP filter, without getting this error?


texts: How to get one time login for all the users?

texts:
I want to send one time login for all the users, So I am using drush uli and getting link like:

  http://html/user/reset/1/1509979615/VBPx_FMfKeJUEt1moVcsSQGUMX_tFUSYEdEfRlmq7eA

So if the user 5 wants to use one time login, this will be used for only the user 1, right? Basically I want to set one time login for all the users.

How do I pass this URL in Drupal 8?

I just wanna know that how could use this in forgot password mail.


texts: Update Quantity of Line Item in all Pending Orders

texts:
Let me begin by saying this, although I'm not new to Drupal, I am fairly new to getting into hooks and the like, so any amount of guidance is helpful. Also, I know my use case seems strange, but it's one that I need to figure out before I move forward.

My scenario in Commerce: A user specifies a price they want to pay for a product and can add any number of products to their cart. They are not charged initially, but a recurring payment is created with a run date at the end of the month. These products are all related (via Entity Reference) to a specific content type (a Project).

On the second to last day of the month, I need to be able to update ALL of the orders with a specific quantity for each line item.

I need to create a form that the product owner will use that lists all of his or her products (that relate to the specific project they've created) for sale and will give them one single text field per product. They enter the quantity there, and that quantity is applied to every order placed for the product.

The purchaser of the product will have a field in their profile called something like "Max amount per month" that they'll set so that no matter what quantity is entered, they won't pay more than the amount they've specified in their profile.

My thought is to create a Content Type called "Update Order Quantities" that could use a view to show all the products the specific project, and then add a rule to trigger once they click "Update".

I have other pieces I need to figure out along this path, but this is the most important piece right now.

Any guidance on how to accomplish this would be greatly appreciated.


texts:
Let's say I have Main Menu and I want to show it in header and in footer, to achieve that I can use Menu Block module, but using it lets say I disable one link in Main Menu, it also disables it in the clone menu in the footer. How do I have multiple copies of same menu, but with different disable options for each, and when adding new links it would update both, but at the same time be able to disable links separately on each menu?

Let's say both menus have Home and Events links. I want to show Home and Events in just header menu and disable Events in footer? And if I decide to add new link, it will add up in both menus at the same time and then again I will be able to disable it in only one of them if needed.

Makes sense?


texts: When I make a change in a user (clicking the edit tab) and save the change, the field remains the same

texts:
I go to edit (registered as admin or as the user) to make a change in the user and then I make the change in a field and click save. The message says that my change has been saved but then I scroll down and the field remains the same.

Does anybody know what the problem might be? I don't get any error messages.

My drupal version is 7.26 and I am having the problem on a number field (called telephone number), an address field, a URL field, a text field, an image field (I try deleting a photo and it appears again after saving). Basically, all the fields except for username and email address.

Also, if I fill in the registration form (as an anonymous user) a new account is created but only the compulsory fields are filled. If I fill any field that is not compulsory the data is lost. The field later appears as empty in the user's account.

If I try to edit content I do not have any problems. It works fine.

I am working on localhost and not connected to a web server.

I have checked in /admin/reports/dblog and there is nothing.

Thanks in advance.


texts: How to alter image captcha title in drupal 7

texts: I am working on drupal 7 image captcha module.I want to alter or hide image captcha title like 'What is in your code'.How can I do it by without hacking the module?


texts: Date range issues with timezones in twig

texts:
We're using date ranges for some events in an application. We're finding that when we use the date value and end_value independent of one another then the timezone is incorrect.

For example, inside a view, we're experimenting with our values using twig.

{{ dump(field_open_close_date) }}

Give us this

field_open_close_date' =>
  object(Drupal\Core\Render\Markup)[7546]
    protected 'string' => string '2020-02-10T20:00:39 - 2020-03-18T14:00:00' (length=41)
   'field_open_close_date__value' => string '2020-02-10T09:00:39' (length=19)
   'field_open_close_date__end_value' => string '2020-03-18T03:00:00' (length=19)

The full date range is correct. Focussing on the end date, 2020-03-18T14:00:00 is correct as we are in +11 right now with daylight saving. But, when looking at the end_value, you can see a +0 date time of 2020-03-18T03:00:00.

I can't seem to (cleanly) fix these in a view and I really don't want to fix them in each view and then in each other location because all other non-views and non-twig examples of this field has the same result. Unless I use the entire range, it wont be correct.

Note that in future I'll just use 2 date fields but we have too much data in the db to change this now.


texts: How do I use the Drupal 7 API to change ownership of a comment

texts:
This function function node_assign_owner_action() is provided by the Drupal 7 API to allow modules change node ownership,

I've searched, but not found a similar function that let me change the ownership of comments. Does anyone know how to change ownership of a comment without hacking the {comment} table directly, and without breaking existing incoming links?

I know that I can update the fields {comment}.uid, {comment}.name and {comment}.mail with the appropriate values, but as I understand things, contributed modules should never update tables "owned" by another module directly.

The only method I've found so far is to recreate the comment under new ownership.  This is not a good solutions because it will invalidate all incoming links that used the permalink associated with the original comment.


texts: How to disable user and e-mail input auto-fill?

texts:
I'm trying figure out, how I can disable auto-fill or change markup of 'user' and 'e-mail' input forms, when a user is logged in.

This auto-fill feature is breaking my design, because the 'user' and 'e-mail' markup are just a text inside a div and I can't apply a correct style on it.


texts:
In my default/files/languages folder I have two JS files:
es_BW4ZdvqK9tDPZ0JRAIb4Da2ATqVPvi01H1gYXugKgWo.js
es_iXHy-aczd8O7uaoQze0vEQJL0ROMrskX7l3yWYGxC9r.js

They are very similar, but one has some missing translations. The one with missing translations is the one that Drupal uses. Therefore some of my strings are not being translated.
I have tried deleting the unwanted file, but after clearing the cache it is always regenerated.
Any ideas? Thanks.


texts: (Windows & Plesk) The directory C:\Windows\Temp\ exists but is not writable

texts:
I'm trying to deploy a site to a Windows VPS (which I am new to) which uses Plesk Web Pro Edition (which I'm also new to). I'm getting the standard error: The directory C:\Windows\Temp\ exists but is not writable which I am very used to dealing with when using linux, but not with Windows / Plesk.

Presumably I just need to change the permissions on the temp directory,  but as far as I can tell I'm unable to SSH into the server, and I've tried using the remote connection but access to C:\Windows is denied when I try to make any changes.

Has anyone had any experience with dealing with this?


texts:
I've tried to theme a portion of a node by adding some values in to it using

hook_theme and a twig template

I've used hook_node_view to add a few variables and then I have included the theme specified in hook_theme and printed it in twig template.

Here is the code; nothing is working like nothing.

function content_statistics_node_view(EntityInterface $node, EntityDisplay $display, $view_mode) {
    $node_count = some function called;
    foreach ($node_count as $key => $value) {
      $node_statistics = array(
        '#theme' => 'content_statistics_list',
        '#letter' => $value->letter,
        '#word' => $value->word,
        '#sentence' => $value->sentence,
      );
    }
  }
  $node->content['content_statistics_list'] = array(
    '#markup' => drupal_render($node_statistics)
  );
}

/**
 * Implements hook_theme().
 */
function content_statistics_theme($existing, $type, $theme, $path) {
   return array(
    'content_statistics_list' => array(
      'variables' => array('letter' => NULL, 'word' => NULL, 'sentence' => NULL),
      'template' =>  drupal_get_path('module', 'content_statistics') . '/templates/' . 'content-statistics-list',
    ),
  );
}

In content-statistics.html.twig, I have printed {{ letter }} but it is not showing anything on the node page. It is also causing an error.

  Warning: Attempt to modify property of non-object in content_statistics_node_view()


texts:
I am in search of a drupal Module for simple inventory tracker. Please see me as a novice in drupal.

My requirement is that, there are 3 levels.
A least level employee request for a inventory item to 2nd level. 2nd level manager approves and sends it to first level, First level manager approves/denies, replies the employee with the details. These items should be tracked with an inventory management tracker thereby showing current status for each requested items.

please suggest me the drupal module for it. I think ubercart is too much for this simple application.

Will CCK along with users module enough for this application? Any suggestions will be highly appreciated. Thanks


texts:
I am making a website where certain users can create events. They can also create a page with information about their events in general. On the bottom of the general events page, I would like to display all events created by that user.

I am working with EVA do fetch all events. I thought I should make a contextual filter, targetting the author:id(110), but this doesn't work. When I debug, I notice that Views thinks the author id(should be 110) is the node id(=56). Am I doing something wrong?

Kind regards,
Tom


texts:
I have created a custom form in Drupal 8 where I want to select a vehicle make, populate the models under the vehicle make and avail the list for selection in another field. I am stuck at the Ajax callback I have googled but haven't found a solution. I need guidance on how to use Ajax to get the desired results. My code is the following.

$query = \Drupal::database()->select('vehicle_make', 'veh');
$query->fields('veh', ['make_id','make_name']);
$results = $query->execute();
$options_makes = array();

foreach ($results as $result) {
$options_makes[$result->make_id] = $result->make_name;
}

$form['vehicle_make'] = array(
  '#type' => 'select',
  '#title' => $this->t('Vehicle Make'),
  '#options' => $options_makes,
  '#default' => '--Select Make --',
  '#ajax' => array(
    'callback' => 'ajaxfunction',
    'wrapper' => 'vehicle-model',
    'effect' => 'slide',
    ),
);

$form['vehicle_model_container'] = array(
  '#type' => 'container',
  '#prefix' => '
',
  '#suffix' => '
',
);

if ($form_state->hasValue('vehicle_make')) {
  $vehicle_make = $form_state->getValue('vehicle_make');
  $subquery = \Drupal::database()->select('vehicle_model', 'md');
  $subquery->join('vehicle_make', 'mak', 'md.make_id = mak.make_id');
  $subquery->fields('md', ['model_id','model_name']);
  $subquery->condition('md.make_id', $vehicle_make);
  $results = $subquery->execute();
  $model_options = array();

  foreach ($results as $result) {
    $model_options[$result->model_id] = $result->model_name;
  }

  $form['vehicle_model_container']['model'] = array(
    '#type' => 'select',
    '#title' => t('Vehicle Model'),
    '#options' => $model_options,
  );

  function ajaxfunction(array $form, FormStateInterface $form_state) {
    return $form['vehicle_model_container'];
  }


texts: Linking to another region in the same page?

texts: My page is broken down into region-a and region-b, region-a links to several Drupal nodes. When I click the links I want the nodes to display in region-b and not in a new page. Is that possible?


texts: Render a select box in custom views field plugin hadler

texts:
I have created a custom field plugin handler. In render() function I want to render a select box. I tried using a renderable array but it strips HTML <select> and <option> tag. If I return a string entire HTML is printed as a string.
Normal HTML tags like <div> or <ul> works fine but input elements or select box are stripped out.

Please help.


texts:
If you have for example http://www.example.com/node/5 and you go to that node page you get the page created by Drupal. My node is about an organization and I want on the bottom of that page a list with all the employees. Is there a way that I can do this with the views module?

Because I don't want to use PHP or HTML in the file for that. I know how to create a new view but if I create a new one I cannot use the same page link.

I think that this is a common problem but can't find a solution.


texts: How to send an email to the admin when user fails to login?

texts:
I need to implement the functionality to notify the admin user via email whenever someone fails to login entering wrong password. Basically simple email format containing the username for failed account to login. Can someone give guidance or suggestion?

P.S: I checked the Rules module but it doesn't have required Rules event like "When user fails to login".


texts: What OG functionality can be triggered by building URLs?

texts:
The OG README file states

  You may craft your own URLs which produce useful behavior. For example,
   node/add/group-content?gids_node[]=4 will add a select the group with node ID 4, in the node form. The prefixed entity can change to indicate other entity types allowing crafting the URL and you can have multiple variables, for example, node/add/group-content?gids_node[]=4&gids_user[]=3&gids_group[]=5,6,7. The above URL will select the group with node ID 4, and the group with user ID 3, and the groups with the unique group ID 5, 6 and 7.
  Note that the actual entity of group ID 5, 6 and 7 can be any entity (e.g. nodes or users).

The above has several typographical errors, and I'm not sure if this is relevant for Drupal 7.

Does anyone have a detailed explanation of current URL crafting options for Organic Groups?


texts:
I have a view that displays data for each user. Now I would like to be able to order the users.

One solution would be to add a new field called something like field_weight to the user content type and then use this field to sort the view, but preferably I would like to do this through drag and drop from the admin/people configuration page.

I installed the weight module, but it doesn't seem to support setting the weight for a user.

Is there a module that can do this?


texts: How to create an alternate title for a node when in a nodequeue?

texts:
We want to be able to override the title of certain content items, but only temporarily, while they're included in a nodequeue. For example, we have a nodequeue view block in a small "featured" sidebar, without much room for long titles.

I want to avoid adding an alternate title to each content type because there are lots of content types and the alternate title only needs to be used while the node is in the nodequeue (ie, featured). Once the node gets replaced in the nodequeue, the alternate title would be cluttering up the database.

I found a module called Nodequeue Annotate, that happens to have the data structure I needed but it's intended for an unrelated use case. I've written a companion module to make it do what I need, but it seems like a bit of a hack to piggyback on a module to make it solve an unrelated use case.

So, I'm curious how would others handle that use case?


texts: How to set properties for a specific chart only using the views integration of the Charts module?

texts:
I'm creating charts using the charts module and its integration with the Views module.

I want to set options for only some charts and found that in charts.api.php:

/**
 * Alter an individual chart before it is printed.
 *
 * @param $chart
 *   The chart renderable. Passed in by reference.
 * @param $chart_id
 *   The chart identifier, pulled from the $chart['#chart_id'] property (if
 *   any). Not all charts have a chart identifier.
 */
function hook_chart_alter(&$chart, $chart_id) {
  if ($chart_id === 'view_name__display_name') {
    // Individual properties may be modified.
    $chart['#title_font_size'] = 20;
  }
}

It seems perfect for what I want because it has the if ($chart_id === 'view_name__display_name') { line for specific views but I wonder if I directly add some settings code such as $chart['#title_font_size'] = 10; here (to charts.api.php) or is there any other way to do this?

I mean overriding the charts.api.php inside of the charts module is OK or do I have to write and run these codes anywhere else?

EDIT:

Based on rooby's comments, these are the two ways that I tried to set the properties for each charts (created with views module):

1. Custom Module

I created a custom module called benim.

This is the benim.info file:

name = Benim
description = Override charts properties.
package = Other
core = 7.x

And this is the benim.module file:

<?php

function benim_hook_chart_alter(&$chart, $chart_id) {
  if ($chart_id === 'chartim__block_1') {
    // Individual properties may be modified.
    $chart['#title_font_size'] = 50;
    $chart['subtitle'] = array(
    '#text' => 'Source:',
    );
    $chart['xaxis'] = array(
    '#type' => 'chart_xaxis',
    '#allowDecimals' => 'true',

    );

  }
}

function benim_hook_chart_definition_alter(&$definition, $chart, $chart_id) {
  if ($chart['#chart_library'] === 'highcharts') {
  if ($chart_id === 'chartim__block_1') {
    $definition['title']['style']['fontSize'] = 100;
  }
}
}

2. Template.php

I added the lines below to the theme's template.php.

function mytheme_hook_chart_alter(&$chart, $chart_id) {
  if ($chart_id === 'chartim__page') {
    // Individual properties may be modified.
    $chart['#title_font_size'] = 150;
    $chart['subtitle'] = array(
    '#text' => 'Source:',
    );
    $chart['xaxis'] = array(
    '#type' => 'chart_xaxis',
    '#allowDecimals' => 'false',

    );

    $chart['yaxis'] = array(
    '#type' => 'chart_yaxis',
    '#allowDecimals' => 'false',

    );

  }
}

function mytheme_hook_chart_definition_alter(&$definition, $chart, $chart_id) {
  if ($chart['#chart_library'] === 'highcharts') {
  if ($chart_id === 'chartim__page') {
    $definition['title']['style']['fontSize'] = 100;
  }
}
}

(above mytheme is the name of the actual theme)

Unfortunately, both two ways didn't work for me. I wondered if the $chart_id parameter is correct and checked for different views but the result didn't change.

Note: I also tried clearing caches, and trying inside another theme.


texts: How to debug "undefined" 404 error in console on front page

texts:
I'm getting a strange 404 error on the front page only, which seems to be causing some other issues for me. I'm hopeful if I solve this it will take care of those, too.

On the front page only, when I load the console, I see the following error:

I am not sure what would be causing this as the page appears to load correctly and it isn't giving much of a clue as to what it is trying to load.

How do I debug from this point?


texts: How to create a link from node view and pass information to a webform

texts:
In Drupal 8, I have a webform field attached to a node with the Link to form formatter enabled.

Can I add the ID of that node in the Link custom attributes (YAML) textarea to display a block view of some node fields?

My goal is to be able to use a contextual filter on the block view to display the node information like title and some other fields around the form


texts: global variable/array unset when hook_field_presave() is being called

texts:
I am trying to pass a global array and work with it in hook_field_presave() but that global array is unset. How do I pass a global array and work with it in presave?

example

function find_feed_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
   etc.
   etc.
global $testvar;
$testvar = $array = array(
    "foo" => "bar",
    "bar" => "foo",
    );
}

function find_feed_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
   global $testvar;
   dpm ($tesvar);  // result = NULL
   etc.
   etc.
}


texts: How to print node id in a block in a module?

texts:
I have created a ctools jump menu in a block in a module. I need to get the node id for use in the links. How can I get the node id printed in the block?

Here is my code;

<?php

function boathood_block_info() {
$blocks = array();
$blocks['boathood_ABC'] = array(
'info' => t('Boathood Block'),
);
return $blocks;
}

 function boathood_block_view($delta = '') {
 $block = array();
switch ($delta) {
case 'boathood_ABC':
  $block['subject'] = '';
  $block['content'] = _boathood_BLOCK_ABC_CONTENT();
  break;
 }

  return $block;
  }

 function _boathood_BLOCK_ABC_CONTENT() {
$output = boathood_page();
 return $output;
 }

 function boathood_page() {
 global $user;
 ctools_include('ajax');
 drupal_add_js($sample_style, 'setting');
 ctools_add_js('ctools-ajax-sample', 'ctools_ajax_sample');
 ctools_add_css('ctools-ajax-sample', 'ctools_ajax_sample');
 ctools_include('jump-menu');
 $form = drupal_get_form('boathood_jump_menu_form');
 $output .= drupal_render($form);
 return array('markup' => array('#markup' => $output));
 }

  function boathood_jump_menu_form() {

 $mynid = $node->nid;

 $url = url('node/' . $mynid);
 $url2 = url('node/' . $mynid);
 $url3 = url('node/' . $mynid);
$form_state = array();
$form = ctools_jump_menu(array(), $form_state, array($url =>    t('one!'),$url2 => t('two'),$url3 => t('three')), array());
return $form;
}


texts: Batch processing possible without redirects?

texts: I'm using the Views Data Export module for exporting Views as .csv. Standard exports work in most cases, but with larger table only batch exports work.  The problem with batch exports is that the redirects don't work well with systems using load balancing between servers and external caching services.  I'd like to have something like the standard exporting, but processed the same way as batch processing so that PHP memory and execution time limits aren't reached.  I've been reviewing the documentation as well as the Views Data Export module, but I haven't found a way to do this yet.


texts: Determine Array Key For Field Type Programatically

texts:
Different fields have different keys for the actual 'value' of the field. For example a regular text field has:

$node->field_my_text_field[$node->language]['value']

Whereas if I have a field using the email module, it looks like this:

$node->field_my_email_field[$node->language]['email']

I'm working on a function that saves a whole bunch of fields, and I want it to be as flexible as possible, it has a loop that looks like this:

foreach($person_details as $k=>$detail) {
    $node->{'field_'.$k}[$node->language][0]['value'] = $detail;
}

This is no good at the moment since 'value' is hard coded, and I have some fields in there that use 'email' and a few others from various modules.

Is there any way to know in advance what the key should be?


texts: Add some extra text(html+content) before start view. (Within the div from the view)

texts:
I'm trying to put some extra hard coded HTML into a view before the sum of the view starts.

www.peace-in-the-city.be

On the homepage you see a section 'visitors'... it shows 4 recent visitors. If my client add a new visitor in the backend... This new visitor will show up a older one is disappearing...

But now my client wants to show one visitor (kermit the kicker) always on the left.

So i want to put that visitor hard coded in...
First i tried to put into the home.tpl...
But then it shows up out of the div around the view, and that f*** up my design. I used the classes from the view to style...

So now I want to put the HTML-code into the view self (within the divs from the view), put i don't find the solution...

Anybody? I tried some options "HEADER" in the view, but there is no space showing up where i can put the HTML-Code in...

Thanks for reading and support :-)

Kristof


texts: Hook into scheduler to delete node from nodequeue on unpublish

texts:
I'm working on Drupal 6 site and trying to solve the following issue. If scheduler unpublished a node, it should be deleted from all nodequeues it's in.

Currently, I'm looking for hooking into the publish/unpublish events of scheduler, but I'm not finding a good example.


texts: Could not Embed Iframe in CKeditor 3.6.6 with WYSIWIG 7.x

texts:
am using WYSIWYG with CKedior but I am not able to embed iframe into this. I went through many documentations and stack pages but i couldnt find a solution.

CKeditor version : 3.6.6.2.7696
WYSIWYG : 7.x-2.2
Media WYSIWYG : 7.x-2.0-alpha4

Any help will be appreciated .Thanks in Advance


texts:
I wrote a custom views handler, that mark message private to 0 or 1 or 2; any is value of hers label [MARK_READ,ARK_NEW,...] :

function mydevel_views_data() {
  $data['mydevel']['table']['group'] = t('mydevel');
  $data['mydevel']['table']['join'] = array(
    // Exist in all views.
    '#global' => array(),
  );

  $data['mydevel']['mydevel_isnewmessage'] = array(
    'title' => t('is new message field'),
    'help' => t('is new message field.'),
    'field' => array(
      'handler' => 'mydevel_handler_field_isnewmessage',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'mydevel_handler_filter_isnewmessage',
    ),
  );

and wrote a filed handler that work properly;
message_mark function is wrote on mydevel module file and work currectly;
if the message is new that filed label row by "now":

class mydevel_handler_field_isnewmessage extends views_handler_field_numeric {

    var $field_alias = 'mydevel_field_isnewmessage';

    function query() {
    }

    function option_definition() {
        $options = parent::option_definition();
        //dsm($this);
        return $options;
    }

    function options_form(&$form, &$form_state) {
        parent::options_form($form, $form_state);
    }

    function get_value($values, $field = NULL) {
        return intval(message_mark($values->mid, $values->message_timestamp));
    }

    function render($values) {
        $value = $this->get_value($values);
        $value_theme = theme('mark', array('type' => $value));
        return $value_theme;
    }

}

Now, i want to write a views filter handler that filter on that filed on numeric mode [0 or 1 or 2] or on check list mode [all, read, new, updated].
but I don't want to overwite query function on filter handler and want to use from value that returned by this common handler filed (mydevel_handler_filter_isnewmessage) that added to views filed.
can wrote this idea by extend the standard views handler?
what i do my dears?
I wrote this but not work: this is return error

class mydevel_handler_filter_isnewmessage extends views_handler_filter_numeric {
  var $always_multiple = TRUE;

  function option_definition() {
    $options = parent::option_definition();
    return $options;
  }

  function operators() {
    $operators = parent::operators();
    return $operators;
  }

  function query() {
  }

}

tank you a lot.


texts: How to programmatically apply a fee/promotion?

texts:
I am trying to use the new commerce_fee module to programmatically apply a fee during admin payment flow. I did a simple form_alter to the commerce_payment_add form to have a list of my Fee entities show up as checkboxes. This allows staff to add the specific fee if they choose.
I also set:
$form['payment']['amount']['#default_value']['number'] = $form['payment']['amount']['#default_value']['number'] + $form_state->getValues()['fee_amount'];

so that the fee is added in to the next step as the amount which will be charged to the customer's CC.
But the Fee is not properly added to my Order. I have seen Commerce documentation and a post here re: this but they do not work. At the moment I have a #submit added to the payment_add_form which follows some of the code I have seen; but no luck:
function _sia_add_fee_to_order (&$form, $form_state) {
  // its crazy that i need to figure out the Order from the URL; why isn't it in the form??
  $url = $_SERVER['REQUEST_URI'];
  $bits = explode('/', $url);
  $order_id = $bits[4];

  $order = Order::load($order_id);
  $fee = current(Drupal\commerce_fee\Entity\Fee::loadMultiple());

  $price = $fee->getPlugin()->getConfiguration()['amount'];
  $splitter = \Drupal::getContainer()->get('commerce_order.price_splitter');
  $amounts = $splitter->split($order, new Price($price['number'], $price['currency_code']));

  foreach ($order->getItems() as $order_item) {
    $order_item->addAdjustment(new Adjustment([
      'type' => 'fee',
      'label' => $fee->getName(),
      'amount' => $amounts[$order_item->id()],
      'source_id' => $fee->id(),
    ]));
  }

  $fee->apply($order);
  $order->recalculateTotalPrice();
  $order->save();
}

The post I saw here left out all the commerce documentation steps of adding adjustments to each line item and simply had the $fee->apply() function. Neither of theses work.
ADDED:
More info about commerce_fee: https://www.drupal.org/project/commerce/issues/2903716, https://github.com/lisastreeter/commerce_fee
This is basically the commerce "promotion" module but redone to be more specific to fees. The question i have posted could be asked re: promotions as well; as should apply equally to either.


texts: Using fivestar_get_votes() to show the votes on a node

texts:
I need to display a multi-axis review system using Fivestar in node.tpl.php in Drupal 7.

I created the content type according to this tutorial, which is for Drupal 6, and I need to know how I can call votingapi_select_results() and fivestar_theme() in Drupal 7.

Initially, I tried the following code.

$design_rating = votingapi_select_results(array('entity_id' => $node->nid, 'tag' =>'design', 'function' => 'average'));
print_r($design_rating );

It caused a fatal error.

Later, I used fivestar_get_votes() as in the following code.

$design = fivestar_get_votes('node', $node->nid, 'design', NULL);
print_r($design);

I got an array.

  Array (
    [average] => Array (
      [vote_cache_id] => 128
      [entity_type] => node
      [entity_id] => 18
      [value] => 80
      [value_type] => percent
      [tag] => design
      [function] => average
      [timestamp] => 1332162918
    )
    [count] => Array(
      [vote_cache_id] => 127
      [entity_type] => node
      [entity_id] => 18
      [value] => 1
      [value_type] => percent
      [tag] => design
      [function] => count
      [timestamp] => 1332162918
    )
    [user] => Array(
      [vote_id] => 8
      [entity_type] => node
      [entity_id] => 18
      [value] => 80
      [value_type] => percent
      [tag] => design
      [uid] => 1
      [timestamp] => 1332162918
      [vote_source] => 122.164.241.37
      [function] => user
    )
  )

I don't know how to use it to show the result shown from the Fivestar module. How can I do it?

i tried with below code in node.tpl.php and it displayed result as '3' not a fivestar widget.

$variables=array('rating'=>60,'stars'=>5,'tag'=>'design');
echo theme('fivestar_static',$variables);

Am i missing anything in it? or is there any other procedure to call theme function in node.tpl.php in drupal 7?


texts: Using #cache key on a render array generates 2 entries per role, how to change that?

texts:
On a page controller I have a method that displays the content via a render array. It also caches the rendered output using the #cache key:

  public function viewContent(NodeInterface $node) {
    $content = array(
     '#entity' => $node,
     '#sorted' => TRUE,
     '#pre_render' => [[$this, 'buildList']],
     // Cache the render array until the lock history/node is changed.
     '#cache' => [
      'keys' => ['my_module', 'node', $node->id()],
      'tags' => ['my_module:node:' . $node->id()],
     ],
   );
    return $content;
  }

But I noticed that drupal is generating 2 cache entries per user role in the cache render table as you can see in the screenshot:

Is it possible to generate only 1 set of entries for all users and manually pick the cid using the builtin render #cache properties?


texts: How do I add "Update Status of User" action to a view?

texts:
I want to create a user list with the Views module, to change the user status. I use the Views Bulk Operations module, but it has no Change status or Active user action.

How can I enable (or change the status of) users in a view table list with one click?


texts:
In Drupal 8 I can see the list of broken links at Administration->Configuration->System->Broken Link.
It is showing thousands of records with pagination.

I'm using Broken Link Module.

Is there any way we can export the entire record as a CSV or XLS file?


texts: How to display message (NDA, warning, etc.) before content can be viewed?

texts:
Say a user wishes to view a certain piece of sensitive content. How can we have the site first respond with a notice, before the content can be viewed?

Specifically, I'm looking to have the site respond with a simple NDA (Non-Disclosure Agreement) before displaying certain nodes (and even then, only to registered users, of course). But I can imagine many more uses: displaying conditions and terms related to the content, displaying an age warning for... er, more delicate content, and so on.

In my case, I need every sensitive node to display an NDA; presumably, the notice would be dismissed by some sort of "Agree" or "Proceed" link, which would then take the user to the content. After that, the node would ideally remember that the user has permission for future viewings of that specific node (i.e., doesn't need to see and agree to the notice every time).

I can imagine other sites, though, that might want to enable agreements for whole groups of content (such as a node type): view the notice once, and then have free access to any of the affected nodes.

Also, it would be ideal to have the option of allowing unimpeded view of the teaser, with the notice coming into play only when a reader tries to view the full node.

Whatever the details, does anyone have ideas for enabling this? I've found many modules or techniques to prevent access to specific nodes by user role, or password access, etc., but not to grant access after displaying a notice. There's the Legal module (http://drupal.org/project/legal) for displaying terms and conditions upon registering to become a user, but that doesn't handle viewing specific nodes.

As always, I suspect I'm missing something obvious. My kingdom for a solution!


texts: How to convert subset of users into a content type?

texts:
I have a Google Map set on view of the node type. I am mapping several piece pieces of content on that map (group meeting locations, organization meeting places, etc). I would also like to be able to add my users to this map but I'm not given "users" as a content type in my list of options.

For this reason I want to take a subset of my users and create a new content type to add to the map. I know I could map a view the users, so it looks like users are a special content type.

So, it seem like the best approach is to create a content type based on a subset of my users (users that aren't admins, or who register under member, chapter head, etc roles).

I realize I could do this manually, and then have the admin add the users that match the criteria, but that seems like a work around, and fairly tedious.

With new users, I could probably hack together a rule that populates the content type from the profile fields, but I have a substantial amount of registered users already.

So, is there some way to populate a content type with user fields? Such that the content type was populated with the fields from every user of a particular role.


texts:
In Drupal 6, I am not happy with the default values for #ahah['event'].

What I want is the effect of having #ahah['keypress'] but when it is set, it also overrides any #ahah['event'].
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/6#ahah

Besides having the form submitted via AJAX when the 'ENTER' key is pressed, I also want the form submitted every 3 seconds after a change is made in the AHAH textfield, but I don't want both types of events to collide and to send the same request nearly at the same time.

Thus, I want to be able to override the AHAH bindings, and create my own events which will trigger my own action which will in turn call the AHAH backend, with the returned result being handled by Drupal in the normal way.

I am currently studying drupal.js, ahah.js and form.inc in hope of understanding how it all works and finding a solution. But I am afraid it's all above my pay grade. Hence this question. Thanks.

I am also wondering if I am not better off by not using FAPI '#ahah' at all and create everything on my own directly using jquery, bypassing FAPI '#ahah'...


texts: How to display the rendered entity of a store in the purchase funnel?

texts:
I created a link that displays the "Terms and Conditions" of the store to which the shopping cart relates in a modal window.
This link a page in a modal window.
I want to replace the page rendered by the store's rendered entity with the cgv display mode (this is the machine name of the display mode in my store type).
What should I change in my code ?
my_module/src/Plugin/Commerce/CheckoutPane/MarketplaceTermsAndConditions.php :
<?php

namespace Drupal\commerce_marketplace_terms_and_conditions\Plugin\Commerce\CheckoutPane;

use Drupal\Component\Serialization\Json;
use Drupal\Core\Form\FormStateInterface;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneBase;
use Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\CheckoutPaneInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;

class MarketplaceTermsAndConditions extends CheckoutPaneBase implements CheckoutPaneInterface {

  public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
    $store_name = $this->order->getStore()->getName();
    $store_id = $this->order->getStoreId();
    $pane_form['#attached']['library'][] = 'core/drupal.dialog.ajax';
    $attributes = [
      'attributes' => [
        'class' => 'use-ajax',
        'data-dialog-type' => 'modal',
        'data-dialog-options' => Json::encode([
          'width' => 'auto'
        ]),
      ],
    ];
    $link = Link::fromTextAndUrl(
      $this->t('terms and conditions of the store "@store_name"', ['@store_name' => $store_name]),
      Url::fromUri("internal:/store/$store_id/cgv", $attributes)
    )->toString();
    $pane_form['marketplace_terms_and_conditions'] = [
      '#type' => 'checkbox',
      '#default_value' => FALSE,
      '#title' => $this->t('I have read and accept @terms.', ['@terms' => $link]),
      '#required' => TRUE,
      '#weight' => $this->getWeight(),
    ];
    return $pane_form;
  }

}


texts: Display inline images with specific image style

texts:
Is there some way to get inline images (inserted with Media/FCKEditor) to be displayed in a specific image style? I can only get them displayed in the original format.

I have tried the Picture module but that somehow "uses" the class attribute so I can not set a specific class for an image.

Thanks!


texts:
I have a problem returning table and form in page callback at the same time it only works if one of them only returned.

function _table_maps(){
$query = db_select('maps','m');

$result = $query->fields('m')
                ->extend('TableSort')
                ->extend('PagerDefault')
                ->limit(50)
                ->execute();

$header = array('Title','Longitude','Latitude','Description');

$rows = array();
while($data = $result->fetchAssoc())
{
    $rows[] = array(
        $data['maps_title'],
        $data['maps_long'],
        $data['maps_lat'],
        $data['maps_desc']
    );
}

$output = theme_table(
            array(
                "header" => $header,
                "rows" => $rows,
                "attributes" => array(),
                "sticky" => true,
                "caption" => "",
                "colgroups" => array(),
                "empty" => t("Table has no row!")
                )
            ).theme("pager");

return $output;

}

function aieadmin_map_form($form_state){

$form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#size' => 30,
    '#maxlength' => 64,
    '#description' => t('Enter the Title For the Location'),
);

$form['long'] = array(
    '#type' => 'textfield',
    '#title' => t('Longitude'),
    '#size' => 30,
    '#maxlength' => 64,
    '#description' => t('Enter the Longitude For the Location'),
);

$form['lat'] = array(
    '#type' => 'textfield',
    '#title' => t('Latitude'),
    '#size' => 30,
    '#maxlength' => 64,
    '#description' => t('Enter the Latitude For the Location'),
);

$form['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Describe it'),
    '#cols' => 60,
    '#rows' => 5,
    '#description' => t('Location description.'),
);

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

return $form;
}

/*******Page Callbacks********/

function aieadmin_callback_mod(){
$page = _table_maps();
$page .= drupal_get_form('aieadmin_map_form');
return $page;
}


texts: updatedhow to set default value in a form field got from another page(form)?

texts:
All,

What I want to do:
On the Home page, I have an input field in which a user can insert their invite code, the invite code gets validated via ajax and if correct, popups the registration form. Its important that the user cannot get access to the registration form without the correct invite code. How can I bullet proof this concept into my Drupal7 install? I am using Regcode module for registration purpose.

The problem I have is that if the user knows the address to the registration form, they can merely enter that into the browser's address bar and register without having to gain an invite code.

One solution I thought was that the invite code is needed on the actual registration form as well, so if they do access the form via the browser's address bar, they will still need to input the invite code. However, if they already did place the invite code in the input field (on the Home page), it would automatically populate the invite code field in the registration form.

What problem I am facing:
Im not sure how to go about transferring the invite code (which the user inserted) into the registration form that pops up upon validation.
The form(single field) on the front page is written by myself inside a block.

Here i am confused how to take the form value to the registration form and how to get the value of field and after getting how to set the value as default in the regcode text field.

 <form method="GET" action="?????"></form>

the modulea's part which alter the registration form is as follows

 function regcode_form_user_register_form_alter(&$form, &$form_state) {
  $code_optional = variable_get('regcode_optional', FALSE);
  $account = $form['#user'];

  $form['regcode']['regcode_code'] = array(
    '#type' => 'textfield',
    '#title' => variable_get('regcode_field_title', t('Registration Code')),
    '#description' => variable_get('regcode_field_description', t('Please enter your registration code.')),

    '#default_value' => ???????????,

    '#required' => !($code_optional || user_access('administer users')),
    '#element_validate' => array('regcode_code_element_validate'),
  );
  // Capture the code from the url and inject it into the registration form
  if (isset($_GET['regcode'])) {
    $form['regcode']['regcode_code']['#value']       = check_plain($_GET['regcode']);
    $form['regcode']['regcode_code']['#description'] = NULL;
    $form['regcode']['regcode_code']['#disabled']    = TRUE;
  }
}

i Hope, its understandable now


texts:
I'm using Adaptive themes in Drupal 8.

I'm trying to have a custom layout for the node/edit page, but don't know what to call the layout suggestion.

What is the page suggestion called?


texts: How do I add Google Scholar meta tags to a custom content type?

texts:
I use drupal 7 and I have custom content type named "Journal"
I want add Google Scholar meta tags to "Journal" nodes.
Like this:

<meta name="citation_journal_title" content="Journal Name">
<meta name="citation_authors" content="Last Name1, First Name1; Last Name2, First Name2">
<meta name="citation_title" content="Article Title">
<meta name="citation_date" content="01/01/2007">
<meta name="citation_volume" content="10">
<meta name="citation_issue" content="1">
<meta name="citation_firstpage" content="1">
<meta name="citation_lastpage" content="15">
<meta name="citation_doi" content="10.1074/jbc.M309524200">
<meta name="citation_pdf_url" content="http://www.publishername.org/10/1/1.pdf">
<meta name="citation_abstract_html_url" content="http://www.publishername.org/cgi/content/abstract/10/1/1">
<meta name="citation_fulltext_html_url" content="http://www.publishername.org/cgi/content/full/10/1/1">
<meta name="dc.Contributor" content="Last Name1, First Name1">
<meta name="dc.Contributor" content="Last Name2, First Name2">
<meta name="dc.Title" content="Article Title">
<meta name="dc.Date" content="01/01/2007">
<meta name="citation_publisher" content="Publisher Name">
<meta name="robots" content="noarchive">

I tried the Metatag and Custom Meta modules. With the Metatag module, I can't add custom meta tags; with the Custom Meta module, I can't add custom meta tags to a content type.

How can I achieve this?


texts: Hide a field on a user profile if the logged in user has a specific role

texts:
I have many fields added for users. What I want is the following:
If the logged in user has a role W and is viewing a user page that belongs to a user of role X then show field Y. Otherwise, field Y should not be visible.

I have tried using a a module named "Field Formatter Conditions" that supposedly has rules integrations and offers the Event: A field is being rendered and the Action: Hide a field. However, when I select the action to hide the field, There is nothing to be configured and I just get the save button.

Kindly suggest how I can accomplish the target and I prefer if the solution is based on rules.


texts:
Is there a way to add a specific class to the img tag in a view? I'd prefer to use a template to perform it. I can see how I can change what classes the image is wrapped in, but I don't see a way to edit the classes of the img tag itself.

I see there's a way to edit the image field using views-view-field--field-image.tpl.php however the only variable I can see that is available is $output.


texts: How do I change submit URL for exposed search filter?

texts:
I've created view using Search API Views with two different displays.
First Page display (by_terms) and with the following options:

Page settings: Path:/taxonomy/term/%
Contextual filters: Category: Term ID (indexed)
Filter criteria: Search: Fulltext search (exposed)

And second Content pane display (panel_pane):

Use Panel path: Yes
Filter criteria: Search: Fulltext search (exposed)
Link display: Custom URL set to search/results

When I open page with 1st display /category/list/name (which is alias to /taxonomy/term/123) and submit Search input, it goes to /category/list/name?keywords=test.
When I open page with 2nd display (/search/results) and submit Search input, it goes to /taxonomy/term/%2A?keywords=test which is weird.
Ideally I would like the submit to end up in both cases at /search/results?keywords=test.

Is there any way of controlling the submit URL of the landing page for exposed filter? How?


texts: Multisites with shared files folder – good or bad idea?

texts:
I'm lacking experience on the following issue and unfortunately it isn't documented explicitly. I'ld like to have a shared files folder for a handful of multi-sites. As those sites all represent sub-organisations of one and the same parent organisation it should be possible that all of them have access to the same files in one certain files subdirectory using a shared file manager like IMCE.

The only concrete clue I found is on https://www.drupal.org/node/53705. But this is about Drupal 5.

  A /files directory could easily be shared across two domains without
  being shared across the remaining domains.

I wildly guess this didn't change much for following versions. But, have anybody ever tried it this way in production? Would you have any concerns doing it this way? What else could I consider to do instead?

As far as I've tested it right now this seems to work. Also images and files uploaded to image and file fields on site A stayed in the shared files folder even after multiple cron runs on site B and site C (as Clive noted to have a look at the file_usage logic).

I also then deleted the files and images from site A's nodes and run site A's cron multiple times. Still the files stayed there. But this simply might be a permission issue, maybe.


texts:
I've created a behaviours in JS but when I'm not connected as admin it show in the console this error:

  Can't find variable: Drupal

When I write console.log(Drupal) in the console explorer it show too the error.

How I can fix this error ?

Edit :

I've defined my library by this way :

myc_facebook:
  version: 1.x
  js:
    js/script.js: {}
    js/timeago.js: {}
  dependencies:
    - core/jquery
    - core/drupalSettings

I integrate my library in a block by this way :

public function build() {
        $config = $this->getConfiguration();

        // Check if the conf
        if (empty($config['token']) || empty($config['pagename']) || empty($config['pageurl']) || empty($config['limit']))
            return array('err' => array('#markup' => t('You might configure this block.')));

        $build = [];
        // Create the wrapper to include facebook posts
        $build['facebook']['timeline']['#markup'] = '

';
        // Push conf vars
        foreach ($config as $key => $value) {
            $build['#attached']['drupalSettings']['myc_fb'][$key] = $value;
        }
        // Includes libraries
        $build['#attached']['library'][] = 'myc_facebook/myc_facebook';

        return $build;
    }


texts: How to resave content so that teaser thumbnails are generated

texts: I imported a load of content from wordpress, and I am using the teaser thumbnail module. I need to effectively click 'edit' and 'save' on all my content so that any images create thumbnails on save automatically. Is there any way to do this.


texts: How to limit the list of nodes in a view based on a text field value?

texts:
Is it possible to show only Views content that passes a text in a given field?

For example, I have 3 content types and each content type has an identifier field (text field) which is hidden to the public.

So on my main content type, which is an information page, I list information about a football team. And then in the second content type I create results and a review of a match. And I display them as a view on the football team page (content type 1).

Content type 1 has a unique identifier, for example a text field saying "barcelona001". And this is the same on the "match results" content type field. How do I let views filter that, so that it only shows the right information?

If I can do this with a text field that would be great since I need to use a lot of taxonomy fields already to make it all work.

Any suggestions?


texts: Where can I find in database that page (panel) is disabled?

texts:
I am using Panels module. If I go to structure -> pages menu link, I will see my pages list.

I can disable/enable those pages. But how does this work under the hood? Where is it marked in the database that some specific page is disabled?


texts: How to restrict a field choice allowing only one to be populated?

texts:
On a basic page I have two similar fields. One for an image and the other for a video.

Either can be populated, but preferably not both, as I don't not want two fields to be displayed on the front end. I also want consistency across multiple view modes with only one being displayed in teasers etc

This trouble is, some editors do not appreciate the reasons and populate both fields, so I need to method for limiting this.

With D7 I found a good solution by using Conditional Fields module. By using a select list (for the file type). the corresponding field input would be exposed in the admin and the same field would be displayed on the frontend. Even if both fields were populated, only the current selection would display.

The D8 version of conditional_fields does not yet have this functionality, and may not get it. See my issue

I am therefore looking for an alternative method and hoped one of the experts here might some suggestions. I am looking for something simple and could not consider anything unsuitable for an untrained editor.


texts: I ran a Page Speed review of my website and got a suggestion that I should combine some images on my site into a single image using CSS sprites. I assume it is the mistake of the person who coded the theme, and I cannot recode it due to lack of knowledge. Is there any easier way of achieving this in Drupal? What I am looking for is solutions like this and this that would make the process easy for Drupal 7.


texts: How to add filter on node list in a custom module?

texts:
I am developing a module. In that module I have a page to list all the nodes of a specific type to user.

I need to:

1- show the nodes each on a row with ' Edit | Delete ' link in each row.

2- I also need to show a dropdown to give the user ability to filter the nodes by one of the node field.

I've created the first one but I don't know how to add a custom filter to the output.

Would you help me ?

I am working on Drupal 6.

Thank you.


texts: Why don't contributors get author attribution for Drupal core issues?

texts:
I'm looking now a commit in the Date range separator should be translatable issue and I don't see the commit message like:

alexpott committed a55967d on 8.3.x authored by mpdonadio

And mpdonadio has submitted a working patch but the message is:

alexpott committed a55967d on 8.3.x

So, I search in other issues to see what happens and I don't see any authored in message when the issue is related to Drupal core.

I remember that when I create a patch to Drupal Entity module the maintainer recognized my work:

clemens.tolboom committed f594060 on 8.x-6.x authored by adriancid

So, why don't contributors get author attribution for Drupal core issues?


texts: How to load some selected files in Media Browser

texts:
I have a run time list of image files with their fid's. I am using Media module to handle image files. I want to load only specific set of image files fid's in the media browser on node add/edit page.

Please help me to achieve this specific stuff.


texts:
Drupal just stores the day count and the total count. Is there a way to give a week count to the node?

ps: i want to show a node title list.the sort creteria is decending the most viewsd in a week. by defaule Drupal just stores the day count and the total count. there is no week count.

could i use this: i add a node created time in a sql query which where clause is less than  time()-24*7 like this where node time created < time()-24*7)then i use the total node count. then descending the result. the node title show will be the same as the week count. am i right? if right, how to put the sql query to views sort creteria .


texts: Setting value of form element from $form_state not working

texts:
I need to track previous values of a few form elements on a form to detect when they change to invalidate some other options on the page. Essentially, if the value of these fields change a field that controls pagination should reset.

I'm trying to accomplish this with this:

$values = $form_state->getValues();
$form['element1'] = [
      '#type' => 'radios',
      '#title' => $this->t('Element 1'),
      '#options' => [
        // Omitted for brevity
      ],
      '#weight' => '0',
      '#ajax' => [
        'callback' => [$this, 'my_callback'],
        'disable-refocus' => true
      ]
    ];

// dump($values['element1']);
$form['element1_previous'] = [
      '#type' => 'value',
      '#value' => (isset($values['element1'])) ? $values['element1'] : 'none',
    ];

No matter what I do the value of $values['element1_previous] is none. If I uncomment the dump() statement right before it I can see the value of $values['element1'] changing each time AJAX is submitted so the value is there.

If I do something like:

$form['element1_previous'] = [
          '#type' => 'value',
          '#value' => rand()
        ];

I can see $values['element1_previous'] being set to a different integer each AJAX submission. I just can't assign the value of $form['element1'] to that field.

What am I doing wrong? Is there a better way I could handle this?


texts:
I'm using Calendar module and I have trouble with calendars implemented by this module. I want to create a Drupal 7 Calendar View which uses two fields (date type) from the same Content Type.

The problem is the View displays duplicated values in Calendar when I use 2 different fields. When I use a single field the View is ok.

Had anybody the same issue?


texts:
I have a text field attached to my node.
The user can add an unlimited number of values.

I want to out put all the values as a HTML list in my node.tpl.php file.

Contemplate module suggests to use the following code to out put the field:

<?php print $node->field_body_list['und'][0]['safe_value'];?>

This, however, has two problems:
1) It only outputs the first value of the field.
2) It uses UND, which is apparently bad.

I have tried using theme developer, but it doesn't produce any code that I can use in my node.tpl.php file.

Any help would be greatly appreciated it.


texts: Commerce checkout form all pane errors to be displayed on top of form

texts:
I am using latest commerce module with D7 site. By default commerce displays form errors inside individual commerce checkout form panes. This is designed by default and every pane has it's own validation callback. So this is different from Drupal's form API error displaying.

Is it possible to display them at the top of the form, same as Drupal form API does it? Does form_set_error works well for all checkout form elements and they get error class? (it seems to not work for me).