texts:
I have an image style in Drupal 7. I attached several images to a nodes and display the images based on this style. I then changed the effects on this image style but the existing images are not being recreated with the new image style effects. They show with the old image style effects.

If I attach new images, they use the new effects. Deleting an existing image and re-uploading causes the image to use the old effects.

The manual (incorrectly I assume) states that just saving an image style causes a rebuild:
http://drupal.org/documentation/modules/image

I have cleared the cached.

How do I force a rebuild?


texts: Drupal 8, save new fieldCollection items to user from a foreach loop doesn't work

texts:
My user structure have a multiple field "foo" of type "FieldCollection". From a custom module, I want create programmatically several fieldcollection item and add them to the current user.

Without any loop, when I add only one new FieldCollection item to the user, its work. But, when I want user a loop for add several FieldCollection, only the first item is added. I mean :

With some light php :

// In my module
    // some operations and prepare the datas structure
    foreach(datas as data){ // count(datas) = 2, by example
        $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
        $field_collection_foo = FieldCollectionItem::create(array('field_name' => "field_foo"));
        $field_collection_foo->set("field_data",$data);
        $field_collection_foo->setHostEntity($user);
        $field_collection_foo->save();
    }

Then if I go to the user edit page from the back office, I see only the item datas[0] added, not datas[0] datas[1]

Where is my mistake ?

UPDATE (add some test) :

I think I find, I do an another $user->save somewhere in my module and I think its it who save the wrong value :) Ill test it


texts: Expose single filter of combination of two fields in views

texts:
I have two user profile fields "Last Name" and "First Name". I also have a user list views. I want to expose "Name" as filter which can search for both Last Name and First Name.
How can I do single filter of combination of those two fields? Can I create it from views UI?

One possible way is to create another profile field "Name" which will be hidden in the form. On user save, I would combine the two field values into the "Name" field and then expose it as filter in the views. But this solution is hard coding and it needs to write hooks.


texts: How can I rewrite the values of facets shown in the Current Search block?

texts:
I am using the Facet API for Solr search on my site.

The Facet API Bonus module provides a Rewrite items filter:

  Filter "Rewrite Items": Filter plugin to rewrite labels or other data
  of the facet items by implementing a new dedicated
  hook_facet_items_alter (in a structured array, before rendering). Very
  handy to rewrite list field values or totally custom encoded facet
  values for user friendly output.

My site has three facets for boolean fields that have "Yes" or "No" options by default.  Using this filter, I have rewritten them so that what is being selected is more clear:

function mymodule_facet_items_alter(&$build, &$settings) {
  switch ($settings->facet) {
    case 'field_friends':
      foreach($build as $key => $item) {
        if($item['#indexed_value'] == '1') {
          $build[$key]['#markup'] = t("Wants friends");
        }
        else {
          $build[$key]['#markup'] = t("Doesn't want friends");
        }
      }
    break;
    case 'field_money':
      foreach($build as $key => $item) {
        if($item['#indexed_value'] == '1') {
          $build[$key]['#markup'] = t("Wants money");
        }
        else {
          $build[$key]['#markup'] = t("Doesn't want money");
        }
      }

This works for the facets.  But the problem is, if the user clicks Wants friends and Doesn't want money, then the Current Search block shows Yes and No (the unmodified facet values).

How can I rewrite the values of the facets show in the Current Search block too?  As it is now, if a user selects multiple Yes and No values, they will have no idea what is actually being applied.


texts: Is there a way to swap webform object between nodes?

texts:
I have a weird situation.

Webform Localization module allows localization by string translation. That's good, that's what I wanted to use. Sadly, it treats all strings as if their "original" language was English. That's a limit/bug I can live with, but one of my editors created webform under node in another language. I can't simply change node's language, because it's title etc are set up OK. Or rather, I can, but I'll have enough work with Webform already that I want to avoid it.

Is there a way to connect that webform to English node, and connect empty webfrom from English node to this one? i only need to do it once, so it doesn't need to be pretty.

Simply swapping Node IDs in {webform} table does not help. It swaps confirmation messages etc (but these i would prefer to leave where they are), but does not swap actual webform components.


texts: how to get a list of all the boolean fields of a node?

texts:
I need to get a list of all the boolean fields of the node

My code

 $query = \Drupal::entityQuery('node')
   ->condition('status', NODE_PUBLISHED)
   ->condition('type', 'product')

Please help me


texts: How to run an executable from within a Drupal Controller?

texts:
I'm working on a controller that when called upon will take a screenshot of the main page of my site. I'm attempting this by calling Chrome in headless mode via the PHP shell_exec() function.

$command = 'google-chrome --headless --no-sandbox --screenshot=./pic2.png --window-size=600,400 http://localhost/';
$output = shell_exec($command);
ksm($output);

Unfortunatley this doesn't seem to work inside my Drupal controller. This will however work just fine in a php script outside of Drupal. Also, if I just try to read the version with my Drupal Controller then it does work. Command to read version:

$command = 'google-chrome --product-version';

I'm assuming there's some security feature that prevents Drupal from triggering an external executable (understandable). Is there a safe way around this or am I just going about this the wrong way? Thanks!


texts: How to speed up node add form with around 50 fields?

texts:
I had a node add form with around 50 fields, mostly text with 1 field collection (with another 5 fields) and a few entity and term references.

The page is taking around 30 seconds to load making it unusable.

There are several slow queries (99.28 - DrupalDatabaseCache::getMultiple, 34.21 - views_plugin_query_default::execute, 20.51 - DrupalDefaultEntityController::load, 18.46 - DrupalDatabaseCache::getMultiple, 17.46 - DrupalDatabaseCache::getMultiple.. they go on)

The Cache::getMultiple query has 1087 placeholders, and the EntityController::load has 1084 placeholders.

If a click on the "Add Another Item" on the field collection that takes a further 30 seconds to complete.

What can I do to speed up the load times of the page?

EDIT: I just installed APC which removed all of the caching queries but did not solve the problem - still around 30 second load time. I don't think the slow load times are related to caching. Is taking around 280MB of memory load build the page.

EDIT: Removing the field collection, installing memcache and entitycache has shaved 20 seconds off the load time. However 10 seconds to initially load the page and another 10 seconds per ajax request is still unacceptable. How do webforms perform with a large number of fields? Maybe that would be a better option?


texts: How to add custom content before hook_form()

texts: Form uploads image and if image is uploaded I'd like it to be displayed before the form. What is the right way to do this?


texts: How do I programatically submit a webform via drupal_form_submit?

texts:
Drupal 7, Webform 3

I want to programmatically submit a webform via drupal_form_submit. However, I'm having difficulty finding a $form_state structure that works. I've submitted my webform via the ui and examined the $form_state variable in my validate callback function, but I still can't get it to work.

My webform has one textfield named "first_name". Below is a snippet of code I've used to test. Whenever I run it, $form_errors is null. With no errors, I would expect the code to have worked.  However, when I check the webform results, it says there are no submissions.

<?php
$form_id = 'webform_client_form_55805';
$form_state = array(
  'values' => array(
    'submitted' => array(
      'first_name' => 'David',
    ),
  ),
);
$node = node_load(55805);
$submission = (object) array();

drupal_form_submit($form_id, $form_state, $node, $submission);
$form_errors = form_get_errors();
?>

Am I doing it wrong?  Is there a better way?  Should I be using webform_client_form_submit instead?

I looked at this Q&A, but it doesn't work for me and seems a bit convoluted: How to submit webform programmatically with Ajax?


texts: UPS shipping method not working on drupal 7?

texts:
Possible Duplicate:
  Ubercart UPS Shipping Method not working?

I am having an issue with setting up Ubercart with my UPS account to allow the customer to configure shipping quotes. After I fill in all of the address information and I click on the "Click to calculate shipping" button, I keep getting the same error message:

  There were problems getting a shipping quote. Please verify the delivery and product information and try again. If this does not resolve the issue, please call in to complete your order.

I have no idea what the issue could be. I'm not sure if there is a setting or configuration that I missed or if it's something else. I'm not sure what information any of you would need to determine the issue, so if someone thinks that they could help me, let me know what information might be needed and I can get it.


texts: Allow tinymce in WYSIWYG to load different skins per content type

texts:
I want to user a different default tinymce editor styles per content type. I basically want to use a different default font in the editor area of tinymce per content type.

I have discovered that the editor of tinymce has some default settings that are not configurable through the WYSIWYG module, but it can by modifying the file
jscripts/tiny_mce/themes/advanced/skins/default/content.css

However, that would apply to all content types.

Is there a way to set a skin for a content type?

This would be a start, but does not apply it per content type:

/**
 * Implements hook_wysiwyg_editor_settings_alter().
 */
function custom_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'tinymce') {
  $settings['skin'] = 'o2k7';
  $settings['skin_variant'] = 'silver';
  }
}


texts:
I had to import a multisite (Drupal 7) to Acquia dev desktop.
The import seemed to be successful.
But the following error is displayed when the page is accessed:

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146
  Table 'kanu_backup.semaphore' doesn't exist: ...

What should I do?


texts:
I created my own bootstrap sub theme and wondering how can I edit the following line:

<h2<?php print $title_attributes; ?>><?php print $title; ?>

to

<h3<?php print $title_attributes; ?>><?php print $title; ?>

As you can see, I want to change the h2 tag to h3 tag.

The code above can be found under bootstrap/theme/block. But I believe that it's not a good idea to edit it directly on this location, unless I'm mistaken.

I know that html.tpl.php or page.tpl.php can be copied from bootstrap/theme/system folder to mytheme/templates but wondering how can I do the same with block.tpl.php.

Any ideas?

Note: I'm using bootstrap 3.0.


texts: Need Steps to Install multisite configuration using only drush. i.e multi-site install having different database

texts:
I need a help to install multi-site setup using only Drush that have multiple/different databases.I have already installed a site using drush but when I do the same steps for install another site into the sites folder using drush it gives me an error to delete previous database. I want instead to install another site that having same code base but different database.

Install site in /var/www/html/abc
Install another in /var/www/abc/sites/xyz.com

Gives error.


texts:
I want to build a custom formatter for a paragraphs field that renders some of the fields of the paragraph. However, I don't know how to access the single files of the paragraph field.

So far I've only written the skeleton of the formatter, but it doesn't do much, except that I can return a serialised string of all of the entire field, which does include the necessary information, but I only need three particular fields rendered themselves in a nice way (a term reference field with a label, a boolean field as "yes" or "no" and a text field. A Twig template is not an option for this.

The function looks like this:

public function viewElements(FieldItemListInterface $items, $langcode) {
  $element = [];

  foreach ($items as $delta => $item) {
    // Desired fields: field_network_name, field_network_specific_site_code, field_network_verified

    $element[$delta] = [
      '#markup' => "Output: " . serialize($item)
    ];
  }

  return $element;
}

I'd need to know how to elegantly access the fields inside $item.


texts: How to add a notification when a relation or friends publish new content?

texts:
I want like Facebook notification add icon when a user relationships or flag friends ( User Relationships or Flag Friend module) published some new content.

I followed this good tutorial who is the closest to do that : How to allow users to manage their own Message Stack messages?. It works perfectly, but only for the current user and not relationships or friends. I also found How to implement Facebook style Notifications for Organic Group posts?.

I would use not only for the current user but for user relationships like a Facebook notification. I tried many ways: using Rules, Views or custom development (the most closest with hook_node_insert and user_relationships_load } but without success.

The problem is you need to notify individually each of the friends, so that they can manage there own notifications. If not each time a friend removes a notification, it's removed for ALL friends.

I add a custom field of user that is fill by one each time a new content is publish with a custom module this is working but I not find a way to JOIN the QUERY with the relationship table or friends tables.

function my_module_node_insert($node){
if($node->type == 'mytype'){
db_update('field_data_field_my_field_name')
->expression('field_my_field_name_value', 'field_my_field_name_value +
:amount', array(':amount' => 1))
->execute();
//or you also can use regular query
//db_query("UPDATE {field_data_field_my_field_name} SET
//field_my_field_name_value = field_my_field_name_value + 1");
}
}

Here is the screen of the views of list "all friends" default views of Flag
    friends module


texts: Duplicate Results in View with OG Relationship

texts:
I have a view that uses the OG Relationship "OG membership: Group Content (node) from OG membership", and this relationship is causing duplicates when a person has more than one group assigned to them.

If I use aggregation settings along with checking the distinct checkbox in the query settings, the duplicates disappear. (Oddly enough, I needed to use BOTH aggregation and "Distinct".)

However, I want the ALL Content Titles for the related Group (which is why I needed the relationship).

I even tried the Views Distinct module, but after fumbling around with it, it either shows one Content Title from the group or all Content Titles from all groups.

All of this behavior leads me to believe there's an issue with OG relationships because there's no way to aggregate the content titles that I can find.

Am I looking at a views hook to fix the issue?


texts:
I am migrating a site from Apache to IIS.

When I backed up the database Clean Urls was active, now my links do not work and I have to add ?q= to them!  Some links work well but the Admin pages are not shown and they display a white screen!

How can I disable Clean Urls?

Also, my images that are customized with ImageCache are not showing!  They return a link to a broken image.


texts: Issues with regions using the Spaces Dashboard module

texts:
I have been facing many issues trying to use the Spaces Dashboard module (part of the Spaces module).

I have setup a site with pressflow, OG, Context, Spaces, and Features; I got everything working well together.

I have been trying to implement the Spaces Dashboard feature, so group managers can manage their own group front page with an easy to use drag'n drop UI.

Through context, I have been able to create a default dashboard with some enabled blocks.
I have configured all spaces_dashboard settings and saved them in my default group space so every new group is shipped with those settings.
I have done some workaround in my template to get the context working with my Zen subtheme (based on #26 at http://drupal.org/node/633778).
I can now drag and drop blocks from my dashboard edition block to my theme regions.
I followed this tuto for setting up the UI (not really fully working with zen subtheme) : http://www.leveltendesign.com/answer/adding-customize-dashboard-magic-your-drupal-theme
I can currently drop blocks in ANY of the theme's regions even the disabled ones. I'm not sure of where does the problem comes from. The region settings are setup in the module config page at both site level and spaces level.
I cannot drop blocks in empty regions. ("Empty" meaning any region on the page that does not contains any block yet.)
If I move a block out of a region and there is no block anymore in the region I cannot move it back in the region. I'm not sure if this is a CSS, JS or module issue.
I found that by adding div for empty regions I can get some empty regions to work, but this is just a html trick and not a solution.

Content top

Finally, the 'save' button from the dashboard block doesn't save any modification to the dashboard in the current space nor in the global settings.


texts: Why does template.php override not work?

texts:
I'm trying to get links from the PDFPreview module to open in a new tab. As described in this issue, overriding the formatter function in template.php does not work.  One can modify the function in the actual .module file, but this is obviously not good practice.  Why does it not work?

Code from the module:

/**
 * Theming functions for our formatters
 *
 * @todo Clearify the image cache thing...
 * @todo Let user choose what preview image to show on non-PDF files
 */
function theme_pdfpreview_formatter($variables) {
  $img_tag = '';
  $item = $variables['item'];

  $image = array(
    'title' => $item['description'],
    'uri' => $item['preview'],
  'alt' => $item['description'],
  );

  $element =array();
  $element['item'] = $image;
  $element['image_style'] = $variables['settings']['image_style'];
  switch ($variables['settings']['image_link']) {
    case 'file':
      $element['path'] = array(
        'path' => file_create_url($item['uri']),
        'options' => array(),
      );
      break;
      case 'content':
      $element['path'] = array(
        'path' => $variables['entity_type'] . '/' . $variables['entity']->nid,
        'options' => array(),
      );
      break;
  }
  $img_tag = theme('image_formatter', $element);
  $wrapper_tag = $variables['settings']['tag'];
  $description = $variables['settings']['show_description'] ? '<' . $wrapper_tag . ' class="pdfpreview-description">' . $item['description'] . '</' . $wrapper_tag . '>' : '' ;
  return sprintf(
          '
'
          . ' <%s class="pdfpreview-image-wrapper">%s</%s>'
          . ' %s'
          . '
',
          $variables['instance']['field_name'],
          $item['fid'],
          $wrapper_tag, $img_tag, $wrapper_tag,
          $description
  );
}

Code from template.php:

/**
 * Theming functions for our formatters
 *
 * @todo Clearify the image cache thing...
 * @todo Let user choose what preview image to show on non-PDF files
 */
function my_theme_pdfpreview_formatter($variables) {
  $img_tag = '';
  $item = $variables['item'];

  $image = array(
    'title' => $item['description'],
    'uri' => $item['preview'],
  'alt' => $item['description'],
  );

  $element =array();
  $element['item'] = $image;
  $element['image_style'] = $variables['settings']['image_style'];
  switch ($variables['settings']['image_link']) {
    case 'file':
      $element['path'] = array(
        'path' => file_create_url($item['uri']),
        'options' => array('attributes' => array('target' => '_blank')),
      );
      break;
      case 'content':
      $element['path'] = array(
        'path' => $variables['entity_type'] . '/' . $variables['entity']->nid,
        'options' => array(),
      );
      break;
  }
  $img_tag = theme('image_formatter', $element);
  $wrapper_tag = $variables['settings']['tag'];
  $description = $variables['settings']['show_description'] ? '<' . $wrapper_tag . ' class="pdfpreview-description">' . $item['description'] . '</' . $wrapper_tag . '>' : '' ;
  return sprintf(
          '
'
          . ' <%s class="pdfpreview-image-wrapper">%s</%s>'
          . ' %s'
          . '
',
          $variables['instance']['field_name'],
          $item['fid'],
          $wrapper_tag, $img_tag, $wrapper_tag,
          $description
  );
}


texts: How to validate all elements in Custom Widget

texts:
I can validate a single textfield usig the fllowing code.

/**
 * @file
 * Contains \Drupal\field_example\Plugin\Field\FieldWidget\TextWidget.
 */

namespace Drupal\field_example\Plugin\Field\FieldWidget;

use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Plugin implementation of the 'field_example_text' widget.
 *
 * @FieldWidget(
 *   id = "field_example_text",
 *   module = "field_example",
 *   label = @Translation("RGB value as #ffffff"),
 *   field_types = {
 *     "field_example_rgb"
 *   }
 * )
 */
class TextWidget extends WidgetBase {

  /**
   * {@inheritdoc}
   */
  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
    $value = isset($items[$delta]->value) ? $items[$delta]->value : '';
    $element += array(
      '#type' => 'textfield',
      '#default_value' => $value,
      '#size' => 7,
      '#maxlength' => 7,
      '#element_validate' => array(
        array($this, 'validate'),
      ),
    );
    return array('value' => $element);
  }

  /**
   * Validate the color text field.
   */
  public function validate($element, FormStateInterface $form_state) {
    $value = $element['#value'];
    if (strlen($value) == 0) {
      $form_state->setValueForElement($element, '');
      return;
    }
    if (!preg_match('/^#([a-f0-9]{6})$/iD', strtolower($value))) {
      $form_state->setError($element, t("Color must be a 6-digit hexadecimal value, suitable for CSS."));
    }
  }

}

But I have more elements in the widgets as follows

public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {

     $element['cert_fqdn'] = [
      '#type' => 'textfield',
      '#title' => t('Fully qualified Domain Name'),
      '#value' => $items[$delta]->value ?: NULL,
      '#empty_value' => '',
      '#placeholder' => t('Fully qualified Domain Name'),

    ];
    $element['privatekey'] = [
      '#type' => 'textfield',
      '#title' => t('Private Key'),
      '#default_value' => isset($items[$delta]->cert_key) ?
          $items[$delta]->cert_key : null,
      '#empty_value' => '',
      '#placeholder' => t('PrivateKey'),
    ];

    // City

    $element['csr'] = [
      '#type' => 'textfield',
      '#title' => t('Certificate Signing Request'),
      '#default_value' => isset($items[$delta]->cert_csr) ?
          $items[$delta]->cert_csr : null,
      '#empty_value' => '',
      '#placeholder' => t('Certificate Signing Request'),
    ];
    $element['cert_crt'] = [
      '#type' => 'textfield',
      '#title' => t('Server Certificate'),
      '#placeholder' => t('Server Certificate'),
    ];

$element['create_cert_btn'] = array(
    //'#name' => implode('_', $element['#parents']) .'_create_cert_btn',
    '#type' => 'submit',
    '#value' => t('Create/Renew Cert'),
        '#element_validate' => array(
        array($this, 'validate'),
            ),

    );

    return $element;

  }

I need to get the values of all the elements  in validate function. How can I change the code to meet this . Please help.


texts: Content creation screen: Add another field conditionally

texts:
I'm trying to figure out how to do the following in D7:
I have a list field in a custom content type. The list contains 8 items. When creating content of this content type, the user can only select one item from this list. But there are two items from this list that I would like to have their own sub-lists. How would I have Drupal conditionally show another list if one of these items were selected? (This is all happening on the content creation screen).

Update
This is not a duplicate of the question you have referenced because this is regarding Drupal 7 content creation. The "Conditional Fields" module was built for Drupal 6 and is not fit for production, as per the module page, in Drupal 7 pages. I am looking for a stable, maintainable solution for a production website.


texts: I have a CCK field that I want to use in a view. How can I do it?


texts: Drupal Rule to deselect radio button item?

texts:
In Rules, I don't see any option to deselect radio button items.

In my rule, I want an Action which is to deselect 'Request Resubmission', as in this screenprint.


texts: Paging issue in views when implements node access

texts:
I have created a content type called Details it is the collection of employees detail. And also I have created a Taxonomy terms called manager, employee, lead. Also I have created a field(as Taxonomy reference) for user profile to indicate whether she/he is manager or lead or employee. Now I want to put the restriction based on the user. I have achieve the restriction using my custom module. The codes are below:

    function my_module_node_access($node, $op, $account) {
  global $user;
  $user_obj = user_load($account->uid);
  if (isset($node->type) && ($node->type == 'details') && ($op == 'view')) {
        if (($user->uid == 0) || ($user_obj->field_user_company['und'][0]['tid'] != $node->field_company['und'][0]['tid'])){
            return NODE_ACCESS_DENY;
        }
    }
  return NODE_ACCESS_IGNORE;
}

The above code simply do, if the node taxonomy term, and the user field taxonomy term is same then he will perfectly access to the nodes. I got struggle with views. I have created a view to show the node title that can be access by the user. Manager has 100 nodes to view, in views settings I have enable the pager, 25 items per page to display. Pager splits into 4 page and shows correctly. But when comes to employee user he has access to 1 node only, but in views it still shows the pager in 4 parts.

function my_module_views_post_execute(&$view) {
  if (($view->name == 'views1') || ($view->name == 'views2')) {
        $nids = array();
      foreach($view->result as $key=>$result) {
          $nids[$key] = $result->nid;
      }
      $nodes = node_load_multiple($nids);
      foreach ($nodes as $node) {
            if (!node_access('view',$node)) {
                $key = array_search($node->nid, $nids);

                unset($view->result[$key]);
            }
        }
     }
  }

The views pager display must be changed dynamically depends on the number of nodes. Is anyone knows kindly show me a right path to achieve this???


texts: How to disable quickedit for specific block, but keep contextual links

texts:
I want to disable the quick edit feature for a specific block so that it does not show up in the contextual links anymore.
However, I want to keep the other contextual links for this specific block (e.g. configure block).
I do not want to entirely turn off quick edit, because I still need it on some elements.
Hope someone can help with this one?


texts: My class derived from RouteSubscriberBase is not used

texts:
I would like to override the user login form in order to replace the username field with an email field.

I created a module (with EventSubscriber declared as service) and installed it. However, my class is not used load when I try to access to the user/login route. The call to exit() I use in my code doesn't display anything.

  /**
   * @file
   * Contains \Drupal\override_user\Routing\RouteSubscriber
   */

   namespace Drupal\override_user\Routing;

   use Drupal\Core\Routing\RouteSubscriberBase;
   use Symfony\Component\Routing\RouteCollection;

   /**
    * Listens to the dynamic route events.
    */
      class RouteSubscriber extends RouteSubscriberBase {

   /**
    * {@inheritdoc}
    */
    protected function alterRoutes(RouteCollection $collection) {
      if ($route = $collection->get('user.login')) {
         exit('user/login access');
         $route->setDefault('_form', '\Drupal\override_user\Form\MyUserLoginForm');
     }
    }
  }

My service

    services:
    route_subscriber:
        class: Drupal\override_user\Routing\RouteSubscriber
        tags:
             - {name: event_subscriber }

What is wrong with my code?


texts: How can I specify required fields when programmatically loading a node creation form?

texts:
I'm building out a custom workflow. Newly registered users can create a node that has several fields - some of the fields are required, others are pre-filled, and others are disabled. The benefits for having 1 content type to handle this greatly outweigh the negatives.

Fields that I set the #default_value, #access, or any other FAPI attribute on are working properly, but fields where I set #required = TRUE are not validating and are not stopping the node from being created!

Here's my code:

function my_custom_callback($arg) {
  module_load_include('inc', 'node', 'node.pages');
  $page['node_form'] = node_add('content_type_name');

  if ($arg == 'foo') {
    $page['node_form']['field_favorite_color'][LANGUAGE_NONE][0]['value']['#required'] = TRUE;
  } else if ($arg == 'bar') {
    $page['node_form']['field_favorite_food'][LANGUAGE_NONE][0]['value']['#required'] = TRUE;
  }
}

If I visit this page with $arg = 'foo',  I can submit this form without entering anything in field_favorite_color, even though this field shows the red asterisk and has the class 'required' and is showing as #required = TRUE in the form's render array when I do a dpm() within the callback function.

Why won't Drupal require that this required fields be filled out? Do I need to rebuild the form somehow after I've altered the fields? If I set the same code in a hook_form_alter() then it works as expected, but in that case I don't have the control that I get through my custom callback to lead the user through a multi-step workflow.

Edit: This is Drupal 7. Tried adding that tag but am seeing 'drupal-7' and 'drupal7' tags are not allowed.


texts: How to check if an article is referenced from a collection?

texts:
I have a collection content type which is just a list of EntityReferences to articles.

When I am loading an article, how can I use the Entity API to check if it belongs to one or more collections?

Previously I would query the DB, but I wonder if there is a more idiomatic way?


texts: Programmatically creating mulitple blocks without creating seperate .php files for them

texts:
EDIT: The code below works - there was a problem with my local machine - read more at the end for why it did not work
I want to create multiple blocks that don't need custom setttings from the interface and get their content from a custom function based on their name.
So basically I a need a bunch of blocks with names in order to be able to be placed in regions from the UI.
I tried this tutorial but I realize that its from early 2014 and things might have changed so I ended up following the the 1st solution to this question which seems newer.
modules/mymodule/src/Plugin/Block/YourBlock.php
<?php

namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;

/**
 * Display all instances for 'YourBlock' block plugin.
 *
 * @Block(
 *   id = "mymodule_block",
 *   admin_label = @Translation("Your block"),
 *   category = @Translation("Your block"),
 *   deriver = "Drupal\mymodule\Plugin\Derivative\YourBlock"
 * )
 */

class YourBlock extends BlockBase {
  /**
   * Build the content for mymodule block.
   */
  public function build() {
    $block_id = $this->getDerivativeId();
    return array(
      '#markup' => $block_id,
    );
  }
}

modules/mymodule/src/Plugin/Derivative/YourBlock.php
<?php
namespace Drupal\mymodule\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;

class YourBlock extends DeriverBase {
    public function getDerivativeDefinitions($base_plugin_definition) {
        $myblocks = array(
            'mymodule_block_1' => t('My Module: Block 1'),
            'mymodule_block_2' => t('My Module: Block 2'),
        );

        foreach ($myblocks as $block_id => $block_label) {
            $this->derivatives[$block_id] = $base_plugin_definition;
            $this->derivatives[$block_id]['admin_label'] =
                t('Title: @name content type: @ctype ', array('@name' => $block_label, '@ctype' => "My Module"));
        }

        return $this->derivatives;
    }
}

above is the complete code I have tried
I have done drush cache-rebuild but the 2 blocks don't appear when I press "place blocks" in admin/structure/block
What am I doing wrong ?
EDIT: Found a solution
it turns out that enabling this module on a different system the blocks where discovered so there was nothing wrong with the code
The setup that had a problem was with php 5.5.9 and mysql 5.5 and the system that was working well had php7.1 and mysql 5.7 so this might be the case


texts:
I have a custom module that implements a webform handler. I'm seeing this error in my Watchdog log when I navigate to admin/structure/webform/manage/myform/handlers:

  Theme hook webform_handler_myform_form_handler_summary not found.

I must have missed something when creating my module, but what? What needs to be added? Searches for "webform handler theme hook" haven't been fruitful.


texts: Can we fetch the depth of taxonomy from term load

texts: Term::load (termid) can we get the depth of term. If yes how can we achieve ? If no, how can we achieve this without loading tree nor children is there any other way we can fetch depth?


texts: I created custom module, and the module uses the mymodule_boot function. Inside that function I wrote user_load_by_mail to check the user is exists or not. But it is not working and I am not able to access site. It throws http error 500.


texts:
I forbid content access to all user that are not connected. The problem is that Drupal prevent also the access of the main page (And I want that an anonymous user will be able to see it..). How can I separate the main page access to the other content of the site ?

Thank you


texts: How to call external api to pull data into json format?

texts:
There is an api that is used to expose data from an external website. How can I use the drupal API to call the external api and pull the data into json format?

the external api would be, for example, "api.website.com/api/get_data".

return results would be in json format "{"data":[....]}

How would I use a module to call the external api and return the data in json?


texts:
I am trying to add the English title as a drupal_set_message on all node pages if available - (Ive done something similar on the CMS) and if the user has node edit permissions (this can be checked using the node_access function).

Code for cms example mentioned. Inside a hook form alter.

// Translation display on CMS page
$nid = (isset($form['nid']['#value'])) ? $form['nid']['#value'] : false;
if($nid) {
    $node = node_load($nid);

    if($node) {
        $lang = 'en';
        $translations = translation_node_get_translations($node->tnid);

        $translated_node = (isset($translations[$lang])) ? node_load($translations[$lang]->nid) : $node;
        $translated_title = '
English Translation: ' . $translated_node->title . '
';
    }
}

$form['#prefix'] = (isset($translated_title) && $translated_node->title != $node->title) ? $translated_title : '';

I am now wanting something similar but as a drupal_set_message on all node pages.


texts: How do I implement a gallery like the following one with jQuery 1.6.4 and Drupal 7?


texts:
I would like to set different prices for different userroles. My main is goal is to set "list price" as price to userrole1, and "sell price" to other users. The "list price" is the retail price and I would like to allow to some users to buy on that price.

As I was researching I came to the conclusion to do it by theme_uc_price(), but this function has no accesss to the sell_price. It gets only a $variable['price']. I think it would be the best practice to push the list price somehow to this function.

function theme_uc_price($variables) {
  global $user;
  if (in_array('userrole1', $user->roles)) {
    $variables['price'] = $here_should_come_the_list_price_but_how; /* missing var */
  }

  $output = uc_currency_format($variables['price']);
  if (!empty($variables['suffixes'])) {
    $output .= ' ' . implode(' ', $variables['suffixes']);
  }

  return $output;
}

My other plan was to modify the theme_uc_product_price(), it really works, but only on the node pages (teaser and full view). On the cart and checkout pages it switches back to sell price, because those pages do not load the theme_uc_product_price().

function theme_uc_product_price($variables) {
  $element = $variables['element'];
  $price = $element['#value'];
  $attributes = isset($element['#attributes']) ? $element['#attributes'] : array();
  $label = isset($element['#title']) ? $element['#title'] : '';

  if (isset($attributes['class'])) {
    array_unshift($attributes['class'], 'product-info');
  }
  else {
    $attributes['class'] = array('product-info');
  }

  $output = '';
  if ($label) {
    $output .= '' . $label . ' ';
  }

  /* get list_price - 'hack' starts from here */
  global $user;
  if (in_array('userrole1', $user->roles)) {
    $node_id = substr($element['#attributes']['class'][1], -4, 4);

    $result = db_query('SELECT list_price FROM `dr_uc_products` WHERE nid = '.$node_id);
    foreach($result as $item) {
      $price = substr($item->list_price, 0, -6);
    }
  }

  $vars = array('price' => $price);
  if (!empty($element['#suffixes'])) {
    $vars['suffixes'] = $element['#suffixes'];
  }

  $output .= theme('uc_price', $vars);
  $output .= drupal_render_children($element);
  $output .= '';

  return $output;
}

Any tip or advice is appreciated. Thank you!


texts: How to implement javascript to the theme Bootstrap

texts:
Please help me figure out what I'm doing wrong. I spent a lot of time to search for solutions, but could not find it.
I am trying to add functionality Demo in the sub-theme Bootstrap.
Added script to theme subtheme/js/script.js

(function ($, Drupal, window, document, undefined) {
    $(document).ready(function(){
        $(".b-left-side__pointer").click(function(){
           if ($(".switch").hasClass('b-container__left-side')) {
                $(".switch").removeClass('b-container__left-side').addClass('b-container-block-left');
            } else {$(".switch").removeClass('b-container-block-left').addClass('b-container__left-side');
                }
        });
    });
})(jQuery, Drupal, this, this.document);

Added styles to theme subtheme/css/subtheme_style.css

.b-container__left-side {
  position: absolute;
  top: 52px;
  left: -300px;
  height: calc(100% - 52px);
  height: -moz-calc(100% - 52px);
  width: 300px;
  z-index: 1006;
  display: block;
  -webkit-transition-duration: 0.8s;
  -moz-transition-duration: 0.8s;
  -o-transition-duration: 0.8s;
  transition-duration: 0.8s;
}

.b-container-block-left {
  width: 300px;
  float: left;
  height: 97vh;
  margin-top: 0;
  border: none;
  background: #fff;
}

.b-left-side {
  height: 100%;
  overflow: auto;
}

.b-left-side__pointer:hover {
  cursor: pointer;
}

.b-left-side__pointer {
  position: absolute;
  bottom: 20px;
  left: 300px;
  width: 25px;
  height: 90px;
  border-bottom-right-radius: 3px;
  border-top-right-radius: 3px;
  background-color: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
  z-index: -1;
}

.b-left-side__pointer p {
  transform: rotate(-90deg);
  transform-origin: left top 0;
  -webkit-transform: rotate(-90deg);
  -webkit-transform-origin: left top 0;
  margin: 80px 0 0 0;
  font-family: WWF;
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

Added to the end of the subtheme file  subtheme/templates/page.tpl.php (the file is copied from a folder of Bootstrap theme themes/bootstrap/templates/system/page.tpl.php)

<?php if (!empty($page['l_sidebar'])): ?>

        <?php print render($page['l_sidebar']); ?>

Block

<?php endif; ?>

Add to subthemes info file the following lines:

regions[l_sidebar] = 'Left sidebar'
stylesheets[all][] = css/subtheme_style.css
scripts[] = js/script.js

The subject area  "Block" appeared but it does not respond on clicking.


texts:
Basically I've created 2 views and one is supposed to be called inside the other one, I've done this call by overriding the style output of the main one.
The problem is because I'm using ajax load more, when I click on "load more" the new elements are displayed in the main view but also inside the other view.
Here how I call it

<?php foreach ($rows as $id => $row): ?>
  <div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>
  </div>
      <?php
        $counter++;
        if($counter == 4) {
          $view = views_get_view('twitter');
          $view->set_display('twitter');
          $view->pre_execute();
          $view->execute();
          $count = count( $view->result );
          print $view->render();
        }
    ?>
<?php endforeach; ?>

Any ideas why ?


texts: Create a controller and a empty theme page

texts:
On Drupal 8, I'm looking for a way for creating an empty page (a page without any theme) that contains JavaScript code.
I created a controller via Drupal Console, and I searched for an example on the web, but I found only very simple examples.

Is it possible to create an empty page accessible via a controller and add JavaScript code to this page?


texts: Different suffix for multiple field value

texts:
I have multiple field value -3 value-, each value have a defferent suffix. For exemple there is a field vessel consumption with 3 value, each value have a unit of measure: HFO or MGO, MDO.
Is there a way to show every value with a suffix or I have to use text field type?


texts: Create Custom Date Formatter for Date Posted Field

texts:
I followed a very helpful article by Antonio Benitez that gave some example code showing how to create a custom date formatter for date fields (How To Create a Custom Format for a Date Field). The code adds an additional format option in the manage display settings page. This works great for date fields I have created (such as an event date for an event content type) but it is not applying to the existing date fields such as the node posted date. How can I make this custom formatter apply to system date fields such as the posted date, so that it appears as an option on the manage display page as well?

I am reproducing the code Antonio posted in his article here:

/**
 * Implements hook_field_formatter_info().
 */
function custom_module_field_formatter_info() {
  return array(
    'custom_date_format' => array(
      'label' => t('Custom date format'),
      'field types' => array('date', 'datestamp', 'datetime'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
    ),
  );
}

/**
 * Implements hook_field_formatter_view().
 */
function custom_module_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $elements = array();
  foreach ($items as $delta => $item) {
    $element = array(
      'element' => $item,
      'field' => $instance,
      'display' => $display
    );
    $elements[$delta] = array(
      '#theme' => 'custom_module_formatter_' . $display['type'],
      '#element' => $element,
      '#field' => $field,
    );
  }

  return $elements;
}

/**
 * Implements hook_theme().
 */
function custom_module_theme() {
  $themes = array(
    'custom_module_formatter_custom_date_format' => array(
      'variables' => array(
        'element' => NULL,
        'field' => NULL,
      ),
    ),
  );
  return $themes;
}

/**
 * Implements theme function
 */
function theme_custom_module_formatter_custom_date_format($vars) {
  $element = $vars['element'];
  $field = $vars['field'];

  // Configure custom date
  $format_date = 'd M';
  $timezone_bd = date_get_timezone_db($field['settings']['tz_handling']);
  $publish_date = DateTime::createFromFormat('Y-m-d H:i:s', $element['element']['value'], new DateTimeZone($timezone_bd));
  $date = format_date($publish_date->getTimestamp(), 'custom', $format_date);
  $date = explode(' ', $date);

  // Declare array for render content with custom format and tags
  $render_array = array(
    'date' => array(
      'date-day' => array(
        '#prefix' =>'',
        '#markup' => $date[0],
        '#suffix' => ''
      ),
      'date-month' => array(
        '#prefix' =>'',
        '#markup' => $date[1],
        '#suffix' => ''
      ),
    ),
    '#theme_wrapper' => array('container'),
  );

  return render($render_array['date']);
}


texts:
my code below results in a page not found when I browse to the path.  How can I debug what is going wrong? I dont see any errors and I have cleared the cache.

mymodule.content:
  path: '/admin/viewfiles'
  defaults:
    _controller: '\Drupal\mymodule\Controller\FileView::content'
    _title: 'File Operations Module Description'
  requirements:
    _permission: 'access administration pages'


texts: ShareThis facebook posts previews are perfect, but posts empty images

texts:
I have been having problems with facebook integration, and I know there are lots of other posts about this as I've been looking through lots of them. I see plenty of information about FB picking the wrong image, but in my case, the image is correct, and the preview of what is going to be posted from ShareThis is perfect. Even the facebook debugger tool has it all correct, but when I actually post it to facebook, the image is just empty.

What confuses me even more is that 2 of my other content types work, and the third doesn't. All 3 are defined in the same fashion, using the metatags open graph module to define the tokens for the meta data. In each page, the source is the same, and the og:image tag is always correct. When copying the image URL out of the source and browsing, the image loads perfectly.

I swear sometimes that facebook just does whatever it feels like sometimes. Anybody have any advice on why 2 of 3 content types work fine, but the 3rd never works?

I have looked at the settings for each imagefield, and they are all nearly identical. None of them are being stored in specific folders, they are all publicly accessible. As an example, the URL http://natureupnorth.org/encounter/mark-martin/smaller-haystack gives me no problems in the facebook debugger, previews fine, but results in just an outline of an image on facebook.

Any help greatly appreciated.


texts:
I have created a rule in Drupal with the following conditions/actions.

With this rule, I give 10% discount on a specific product type, but the tax (21% in The Netherlands) is still calculated on the old price (without the discount).

For example, without discount I get the following.

Sub total €28.93
Tax €6.07
Total price €35,00

With the discount, I get the following.

Sub total €25.43
Tx €6.07
Total price €31.50

I tried to change the weight of the rule, but it didn't help.

I used the default tax module of Drupal Commerce and all the default settings. Is there something I can do about it?

I tried also the Commerce Discount module, but with the same behavior.

PS: Prices on this website are shown included of taxes.

After the patch, it is still not working. The Tax should be the following. (The product price is €0.90 with 10% discount; normally the price is €1.00 without the discount.)

€0.74 (excluded tax)
€0.16 (tax)
€0.90 (total)


texts: Retrieve contents from a JSON URL using cURL and display them in an HTML table

texts:
I am trying to display contents retrieved from an external URL using JSON (the cURL method). So i wrote the below function:

function file_get_contents_curl() {
  //JSON URL which should be requested
  $gry_str = "?timezone=" . urlencode(date_default_timezone_get())  . "&dateFrom=" . date('Y-m-d') . "&dateTill=" . date('Y-m-d');

  $json_url = 'https://www.example.com/json/financial-calendar.json' . $gry_str;

  // Initializing curl
  $ch = curl_init();

  //Configuring curl options
  $options=array(CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => array('Content-type: application/json'),
    CURLOPT_URL => $json_url);

  //Setting curl options
  curl_setopt_array($ch, $options);

  //Getting resutls
  $results= curl_exec($ch); //Getting json result string
}

I want the contents retrieved to be displayed in an HTML table. So i am using this:


texts:
Iam using domain access module in my website and having multiple domains in my website for example iam having domains

test.example.com (primary domain)
test1.example.com

when iam creating a sample content "Contact" and provided with the URL alias as 'contact' (assume node id as 143), Under domain access options i select "send to all affiliates". When i try to access the below url

test.example.com/contact (its working fine)
test1.example.com/contact (page not found)
test.example.com/node/143
test1.example.com/node/143
both are working

Is it possible to have a same URL alias for all the domains. I used domain path module and its not working as my need.
Thanks.


texts:
I'm trying to create a form in which you can fill in user names. I want to dynamically add new textfields by pressing a button. I based my code on the following question (because it also uses Drupal 8 and supposedly should work).
However, unfortunately it doesn't add the fields. The code I'm using currently looks like this:
<?php
    /**
     * @file
     * Contains \Drupal\bulk_email\Form\EmailForm.
     */

    namespace Drupal\bulk_email\Form;
    use Drupal\Core\Form\FormBase;
    use Drupal\Core\Form\FormStateInterface;
    use Drupal\Component\Utility\UrlHelper;

    class EmailForm extends FormBase {
        public function getFormId() {
            return "bulk_email_form";
        }

        public function buildForm(array $form, FormStateInterface $form_state) {
            $form['#tree'] = TRUE;

            $form['users'] = array(
              '#type' => 'fieldset',
              '#title' => t('Users'),
              '#prefix' => '
',
              '#suffix' => '
',
            );

            $num_users = $form_state->getValue('num_users');
            if (empty($num_users)) {
                $num_users = 1;
            }
            for ($i = 0; $i < $num_users; $i++) {
                $form['users'][$i] = array(
                    '#type'  => 'textfield',
                    '#description' => t('Select a user.'),
                );
            }

            $form['users']['users_more'] = array(
                '#type' => 'submit',
                '#value' => t('Add one'),
                '#submit' => array($this, 'bulk_email_addfieldsubmit'),
                '#ajax' => array(
                     'callback' => array($this, 'bulk_email_add_more_callback'),
                     'wrapper' => 'users-wrapper',
                ),
            );

            $form['actions'] = array('#type' => 'actions');
            $form['submit'] = array(
                '#type' => 'submit',
                '#value' => t('Send'),
            );
            return $form;
        }

        public function submitForm(array &$form, FormStateInterface $form_state) {
            // submit code
        }

        public function bulk_email_addfieldsubmit(array &$form, FormStateInterface $form_state) {
            $num_users = $form_state->get('num_users') + 1;
            $form_state->set('num_users', $num_users);
            $form_state->setRebuild(TRUE);
        }

        public function bulk_email_add_more_callback(array &$form, FormStateInterface $form_state) {
            return $form['users'];
        }
    }
?>

I'm most likely missing a small detail, but I can't seem to find it...
Any help is appreciated.


texts: Send message to customer after the order has been created by administrator

texts: I use Drupal Commerce version 7.x-1.x. I want to Send message to customer automatically after the order has been created by administrator on page admin/commerce/orders/add. How can i done it with rules or hooks (for example mymodule_form_commerce_order_ui_order_form_alter) or other ways....


texts: Very slow loading on localhost (via. Uniform Server)

texts:
I've setup Drupal to run successfully on a Uniform Server installation on my local machine, but it's really slow.  It's taking over 30 seconds to enable/disable modules, and around 3-10 seconds on most other pages.  This is becoming time prohibitive.

Things I've observed/tested:

PhpMyAdmin (running under the same server stack) doesn't seem to take any unnecessary time to load with any operations.
As per this guide, disabling my firewall (while LAN/WAN disabled) has no effect.
Modifying php.ini and my windows hosts file (also by that guide) have no effect.
Firefox settings seem to have no effect (including the one mentioned in that guide).

My next move is simply to try a different server stack, but I'm wonder if I have to.  Advice?


texts:
I'm learning how to create a new module for the first time, so please bare with me. I'm trying to add a validation on the comment form from scratch; it's just not validating at all, meaning that my form successfully submits when I intentionally don't fill out the subject field.
Here is my code:

/*
 *  Implementation of hook_form_alter
 */
function my_module_form_alter(&$form, &$form_state, $form_id){
  if ($form_id == "comment_form") {
    $form['#validate'][] =  'my_module_comment_validate';
  }
}

/**
  * Validate routine to prevent keywords from being used within comments.
  */
function my_module_comment_validate($form, &$form_state){

if ($form_state['values']['subject'] == '') {
 form_set_error('', t('Error!'));
 }
}


texts: Add HTML code outside content area on every page load

texts:
I am trying to add HTML code outside the content area on every page load with the use of:

function us_page_build(&$page) {
  $page['content'][] = array(
    '#markup' => '

Here is my div content!!

',
  );
}

However, in this way I am placing the element within the content attribute. Is there a way to set it outside, having as parent only the html element?
I am aware I can paste code into the template files, but then if I switch to another template(which I will) I will need to re-enter it.


texts:
I am using Drupal 7, I recently used homebox module to create my dashboard for the users. While creating paths in homebox, I found that using '%' or '*' as dynamic path (user/%/dashboard) threw a validation error.

The strange thing was, the drupal.org has the same path for its dashboard too, I am not sure how this could be possible with homebox, when '%' or '*' cannot be used in the path definition.

Would be great if any one can answer about using dynamic paths in the homebox module.


texts: js-header and js-footer are not loading drupal 8

texts:
portfolio-library:
  version: 1.1
  css:
    theme:
      assets/css/main.css: {}
      #assets/css/font-awesome.min.css: {}
      assets/css/ie9.css: {IE: 'lte IE 9'}
      assets/css/ie8.css: {IE: 'lte IE 8'}

  js-header:
    header: true
    js:
      assets/js/ie/html5shiv.js: {IE: 'lte IE 8'}

  js-footer:
    js:
      assets/js/skel.min.js: {}
      assets/js/ie/respond.min.js: {IE: 'lte IE 8'}
      assets/js/main.js: {}

  dependencies:
    - core/jquery

This is my library file but my js files are not included in my theme can anyone please let me know what is going wrong.


texts: How to add "load more" link to comments?

texts:
I am trying to style my comments list to be similar to Facebook comments, so that user can load more comments by clicking on a link to load more. If there is a big number of comments then he should be able to load more and more comments.

Any suggestions how to start this?


texts: After implementing hook_node_access, how to stop node from appearing in view?

texts:
In Drupal 8, I implemented a hook_node_access function in my module to control access for a certain role under certain conditions and it works fine.

However, all of that content type are still shown on a view when the user views it. This is expected behavior according to the documentation:

  In node listings (lists of nodes generated from a select query, such as the default home page at path 'node', an RSS feed, a recent content block, etc.), ... hook_node_access() is not called on each node for performance reasons and for proper functioning of the pager system. When adding a node listing to your module, be sure to use an entity query, which will add a tag of "node_access". This will allow modules dealing with node access to ensure only nodes to which the user has access are retrieved, through the use of hook_query_TAG_alter(). See the Entity API topic for more information on entity queries.

(Link)

I understand why the view does not check each individual content, but I do not understand what this documentation is asking me to do to fix that. The documentation for hook_query_TAG_alter and on entity queries is not very helpful either.

How do I ensure that only items of this content type that the current user has view access to are shown in a view?


texts: Make a field theme function work on empty fields

texts:
I am using a field theme function in my template.php file to override a field.

Everything works fine, but the function only seems to run if my field has content. If my field is empty, it does not run. How can I get the function to run all the time?

Here is the code I am using. The function checks a value in theme_settings.php and then alters the output of the field accordingly.

function THEMENAME_field__field_call_to_action_button(&$variables) {
 // kpr($variables);

    //Load the value of CTA to determin which text to use
    $field_cta_option = field_get_items('node', $variables['element']['#object'], 'field_call_to_action_setting');
        $cta_option = $field_cta_option[0]['value'];

    //Assign theme/node settings to variables for easy access
    $cta_link_main      = theme_get_setting('cta_main_node');
    $cta_link_secondary = theme_get_setting('cta_secondary_node');
    $cta_link_custom    = theme_get_setting('cta_main_node');
    $cta_text_main      = theme_get_setting('cta_main_button_text');
    $cta_text_secondary = theme_get_setting('cta_secondary_button_text');
    $cta_text_custom    = $variables['#items'][0]['value'];
    switch ($cta_option) {
        case 'cta_main':
            return ctabutton($cta_link_main, $cta_text_main);
            break;
        case 'cta_secondary':
            return ctabutton($cta_link_secondary, $cta_text_secondary);
            break;
        case 'cta_custom':
            return ctabutton($cta_link_custom, $cta_text_custom);
            break;
        case 'cta_none':
            return "";
            break;
    }
}


texts: Use different settings for a Views' block basing on the content type of the node being shown

texts:
I have 2 content types,  photo articles and video articles. On a photo article page, I want to have a block that shows 5 other photo articles. When I place this same block on a video page, it should show 5 video articles.

How can I use contextual filters to achieve this? I don't want to install a separate module to achieve this.


texts: WYSIWYG editor not actually able to make use of all its tools

texts:
I've enabled my WYSIWYG editor for my authors on my site so that it uses filtered HTML format (using better formats module to ensure they use that text format).

However, while testing I note that when I use the WYSIWYG editor to input content, like new lines, tables, etc...the formatting doesn't actually 'take'. Certain things like links get set ok and bolded items...but not all the tools available in the CK editor WYSIWYG are showing correctly when the item is unpublished or published. When I go back to edit the item the HTML is all still there...but for some reason it doesn't display as if it's using the HTMl.

Thoughts on this?


texts: Given a field for Content Profile for a user, how can I extract that field via code?

texts:
I have a location field for a user that is created via the Content Profile module.

How can I access that field in code for the logged in user? Is it something like $user->content_profile['location']

I can't seem to grab this info.


texts:
What are the difference? And when should you use which one?

entity_uri() is rather new to me (Drupal 7) and I see it little used. But it appears to be a lot cleaner and better performing then drupal_get_path_alias().

FYI: I want to get some background information to deal with an issue on Tagadelic.


texts:
I'm a new Drupal dev trying to get a form to work the way the client's current form works. As it is now, the client has a form on their site that submits to a different site that processes the form data. For clarity, the action attribute on the form tag is set to a specific URL where the form data is processed.

We're rebuilding the client's site in Drupal and I've got the form built on their site using the Webform module. I tried simply setting the redirection location to the other site. As you would expect, the form submits, then redirects to the other page, but none of the data goes to the other site.

After reading suggestions, I installed and enabled the Remote Post module. On the form, I added the processing URL as the Target URL and left the Redirection Location alone (so its still the processing URL). When I submit the form, it redirects to the processing URL, but again none of the data is there.

I've tried removing the Redirection Location URL, but then the form simply submits and takes me to a  "Thank You" page.

I've tried snippets of supposedly working code to no avail. This one would be fine for our purposes since Drupal doesn't need to record or process any of the form data, just send it over to the other site. When I put these code snippets into my template.php (and customize them for our usage), nothing with the form or submission behavior changes, but I may have just typed something in incorrectly.

Webform - Submit values from Drupal 7 from to external url

This is literally the last thing I have to work on for this site and any help I can get would be appreciated!


texts: How does one theme a panel (or add a style)

texts:
I'm using drupal 7 and panels 3.

I'm looking for a good tutorial, or tutorial video that describes how to them panels. I understand generally hoe to theme nodes and them fields using the template files, but I don't really understand how to theme panels. I see that within the layout designer, it allows you to add a "style" to your panel panes. I understand this is probably theme based, but how would one add another style to this.

Any help would be great.

Thanks

P.S. I did do a search already for this info but was unable to find any really good info.


texts: How can I check the changes for the fields at form alter submit?

texts:
I am using hook_form_alter() with custom submit handler ().
At submit I want to check if there is any change in the content except node->expire then my custom code will run.

but at $form_state['value'] I am also getting: nid, vid, uid, created changed etc.
and I have field type as taxonomy term reference and media files.

I do not want to  hard-code the fields name as admin may add new fields later on.


texts: Remove the URL aliases that don't have a node

texts: I have been importing a lot of data using feeds, then deleting all imported items again when there were problems with the import. Unfortunately, the URL aliases for the pages do not seem to be deleted, so they are related to nodes that no longer exist. Is there any way to remove them, other than going through by hand?


texts: Contextual filter for an indirect taxonomy term?

texts:
I know how to display similarly tagged items of a different content type in a view block (here is a good explanation and settings picture).

I have a scenario where the term IDs aren't directly associated with both content types. The term reference field on the page content type is attached, not to the view content type itself, but to another taxonomy that is attached to the view content type (the view content type uses a taxonomy that has a field which is also used in the page content type).

How can I filter my view to items that are "mapped to" the term?


texts: How to access "add a card" page in Commerce Card on File?

texts:
I would like to allow users to add a "card on file" outside of the payment workflow. I have authorize.net configured and I'm able to save a "card on file" during order completion. The cards list view appears correctly at the path user/1/cards:

This path is provided by commerce_cardonfile's implementation of hook_menu():

$items['user/%user/cards/add'] = array(

So logged in as user 1, I should be able to add a card from the page at the path  user/1/cards/add

But I get "Access denied"... How can I access a form to add a card outside of the payment workflow?


texts: What happened to the links to import or export a View?

texts:
In Drupal version 7, within the overview of all Views available in a site (located at "admin/structure/views"), for each view there are these options (links) at the very right after each view:

Enable (if view is disabled) or Disable (if view enabled).
Edit.
Delete.
Clone.
Export.

And near the top there is also an "import" link.

However, in Drupal version 8, on the equivalent page (also at "admin/structure/views"), there is no more link like export or import.

So what happened to importing/exporting of a view in D8?


texts:
I am using Newsletter module to send newsletter to all my registered users. I have created 2 lists 1.Blog and 2. Project (Have created templates for them as well). My questions are;

How to send only projects node in the project's list? (Does the fields in the templates are enough?)
The test mail just sends the [node: title] like tokens. What should I add to mail the contents of the node?

Thanks


texts: Menu doesnt appear on custom 'not found' page

texts:
On my site I have configured things so that the home page will appear if the URL doesnt exist.
(ie in admin/settings/error-reporting I set a replacement page for the 404 page.)

The problem is that the menu doesnt appear, so if a user lands here he cant use the site properly.

My menu is the 'primary menu' and has been placed in the left sidebar. I dont have any special setting for this block - eg no page 'includes' or 'excludes'.

To help me debug can anyone tell me if this is the expected behaviour or any suggestions for what might have gone wrong?

I'm using Drupal 6.


texts:
I have a problem with my module that only creates a form to submit a validation.
The target of this module is to set a variable that I put in a textfield.
The problem is that it doesn't save the variable, it only shows the default value. (I use variable_set and variable_get)

This variable is necessary because I use this form in another module that get this variable from the database. (My variable is id_event)

This is my code of my own module:

<?php
function example_form_form1(){
    $form['id_event'] = array(
     '#type' => 'textfield',
     '#title' => t('Id Event'),
     '#required' => TRUE,
         '#value' => variable_get('id_event', 7), //Here is my dude
    );

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

function example_form_submit($form, $form_state){
    $id_event = $form_state['values']['id_event'];
        variable_set('id_event', $id_event);//here is my dude
        drupal_set_message($id_event);
}
?>

Now, this variable is necesary for other module that only get.

<?php
$file_json = $this->options['xml_file'].variable_get('id_event', 1);
//Here don't get the value that i put, only put the value for default.
?>

Thanks :D


texts: Deleting User Picture changes the password of user?

texts:
I have used following code to delete the user picture on click of a form button element (using #ajax).

function delete_user_picture($form, &$form_state){
  global $user;
  $account = user_load($user->uid);
  unset($account->picture);
  $edit = (array) $account;
  user_save($user, $edit);
}

This successfully deletes the picture but also changes the password. How can I prevent it from doing so?

UPDATE:
Based on Molot's Suggestion, I made the following change to code and now it works perfectly:

function profile_delete_user_picture($form, &$form_state){
  global $user;
  $account = user_load($user->uid);
  $file = file_load($account->picture->fid);
  unset($account->picture);
  $edit = array();
  //add just the picture info and not the whole account info and password won't be changed
  $edit['picture'] = $account->picture;
  user_save($user, $edit);
  if ($file != NULL) {
    file_delete($file);
  }
}

Also added code to delete the file from database as per SlakeFistcrunch's Suggestion.


texts: Force user to fill in at least text area or file

texts:
A registered user is creating a node with a body and file field. I want to force the user to either fill the body with 300 chars or select a file. At least one needs to be selected/filled.

How can I do it?
Can I do this using the Rules module?


texts: computed field with product variation and content type

texts:
Using Commerce Kickstart 2 distribution :

Question 1: Where should the computed field go to access fields from both the Content Type and Product Variation? Does the computed field belong to the content type or to the product variation?

Question 2: How do you reference one from the other?

ie - I thought...

$field_my_gauge = field_get_items($entity_type, $entity, 'field_needle_guage');
$field_my_type = field_get_items($entity_type, $entity, 'field_needle_type');
$field_my_st = field_get_items($entity_type, $entity, 'field_needle_style');
$field_my_len = field_get_items($entity_type, $entity, 'field_needle_length');
$vari_l = taxonomy_term_load($field_my_len[0]['tid']);
$vari_g = taxonomy_term_load($field_my_gauge[0]['tid']);
$vari_t = taxonomy_term_load($field_my_type[0]['tid']);
$vari_s = taxonomy_term_load($field_my_st[0]['tid']);
$vari_result =  $vari_l->name . $vari_g->name . $vari_t->name . $vari_s->name;
$vari_result = preg_replace('/[\s,.]{1,}/', '', $vari_result);
$entity_field[0]['value'] = $vari_result;

buuuut...

Notice: Trying to get property of non-object in eval() (line 9 of /Users/Robert/Sites/devdesktop/country_yarns/modules/computed_field/computed_field.module(468) : eval()'d code).

$vari_g is, or should, be based on the field_needle_guage field. But this is in the product variation of Needle, and not in the content type of Needle. All other fields are in the content type and work correctly.

So what's the right way to access members of a product variation in the content type - or is that even the right way around? (See Q1)

[EDIT]

Ok, so looking at the objects available in the wrapper:

$wrapper = entity_metadata_wrapper($entity_type, $entity);
// field_product_node is documented as the automatically created backreference to the content type.
$product = $wrapper->field_product_node;

// DrupalCommerce Kickstart 2 documentation says the below should work, but it does not - 'error: can't find getProduct function'. (WHY?)
$wrapper->getProduct();

// This comes out as an EntityDrupalWrapper
dpm($wrapper);
// This comes out as an EntityListWrapper
dpm($product);

// but below fails - can't find getIterator on object (WHY??)
$plist = $product->getIterator();
// and below returns an empty array!
$plitems = $product->value();

So all these auto-back-reference class things in DrupalContrib are not accessible in this manner, it seems. If they work, I'd love to find out how!

Looking at how the tables are set up: field_revision_field_product is the link table between 'commerce_product' 'commerce_product_revision' and 'node', and any particular field_data_field_XXX field data table.

So I guess I need to use a sql query to get the field_data_field_XXX value through an inner join. I guess I'll need to put that into a custom module and then make a field of that type that allows you to configure what field to grab from the CT


texts:
I would like to use the active trail menu as url path by altering pathauto?

Can this be performed?


texts: How to call a view in a twig.template not page

texts:
I don't find good info on how to call for an existing view
in a particular twig.template (NOT the PAGE.HTML.TWIG!!!!).

The systemname of my view is this: testfeest

So I find sollutions online and tried them:

{{ testfeest }} not working
{{ content.testfeest }} not working
{{ view.testfeest }} also not working

Keep in mind that:

I don't want to create a extra block of region for this
The view will be placed not in the page template but a node template

Hope somebody can help me...
Thanks for reading.
Kristof


texts: how can i add another textbox in link module in drupal 7

texts: I have an article content type with author name. I can add a link field to the article with the use of the link module. I also show the author name of the article without a link. How is it possible to do this through the link module?


texts: How to trigger an action when a site receives an email?

texts:
In Drupal 7, is it possible for users to send an email to a website, which will trigger an action?

For example, the user sends an email to offers@mydrupalsite.com. The Drupal site receives this and then sends the user an email with a PDF attachment.

I've searched extensively; however, the nature of the query means that it usually turns up relevant results.


texts: Is there a way to add a unique view to a dynamic field in Display Suite

texts:
I am using Display Suite 7.x-2.6 and have created a Dynamic Field for my  content-type. I have seven (7) unique items of that content-type. I configured Full Content to use "Dynamic Right Column" on the right side of a static two-column layout.

I would like to add a unique view for each "Dynamic Right Column" Is this possible? OR Should I use a Custom Code Field for this kind of functionality instead of Dynamic Field?

Using Display Suite Extras does not make each of my content-type items unique. I can't add a unique view/block/piece of content to each. I do not have Page Manager enabled.


texts:
Is there a way to add an extra class to the View content wrapper, which outputs as <div class="view-content">?

To make it clear: I use Semantic views to generate a nice UL for a slider, but I am not able to add a wrapper with the proper class name to trigger the Jquery.


texts: Instructions to install a ready-made site in localhost

texts:
I am trying to install a ready-made instructional site on my local Linux webserver.
How should I proceed?

Thank you J.Reynolds for answer.

Please understand that after I posted question I did some homework and read the article you mention, that is why I am editing question.

mod-rewrite is enabled and so is AllowOverride, the site is correctly chowned and I opened the perms to 777 to get it going, I will correct that later.

I imported the db and edited settings.php to "glue" files and db, basically I replicated the settings of another settings.php file from a site that I created from scratch and virtualized same as this one, the differences are only the site customizations of course.

I entered correct $base_url.

The site is still failing and here is the error message:

  "The specified file temporary://fileK7hduG could not be copied,
  because the destination directory is not properly configured. This may
  be caused by a problem with file or directory permissions. More
  information is available in the system log."

This message keeps repeating for 6 times with different temp files.
I looked at the apache2 log and there is nothing useful there.
I cannot figure out how to launch this site correctly.


texts:
I have a list of ~2500 pages that I need to get canonical urls for from an old D6 site.  The site uses Path_Redirect.

Using mysql queries I can get a list of nids for the pages I want, but I'm having trouble connecting the nids to the most current path alias.  Little help?


texts: Read only version of node form for anonymous users?

texts:
Use case: a site that accepts applications for courses. Users need to register first before they can create an application (for security, spam etc.) - however the registration process might put them off; can anyone suggest a way to preview the form?

Requests to '/node/add/application' obviously get Access Denied when not logged in, because Anonymous Users don't have the "Application: Create new content" permission.


texts: formBuilder()->getForm() outputs everything except the  tag in a view?

texts:
When displaying my entity edit form with \Drupal::formBuilder()->getForm($form); (for a flagging attached to a node) in a View that is set to show Content with the Default display, I noticed the <form> tag itself is missing:
<form class="flagging-myflag-edit-form flagging-form" data-drupal-selector="flagging-myflag-edit-form-iq8dn9lwifq" action="/flag/details/edit/MYFLAG/52" method="post" id="myform-myflag-edit-form--iq8dn9lWIfQ" accept-charset="UTF-8">
Everything between the form tags is printed properly.
</form>

The <form> tag appears on the node page correctly, but it does not appear in the view.
So somehow, Views is filtering out the <form> tag, but I need to keep this tag.
This is the code I am using:
function MYMODULE_node_view(array &$build, NodeInterface $node, EntityViewDisplayInterface $display, $view_mode) {
  if ($node->getType() == 'MY_CONTENT_YTPE') {
    if ($display->getComponent('my_flagging_form')) {
      $flag = \Drupal::service('flag')->getFlagById('MY_FLAG');
      $flagging_entity = \Drupal::service('flag')->getFlagging($flag, $node);
      $form = \Drupal::service('entity.manager')
        ->getFormObject('flagging', 'edit')
        ->setEntity($flagging_entity);
      $build['my_flagging_form'] = \Drupal::formBuilder()->getForm($form);
    }
  }
}

According to twig debugging, the custom form is being output through core/modules/system/templates/form.html.twig, but there's no form tag when output by Views (the tag does appear on the node page).
This is form.html.twig:
<form{{ attributes }}>
  {{ children }}
</form>

EDIT: I tried to render it based on the comment of @Ales:
  $form = \Drupal::service('entity.manager')
    ->getFormObject('flagging', 'edit')
    ->setEntity($flagging_entity);
  $form_to_render = \Drupal::formBuilder()->getForm($form);
  $renderer = \Drupal::service('renderer');
  $build['remember_form']['#markup'] = $renderer->render($form_to_render);

This gives me the same output as my original code; the form is there, but the <form> tag is not...
EDIT 2: I also tried using template_node_preprocess() instead of hook_node_view():
function MYTHEME_preprocess_node__MY_CONTENT_TYPE(&$variables) {
  $node = $variables['node'];
  $flag = \Drupal::service('flag')->getFlagById('MY_FLAG');
  $flagging_entity = \Drupal::service('flag')->getFlagging($flag, $node);
  $form = \Drupal::service('entity.manager')
    ->getFormObject('flagging', 'edit')
    ->setEntity($flagging_entity);
  $form_to_render = \Drupal::formBuilder()->getForm($form);
  $variables['MY_FLAG_form'] = $form_to_render;
}

But when I rendered this variable in my theme template, I got the same result-- the <form> tag appears on the node page, but not in the view that shows Content with mode full content.


texts: How to add term programmatically in Paragraph field?

texts:
I have a paragraph with a taxonomy reference (autocomplete) field and I want to populate it when I create programmatically a pararagraph item.
I checked the option "Create referenced entities if they do not already exist" in this field.

I use this code, but I don't know how to find more informations to do that without Term::create (if it's possible) :

use Drupal\node\Entity\Node;
use Drupal\paragraphs\Entity\Paragraph;

        foreach ($field_value as $creator_type => $creator_name) {

            $paragraph = Paragraph::create(['type' => '_zotero_ref_creators']);
            //text field
            $paragraph->set('field_nom_prenom_createur', $creator_name);
            //taxo reference field
            $paragraph->set('field_type_createurs', $creator_type);

            //$paragraph->isNew();
            $paragraph->save();

            $paragraphn_field_value = array(
              'target_id' => $paragraph->id(),
              'target_revision_id' => $paragraph->getRevisionId(),
            );

            $node_reference->set('field_liste_contrib', $paragraphn_field_value);
          }


texts: Display Suite vs. EVA for displaying a view as field

texts:
I want to display a specific view as a field in nodes. It’s the same view for all nodes of this type, making use of the contextual filter "Content ID from URL".

I found two solutions using contributed modules:

EVA: Entity Views Attachment: it’s specifically for this use case
(there is also Viewfield, but that’s still in alpha)
Display Suite: it’s not its primary use case, but makes it possible by adding a "block field", where you can select the block generated by the view

Assuming that Display Suite is installed anyway (installing it just for this use case would be overkill, I guess), is one solution better than the other? Both seem to work fine, but I’m thinking of possible issues I can’t foresee now, like performance impact or compatibility with the Drupal ecosystem.


texts: Drupal 7 errors after upgrading from 7.12 to 7.14

texts:
I just updated my drupal version from 7.12 to 7.14 and now I get these errors when trying to update/edit a content type:

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in _form_set_class() (line 4134 of /var/www/vhosts/xxx/public_html/includes/form.inc).

Warning: implode() [function.implode]: Invalid arguments passed in theme_radios() (line 2809 of /var/www/vhosts/xxx/public_html/includes/form.inc).

An illegal choice has been detected. Please contact the site administrator.

Please note that this is happening when I edit the node not the actual content type definition. But only for this one particular content type. All the other work fine still.

If it's at all helpful here are the fields for that content type:

Title - title - Node module element

Photo - field_photo_image - Image - Image

Vote - field_photo_vote - Fivestar Rating - Stars (rated while viewing)

Domain access - domain - Domain Access settings.

Description - field_photo_description - Long text - Text area (multiple rows)

Author - field_photo_author Text - Text field

Admin selected - field_photo_winner - Boolean - Single on/off checkbox

Any help would be much appreciated.

C


texts: What is the most drupal-like way to bring the title of a single node page into the rest of the content?

texts:
This is similar to Considerations displaying page titles in page or node template which in turn claims to be similar to another question, but the questioner doesn't mention how they achieve what they are doing, and what they are doing may be different from what I'm doing.

In my case, on single node view pages, for certain (most) content-types, there is an optional image field, that needs to be floated left of the title.

I'm not sure if it would be best practice to move the title output down into the node.tpl.php template or to keep it in the page.tpl.php template and load the relevant field for the node in the page template.

This is what I've done:

template.php:

function enviroscope_preprocess_page(&$variables, $hook) {
  if (isset($variables['node']->field_doc_cover)) {
    $node = node_load($variables['node']->nid);
    $output = field_view_field('node', $node, 'field_doc_cover', array('label' => 'hidden'));
    $variables['field_doc_cover'] = $output;
  }
}

page.tpl.php:

<?php print render($title_prefix); ?>
<?php if ($title): print render($field_doc_cover); ?>
<?php print $title; ?>
<?php endif; ?>
<?php print render($title_suffix); ?>

This gets the image field printed before the title, but I'm not sure if there is an equivalent here to hide($content['field_doc_cover']);?  Currently this has field_doc_cover printing twice.

So the main question is,

  Is this the right approach?

but this breaks down into some more specific questions:

Should the title definition stay in page.tpl.php for single node pages?

If so, is there a good way to exclude the field_doc_cover field from being rendered in the node.tpl.php file without messing with that template too?

Is there a good reason not to handle the title in the node.tpl.php, and remove it from the page.tpl.php file for these content_types?

If there is a good reason for it to not be in nodes, would it be sensible to render the element in page.tpl.php and send it as a variable to be used in node.tpl.php?

I'm pretty new to drupal theming as is probably obvious, so examples with your answers would be very helpful!

Update: I was asked to create a visual representation of what I'm trying to do, which was a good call because it reminded me of one more issue: The last modified date should be printed above and to the right of the title.

I guess one of the main things I don't understand is whether there is some good reason why the title needs to be part of the page.tpl.php template.  It sure would be easier if it were down in the node template.


texts: Inserting tokens into a text field, such as body

texts:
For many years I've used the excellent token filter module. However, viewing development activity on the module, (Seeking co-maintainers, Maintenance fixes only, and last updates are over a year ago) suggests that this module's future may not so bright. Which, in turn, suggests that there is another or better way of achieving similar functionality? For example, I commonly use token filter to construct the current year for the copyright mark. Other examples include referencing the site email or slogan.

What's the best "future-proof" method for inserting token-like content into text fields?


texts: How do I exclude a single menu item from the home page?

texts: I have a menu that displays on every page, and the top link for that menu is the "Home" link.  The clients do not want this menu item to appear when a user is viewing the home page, but wish it to be there at all other times.  How can this be accomplished?  There's no way I see to set an excluded page for menu item links.


texts:
I am using the latest version of Drupal 7 and my webserver is Nginx. I checked the status report and it says:

  Upload progress Not enabled
  Your server is not capable of displaying file upload progress. File upload progress requires an Apache server running PHP with mod_php.

How can I fix that problem?


texts:
What should the dynamic query for the following SQL string be?
SELECT p.id, p.name, GROUP_CONCAT(s.name) AS site_list
FROM sites s
INNER JOIN publications p ON(s.id = p.site_id)
GROUP BY p.id;


texts:
At this url:

/admin/config/media/file-system

There is a setting:

Delete temporary files after X hours

Does this specifically refer to files in /tmp ? Or whatever I set as my temporary folder? Or will it possibly delete "unused" files?

I ask, because I use file_save_data to save files. And I'm worried that Drupal at some points decides to delete some of these files, as they won't be referenced anywhere except in my own custom table.


texts: Want to modify drupal default pager functionality

texts:
I am creating a page with teaser of articles using views... In the Full pager, the default functionality is....

1 2 3 4 ... next >

when i click next now the next number gets highlightd like...

< prev ... 1 2 3 4 ... next >

and now when i again click next...

< prev ... 2 3 4 5  ... next >

the number set gets altered...

But what i actually need is...

1 2 3 4 next >

< prev  1 2 3 4  next >

< prev  1 2 3 4  next >

< prev  1 2 3 4  next >

and now when i click next...

< prev 5 6 7 8 next >

There are some modules like PAGERER to change the appearance of the core pager... But is there any to make this functionality or should I do some custom work...


texts: How to limit number of files uploaded with plupload integrtion module?

texts:
I'm using Plupload integration module. In my Form API form I want to use it as simple replacement for file element. However, both file and managed_file types accept one file. plupload accepts any number of files. How to limit it to only defined number of files? Or simply one?

Setting cardinality as FileField Sources Plupload does:

'#plupload_settings' => array(
  'cardinality' => 1,

does not work, and I wasn't able to find any other parameter for this.


texts:
When you make a copy of one of  displays of a view the new display is given a name like Page 2. How do you rename that display? I can't seem to find a way of renaming the pge but I suspect there must be a link to edit it.

I have done it before and wonder whether some module or CSS change may be occluding the link required to change it.


texts: Node select list + dropdown + view of entity references

texts:
In a content type, and a field is an entity reference to another content type (the professionals companies).

I created a view, to display: first: the professionals flagged as favorite; then all the others.

Then comes my problem:

How can I create a selection of professionals like this:

If user click on the "empty" field (empty before selecting): the list of favorites appears (this can be the first 10 of my view)
the user can type and like autocomplete, the results are shown.
if no favorite found, then comes a text (with link) to add node (create a new professional).

In the widget type of the entity reference:

I tried "autocomplete" but the 1. doesn't work (user is obliged to type before something shows)
I tried "view" but it's even worse (and the search is difficult)
I tried "select list" but it doesn't allow to search.

I forgot to specify:
The 3 options should be on the same field.
So, when user click on the field to select (the company), the behavior of the field to select the garage should be like this:

User clicks on it: user's favorites companies appears (through view)
If the company he wants was not flagged as favorite, he can start to type in the field and the results appears (classic behavior in Drupal).
If the name of the company he types doesn't exist, the field shows "no result" and show a link to create a company.


texts:
I have the content type of "Front Page Section" where there are the fields "body" and "field_home_section_photo".

On the home page (page--front.tpl.php) I would like to be able to print the body and image fields separately for particular nodes with their formatting in place:

Print Node 42 Body

Print Node 42 Image

Print Node 43 Body

Print Node 43 Image

Print Node 44 Body

Print Node 45 Image


texts:
i want to limit node reference (autocomplete widget) based on one of CCK field on current node. So, i made view to limit results and in argument->Provide default argument->PHP Code.
And write code like this:

$mynode = node_load(arg(1));
return $mynode->field_foo[0]['nid'];

But problem is in that arg(1) is not returning NID of current page but string 'autocomplete' (i guess it is name of function).
(Didn't had luck with menu_get_object() either)

So how can i get NID of current node other than using ARG() in views custom PHP argument?

Can i reference directly on CCK field (yes, as I sad it is on samo page as autocomplete text-field)?

Thanks for help.

UPDATE:
This is specific to autocomplete widget.

It works well with other widget types (select list, checkbox...)


texts: I want alter $node_url in node.tpl.php inside a module not in node.tpl.php, which hook should I use?


texts:
I installed Pressflow on my Drupal 6 website by replacing core files. I only kept .htaccess, robots.txt and sites folder.

After that I got a lot of PHP errors, even after I change php.ini's error reporting.

So I checked Apache logs.

I had APC running on my site already and I noticed the following error happening frequently:

[apc-warning] Unable to allocate memory for pool.

It disappeared after I change APC memory to 16MB (it was 30MB) and restart Apache.

Although I can now load a few pages, I'm getting a white screen when trying to load home page and some other pages. Also, some regions of the page aren't showing up properly.

I tried clearing cache too.

Is there anything I'm missing?


texts: user empties cart how do I redirect that user to originating page

texts:
I have a rule

  Redirect to cart after adding a registration

this rule works exactly as planned.

New scenario and new rule, If the user empties their cart of all products, I want to redirect to previous page (the sending page).

New rule

  Redirect user to originating page after removing all items from cart

I have the Event and the Conditions but I don't see how to massage the originating address that was used to get to the cart. The originating form action is <input type="submit" id="edit-submit" name="op" value="Add to cart" class="form-submit">.

{ "rules_redirect_user_to_originating_page_after_removing_all_items" : {
    "LABEL" : "Redirect user to originating page after removing all items from cart",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Cart" ],
    "REQUIRES" : [ "rules", "commerce_cart" ],
    "ON" : { "commerce_cart_product_remove" : [] },
    "IF" : [ { "data_is_empty" : { "data" : [ "quantity" ] } } ],
    "DO" : []
  }
}

Can anyone help?


texts: make the sidebars and the "content" region the same length as each-other?

texts:
I have a website that has regions that are uneven. the sidebar first is a different length than the content, and the content is a different length that sidebar second. it looks something like this:

I could fix it manually in the css and make them the same length, but then any time I add something to any of them, it becomes uneven again. is there any way (or any module) to fix it so that it will dynamically stay the same length, so that when I add something to the content, and it becomes longer that the sidebars, they will fill with white-space and become the same length as the longest content?


texts: What is the correct way to exclude certain CSS files for anonymous, but include for authenticated users?

texts:
We have a subtheme, mytheme that is based off of the classy base theme. We have set Aggregate CSS Files = true and when the pages load we end up with many aggregated CSS files.

One issue is that we don't need all the CSS for anonymous users, only authenticated users since most of them are for logged in users.

How would I only add the following CSS for only authenticated users, but not anonymous users using the mytheme.libraries.yml?

Goal:

We do not want to override anything in those libraries, but rather remove them all together from render based on if the user is authenticated or not.

CSS files included in local development:

<styles media="all">
@import url("/core/themes/classy/css/components/progress.css?pe4tq3");
@import url("/core/themes/classy/css/components/dialog.css?pe4tq3");
@import url("/core/themes/classy/css/components/action-links.css?pe4tq3");
@import url("/core/themes/classy/css/components/button.css?pe4tq3");
@import url("/core/themes/classy/css/components/collapse-processed.css?pe4tq3");
@import url("/core/themes/classy/css/components/container-inline.css?pe4tq3");
@import url("/core/themes/classy/css/components/details.css?pe4tq3");
@import url("/core/themes/classy/css/components/exposed-filters.css?pe4tq3");
@import url("/core/themes/classy/css/components/field.css?pe4tq3");
@import url("/core/themes/classy/css/components/form.css?pe4tq3");
@import url("/core/themes/classy/css/components/icons.css?pe4tq3");
@import url("/core/themes/classy/css/components/inline-form.css?pe4tq3");
@import url("/core/themes/classy/css/components/item-list.css?pe4tq3");
@import url("/core/themes/classy/css/components/link.css?pe4tq3");
@import url("/core/themes/classy/css/components/links.css?pe4tq3");
@import url("/core/themes/classy/css/components/more-link.css?pe4tq3");
@import url("/core/themes/classy/css/components/pager.css?pe4tq3");
@import url("/core/themes/classy/css/components/tabledrag.css?pe4tq3");
@import url("/core/themes/classy/css/components/tableselect.css?pe4tq3");
@import url("/core/themes/classy/css/components/tablesort.css?pe4tq3");
@import url("/core/themes/classy/css/components/textarea.css?pe4tq3");
@import url("/core/themes/classy/css/components/ui-dialog.css?pe4tq3");
@import url("/core/themes/classy/css/components/messages.css?pe4tq3");
</styles>

We initially thought to do the following in the mytheme.info.yml file, but that would mean we have to exclude every single CSS manually (line by line).

name: 'mytheme'
type: theme
base theme: classy
package: custom
core: 8.x
libraries:
  - mytheme/library1
stylesheets-remove:
  - core/assets/vendor/normalize-css/normalize.css


texts: How to attach a date field from another entity to a new form

texts:
I am attaching a few fields from the user entity to a custom form with the following:

$account = user_load($user->uid);
foreach ($fields_to_collect as $field) {
  field_attach_form('user', $account, $form, $form_state, NULL, [
    'field_name' => $field
  ]);
}

This works fine except for date fields (I am using the date_popup widget but I haven't yet narrowed that down as responsible).  Attaching a date field results in the following error: Warning: implode(): Invalid arguments passed in date_limit_format() (line 2262 of sites/all/modules/date/date_api/date_api.module).  The date field is just shown as a text field with the text Format shown as a description.

The error is due to $granularity being NULL.  On, for example, the user account edit page which has this field, $granularity is something like:

[
  'month',
  'day',
  'year'
]

Thanks for any help/suggestions.