texts: How to hide the comment form label (not title)?

texts:
I have tried a number of different modules that claim to do this but none have worked, I have also tried changing the comment.tpl file, and I even tried using CSS "Display:none"; however nothing has worked. So how can I hide the "Comment" label on a comment form box? I am not talking about the comment title here, as this can be easily disabled in the content type settings. This is what I am talking about:

I originally thought that this could be done in the manage display settings, by setting the comment label to hidden. So I did this but it didn't change the label of the comment box:

So how can this be done? I simply want to hide the word "Comment" and the "*" after it of course.


texts: get the value of a field of nodes inside an extra field

texts:
I have listed the node articles in the teaser mode. I have added an extra field, which is a select field (Using form API).

For more explanation, this is what I have done :

Define a form with form API

function article_flag_term_form($form, &$form_state) {
    $form['term_flag'] = array(
        '#type' => 'select',
        '#options' => custom_selectbox_contents(7), // function to get the items of the vocabulary having the id : 7
        '#ajax' => array(
            'callback' => '_term_flag_change'
        )
    );
    return $form;
}

I added this form as an extra field with hook_field_extra_fields, so I can see this simple form in each node listed in teaser mode :

function MY_MODULE_field_extra_fields() {

    $extra['node']['article']['display'] = array(
        'flag_form' => array(
           'label' => t('flag form'),
           'description' => t('Flag form addded to Node Content'),
           'weight' => 10,
        )
    );

    return $extra;
}

And the idea was to allow users to change the value of this vocabulary of each article.

The question is how can I put the default value of this select box with the correct value of the vocabulary item of each article.

Thanks in advance


texts: How to set which node a module loads on?

texts: I have a module that works on the hook_user (updates) it pushes details to another DB. I only want this module to load on the admin user edit screen where you can assign roles to a user. Currently I have a message that either says because you are role X you are allowed to send data, else sorry you do not have the rights to send data. However these messages display on every page in my drupal 6 website. I was wondering how I can limit this module to just the admin user edit screen, that would help a lot.


texts: Similar Module for Drupal: Easy Folder Listing?

texts:
Do you know of a Drupal module that does this: I have been searching for a solution to use in a Drupal site where the Folder Contents are Listed in a Table, exactly as described in the below description of this Joomla module.

http://extensions.joomla.org/extensions/directory-a-documentation/downloads/12249

Description:
This is a simple-to-use module that is used to list the contents of a folder in either a table or a list. The folder listing can display the filename, with or without the extension, with or without the date modified and file size, as well as a icon representing the file type. It has the feature of allowing the user to specify whether the filename listed should be linked or not.

Main features:

  List files in a specified sub-folder of the Joomla root
  Show icons for file types
  List files in either a table or a unordered list
  Option to link to the files or not


texts: How to use a div class to wrap some selected fields of a grid views view

texts:
I have came through this:

Views group different number of divs of a view by wrapping them
Views - Add a wrapper DIV around a Group

but can't understand how to use a div class to wrap some selected fields of a grid views view. In my case, i want to wrap three fields of a view into a div class as the image shows below:


texts:
The forum topics list has this in the table header: Topic, Replies, Created, Last Reply. I just want to remove the Created heading.

Template file forum-topic-list.tpl.php prints the table header with <?php print $header; ?>

The template file documentation explains that:

  $header is pre-generated with click-sorting information. If you need to change this, @see template_preprocess_forum_topic_list() @see theme_forum_topic_list().

So I dig around in forum.module and find template_preprocess_forum_topic_list(). This function appears to prepare the variables for the header, but doesn't create the HTML for the output.
I look up the other function that was referenced, theme_forum_topic_list().

The API documentation reports the following:

  This function is never used; see the corresponding template file instead."

What am I missing here?


texts:
I'd like to investigate if the following scenario is plausible somehow in Drupal 7:

The creation of a public form (node form/webform or whatever) with many instances so that each instance can be accessed only by a specific URL and can be filled by an anonymous user. The anonymous user should be able to fill in some of the fields, save his progress and come back later to fill some more using the same URL.

This scenario would allow the admin to create new instances, pre-fill some fields and send the form url by email to the final anonymous user.

The reason for all this is basically to avoid user registration and hold each user's submission to his unique URL form.


texts: Drupal-7 - Lists and Custom Content Types

texts:
I've just started with Drupal-7 coming from Drupal-5 that I last used a few years back and made a few customisations too. It seems to be Drupal-5 was much easier for modification, though Im starting to work out where all the data is saved processing through all the examples.

What isn't clear is when is a node not a node. For example, there are various support lists that I would like in my customisations, for example "salutation" (mr, mrs, miss, dr, revd etc) that should be user maintainable and stored in a database. It seems a bit overkill to create a separate content type and node just for this.

The current project Im working on is for Events, but I need to sub-categorise those Events twice by Event Type and Sub-Event-Type. Both of these should be user maintainable and therefore database driven. I can put them in a Content Type/Node but it does seem overkill.

I can't figure out if there's a programmatical way to insert, alter, delete (like the old days) into their own tables and then reference them in the Event node I will create generating a dynamic list.

There are lots of information out there about using Values, Taxonomy and Views etc. Seems everybody shys away from programming now and there's no examples anymore!

Any thoughts where to start? It seemed much easier finding the information before.


texts: Default to original language in nodes list

texts:
I set up a multilingual blog with Drupal 8 (in English and Chinese), I want to list articles according to current language in the front page.

However, if an article does not has an translation in the current language, I want it to default to the original untranslated version(whatever language), with a hint like "This content is not available in Chinese, we are showing the original article in English."

Assuming that I have 3 blog articles (nodes), with or without translation:

Article 1 (original language: English; translated to: Chinese)
Article 2 (original language: Chinese; translated to: English)
Article 3 (original language: English)

When a user visits the English front page at example.com/en, they will see:

Article 1 (in English, original)
Article 2 (in English, translated)
Article 3 (in English, original)

which is the default behaviour of Drupal 8.

Now, when a user visits the Chinese front page at example.com/zh-hans, I would like them to see:

Article 1 (in Chinese, translated)
Article 2 (in Chinese, original)
Article 3 (in English, with a hint)

However, Drupal 8 out of the box will display:

Article 1 (in Chinese, translated)
Article 2 (in Chinese, original)

I tried editing the front page as it is a view in Drupal 8, but with the filters in view I could not achieve this.

(Filters in view)

Do I need to implement a custom filter for the front page view? Please suggest where should I start, I have no idea how to do this.

Thanks!


texts:
I'm using Drupal 8 latest stable version: 8.5.x

I have 2 blocks (Upcoming events and Past events).

On Past events views infinite scroll is working with a button enabled providing the user ability to view more. It has many items and the module works as designed.

Same structure Upcoming events block returning only one upcoming event. When user clicks view more button the page is returning nothing and even the one item listed get disappeared.

Ajax is enabled on both views, the only difference is that upcoming events is returning only one result.

How can i solve this?


texts: Seeking a point/level module to encourage user activity

texts:
I have a very new site. Users have occassionaly popped in to say "hi" and that's about it.

I suspect a chicken and egg situation - I won't get content until there is content.

I seem to recall that Drupal Commons (sadly my server seems too  slow for it) has a system which is fairly standard in forums, where users get points and gainlevels for activity.

Is there something like that which is simple to add for a new admin on D7?

Thanks in advance

p.s. That's at its simplest, from an old school forumer; maybe I need +/-or "like/dislike" or new-fangled facebooky stuff?


texts: Disable quantity widget on cart page for certain products and not for product types

texts:
I am trying to disable quantity widget on edit cart page.

I can disable the quantity widget for a product type but i need to disable quantity on the basis of product ids in the cart.

Any suggestions?

Thanks


texts: Accessing data on Drupal with external application

texts:
I'm developing a native iOS application for a small company. The company has a career website on which they publish job offers. The contents such as job descriptions and contact person information are maintained with Drupal. Is there a way to get the plain data of the contents from an iOS application? I never used Drupal before, please help me.

Thanks a lot in advance!


texts: How to display default value of disabled form elements after failed validation?

texts:
I have a form with some disabled form elements. When the form fails validation and is sent back to the user, the disabled fields are empty. How can I make the disabled fields display the default values that were originally defined in the form?

function foo_form(&$form_state) {
  return array(
    'foo' => array(
      '#type' => 'textfield',
      '#default_value' => 'foo',
      '#disabled' => true,
    ),
    'submit' => array(
      '#type' => 'submit',
      '#value' => 'Submit',
    )
  );
}

function foo_form_validate($form, &$form_state) {
  form_set_error('submit', 'You cannot submit this form');
}

In this example, when the user presses the Submit button, the expected warning is displayed, but the text field is empty. This is most disturbing for the user, he does not know that all relevant information to process the form are still present.

$form_state['values']['foo'] is empty, but that's expected because disabled HTML elements are not included in the HTTP request that submits the form. Setting $form_state['values']['foo'] to the desired value in the validation function does not help.


texts:
I have a map where multiple nodes are shown as marker (filtered by terms). Now I would like to add a caption (block) which explains the (filtered) marker. The map may contain several results with the same marker.
So the map shows filtered by TERM 1 and TERM 2 shows following results:

NODE 1 (as it uses TERM 1)
NODE 2 (as it uses TERM 1)
NODE 3 (as it uses TERM 1)
NODE 4 (as it uses TERM 2)
NODE 5 (as it uses TERM 2)

In the caption (block) I would only like to show the distinct result:

TERM 1 (the marker image + name)
TERM 2 (the marker image + name)

FILTER > TERM 1 + TERM 2
But it does not matter what I tried (for 2 days), the result is always:

TERM 1 (of NODE 1)
TERM 1 (of NODE 2)
TERM 1 (of NODE 3)
TERM 2 (of NODE 4)
TERM 2 (of NODE 5)

Please give me a hint to understand why I cannot manage it.
Kind regards,
Benjamin
EDIT:
I found following interesting article, nevertheless it does not work 100%: when a node has multiple terms -although filtering one- all terms are listed (not only the filtered one):
View List with distinct term listing of multiple nodes


texts: Why would taxonomy_term_save be slow when called from hook_install_tasks?

texts:
As part of making a site more easily deployable from scratch, I have generated two PHP scripts to pre-populate taxonomy vocabularies with a list of terms.  The scripts are straightforward, creating stdClass objects with the appropriate fields and callingtaxonomy_term_save on each one.  Example:

$term = (object) array (
  'name' => 'Art & Architecture',
  'description' => '',
  'format' => 'plain_text',
  'weight' => '0',
  'vocabulary_machine_name' => 'categories',
  'field_cc_numeric_code' =>
  array (
    'und' =>
    array (
      0 =>
      array (
        'value' => '102',
      ),
    ),
  ),
);
$term->vid = $vocabulary->vid;
taxonomy_term_save($term);

The variable $vocabulary already contains the appropriate taxonomy vocabulary structure at the time this is called.  One vocabulary has about 150 terms to create, the other about 2,000.

On a fresh installation of the site made using drush site-install, these scripts run almost instantly when called via drush php-script.  However, if they are incorporated into the installation profile and called by a task in the implementation of hook_install_tasks, they are much slower.  In the latter case, saving each term takes about a second, which is unacceptably slow.

There is discussion of a similar issue at https://www.drupal.org/node/1887924, but no solution offered either there or in the linked bug report.

Why would taxonomy_term_save be so much slower when performed from an installation task?  Is there anything that can be done about it?


texts: Getting the display value for a form option with webform 3.x while processing submissions

texts:
I want to create an associative array of submitted form data and do some additional processing on the submitted data (namely send the data over http POST). I have the following code:

function webformssalesforce_form_alter(&$form, &$form_state, $form_id) {
    if (substr($form_id, 0, 20) == 'webform_client_form_') {
        // Add the submit handler after the existing Webform submit handler,
        // but before the second Webform handler. Pop off the first one and add
        // ours second.
        $first = array_shift($form['#submit']);
        array_unshift($form['#submit'], $first, 'webformssalesforce_client_submit');
      }

}

function webformssalesforce_client_submit($form, &$form_state) {
    $node = node_load($form_state['values']['details']['nid']);

    $fields =  Array();
    foreach($form_state["values"]["submitted_tree"] as $key=>$value) {
        if(! is_array ( $value)){
            $fields[$key] = $value;
        }
    }

    //do stuff with $fields

}

This works fine for text and email fields, however for select elements I get the option's safe_value instead of the display value for the select. So for example if an element has the folowing options:

1|Display value 1
2|Display value 2
3|Display value 3

How can I get the display value instead of the safe_value (Display value 2 instead of 2) for an element?

I'm pretty sure this code worked fine for me with a previous version of webform.


texts: Get the name of file from file field before node is saved

texts: There is a file upload field(which uploads zip files) . I want to get the name of file in node_presave , How do I do it?


texts: Drush cr is responding with Bootstrap Failed

texts:
I have a Drupal 8.9 site I built on my development server. I've now copied it over to my production server (Ubuntu 16) and set up the database. I need to run drush cr to finish the process but when I do I get Bootstrap failed.
I've been all over the web trying different things to get it to work. I've changed 'localhost' to '127.0.0.1' in settings.php. I've removed drush and reinstalled. I've double checked that the database is accessible with the credentials in settings.php. I've run out of ideas.
Here's the verbose output:
administrator@ubuntu:/var/www/html/ycfld$ drush cr -vvv
 [preflight] Config paths: /home/administrator/.composer/vendor/drush/drush/drush.yml
 [preflight] Alias paths: /var/www/html/ycfld/drush/sites,/var/www/html/drush/sites
 [preflight] Commandfile search paths: /home/administrator/.composer/vendor/drush/drush/src
 [debug] Starting bootstrap to site [0.05 sec, 7.81 MB]

In BootstrapHook.php line 32:

  [Exception]
  Bootstrap failed. Run your command with -vvv for more information.

Exception trace:
  at /home/administrator/.composer/vendor/drush/drush/src/Boot/BootstrapHook.php:32
 Drush\Boot\BootstrapHook->initialize() at /home/administrator/.composer/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:34
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook() at /home/administrator/.composer/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:27
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize() at /home/administrator/.composer/vendor/consolidation/annotated-command/src/CommandProcessor.php:145
 Consolidation\AnnotatedCommand\CommandProcessor->initializeHook() at /home/administrator/.composer/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:289
 Consolidation\AnnotatedCommand\AnnotatedCommand->initialize() at /home/administrator/.composer/vendor/symfony/console/Command/Command.php:221
 Symfony\Component\Console\Command\Command->run() at /home/administrator/.composer/vendor/symfony/console/Application.php:1018
 Symfony\Component\Console\Application->doRunCommand() at /home/administrator/.composer/vendor/symfony/console/Application.php:271
 Symfony\Component\Console\Application->doRun() at /home/administrator/.composer/vendor/symfony/console/Application.php:147
 Symfony\Component\Console\Application->run() at /home/administrator/.composer/vendor/drush/drush/src/Runtime/Runtime.php:118
 Drush\Runtime\Runtime->doRun() at /home/administrator/.composer/vendor/drush/drush/src/Runtime/Runtime.php:49
 Drush\Runtime\Runtime->run() at /home/administrator/.composer/vendor/drush/drush/drush.php:72

And here's the status:
administrator@ubuntu:/var/www/html/ycfld$ drush status
 PHP binary    : /usr/bin/php7.4
 PHP config    : /etc/php/7.4/cli/php.ini
 PHP OS        : Linux
 Drush script  : /home/administrator/.composer/vendor/drush/drush/drush.p
                 hp
 Drush version : 10.3.1
 Drush temp    : /tmp
 Drush configs : /home/administrator/.composer/vendor/drush/drush/drush.y
                 ml
 Drupal root   : /var/www/html/ycfld

I'd appreciate any insights. This one thing is all that stands in my way of the site going live (I think).


texts: Drupal 7 Comments Alternating Row Colors

texts:
I'm interested in making the comments that appear on my resource content type nodes show with alternating background colors. Anyone know how to make this happen?

I tried something like this with CSS but I'm not seeing how I can make this work as the comments don't seem to have anything regular I can target (as the class is quite a bit different if the comment is made by a logged in user vs. an anonymous user for instance):

.comments-by-anonymous .field-item:nth-child(even) {
    background: #fcfc33;
}

Then I thought, well I could try and do some PHP if/then hackery to my comment.tpl.php template but I'm unfamiliar enough with that template to know if its a) even the correct one to edit, and b) if perhaps there might just be a better way to do it.

Anyone have any good ideas?


texts: How to check for drupal page routine, no form submit working

texts:
On my drupal website, I suddenly can't submit any form successfully. The page appears to reload but does not go anywhere, stays exactly where any form is.

Using drush uli, I can get in as admin but can't make any changes. The website is here: http://162.243.88.90

I hope someone knows a fix to this one or any tests I can run to track what could be causing this.

Thanks.


texts: I am working on a site that is a directory of all track and field clubs (trackandfieldclubs.com). A user can create an account and add their club if it is not listed. However, nearly all the clubs have been listed by me to give the site some value. After all, what good would the site be if no track and field club were listed? The problem is that I want a user who's club is already listed to become the author of their club's node. Right now I have implemented a rather archaic system to do this where a user first creates an account, then fills out a web form (http://trackandfieldclubs.com/form/request-edit-existing-club) telling me their club name and username. I then login as an admin and change the node's author. Is there a better way to do this? Can this process be automated? Thanks in advanced!


texts: Add a custom carousel block with HTML, CSS, and JavaScript

texts:
I'm new to drupal and not a coder but trying to add owl-carousel in the custom block following some online guides.

I found 2 links which had good owl carousel demos and both of them had 3 sections (HTML,CSS,JS) that need to integrate to make it work.

Links:

owl carousel

Flickity carousel

I was trying the owl carousel and the method I tried was to create a custom block with Full HTML support and used the following HTML code.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<link href="/en/libraries/OwlCarousel2-2.2.0/dist/assets/owl.carousel.min.css" rel="stylesheet" />
<link href="/en/libraries/OwlCarousel2-2.2.0/dist/assets/owl.theme.default.min.css" rel="stylesheet" />

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ultrices, elit sed faucibus pharetra, diam mauris bibendum orci, sit amet ullamcorper purus dui sit amet augue. Donec aliquet diam ut neque mattis, eu tristique sem rutrum.

&nbsp;

Don Know

Important person, some Company

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ultrices, elit sed faucibus pharetra, diam mauris bibendum orci, sit amet ullamcorper purus dui sit amet augue. Donec aliquet diam ut neque mattis, eu tristique sem rutrum.

&nbsp;

Pablo Napp

Important person, some Company

Sorry, the code was taken from some other sources and I've only limited knowledge on it.

Could anyone please guide me how to implement such carousel.

Thanks


texts: how to add an event subscriber when the user reaches the login form

texts:
I am new on Drupal 8 , I have implemented a hook 'hook_form_alter' in my module to add a new field to the login form , but now I want to handle it with the event , I want to trigger an event when the user reaches the login form and then add this field using event not a hook.
Can anyone please suggest me how to do it ?
This is the hook
function my_module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id == 'user_login_form' ) {
    // Add placeholders.
    $form['condition'] = array(
      '#type' => 'checkbox',
      '#options' => t('Enable'),
      '#title' => t('J’accepte les conditions'),
      '#required' => true,
    );
  }
}


texts: Update views result after unset() in views_pre_render

texts:
In hook_views_pre_render(&$view) I have a simple code:

foreach ($view -> result as $key => &$result) {
    if('some condition') {
        unset($view -> result[$key]);
    }
    if('some condition') {
        unset($view -> result[$key]);
    }
}

Above works OK. it unsets result row of the view. Now, in my view I am displaying 2 results per page. Currently have it outputs 10 node which means there are 5 pages.

The problem is, as you might suspect that if, for example, 2 unset results happened to be on page number, say 2, of the view, this page is still displayed in the pager. So what I have now is 2 results on page number 1, no results on page number 2 and 2 results on page number 3.

Similarly, if only 1 result is unset, I have 2 results on page number 1, 1 result on page number 2 and 2 results on page number 3.

is there a way of letting the view know that it needs to update it's structure? There is a query_alter possible solution but I would like to avoid it if possible.

I do realise that this might not be the best way to unset results and I am open to suggestions, however i would like to keep the code in my custom module (not being fore to alter template.php).


texts: hook_preprocess_field() $variables crashing while printing

texts:
I am trying to modify a file field value and add a download svg icon and then add it to a twig file by using a preprocess field.

function myfi_preprocess_field(&$variables) {
  if ($variables['element']['#field_name'] == 'field_download') {
    print_r($variables);
  }
}

I am not sure what I am doing wrong here but the variable is not loading and it is timing out (memory exhaustion)


texts: Best practice to alter the attributes variable in a Drupal 8 Twig template

texts:
I'm creating a custom Drupal 8 theme based on Bootstrap. (NOTE. I'm aware of https://www.drupal.org/project/bootstrap, I just want some practice.)

More often than not, I find myself adding Bootstrap classes to the existing Drupal classes via the Attribute object already available in the template.

For instance, in Bootstrap, the main navigation menu looks like this:

...

What is the best practice is to add the nav navbar-nav classes to Drupal's menu.html.twig template? This template already contains the following line:

1) Add the classes with a preprocess function?

I could add the following function to my MYTHEME.theme file to alter the attributes variable before it's passed to the template:

function MYTHEME_preprocess_menu(&$variables) {
  if ($variables['menu_name'] == 'main') {
    $variables['attributes']['class'][] = 'nav';
    $variables['attributes']['class'][] = 'navbar-nav';
  }
}

2) Add the classes directly inside the Twig template?

First, I'd create a template named menu--main.html.twig to override only Drupal's main menu.

Then, I'd alter the line with the
 to:

I find #2 a little less clean but it keeps all the markup in the same place.

What do you think?


texts: Views show table of titles of last nodes for each content type

texts:
I want to show a table (using views) displaying a list of the last node (latest pub date) for each content type.

Any ideas?


texts: Programmatically add multiple values to an entity reference field

texts:
I use the following code to load entities by their IDs.
$themes = entity_load('theme',array(7,8,9));
$thid = array();
foreach ($themes as $theme) {
  $thid[] = $theme->id;
}

Next, I should add those IDs to an entity reference field ($tests->field_theme).
How can I achieve this?


texts:
I'm using CIVCRM module in Drupal, and I have created multiple custom data sets for Drupal registration form.

Now problem is that I have 4 membership levels and each level have custom data set so I need to hide other data set and show only those related to selected member level.

Is there a way to do that through administration.

Thanks in advance.


texts:
I would like to all the href of the edit tab link on several nodes.

IOW: instead of

example.com/node/%/edit

I would like to substitute my dynamically created link

example.com/products/$myproductid/edit

My first stab at this (just to see if I understood the wild cards):

function jch_utilities_menu_alter(&$items) {
  $items['node/%node/edit']['title'] = '1234';
}

...and this fires, BUT I don't understand how to pass the URL I want dynamically to it.

What I want to do is pass a variable from the node (a field variable) to that link.

I see that there is a page callback member of the array but that seems to call the node_edit page... which is over my head. I can't find a simple clear example of how to do this without a -lot- of study.

Is there no way to simply -force- a link href as one could do with jQuery?

TIA.


texts: Rendering arbitrary field values without a parent entity in Drupal 8

texts:
I would like to expose to the user their choice of field formatters and the respective field formatter options. The selected formatter would then render an arbitrary array of items in the same format as a value for that field type, without any kind of parent entity.

Again, I want to render what looks to be an array of field values, without having an actual field or entity with a field value.

In Drupal 7 I could accomplish this using the following code (Gist formatted version):

// Render a file using the 'Generic file' formatter (a nice link with an icon):
$file = file_load(1);
$field = array('type' => 'file');
// File fields are stupid with their field values.
$items = array(0 => array('fid' => $file->fid) + (array) $file);
$display = array('type' => 'file_default');
$output = field_items_render($field, array(), $items, $display);
return drupal_render($output);

// Render node 1 with an entityreference formatter
$field = array('type' => 'entityreference');
$items = array(0 => array('target_id' => 1));
$display = array('type' => 'entityreference_label', 'settings' => array('link' => TRUE));
$output = field_items_render($field, array(), $items, $display);
return drupal_render($output);
// Outputs Title of node 1

function field_items_render(array $field, array $instance, array $items, array $display, $langcode = LANGUAGE_NONE) {
  $field += field_info_field_types($field['type']);

  $display += field_info_formatter_types($display['type']);

  $instance += array(
    'entity_type' => 'node',
    'bundle' => '_fake',
    'settings' => array(),
  );
  $instance['settings'] += $field['instance_settings'];

  $entity_type = 'node';
  $entity = NULL;
  $entities = array(0 => $entity);
  $entity_items = array(0 => &$items);

  // Run hook_field_prepare_view() on the field module.
  $function = $field['module'] . '_field_prepare_view';
  if (function_exists($function)) {
    $function($entity_type, $entities, $field, $instances, $langcode, $entity_items);
  }

  // Run hook_field_formatter_prepare_view() on the formatter module.
  $function = $display['module'] . '_field_formatter_prepare_view';
  if (function_exists($function)) {
    $function($entity_type, $entities, $field, array(0 => $instance), $langcode, $entity_items, array(0 => $display));
  }

  // Run hook_field_formatter_View() on the formatter module.
  $function = $display['module'] . '_field_formatter_view';
  $result = $function($entity_type, NULL, $field, $instance, $langcode, $items, $display);

  return $result;
}

While I can do this in Drupal 7 very relatively easily, how can I accomplish the same in Drupal 8 (or at least help lead me down the right path through all the major parts of this)?


texts: Create config object with array containing key-value pairs

texts:
We have a custom module, mymodule, that we want to use to create a config object for so that it can contain an array of key-value pairs. We need to be able to click button Add More on the form that will add more key and value fields that will be mapped together.

How can we create a form that would not only display existing key-value pairs, but also provide option to add more?

Goals:

On the admin Form, MyModuleForm be able to see existing key-value pairs.
Add more key-value pairs.
Key and value are text fields.
Use the config_object within the mymodule.module file and fetch all the key-value pairs.

Below is what we tried, but got stuck on how to add the Add more functionality and how to properly store customKey and customValue into an array.

MyModuleForm.php

class MyModuleForm extends ConfigFormbase {
  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'mymodule.settings'
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'mymodule_settings';
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    $config = $this->config('mymodule.settings');
    $form['customKey'] = [
      '#title' => $this->t('Key value for array.'),
      '#type' => 'textfield',
      '#default_value' => $config->get('customKey'),
      '#maxlength' => 255,
      '#required' => TRUE,
    ];
    $form['customValue'] = [
      '#title' => $this->t('value for array.'),
      '#type' => 'textfield',
      '#default_value' => $config->get('customValue'),
      '#maxlength' => 255,
      '#required' => TRUE,
    ];

    return parent::buildForm($form, $form_state);
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Retrieve the configuration
    $this->configFactory->getEditable('mymodule.settings')
      ->set('customKey', $form_state->getValue('customKey'))
      ->set('customValue', $form_state->getValue('customValue'))
      ->save();

    parent::submitForm($form, $form_state);
  }
}


texts: taxonomy name filter to get terms with special characters

texts:
I am getting my term description using taxonomy_get_term_by_name().

I'm having problems with term names like "barnes & noble" and "Café"; I guess it must have something to do with the special characters. How can I filter my taxonomy name input the best way to get back term results?

I'm using the function in a views-view-list.tpl.php template, where $title is outputting the taxonomy; then I use $title with the following code.

$terms = taxonomy_get_term_by_name($title, 'places');

$title seems to be stripped from all kind of htmltags - its plain text.


texts: Remove module dependency in multi-site D7 setup?

texts: In sites/all/modules, I have video module 7.x-2.2 installed. Within my sub-site in a single-core, multi-site setup, I have video module 7.x-2.7 installed. When I try to disable and remove the local video module (7.x-2.7) - for a lack of words, it wont' let me, nor default back to the sites/all/modules/video module. I get wsod, database errors, and funky behavior. How would I remove my subsites manual dependency on its local module? Is my last resort to go into the database? Thanks,


texts:
Ive migrated my site and now my View UI is broken. My relationship 'Relationship: Entity Reference: Referencing entity' works the opposite way round to the way it should. This has been confirmed by a colleague who uses Drupal.

Also fields that ive added to my content type are not available as fields in views, and sometimes the body field is missing too.

Does anyone have any ideas as to how I would start to go about fixing this? My Drupal status report doesn't return any errors.


texts:
It's not a "new" issue, but I'd like to implement a year + month dropdown selector to navigate a standard calendar view's display, as this particular calendar shows historical entries spanning many years, all of which need to be directly accessible.

I understand it's possible to specify an argument via URL to control the calendar view's current display through its contextual filter. However, I don't know how to supply this argument via a dropdown, either in the block itself or another (similar to an exposed filter), in a way that would function properly in all cases.

Working without a solution, I created my own views style plugin, added an exposed filter, and am now going to look for a way to display the easily filtered-by-month results in a custom calendar implementation through my code.

Hopefully there's a way to make use of the existing calendar module via "inspired" filtering, instead of my custom plugin route?

Any guidance would be appreciated.


texts: Migrating body text from 7 to 8, markup displays until edited and saved

texts:
I'm migrating nodes and have run into a problem with the text formats when mapping our old site's input formats to the new site's input formats. (We're simplifying!)

Relevant yaml:

  body:
    plugin: sub_process
    source: body
    process:
      value: value
      format:
        plugin: static_map
        bypass: true
        source: body_format
        map:
          'plain_text': basic_html
          'basic_tags': basic_html
          'minimal_formatting': basic_html
          'filtered_html': basic_html
          'extended_tags': full_html
          'full_html': full_html

When I run this, all the content and formats are imported correctly, but the nodes all display the markup on the page until each node is edited and saved.

What could be causing this and how might I go about fixing it?


texts: Set multiple items for an argument in embeded view

texts:
I'm using this code to display a view inside a node:

$view_args = array($node->field_page_cck[0]['value']);
$view = views_get_view('my_view');
$view->is_cacheable = FALSE;
$view->set_display('default');
if (!empty($view)) {
    print $view->execute_display($display_id , $view_args);
}

The argument is set with the option Allow multiple arguments to work together.

I tried with:

$view_args = array($node->field_page_cck[0]['value'], $node->field_page_cck[1]['value']);

but no luck.

I also tried to convert to a string like this: argument1+argument2+.... or argument1,argument2,.... still no luck.

Any help, please?


texts: How to display the user name that created the profile (the owner or author of the profile)?

texts:
I have a site with Drupal 8 and I want to customize the templates of my pages.

I use the module:

"Profile" https://www.drupal.org/project/issues/profile

Here is my template to customize the profile page:

{#
/**
 * @file
 *
 * Default theme implementation for profiles.
 *
 * Available variables:
 * - content: Items for the content of the profile.
 *   Use 'content' to print them all, or print a subset such as
 *   'content.title'. Use the following code to exclude the
 *   printing of a given child element:
 *   @code
 *   {{ content|without('title') }}
 *   @endcode
 * - attributes: HTML attributes for the wrapper.
 * - profile: The profile object.
 * - url: The profile URL, if available.
 *
 * @ingroup themeable
 */
#}

      {{ ??? USERNAME ??? }}

How to display the user name that created the profile (the owner of the profile) ?


texts:
I am calling node_delete($nid) from inside a function callback that is called when the DELETE button is pressed, but the node is not deleted.  There is no error - it just doesn't work!  What can be going wrong?

In bhl_form_alter() I put:

$form['actions']['delete']['#submit']['0'] = 'delete_mem';

Then delete_mem($node) calls node_delete($node->nid).

I have also tried to figure out a way to use the default callback hook_node_delete(), but if I put a redirect there with drupal_goto(), the redirect happens, but the node again does not get deleted. drupal_form_redirect() doesn't work in this function because $form_state is not passed.


texts: It is safe to store custom information in the data field of a commerce_order or commerce_line_item entity?

texts:
I have this

 line_item = commerce_line_item_load($form_state['line_item']->line_item_id);
            dpm($line_item);
            $line_item->data['data_custom']['name'] = $form_state['values']['name'];
            $line_item->data['data_custom']['phone'] = $form_state['values']['phone'];
entity_save('commerce_line_item', $line_item);

It is save? In theory I'm only the only one to work with this data, other modules should not even care about that being there, right?


texts: How do I add an ajax item on the submit button?

texts:
I created a form using the module "Webform". Now I want to add an #ajax item to the submit button.

Here's what I already did:

use \Drupal\Core\Form\FormStateInterface;

function mytheme_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
  $form['#submit']['#ajax'] = array(
    'callback' => '\Drupal\mymodule\Controller\DefaultController::process_form_submission'
  );
}

The '#submit' field of the form now looks like this:

'#submit' => array(2)
    '0' => string(12) "::submitForm"
    '#ajax' => array(1)
        'callback' => string(72) "\Drupal\mymodule\Controller\DefaultController::process_form_submission"

But the process_form_submission function is not called. Instead the page reloads on submit as before.


texts: I have created a custom content type called building which I have added a entity reference field called category which is the vocabulary and added building type terms. I created a view called buildings and added an exposed filter that is listing the building types. I get the listing of the categories by exposing the filter Has Taxonomy Term and then using BEF to list the categories as links rather than a dropdown or autocomplete. Whenever I click each category link for the exposed filter I get the url www.example.com/building?category=1 is there a way to make it use the term name rather than the term id. Also further, is there a way to have it make the url a little cleaner like www.example.com/building/category/buldingtype


texts: Why do I get an error after adding a .theme file?

texts:
After creating (e.g empty) .theme file in my template folder, I get the following error message:

  The website encountered an unexpected error. Please try again later.RuntimeException: Failed to start the session because headers have already been sent by "/homepages/d825952918/htdocs/themes/universaldenker/universaldenker.theme" at line 1. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 145 of vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php).

If I delete the .theme file, everything works again. I think it has something to do with opcache, because the path "/homepages/d825952918/htdocs/themes/universaldenker/universaldenker.theme" comes from the .opcache folder.

How can I tell Drupal not to use it and clear all the cached files?


texts: How to acess API rest/views using token or login?

texts:
I have a Drupal 8 website. I need to access the list of articles using www.myexample.com/rest/views/articles.

I could get the token using curl --header "Content-type: application/json" -b cookies.tt --request POST "https://www.myexample.com/user/login?_format=json" --data '{"name":"myname", "pass":"mypassword"}'.

How do I use cUrl to pass the token or user/pass and get 'rest/views/articles' in JSON format?

I tried curl --header 'authorization: Bearer {D12G7AajU9NdUAb260zqwCimfdddR1Krg5}' --url https://www.myexample/rest/views/artigos/format?_format=json,
but it returns an error.

UPDATE

I follow the @Ismail Cherri suggestion, seems a progress in the question but give me back :

"message":"The used authentication method is not allowed on this route."

In drupal website the config :

/entity/view/{view}
is set to :

GET
formats: hal_json, json
authentication: basic_auth

and
/entity/entity_view_mode/{entity_view_mode}
is set to :

GET
formats: hal_json, json
authentication: basic_auth

anyone could help?


texts: How to make sure no emails go out after importing users?

texts:
I'm creating a new Drupal site and importing users from our existing website. I want to make sure users don't receive any email notifications of any kind from our new website during this process. What things should I check to ensure this?

I am using Drupal 7.54.


texts: Full HTML Formatter / WYSIWYG Not Working In Views 3?

texts:
I have a Drupal 7 site that I've been plugging away at for the last few weeks, and I noticed that when I'm in Views and am trying to add a Global Text Area to the footer of my view (for a "Read More" link that goes to a custom page), the WYSIWYG formatter does not show up at all. The dropdown to pick formats appears, but none of them initiate TinyMCE.

The strange thing is that the Input Formats are configured just fine for the rest of the site and proper user roles. It works across all of the content types I have set up. So, my question is, how can I get this working so that I can put a link in the footer?

For sake of explaining things better, here's a screenshot. Note that this problem is only happening in Views.


texts:
I'm using the following modules

Meta Tags
Page Title

I need to be able to make the sites title work like this:

Use the title set in Meta Tags for each Node first of all, if this isn't set then default to the Page Title module.

If this isn't set, just use the pages title.

How do I set a precedence for the titles?  Do I have to hook into html_head_alter?

Any help is greatly appreciated,

Cheers


texts: Views with node references result redundant records

texts:
I have three content types - Leg, Transport and Ticket. Transport has a node reference to Leg. Ticket has a node reference to Transport.
Thus, Leg and Ticket have an indirect way of relationship. But,Transport and Ticket have optional relationship.

I'm creating a view which lists transports of the given leg ( contextual filter ).
In the list, ticket is needed to join to show ticket price. Here is my views settings :

The view result is not what I expected. It lists unnecessary and duplicate records as shown in the screen shot.
The first two records ( in the red box ) should not be listed here. They are redundant of the last two records ( in the red circle ). You can see prices are not showing for the first two.

Aggregation did not help me in this case.


texts: Content not showing up by default with exposed filters

texts:
I have a view with 2 taxonomy term fields. I have these fields presented as expose filters for site users to select from dropdown, which works fine. However, when I first land onto the view page, none of my content is showing up. All I see is a blank view.
However, if I click apply, with all the fields unselected (e.g. - Any -), then all my content shows up. How do I make the content show up by default without having to click on Apply?

Upon landing on the page for the first time:

After clicking Search:


texts: How to add entity reference to custom entity

texts:
I've created two custom entities and need to create a one to many reference between them. What I would like to achieve is to have the Child entity with field Parent that would reference the Parent entity. On the other hand, the Parent entity should have field with collection of Children entities.

The Entity reference module seems like the obvious choice, but how do I use it strictly from code to reference my custom entities in the way I described?

I also thought of just using Entity's API Entity::setUp() to load the references. This solutions seems simpler but what is the best Drupalish approach?

Both entities are fieldable.


texts:
I want to load the node details for a specific revision. I tried using the following code.

use Drupal\node\Entity\Node;
$nid = 1171;
$vid = 9423;
$rev_node = Node::load($nid, $vid, TRUE);

I also tried the following code.

$rev_node = node_load($nid, $vid);

It always loads the latest version, irrespective of the revision ID passed to the method/function call.

Is there a way to load the data for a specific revision?


texts: How to get images into a slideshow via json javascript with new itok

texts:
I have just updated to drupal 7.21, and I have massive errors with the new itok suff: Right now I use json_encode(views_get_view_result('viewsitem')), and decode the result with JSON and JavaScript. My slideshow wants to have the normal path but returns things similar to "...sites/default/files/styles/large/public/field/image?itok=M-zTIVI1/mypic.JPG."

Normally, I get the images using the following code.

if (value.field_field_image) {
  var images = value.field_field_image
  // iterating over the images per nid
  for (var i = 0; i < images.length; i++) {
    slideshow_settings.this_slides += '';
  }

  pics = slideshow_settings.this_slides;
}

How can I fix this?


texts: Icons are broken after a clean installation of panopoly profile

texts:
I have made a clean installation of Panopoly.However icons are broken.I attach an image.
Seems images are not on the correct folder.
How can i fix that?
thanks


texts: Write drupal config in a profile installation

texts:
Here's my problem: I use profiler builder to generate a profile from an installation. But the fact is : the profile only list my modules.

What I want my profile to do is also to keep my Drupal configuration. For exemple, if I generate the profile of a drupal installation with a WYSIWYG installed and configured, I want the profile to keep this configuration and reload it to new instance (created with the profile).

Is it possible ? Thanks.


texts:
I purchased a theme called "Porto" which is quite good.  With that said, for troubleshooting purposes, I need to turn that theme off.

I can uninstall every theme on the site except "seven" and this purchased theme.

When we installed the theme, we had to do a whole install using SQL rather than just dragging over the theme file.  I BELIEVE that there is something in these files that is preventing them from being uninstalled but I'm not sure where to look.

Can someone tell me where I might look to find this setting and override it? In the theme file? Setting file?


texts:
This morning suddenly after hours of work I found my self unable to access admin account, just a blank page without any info.
The anonymous and authenticated users  are logged in normally without any problem , like usual..

The first reflex was to clear all the cache manually from the database,but this drove me to this issue:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away' in /home/www/includes/database/database.inc:2171 Stack trace:
#0 /home/www/includes/database/database.inc(2171): PDOStatement->execute(Array)
#1 /home/www/includes/database/database.inc(683): DatabaseStatementBase->execute(Array, Array)
#2 /home/www/includes/database/database.inc(2350): DatabaseConnection->query('SELECT expire, ...', Array, Array)
#3 /home/www/includes/lock.inc(167): db_query('SELECT expire, ...', Array)
#4 /home/www/includes/lock.inc(146): lock_may_be_available('schema:runtime:...')
#5 /home/www/includes/bootstrap.inc(433): lock_acquire('schema:runtime:...')
#6 /home/www/includes/bootstrap.inc(455): DrupalCacheArray->set(Array)
#7 [internal function]: DrupalCacheArray->__destruct()
#8 {main} thrown in /home/www/includes/database/database.inc on line 2171

I tried to change the theme by removing it from the themes folder but nothing worked.
Any Help please..


texts: How to replace a taxonomy term by its description?

texts:
In drupal 7.39, I have created a taxonomy vocabulary called TYPE. Inside this vocabulary I have added list of terms called CLOSE, END and INITIAL.

By default, when I view the node page it will show the Taxonomy term as CLOSE, END. But I don't want this, instead of the CLOSE term it should be replaced with the description specified in the CLOSE term.

Any suggestions about how to do this?


texts:
I am new to Drupal and having an issue relating to SSL. The view I'm working with is using the jcarousel module to display images with links.

The data contains a link and image source. All of the links are entered using relative paths to the root of the site.

The home page has 5 links on it. When the you look at the source from the generated page, 2 of the links are https and the other 3 http even though none have the base URL in the link data.

I have added $_SERVER['HTTPS'] = 'on'; to settings.php but that hasn't corrected the issue.

What is the proper way to force both tags to be generated with https: links?


texts:
I'm trying to decrease the number of my queries with the devel module but I have two questions.

1) Why do I have 281 dblog_watchdog queries? How can I get rid of them?
Why should I keep them, I already have the apache logs?

INSERT INTO watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9)

2) How to show the number of queries for anonymous users?
Right know it doesn't show anything.


texts: How do I fetch the product display nodes referencing the given product using "Fetch entity by property"?

texts:
Let me start off by saying that I am ultimately trying to get the product display from a line item. I would use commerce_rules_extra, which has a feature that is supposed to do this, but I could not get it to work. So I am trying to get the product display node for the product.

My strategy is to create a simple Rules Component that returns all product display nodes that reference a given product.

My component accepts a parameter of type: Commerce Product

My component has a Condition: Data comparison: Product:type - equals - "Product"

My component has an Action:

Fetch entity by property, Entity type: Node, Property: Product (I believe this is the product reference field)

When I attempt to set the Value as the component's Parameter "Product", the action will not accept this—instead it gives this error:

  The data type of the configured argument does not match the parameter's value requirement.

This would be the typical method for fetching nodes by property on an entityreference field but I can't do the same with this productreference field. Any hints would be greatly appreciated.


texts: How to query the database to create a report based on user input variables in a form?

texts:
I am creating an example report of user data based on selection criteria selected in a form. I can create the form variables, and I can redirect the user to the report output page, but how do I include the selection criteria variables in the redirect? Here is my module code:

<?php
/**
 * @file
 * Example form module that creates a users report.
 */

/**
 * Implements hook_menu().
 */
function example_form_menu() {
  $items = array();
  $items['example-form'] = array(
    'title' => 'Example Form',
    'description' => 'Provides search criteria for the Users report',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('example_form_create_form'),
    'access arguments' => array('access content'),
    'type' => MENU_NORMAL_ITEM,
  );

  $items['example-form-output'] = array(
    'title' => 'Report output',
    'description' => 'Output page for Users report',
    'page callback' => 'example_form_output_page',
    'access arguments' => array('access content'),
  );
  return $items;
}

/**
 * Creates a form.
 */
function example_form_create_form($form, &$form_submit) {
  $form['title'] = array(
    '#title' => t('User'),
    '#type' => 'textfield',
    '#description' => 'Search for a User.',
  );

  $form['user-date-created-comparison'] = array(
    '#title' => t('Creation Date'),
    '#type' => 'select',
    '#options' => drupal_map_assoc(
      array(
        t('is greater than:'),
        t('is less than:'),
        t('is equal to:'),
      )
    ),
    '#empty_option' => '',
  );

  $form['user-created-date'] = array(
    '#type' => 'date_popup',
    '#date_format' => 'm/d/Y',
    '#date_label_position' => 'within',
  );

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

  return $form;
}

/**
 * Implements hook_form_alter().
 */
function example_form_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == "example_form_create_form") {
    $form['submit']['#submit'][] = 'example_form_redirect_handler';
  }
}

/**
 * Attaches the redirect to the submitted form.
 */
function example_form_redirect_handler($form, &$form_state) {

  $form_state['redirect'] = 'example-form-output';
}

/**
 * Creates the report output page.
 */
function example_form_output_page() {

  // Here is where I am stuck. How do I access the form variables?

  // Call db_select()

  $html = "
Report Output:
";

  // Display users, roles, creation date, etc. based on the search
  // criteria supplied in the form.

  return $html;
}


texts: How to create rule to change user role based on points (using User Points module)?

texts:
I'm using the User Points module which allow me to grant points to user. So far so good.

I need to create a rule to fire this condition/action: When user points are granted, then check if the user has more than 10 points. If so then add the "Master" role to this user.

I try using the Rules Condition "Data comparison", but I can't find the value something like "total points of the user".

Can I do this in any way?


texts: Create a permanent list of a content type

texts:
I have a content type named "clients" which can be filtered within a view and all can be selected using bulk operations.

What I would like to do is take the filtered list in the view and copy it to a permanent list of content on my site. So that it is saved and can be accessed at a later date without having to go through the filter options again.

For example, to store a list of clients all from one country, say Germany, to a list of these clients named Germany.

Any ideas how I would do this?


texts: Views removes style attribute in "Rewrite Results"

texts:
I've got screenlists for videos and I need to put them into the div tag to as a background and then change bacgkround position with JS to show the preview. I've downloaded Image URL Formatter for this purpose and added code to "Rewrite Results" field of the field in my view:

But there is no such attribute "style" in rendered html of the page. Does Views module block it?


texts: How to offset only a subselection of a set of nodes in a view

texts:
Sorry for the cryptic title, but could not find a better descriptive title. Suggestions welcome.

Situation: There is a newssite with on the frontpage two blocks:

1) a block of the latest 6 'promoted to frontpage' articles in form of an image caroussel
2) a block with the latest 12 newsheadlines, contains both 'promoted' as 'regular' articles

What should happen is:

block one displays the latest 6 'promoted to frontpage' articles
block 2 does not only contain older 'promoted to frontpage' articles, but also regular articles
when an article shifts out of bock 1 it should shift towards block 2, assuming it is not older than the 12th article in this block
there should be no overlap in articles between block 1 and 2, ie: the articles displayed in block 1 should not be displayed in block 2

Problem:

The problem is block 2. I can't figure out howto establish what I want without having an overlap between the two blocks.

The view of block 2 is pretty easy: select 12 nodes of the type 'article', order by date.

Question:

But how do I make sure that this selection takes out the first 6 promoted to frontpage articles? Offset 6 won't work, because then it might also skip regular articles. Only the promoted articles should be offsetted.

Is this feasible with some custom php code?

--- update ---

I think the most feasible solution would be either:

1) merge two views (one that selects the latest promoted articles with an offset of 6 and one that selects the latest regular articles together with some sort of union functionality and then limit it to 12
2) remove duplicates: so create a view that displays the latest 12 articles of any type, but which has been filtered in order to remove duplicates between the articles that are displayed in block 1

Haven't found a solution on either though...


texts: I have 2 commerce feeds imports, one must run before the other

texts:
I have a drupal 7 commerce site, each day our client uploads a .csv with updates to approx. 4000 products, including published status.

2 imports have been configured, 1 to update the product information and the other to update the product references (node/display) - both read the same .csv.

The importers must run 3 times a day, in order to avoid errors, the product importer must execute before the reference importer. If we use Drupal cron, both will start at the same scheduled time, which leads to errors.

What we really want is to run the product importer until it is completed (multiple times if necessary), and only then to run the reference importer. All of the above 3 times a day.

I imagine there is a hook allowing execution of a specific importer, so I can run it via bash cron, but I don't know where to begin looking, any pointers would be appreciated.


texts: Views name or url from taxonomy child terms

texts:
i have this vocabulare:

Mother

----Subchild 1

--------Child 1

----Subchild 2

--------Child 2

--------Child 3

how can i get the name or the url from child 1 or child 2, 3? In Views i found a (Term) Taxonomy-Term: parent term relationship/filter only?!

When i use them i get the names of the parent terms of my term. But i want to get the names of the child terms of my term. Any solution?

regards


texts: How can I modify the login form using hook_form_alter()?

texts:
I'm trying to alter the login form with the following code:

function git_form_alter(&$form, $form_state, $form_id) {
  $forms = array(
    'user_login_block' => 'user-login-form',
    'user_login' => 'user-login'
  );
  if (array_key_exists($form_id, $forms)) {
       //my altering code
    }
}

I got this from the openidselector module that introduces some JavaScript widgets and more or less is what I'm trying to do.
When I go to mysite/user/login it doesn't call the block where I have to alter the form.
It simply doesn't call hook_form_alter().

A different thing is with the register form, or any other form, that are calling the hook.

Can anyone tell me what can I do? How is it possible that openidselector uses the same method, but in that module the code works, while it doesn't work in my code?


texts: Filtering view results with a toggle for entity referenced fields that are 'null'

texts:
I have 2 content types:
Content type 1: 'Country'
Content type 2: 'Indicator'

The Indicator content type has 3 fields
Field 1: 'Indicator Value 1' (a number)
Field 1: 'Indicator Value 2' (a number)
Field 2: 'Country' Entity Reference for the country

I have a view that displays a list of countries and has the entity reference relationship setup to display referenced fields that are from the indicator content type.

My issue is that not all countries have both indicator values available (some only 'Indicator Value 1', some only 'Indicator Value 2', some both, and some neither). I want to have 2 range filters in the view, one for each Indicator. I am using a slider widget where I need to indicate minimum and maximum.

As soon as I add a range filter, because of the minimum and maximum any countries that don't contain both indicators within the range are removed from the results.

I want to be able to see all results by default, including the ones with null values. And have the option to search by one or both indicators using the slider filter.


texts:
I can not seem to find out what cron.php is doing exactly that it needs to have an ssl connection with Google.
I keep getting the following error:

  ERROR: Authentication with Google failed. Reason: BadAuthentication

I've Googled it and basically come up with nothing that seems to be similar to my issue.
Is there some cron.php configuration parameters I should be setting somewhere?

Thanks in advance,

SOLVED

The "Search" module is the culprit. Here's how I found it.
I hacked my cron.php file to add a couple functions it was calling so I could add logging information to help me track down the module. I copied both the module_invoke_all() and drupal_cron_run() functions into my cron.php, renaming them dev_module_invoke_all() and dev_drupal_cron_run(). The dev_module_invoke_all() is the logging is added and is shown below. The change I made in my dev_drupal_cron_run() was simply to change the module_invoke_all('cron') call to dev_module_invoke_all('cron'), so I am not pasting it. Then the cron.php call to drupal_cron_run() is changed to dev_drupal_cron_run() to use my functions.
I could then look in the "Recent log entries" under the Report menu to see the last module cron_hook() called. For me, it was the "Search" module. I disabled it, re-ran cron, and it successfully completed.

This is with a Drupal 6 installation.

function dev_module_invoke_all() {
  $args = func_get_args();
  $hook = $args[0];
  unset($args[0]);
  $return = array();
  foreach (module_implements($hook) as $module) {
    /*This logs a message out to the Recent Log Entries report.*/
    watchdog('cron', "Calling module: " . $module . " cron_hook: " . $module . '_' . $hook);
    $function = $module . '_' . $hook;
    $result = call_user_func_array($function, $args);
    if (isset($result) && is_array($result)) {
      $return = array_merge_recursive($return, $result);
    }
    else if (isset($result)) {
      $return[] = $result;
    }
  }
  return $return;
}

Even more info. I added watchdog logging to the search.module's search_cron() to determine which module it was calling and tracked the issue to the node module. I then added watchdog logging to the node.module _update_index function to log out which node was being indexed. I then re-ran the cron and found the offending nodes. There turned out to be a couple of issues: A PHP page trying to do openssl authentication which was my original error. That page had been deprecated, but was still in the node list. I deleted the page.

Dan


texts:
I'm writing a custom module to extend the Casetracker module to allow users to update the cases' due date via the comments form. So far I have successfully used hook_form_comment_form() to add the date field to the comment form and hook_comment() to write the new value to the DB using drupal_write_record().

I'm running into a caching problem though. The updated values don't show up in the node until I drush cc all. Is there a way I can tell Drupal to update it's cache to show the new value?

I'm using Drupal 6.26, Casetracker 6.x-1.0-beta9 (part of OpenAtrium).


texts: How to make different users profile pages for different user types in Open Atrium2?

texts: I have 3 different user types and I want to provide a specific profile edit page for each. The user type is set when registering for an account. I have the profile fields associated to each user type created in config/people/accounts, but I'm lost on how to create the separate pages for each user type and then to trigger the loading of the correct page based on the users type.


texts: How do I add a title attribute to the search submit button, exposed search, and reset buttons?

texts:
I want to add the title attribute to the search submit button, the exposed filter search, and the reset button.

How can I achieve this?


texts: Node hits getting cached for anonymous user

texts:
We are using Drupal 8.8.5. For every page we are trying to provide a counter which increments whenever user hits that node. These are nodes are available to anonymous users. So whenever an anonymous user hits the node, the view counter on that node should be updated to show the no of total hits . So lets say Tom and Hary are anonymous users. Tom hits node1. On top of Node1 it says "View 1" times. Now when Hary hits Node1 it should sat "View 2" times. Again if Tom hits node1 it should day "View 3" times.
I checked How can I show node Hits (statistics)? and made the necessary code changes in basic.theme and node.html.twig. Still, it shows Viewed O times.
This is the code I have in the basic.theme file.
function basic_preprocess_node(&$variables) {
  $variables['node_view_count'] = 0;
  if (!empty($variables['node'])) {
    // Get the number of times the current node has been viewed.
    /** @var \Drupal\statistics\StatisticsViewsResult $statistics */
    $statistics = \Drupal::service('statistics.storage.node')
      ->fetchView($variables['node']->id());
    if ($statistics instanceof StatisticsViewsResult) {
      $variables['node_view_count'] = $statistics->getTotalCount();
    }
  }
}

This is the code I added in the node.html.twig file.
Viewed {{ node_view_count }} times

I believe there might be a caching issue once it starts working. For each hit, the values should be updated.
On a side note, when I am using the Visitors module, the report is showing an updated page count even for anonymous users. I had to install the Advanced Page Expiration module, though.
How do I increment the node hit for anonymous user visits in each page and show it updated?


texts: Why isn't my programmaticlly created field showing up to be added to a content type

texts:
I'm trying to create a field that I can add to content types via my module, here is how I'm doing it:

/* Create the field to hold RSVP info */
function kade_rsvp_enable(){
    if(field_info_field(FIELD_REQUIRE_RSVP)) return; //field already created

    $field = array(
        "field_name" => FIELD_REQUIRE_RSVP,
        'cardinality' => 1,
        'entity_type' => 'node',
        'type' => 'list_boolean',
        'description' => 'Enable RSVP for this event?',
        'label' => 'Enable RSVP',
        'widget' => array(
            'type' => 'options_onoff',
        ),
        'settings' => array(
            'allowed_values' => array(
                '0' => 'No',
                '1' => 'Yes',
            ),
        ),
    );

    field_create_field($field);
}

And the field is getting created when the module is enabled. Here is the var_dump of the field_info_field for it's id:

array(20) {
  ["entity_type"]=>
  string(4) "node"
  ["description"]=>
  string(27) "Enable RSVP for this event?"
  ["label"]=>
  string(11) "Enable RSVP"
  ["widget"]=>
  array(1) {
    ["type"]=>
    string(13) "options_onoff"
  }
  ["settings"]=>
  array(2) {
    ["allowed_values"]=>
    array(2) {
      [0]=>
      string(2) "No"
      [1]=>
      string(3) "Yes"
    }
    ["allowed_values_function"]=>
    string(0) ""
  }
  ["entity_types"]=>
  array(0) {
  }
  ["translatable"]=>
  string(1) "0"
  ["storage"]=>
  array(5) {
    ["type"]=>
    string(17) "field_sql_storage"
    ["settings"]=>
    array(0) {
    }
    ["module"]=>
    string(17) "field_sql_storage"
    ["active"]=>
    string(1) "1"
    ["details"]=>
    array(1) {
      ["sql"]=>
      array(2) {
        ["FIELD_LOAD_CURRENT"]=>
        array(1) {
          ["field_data_field_require_rsvp"]=>
          array(1) {
            ["value"]=>
            string(24) "field_require_rsvp_value"
          }
        }
        ["FIELD_LOAD_REVISION"]=>
        array(1) {
          ["field_revision_field_require_rsvp"]=>
          array(1) {
            ["value"]=>
            string(24) "field_require_rsvp_value"
          }
        }
      }
    }
  }
  ["foreign keys"]=>
  array(0) {
  }
  ["indexes"]=>
  array(1) {
    ["value"]=>
    array(1) {
      [0]=>
      string(5) "value"
    }
  }
  ["id"]=>
  string(2) "23"
  ["field_name"]=>
  string(18) "field_require_rsvp"
  ["type"]=>
  string(12) "list_boolean"
  ["module"]=>
  string(4) "list"
  ["active"]=>
  string(1) "1"
  ["locked"]=>
  string(1) "0"
  ["cardinality"]=>
  string(1) "1"
  ["deleted"]=>
  string(1) "0"
  ["columns"]=>
  array(1) {
    ["value"]=>
    array(2) {
      ["type"]=>
      string(3) "int"
      ["not null"]=>
      bool(false)
    }
  }
  ["bundles"]=>
  array(0) {
  }
}

However, it doesn't show up when I go to add it to a content type

What am I doing wrong?


texts: Why is my website often put in maintenance mode by itself?

texts: My website in maintenance mode by itself. But other sites is work well, only this site has this problem. Some people encountered this kind of situation? Thank for help..


texts: How to dynamically enable a payment method

texts:
I have a product display node with a field "Choose one or more payment method" - Field type: List(text)-  for choosing  the payment method.
I sell only one product at a time.
Is it possible to dynamically enable a payment method according to the value set in the field of the product display node? I would like to do this with rules module.


texts: How to efficiently color countries on a map from a content?

texts:
I have various types of data-sets for 30 countries. (e.g. Population, GPD, birth numbers, etc.) What I want to do is, when people click each type for content, I want to display each data on a map with colors. Such as, USA GDP is bigger so it has more intense / darker color, etc.

So I plan to generate a new content type with fields for each country to enter data of each country. But I don't know if it's possible to plot this on a map almost like a heat-map?


texts: I want to add some div's and hrefs to user registration form. any ideas? I'm using ajax login/register module to get user login/register form in ajax windows. and i have no idea how to add some divs and hrefs to register form.


texts: Exporting comments only from one drupal site to another

texts:
How can i export only comments from a Drupal Site (Live) to a Drupal site (Dev).

The content of both sites is same. The live site only has new users and comments. I already exported the users and imported into Dev Site.

I looked into many modules but non on them only allow comments to be exported. Can i simply copy some MySql tables ?

thanks


texts: How can I hook into the system Contact form Message Sent process and alter the HTML generated?

texts:
I have a Drupal site where I am using the sited-wide system Contact to allow visitors to send messages to the site owner.  Once a visitor submits the form, the user is redirected to the home page and a sticky appears at the top reading:

Your message has been sent.

My question then, is it possible to change this message and add some HTML to the output?  Ideally I would add some javascript to create a virtual page view for the Google Analytics account so that I can track it as a Goal Conversion.

I imagine this would be a hook_ function sitting in my template file, but I'm relatively new to this process.


texts: How to change views pager with View All links

texts:
I am using the full pager in views module. I am displaying 40 items per page. The full pager display links like this

1 2 3 4 5 next last
I want to change it to this

View All 1 2 3 4

How will I do this? Any idea about this?


texts: Validate a field only if the value has changed and/or if it is a new value

texts:
I'm building a module that get information from the NCBI database API -- specifically it get's publications, from my group, by using a publication ID. I want anyone in the group to be able to add a publication to our site, however, to do this I need to make sure that the ID's being input are only input one time since they are all unique.

I've already set up a system that checks whether someone else has already submitted that value. I did this by building a constraint and constraint validator on that specific field that uses this query

$query = \Drupal::entityQuery($entity_type_id)
            ->condition($field_name, $id, '=')
            ->execute();

My current issue that I haven't been able to circumvent is in the event the user needs to update/change information in the fields on a node that has already been submitted, the validator is still run on that ID field and throws an error that this ID already exists - hence changes are not saved. I figure the easiest solution is to figure out if there's a way to remove the constraint property on the field only if the field is the same as it was previously. That way, if a user needs to edit that particular node, when they save the changes, the validator for the ID field doesn't throw an error.


texts: Generate slideshow of images present in a folder

texts: I want a module which gives user just a screen to upload images to a folder and it will generate a slideshow of the images and place it on a certain block in my website. Is there any module to do this or any custom code to do this?


texts:
The code below is used to get the word count of a field (field_body) using ajax callback. It works great and everything functions as it should, well almost.
For some reason, the click of a button is also calling the default node form submit action.

So what happens is after I update count, and suppose I don't save the content. In fact, just go to another page or refresh the page, I get something like
Categories is required
Tags is required
Thumbnail is required....

Basically whatever I would get on form validation. It's just that the result is delayed as I am using ajax.

The problem is not with ajax, because even I comment the callback, and I click the button it tries to submit the form, when clearly it should not as executes submit callback is False.

function hook_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'article_node_form' || $form_id == 'q_and_a_node_form' ) {

    $form['get_word_count'] = array(
     '#type' => 'button',
     '#value' => t('Update Count'),
     '#weight' => 5,
     '#executes_submit_callback' => FALSE,
     '#ajax' => array(
      'callback' => 'count_words',
      ),
    );

    $form['body_words'] = array(
     '#title' => t('Words in Body'),
     '#type' => 'textfield',
     '#disabled' => TRUE,
     '#weight' => 5,
     '#prefix' => '
',
     '#suffix' => '
',
    );
   $form['field_length_type']['#prefix'] = '
';
    $form['field_length_type']['#suffix'] = '
';
  }
}

function count_words($form, $form_state) {
  $str = $form['field_body']['und'][0]['value']['#value'];
  $count = preg_match_all("/\S+/", preg_replace('/(' . chr(160) .'|&nbsp;)/', ' ', strip_tags(str_replace('><', '> <', trim($str)))), $matches);
  $form['body_words']['#value'] = $count;
  if ($count < 500) {
    $form['field_length_type']['und']['#value'] = "short";
  }
  else if ($count > 500 && $count < 800 ) {
    $form['field_length_type']['und']['#value'] = "medium";
  }
  else {
    $form['field_length_type']['und']['#value'] = "long";
  }
  return array(
    '#type' => 'ajax',
    '#commands' => array(
      ajax_command_replace("#replace_body_words", $form['body_words']),
      ajax_command_replace("#replace_field_length_type", $form['field_length_type'])
     )
   );
 }
}

Any help would be much appreciated. Any workaround?


texts:
Is it possible to display the full, absolute URL of the home page in Drupal 7, like  www.example.com/The-best-example-possible ?

I'd like to display the full URL of the home page, not just the hostname.


texts: Conceptual question about taxonomy structure

texts:
Imagine i want a directory of different organisations in different locations. Let's say i have

hospitals
retirement homes
yogashops
health-insurance agencies
(...)

in

Boston
Detroit
Denver

I would create an overview listing of the cities to link them to the organistaions-categories of each city. These would be links to a view of all organisations of the chosen type in the chosen city.

What i already have is a vocabulary "organisations" and a vocabulary "cities". I have created a view with a contextual filter "organisations" which lists all items of an organisation-term:

organisations/yogashops

But how can i prepend the selection of a specific city?

Do i have to create a vocabulary of organisations for every city? Even if they are the same?

How can i reuse my "organisations"-vocabulary?

EDIT: Would it be an alternative to create a node for each city and then use them as entity reference for the categories?


texts:
I am looking for a simple way to sort my custom entities through a drag and drop interface and display them in the custom order in my views.

The best way would probably be to add a weight basefield to the entity type and let the drag and drop interface change the weight on each entity through ajax. Are there any examples on how to do that?


texts: How do I create a log/statistics of on page events?

texts:
I am using drupal 7, I have seen there are already statistic modules but can't find any for my situation

On my website I am trying to track certain on page activities which site admins can see in a table.

Example of activities are if users engage with certain elements on a page, if certain images load before user leaves, and browser information. Alot of information is only available through JS or Jquery not PHP.

On my site I can build a client side log, so when I go to console I can see the statistics I am looking for, but what is the best way to save this log/statistics to by drupal database.

I was thinking of building a content type called 'page log' with different fields relating to page info I need, which would be loaded on every page and filled/submitted via javascript. But think this would be too resource intensive.

To summarise, I have been building a function in javascript which collects on page activities which currently I can view in my browser console. I am looking for a way to save the log for each page to my drupal site in a way which can be recalled easily. Probably through views.

How can I save this log? Thanks for any help


texts: Display error message when validating form in a specified region or div

texts: I have a Drupal 7 form, built by using Form API. I just want to validate using the hook_form_validate function, and if there are errors, display them using drupal_set_message. It is working perfectly. The problem is that in another page, I have the same form in a div, in the left side of the page, and would want the error message to appear in this region only, and not at the top of the page, where now it is appearing (that is controlled in page.tpl.php via $message variable, I think). Any idea of how could I achieve this easily?


texts: Drupal 7 Single Sign On possibilities with the Domain Access Module

texts:
The background:
We (currently) have 2000 domain names pointed at a single IP. Drupal inherently has the ability
to use multisite, but for our particular Drupal 7 install we use a module named Domain Access to
delegate sites. The gist is though that Domain Access will not allow cross site logins, but yeah,
we would like our editors to log in once, and have access to all sites.

The question:
Has anyone made any headway with coming up with a single sign on solution with Domain access to date
for Drupal 7? I've been looking closely at two old modules, one no longer maintained (SSO for D6) and
one still maintained (CAS). I'm worried about using CAS I am not sure if it will work the way I intend
it since Domain Access seems to change quite a bit of Drupal(ly) stuff.

We could potentially use facebook, openid, twitter option, but i thing not having able to offer visitors
or customers a unique id across a network of sites is too me a big loss of identity and privacy.

Are there any solutions that are known to date, or information on what to start looking into? Has anyone in
the Drupal community managed to make a solution that I have not been able to find? The only possiblitiy that
I've found was this thread on Domain Access SSO but am uncertain to what version it pertains to (Drupal.
DA, SSO or otherwise). I tried contacting the author multiple times but never received a response. It looks
like the "Solution" was to create a master table set with users and permissions, then share those across the
domains. Unfortunetly (again) SSO on Drupal 7 is not an option.

Any opinions out there on the who what or why would be greatly appreciated, I honestly just need a start point
to get the ball rolling. Thanks everyone


texts:
I am using Drupal 7. I installed the computed field module and have a computed field in a content type. I need to be able to access the actual name of a node reference field that is in the same content type so i can then work with the data in the computed field. Currently I can only get the number of the node reference field using this in the computed code (php) field:

    $entity_field[0]['value'] = array_pop(field_get_items($entity_type, $entity, 'field_charity_reference'));

I need to be able to access a 'drill' into the the node reference to get the rendered title, which is a human readable name.

When using views and custom php I can use dpm($data); to explore the data and use this to work out I can access the rendered title by using:

    $data->field_field_charity_reference[0]['rendered']['#title']

Since originally posting this question I have found i can use dpm(field_get_items($entity_type, $entity, 'field_charity_reference')); in the 'Display Code (PHP)' input in the computed field to give a devel printout of the field I wish to access data from.

I would like to know how to drill into the results returned by field_get_items($entity_type, $entity, 'field_charity_reference') in order to output the name of the node reference field. Thanks


texts:
I have this code which gives me the number of terms on a node

 $count = count($node->taxonomy)

Is there a way i can restrict this to VID. i only want to get the count for a specific vocabulary.

Oh yeah the site is in D5

here is a link to the page http://national.thedelimagazine.com/8947/delis-austin-issue-2012-pdf-version-available


texts:
On a custom template for a taxonomy view, I want to render the current term (the one being viewed) using my custom taxonomy term formatter, how do I do that?

I have looked at the field_view_field function, but it's not clear to me how I would use its parameters field_view_field($entity_type, $entity, $field_name, $display = array(), $langcode = NULL) - esp. the $field_name part is not clear. I am afraid this is not the right function... Any help please?


texts: How to Execute a Specific Part of a Function

texts:
I am building a function in a custom module, and I want to be able to execute only a specific part of that function.

I am starting with the hook_node_api to see if an event occurs, and if that event occurs, I want to execute a only a specific part of that custom function.

function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {

    case 'presave'
    if (  $node->type == 'property' ){
        $old = node_load($node->nid);
        if($old->field_realtor_reference[0]['uid'] == NULL && $node->field_realtor_reference[0]['uid'] !== NULL){
               mymodule_tn_complete($node);
        }
      }

      break;
  }
}

function mymodule_tn_complete( $node)
{
  //Do something
  //Do Something Else

}


texts: How to alternate image on left/right using "Views Parity Row" module

texts:
This great tutorial explains everything except the CSS work.
http://gogrow.org/tutorials/views_parity_row

I need to add CSS class to each row so I can set left/right alignment accordingly in css style.
Views settings allows me to set the ccs class in Page: Style options but this one is always the same for each row. I need the class name also to alternate.

I need something like dynamically use the View Mode as css class name.

Current output:

Desired output:
 and

Or am I missing something and the CSS work is done in a complete different way?


texts: OG groups: How to check if user is a member or not?

texts: What code can I use to check if a user is a member of a group?


texts:
In Drupal 8 I'm struggling to remove classes from a given block. Here's a quick snippet from a preprocess function:

function mytheme_preprocess_block(&$vars) {
  $block_classes = array(
    'block_id' => array('custom-class'),
  );
  $id = $vars['elements']['#id'];
  if (isset($block_classes[$id])) {
    $vars['attributes']['class'] = $block_classes[$id];
  }
  return $vars;
}

Interestingly this works, and adds custom-class to the block, but even though it is overriding the existing class array, all the default Drupal classes are still added (later on maybe?). I know that I can remove classes in twig with {{ attributes.removeClass('class-to-remove') }}, but ideally I would like to have a preprocess function that doesn't require exposing more template files.


texts: page--user--login.tpl.php is not recognized

texts:
drupal isn't recognising the page--user--login.tpl.php file.  Tried clearing the cache. Still not working. I've never themed the user login page before. Any idea's?

I am running Drupal 7 and I want to theme the whole page.
The other page template is being picked up.
There isn't any other page--user--login.tpl.php in my theme directory

the page--user.tpl.php is being recognised but the page--user-login-tpl.php is not.
bummer because i want the login page to be considerably different to the user page.


texts: Drupal 8.0 to 8.1.8 upgradation is not working

texts:
When i tried to update drupal to latest version (8.1.8) am getting  the following error

But in the status report page it shows as upgraded to 8.1.8

Any idea how to resolve this ??


texts: Add another node in create content Drupal 6

texts:
I am searching for a way to add content in node/add/page (for example) with a "Create another node (of this content type)" button. The button would add another form, and when the forms are submitted, Drupal would create 2 nodes.

Is there already a module that does this? How can I differently achieve this?


texts: How to create node reference fields in Drupal 7?

texts: I am puzzled. This was a very valuable option in D6 CCK, but since it moved into core, I can't find the option to create a noderef field (found a term reference field, though). I know it must be out there, where is it?


texts: how to differ start date and end date in a table views

texts: in D7 i have a date field with start date and end date and configured like start=now and end date=+30days. both dates are displayed well in two columns in a table views seperately. now i want a third column to dispaly like end date-start date = 30days. how? any help please.


texts: How to transfer webform submission ID to client side

texts:
I need to transfer the submission ID to the client side after a webform is submitted. The problem is that after submission the Confirmation page is showed. And how can I attach the current sid to a page? I know how to do it on a node (se below) with Drupal behaviors on a client side JS-script.

Anyone? Or maybe the sid can be transfered to the client side another way?

function mymodule_webform_submission_insert($node, $submission) {
 // $node will give you the node id of your webform
 // $submission will give you the id of your data which you inserted in web form
 $sid = $submission->sid ? $submission->sid : FALSE;
 if($sid){
   $currentSid = array('mymodule' => array('sid' => $sid));
   $node->content['#attached']['js'][] = array(
     'data' => $currentSid,
     'type' => 'setting',
   );
 }
}


texts: How do I display the content type's description in a view's header?

texts:
I have a view that lists nodes of a single content type, where the content type is given as contextual filter.
I'd like to add the name of the content type and a description to the header, for example as the following.

Content Type: Cooking
The Cooking content type is for cooking-related content

I can show the content type name by by adding a hidden field to the view and then using <h1>{{ type }}</h1> in the header, but I don't see such an option for the description.
Is there a way to achieve this?


texts: commerce show message if anonymous user adds product to cart

texts:
What I am trying to accomplish is :

If an anonymous user adds a product to the cart, I would like to display a message on the site that says : Login to check out

what I did is the following:
Added a new rule with the event: After adding product to cart

Condition: Data comparison, Data to compare: site:current-user:roles, The value to compare the data with: anonymous user

Action: Show message on the site : Please Login or Sign Up in order to checkout

but the message still does not show if an anonymous user adds a product to the cart


texts: Contextual Filter with Title and Language

texts:
I'm building an api that is going to change base on the title and the language that is been request. This request is base on the URL something like this www.example.com/abc/fr-fr

abc = title of the content
fr-fr = Language Code name

For some reason the context filter of the language is turning my search into empty. Here is what happen when I try to run www.example.com/abc/fr-fr

{
  "nodes" : []
}

And it should looks like this instead:

{
  "nodes" : [
    {
      "node" : {
        "Literal Api" : "{\n \"glossary\": {\n \"title\": \"example glossary\",\n\t\t\"GlossDiv\": {\n \"title\": \"S\",\n\t\t\t\"GlossList\": {\n \"GlossEntry\": {\n \"ID\": \"SGML\",\n\t\t\t\t\t\"SortAs\": \"SGML\",\n\t\t\t\t\t\"GlossTerm\": \"Standard Generalized Markup Language\",\n\t\t\t\t\t\"Acronym\": \"SGML\",\n\t\t\t\t\t\"Abbrev\": \"ISO 8879:1986\",\n\t\t\t\t\t\"GlossDef\": {\n \"para\": \"A meta-markup language, used to create markup languages such as DocBook.\",\n\t\t\t\t\t\t\"GlossSeeAlso\": [\"GML\", \"XML\"]\n },\n\t\t\t\t\t\"GlossSee\": \"markup\"\n }\n }\n }\n }\n}",
        "Title" : "abc",
        "Language" : "French"
      }
    }
  ]
}

Things that I have already try it out:

I thought that the problem was having multiple contextual filters
but that did not fix the problem because I try using it only the
language contextual filter and I still have the same problem.
Also, I try to use the word "French" instead of the language
code, which is "fr-fr" and this did not fix the problem.

Here is my view configuration:

Note I'm using node translation in 7, not entity/field translation. Each language has its own copy of a node.

My question is why I'm getting an empty node instead of the entire node information?


texts: how to get valid URL in combination of text and field content in VIEWS

texts:
Field HOSTNAME returns IP Adress.
I have to overwrite the field output .
Is there a way to modify this with an given URL like this:
'www.ip-tracker.org/locator/ip-lookup.php?ip=' and adding the field content of HOSTNAME to get an valid URL?


texts: What options do I have for changing CSS depending upon context?

texts:
I would like to change CSS for different site areas and page layouts depending upon contextual information such as the user role or the type of content being displayed.  The types of changes would include font, color, and background options.  I can think of several ways to approach this, but could really benefit from the experiences of others.

Some options:

Use Views or panels to identify context and then associate styles with them.  This is limited because some of the elements are not directly associated with content, such as menu background, colors, etc.
Create a custom module to identify the user, content type or other context criteria and then modify the render array.  This sounds feasible, but the render array is pretty cryptic, and I'm not clear on what needs to change.  IF you've tried this, what have you done.
Create custom code in a theme to identify the context and then assign div class values to isolate the affected sections.

If you have tried this or other options, what did you do and how effective was it?


texts: Create nodes from a JSON file uploaded in a form by an user

texts:
I've got this form:

 $form['import_json'] = [
      '#type' => 'file',
      '#description' => $this->t('Allowed extensions: json'),
      '#title' => $this->t('Import your JSON\'s file.'),
    ];

    $form['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Import'),
    ];

I have to use '#type' => 'file' because AFAIK managed_file doesn't allow json file and file is the only type left.

I need to be able to get the uploaded file when the user submit the form to be able to convert the JSON's data to create nodes of a certain type.

My function is already created and it looks like this:

protected function createActualite(string $json)
  {

    $jsonstring = json_decode($json, TRUE);

    foreach ($jsonstring as $field) {
      $node = Node::create([
        'type' => 'import_content', // Machine name de notre content type 'actualité'
        'title' => $field['titre'],
        'body' => $field['body'],
      ]);
      $node->save();
    }
  }

The problem is that I can't find a way to properly get the uploaded file, I tried the same way that we do with managed_file

$file = File::load($field['import_json']);
        $file->setPermanent();
        $file->save();

but it doesn't work, also this (which is 10yo) doesn't do the trick either gist

If someone can lead me to arrive to save this file or to any doc, I would greatly appreciate.


texts: How to efficiently divide entities into groups based on field values

texts:
Problem

I'm trying to create job alerts. So every user will select certain filter criteria on their account, which will then be used to perform a search api query returning the relevant new jobs.

To my inexperienced programmer brain this sounds like a lot of queries that will scale terribly.

So I'm trying to construct something which will organise the users into groups who have the same criteria thus avoiding repetition of queries.

(i.e. divide a set of entities into groups based on field values).

My question is, is there a function or commonly used set of procedures for doing this? (Perhaps a module which I could look to for the design?)

Or another option, would the performance change be minimal, because of things like memcache and APC which would cache the queries which repeated?

My current design

In order to do this, my current thinking revolves around creating a branching set of queries.

First divide users by field a options, then divide each sub option into field b options and so on.

Each time you'd check to see if you ended up with 0 or 1 users in which case you could stop the tree.

Because I already use SearchAPI and have indexes running for users and nodes I would use this to query. (I'm assuming it would be faster than pulling from the database).


texts:
I followed this post, I am able to filter nodes based on content type and other parameters

http://test/api/node?parameters[nid]=1&parameters[status]=1

but I am not able to filter based on taxonomy terms (tid), problem is with nested json, how do I pass the parameter on URL for nested json?

I don't want to use services_views.

Below is my json data,

{
    "vid": "142",
    "uid": "2",
    "title": "Tomato",
    "log": "",
    "status": "1",
    "comment": "1",
    "promote": "1",
    "sticky": "0",
    "nid": "142",

..
..

 "field_category": {
        "und": [
            {
                "tid": "2"
            }
        ]
    },
}


texts: Resize & Crop Image Style Lowers Resolution

texts:
Whenever I try to implement a "resize & crop" image style on the display of a node in Drupal 7, the image also comes out with a lower resolution than the original file. Any idea why this might be happening or how I can get it to stop?

Thank you.


texts:
Drupal 8 ships with ckeditor as the default text editor. Drupal itself can be used free of charge without limitations. At least this is what I thought until now.
While CKEditor seems to be OpenSource, the website suggests there is a price depending on how it will be used. E.g. if a project has more than 2 developers, or more than 5 content editors.
https://ckeditor.com/pricing/
How does this play together? What am I missing? Is there a special license when using CKEditor in a Drupal project?