texts: How can I rebuild node / view cache based on the contents of an entityqueue

texts:
I have

Content types:

front_banner
news

Entity Queues:

front_banner -> only ever contains one front_banner node
news -> contains multiple news nodes

Views:

front_banner -> displays rendered nodes (default)
news -> displays rendered nodes (teaser)

The front banner content type has a field in it that determines whether the text colour should be light or dark when display (sets a class in the twig template, works fine).  The news content type also makes use of the front_banner's overlay style field like so:

function mymodule_preprocess_node(array &$vars) {
  if ($vars['node']->bundle() == 'news'){

    // Set the overlay class (dark/light).
    $entity_subqueue = \Drupal::entityManager()->getStorage('entity_subqueue')->load('front_banner');
    $items = $entity_subqueue->get('items')->getValue();
    $front_node = node_load($items[0]['target_id']);
    $vars['overlay_class'] = $front_node->get('field_overlay_style')->getString();
  }
}

All of this works perfectly well, my problem occurs when I alter the front_banner node or entityqueue: the cache is obviously not set to refresh for news items when that occurs.

1. Which render cache do I need to rebuild?

Is it the view cache? or the node's render cache? or both?

2. How can I do it?

I have tried creating my own cache tag and flushing it like so:

function mymodule_entity_presave(EntityInterface $entity) {
  $tags = ['entity_type:' . $entity->getEntityTypeId() . '.' . $entity->bundle()];
  Cache::invalidateTags($tags);
}

function mymodule_node_view_alter(array &$build, Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display) {
  if ($build['#node']->bundle() == 'news'){
    //dpm($build);
    $tags=['entity_type:node.front_page_banner', 'entity_subqueue:front_banner'];
    $build['#node']->addCacheTags($tags);
  }
}

(entity_subqueue:front_banner tag is provided by the entityqueue module)

I cannot get the news node page itself to change the overlay style, nor can I get the view that displays news nodes to change the overlay style when the front_banner node is saved.

[Edit 1:] I looked into Views Custom Cache Tags - this does allow me to state which tags I want to affect the views cache - I tried putting the two relevant tags in my view to no effect.  Perhaps this means it's the node cache that is giving me grief?


texts: Custom block template PHP page, possible to make content editable in UI?

texts:
I have custom PHP files for a few blocks, e.g., /sites/all/themes/at-commerce/templates/block--block-10.tpl.php

Is it possible to make this content editable using the block editing UI mechanism in Drupal administration, so the customer can make changes him/herself?

For example, customer visits URL admin/structure/block/manage/block/10/configure and can edit the content.


texts: Get all related sister (same content type) nodes through a view in Drupal 7

texts:
On my node detail page, I am hoping to show all the related nodes through a view which have the same taxonomy term(s) selected.

How can I make sure to get the related nodes on the node detail page (Note:- I don't have taxonomy term in the URL )

Thanks.


texts:
I am trying to migrate Drupal 7 site to Drupal 8. Other migration processes work well, but only file migration fails.

I have files in sites/default/files/.

This is my migrate_plus.migration.upgrade_d7_file.yml

uuid: c6ddfa39-c76a-4457-ba30-8db364387f45
langcode: en
status: true
dependencies:
  module:
    - file
id: upgrade_d7_file
migration_tags:
  - Drupal 7
label: Files
source:
  plugin: d7_file
process:
  fid: fid
  uid: uid
  filename: filename
  uri: uri
  filemime: filemime
  status: status
  created: timestamp
  changed: timestamp
destination:
  plugin: entity:file
  source_path_property: filepath
  urlencode: true
migration_dependencies:
  required: {  }
  optional: {  }

And, I execute it with this drush command:

drush8 migrate-import upgrade_d7_file

This process returns this error message:

Processed 446 items (0 created, 0 updated, 446 failed, 0 ignored) - done with 'upgrade_d7_file'

What am I doing wrong here?


texts: The "migration" entity type does not exist." error after switching site file structure

texts:
I am working on D6->D8 migration. We initially stared the site out using the [drupal-project](https://github.com/drupal-composer/drupal-project template), and I had my migration working. However, the site is hosted on Acquia, and Acquia requires a different file structure, so to get started, I spun up a D8 site on the Acquia free tier, and cloned that repo to my local. I got all my contrib modules and themes installed via Composer, and installed our custom modules, including my migration module. However, I am unable to bring up my site or even run a drush command (including trying to uninstall/install my migration module) because I get the following error:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "migration" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 133 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).

I have removed the migration configuration records from the config table and run a cache rebuild, but to no avail. I've also tried to run the drush migrate-upgrade --configure-only command, but I get this error:

Argument 3 passed to migrate_plus_migrate_prepare_row() must be an instance of Drupal\migrate\Entity\MigrationInterface, instance of    [error]
Drupal\migrate\Plugin\Migration given migrate_plus.module:66

How do I get around this?

Thanks.


texts: How do I get block relationships for a content type?

texts:
As part of a migration from drupal 7 to drupal 8, I currently have a rather original node display method that I'm trying to reproduce to Drupal 8, but without success.
Currently on Drupal 7, this method is filled by a custom preprocess that I try to remove in favor of views / entity reference.

Here is the procedure:
I have a node type that contains tags (field_tags), with for example the vocabulary 'news' from the 'Users terms' term. And basic content (title, body...).
I would like, via an already existing block having a field tags and value 'news', recover all the nodes with the tag 'news'.

Recap of entities I have tried:

Node:
- title
- body
- field_tags / value: 'news' (reference to "User terms")

Views name 'flow':
- display: content
- contextual filter: 'Content: Has taxonomy term ID' > 'Display all results for the specified field'
& Content: Nid
- relationsips: nothing, because I can't add a entity reference to a block

Block name 'block flow' :
- title
- field_tags / value: 'news' (reference to "User terms")

I would like when I create a block type 'block flow' with 'news' tags, get all node type that containing the 'news' tag.

I can't get it working because the views relationships don't allow me to reference the field 'field_tags' from my block (only content or taxonomy available).
We have a theme preprocess who can do that but I would like to know if there is a workaround ou any contrib module doing that.

Why I don't create a block from the view? Because in our process, we don't give access to the views of our contributors.


texts:
I have a block which template I'm overriding with my own.

The title in it is displayed by the following code:

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

I just want to add some custom classes to the h2, but I can't figure out how to format it. I want to keep $title_attributes but I can't seem to be able to add my own classes if I do.

I tried:

    <h2 class="a-class" <?php print $title_attributes;?>><?php print $title; ?>

and:

    <h2<?php print $title_attributes .'a-class';?>><?php print $title; ?>

But neither did anything. My PHP is scrappy at best so it's probably just me who don't know how to write what I want. Can anyone help me?


texts: Clean URLs enabled but main-menu keeps replacing clean URL with ugly node/ URL

texts:
I have enabled clean URL's on my website and had a menu item in my main-menu that pointed to a View that had a URL alias set up for /ebook-register. I just removed that alias and assigned the same alias up to a page (content item). However now the menu item keeps getting set to node/2 instead of ebook-register. How can I get the menu to stop changing my clean URL into ugliness? If I manually navigate to localhost/ebook-register I get to the right page, and under URL aliases in the admin I can see the alias and confirmed it's pointing to the correct page, and the menu doesn't throw an error when I set ebook-register to the path so it's finding the alias.

It does give me the following message:

  The menu system stores system paths only, but will use the URL alias for display. ebook-register has been stored as node/2.

However, despite saying it will display the clean URL, clicking the link sends you to the ugly node/2 URL.

I am using Drupal 7 and have tried clearing the cache already.


texts: CCK ahah image upload working if admin, but not for others!

texts:
A content type have image field. When uploading image as admin, everything works fine. But If i logged in as a normal user, and click on upload , it gives error ahah http error alert!

Also found add another button also giving same error.

What could be the issue?


texts: hook_field_views_data() not picked up in mymodule.views.inc

texts:
I have implemented hook_field_views_data() in mymodule.views.inc but the hook is not picked up.

In mymodule.module I have the following code to define where mymodule.views.inc resides.

/**
 * Implements hook_views_api().
 */
function mymodule_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'mymodule') . '/views',
  );
}

Below is the code for views/mymodule.views.inc. And the problem is that if I try dumping out $field for example it seems like hook_field_views_data() is not picked up.

I tried to change mymodule_field_views_data() to mymodule_views_data, and that function is picked up. I tried this just to be sure that the file is included at all.

/**
 * Implements hook_field_views_data().
 */
function mymodule_field_views_data($field) {
  $data = field_views_field_default_views_data($field);

  // Add a handler for localities.
  foreach ($field['storage']['details']['sql'] as $type => $tables) {
    foreach ($tables as $table_name => $columns) {
      if (!isset($columns['locality'])) {
        continue;
      }

      $column_real_name = $columns['locality'];
      if (!isset($data[$table_name][$column_real_name]['filter'])) {
        continue;
      }

      $data[$table_name][$column_real_name]['filter']['handler'] = 'mymodule_views_handler_filter_locality';
    }
  }

  return $data;
}

mymodule.info

name = mymodule
description = Bla bla
core = 7.x

files[] = views/mymodule_views_handler_filter_locality.inc


texts:
I have node URL like:
http://url.com/program/category/app/

I would like to create view with path:
http://url.com/program/category/app/alternatives

Is this possible? When I use in Views. I tried
"/program/%/%/alternatives"
but this doesnt work, run node not my views.


texts: Custom image style is not honored on new content

texts:
On drupal 7 I created two new image styles. Now when I save new contents, I expect the new images to be saved in the new image styles as well but this does not happen. Images are only saved in the ordinary thumbnail, medium, large and square-thumbnail sizes.

How can I make the new image styles be honored?

Edit: So Mołot and Bala made it clear that a certain image style has to be called to generate an image of that style. Yet, I would like to call for a smaller image in the code, and then load a larger version for wider screens.

Is this possible?
Note: I am using ZEN as the theme.

Edit 2:

What I want to do is to load an initial small image like:

<img class="resp-image" src="very-small.jpg" />

Then, according to the screen size, I will replace the image with a larger version. This version of the image is provided by an image style:

if($(window).width() > 768) {
    $('.resp-image').attr('src', 'large.jpg');
});

The problem is, since I do not refer to large.jpg in the content type's display settings, it is not rendered to the given style and thus does not exist yet.

I was going to put this up as a new question but I found out that it is already discussed here and here.

Mołot's answer best described the situation referred to in the inital question. So I accepted it.


texts: How to set different cache mobile and desktop based on header HTTP for one URL?

texts:
Here is the problem we're facing :

I have one url : www.example.com/my-page with a different HTML footer for mobile and desktop.

To know which HTML to use we look for HTTP Headers sent by one CDN (Akamaï) => $_SERVER['HTTP_X_AKAMAI_DEVICE_CHARACTERISTICS'].

What we want to achieve is to have cache for both mobile and desktop based on that HTTP Header since the URL is the same. Is it possible ? And if yes, how to do it ?

Having both HTML in the DOM is not an option here, for performance reasons.

We played with contexts in the #cache array but no success here. Maybe with using tags, but not sure about how to use it.

Any help would be greatly appreciated.


texts: I am Unable to fetch the $form['select'] array in Views Bulk Operations

texts:
I am trying to use vbo_multipage_selection module to Select the Contents Created to Create a newsletter as the Views Bulk Operations currently doesn't support multipage selection.
This module works upon an array called $form['select'] which I think, stores the id of checkboxes / content selected by the user and is generated by Views Bulk Operations module after the user selects the contents but its not being generated, Are there any dependency issues or Is there any other way to use multipage selection.


texts: Where do I programmatically create new roles?

texts:
I want to programmatically create new roles in Drupal 8. I found this code in this post.

//your data array
$data = array('id' => 'client', 'label' => 'Client');
//creating your role
$role = \Drupal\user\Entity\Role::create($data);
//saving your role
$role->save();

But I don't know where I should put it, in which file, which folder? And how do I run it?


texts: How do I use views to override a taxonomy term page for only terms with a single vocabulary?

texts:
How do I configure a view to allow me override only term pages within a specific vocabulary without overriding all other term pages?

Edit: Due to the requirements of the project, this must be done with a view and not overridden with a custom tpl.


texts:
I'm using drupal 7 and i'm having some problems customizing the search results page. I have a form altered in template.php file where i have created my fields like this:

$form['basic']['keys']['search_string'] = array
      (
        '#prefix' => '
',
        '#suffix' => '
',
        '#type'=>'textfield',
      )

I also created a page search-results.tpl.php where i just wrote:

 dprint_r($search_results)

When i submit the form i get on /search/node and another form is displayed with the following error:

 Notice: Undefined index: keys in search_form_validate() (line 145 ..)Please enter some keywords.


texts: How to create node twig template suggestions for one content type?

texts:
I need to create a node twig template that is just for the basic page content type that based on a custom field on the content type. We have other content type like Article, Blog, Products that do not need these specific twig template.

How would we create twig templates based on the field_type so that it only applies to the basic page content type?

Here is what we tried, but couldn't find how we could detect for the basic page content type and the value for the field_type. We tried ksm($suggestions) and ksm($variables), but it does not print which implies that the hook isn't called even after clearing cache.

function mymodule_theme_suggestions_node_alter(array &$suggestions, array $variables) {
  // This is what we are looking for.
  $node_bundle = $node->bundle();
  if($node_bundle == 'page') {
    // we want something like this.
    $node_type_value = $node->field_type->value;
    $node_view_mode = $node->view_mode; // not sure what this would be.
    $suggestions[] = 'node__' . $node_bundle . '__' . $node_type_value
  }
}


texts: How can I pass a query string from the url to a hidden user form field?

texts:
I'm building a conference registration site in Drupal 8. I've set up a register link for a custom user role that includes a query string (/register?reg-id=custom-id) and would like to pass this value (custom-id) back to a hidden field when my form is displayed to my user so that I can have users that are of the same role but with varying reg-id depending what they signed up for.

Ideally I would like to set it up using the user fields available under account settings and not through the template settings as more than one template may be used in the future (on a per conference basis). Alternatively a module might work, but I can't seem to find a starting point for this in Drupal 8. As a side note the custom-id is generated from a taxonomy term field on the referring page - just in case there an option to feed the form the variable another way.

I have looked at the following, and numerous others, but they don't quite meet the requirements for my use case:
How to retrieve GET parameter in Twig template
https://www.drupal.org/project/userreference_url (seems ideal but not ported to D8)
How do I pass a value from the url to a custom field in the registration form? (for D7)

Any assistance would be greatly appreciated.


texts:
I want to get the node ID to load the nid fields.
How can I get the node ID from the current URL using this function?


texts: How to check if a menu exists programatically in Drupal 8

texts:
I have a script where I instantiate and fill menus with menu items programmatically.

Whats the best way to check if a menu already exists if I already know it's ID.


texts: How to stop CKEditor 3.6.3.7474 from stripping  tags

texts:
With Full HTML enabled and related filters off, CKEditor will strip any <script> tags from content it is editing.  The editors who create content for this particular site need to be able to embed things like this in the content they are creating:

    <img src="http://s2.thingpic.com/images/TD/zKWJQJiFBsp3oP1etNC1.png" width="560" class="alwaysThinglink"/>
<script charset="utf-8" src="//www.thinglink.com/jse/embed.js#286861458501795840"></script>

In theory we can make this work by disabling CKEditor and working directly with HTML, but in practice it doesn't work: the editors are not HTML-savvy.  They know enough to temporarily drop out of rich-text mode, paste in the above, and then switch back to rich-text mode.  But if they go to edit that content again, CKEditor strips the <script> tags when opening the content.

How can I stop that behavior and have CKEditor leave the <script> tags in place?  Is there a hidden setting somewhere for that?

BTW, we are using CKEditor in conjunction with Wysiwyg 7.x-2.1 module.

And yes, in general allowing <script> is very bad, but in this case the only people who have access to the Full HTML format are the editors (who are trusted).

Thanks!


texts: Views - Add a wrapper around fields or rows

texts:
Example:

I have a view with fields:

[field_name]    == Field collection item: Name
[field_title]   == Field collection item: Title
[field_text]    == Field collection item: Text

I can wrap these fields by excluding from display first two of them, and rewriting the output of the third field with tokens, for example:

[field_text]

[field_name] // [field_title]

It seems a bit tricky, so here is my first question:

Is there any module or just another way to wrap fields in views?

I know Semantic Views module which solve the problem, but there is no recommended releases for Drupal 7.

Question #2

All my fields are wrapped in their div like in above mentioned example, but this is only the one row, and I have several rows. I need wrap all of them in another div.

Do I have to create a view template file only for that? which contain for example:

<?php if($rows): ?>

        <?php print $rows; ?>

<?php endif; ?>

I have a feeling like I miss something when I have to create a special template file only for one wrapper.


texts: How can I get views_save_view($view) to return TRUE when using Drush?

texts:
I have a script that calls various views API functions, namely views_save_view() or $view->save().

When using Drush 5 to run the script, these functions return false. However, when I run these with cron while logged into Drupal through the config, it works fine and everything executes as normal.

How can I get these to return true while using Drush?

I have feeling this is a permissions issue, but can't figure out how to get Drush to execute with the permissions it needs. This is a follow up question to here:

How can I run Drush as user 1 in version 5?

Also there is a somewhat related issue here:

http://drupal.org/node/1515616#comment-6312604


texts:
Drupal 6 only:  I have a button field on a petition node for users to sign that petition. I have custom php in a rule to check if they've signed it before. If they have, I need to hide the button.

So I need php in an action to hide the button field.

(Using conditional fields according to the issue queue doesn't work with the button field)

Anyone know how to do this?  Help would be very much appreciated!


texts: Using hook_menu to add a child to a menu item

texts:
So I create a menu item called Sponsorship in administration in the following way:

function eac_sponsorship_menu() {
  $items['admin/sponsorship'] = array(
    'title' => 'Sponsorship',
    'description' => 'This is where all of the child sponnsorship data is stored',
    'page callback' => 'system_admin_menu_block_page',
    'file path' => drupal_get_path('module', 'system'),
    'file' => 'system.admin.inc',
    'access callback' => 'user_access',
    'access arguments' => array('access sponsorship section'),
    'plid' => 1,
    'weight' => -500,
    'expanded' => TRUE,
  );
    return $items;
}

If I want to create another menu item directly after this, in the same function, how do I make it a child to this previously defined 'Sponsorship' menu item?

I have seen examples that use a DB lookup to get the plid value. This seems a bit counter intuitive bearing in mind I've only just created the Sponsorship menu item, is there a simple way to do this using the API?

For example

$items['admin/sponsorship/child'] = array(
  'plid' => //simple API function to get admin/sponsorship mid?
}

Edit

I think I've just answered my own question...I don't need to define plid, the path of the array $items is enough:

$items['admin/sponsorship/child']

Is this correct?


texts: Categorize nodes outside of create/update form

texts:
I should add some new taxonomy reference fields to my Blog content type, but currently this content type has a lot of fields and a very complex UI.

I think it may help to let user categorize his post after inserting, outside of create and update forms.

Is there any module or configuration for this situation?


texts: X-Drupal-Cache is missing from HTTP headers

texts:
X-Drupal-Cache seems to be missing from HTTP headers. The funny thing is that, when I cleared my cookies, it reappears twice: once with a "MISS" and then with a "HIT". After that, X-Drupal-Cache disappears again.

Is this normal?


texts: custom "register" button on a form - problem with redirection

texts:
How to make a custom register button in the user login form (block) so that it redirects to 'user/register' ?

Currently, when I click my custom "Register" button, the code in _mymodule_register is executed (I debugged), but the page just reloads, it does not go to user/register. I tried both drupal_goto and form redirect, but nothing works.

function mymodule_form_user_login_block_alter(&$form, $form_state, $form_id) {
  $form['actions']['register'] = array(
    '#type' => 'submit',
    '#value' => t('Register'),
    '#submit' => array('_mymodule_register'),
    '#limit_validation_errors' => array(),
  );
}

function _mymodule_register($form, $form_state) {
  $form_state['redirect'] = 'user/register';
  //drupal_goto('user/register');
}


texts: How do I enable a module by exporting the configuration?

texts:
I enabled these core modules: Language, Content translation, Config translation, and Interface translation. I exported the core.extensions.yml file, but when I placed the same file in the development environment, those modules weren't installed.

How can I install modules by exporting the configuration?


texts:
User signatures are not showing up in comments.

Drupal version is 7.41

In /admin/structure/types/manage/forum/comment/display the setting "User signature" is set to visible.

In comment.tpl.php:

<?php if ($signature): ?>

  <?php print $signature ?>

<?php endif; ?>

In advanced-forum.themename.post.tpl.php

  <?php if (!empty($signature)): ?>

      <?php print $signature ?>

  <?php endif; ?>

But user signature is not shown neither in forum or other node comments.

I've checked the generated html code and it is not a css issue. I've disabled advanced forum and I've also used the Garland theme, but the issue persists.

What can I do to have the user signatures shown?

Thanks!


texts:
Is there is any alternative way to make token to work in the Drupal 8 menu link field other than Menu Token module. I want to use token to set as a default value when I am creating new menu, but if I am using Menu Token module, first, I don't see any option in the node form to enable the token menu. Secondly, I have to manually enable the token option for each menu item under Admin-> Menu after creating a node which I don't want to do.
I am trying this in Drupal 8, any suggestion would be helpful


texts: Using Theme() to output html/javascript in user edit

texts:
I have a module that outputs a button to the user edit page. I use the form_user_profile_form_alter to append the button but I want to add html and javascript after it. I saw that the theme() function can do this but my attempt does not add any html. Also I saw that the theme needs two parameters but I do not know what the 1st parameter is supposed to be. I was only following examples.

function myModule_form_user_profile_form_alter(&$form, &$form_state, $form_id) {

  $form['actions']['myButton'] = array(
    '#type' => 'submit',
    '#value' => 'Click Here'
  );
  $form['actions']['myButton']['#submit'][] = 'myModule_callback';

  return $form;
}

Here is my callback function

function artsci_pubmed_biblio_callback($form,$form_state){
  drupal_set_message('Button Clicked');
  return theme('box', '
Item 1

Item 2

Item 3
');
}


texts:
I wanted to edit my register menu link so I could show the registration link in the menu account only for anonymous user (not logged in users). But when I try to edit the register menu link the following error occurs:

Access denied
Home >> Administration >> Structure >> Menus
You are not authorized to access this page.

The link I'm trying to access supossedly

localhost/admin/structure/menu/item/8/edit?destination=/admin/structure/menu/manage/account

PS: I created a new registration form and in that one I could edit and show the the link in users menu only not logged in users but in this one I can't access even I have an admin role.
Log message:


texts: Why are there entries in sessions table for uid 0?

texts:
I was alarmed to find sessions being written to the table [sessions] for uid 0. Do I need to worry or is this normal? I could not find answers by searching. I don't know how the sessions table works.
This is Drupal 8.


texts:
This question has been asked before, but the regularly accepted solution is not working for me. I want the node form to be rebuilt on every page refresh. I have added an implementation of hook_form_BASE_FORM_ID_alter(), like so:

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function my_module_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['#cache']['max-age'] = 0;
}

The array inside $form['#cache'] looks like this:

contexts = [
  languages:language_interface
  user.roles:authenticated
]
tags = [
  config:core.entity_form_display.node.article.default
  node:123
]
max-age = 0

...but the form remains cached?

Ideally, I would like to clear the node form's cache only when a new node, of a particular type, is created. When such a node is created, a new token is also generated - and it is the token tree that I want to become updated in the node form because I am adding a tokens link tree to the base of my body field widget.

$form['body']['tokens_tree'] = array(
  '#theme' => 'token_tree_link',
  '#token_types' => ['my_tokens'],
  '#global_types' => FALSE,
);

I'm assuming that invalidating the cache of the node form will achieve my goal. Certainly, doing drush cr does the job.


texts: Custom module embedding existing node form

texts:
I have the following content types:

event
signup

I'm dealing with my_singnup module, for which I wish to:

allow user to add signup content (same as core node/add/signup)
using signup/event/%eventid path (it is simple link expose in every event)
presenting (while adding) some information from event in left side
and node/add/signup form on the right side
preventing signup/event without argument to run

The code I have already wrote is the following.

function my_singnup_menu() {
   $items = array();
   $items['signup/event'] = array(
     'title' => 'Sorry, no such event.',
     'page callback' => 'There is no event id in path.',
     'type' => MENU_CALLBACK,
     'access callback' => TRUE // for now
   );

   $items['signup/event/%eventid'] = array(
     'title' => 'Signing up for event',
     'title callback' => 'my_signup_title',
     'title arguments' => array(2),
     'page callback' => 'my_singnup',
     'page arguments' => array(2),
     'type' => MENU_CALLBACK,
     'access callback' => TRUE // for now
   );
   return $items;
}

function my_signup_title($node) {
  if ($node->type == 'event') {
  drupal_set_title(t('Signing up for event '.$node->title));
  }
  if ($node->type <> 'event') {
  drupal_set_title(t('Id in path is not event id.'));
  }
  return t('Signing up for event');
}

function my_signup($node = FALSE) {
   if($node) {
     if($node->type == 'event') {
       module_load_include('inc', 'node', 'node.pages'); //Added
       global $user; //Added
       $new_node = new stdClass; //Added
       $new_node->type = 'signup'; //Added - here was bug
       $new_node->language = LANGUAGE_NONE; //localization
       $new_node->user = $user->uid; //Added
       $new_node->name = (isset($user->name) ? $user->name : ''); //Added
       $form = drupal_get_form('signup_node_form', $new_node); //here was my big trouble
       return $form;
     }
   }
   return drupal_not_found();
}

function my_signup_theme($existing, $type, $theme, $path) {
  return array(
    'signup_node_form' => array(
      'render element' => 'form',
      'template' => 'signup-node-form',
      'path' => drupal_get_path('module', 'my_signup'),
    ),
  );
}

Right now, I see some form under event/signup/999 (thats good), but there is no custom groups and fields like in core default node/add/signup. I was so happy to see it that I forget to check it looks the same. I see only core vertical tabs such as Menu, Book, Version, Adress, Comments, and there is no custom fields and groups in it. It is strange.


texts: Module-registered menu paths and non-existing pages lead to non-Drupal 404

texts:
I'm trying to build a custom module, but I think there's something wrong with my server settings and/or Drupal install. Whenever I navigate to a non-existent site path, or even a path that is registered by a module, it goes to a generic 404 page that is not encapsulated by Drupal that looks like this:

Not Found

The requested URL /drupal/devel/phpinfo was not found on this server.

Apache/2.2.22 (Debian) Server at ******** Port 80

Not really sure where to go from here. Any help would be appreciated. Happy to provide more information.

Thank you!


texts: Custom date range format on a node by node basis

texts:
I'm working on a way to alter the way a date field, field_node_date, is formatted when rendered.

Currently, on the content type I'm working on, the Long format is being used (e.g. Monday 18 January 2016 - 22:55) and "Both Start and End dates" are displayed by default (on Display settings for any view mode this node is using). As a result, in the node's template,

<?php print render($content['field_node_date']); ?>

is rendering the field as expected.

I've added a new checkbox field to the content type. When users check that checkbox, I only want the date part of the field to be rendered, ie without the time, e.g.

"Monday 18 January 2016"

instead of

"Monday 18 January 2016 - 16:55"

when only a start date is entered, the same for a date range, e.g.

"Monday 18 January 2016 to Tuesday 19 January 2016"

instead of

"Monday 18 January 2016 - 16:54 to Tuesday 19 January 2016 - 19:44"

I tried overriding the theme registry to provide my custom theme callbacks for a single date and a date range:

function mymodule_theme_registry_alter(&$theme_registry) {
    if (isset($theme_registry['date_display_range'])) {
        $theme_registry['date_display_range']['function'] = 'custom_range_date_display_format';
    }
    if (isset($theme_registry['date_display_single'])) {
        $theme_registry['date_display_single']['function'] = 'custom_single_date_display_format';
    }
}

and then copying over date's theme_date_display_range() and theme_date_display_single() functions from date.theme and alter them to return the dates without the time. But there's no way to hook into each separate node withing the scope of this functions and see if the "don't show the time" field is checked so the returned date format would always be the same, either with the time or not, for all my nodes.

Another solution would be to go straight into the node's template and replace

<?php print render($content['field_node_date']); ?>

with something like

<?php print format_date(strtotime($date_field_value) ,'custom','whatever format I need for each node'); ?>

and create the same HTML structure for a single date or a range of dates. But that doesn't cover other view modes and it's not very clean.

I also tried to find the node hooks that would allow me to alter the date but I now see that no matter what format is selected, the date item always holds the date field's value as it's saved on the database and then only the markup changes. Programmatically altering the markup of the field would probably not be a preferred solution as any change of the format on the UI under display settings (e.g. from long to short etc) would be ignored.

I'd also like to avoid adding a new date format / type to my db

A good solution that would allow me to hook into my nodes, check if that checkbox is checked and then enforce my preferred custom date format every time the node is rendered would be ideal.

I'd appreciate any suggestions, thanks.


texts: Display a view inside a field collection with eva

texts:
I'm trying to display a view inside a field collection via EVA. I've created the view which accepts the nid of the containing content type as the context argument and all is good in that the view shows correctly when the nid is passed in, however I think the problem is that a field collection is stored as a separate piece of content, so the nid that is supplied when viewing is not that of the containing content type.

The view returns nothing when inserted into the field collection.

Is there a specific way to get the containing content-type nid into the view via the field collection? I've looked in the tokens section for the argument input in the eva view, but nothing specifically for the containing nid, only the specific field collection nid.


texts:
Hi I'm getting this Drush error no matter which command I try.

Fatal error: Class 'Drush\Log\Logger' not found

How can I fix it?
I haven't been able to find other users reporting the same issue. I'm using Drush 8.


texts: Help needed for adding and edit & delete link in a column in a view table

texts:
I need to implement views with a table format to display fields for selected content.  I would like one of the columns to have edit/delete links that will request perform the desired task for the row selected.  I have seen it done on sites, but have not found an example In which to review the view configuration.

Clarification:  Each row in a table represents a content node and each column would display a field in the content type.  I want to put an edit link that will call up the specific node in that row in the editing form.


texts: is there a way to change multiple tags at once?

texts: I decided to change a tag which is commonly used.  Is there an easy way to change it for all my content or do I have to manually go in and change each one?  Thank you.


texts: How to redirect an anonymous user to the login form after a 403 error?

texts:
I want to redirect an anonymous user to the login form if such user encounters a 403 error.

I have created event subscriber and this is my code, but I end up on loop on the current page.

/**
   * Redirect anonymous user to login page if he encounters 404 or 403
   * response.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $response
   *   The created response object that will be returned.
   * @param string $event
   *   The string representation of the event.
   * @param \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $event_dispatcher
   *   Event dispatcher that lazily loads listeners and subscribers from the dependency injection
   *   container.
   */
  public function checkLoginNeeded(GetResponseEvent $response, $event, ContainerAwareEventDispatcher $event_dispatcher) {
    $routeMatch = RouteMatch::createFromRequest($response->getRequest());
    $route_name = $routeMatch->getRouteName();
    $is_anonymous = \Drupal::currentUser()->isAnonymous();
    $is_not_login = $route_name != 'user.login';

    if ($is_anonymous && $route_name == 'system.403' && $is_not_login) {
      $query = $response->getRequest()->query->all();
//      $query['destination'] = $routeMatch->getRouteObject()->getPath();
      $query['destination'] = \Drupal::url('<current>');
      $login_uri = \Drupal::url('user.login', [], ['query' => $query]);
      $returnResponse = new RedirectResponse($login_uri, Response::HTTP_FOUND);
      $response->setResponse($returnResponse);
    }
  }

I think this is related to the fact that the response already contains destination(current uri) and system.404 and system.403 have some high priority that prevent me to override this.


texts: Ajax callback values not saved on submit

texts:
I added an Ajax callback to Add to cart form on two fields : quantity and a date line item field, because I need customers to choose the product id depending on these values (see study case if you wish more details).

Everything works fine... except that Ajax values, especially product_id, aren't saved in cart on form submit :(

Relevant parts of code

Add to cart form alter

/**
* Implements hook_form_alter().
*/
function vts_commerce_form_alter(&$form, &$form_state, $form_id) {

  if (strstr($form_id, 'commerce_cart_add_to_cart_form')) {
    //line item field callback
    $form['line_item_fields']['field_date_de_d_part_line_item']['und'][0]['#ajax'] = array(
      'callback' => 'vts_commerce_liberte_addtocart',
     );
    //wrapping $form['product_id']
    $form['product_id']['#prefix']='
';
    $form['product_id']['#suffix']='
';

    // ... SOME CODE setting $options

    //overwriting native $form['quantity'] to have a select with specific options
    $form['quantity']= array(
      '#type' => 'select',
      '#title' => t('Number of participants'),
      '#default_value' =>  1,
      '#datatype'  => 'integer',
      '#size' =>  1,
      '#weight' => 45,
      '#prefix' => '
',
      '#suffix' => '
',
      '#options' => $options,
      '#ajax' => array(
        'callback' => 'vts_commerce_liberte_addtocart',
        'wrapper' => 'qty',
        'method' => 'replace',
      ),
    );
  }
}

Ajax callback

function vts_commerce_liberte_addtocart($form, &$form_state) {

  $commands = array();

  // ... SOME CODE setting $pid and other stuff, messages...

  //TRYING TO UPDATE PRODUCT ID with drupal_render
  $form['product_id'] = array(
    '#type' => 'select',
    '#options' => array(
       $pid => 'product title: '.$pid, // TODO retrieve product title
    ),
    '#default_value' => $pid,
    '#weight' => 0,
  );
  $commands[] = ajax_command_replace('#liberte_pid', drupal_render($form['product_id']));

  //TRYING TO UPDATE PRODUCT ID with $form_state['values']
  $form_state['values']['product_id'] = $pid;
  $form_state['rebuild'] = TRUE;

  return array('#type' => 'ajax', '#commands' => $commands);
}

Either $form['product_id'] and $form_state['values']['product_id'] are changed by the callback, but when I submit the form, it takes the product id selected on page load instead of the one passed through  the callback.

With or without $form_state['rebuild'] = TRUE; in my callback doesn't changes anything...

As an alternative (or complement), I also noticed that product_id's callback is  commerce_cart_attributes_refresh_alter(), which updates the values given to cart, but I don't know how/where to call or trigger it in the ajax process ?


texts: How do I add a simple form to the node edit page?

texts:
I've spent a grand total of 8 hours trying to solve this problem. The form needs to be separate from the node edit form so I can't use the form_alter hook. It needs a separate submit button. It only needs to appear on admin screens ... I've tried overriding page.tpl.php (the one used by me admin theme, seven) with no luck. See the code below ... absolutely nothing happens. When I add html into the page.tpl.php file (located in my modules folder), the html does not appear.

/**
 * Implements hook_theme_registry_alter()
**/
function my_module_theme_registry_alter(&$theme_registry) {
  $mod_path = drupal_get_path('module', 'my_module');
  $theme_registry_copy = $theme_registry;       // munge on a copy
  _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'seven', $mod_path);
  $theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
  $hooks = array('node');
  foreach ($hooks as $h) {
    _my_module_insert_after_first_element($theme_registry[$h]['theme paths'], $mod_path);
  }
}
/**
 * Helper function for re-ordering arrays (needed by theme_registry_alter)
*/
function _my_module_insert_after_first_element(&$a, $element) {
  if(is_array($a)) {
    $first_element = array_shift($a);
    array_unshift($a, $first_element, $element);
  }
}

Also, I realize I can create forms the drupal way with the form hook (and page call backs). I've had success creating forms and showing them on custom urls, but I can't seem to programatically add the forms on pages I want, such as the node edit pages. If I could figure out how to do that, it would be preferable to just adding an html form into the template folder.


texts: Modal confirmation type and hook_form_alter in WebForm module

texts:
I have a *_hook_form_alter for a form being submitted with the Webform module. The $form_id triggers one of a couple *_form_emails_form_submit functions
Using the inline confirmation message type (Webforms >> Setting >> Confirmation), I have no issues triggering the *_form_emails_form_submit function that handles it.
When I switched to use the modal confirmation I started getting errors that my $form_state->getValue('email_address') (One of my fields in the webform) was null and broke the functionality of the *_form_emails_form_submit function
For example:
    function my_module_form_emails_form_alter(&$form, FormStateInterface $form_state, $form_id) {
     //Switch statement that looks for form_id and fires off below
     foreach (array_keys($form['actions']) as $action) {
            if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
              $form['actions'][$action]['#submit'][] = 'product_learn_more_form_emails_form_submit';
            }
          }
    }

    function product_learn_more_form_emails_form_submit(&$form, FormStateInterface $form_state) {
      //When confirmation is inline
      $email_address = $form_state->getValue('email_address');
      //me@me.com

      //When conformation type is modal
      $email_address = $form_state->getValue('email_address'); //null
    }

I am not sure what I am missing or why switching to modal changes thing but any hints you can give would be greatly appreciated.


texts: Place custom block on particular content type pages and home page

texts:
I have a custom block which I want to place on all the pages of one content type AND on the home page. The home page is a custom twig file that pulls in the region where the block is placed. Right now I have the custom block limited to the content type I want but of course that precludes being able to put it on the home page. Is there an elegant way to get it in both places? I'm also using Twig Tweak if that will help.
(Worst case I'll duplicate the block content and put it right into the twig file but I'm trying to avoid that.)
Thanks!


texts: How to add an attribute in an input date field

texts:
I want add the attribute autocomplete="Off" in the input field of the date field.
I've created a modulo with hook_form_alter but not works.
This is my code:

function no_input_autocomplete_form_alter(&$form, &$form_state, $form_id) {
    if($form_id === 'prenotazione_node_form'){
        $form['field_periodo_prenotazione_to']['#attributes'] = array('autocomplete' => 'Off');
    }
}

I've noticed that with other field type works as I expect.

How can solve it?


texts: How to allow user picture during registration?

texts:
I have the Avatar Selection module and the Register with Picture module installed.

But I can't get the file chooser to show up on the registration page.

What would be the problem?


texts: Invalidate local_task cache for a specific entity

texts:
Is there a way to invalidate local_task cache for a specific entity?

The issue is that an additional local task is defined by a different module that has a custom access check. That custom check if only returning TRUE if certain actions have been made by the system. Though it seems that initial cache persists forever (or until the caches are cleared).

This code seems to be able to remove all caches of local_task type, yet only one entry should really be affected (or a couple, depending on the situation).

\Drupal\Core\Cache\Cache::invalidateTags(['local_task']);

The issue with this code is that it would remove too much of the cached data. Current implementation does know when actions are taken that would change the permission response for that specific local_task item and would be able to run it.

Looking through the rendered cache table, it did not seem that entity was mentioned within the tags for local_task cache entry. There might be a way to make sure it is added there and make the local_task be invalidated along with the entity being changed or just invalidation cache tags for that specific entity.

EDIT:
After poking around I was able to determine that custom entity type does not get cache tags added to local_task tabs. Nodes do seems to have it. The question is thus: how to add entity specific cache tags to local_tasks associated with that?

The bad way would be to use the hook_menu_local_tasks_alter(), determine that path is one of the suitable ones and then add the correct cache tags as needed.

A better way would be to make sure that these are always added to any of the tasks directly related to the entity type.


texts: Ensuring Users Get the Most Up-to-Date PDF

texts:
I have taken over a Drupal 7 site that contains a lot of pdf forms. These forms are frequently updated. Many of these forms were uploaded to sites/default/files/userfiles and manually linked across the site.

To prevent having to track down each link, when I update a form I have been replacing the file using the same filename. This naturally isn't a great solution because people are loading the old versions from cache locally.

Is there a simple solution I am overlooking?

Note: I am using the media module for new forms going forward, but wonder if there is a solution for the old files that were done "improperly" as it were.


texts: How can I add to the class name of a form element?

texts:
I'm trying to add an additional class to a form element using the following code:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function grant_opportunity_form_grant_opportunity_node_form_alter(&$form, &$form_state, $form_id) {

    $form['grant_opportunity_end_date']['#attributes']['class'][] = 'datepicker';

}

But the additional class is not being added. Am I doing this incorrectly? This is a very simple thing I'm trying to do, so I'd prefer not to go through the trouble of overriding the theme, or anything more involved like that.

EDIT: To be clear, a class is being added to the parent div of this element, but not the element itself.


texts: Add custom variable to page.tpl.php using custom module?

texts:
I found this solution here:

https://www.drupal.org/forum/support/module-development-and-code-questions/2010-12-25/add-custom-variable-to-pagetplphp

I created a module for give possibility to some users to change the background file from the UI.

In my module:

function office_file_upload_preprocess_page(&$vars)
{
    $vars['background'] = "BK2.jpg";
}

In my

  page.tpl.php

Now how can I modify permanently  after this function

$upload = file_save_upload('upload_item', $validators, $location, $replace = FILE_EXISTS_REPLACE);

the above variable to change the background?

I tried

  variable_set($vars['background'], $upload->filename)

but no luck!

This is the form

and this is the module:

https://kopy.io/kOW3s


texts: Using twig inside theme folder rather than twig from modules

texts:
I installed a paragraph module and it uses twig from inside /modules/paragraphs/templates/
but I would like to override it inside my /theme/theme_name/ folder.

How can I do this?
Thanks.

Edit:

<!-- FILE NAME SUGGESTIONS:
* paragraph--steps--default.html.twig
* paragraph--steps.html.twig
* paragraph--default.html.twig
x paragraph.html.twig
-->
<!-- BEGIN OUTPUT from 'modules/paragraphs/templates/paragraph.html.twig' -->

Twig debug looks for the file in modules/paragraphs/templates and I would need it to look in mytheme/templates/. :/


texts: how do I specify a render cache context as universal?

texts:
I want to a render array in my page to be cached, and I know that it's the same for every user in every circumstance.
How do I specify that its cache context is universal, rather than anything else?


texts: Pros and Cons of Combining CSS/JS files or loading contextually?

texts:
I am building an application in Drupal 7.
There is one common CSS file A.css with 1000 lines of code. There are other 5 CSS files(B.css,C.css .... F.css) with 100 lines each. I want to load the other 5 files contextually(only on the pages they are needed).

Regarding pagespeed, what are the pros and cons of combining all those CSS files into one or loading them separately(contextually) ?

AFAIK, If I load them contextually, then the weight of those 5 files will be avoided in the pages they are not required. But I am not sure how Drupal's aggregation works. There are two possibilities I can think of.

When B.css is loaded contextually, the aggregated file will contain A.css + B.css into one file. Lets call it X.css. By this logic, when C.css is loaded, the aggregated file will contain A.css + C.css. Let's call it Y.css.  But since X.css and Y.css are two different files, this will not utilize browser's caching and will make http requests each time.
When B.css is loaded contextually, A.css and B.css will load separately. And similarly C.css will be loaded separately when needed. By this logic, A.css will be cached. Also B.css and C.css will be cached after being loaded once.

Which way it works(1 or 2)? How do I control it ?


texts: i have added modules to my website , but now when i want to open modules from admin section its showing blank and i am getting PDOException: SQLSTATE[42S02]: Base table or view not found:


texts: How do you migrate a site with Drupal 7 Image Styles and make sure the adjusted images migrate?

texts:
I am moving a D7 site from local to staging for the first time. I pushed my codebase through deployment, and I did drush sql-dump to get the database moved over. Then I copied the files directory as-is.

The new server site works perfectly -- except that images that are supposed to be generated by the image styles show up as broken. They're not being dynamically generated like they should, even though the styles themselves are there.

Any thoughts on why this would happen or how to debug it?


texts:
The query below is taken from the related View. How can I get the field value for 'field_data_field_news_link', 'field_data_field_news_source', and field_data_field_news_date' for each row (news content type that is published and featured)? I prefer to use what I already have, which probably means changes are needed to the JOIN statements? Right now, all that is printing are the node titles.

If there is a more straight forward approach, I'm open to that too.

<?php
    $query = "SELECT node.nid AS nid, node.title AS node_title, field_data_field_news_date.field_news_date_value AS field_data_field_news_date_field_news_date_value, 'node' AS field_data_field_news_date_node_entity_type, 'node' AS field_data_field_news_link_node_entity_type, 'node' AS field_data_field_news_source_node_entity_type
        FROM {node} node
        INNER JOIN {field_data_field_news_is_featured} field_data_field_news_is_featured ON node.nid = field_data_field_news_is_featured.entity_id AND (field_data_field_news_is_featured.entity_type = 'node' AND field_data_field_news_is_featured.deleted = '0')
        LEFT JOIN {field_data_field_news_date} field_data_field_news_date ON node.nid = field_data_field_news_date.entity_id AND (field_data_field_news_date.entity_type = 'node' AND field_data_field_news_date.deleted = '0')
        WHERE (( (node.type IN  ('news')) )AND(( (node.status = '1') AND (field_data_field_news_is_featured.field_news_is_featured_value = '1') )))
        ORDER BY field_data_field_news_date_field_news_date_value DESC
        LIMIT 5 OFFSET 0";

?>

<?php $results = db_query($query); ?>

<?php $i = 0; ?>
<?php foreach ($results as $row) : ?>
    <!-- Custom HTML here -->

<?php endforeach; ?>

Some background. I am upgrading a project that I inherited to Drupal 7. The Drupal 6 version has all hard coded templates (not my doing!). The specfic page I am working on is of Page content type. This is the News node. On this node, I need to render all News content types and the selected fields. I also need to render this into custom HTML. I prefer not to go the Rewrite results route.
Changing anything in Manage Display would be changing the Page content type which I do not want to do.
Additionally, it seems print render($content['field_news_link']) would only render that field from one News content type?
So if I already have a template file for the News node (of Page content type), what would be my approach? Would I create a template for the view and then just print the view in my existing News template?


texts: Primary menu not showing when lanugage is changed?

texts:
I have installed following modules :

1.Locale
2.Content Translation
3.Internationalization
4.Block translation
5.CCK translation
6.Content type translation 7.Menu  translation

I added Arabic language .po file using admin/build/translate/import. I added one menu item for English and another menu item for Arabic in primary links. The menu items added for English are displayed on a node view page (when English is selected from language switcher) but the menu items added for Arabic are not displayed on a node view page (when Arabic is selected from language switcher).


texts:
I have a menu like this:

In the first sidebar you see the main menu with links.
The second sidebar is a block that is visible on pages that begin with stocklijst/.

The link in the first sidebar links to the first link in the second sidebar. So the menu items both have class active. But when I click on the second link in the second sidebar the menu link in the first sidebar won't be active anymore.

I've installed the Menu Position module to make sure the link is active but it doesn't work. I added a rule like this:

But the menu item isn't active when the path is equal to stocklijst/gezocht.

What am I doing wrong?

UPDATE:
This is my view:


texts: Alter and set a id attribute for a field in drupal 7

texts: Can anyone help me how to alter a field attribute  in drupal 7. Let say i have created a field name hello_test with label as hello.Now I need to alter the label and set a attribute for the filed in template.php file in my theme.Can anyone help me


texts: Relation through paragraph seems to be exclusive

texts:
I implemented the following scheme:

Publication (node) - Mention (paragraphs) - Project (node)

Project is referenced by Reference Entity from paragraphs type and Mention is a paragraphs field (Entity Reference Revision) in Publication.

This seems to work fine and relations are shown correctly in publications. To show the reverse relation from a Project to Publication I use an additional view which has a mandatory relation to Mention paragraphs field and a filter using the ID from the URL. This view has a strange problem: Only the relation to the last saved publication is shown.

I'll explain it with an example using 2 publications, Publication1 and Publication2. They both have a relation to Project1 defined trough Mention (paragraphs). Both of them show the relation correctly when editing the publication but visualizing Project1 only shows one relation, either Publication1 or Publication2. To make it clearer:

Publication1 - Mention \
                         Project1
Publication2 - Mention /

The view listing the publications which mention this project only shows one relation, either to Publication1 or Publication2. What I noticed is that it's always the last saved publication, but only this and not both. So if I save Publication1, Project1 will show the relation, but not the one to Publication2. Saving Publication2 will then show only this relation from Project1, but not the one to Publication1.


texts: What function should I use in instead of mimemail()?

texts:
I was using mimemail(), a function defined from the MIME mail module, in Drupal 6 to send emails using attachments.
The Drupal 7 module doesn't have mimemail().
What function should I use in Drupal 7, instead of mimemail()?


texts: how to update order status in shopping cart to checkout

texts:
Here is my code for updating order status in shopping cart to Checkout: Checkout. After running no error but it does not show order status as Checkout: Checkout.

function commerce_services_order_checkout_update($order_id,$data, $flatten_fields) {
    $status; $message;

    $status = $data['status'];

    $order = commerce_order_load($order_id);
    $order = commerce_order_status_update($order, "Checkout: Checkout");
    if($order != null){
        $status = 1;
        $message = "Order status set to checkout successfully.";
    }else{
        $status = 0;
        $message = "Order status can not set to checkout.";
    }

   $reply= (array('status' => $status,'message' => $message, "order status ". $order));

    return $reply;
}

Any suggestion is greatly appreciated!

Thanks


texts: How to add custom webform email handler if submission is sticky/flagged

texts:
I use the bulk operation "Star/Flag selected submission" within webform views to process webform submissions which works nice.

I would like to be able to send an email to the author if a submission of a webform belonging to one of his nodes has been changed to sticky (flag). Is there a way to do this?

I saw that I need to add a custom handler but it is not clear to me with what content.


texts: Views templates: How to print file fields

texts:
I am creating a template for my table style view. I have several fields most of which are excluded from display. Inside my template I want to print those excluded from display fields. After some search I found that you can access all fields including those excluded by using:

$view->result[$row_count]->

Now the field I want to print is a file. This is the structure that dpm returns me:

  field_field_programme (Array, 1 element)

0 (Array, 2 elements)
    rendered (Array, 3 elements)
        #theme (String, 9 characters ) file_link
        #file (Object) stdClass
            fid (String, 4 characters ) 1011
            display (String, 1 characters ) 1
            description (String, 0 characters )
            uid (String, 1 characters ) 1
            filename (String, 10 characters ) seminar3.pdf
            uri (String, 40 characters ) public://seminaria/programmes/seminar3.pdf
            filemime (String, 15 characters ) application/pdf
            filesize (String, 6 characters ) 218882
            status (String, 1 characters ) 1
            timestamp (String, 10 characters ) 1333973478
            rdf_mapping (Array, 0 elements)
        #access (Boolean) TRUE
    raw (Array, 11 elements)
        fid (String, 4 characters ) 1011
        display (String, 1 characters ) 1
        description (String, 0 characters )
        uid (String, 1 characters ) 1
        filename (String, 10 characters ) seminar3.pdf
        uri (String, 40 characters ) public://seminaria/programmes/seminar3.pdf
        filemime (String, 15 characters ) application/pdf
        filesize (String, 6 characters ) 218882
        status (String, 1 characters ) 1
        timestamp (String, 10 characters ) 1333973478
        rdf_mapping (Array, 0 elements)

It is not as simple as using $field->content. How can I print my file? Do I need to create a link and add the information above? What code can I use so depending on the filemime the icon will change?

In other views I have created the output of files is:

With the information I get from the file I could create such a link. I am guessing length is the filesize? Maybe there is an api function that constructs file links?


texts:
what I'm trying to do is create a "Upgrade account" screen where the user will chose a different level of upgrade.  Then they enter payment info and if all goes well the upgrade is processed.

Being new to Drupal there seem to be many options from the powerful Commerce module to other more specific modules.  I was trying to go down the route mentioned here: https://commerceguys.com/blog/creating-orders-drupal-commerce-api

However, I'm not even sure how to execute that PHP from the click of a button.

So my questions really are:

Is the Commerce module the right fit (based on what I've mentioned)?
If so, how would I go about connecting the dots from building a screen to calling the PHP to kickoff the checkout?


texts: How to use template_preprocess_views_view to pass a variable to a views tpl file

texts:
Since the case re-occurred to me for the second time recently, I decided to ask the question so to perhaps learn something.

In Views, the main display title (the one that usually gets rendered at the top of the view) is available in display output as $title but does not seem to be available in style output at all. Instead, the $title variable in style output means the name of a group if grouping is used.

What I want is to have that display title ('human name') available in any template as $display_title. So what I did was putting this code in my template.php:

function MYTHEME_preprocess_views_view(&$variables){
  if($variables['name'] == 'studios' && $variables['display_id'] == 'block'){
    $view = $variables['view'];
    $variables['display_title'] = $view->human_name;
  }
  dpm($variables);
}

...hoping to have the human title handy:
<?php print $display_title; ?>

...but no joy. What am I doing wrong?


texts: Reloading a page from selecting a taxonomy term from a views filter

texts:
general

I have a book containing docs for multiple versions of software.

I want the pages of those books to be searchable and sorted per version.

specifically

I have a node override provided my panels of a certain content type.

One of those panels is a view displaying the content type that has been tagged with a taxonomy term.

How can I

Create an exposed filter that provides a dropdown selection of
terms, in this case, version numbers?

and

Have the page reload the view after a new term, in this case, the
version number, is selected and then submitted via a submit button?

This would preferably be done with contrib modules.


texts: Commerce product entity not being saved by EMW from another entity form submit

texts:
I'm using the module Commerce Stock Sources to manage different stock locations for my products.

When saving the Commerce stock sources form, on form submit, I want to update a field value on the Commerce product entity. The field is an Entity reference field.

The problem is that I can't get the field updated. No notice or error returning.

    //first I'm getting the values to be set; will have a simple array of IDs
    if (!empty($form_state['values']['plugins']['plugin_settings'])){
                $selected_sources = array_values(array_filter($form_state['values']['plugins']['plugin_settings']));
        }
    //next I'm loading the product entity; I have checked, the product is loading OK
    //and then the wrapper and the operations
    $product_entity = entity_load_single('commerce_product', $form_state['complete form']['#product']->product_id);
    $wrapper_product = entity_metadata_wrapper('commerce_product', $product_entity);
    if (!empty($selected_sources)) {
        $wrapper_product->field_product_location_store = $selected_sources;
        $wrapper_product->save();
    }

The field is not updated. I've checked to see if I can read values from product using entity_metadata_wrapper() and it works. When I try to update any field, it doesn't work.

I tried updating with field_attach_update(), but it doesn't work either.

        for($i=0; $i<count($selected_sources); $i++){
          $product_entity->field_product_location_store[LANGUAGE_NONE][$i]['target_id'] = $selected_sources[$i];
        }
        field_attach_update('commerce_product', $product_entity);
        entity_get_controller('commerce_product')->resetCache(array($product_entity->product_id));

Any thoughts?


texts: What content type select in View related to email?

texts:
I want to create a View. In my site there are lots of users are there, there is an email system i.e. send mail in these events : At the time of registration, At the time of password reset, etc..

I want to create a View of type Email or related to Email so I want to show the following things inside View related email :

  Mail ID

  Subject

  Body

May anybody please help me to find out that what content type am I select for email while creating View. Please help. Thanks


texts: Which Drupal 6 theme framework is good for creating a responsive web design? Is it advisable to use Zen starter-kit to develop a responsive theme?


texts: How can i have a custom theme created by myself for multilingual site?

texts:
My website uses i8ln and it is configured to work with a large amount of languages. Using the page.tpl.php i managed to translate the website. But i had to create another custom theme for a specific path and the 404 page. So i created a page--node--23.tpl.php file and clear the cache. The file worked since the node i was trying to import the new theme was the node id defined when i created node/23.
Now my problem is that i need to translate node/23 but when i click on translate and click save to save the translation another node is created and hence the page--node--23.tpl.php file is not used. How to set up drupal and able to adjust trasnaltion along with the custom themes???


texts: How to keep Views argument results in panels display

texts:
I'm working with Views and Panels and I am having troubles keeping the results of a View argument within Panels.

I have a content type for events, and I want to display a list of previous events grouped by year. Through Views, I created a Views panel with an argument based on the year of the event date to display the list of years (2011, 2010, 2009, etc.). The Views panel displays just fine within my Panels variant, but whenever I follow one of the links, the results are not within Panels anymore.

I'm sure I'm missing something very obvious but I can't seem to get this to work properly.


texts: How to add a image style to an image in a template file?

texts:
I need to change these lines (belong to a tpl.php file) to include a image style called "adaptative_image_style" to the generated image.

<?php print l(theme('image', $image_attributes), $ad['url'], $link_attributes); ?>

I think I should use the function to theme_image_style($variables) instead but not sure how to implement it.

Based in Clive's answer I get it working with this code:

  <?php
  $image_attributes['style_name'] = 'adaptative_image_style';
  print l(theme('image', $image_attributes), $ad['url'], $link_attributes); ?>


texts: Couldn't avoid duplicates and merge rows on my views

texts:
I have a view of list of contents referenced in many others content types in my site.
Lets talk about just 2 content types :
A content type called container is referenced in a content type position, so we say that the container has many positions.
Container position is a select list field in Position, for every item in this select list, there are some fields to fill.for example if I select 'on board' I have to fill the field 'date of loading', If I select 'in the shipper' I have to fill the field 'name of shipper'.
So in my view I want to display  the list of containers with informations from the positions where they were: container;date of loading;port of loading; shipper.
When I created the view I get duplicated results for every container. I tried aggregation and distinct option, It not works, or it removes duplicates without merging the rows if use them both.

Update:
My question is similar to this Views - adding relationship adds duplicate row for each relation


texts: How can I display site logo, name and slogan?

texts:
how can i show site logo, name and slogan Separately in custom area in my site theme, I now use this code to display theme, buts this code don't allow me to edit each of them Separately.

{{ page.header }}


texts: Updating to a newer dev version of a module using Drush (ignoring point/recommended releases, without trashing version control)

texts:
[NB This question is off the back of, but separate/further to, an earlier question of mine, here.]

I've been using Drush a good while, but every so often I get stumped. At the moment, I'm really not sure how to go about this.

Scenario: currently, the site uses a dev release, dated way in the past. In the meantime, no point release has been created, but a newer dev release has. So we have something like:

Reroute Email           6.x-1.x-dev (2010-Sep-27)
Recommended version:    6.x-1.0 (2008-Jul-24)
Development version:    6.x-1.x-dev (2011-Feb-25)

Doing drush dl <module>-6.x-1.x-dev overwrites the existing  directory with the latest 1.x dev release. That's fine, but it trashes the .svn folder.

If I do drush upc <module>, it will download the point release (see edit below), which I don't want, but if I do drush upc <module>-6.x-1.x-dev, it just refreshes the update data and then tells me "Specified version already installed" on the relevant line on the output.

So how do I use drush to overwrite the old dev release, getting the new one in its place, without trashing the SVN folder?

EDIT: Actually, in this instance, drush upc <module> downloads the correct version, but I'm pretty sure if the point release was dated like 6.x-1.0 (2011-Jan-24) it would have gotten that one. Anyone want to clarify/correct?


texts: Replace the URLs entered in a textarea with "url_removed"

texts:
I am using Drupal 8.9.1 and Webform module 8.5.16. I looking for the best way to either replace all URLs that a user might enter in a text area with "url_removed" or not allow the user to enter a functioning URL.
The goal is to prevent webform submission emails from having potentially malicious links within them the body of a comment.


texts: form_set_error not showing error message on webform

texts:
I have created my own module and when i try to use form_set_error all im getting is the red border around the form input but no error message.

here is my code

function dd_alert_register_form_alter(&$form, &$form_state, $form_id)
{
    if($form_id === 'webform_client_form_123'){
        $form['#validate'][]='dd_alert_register_form_validate';
    }
}

function dd_alert_register_form_validate($form,&$form_state)
{
    //where "phone" is field name of webform phone field
    $email = $form_state['values']['submitted']['email_address'];

    if ((bool) db_select('users')->fields('users', array('uid'))->condition('mail', db_like($email), 'LIKE')->range(0, 1)->execute()->fetchField()) {
        form_set_error('submitted][email_address',t('The e-mail address is already registered'));
        return $form;
    }
    // Then use regular expression to validate it.
    // In above example i have check if phonefield is empty or not.
}


texts: Is there a way to disallow the node/* path for anonymous users?

texts:
The reason of my question is that I have built a one-page website, but if people who knows a bit of drupal patterns wants to try to request the site by editing the url with a path like domain.tld/node/12 (for ex.), they will be redirected to the clean url and it will work, but this behavior is not intended and the theming customized in a way which is not made for direct requests on nodes.
Apart from the one-page, all the other content is in views and blocks, with a few colorbox links to open one content type in detail.
What I want to do is find a way to disallow node/* requests in path, just to "keep some control" of the way anonymous users visit the site (and potentially test it).

I have tested internal nodes which gives a partial answer, but it disallows all node's requests in colorbox.

I tried path rules but same issue as internal nodes.

Any idea to help me?


texts: How to return node object on programatically node creation

texts:
I can create  node programmatically  with following snippet

 use \Drupal\node\Entity\Node;

// Create node object with attached file.
$node = Node::create([
  'type'        => 'article',
  'title'       => 'Druplicon test',

])->save();

but it only returned "1" on successful,I want to return the created node object . how can I achieve that?


texts: How to fetch X random entities of a given type using rules?

texts:
I have a custom content type "project" with several CCK fields. One of them is named "field_old_intranet_url". No i want to assign a (random) user to every node of type "project". The author field or any other user_reference would be fine.

My first thought was to create a rule which is triggered when a user logs in. Fetch X random "projects" without an author and save the current user as the nodes author.

The problem is, that you can either fetch nodes by id or property. nid is not working, since i dont know the id. When fetching by property one can only compare the property with data from the current user or the current page. In my opinion it is not possible to fetch X random nodes.

Another solution would be, to trigger the rule by content creation or when content ist saved or whatever and then assign a random user. But this isnt possible either, because you cant fetch X user without a property to compare.

I hope my problem is clear and you can come up with quite different solutions!

Edit: It is possible to fetch every possible combination of X nodes of whatever type with Views Bulk Operations. This part of the problem is solved. Now the remaining challenge is to assign one entity of one of the lists (users / nodes) to a random one from the other, is this possible?

One solution would be to fetch a random node using views, is this possible?


texts: Why does Drupal use strange file extension for PHP code?

texts:
Is there any hidden reason why Drupal developer decided to use strange file extensions — for example node.install, node.module, simple.profile, case.test? Why not just using stand .php extension?

Thanks


texts: Entity reference : show fields instead of Label

texts:
Each user has a personal calendar (tab in profile from Views) where they can add "Event" content-type. I have a Entity reference field where the user can add 5 different "friends" to this "Event".

With Entity Reference view Widget I have a view (Picture and user name) from which the user can add up to 5 people. And it works, but...

How can I have more than just the Label? I would like to have the user picture and his name.

I've tried for 2 days... Please help. Maybe Entity Referennce is not the solution.

Thanks.


texts: I have a menu tab on nodes which is visible to everyone on the site. But I want it to be user specific. If the logged in user is the one who created that node, only he should be able to see the menu tab. Is it possible to do this using views ?


texts: Adding an asterisk via custom CSS is giving a 403 error

texts:
Using Drupal 8 and the Webform module, I am trying to add an asterisk to a required field label using the Custom CSS option in Webform by using this CSS style.

.form-required:after {
content: " *";
}

After adding the CSS style and trying to save the form, I get the following error message.

  403 error - Access to this resource on the server is denied!

I can add any other character in the CSS. Why?

As work-around, I am adding the CSS style to the style.css file, but I would like to understand why this is happening.


texts: Why would just adding a product to cart create a payment with method type "unknown" and credit card of "4111--------1111"

texts:
We have the Payment Method Example module turned OFF. And, we only have one payment type set up (Authorize.net) in the Enabled Payment Method Rules.

Yet, when we add just one product to the cart and click submit (without going to checkout, so without filling in any payment fields) we can go to orders/shopping cart and see that a payment with the following fields has been added to the order in process:

Date: "6/25/2015" (even though today is 6/22/2016)
Method: "Unknown"
Remote ID "-"
Result Message: -    Number: 4111--------1111  Expiration: 06/2015
Amount: $1,788 (which is $4.00 less than the total for this particular order. Note that this amount will vary, though.)

This causes the following Authorize.net issues:

1) In the above example, Authoize.net comes in and accepts a transition for $4.00. The order balance is then zero, based on the above $1,788 "unknown" payment plus the $4.00 from Authorize.net.

OR

2) Authorize.net comes back with the below error when the "Unknown" method payment is larger than the actual order:

REJECTED: A valid amount is required.
AVS response: AVS not applicable for this transaction
CVV match: -

If it helps, here are the rules that fired on the product submit page:

Commerce Pricing Attributes (default)
Calculate taxes: Sales tax (default)
Calculate taxes: VAT (default)
Reset the cart order status on product add or remove (default)
Add to Cart message (overridden)
Redirect after product add to Cart (custom) - a page redirect after submit

So - I need some help to debug/fix this:

1) Is there anything obvious I should look at? I have analyzed the setup of all modules, rules, etc.

2) How would what looks like an example payment type be added before even going to any checkout page - when we have the Payment Method Example module turned OFF.

3) And, since there is no error message - where do I even begin to debug this (I am a novice)?

4) Will Devel help? It seems you need some code added to a module. How do I figure out what module, what code, and where to add the code?

Thanks! Any help you can give would be highly appreciated!


texts: View not displaying correctly for all visitors

texts:
I have created a simple view that displays upcoming events on a page.  Both the events and the pages are meant to be viewed by all site visitors.  The problem that I am having is that in order to see all the events, you need to be logged into the site.  I checked the nodes and permissions and don't see anything out of the ordinary.  The View is supposed to display 17 events, but for the anonymous user they are only getting 12 events.  Inside the view the access is Unrestricted.  I have tried re-entering the 5 events that are missing and they still do not show in the View.

I also have a calendar that displays the events.  Similar to the view, it is not displaying all events.  The ones that are missing from the View are also missing from the calendar.

Any suggestion on what is causing this and how to fix it?  Thank you.

I am using Drupal 6.2 and Views 6.x-2.16

Chris


texts:
I try to get selected language for specified node (I mean in edit form) on form alter with following snippet in MODULENAME.module

use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\HttpFoundation\Request;

function MODULENAME_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
    if ($form_id == 'node_trends_edit_form') {
        kint($form);
        kint($form_state->getValue('langcode'));
        kint($form_state->getValues());
    }
}

BUT    results for   kint($form_state->getValue('langcode'));           kint($form_state->getValues()); are NULL.

how can I get language selected for node on form_alter


texts: trailing slash added unwillingly and page not found

texts:
There is a url that links to a view that is a page. When clicking the link to that view, a trailing slash gets added and the the page returns 'page not found' nothing about the site gets loaded, just this string as if it said die('page not found') first thing on load.
It wouldn't matter if I would manually type the correct url, the trailing slash would be added as well and return the same page not found string.

The only module I could find was global redirect. This module has checkbox in its settings that says 'Deslash'. I tried unchecking - save and checking - save again, but no help.


texts: Set Generate automatic URL alias during import in Taxonomy

texts:
how to set 'Generate automatic URL alias' for my terms during Feeds import?

I tried to set 1 or '1' in URL (url) field but it does not work for me.


texts:
I would like to know the proper way to display content of a block.
So far, i know a few ways:

1) Output html directly to block content. ie. $block['content'] = 'Hello';

2) Using preprocess and theme function and output variable to template file.

3) Provide an array to the block content. ie.

  $block = array(

'contact' => array(
  '#type' => 'markup',
  '#markup' => 'some content here',
)

 );

I am still new to drupal, can someone tell me about the pros and cons of using above methods?

or is there other way to do it?


texts:
Custom block doesn't show up on block listing and pages allowed to display that block.
After switch theme everything is ok, so it is not module layer issue.

I check template.php everything seems to be ok. I check CSS (display: none, etc), it seems that it's not CSS issue.

I asked about other idea's, why that block doesn't show up? I am struggling few hours and starting to have no new idea's to solved that issue


texts: Webform: send uploaded files as attachments

texts:
Hi i'm using SMTP module to send uploaded inforamation into mail using webforms.so i'm getting below information to my mail fine but in place of upload Your Cv link i need attachment .

 The following application was received from the website.

==Contact details==
     Title: demo1
     First name: demo
     Surname / Family Name: demo
     Tel (Daytime): xxxxxxxxxx
     Email address: demo@gmail.com
     Currently living in: london
     Prepared to relocate: Yes

==Career choices==
     Job type: Permanent
     Current salary: 200
     Min. salary required: 200
     Were you referred by a friend?
     Upload your CV:http://xxxxx/system/files/webform/uploaded_cvs/demoresume_4.doc

This requirement cab be done using MIME module and Mail System but it's take more time to submit form.

Please help me i'm new to drupal.

Thanks in advance.


texts: Content type access permission by user role

texts:
I have created 4 different content types and all except only one content type are visible to every user.  Here, I am not using any type of access module like content access, field permission or organic groups even I have also uninstalled my custom module but still could not able to find out the root cause .

In the attached screen shot
1) The above section is permission on a node created in that content type as per user roles.
2) The below section is what, which is visible to user other than site admin.

I have also gave "View published content", "View own published content" and "View content revision" permissions (and cleared the cache) but it still not fixed.

Appreciate any guess or suggestion !!


texts: Custom Entity: define a view in entity reference field

texts:
I defined a custom entity and for a entity reference field I want to set the view reference widget and a view/ display to be used instead of an autocomplete.

I tried many different settings - nothing worked. The latest version not working is:

$fields['user'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('User account'))
  ->setDescription(t('The user account this profile is connected to'))
  ->setSetting('target_type','user')
  ->setDisplayOptions('view', array(
    'label' => 'inline',
    'type' => 'string',
    'weight' => -6,
  ))
  ->setDisplayOptions('form', array(
    'type' => 'views',
    'settings' => array(
      'handler_settings' => array(
        'view_name' => 'users_without_profile',
        'display_name' => 'entity_reference_1',
        'arguments' => []
      ),
      'weight' => 20
    )

  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

For the form view setting I also tried

  ->setDisplayOptions('form', array(
    'type' => 'views',
    'settings' => array(
      'view_name' => 'users_without_profile',
      'display_name' => 'entity_reference_1',
      'arguments' => [],
      'weight' => 20
    )
  ))

and

  ->setDisplayOptions('form', array(
    'type' => 'entity_reference_autocomplete',
    'settings' => array(
        'handler' => 'views',
        'handler_settings' => array(
            'view_name' => 'users_without_profile',
            'display_name' => 'entity_reference_1',
            'arguments' => [],
        ),
        'weight' => 20
    )
  ))

No success. Can somebody give me a hint?


texts: How to create a view that automatically shows all fields as a table, even if new ones are added to the entity?

texts: I need to create a table view that shows all of the user accounts on the site and their fields. The client has the ability to add new fields to the user entity but I do not want to make them go into the view to add the field as well. Is there a way to have views just output all fields? I know I can change the display as an entity and select a view mode but I need this to be in table format.


texts: Multi-language with domain name specific doesn't work

texts:
I am working on a multi-language website. I am setting content in both English and French.

When I use path prefix as my detection method, it works fine, like poc-local.com and poc-local.com/fr. When I use domain as my detection method, it doesn't work, like fr.poc-local.com.

I am getting a 302 error, and "the page isn't redirecting properly" error. How can I fix this?


texts: How to render svg image in node twig file?

texts:
How to render svg image in node twig file. The image field is in field collection.
Rendering code used

<img src="{{ file_url(l2web.getFieldCollectionItem().field_deployment_image2.entity.uri.value) }}" />

( https://www.drupal.org/node/2541480 patch used )

  But am getting issue in node twig file. Issue is
  Twig_Sandbox_SecurityError: Calling "uri" method on a
  "Drupal\field_collection\Entity\FieldCollectionItem" object is not
  allowed. in
  Drupal\Core\Template\TwigSandboxPolicy->checkMethodAllowed() (line 197
  of \node--l2-page.html.twig)


texts: Drupal Pager Error Causing WSOD When Viewing Term or Edit Term

texts:
I have recently been through the ordeal of updating D6 to D7. Things went better than I had previously encountered but I have a problem thats really holding me back and I can't work out how to sort it.

When I try to view a taxonomy/term/ page or edit a term I get a WSOD. I managed to show the error which was:

  Fatal error: Call to a member function use_pager() on a non-object in /home/oddeba/public_html/onlinebanter.co.uk/sites/all/modules/views/includes/view.inc on line 690

Line 690:

    function init_pager() {
         if (empty($this->query->pager)) {
           $this->query->pager = $this->display_handler->get_plugin('pager');

        Line 690>>>  if ($this->query->pager->use_pager()) {
            $this->query->pager->set_current_page($this->current_page);
           }

Things are fine with Views disabled. I can for the life of me think how I needed a pager about my taxonomy before.

Could anyone suggest anything that could be causing it?


texts: Disabling node editing after first node flagging

texts:
I use flagging for signing petitions. Petitions should be editable until the first signing (flagging) is done.

Now I look for a solution to disable node edition after first signing.

My first thought is doing it with Rules. I have access to flagging reactions, node type conditions but I have no action for editability of nodes.

Is there another way to get it done with Rules or something without it?


texts: where does $data come from in hook_tokens?

texts:
In a custom module i have hook_tokens() implemented in order to create some custom tokens. What i realized is that some data is being declared as null but i don't know where this is happening. These values are coming from user input in a submitted web form. input from traditional web form fields do appear but input added through payment method fields are the ones appearing as null.

this is a small snip of what var_dump($data) shows:

$data['webform-submission']->payments[34]->contextObj->submission->data[47][0]"August"
$data['webform-submission']->payments[34]->contextObj->submission->data[46]array[1]
$data['webform-submission']->payments[34]->contextObj->submission->data[46][0]"1"
$data['webform-submission']->payments[34]->contextObj->submission->data[16]array[1]
$data['webform-submission']->payments[34]->contextObj->submission->data[16][0]null
$data['webform-submission']->payments[34]->contextObj->submission->data[35]array[1]

EDIT:

Thanks for the clarification on where $data comes from. I also realized that the hook i created (hook_token_info) is not being utilized. When i create a token i do not see it listed under Browse available tokens when i edit emails templates under the web form tab. Oddly hook_tokens is being called when i pass token_alter('[submission:custom:card_type]', array('submission'=>$card_type)) however the token is empty.


texts: How can I change a form input to not be required?

texts:
I want to change a form from required = True to False

<input data-drupal-selector="edit-attributes-alt" type="text" id="edit-attributes-alt--SMq1dTLhZG8" name="attributes[alt]" value="" size="60" maxlength="2048" placeholder="" class="form-text required" required="required" aria-required="true">

I thought that using form alter is the right thing to do but how can i use the $form_id if keeps changing ?

Here is my code :

<?php

use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\HttpFoundation\Request;

function alt_not_required_form_alter(array &$form, FormStateInterface $form_state, $data_drupal_selector) {
  if ($form_id == 'edit-attributes-alt--????') {
    $form['postal'] = array(
      // Don't make this field required. Use the validate hook.
      '#required' => FALSE,
    );
  }
}


texts: Output from preprocess_views_view_field in Drupal 8

texts:
I tried to alter the Output of an View-field with function in Drupal 8:

function mytheme_preprocess_views_view_field(&$variables) {
  $view = $variables['view'];

  if ($view->storage->id() == 'myview' && $variables['field']->realField == 'field_sterne_value') {

    $string = "";
    $sterne = intval($variables['field']->getValue($variables['row']));

    for ($i=1;$i < $sterne;$i++){
      $string .= "<img src='/themes/mytheme/img/stern.png'>";
    }

    $variables['mystar'] = $string;
  }
}

The output should show the stars as Images, but shows the html-Code in Frontend.
I tried different encoding with htmlentities and html_entity_decode.
But it does not work or I did encoding in a false way.

In my custom twig-template I use {{mystar}}.
But the same problem exists when I use the original template with {{output}}.

Where is my error?


texts:
In a view an exposed filter of type taxonomy reference exists, the referenced taxonomy vocabulary contains about 15 terms, the functionality I'm trying to get is to allow user call view with a default value for filter, so if user enter the path sitename/view-name/term-name the view would be load with entities of term term1.

I used contextual filter for limiting entities to those having specific term-name but the problem is, if user selects another term name, rather than the one specified in contextual filter, the view returns no result (term reference in node accepts only one value).

So I wanted to know if there is a solution to set the exposed filter default value based on url?


texts: Using select list with Views exposed filter when it is a custom schema through hook_views_data

texts:
I need to build a page in Panels that is composed of Views displays. The page that this will make will function as a kind of workstation for a staff member displaying bespoke information about readership details, demographics, products chosen etc. etc.

The problem is that I've inherited this project and the previous developer was hard-coding things, avoiding the Drupal API and trying to create his own CMS to handle this complex readership-type subscription system. I now have to make this something that will play nicely with Drupal rather than starting again due to time constraints.

I've used hook_views_data to expose his custom tables but because it seems to be data unmanaged by Drupal (i.e. he used nothing like nodes/ entities etc.) I don't think I'm able to exploit the node/custom field/select (https://drupal.org/node/391528) workaround I'm not sure of what I should start looking at.

Please do offer suggestions (possibly even on the wider context if it's relevant)


texts: Change Drupal Views Rows before they were rendered

texts:
I want to change the output of a view. More precisely i want to reduce the resulting list to exact 3 matches: one specific row and its previous and next row.

As far as I understand I need to generate the whole list first, because otherwise i cant find the previous row. So I thought I have to do something in the views-view.tpl where all the rows will printed.

My question then is: How can I get the content of a specific field in each row in $rows so i can check for that specific row and its surrounding rows?

Or is there any better way?

ps. ( i am a php noob )


texts: Configuration Settings of Authcache + File Cache

texts:
I have already file cache module installed and working perfectly except that I've read that it also work with authcache.

So I installed authcache but wondering what is the proper configuration in the settings.php.

In authcache readme file, it gives an example as follows:

$conf['cache_backends'][] = 'sites/all/modules/filecache/filecache.inc';
$conf['cache_backends'][] = 'sites/all/modules/authcache/authcache.cache.inc';
$conf['cache_backends'][] = 'sites/all/modules/authcache/modules/authcache_builtin/authcache_builtin.cache.inc';
$conf['cache_class_cache_page'] = 'DrupalFileCache';

And my current configuration for file cache module is:

$conf['cache_backends'] = array('sites/all/modules/filecache/filecache.inc');
$conf['cache_default_class'] = 'DrupalFileCache';
$conf['filecache_directory'] = '/tmp/scfilecache-' . substr(conf_path(), 6);

I tried to combine the two configuration as follows without luck:

$conf['cache_backends'][] = 'sites/all/modules/filecache/filecache.inc';
$conf['cache_backends'][] = 'sites/all/modules/authcache/authcache.cache.inc';
$conf['cache_backends'][] = 'sites/all/modules/authcache/modules/authcache_builtin/authcache_builtin.cache.inc';
$conf['cache_class_cache_page'] = 'DrupalFileCache';
$conf['filecache_directory'] = '/tmp/scfilecache-' . substr(conf_path(), 6);

My site returns an error with the config above.

Anyone know what is the correct configuration for authcache + file cache?