texts: Why won't this update in hook_update_n() run in batches correctly?

texts:
I am working on this issue in the Feeds issue queue: https://www.drupal.org/node/2341407

I am trying to make the updates to the importers run in batches. I can't figure out why this won't run in multiple batches when there are multiple importers. What happens is instead of seeing a progress bar reload a few times when running update.php, it loads once and processes all importers in a single batch.

The code works well except for batching. Below is the code. Thanks in advance!

<?php

/**
 * Fix importer mappings for file and image fields to use :uri convention.
 */
function feeds_update_7210(&$sandbox) {
  // If this is the first pass through this update function then set some variables.
  if (!isset($sandbox['total'])) {
    // Load all importers.
    $importers = feeds_importer_load_all(TRUE);
    $sandbox['total'] = count($importers);
    $sandbox['current'] = 0;
  }

  foreach ($importers as $importer) {
    $processor = $importer->processor;
    $config = $processor->getConfig();
    foreach ($config['mappings'] as $id=>$mapping) {
      // Act on mappings that do not contain a colon.
      if (!strpos($mapping['target'], ':')) {
        // Get field data. Check if $info is empty to weed out non-field mappings like temporary targets.
        $info = field_info_field($mapping['target']);
        if (!empty($info)) {
          // Act on file or image fields.
          if (in_array($info['type'], array('file', 'image'))) {
            // Add ':uri' to fix the mapping.
            $config['mappings'][$id]['target'] = $mapping['target'] . ':uri';
          }
        }
      }
    }
    // Add the updated config and save the importer.
    $processor->addConfig(array('mappings' => $config['mappings']));
    $importer->save();

    drupal_set_message(t('@importer fields have been updated.', array('@importer' => $importer->id)));
    $sandbox['current']++;
  }

  // Set the value for finished. If current == total then finished will be 1, signifying we are done.
  $sandbox['#finished'] = ($sandbox['current'] / $sandbox['total']);

  if ($sandbox['#finished'] === 1) {
    drupal_set_message(t('@importers importers processed.', array('@importers' => $sandbox['total'])));
  }
}


texts: The Field module shows an error when I call drupal_get_form()

texts:
I have a menu local task callback in hook_menu():

$items['leg/add'] = array(
    'title' => t('Create a new leg'),
    'page callback' => 'mymodule_leg_node_form',
    'access arguments' => array('create leg content'),
    'file' => 'node.pages.inc',
    'file path'=> drupal_get_path('module', 'node'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
);

This is the page callback function:

function mymodule_leg_node_form(){
    $form = drupal_get_form('leg_node_form');
    return $form;
}

When I visit that page, I get the following error:

  Fatal error: Cannot access empty property in path\to\site\modules\field\field.attach.inc on line 197

I have a "Leg" content type, and I just want to show the form to create nodes of that type in a tab.

My content type has two fields: "field_from" and "field_to."
drupal_get_form() calls _field_invoke(), and the error is generated from that function.

I tried to change the menu definition as below, but I get the same error.

$items['leg/add'] = array(
    'title' => t('Create a new leg'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('leg_node_from'),
    'access arguments' => array('create leg content'),
    'file' => 'node.pages.inc',
    'file path'=> drupal_get_path('module', 'node'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
);

I'm implementing something similar to what reported in http://drupal.org/node/251526#comment-827860; it might work in Drupal 6 with the CCK module, but it doesn't seem to work on Drupal 7.

I found the same problem reported in Drupal bug issues, but I could not find any qualified answer.

http://drupal.org/node/1015580#comment-4914818
http://drupal.org/node/1028230#comment-4799746


texts:
This question is about Rules on Drupal 8.

Reading the documentation, I find information about how to replace many of the hooks, but not hook_rules_data_info. It might be obvious, but please point me in the right direction and consider adding this info to the docs.

In Drupal 7 I just had:

  'property info' => array(
    'uid' => array(
      'type' => 'integer',
      'label' => t('User ID'),
    ),
    'timestamp' => array(
      'type' => 'integer',
      'label' => t('Timestamp'),
    ),
    'name' => array(
      'type' => 'text',
      'label' => t('Name'),
    )
  );

How do you properly define the samething? As a subclass of \Drupal\Core\TypedData\Plugin\DataType\Map? How?

This is basically a repost of the issue "hook_rules_data_info replacement" in the hope that someone here has worked enough with Rules on Drupal 8 to easily solve this. In that issue Fago wrote this (in comment # 3 of it):

  ... that's now covered by the Typed Data API. Thus, you'd define a new data type using typed data. You can then use it in Rules. For structures like that, you'd need to define a complex data type, i.e. you can extend from the Map base class in the ComplexDataDefinition base class. The definition class needs to be used for defining the structure, for the actual instance class you can use whatever fits your use case. Could be that Map is already perfectly fine for your use case.

To which I replied:

  I'm happy that I wasn't complete off the track, but I still think the Rules documentation would benefit from a code sample. I did try to look at Typed Data API documentation, but I didn't really find the help I needed. I'll look at that Map class again ...

So basically, I maintain my question. Alternative title: "How to use the Typed Data API with Rules"


texts: Is there a nicer way of getting my nodes language and text direction?

texts:
My site is almost entirely in English, but with individual pages in different languages. There's one extra page per language other than English, as a single page "this is a summary of the sites information in your language" sort of deal.

I've used the Drupal "language" module to set up some languages and give some nodes a language other than English. I don't really want anything more complicated than this. Specifically I don't want:

To translate the entire site to any other language.
To allow users to pick their language.
To translate anything other than node (single page) content. Menus,
site slogan, etc, will always be in English.

When viewing the pages for those nodes, I want to set some CSS classes and in some cases the text direction (rtl for Arabic / Urdu / Hebrew) based on the nodes language.

For some reason, the global $language variable is always set to English, regardless of the node language.

I can get the nodes language from $node->language and work out my CSS classes and text direction with the following code in my page.tpl.php:

<?php
    $node_lang = 'en';
    if (isset($node) && isset($node->language)) {
        $node_lang = $node->language;
        $rtl = ($node_lang == 'ar' || $node_lang == 'ur' || $node_lang == 'he');
    }
    $en = ($node_lang == 'en' || $node_lang == 'und');
?>
<div id="content"
    class="primaryContent <?php if($rtl){print "rtl";}?>"
    <?php if ($rtl) { print "dir='rtl'"; } ?>
    <?php if (!$en) { print "lang='$node_lang' xml:lang='$node_lang'"; } ?> >
...content...
</div>

Is there a simpler or "more recommended" way of doing the above? Doing my own detection of rtl / ltr feels fairly brittle.


texts:
Does anyone know how to turn off maintenance mode for brainfx?  I tried http://www.website.com/?q=user/login but that gives me a blank page (no html source or anything).  I tried the following query.

UPDATE `variable` SET `value`='0' WHERE 'name' = 'maintenance_mode';

It didn't affect any records.

I tried to find a $conf['maintenance_mode'] variable in the project, but it doesn't exist. Adding that $conf['maintenance_mode'] = false; in setting.php didn't do anything either.

How do I turn off maintenance mode?


texts: Can a database be tested to see if it is inconsistent?

texts:
We all know that Drupal doesn't really support the concept of foreign keys in the database, and likely never will1.

We also know that it is possible for modules to not do the right thing, or that users will periodically do crazy things like

DELETE FROM node_revision
WHERE vid = 123

in an effort to "keep the database tidy".  When this happens, hooks don't run, and there is orphaned data in the database.  Mostly, this data is harmless, but occasionally it causes really weird behavior and can bring out bugs in code.

Are there any decent methods for detecting whether you have have dead and/or inconsistent data in your database?

1 The Drupal 7 Schema API supports them for documentation, but not enforcement.


texts: read new menu link id (mlid) before new menu item is saved

texts:
I'd like to do something with menu links when they are saved.

I can use hook_menu_link_alter():

function my_module_menu_link_alter($item) {
  my_module_do_something($item);
}

This seems like the best and only hook I can use here. Only, the my_module_do_something function requires $item to have the mlid propety (menu link ID) set, and when a new item is being saved, the property doesn't exist yet.

I can fake it by querying the database for the most recent mlid value and incrementing 1:

$item['mlid'] = db_query('SELECT mlid FROM {menu_links} ORDER BY mlid DESC LIMIT 1')->fetchField() + 1;

(I'm not sure if I can use MAX() here, I don't know enough about dbs that aren't MySQL or Postgres)

And I think this will work fine for my specific use case, but I'm curious to know if there is a better, more generic solution. It seems to me that this one will break down if content is being imported rapidly while users are active on the site, for example.

What is the best way to pass the future value of the item's mlid property to my function?


texts:
I am working on a website with facetapi + search_api, with some facets for taxonomy term references.

One of my facets is getting the machine name field_xyz_parents_all or field_xyz:parents_all, which in the URL this becomes field_xyz%253Aparents_all.

I want this facet to replace the older facet with machine name field_xyz, so that old URLs still work. So I would like to change the machine name or url query key of the new facet.

Any idea how to do this?

One idea I have would be to implement hook_entity_property_info_alter() and define my own entity property with the desired machine name, overwriting the existing entity property field_xyz. I imagine this would work, but it somehow seems wrong, because in other places I might want to keep the original meaning of this property. Ideally I would only change the facet query key, not the property.

EDIT: The original intent I had with this was to change the facet alias used in the url. However, changing the question to clarify this would make it a "chameleon question". Hence, I don't.


texts: Conditional .htaccess rule for multisite sitemap.xml

texts:
We have multiple sites hosted with Domain access module. I was planning to host sitemap.xml files like web_root/zyx.com/sitemap.xml and web_root/abc.com/sitemap.xml.
I am using the following code.
RewriteCond %{HTTP_HOST} ^xzy.com [NC]
RewriteRule ^sitemap.xml$ /xzy.com/sitemap.xml

This code isn't universal and it requires to duplicate it every time a new domain is added.
How can this code be improved to serve sitemaps from web_root/website_name/sitemap.xml?


texts:
I have put this code into my scheduler under php evaluation. It gives me wrong output like:
Thu, 01/01/1970 - 05:30
My Code:
I put a cck field in data selector to get the date value that I am using in $value variable to get the date.
$originalDate = $value;
$date1 = str_replace('-', '/', $originalDate);
return date('Y-m-d',strtotime($date1 . "+3 days"));

Please help me why its printing the wrong date in scheduler.
Screen short of my scheduler page what i am trying to do is.. may be it will be more helpful to understand


texts:
My menu looks like the following:

defs menu is linked to def view, fghs menu is linked to fgh view.

abcs | defs | fghs

Now when I click on defs, a view gets opened.
Now my breadcrumb is the following:

Home >> defs >> def

def is the view. In this view there is a link to another view. When I click on this view, the breadcrumb is the following:

Home >> fghs >> fgh

But I want the breadcrumb in this format:

Home >> defs >> def >> fgh

How can I achieve this? I am using Bartik theme.

In the page.tpl.php file, I am using the code below:

<?php if ($breadcrumb): ?>
      <?php print $breadcrumb ?><?php if ($title != ""): ?>
&raquo; <?php print $title ?>
<?php endif; ?>
<?php endif; ?>


texts: How to copy one field data to another and save a new revision?

texts:
We are going to remove an obsolete field(field_old) and will be using a new field (field_new) and have a need to copy the data from field_old to field_new (both text fields). Then we need to create a new revision of the node so that field_new can be saved moving forward.

Below is what we have tried but it is not working.

function mymodule_update_7001(&$sandox) {
   $result = db_select('node', 'n')
             ->fields('n', array('nid', 'field_old', 'field_new'))
             ->condition('n.type', 'article')
             ->execute()
             ->fetchAll();

   foreach( $result as $nd) {
        $node = node_load($nd->nid);
        $node->field_new = $node->field_old;
        $node->revision = TRUE;
        node_save($node);
   }
 }

Through the node/edit screen under URL Settings, i can check the "Auto generate URL alias" checkbox. How would i be able to incorporate as part of the field copy?


texts: Drush - module/feature changes -- dev --> qa --> staging --> prod

texts:
Is Drush make file and install profile used for the initial set up only? We are in very early stages of development and trying to figure out the best approaches to transfer changes across environments: dev --> qa --> staging --> prod

Say that week 1, I created an install profile and used that to set up the distribution in qa environment. In week 2, I added a few more modules. How do I go about adding the new modules in qa environment? Looks like "drush make filename.make" is used for creating new site, but not updating.


texts: Constraint doesn't attach from BundleFieldDefinition, but does from entity_bundle_field_info_alter()

texts:
I'm adding a trait to Commerce Product Variations, which applies the following

  public function buildFieldDefinitions() {
    // Builds the field definitions.
    $fields = [];
    $fields['plan_code'] = BundleFieldDefinition::create('string')
      ->setLabel(t('Recurly Plan Code'))
      ->setDescription(t('The Plan Code of the related Recurly plan.'))
      ->setCardinality(1)
      ->setRequired(TRUE)
      ->setDisplayConfigurable('form', FALSE)
      ->setDisplayConfigurable('view', FALSE)
      ->addConstraint('RecurlyPlanCodeExists', []);
    return $fields;
  }

The plan_code field appears on product variations as expected when the trait is enabled, but the field is not validated against RecurlyPlanCodeExists when the entity is saved. However, if I add the constraint via hook, as in the following, the constraint is attached and validation runs as expected.

/**
 * Implements hook_entity_bundle_field_info_alter().
 */
function commerce_recurly_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) {
    if ($bundle === 'recurly_plan_variation') {
      if (isset($fields['plan_code'])) {
        $fields['plan_code']->addConstraint('RecurlyPlanCodeExists', []);
      }
    }
}

Inspecting $fields['plan_code'] in the above hook confirms no constraints exist on the field prior to adding $fields['plan_code']->addConstraint('RecurlyPlanCodeExists', []);. Interestingly, $fields['plan_code']['description'] is also an empty string despite being defined in the BundleFieldDefinition. I'd assume that these are related. Any idea what the cause might be?

I've already tried deleting all existing variations and disabling/re-enabling the trait and it's had no effect.

EDIT: I just realized that the docs refer to adding constraints to BaseFieldDefinition, while I'm using BundleFieldDefinition. Maybe this is the reason?


texts: Reducing redundancy (code duplication) in templates

texts:
The front page of my site needs a very different layout to every other page on the site, so I want to use page--front.tpl. However, the front page still has many of the standard regions, and shares the same main_menu as the rest of the site.

I have just tried moving the shared "outer" parts of my page.tpl (including main_menu and page_bottom) into the html.tpl because I want to use page--front.tpl without duplicating code if possible.

Unfortunately, many of these variables, notably main_menu are defined only for page.tpl, so I've had to hack it into X_preprocess_html. This makes me nervous because I don't know what other variables I might be missing: I basically want to refactor it to avoid code duplication.

Am I going about this the wrong way? Or if not, how can I be sure I still have all the variables and regions I need pushed up to html.tpl?


texts:
I have an object called 'attributes' available to me in a twig template. Given that the following:

{{ dump(attributes) }}
{{ dump(attributes.storage) }}
{{ dump(attributes.storage['data-quickedit-field-id']) }}

dumps this:

how do I access the value property:?

'paragraph/3/field_section_title/en/default'

I've tried the obvious:

{{ dump(attributes.storage['data-quickedit-field-id'].value) }}

The following methods are available to me:


texts: Is it possible to get relation in Views to Commerce products?

texts:
I made View by Taxonomy term.
Using Relations I got Content which has this Taxonomy term.

Now I want to see couple of Commerce fields (SKU and Price) which are referenced from Content type.
Is it possible from Taxonomy View go to Content (I have already done it) and then to Commerce fields from Content?


texts:
It seems like the browser conditionals:

  drupal_add_js(drupal_get_path('module', 'cufon') . '/js/cufon-drupal.js',
 array('group' => JS_THEME, 'browsers' => array('IE' => 'gte IE 9', '!IE' => TRUE),
'weight' => 999, 'preprocess' => FALSE));

included in template.php (or a module) are not working due to the fact browsers option is supported for drupal_add_css() but not for drupal_add_js().

Can one state a not-hackish/patchy solution to exclude this file cufon-drupal.js on older browsers?

A solution like

<!--[if gte IE 9]>
<script src='<?php drupal_add_js(drupal_get_path('module', 'cufon') . '/js/cufon-drupal.js'); ?>'>
</script><![endif]-->

in html.tpl.php
is not working.


texts:
I encountered a strange situation. I have a Drupal 6 site with a very large menu tree. I can add new menu items but I cannot rearrange menu items. I can move the items, but when I submit the changes, the menu item gets back to the old position.
I tried to disable javascript and set the weight manually, I tried to empty the cache, even disabled it completely. I tried to rebuild the menu with DEVEL, but nothing helped.

I recently upgraded to PHP 5.3.27 so maybe it's related to this. I had some errors about timezone settings, but I corrected this with the timezone set in php.ini. I have no other errors in the log.

If I edit a menu item and set the weight, it works. If I set the weight from the DB, it works. The only thing that doesn't work is the rearranging on the items list page.

Edit: PHP log shows no errors even with E_ALL reporting.
I think the problem is with Drupal, as it only lets weights from -50 to 50 and the rearranging can't put the items where I want them. Whe I set weights of more than 50 in DB, the ordering was correct, just until I wanted to change the order withhin Drupal. Then, the manually set items scrambled. Is there a way I can set it up to allow values in a wider range? I don't want to rearrange everything via DB it's a pain in the ass.


texts:
I'm using Drupal Services along with Drupal Commerce Services to make an e-commerce site that runs on JS/Backbone.

I want to prevent a user from being able to flood an API endpoint with requests, because in my initial tests it seems that hitting a few endpoints every 100ms kills my Mariadb process after about half a minute. Although I think it's actually the massive increase in PHP-FPM that does it. Either way, I'm looking for a Drupal-first route, so it will be solid on the server, client and api.

I'm not looking for anything regarding hiding the submit button or anything like that, I'd rather something that would "lock" any JSON requests if, say, 5 requests are made in 10 seconds, based on IP, sessionID and others. Similar to what fail2ban or the NPM flood module does.

It may be a basic module tat I've just not found yet, so apologies if the answer should be obvious.


texts: I want to submit several items with Views Bulk Operations - is there a module or method to add fillable fields to a view?


texts: How do I reload an AJAX modal node add form without altering the behaviour of the original node add form?

texts:
I'm trying to edit the behaviour of node submit form (node type = 'class') but only when the form is submitted within an ajax modal window. Importantly, after the form in the modal window is submitted the modal window should just close (or even better reload a blank form and display a status message confirming the previous submission). This would enable the user to carry on submitting 'class' nodes before closing the modal window and returning the existing page.

I managed to get the below module code (adapted from here) to simply close the modal window, but this also seemed to alter the original node add form (accessed at: /node/add/class) so that the page did not redirect to the newly published content following submission of the form. How could I adapt the module code to only alter a new form display mode with machine name: node.class_modal_form_mode (leaving the default form at node/add/class unaffected)?

<?php

use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\CloseModalDialogCommand;
#use Drupal\Core\Ajax\RedirectCommand;

/**
 * Implements hook_help().
 */
function modal_form_example_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the modal_form_example module.
    case 'help.page.modal_form_example':
      $output = '';
      $output .= '
' . t('About') . '
';
      $output .= '
' . t('Display a form in a modal window using the Drupal Ajax API') . '
';
      return $output;

    default:
  }
}

/**
 * Implements hook_form_alter().
 */
function modal_form_example_form_node_class_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['actions']['submit']['#submit'][] = '_modal_form_example_ajax_submit';
  $form['actions']['submit']['#attributes']['class'][] = 'use-ajax-submit';
}

/**
 * Close the Modal and redirect the user to the homepage.
 *
 * @param array $form
 *   The form that will be altered.
 * @param \Drupal\Core\Form\FormStateInterface $form_state
 *   FormState Object.
 */

function _modal_form_example_ajax_submit(array $form, FormStateInterface &$form_state) {
  $response = new AjaxResponse();
  $response->addCommand(new CloseModalDialogCommand());
  #$response->addCommand(new RedirectCommand('/'));
  $form_state->setResponse($response);
}

Any help appreciated.


texts: Problem Trying to upgrade webform to latest version using composer

texts:
I've been trying to upgrade webform 5.19 to version 6 using composer but I keep getting this error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
drupal/webform_ui 5.19.0 requires drupal/webform 5.19.0 -> satisfiable by drupal/webform[5.19.0] but these conflict with your requirements or minimum-stability.

I asked over at the module's help and was to to try here. Has anyone seen this or have an idea what I'm doing wrong?


texts: Thumbnail preview not showing in Video Embed Field Module

texts: I am using Video Embed Field Module for embeding videos in dupal 7 site. The thumbnail preview is not showing. I created a view block in the preview section of the view its shows the thumbnail but when the block in in some region of page it only displays the title.


texts: Dupal cache and GeoIP - how can I have both?

texts:
Drupal 6 installation, 13 languages. Users are being redirected to the correct language based on browser language and we have a link that includes visitors's country code (i get this code VIA GeoIP API).
Problem is - if Drupal cache is enabled, it caches the pages and users are being redirected to different languages, and also country codes are wrong. If I disable cache, everything works, but the site is much slower.

Is there a way to use cache AND have GeoIP work correctly?


texts: How to install ckfinder outside the ckeditor module folder?

texts:
I have installed both the ckeditor module and the ckfinder plugin. They work fine. So far so good.

The problem is that I have ckfinder plugin inside the ckeditor module folder (sites/all/modules/ckeditor/ckfinder). Then every time I update the ckeditor module I lost the ckfinder plugin.

I'm sure that there is a way to put ckfinder inside the libraries folder instead but I don't know to do it in the right way.


texts: Blank screen with no error messages on new server

texts:
I have a working Drupal 7 site, built with git, running on 2 different servers, one test server and one server used for staging and production sites. So I know that the site is working.

So after deciding to move the production and staging sites to a new Apache server I cloned my git repo with the whole codebase, to the webroot and created the database and imported a copy of the mysql database.

I then edited the settings.php file to match the new database name, user and password. Using SSH and Cygwin I can login and run mysql commands, like 'show databases' etc. So I know that the mysql connection works too.

But when I try to test the site from a browser I just get a white screen, that times out after a couple of minutes.

I have read this artcile How to see the error messages when I get the white screen of death?, and I have added the suggested lines in order to show error messages in both index.php and settings.php with no change whatsoever. Just a white screen and the busy icon turning.

So maybe there is something in .htaccess that needs to be changed? I tried to uncomment the rewritebase line and adding the site name, with no luck.

  RewriteBase /

The phpinfo.php file in the webroot opens without problems. So I guess it must be somehting odd with the site all the same.

The file structure on the web server does not include any public_html folder. This is how it looks and I have cloned my site directly into this folder:

/home/httpd/example/www.example.com

Is that the problem here? That Drupal 7 needs a another folder structure?

This is what the server error log looks like, after the timeout:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 130968 bytes) in /home/httpd/example/www.example.se/includes/bootstrap.inc on line 966

After increasing the memory_limit from 128 MB to 512 MB, the apache server's error message stops complaining about the memory and instead shows this message:

Script timed out before returning headers: index.php

I now tried to do a fresh install of a Drupal 7 site with a new database, which actually worked. I then changed the database settings in settings.php to call my original site database. And that worked to.

So now my code is on speaking terms with the right database. But I have no git branches and all my images an so forth in the default/files folder is missing. But why did this work? Is there a step when deploying a Drupal site to a brand new server with git, that I missed? The git repo contains everything that is needed, but still it didn't work. Please help, if anyone recognizes this behavior.


texts:
The jCarousel plugin looks like it's mostly used with Views, but I'd like to use it (or something like it) for a simple Image field which has multiple images in it.

Do you know of a way to do this or another module which behaves this way?


texts:
I maintain a module (http://drupal.org/project/csm) that adds a new tab to the node type settings page, and gives the user various fields in that tab that can be used to tweak some settings related to that node type.

I'm in the process of adding some new functionality that will need me to change how this form works. I'll need to be able to give the user the ability to set an order of priority for some of the fields. So, if the fields are called A, B, C, D, and E, the user needs to be able to tell the form that C, say, is the most important field, followed by E, then D, then B, then A (for example).

I think the most elegant way to do this would be to allow the user to drag the fields about in the form, while they are typing into the fields. Is this possible with the Drupal form API? How can I do it?


texts:
After I tried to update the database I got the following error:

  Failed: Drupal\Component\Plugin\Exception\PluginNotFoundException:
  [error] The "pdf_thumbnail" plugin does not exist. in
  Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52
  of
  /home/www/sites/stdev/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

I tried to find the solution and found one of a similar issue:

drush updb fails with "the 'media_delete_action' plugin does not exist" after 8.4.6 > 8.5.1 update

Alas, I can't apply that solution because I don't know which module uses the pdf_thumbnail plugin. How can I find it out which module uses the plugin and solve the problem with the update?


texts:
I created a view (using Views) which shows node locations in a map using Location and Gmap modules.

How can I make map black and white?


texts: How to use EntityFieldQuery etc. to return a particular field efficiently?

texts:
A taxonomy has a lot of big fields attached, but one of these fields is a short text field called external_identifier.

In code, I need to obtain an array mapping external_identifiers to tids for a given list of external identifiers.

So in raw SQL this is very efficient:

SELECT entity_id, field_external_identifier_value
  FROM field_data_field_external_identifier
 WHERE field_external_identifier_value IN ('a123','b567',...);

I understand I should be using EntityFieldQuery, but this only gives me an array of tids, keyed by ...tid. Then if I loop those and call entity_load it will be doing lots of separate lookups and loading a whole load of stuff I don't need. This looks really inefficient.

I understand that EntityFieldQuery will only return Ids, so is there a better way?

Or do I just resort to SQL?


texts: CkEditor Toolbar not available/visible to Administrator when creating content

texts:
I am having a strange problem on my local dev site install. When either Basic HTML or Full HTML mode is selected in CkEditor, the toolbar and the whole area where text would be typed, are not available or visible. Yet when selecting Restricted HTML, the area for text and toolbar are visible and available.

This is the only user I have on my site so I am assuming it has full administrative privileges correct?

Where else do I need to change any settings for this user to have access and use Full or Basic HTML along with the toolbar?

The Text formats and editors section have Administrator under the Rolescolumn for Full HTML

Any ideas or suggestions of where I am going wrong?

Brand new Drupal user here, obviously.

Semi Reolved..
Found the issue for a temporary fix..
Status Report showed an error for a CodeTag module that was not loaded for some reason.
Even though it was installed and enabled with drush.
Even showed up in list from
drush pm-list
command so not sure what the deal is with it.
Uninstalled it in UI on-site instead of with drush and the editor issues are no more. For what I originally posted.


texts: How do I edit the CSS based on node, page, or placement on page?

texts:
I've been learning how to navigate around and edit my global.css file, but am confused as to how to edit specific elements. I've come across answers to this question that don't specifically describe how to do this

To clarify, say that I have 3 pages on my site titled Red, Blue, and Black. If I want to edit just the h1 headers on page Red, how do I go about doing that? Is there a way to do this without PHP or installing extra modules?

Currently, whenever I try to edit the h1 header on supposed Red page, every single h1 header on my site is updated and edited.

Sorry if this is a duplicate, I honestly couldn't find any answer to my question while I was searching


texts:
I'm trying to implement hook_menu() in my module. The problem is, it doesn't add the menu item for English while it does for Turkish. I'm guessing it has something to do with title arguments, but I can't be sure. Below is my code:

function suweb_agi_menu() {
  global $language;
  $lang = $language->language;
  $items = [];
  $items['agi'] = [
    'title' => ($lang == 'tr')?'AGİ (Aile Geçim İndirimi)':'AGİ (Family Status Declaration)',
    'page callback' => 'drupal_get_form',
    'page arguments' => ['suweb_agi_form'],
    'access arguments' => ['access content'],
    'menu_name' => 'menu-sol-menu'
  ];
  return $items;
}

What am I doing wrong?


texts: What exactly is affected by "Default download method" setting?

texts:
At /admin/config/media/file-system is option Default download method (public or private files) which sets "the preferred download method".

I am not sure what exactly is affected by this setting? Apparently I can create a type of content with two fields for files: one field for files stored as public files, another field for files stored as private files. So I can use both public and private files simultaneously.

Let me stress my question is not about the difference between public and private files – I understand it. I just wonder about meaning of the above mentioned setting.


texts: Drupal8 views broken handler with custom entity type

texts:
I'm building a Bet website a long test of Drupal 8.

Thanks to drupal console I managed to create a lot of custom entity types.

Now I want to expose my entity to views but I get this message;

One of the only customization I've done from my game entity type was to change the table name : from game to mespronos_game, by editing the annotation from :

base_table = "game"

to

base_table = "mespronos__game"

This is working, I'm able to create game entities but I can't figure how to tell views the table he should look in.

Here's all the annotation for my game entity :

/**
 * Defines the Game entity.
 *
 * @ingroup mespronos
 *
 * @ContentEntityType(
 *   id = "game",
 *   label = @Translation("Game entity"),
 *   handlers = {
 *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
 *     "list_builder" = "Drupal\mespronos\Entity\Controller\GameListController",
 *     "views_data" = "Drupal\mespronos\Entity\GameViewsData",
 *
 *     "form" = {
 *       "default" = "Drupal\mespronos\Entity\Form\GameForm",
 *       "add" = "Drupal\mespronos\Entity\Form\GameForm",
 *       "edit" = "Drupal\mespronos\Entity\Form\GameForm",
 *       "delete" = "Drupal\mespronos\Entity\Form\GameDeleteForm",
 *     },
 *     "access" = "Drupal\mespronos\GameAccessControlHandler",
 *   },
 *   base_table = "mespronos__game",
 *   admin_permission = "administer Game entity",
 *   entity_keys = {
 *     "id" = "id",
 *     "uuid" = "uuid"
 *   },
 *   links = {
 *     "canonical" = "/admin/game/{game}",
 *     "edit-form" = "/admin/game/{game}/edit",
 *     "delete-form" = "/admin/game/{game}/delete"
 *   },
 *   field_ui_base_route = "game.settings"
 * )
 */

All my sources files are available on github : https://github.com/kgaut/mespronos

Thanks in advance.


texts:
I made a custom EntityQuery Block Plugin with a table output and managed to make the headers sortable using this $header definition:
        $header = [
            'title'      => [
                'data'      => t('title'),
                'field'     => 'title',
                'specifier' => 'title',
            ],
            'mydate'       => [
                'data'      => t('mydate'),
                'field'     => 'field_date_paragraph',
                'specifier' => 'field_date_paragraph',
            ]
        ];

Then I added a tablesort when retrieving the nodes:
    $nids = \Drupal::entityQuery('node')
        ->condition('status', 1)
        ->condition('type', 'project')
        ->tableSort($header)
        ->condition('field_exhibition.target_id', \Drupal::routeMatch()->getRawParameter('node'))
        ->execute();

The output looks fine and column headers are clickable - but nothing happens. Actually the GET parameters get correctly added to the URL and look something like:
?sort=asc&order=mydate

I think the problem is date field (field_date_paragraph) which is a paragraph field. Inside the paragraph I have a date field and it is this one which should get ordered. What do I have to add to $header definition to make reference to the date field inside field_date_paragraph?


texts: Limiting table rows viewed in CCK Table Field

texts:
I'm using Drupal 6. The node has been created with 10 rows.

I'm looking for ways to make the table content viewed on the front page with 5 rows, where it has "more" link to the full node.

It can be PHP code to be placed in the block, or any other ways. Any suggestion are welcome including modification on other modules.


texts: How can I perform an operation programatically when the value of a user field is changed?

texts:
On my user accounts, I have a text field, field_nickname.  Users can change this at any time.

When they do change it, however, when the user account is saved I want to copy the old value for field_nickname to a text field accepting unlimited values, field_nicknamehistory.

In Drupal 7, you could do this in Rules by making a rule "on user update" and accessing the old value through the tokens in the rule interface.  However, Rules isn't here yet for Drupal 8, so I'm trying to do this in code.

I tried to do this with hook_user_presave() but I don't know how to get the old value to compare it against the new value:

function mymodule_user_presave(Drupal\user\UserInterface $entity) {
  // How do I get $previousnickname?
  if ($entity->get("field_nickname") !== $previousnickname) {
    $entity->get('field_nicknamehistory')->appendItem($entity->get($previousnickname));
  }

I looked through the API and found onChange(), but I don't see how that would help me here.


texts: Migrate user passwords salted and hashed with md5

texts:
I have quite complex migration for some legacy non drupal site to migrate it into D7. The whole migration works fine but it turned out that source user passwords are salted and hashed with MD5. Because they are salted I can't do this in my migration class:

 $this->destination = new MigrateDestinationUser(array('md5_passwords' => TRUE));

I've found this solution which boils down to reimplementation of original hashing algorithm in new drupal site. I don't like this solution because it decreases security of the site and throws away whole D7 password hashing code.

Something tells me that the only way to migrate those old passwords and keep the drupal hashing algorithm is to copy-paste whole includes/password.inc and add "temporary" hashing algorithm from the old non-drupal site in similar way drupal core handles old MD5 passwords without salt.

Or maybe there is a better way to migrate those old passwords?


texts: Google AdWords claiming my site has an “existing compromise that prevents referrer URLs from successfully visiting the site through an ad”

texts:
Here's the email I just received from Google about why they won't turn on my AdWords account after my hosting provider had DNS issues which caused AdWords to believe the site was compromised by malware:

  The destination URL: http://www.ledsignage.com/counters-clocks-timers is returning a 404 error when our systems scan it via an ad click. This indicates that the site's server likely has an existing compromise that prevents referer URLs from successfully visiting the site through an ad. Please note that the URL may still work when directly visited in a browser since the referer URL is a completely different setting.

Is this actually possible? There's no other way to reach the page other than using the URL to it. I thought a referrer URL is in the header of the HTTP request, and simply stored the URL of the page you were just at.

Are they saying that there's some kind of malware on my site that's filtering requests based on the value of the referrer URL? Have any of your ever had this problem?

I had to comment out the following lines to get the .htaccess file to work with goaddy:

# PHP 5, Apache 1 and 2.
#php_flag magic_quotes_gpc                 off
#php_flag magic_quotes_sybase              off
#php_flag register_globals                 off
#php_flag session.auto_start               off
#php_value mbstring.http_input             pass
#php_value mbstring.http_output            pass
#php_flag mbstring.encoding_translation    off

I am having another issue but only with some pages. I'll probably make this another question, but it might be related. Some pages are causing redirect loops. Here are some examples:

http://www.ledsignage.com/faq, /software, /outdoor (stackexchange won't let me put in more than one link)

I've tried to remove the url alias from these pages and still have the infinite redirect issue. I did recently move this site from another hosting provider to godaddy. This is drupal 7.2. I'm not sure what other info you need so just let me know and I'll post a comment with the information (assuming I can commment). Thanks in advance for any help!


texts: How to allow content editors to choose from Image Styles during content creation?

texts:
Say I have an image field and several different Image Styles (image cache presets) set up. I would like to allow my content editors to be able to choose from the list of available presets during content creation.

Any Ideas on this is achieved? Off the top of my head it seems like a custom module might be in order...


texts: How to make the module Node Embed work for any content type?

texts:
I have installed Node Embed and created a content type called Text Page, and it works very well to embed nodes of all kind.

But I also have a content type called Article and there, no kind of node will be embedded.....I only get the [[(nid:number)]]. Both content types have the text field called: body; which is the long text and summary.


texts: Creating a view that shows all events and the users that have signed up for each event

texts:
I am using the Signup module, and I am looking to create a view that shows all events and the avatars (default Drupal user picture field) of the users that have signed up for each event.

Here is a mockup of what I am trying to achieve. I have everything but the avatars so far.

View Mockup

See export of the View I have so far


texts: EntityQuery how to get all delta and good for field_dates

texts:
I've got these dates linked to a node.

I just want to make a request to render all node when time() is between field_date_value AND field_date_end_value OR time() is < to field_date_value

(ps: time() = 06-26)

I coded this for that :

And my render is :

So I think this code find some good value in database but is returning only 1 case with the first date which is wrong instead of the good which is the second and the third.

My wish :

Thanks in advance.


texts: How to create a path alias with a query string in the target?

texts:
I want to link /myownstuff to /stuff?owner=myself

It should at least be possible to do with some module, and with httpd-level configuration, but I don't know how to achieve either of them.


texts:
I have a module that implements a hook_boot(), and it checks if user is going to access home page and if user does not have a specific cookie. If both verifications are true, it redirects user to a /welcome page and set cookie. So the second time a user tries to access home page, it will see that user has the cookie and will not redirect.

Recently, I installed Varnish on my site, and everytime I try to access home page, I get to /welcome page. It never skips.

I'm not sure but it looks like the first time I access home page, when I still don't have cookie, it caches the home page, shows /welcome page and set cookie. Then, second time I try to access home, it gets the cached page (which thinks I don't have cookie) and redirect again to /welcome page, even though I have cookie.

I tried not caching home page but it didn't work.

Any thoughts?


texts:
I am working on my client's project and they are using Drupal 8.
I discovered that when one uses http://example.com/index.php to access the webpage, the url generated by the menu items , the index.php part is included, i.e. http://example.com/index.php/aboutus instead of http://example.com/aboutus. And it leads to a wrong page.
And I checked with the template file which generates the menu, the url of the menu is generated by {{item.url}}, which item is one single item of items for the available variables in the menu templates.

Available variables:
-menu_name: The machine name of the menu.
-items: A nested list of menu items. Each menu item contains:
-attributes: HTML attributes for the menu item.
-below: The menu item child items.
-title: The menu link title.
-url: The menu link url, instance of \Drupal\Core\Url
-localized_options: Menu link localized options.

Therefore I am asking if there are ways to get rid of the "index.php" in this case and in order to avoid drupal generating wrong url? Thank you very much


texts: Modules appear to install, but don't show up

texts: I'm trying to install new modules via the url installer and uploader. I supply my sftp credentials. It says everything is fine. Then it says my module was installed successfully. However the new module doesn't show in the listing and it isn't in the sites/all/modules folder. What could I be missing?


texts: How to show results in entityreference autocomplete only after the user enters 5 characters

texts: I want to know if it's possible to show result of an entityreference autocomplete only when the user enters 5 or 6 characters.


texts: Drupal views UI, is it possible for the user to limit the number of row of the result?

texts:
I created a view that display some content. I would like to allow the user to change the number of result (row).

By example, the view display ten row. The user can set (in text field?) 5, and the view display only the first five result.

Is it possible via view ui ? I didn't find...
If not, I guess that I must create a custom module with view alter..

Thanks for help =)


texts: after migrating to D7 all images are missing

texts:
After migrating to D 7.20 all my images are gone, actually they exist on the server but are not being displayed at all. I have a multi-site installation and I've successfully migrated all the content and re-enabled the modules.
I have a page where all the users pictures should be displayed and none of them are being displayed. So, I've created a new account and uploaded a picture for it and this new picture appears. What should I be looking at? How can I migrate all the pictures to the new installation properly ?

Thanks.


texts: I have a register form with some fields like name shop, btw number, subscription, ... . I want to create an invoice of the data filled in (do some operations with other variables). I know that there's a drupal module Invoice but how can I automatically create one when clicked on register button and send them to the users email? (I'm a drupal beginner)


texts: Migration with unique index across multiple fields

texts:
It is the first time I'm using the migrate module and I want to import some nodes from a JSON file and to specify a unique key that has two distinct fields. I.e so that the row is not imported or it's updated when the combination of those two fields values already exists in the database

id: import_json_entities
label: "JSON Entities"
migration_group: import_json_group

destination:
  plugin: entity:node

migration_dependencies: { }

dependencies:
  enforced:
    module:
      - my_module

source:
  plugin: url
  data_fetcher_plugin: file
  data_parser_plugin: json

  urls:
    - 'public://entitities.json'

  item_selector: Schema

  ids:
    - name
    - version

  fields:
    -
      name: name
      label: 'Name'
      selector: Name
    -
      name: version
      label: 'Version'
      selector: Version

process:
  type:
    plugin: default_value
    default_value: service

  title: name
  uid:
    plugin: default_value
    default_value: 1

  field_version: version

It works if I only leave "name" in the list of ids, but it does not import anything if I specify both "name" and "version" as id.

What I want is something similar with what you achieve in MySQL with:

ALTER TABLE `entities` ADD UNIQUE `unique_index`(`name`, `version`);


texts:
I've been trying out this codes from this blog, and tried a couple of snippets and my trials on the codes but have no luck at the moment.

This blog has (http://www.grasmash.com/article/connecting-facebook-drupal-easy-way) the following functions:

/**
 * Implements hook_fboauth_user_properties_alter().
 */
function grasmash_fboauth_user_properties_alter(&$properties) {
  // Allow the location property to be mapped to Addressfield typed fields.
  $properties['location']['field_types'][] = 'addressfield';
}

which this hook is available in D6

/**
 * Implements hook_fboauth_field_convert_info().
 */

function grasmash_fboauth_field_convert_info_alter(&$convert_info) {
  $convert_info += array( 'addressfield' => array(
    'label' => t('Address Field'),
    'callback' => 'grasmash_fboauth_field_convert_location',
    ),
  );
}

This is never fired up, and seems i cannot find the hook in D6

/**
 * Facebook data conversion function.
 * Converts an incoming Facebook location (which is an object) into an array compatible with the addressfield module.
*/
function grasmash_fboauth_field_convert_location($facebook_property_name, $fbuser, $field, $instance) {
  $value = NULL;
  if ($field['type'] == 'addressfield' && isset($fbuser->location) && module_exists('geocoder')) {
    $geodata = geocoder('google', $fbuser->location->name);
    foreach ($geodata->data['geocoder_address_components'] as $key => $components) {
      switch($components->types[0]) {
        // Set city.
        case 'locality':
          $value['locality'] = $components->short_name;
        break;
        // Set state.
        case 'administrative_area_level_1':
          $value['administrative_area'] = $components->short_name;
        break;
        // Set country.
        case 'country':
          $value['country'] = $components->short_name;
        break;
       }
     }
   }
   return $value;
}

This one is firedup when the second function is firedup, but the logic inside of this doesnt matter as long as $fbuser is available.

In totality my goal is to have access of the $fbuser after the user successfully connect to Facebook.


texts:
I have a node which needs to contain a list of product prices in the following format:

Node Title
Node Body

Product 1 URL - Product 1 Price
Product 2 URL - Product 2 Price
Product 3 URL - Product 3 Price
Product 4 URL - Product 4 Price

I'm not sure how that list of URL's and prices should be stored in Drupal so that it can be given a relationship with a specific node and displayed within the node.

Do i use taxonomy or make each url/price pair its own node?


texts: How to setup session sharing for language subdomains (URL language detection set to domain prefix)

texts:
I would like to use domain prefix for language selection, like en.example.com and de.example.com. I've set up language detection to Domain here admin/config/regional/language/configure/url.

In theory everything works fine, except that session data is not shared between subdomains. If I log into the main site example.com and then visit en.example.com I have to log in again. Is this behaviour by design? Can I setup drupal to share session data between subdomains? It's the same site after all - only subdomain is different.


texts: Can I Run custom callback in site maitenance mode

texts:
In drupal site maintenance mode all custom menu callback is not working. it redirect into site maintenance page.
But user/login is working.
I need to create menu like user/login. please help me.


texts: How to get programatically 'display_options' for a specific page in Views

texts:
I am a bit confused on how I should code this...
I have a view based on a custom content entity with 4 displays: default (hidden), Page (page_1), Export Entité (rest_export_1) and Export pour Maps (rest_export_2).

Devel shows this for this view:

I'd like to get the value of the path for 'rest_export_1' to use it in $name.
My code:

function association_exportCSV($view, $page)
{
  $view = \Drupal\views\Views::getView($view);
  $name = ???
  $page = $view->preview($page);
  file_unmanaged_save_data($page , 'private://' . $name . '.csv', FILE_EXISTS_REPLACE);

}

What should I do next? How to get $name from 'path'?


texts:
When i look at

  AccessResult::forbidden()

We can set a reason as parametter.

So i try this :

 public function access(Request $request, AccountInterface $account)
    {

        $userRole=$account->getRoles();

        if(in_array("administrator", $userRole) || in_array("agence", $userRole))
        {
            return AccessResult::allowed();
        }

        return AccessResult::forbidden('TESTTT');
    }

If a user try to access my page who call this custom check access, he got :

So it's in french but it's the default forbidden access message.
I try to custom this message, and i was thinking about the reason in parameter.

Any idea why i can't get TESTTT as message ?


texts:
In my custom module I'm using drupal_valid_path to check if a given alias exists before I create such.

$target_alias = 'some/path';
if(drupal_valid_path($target_alias, FALSE) === FALSE){
  // create 'some/path'
}

The function always returns FALSE and thus creates tons of identical aliases. What could be wrong?

I have tried various boolean expressions, such as: !drupal_valid_path or weak type test ==. To no avail.


texts: How to load library only on one twig template?

texts:
We have a custom theme, mytheme where we have the following library for the header-fix. I have also added {{ attach_library('mytheme/header-fix') }} to only one twig template block--myblock.html.twig that is for my custom block myblock.

The goal is to only add the library to myblock when myblock is rendered on the page.

The problem we are having is that the library is being added to all pages even ones where the block is not present (loaded on the page). How can we load a single library only on one block and not all the twig templates?

myblock configuration:

restricted to only Article content type (so do not load on basic content type)

block--myblock.html.twig

{{ attach_library('mytheme/header-fix') }}

Continually fashion turnkey sources without web-enabled alignments. Some more content.

mytheme.libraries.yml

...
header-fix:
  version: 1.x
  js:
    /path/to/header-fix.js: { preproces: false, attributes: { defer: true } }
...

mytheme.info.yml

...
libraries:
  - mytheme/header-fix
...


texts:
I am trying to display title and other fields in page.tpl.twig. {{ title }} doesn't display the title, but {{ page.content }} displays all the content.

How do I print the title in page.tpl.twig?


texts: Views: How to list nodes by 2 vocabularies with “%” on url path for contextual filters

texts:
I have a content type with 2 different Term references. I wanna use Views to list “Term one” with “%” on url path, and use “Term two” as section. See below for details.

Vocabulary term one:
Book type A
Book type B
Book type C

Vocabulary term two:
Book style A
Book style B
Book style C

List result: on Book type A
Book style A
    - node 101 title, author name
    - node 102 title, author name
    - node 103 title, author name

Book style B
    - node 111 title, author name
    - node 112 title, author name
    - node 113 title, author name

Book style C
    - node 121 title, author name
    - node 122 title, author name
    - node 123 title, author name

— — updated info @ Sep. 9th 2014 @ 1:16pm

I created a content View, which has “Content: Type Book A” and set the path as “/booka/%. It came out fine except I don’t know how to use the 2nd Term as section to list all those node under their style.


texts: Adding Zurb-Foundation (or bootstrap) elements & components to a Drupal sub theme. E.g. Zen5

texts:
I want to add Zurb-Foundation elements/components to my Zen Subtheme. I think those who have done this using Bootstrap may know the basic procedure as well?

My example use-case is to style the 'main-menu' using the Foundation 'nav-bar' :->

I have included foundation.css from Zurb-Foundation and I can hack around in Firebug and get the main-menu styled with the Foundation nav-bar style. Great.

But how to evolve this to actually be a usable workflow?

Issues:

How do I integrate Foundation into my Zen SASS workflow? What do I need to @import into the Zen subtheme?
What changes do I need to make to config.rb, if any?
Ditto from the .info file in my subtheme?

Assuming I can incorporate Foundation components, I then have to override in MYTHEMENAME__preprocess_page within my Zen Subthemes 'template.php'? Is this correct?

Any examples of the render-array in MYTHEMENAME__preprocess_page to say, in this example, override the menu-links to use the Foundation 'nav-bar' class/style?

Many, many, thanks

PW


texts: HTML tags removed during Views Rewriting

texts:
Hello I created a sitemap with the modules "Views and data export". The sitemap of my page works fine, but I would add images to my page.

The sitemap should look at first capture, I do a test with figure and they are well placed. When I "rewrite the results" the tag is ignored.
How to implement these label ? it's been weeks since I'm on it.

Thank you

If I replace the HTML tags with text data it works:

However when I add HTML it gets removed:

I found answers to How add markup and prefix / suffix for computed field. Can you tell me how to put that in place?


texts:
When use search_api, module automatic create more table:
search_api_db_article_title,search_api_db_article_body,...
But I accidentally lost these tables ==> search_api can't index. How to get back to the table?
I run cron, updatedb but nothing happen :(


texts: What is the alternative for user_check_password in drupal 8

texts: What is the alternative for user_check_password(), How I can verify a plane password with a user account?


texts: Dynamically adjust argument or filter to views entity reference filter based on value from select list in form

texts:
I have a entity reference field that references a taxonomy term from a vocabulary named "fund".  Now I'm needing to add a fiscal year field to the fund terms to allow us to have different budget lines for different fiscal years.  Some of these funds will have the same name, but be from different fiscal years, so I now need to add a fiscal year dropdown list before the autocomplete entity reference field mentioned above.

Say the dropdown has two values FY17 and FY18, I'd like the views entity reference filter view to receive the selected value for fiscal year, and apply that as a filter to the views entity reference filter.  How can I accomplish this?  Alternatively is there a better way to accomplish this?

For example:

I looked at Dynamically change views entity reference filter based on current form value but it doesn't seem like it quite fits what I'm trying to do.  I could be wrong.


texts: Javascript/jQuery fail after AJAX Referesh

texts:
I'm using Drupal 7 with Drupal Commerce and the Commerce Product Option module. Design goal is to have a visual product configurator for choosing custom furniture - an area on the Add To Cart Form where product images update as the user selects individual line item options.

So far I've implemented a semi-successful solution that uses jQuery to (A) modify the line item form to modify the product display area, and (B) add handlers to form elements. This javascript is attached to the form via a custom module, hook_form_alter() and $form['#attached']['js'] which references a javascript file with a defined Drupal.behavior.

(function ($) {
 Drupal.behaviors.prod_form = {
   attach: function (context, settings) {...

The problem I'm having is with the Product Display form, which provides the user a SELECT list (ID=edit-product-id) to choose a specific product from a family of related products (4 seat sofa, 3 seat sofa, loveseat, etc.). Upon initial display everything works, however if the user selects another product the javascript form modifications fail.  Looking at the console.log it seems as though the jQuery selectors are failing because they are being called before the form item exists. (no elements are found with selector ...).

I suspect the issue is related to when ajax is called vs. when the elements are being drawn, but stuck on how exactly to resolve. Any pointers or suggestions will be greatly appreciated.

Chris


texts: Is there an existing module to bulk delete user content but not user?

texts: I have a user role that is meant for pseudo-anonymous usage and each account of this role-type will be shared in a pool of users. Whenever a user of this role logs out, I'd like to delete all their associated content to prepare for the next possible user using this account. This sounds like a job for hook_logout, but it also seems like there should be a module for this already, right? I searched but maybe I'm not using the right keywords.


texts: Unable to save data from custom drupal form

texts:
I'm unable to save the details into database after the form is submitted in Drupal 7.

Below is the code for my custom form to save the details to DB,

function form_module_menu() {
  $items = array();
  $items['form_module/form'] = array(
    'title' => t('Registration form'),
    'page callback' => 'form_module_form',
    'access arguments' => array('access content'),
    'description' => t('Registration Form'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function form_module_form() {
  // This form calls the form builder function via the
  // drupal_get_form() function which takes the name of this form builder
  // function as an argument. It returns the results to display the form.
  return drupal_get_form('form_module_my_form');
}

function form_module_my_form($form_state) {
  $form = array();
    // This is the first form element. It's a textfield with a label, "fName"
  $form['fName'] = array(
        '#type'      => 'textfield',
        '#title'     => t('First Name'),
        '#required'  => TRUE,
        '#size'      => 60,
        '#maxlength' => 64,
  );
  // This is the lastname form element. It's a textfield with a label, "lName"
  $form['lName'] = array(
        '#type'     => 'textfield',
        '#title'    => t('Last Name'),
  );
  // This is the email address form element. It's a textfield with a label, "email"
  $form['email'] = array(
        '#type'     => 'textfield',
        '#title'    => t('Email'),
        '#required' => TRUE, //must fill this if set to TRUE
        '#rules'    => array(
                            ),
        '#filters'  => array('trim', 'uppercase')
  );
  // This is the password and confirm password form element. It's a textfield with a label, "cpwd"
  $form['cpwd'] = array(
        '#type'     => 'password_confirm',
  );
  $form['submit_button'] = array(
        '#type'     => 'submit',
        '#value'    => t('Submit'),
  );
  $form['clear'] = array(
        '#type'     => 'submit',
        '#value'    => 'Reset form',
        '#validate' => array('my_module_my_form_clear'),
  );
  //print l('return to main home page', '<front>');
  return $form;
}

//Rebuild the form
function my_module_my_form_clear($form, &$form_state) {
    $form_state['rebuild'] = TRUE;
}

function form_module_email_validate($element, &$form_state, $form) {
  //email validation not working how to validate email
  $mail = $form_state['values']['email'];
  if (strpos($mail,'@') !== true) {
    form_error($element, t('Please enter a valid email address.'));
  }
  else{
    form_error($element, t('Please enter a valid email address.'));
  }
}

function form_module_my_form_submit($form, &$form_state) {
    drupal_set_message($form_state['values']['fName'].$form_state['values']['lName'].$form_state['values']['email']);
    $sql = "INSERT INTO {customers} (first_name,last_name,email_addr,password) VALUES('%s', '%s', '%s' , '%s')";
    db_query($sql,
        array('%s' => $form_state['values']['fName']),
        array('%s' => $form_state['values']['lName']),
        array('%s' => $form_state['values']['email']),
        array('%s' => $form_state['values']['cpwd'])
    );
    drupal_set_message(t('Thanks for registering with us. You will receive an email shortly to activate your account.'));
    //after successfully saved how to send mail to user with his login details
}

The submit handler is called and the values are displayed.but in database all rows are filled with '%s'. I new to working in Drupal. How to store passwords and how to save the data and send an email to the user registering..


texts: How can I delete all field collection revisions?

texts:
I want to delete all field collection revisions of a specific field.
I found deleteRevision for this job, but I don't know how to use it. (I couldn't find any example of it.)

Anybody know how can I delete all field collection revisions of a specific field?


texts: How do I set a link for the content type field?

texts:
I have created the view and display to page, but now I want to click on the content title and open this image on new view or page.

How can I set the path in the view and change the path from node/15 to a custom URL with title, for example artist-works/Robert-Boynes/Infinite-Red?


texts: Rules loop through list and create nodes with custom title

texts:
I'm using rules to create new nodes on 'After saving content of type' event.

To do so I loop through a list of type entity reference

Loop
Parameter: List: [node:field-childs]
List item: Current list item (list_item)

Inside the loop I  Create a new entity,

Create a new entity
Parameter: Entity type: Node, Content type: Attendance, Title:
[node:field_childs], Author: [node:author]
Provides variables: CreateAttendancePage (basic_attendance_created)

Then I save the entity

Save entity
Parameter: Entity: [node], Force saving immediately: true

This will title all the new nodes with all the field_childs values available instead of taking them one by one.

I end up with titles like:

First node: Timmy, Jack, Jimmy, Sam, Hannah

Second node: Timmy, Jack, Jimmy, Sam, Hannah
etc.

Instead of:

First node: Timmy

Second node: Jack


texts: how to display avatar in forum-list (advanced-forum)

texts: Any suggestions? I'm interested in how to display the avatar last post in forum list. I tried to display the avatar as $picture but is not working.


texts: Why can't I get the jQuery jGrowl or Sliding Message library working?

texts:
So I have tried two different methods to get a dismissable message to slide onto the screen, and neither seems to do anything:

jQuery Sliding Messages Method

<script type="text/javascript" src="/sites/all/libraries/jquery-sliding-message/jquery.slidingmessage.js"></script>

<script type="text/javascript">
(function ($) {
  'use strict';
  Drupal.behaviors.flyoutMessage = {
    attach: function(context, settings) {
      var options = {id: 'message_from_top',
                     position: 'right',
                     size: 300,
                     backgroundColor: 'red',
                     delay: 1500,
                     speed: 500,
                     fontSize: '30px'
                    };
      $.showMessage("This is with options!", options);
    },
  };
})(jQuery);
</script>

Note: I had to allow for the use of '$' in jquery-sliding-message.js file by adding it as a parameter to the function() to eliminate an error, but I see no message appear on the screen. There are no error messages either.

jGrowl Method

<script type="text/javascript" src="/sites/all/libraries/jGrowl/jquery.jgrowl.js"></script>
<script type="text/javascript">
(function ($) {
  Drupal.behaviors.showAnnouncement = {
    attach: function (context, settings) {
      $.jGrowl("Hello world!", { sticky: true });
    },
  };
})(jQuery);
</script>

I checked the source, and there is no "Hello world!" message anywhere to be found. Again, no errors in the console either.


texts: Active a menu  when the menu entry is a view page

texts:
I have a section (call news) that have an "home page". This home page is created via "views" and via "views" I have insert a link item into "main menu" menu based on path (/news). When I go to /news the relative entry in "main menu" is active (the <li> item has "active-trail" class). All works.

How can I active the same menu when I'm into a node of type news ? I have read that I need to use menu_tree_set_path() into a hook_preprocess_page(). So I have tried to add this line into THEME_preprocess_page(&$vars) :

menu_tree_set_path('main-menu','/news');

but it does not work. I have tried with:

menu_tree_set_path('main-menu','news');

Same result. Not working.

In all my search, all tutorials tells to set for the second parameter of menu_tree_set_path a node/NID or a taxonomy/term/NID, but I have not this node/nid. I have a view page path.

So, How can I do it ?  Thanks.


texts:
I have another post here:
Retrieve Webform submission data from database
I got some guidance but some of it wasn't feasible for our application and the edited assistance was a bit general.  Based on the person's suggestions I am trying to use a hook_form_alter on a Webform module webform. Here's the files and code I have.
cc_processing_getsubmissiondata.info.yml
name: 'CC Processing Get SubmissionData'
description: 'Provides a custom webform handler for retrieving the previous forms submission data'
core_version_requirement: ^8.8
Core: 8.x
package: Custom
type: module

CCProcessingGetSubmissionData.module
<?php

/**
 * Implementation of hook_form_alter
 */
 use Drupal\Core\Form\FormStateInterface;

 function CCProcessingGetSubmissionData_webform_submission_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
    echo "form alter hook triggered";

    if($form['#webform_id'] == 'credit_card_billing_information') {
        echo "form alter form id found";
        $myValue = 'Jared';
        $form['elements']['credit_card_name']['#default_value'] = $myValue;
    }
 }

I am not new to programming but am new to Drupal programming.  I have some other code in the module that's not in the answer suggestion on my previous post like the echos I found on other posts in an attempt to try to get something to happen that lets me know the the hook is being called.  Both files are in modules/custom/cc_processing_getsubmissiondata.  The folder structure I got off of a YouTube video on building hooks but it was just a short 8 minute basic hook video.  From all the posts I've seen out there, everything I have looks correct but nothing happens.  Any assistance in helping me getting this hook to work would be awesome. :)


texts: How to create a product display view showing all users who purchased a product through a specific display

texts:
Im looking to create a view which will have an exposed filter of Product Display Titles in a select list and then display a table of users who purchased a product which originated from that display. The product will be used on multiple displays so this is important to get that filter. Im really struggling to achieve this and so far am getting it to display users for a product but not the display.

It seems the only indicator of the original product display is the display path. I thought I had cracked it but its just not working. If anyone can have a go or walk me through it that would be amazing.

Thanks all


texts:
I have set up continuous integration for a Drupal site. After every git push the site is built remotely from scratch in a Docker container. It runs a site install, sets the site's UUID to import the configs, creates some sample content and then runs Behat tests.

For simplicity I'd simply commit the UUID in a text file and then import it like so:

drush cset system.site uuid "$(< sites/default/uuid.txt)"

The underlying question I have is if it's OK – from a security point of perspective - to commit a site's UUID into a public Git repo? Does that create any vulnerabilities to my site?


texts: How to migrate Drupal nodes from one installation to another, preserving revision history?

texts:
Is there a good way to export a set of nodes from one Drupal installation, including node revision history, and then to merge these into another Drupal installation, including revision history?

I'm familiar with modules such as Node Export and Backup and Migrate...  But Node Export doesn't preserve revision history, and Backup and Migrate doesn't allow merging (only full table replacement).


texts: Random page rendering error: A stray renderRoot() invocation is causing bubbling of attached assets to break

texts:
I have a D8 site that's in development and I am getting this error thrown at random on pages which most of the time render quite happily. There doesn't seem to be any real pattern in it.

I can see that it looks like it's designed to prevent the renderer creating an infinite loop (the code is on line 133 of core/lib/Drupal/Core/Render/Renderer.php), but it isn't really clear what's actually causing it. The log error is pretty useless really.

Anyone seen this and found out the cause? Thanks


texts: Storing a URL from a basic page using a custom module

texts:
I created a basic page at http://example.com/[company]/[customer]?id=2. I want to store this URL in a global variable for string manipulations within a custom module.

I succeeded to retrieve the URL by using hook_form_alter() with respect to a webform but I don't know how to do the same thing for a basic page.

Which hook do I need to use?


texts:
I want to send an XML mail using Drupal's mailManager.

I have created a custom twig template in my module that will the the mail body.

Here's what my template looks like, my-module-xml-mail.html.twig:

<record>
  <name>{{ name }}</name>
  <phone>{{ phone }}</phone>
  <email>{{ email }}</email>
</record>

And my template definition:

function my_module_theme($existing, $type, $theme, $path) {
  return [
    'my_module_xml_mail' => [
      'variables' => [
        'name' => NULL,
        'phone' => NULL,
        'email' => NULL,
      ]
    ]
  ];
}

And where I send the mail:

$mail_message = [
  '#type' => 'theme',
  '#theme' => 'my_module_xml_mail',
  '#name' => 'Name',
  '#phone' => 'Phone',
  '#email' => 'E-mail',
];

$rendered = \Drupal::service('renderer')->render($mail_message);

\Drupal::service('plugin.manager.mail')->mail('my_module', 'xml_mail', 'test@example.com', 'en', [
  'message' => $rendered,
]);

The problem is that when the mail is sent all the XML tags are stripped and only the values from the tags are sent.

How can I send the XML as plain text?

I thought about creating a my-module-xml-mail.xml.twig if that's possible, but when "kinting" the result from the renderer service it looks like renderer is not stripping any tags.

Do I need to send any headers to the mail, in order to send the XML as plain text?


texts:
In Drupal 7, I've created a content type, with a textfield. In the field settings, I'm invited to add some "Help text", and the description for this specifically says "This field supports tokens".

However, I'm finding that the tokens are never replaced with actual values. The token just displays literally under the form field.

I've also been unsuccessful when testing with "simpler" tokens than "current-date". What am I missing?


texts: How to force Views (or whole Drupal) to lowercase page paths?

texts:
Is it possible to force Views to always lowercase URL paths? Here is a detailed example. I'm using contextual filters to filter by node field (field's name is country). Here are the node examples:

Node title: Madrid | country: spain
Node title: Rome | country: italy

Country name values are intentionally lowercased. Now I create a country contextual filter with this path: results/%. These are the results:

Path: results/spain
Result: Madrid

Path: results/Spain
Result: Madrid

Path: Results/Spain
Result: Madrid

I want the results to be available only on these paths:

results/spain

results/italy

Is there a way to force Views to convert all of the paths to lowercase letters? If it's not possible in Views, is there a way to make Drupal convert all of the URL requests to lowercase paths?


texts: Publish tweets in drupal 7 site in real time

texts: I need to publish tweets from twitter in my Drupal 7 site. I use twitter module but I need to publish this tweet in real time that's not the case with this module. Any one have an idea to fix this issue ??


texts: Add counter to view with rendered entity output

texts:
On my site I've a search based on Views, with an exposed filter. The style output is "rendered entity", and I've to add the "result counter" beside the title.

Is there a way to do this or I've to use "fields" output?

I should have something like:

  Title1
  Title2


texts:
I have a field in my orders which should be updated when an order is saved. I created a rule with the event "commerce order save", do the calculation for the field and at least save the order. But that logically gives me an endless loop.

How can I save the order without firing the event again?


texts: Using Drupal 7 hashing method in Drupal 6

texts:
I want to use Drupal 7 hashing method in Drupal 6 for generating hash(not for password).
I will be using a key(say username) generate hash and store it in DB, later on when user provides username i will be generating hash for input and compare with the one that's stored in database.

include 'd7_modified_password.inc';
$key = "random_string";
print user_hash_password($key);

This generates a random string every time even though $key is unchanged. How can I use this so that I can use this method to compare two keys.


texts:
I have a view that renders its contents as three fields, and based on the layout markup I received from our Front-end developer, two of these fields need to be wrapped in a container div so they can be floated as a column, with the first field and its encapsulating div serving as one column in itself.

However, I can't think of any way to theme these fields without creating a tpl.php, unless there's a prefix/suffix setting inside the Views setting i'm not seeing, and if not, what are my options for theming the field output?

The output generated is printed below.

Health

Donec consequat sem urna, quis posuere felis
      tincidunt sit amet ongue vestibulum


texts: Is it valid to use entries in #default_value if they are not in the #options?

texts:
I have a form. On this form I have a select element, like this:

  array(
    '#type' => 'select',
    '#title' => t('Animals'),
    '#multiple' => TRUE,
    '#options' => array(
      'rat' => t('Rat'),
      'cat' => t('Cat'),
      'dog' => t('Dog'),
    ),
  );

I also have a function called get_suggested_animals($user_id). Let's assume that this code works:

global $user;
print_r(get_suggested_animals($user->uid));

// Array
// (
//    [0] => lizard
//    [1] => cat
// )

Would it be OK to just write:

array(
    '#type' => 'select',
    '#title' => t('Animals'),
    '#multiple' => TRUE,
    '#options' => array(
      'rat' => t('Rat'),
      'cat' => t('Cat'),
      'dog' => t('Dog'),
    ),
    '#default_value' => get_suggested_animals($user->uid),
  );

without testing if default options are on the list of available ones? I know it works (in this example - only 'cat' is selected by default), it does not generate any warnings or anything, but I still feel uncertain if it's legit, or if there are hidden traps I simply don't know yet.


texts:
My Drupal 6 sites are hosted on a Linux server with Apache 2.2, PHP 5.5, MySQL 5.6 installed. I use Drush 8 which I installed via composer.
I set a cron job via cPanel which runs every day this script:

#!/bin/bash
# Script to execute all the cron jobs with drush
echo '**************** French site *******************'
cd /home/myuser/public_html/fr/sites/fr.mysite.com
/home/myuser/.composer/vendor/bin/drush -v core-cron
echo '**************** English site ******************'
cd /home/myuser/public_html/en/sites/en.mysite.com
/home/myuser/.composer/vendor/bin/drush -v core-cron
echo '**************** Spanish site ******************'
cd /home/myuser/public_html/es/sites/es.mysite.com
/home/myuser/.composer/vendor/bin/drush -v core-cron
echo '**************** Completed **********************'

But it fails and ends with:

**************** French site *******************
X-Powered-By: PHP/5.5.33
Content-type: text/html

Warning:  proc_open(): Descriptor item must be either an array or a File-Handle in /home/myuser/.composer/vendor/drush/drush/includes/startup.inc on line 434

Warning:  proc_get_status() expects parameter 1 to be resource, boolean given in /home/myuser/.composer/vendor/drush/drush/includes/startup.inc on line 435

Warning:  proc_close() expects parameter 1 to be resource, boolean given in /home/myuser/.composer/vendor/drush/drush/includes/startup.inc on line 436

**************** English site ******************
X-Powered-By: PHP/5.5.33
Content-type: text/html

Warning:  proc_open(): Descriptor item must be either an array or a File-Handle in /home/myuser/.composer/vendor/drush/drush/includes/startup.inc on line 434

Warning:  proc_get_status() expects parameter 1 to be resource, boolean given in /home/myuser/.composer/vendor/drush/drush/includes/startup.inc on line 435

Warning:  proc_close() expects parameter 1 to be resource, boolean given in /home/myuser/.composer/vendor/drush/drush/includes/startup.inc on line 436

**************** Spanish site ******************
X-Powered-By: PHP/5.5.33
Content-type: text/html

Warning:  proc_open(): Descriptor item must be either an array or a File-Handle in /home/myuser/.composer/vendor/drush/drush/includes/startup.inc on line 434

Warning:  proc_get_status() expects parameter 1 to be resource, boolean given in /home/myuser/.composer/vendor/drush/drush/includes/startup.inc on line 435

Warning:  proc_close() expects parameter 1 to be resource, boolean given in /home/myuser/.composer/vendor/drush/drush/includes/startup.inc on line 436

**************** Completed **********************

The strange thing is that when I manually run drush -v core-cron on any site, the cron run ends successfully. I really don't know where the problem comes from.


texts:
Possible Duplicate:
  How to add newsletter functionality in drupal 7 (just stable modules if possible)

I need to know a good email newsletter system for Drupal that can trigger email send in batch. I know in WP how to do that, but have to previous experience with Drupal. I Have about 1000 email, and the provider allow only 200 mail / hour, so i need and option to send let's say 150 mail / hours and let the system go under the radar. Please, don't tell me to use mail-chimp, i know and it's not in Drupal but outside. i like a solution build in !

thanks in advance


texts: Variations price adjust based on previous variation

texts:
Using Drupal Commerce, is there a way to adjust the variation price base on the first or second variation selected?

For example I have 3 variations: size, material, color. If I choose Small (that costs $5) and material that costs $10 ($15 total), then when I choose Large at $12, the material should cost $20.

I guess I should use rules. Has anyone done this?


texts:
I have a Drupal 7 install that acts as a user network site. Users have 'member' permissions but are not administrators.

Some user fields are hidden via the field permissions module, but the rest should be viewable and editable by the user.

After updating the OG module, as well as the Webforms module, all custom fields added to the user node disappeared, both for registered members and new applicants (http://member.clevergirlscollective.com/drupal/?q=user/register , there should be several additional fields here).

I've adjusted permissions both at the field level and at the user node level, but for some reason this still happens.

Any ideas you have would be great!


texts: How I can give a particular style to maps in drupal site based on gmap module

texts:
I am currently developing a website which makes heavy use of gmap and location module.
I want to style maps in a particular style by appending style to google.maps.MapOptions.styles array, But maps in website still come out plain defaults.
I am not sure how I have to proceed, as firebug reports that style changes are done properly in styles array

(function() {
var style = [
{
    featureType: "landscape",
    elementType: "all",
    stylers: [
    { hue: "#ffa200" },
    { lightness: -20 }
    ]
},{
    featureType: "water",
    elementType: "all",
    stylers: [
    { hue: "#ff9100" },
    { lightness: 52 }
    ]
},{
    featureType: "administrative",
    elementType: "labels",
    stylers: [
    { hue: "#1100ff" },
    { saturation: -100 },
    { lightness: -18 }
    ]
},{
    featureType: "poi",
    elementType: "all",
    stylers: [
    { lightness: -18 },
    { visibility: "off" }
    ]
},{
    featureType: "landscape",
    elementType: "all",
    stylers: [
    { visibility: "off" }
    ]
},{
    featureType: "water",
    elementType: "labels",
    stylers: [
    { lightness: -18 },
    { visibility: "off" }
    ]
},{
    featureType: "road",
    elementType: "labels",
    stylers: [
    { visibility: "off" }
    ]
},{
    featureType: "administrative",
    elementType: "geometry",
    stylers: [
    { visibility: "simplified" }
    ]
},{
    featureType: "road.highway",
    elementType: "geometry",
    stylers: [
    { saturation: -100 }
    ]
},{
    featureType: "road.arterial",
    elementType: "geometry",
    stylers: [
    { saturation: -100 }
    ]
},{
    featureType: "road.local",
    elementType: "geometry",
    stylers: [
    { lightness: -27 }
    ]
},{
    featureType: "transit",
    elementType: "all",
    stylers: [
    { visibility: "off" }
    ]
}
];

Drupal.behaviors.sepiaStyle = function(context) {
Drupal.gmap.addHandler('gmap', function(elem) {
    var obj = this;
    obj.bind("bootstrap_options", function() {
    var new_style = $.extend(obj.vars.styles, style)
    jQuery(elem).change(function() {
        obj.vars.styles= new_style;
    });

    });

});
};
}());

Any help is greatly appreciated. Thanks in advance


texts: How can alter the select options provided by Simple hierarchical select?

texts: Simple hierarchical select is used to display Taxonomy as a select field in my existing content type. So I'm trying to alter the value of it. Even tried using hook_form_alter but didn't work. So is there any way or hook using which I can alter the value of the select list?


texts: Change Login Form:Username to Select Text

texts:
Is it possible to change the login form? Specifically the Textbox for username to select text?

Let's say I have 4 users named: User1,User2,User3,User4 and when select text is clicked. All users will be listed as a choice?

PS: I'm very new to drupal detailed help will be appreciated.


texts:
I know how to override the preview of a node being edited, but for some reason in the "trimmed" portion it displays a node's title and in the "full" version only the body. I'd like to be able to display the node's title in the "full" version also.

The theme method I'm overriding is theme_node_preview($variables).

I'm actually removing the "trimmed" portion completely, since it's not relevant to my content types. The method looks something like:

function theme_node_preview($variables) {
  $node = $variables['node'];

  $output = '
';

  $preview_trimmed_version = FALSE;

  $elements = node_view($node, 'full');
  $full = drupal_render($elements);

  $output .= $full;
  $output .= "
\n";

  return $output;
}


texts: Order confirmation email with custom order fields

texts:
I have added some fields to the order type and they are completed on checkout flow. I would like to include those fields in the confirmation email but I haven't found a way to get it on the twig template. I have followed this page to override twig email template.
For example, I have a field named as field_pedido_obs where the user could add some custom comments about the order. I have tried this on twig template:
{{ order_entity.field_pedido_obs}}
{{ order_entity.field_pedido_obs['#items'].0.value }}
{{ order_entity.field_pedido_obs['#items'].0.value }}
{{ order_entity.field_pedido_obs.value }}
{{ order_entity.field_pedido_obs[0].value }}
{{ order_entity.field_pedido_obs[0]|raw }}

But none of them works. How could I add it?


texts: How to display a view on user's profile page?

texts:
I would like to select fields associated with users and display the outputs on users' profile page. In other words, when someone navigates on a user's profile page, the outputs of the selected fields get displayed.

I tried to do that with a user views and I tried setting up different types of contextual filters (such as 'user ID', Provide Default Value, User ID from URL). But nothing seems to be work, the view does not display. When I remove the contextual filter, the view does display on the page so the problem seems to originate from the filter I selected or how I set it up.

The problem is probably really simple but I'm missing something here. Any hint?

Thanks a lot!


texts: Filter for previous time periods in views

texts:
I'm trying to set up Grouped filters for Content revision: Changed in a view. I want the filter to work for Today, Yesterday, Last week, Last month, and Last year. The grouped filters makes that simple enough, and it looks like this:

But all the filters are not filtering correctly.
For the Today filter, this will work.

But When I try to use an Is between operator for any previous dates, I get an error like this

How do I filter for previous time periods in views?

The Today filter works with Is greater than or equal to today midnight. It's the Is between parameters that the view won't accept.
The existing Today filter query adds
 AND ((node_field_revision.changed >= 1597759242-68400))

to the query, which converts to
GMT: Tuesday, August 18, 2020 2:00:42 PM - 19 hours.

Setting the Yesterday filter with Is less than or equal to yesterday adds
AND ((node_field_revision.changed <= 1597759395-154800))

to the query, which converts to
GMT: Tuesday, August 18, 2020 2:03:15 PM - 43 hours

which means the filter will show values from yesterday and today. That's not a yesterday filter.
So Is between is the way to go, but any values I try, including yours @Yuseferi, aren't accepted in the UI and so can't adjust to the query accordingly. If the view would accept an Is between operator, the query would add something like this:
AND ((node_field_revision.changed <= 1597759956-(1597723200-1597636800))

Where
Now: 1597759956
Today: 1597723200
Yesterday: 1597636800

That would be a yesterday query, which Drupal could then adjust for GMT.


texts:
In my theme, I have to output a toggle link like this:

Show LessShow More

Its not a real field or anything like that. Is there a way I can use link or path functions to generate this output instead? I am guessing since the title has two spans in it that I cannot, but lets assume there were no spans, I'd like to know if this is possible.

I tried:

{{ link('Show More', 'internal:#') }}

and

{{ link('Show More', '#') }}

The first one creates an empty href, which does not work. The second throws a fatal error.


texts: How to redirect links to a single domain in a multi-domain setup?

texts:
I am working on a project that uses Domain Access. The site has two domains one public(example.com) & one for members(example.com/members).

Some contents are common to both domains and some are domain specific.

Any link rendered on webpages has a relative path to that domain.

eg. A page that is displayed on both sites has the link (/some/link). Clicking it would take you to example.com/some/link if you click it on example.com AND to example.com/members/some/link if you click it on example.com/members

There are a few links that I want to appear on both domains but they should redirect to the members domain only.

eg. for the case described above the link should redirect to example.com/members/some/link even if it is clicked form the example.com domain.

Is there a way to do it?

UPDATE:

These are subdomains example.com & members.example.com. There is some server-side settings for url rewrite that makes them appear as example.com & example.com/members in URL.


texts: How to insert textfield in the table and submit button under the table

texts:
I want to create receive item from my purchase order node.
I have to create a table and displayed all data from node.
In last column of table I need to add a textfield and a submit button under the table.

I have read a lot of reference, but still getting error.
I hope somebody help to solve my problem.

by this code i want to create a form in table

function wespi_po_page(){
    $nid =arg(1);
    $form = array();
    $items = db_query('Select
                          Count(field_data_field_item.delta) As items
                        From
                          node Inner Join
                          field_data_field_item On node.nid = field_data_field_item.entity_id
                        Where
                          node.nid = :nid',array(':nid'=>$nid)
                    )->fetchField();
    drupal_set_message('Items counted : ' . $items);

$header = array(
    array('data' => 'Title', 'field' => 'title'),
    array('data' => 'On order', 'field' => 'on_order'),
    array('data' => 'On received', 'field' => 'on_received'),
    array('data' => 'Receive', 'field' => 'receive'),
    );

    $result = db_query ('
                        Select
                          field_data_field_item.field_item_nid As nid,
                          node.title As title,
                          field_data_field_on_order.field_on_order_value As on_order,
                          field_data_field_on_received.field_on_received_value As on_received
                        From
                          field_data_field_item Left Join
                          field_data_field_on_received On field_data_field_item.entity_id =
                            field_data_field_on_received.entity_id And field_data_field_item.delta =
                            field_data_field_on_received.delta Left Join
                          field_data_field_on_order On field_data_field_item.entity_id =
                            field_data_field_on_order.entity_id And field_data_field_item.delta =
                            field_data_field_on_order.delta Inner Join
                          node On field_data_field_item.field_item_nid = node.nid
                        Where
                          field_data_field_item.entity_id = :nid
                        Group By
                          field_data_field_item.field_item_nid', array(':nid' => $nid)
                );
    $rows = array();
    foreach ($result as $data) {
        $rows[] = array(
                    'data' => array(
                          l($data->title, 'node/'. $data->nid),
                          $data->on_order,
                          $data->on_received,
                          //$data->status
                    )
        );
    }
    $output = theme('table',
                            array(
                                'header' => $header,
                                'rows'=>$rows,
                                'sticky' => TRUE,
                            )
        );
    return $output;
}

function wespi_po_theme($existing, $type, $theme, $path) {
  return array(
    'wespi_po_table' => array(
      'render element' => 'element'
    ),
  );
}

function wespi_po_tab_page_form_submit(){
    drupal_set_message($items . ' Items received');
}


texts:
I would like to set up simple file storing and sharing (for educational purposes) for my users. I considered creating Profile2 profile and put data uploads files there. But it seems little clumsy.

Now i have idea to set up content types "File" Which will contain title and File upload field. That way they could possibly be able to "send" those nodes to anyonther somehow.

I could create listing of user files with views or else.

I am also using User Relationships module.

Question:
What would you suggest, what would be best method to achieve this ?
Is there mechanism for user to "send" node to another (User Relationships) ?
What is the danger of having extreme number of nodes that user can produce this way ?
Is there an alternative ?

Thanks