texts: Unable to set default value for checkbox form element inside tableselect

texts:
I've created a custom table using a tableselect element, and within each row, I have a checkbox form element that should populate the checkbox from a checkbox field in the node. I've tried every possible format of #default_value (setting it to 1, array(1), etc), to no avail. Since in HTML it's the checked attribute that causes a checkbox to show as checked, I came up with this option:

  foreach($translations as $locale => $locale_data) {
    // Get data for other fields...

    // Get data for Staging Only checkbox
    $staging_only = isset($entity->field_pub_staging_only[$locale]) ? (int)$entity->field_pub_staging_only[$locale][0]['value'] : 0;

    $row = array(
     'language_locale' => $locale_link,
     'status' => $status,
     'stage_url' => $stage_url,
     'start_date' => array(
       'data'=> array(
         '#type'=>'textfield',
         '#value'=> $new_start_date,
         '#title' => 'Start Date',
         '#title_display'=>'invisible',
         '#name'=> 'start_date[' . $locale . ']',
         '#id'=>  'start-date[' . $locale . ']',
         '#attributes' => array('class' => array('datepicker')),
         '#size' => 10,
         '#maxlength' => 10
       ),
     ),
     'end_date' => array(
       'data'=> array(
         '#type'=>'textfield',
         '#value'=> $new_end_date,
         '#title' => 'End Date',
         '#title_display'=>'invisible',
         '#name'=> 'end_date[' . $locale . ']',
         '#id'=> 'end-date[' . $locale . ']',
         '#attributes' => array('class' => array('datepicker')),
         '#size' => 10,
         '#maxlength' => 10
       ),
     ),
      'staging_only' => array(
        'data'=> array(
          '#type'=>'checkbox',
          '#title' => 'Staging Only',
          '#title_display'=>'invisible',
          '#name'=> 'staging_only[' . $locale . ']',
          '#id'=> 'staging_only[' . $locale . ']',
          '#default_value' => $staging_only
        ),
      ),
      'display_title' => $title
    );

    if ($staging_only) {
      $row['staging_only']['data']['#attributes'] = array('checked' => array('checked'));
    }

    $options[$locale] = $row;
  }

  $header = array(
    'language_locale' => t('Language Locale'),
    'status' => t('Status'),
    'stage_url' => t('Stage URL'),
    'start_date' => t('Start Date'),
    'end_date' => t('End Date'),
    'staging_only' => t('Staging Only'),
    'display_title' => t('Display Title')
  );

  $form['table'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#empty' => t('No content available.'),
    '#attributes' => array('id' => array('locale-table')),
  );

...

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

  return $form;
}

where I'm basically manually added the checked attribute to the element when it's checked. It works, but it seems sort of hackish, since it's not using what would normally be used to set a form element value with Form API. Is there a better way to do this with the usual Form API settings?

CLARIFICATION It appears that my question wasn't clear, based on the answers I've received so far. The issue is not whether the tableselect row checkbox is checked by default; the issue is attempting to mark as checked the staging_only checkbox, which is a separate from api element within the tableselect row.


texts: Modify the links included in the user menu

texts:
On a base Drupal install, there are 2 links included in the User Menu, My Account, and Log Out. I want to modify the My Account link to be expanded, and modify the Log Out link to be a child of the My Account link. How can I do this?

I've tried:

function MODULE_menu_alter(&$items) {
  if (isset($items['user'])) {
    $items['user']['expanded'] = true;
  }
}

To at least set the My Account as expanded, but that's not working (ie. not setting the expanded property to true). And I don't know how to change the parent of the Log Out link. Preferably this could all be done without a database request.

EDIT:
I recently succeeded a little bit in using:

function MODULE_menu_link_alter(&$item) {
  if ($item['link_path'] === 'user' && $link['module'] === 'system') {
    $link['expanded'] = 1;
  }
}

That modifies the My account link to be expanded, but I still can't seem to modify the plid of the logout link ('user/logout').


texts: Referenced content not displayed on page with Adwords-queryparameter

texts:
I have landing pages containing a panel as the main page content and url, blocks and a banner/slider and portfolio items. The banner (A View using flexslider) and portfolio items (standard content type) are referenced to that page by a url field.

The problem is that when a Adwords-queryparameter is added to the url the banner and portfolio items are not displayed.

You can see the problem below:

The way it should be:

http://premiumvoices.nl/engelse-voiceover-stemmen

Now the result when a google test parameter is added to the url:

http://premiumvoices.nl/engelse-voiceover-stemmen?gclid=TeSter-123

Any ideas or solutions?


texts: Why does JsonResponse keep returning a <?php tag at the beginning?

texts:
I am returning my data like this:

return new JsonResponse([
  'data' => $this->data,
  'error' => $this->error,
  'errorMsg' => $this->errorMsg,
], 200);

Somehow, a PHP opening tag is always being added, making it impossible for Angular 2 to parse the result.

<?php{"data":[],"error":true,"errorMsg":"This email seems to be used by another user."}

I have already tried the most desperate solutions like str_replace() in Response.php in Drupal but it did not seem to help.

Why is it happening?


texts: views - remove duplicates based on field value

texts:
Hi I have an order list created in views with 2 fields: order ID and order payment method. Each order can have multiple payment methods (every payment method gets own incremented id when attached to order).

Example:

order id1 with payment id1
order id2 with payment id2 and payment id3
order id3 with payment id4

This causes duplicate rows in second case.

Problem: How can I show only orders with the last payment method attached to them?

One solution would be to create one view with order id argument, showing only one row and sorted by payment id descending. Then using views field view module and create another view with order list without duplicates.

Question: is there a more simple solution without creating second view? Thank you.


texts: Is there a way to not show some fields of a content type on the add form?

texts: I have a content type "Print" with several fields. Some fields need to be filled out by users and thus, should be hidden from the anonymous users who create content of type "Print." Is there an easy way to do this?


texts:
I'm working in Drupal 8 and am using Search Api for searching my website. I'm using the build in Highlight function and it works great on the title and on the body text. But I can't seem to get it to work for Taxonomy Terms in a Entity Reference Field.

I enabled the Index hierarchy processor to search the Taxonomy Term Reference. But this didn't help.

Is this possible and what are the settings I should use to get this to work?

Thanks in advance


texts: How to show paragraph bundles of different types in a view of content containing paragraphs?

texts:
I am using the Paragraphs module and I want to show the paragraphs of one type at the beginning of the view and the paragraph of a different type at the end. How do I distinguish paragraphs of different types (since the field name is the same)?

I see that they are doing it here but my view doesn't have those options :
https://www.drupal.org/node/2592021

ALSO I want to be able to insert this view of paragraphs into a view of the corresponding content. How can I do that?


texts: Implementing a reply-by-email comment system that integrates with subscriptions

texts:
I'm trying to implement a reply-by-email flow on an existing site that will allow users to reply to comments made on the site directly from the email sent informing them of a new comment.

The site (Drupal 7) is using the subscriptions module and has some custom functionality built around that module based on requirements for that site.

I attempted to use the mailcomment module with the notifications module but there is a lot of functionality conflicts and overlaps with the subscriptions module and notifications. I would just remove the subscriptions module and use the notifications module but the site is too intertwined with subscriptions.

Does anyone know of a reply-by-email solution that integrates well with subscriptions? Or, have any ideas/alternatives for doing a reply-by-email system in Drupal 7?


texts: How to pass user information to Commerce product fields when creating a product?

texts:
Looking for a way to pass user information and other ready-filled product information to the fields when creating a new product.

More precisely, I'm working with multiple type CVs as Commerce products and it's definitely a stretch to have the users type in lots and lots of the same information over and over again.

Hence, I'd like as much information as possible to be passed from the users own profile (e.g. name, address, etc.) and from CVs that the user has filled out already (competences, personal qualities, etc.). Bare in mind, these should definitely be multistep (multipage) content anyways but multistep only apparently works with normal content types and not with Commerces product types. Please correct me if I'm wrong. The point is to make adding products as easy as possible :)


texts: Splas / First frame image not working in a flowplayer module

texts:
I am using drupal.org/project/video and drupal.org/project/flowplayer module to display the flv videos from video module. Everything works fine, except the splash/first frame image. Video module successfully creates 5 thumbnails from a movie and i can display these thumbnails in a view, but when i load a node with player it showing not a generated thumbnal, but first frame from the movie.

How can i set generated thumbnail as a splash image with flowplayer?


texts: When I update my database schema with drush entity-updates. I get an error

texts:
When I try to update my database Schema I'm getting the following error:

  Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException:[error]
  The SQL storage cannot change the schema for an existing field
  (order_total in uc_order entity) with data. in
  Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->updateSharedTableSchema()
  (line 1376 of
  /www/htdocs/xxx/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).
  Failed:                                                              [error]
  Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException:
  !message in
  Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->updateSharedTableSchema()
  (line 1376 of
  /www/htdocs/xxx/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php).

What can I do?


texts: Ability to order fields for each content in a content type

texts:
I have a custom content type which is rendered by a custom tpl php. I would like to have the ability to control the order in which the fields are displayed for each contents.

I can use the order of the fields defined in the content type, but that will affect all the contents for that content type. Can I have some field in which I can specify the order of the content types that is being displayed? So that based on the field containing the order, I will render the fields in configured order.

Or else what would be the best way to do that, so that I can get control over the order of each content?


texts: How do I migrate file entities into media entities?

texts:
I am using the Migrate module for a D7 to D8 migration and I am writing the whole migration manually in code (rather than use the built in D7 migrate module, as I wanted more granual control on the migration.)

I have the following structure: the D7 site has a image field where images are stored as File entities. On the D8 site, the image field is an entity reference to a Media entity (and the Media entity in turn has a Image field.)

Originally, I had the following for my Images migration:

id: image_files

source:
  plugin: legacy_images
  constants:
    source_base_path: http://example.com/

destination:
  plugin: 'entity:file'

process:
  fid: fid
  filename: filename
  source_full_path:
    -
      plugin: concat
      delimiter: /
      source:
    -     constants/source_base_path
    -     uri
    -
      plugin: urlencode
  uri:
    plugin: file_copy
    source:
      - '@source_full_path'
      - uri
  filemime: filemime
  status: status

Inside my article node migration file, I had the following:

'field_article_image/target_id':
plugin: migration
migration: image_files
source: field_article_image

but I realized that this would not work. The target_id coming from the image_files migration were really File Entity ID's, not media entity ID's.
In the ideal world, I'd like to find a way to create a third migration, which would create this middle step, and migrate file entities into Media Entities and then map that migration to the Articles migration. However, I can't figure out a good way of doing this.

Plan B will simply be to create a process plugin for the images migration, which will manually create file entities, attach them to media entities, and pass that migration over to Articles (this removes the middle step). This would mean, though, that while Media entities can be rolled back, File Entities could not.


texts: Where should I be extracting the Libraries module, sites/all/modules or sites/all/libraries?


texts: Disable CSS and JS from a contributed module

texts:
I am using Simple Mega Menu module.

I want to disable the CSS and JS provided by this contributed module:

modules/contrib/simple_megamenu/js/simple_megamenu.js
modules/contrib/simple_megamenu/css/style.css

In the module description the say

  Simple Mega Menu provide basic styling. You can override the library
  (css/js) provided by this module simply by adding theses lines into
  your theme file my_theme.info.yml

libraries-override:
  # Replace an entire library.
  simple_megamenu/base: my_theme/megamenu

How do I disable the CSS and JS files properly in my_theme.info.yml?


texts: How to delete file using drupal_form_submit?

texts:
I'm using rest services with a custom resource on node update, i want to build the correct variable node structure to delete one of the files on a file image multiple fields.
I removed the file element from the form_state['values'] but isn't working.
I know i can do it manually but is it possible altering form_state['values]  ?


texts: Create a view block on a node reference field (using Node Reference)

texts:
Creating a related content block on a node reference field. I have two content types: Article and Author.

The content type Article has the field Label: Por 'field_autor' which is a node reference to an author node.

I want to be able to take that ID and lis other articles with the same NID.

The view is setup as such:

Format: HTML List
Fields: Title
Filter: Published;
Type (Article)
Order: Weight

Advanced Options

Contextual Filters: (field_autor) Content: Nid
Relationships: Content: Por (field_autor) - reverse

However, this isn't displaying articles with the same author. Looking for assistance!


texts: I'd like to know if any extra tpl.php file in drupal theme has additional resourse loading? Will drupal site work faster with less tpl.php files?


texts: How do I invoke JavaScript in AjaxResponse?

texts:
I'm submitting a form via AJAX.

$response = new AjaxResponse();

It's not using the Drupal default dialog, so I can't use $response->addCommand(new CloseModalDialogCommand()); after all validation is done. It's using jQuery Modal.

Validation is working fine. After all things done I want to execute Javascript in submitForm function.

Which function should I use? I need to check for example alert(1).

I have to close window using Javascript & Alert message as well. I tried AlertCommand but not working.

Following this example: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Ajax%21InvokeCommand.php/class/InvokeCommand/8.2.x
But not working

I have below code

modules/demo_test/src/Form/DemoTestForm.php

namespace Drupal\demo_test\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\InvokeCommand;

class DemoTestForm extends FormBase {

  public function buildForm(array $form, FormStateInterface $form_state) {

    $form['#prefix'] = '
';
    $form['#suffix'] = '
';

    $form['firstname'] = [
      '#type' => 'textfield',
      '#title' => $this->t('First name'),
      '#required' => TRUE,
    ];

    $form['actions'] = [
      '#type' => 'actions',
    ];

    $form['actions']['submit'] = [
      '#name' =>'submit',
      '#type' => 'submit',
      '#value' => $this->t('Submit'),
      '#ajax' => [
        'callback' => '::ajaxSubmitForm',
        'event' => 'click',
      ],
    ];

    $form['#attached']['library'][] = 'demo_test/demo';

    return $form;
  }

  public function ajaxSubmitForm(array &$form, FormStateInterface $form_state) {
    drupal_get_messages();

    $response = new AjaxResponse();
    if ($form_state->getErrors()) {
      unset($form['#prefix']);
      unset($form['#suffix']);
      $form['status_messages'] = [
        '#type' => 'status_messages',
        '#weight' => -10,
      ];
      $response->addCommand(new HtmlCommand('#demo-test-modal-form', $form));
    }
    return $response;
  }

  public function getFormId() {
    return 'demo_test_form';
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    $response = new AjaxResponse();
    $response->addCommand(new InvokeCommand('html', 'trigger', array(
      'triggerName',
      array(
        'foo' => 'bar',
      ),
    )));
    return $response;
  }
}

modules/demo_test/js/demo.js

(function ($, Drupal) {

  'use strict';

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

      $(document).on('triggerName', function(e, data) {
        alert('data.foo'); // alerts string 'bar'
      });
    }
  };

})(jQuery, Drupal);

jQuery(document).on('triggerName', function(e, data) {
    alert(1);
    alert('data.foo'); // alerts string 'bar'
});

It's not going in JS file & alert. JS file is loading fine.


texts:
I've got problem with making main-menu wrapped in  element.
I've tried:

Using hooks in template.php like:

function koko_menu_link_main_menu($variables) { /* For block override */
$output = '';
      foreach ($variables['links'] as $link) {
        $output .= l($link['title'], $link['href'], $link);
  }
  $output .= '';
  return $output;
}

function koko_links__system_main_menu($variables) {
  $output = '';
foreach ($variables['links'] as $link) {
  $output .= l($link['title'], $link['href'], $link);
}
  $output .= '';
    return $output;
}

Using preprocesss/block.preprocess.inc:

  switch ($variables['block']->module) {
    case 'system':
      switch ($variables['block']->delta) {
        case 'help':
        case 'powered-by':
          break;

      case 'main':
          // Use a template with no wrapper for the page's main content.
          $variables['theme_hook_suggestions'][] = 'block__minimal';
          break;

      default:
          // Any other "system" block is a menu block and should use
          // block--nav.tpl.php
          $variables['theme_hook_suggestions'][] = 'block__nav';
          break;
      }
      break;

      case 'menu':
      case 'menu_block':
      // Use block--nav.tpl.php template.
      $variables['theme_hook_suggestions'][] = 'block__nav';
      break;
  }

case 'main':
  // Use a template with no wrapper for the page's main content.
  $variables['theme_hook_suggestions'][] = 'block__minimal';
  break;

default:
  // Any other "system" block is a menu block and should use
  // block--nav.tpl.php
  $variables['theme_hook_suggestions'][] = 'block__nav';
  break;
 }
 break;

case 'menu':
case 'menu_block':
    // Use block--nav.tpl.php template.
     $variables['theme_hook_suggestions'][] = 'block__nav';
     break;
   }

That contains. block--nav.tpl.php

    <nav<?php print $attributes; ?>>
      <?php print render($title_prefix); ?>
      <?php print render($title_suffix); ?>
      <?php print $content; ?>

Still nothing happends. Main-menu is not wrapped in anything different than:
.


texts:
I've been looking on several sites trying to figure this out, but no dice yet.

I have a module, 'spower'. I need to include several php files inside the polygon folder (spower/polygon/*.php). In the spower.module file, I've included the line:

module_load_include('php', 'spower', 'polygon/polygonBase');

However, when I run the module, I get the error Call to undefined function PolygonBase, so obviously, something's not loading right.


texts: How to build multivalue form elements using Form API

texts:
With the 'field collections' module at the form level, you can create a fieldset (or 'field group') that will accept multiple sets of values.

Is there a way to do this with the Form API directly (or with the help 'field collections' or 'field group' module) programmatically.  I can make the form fieldset easy enough, but I'm not sure how to set multiple values for this set.  In fact, I'm not really sure how you define multiple values for any field with the Form API.

UPDATE: Just to be clear I want to create the form, not the entity itself (at least not yet).  I want to use the Form API to accomplish this to make my own $form – just the form.


texts: Node ID and node title in panels page URL

texts:
I would like to set up Panels page URL with this pattern: my-site/[node:nid]/[node:title] (i.e. my-site/34/node-34-title).

I don't exactly understand how the Panels page URL setting works with arguments. I can set up the path to my-site/%nid/%title but how can I set it up so that %nid = [node:nid] and %title = [node:title]?

My questions:

How do I configure Panels page to do that?
Panels panes are populated with Views field. Is there anything to do in views to get these arguments?
How can I get transliterated node titles, using Pathauto or Transliterate?

Thanks!


texts: Comment Notification with Message Stack / Message Notify

texts:
The message stack has three main modules: Message, Message Notify and Message Subscribe.

One thing that it can do, is notifying node author of comments in their nodes. This is very much needed feature. At least that's the impression I get.

Can anyone help on how to setup Message Notify to let the node author they got a new comment on their node? Unfortunately there isn't that much documentation on how to do this.

I have installed the Message stack but don't know where to go from there.

Have looked at other options as well. Here are my findings.

There is the Comment Notify module, but there is not very much support at the moment and a lot of open issues. I have installed it but isn't enabled by default for users when they register on the site.

Rules for Drupal 8 does not support this feature yet.


texts: What do I need to create a custom form widget?

texts:
I used hook_field_widget_info() and hook_field_widget_form() to create a new widget for the user reference module. The problem is when I select a value in content edit form using my widget, selected value is not shown in node display page. Also when I go back to the edit form, my selected value is not the default value(is not saved).

Does it need anything else to work properly?

function mymodule_field_widget_info() {
    return array(
       'custom_user_widget' => array(
            'label' => 'Custom user widget',
            'field types' => array('user_reference'),
            'behaviors' => array(
                'multiple values' => FIELD_BEHAVIOR_DEFAULT,
                'default value' => FIELD_BEHAVIOR_DEFAULT,
            ),
        ),
    );
}
function mymodule_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
    if ($instance['widget']['type'] == 'custom_user_widget') {
        $element['uid'] = array(
            '#type' => 'select',
            '#options' => array(1=>'a', 2=>'b', 3=>'c'),
            '#title' => t('Username')
        );
        return $element;
    }
}


texts: Zurb vs. Bootstrap themes: About performance

texts:
I'm trying to decide to use Foundation or Bootstrap as a base theme for a redesign, but even if Foundation have a lot of strengths (native sass support as I've read), it seems that it is waaay bigger than Bootstrap.

Zurb compressed file is about 585.16 KB while Bootstrap is 103.27 KB.

Bootstrap is being used by way more people, but that doesn't necessarily mean that it's better. Any insight about their performance?

I've read several articles about their performance, but none about their "Drupal versions" of each theme.

So, my question is: Does a much, much bigger base theme impacts into performance?

It seems that it does, but I've read somewhere that Bootstrap and Foundation are almost equal in terms of performance. How can that be?


texts: Webform doesn't send email using MIME Mail

texts:
My webform forms doesn't send the email if I set Site-wide default MailSystemInterface class to MimeMailSystem.

It works fine if I set Site-wide default MailSystemInterface class  to DefaultMailSystem

Take a look at my captures:

I was working fine until yesterday, then all the sudden this problem is happening.

How can I trace this?


texts: Recently when i try to add fields in views save option has been hidden, I don't know how it happened, Is there any solution to overcome this ?


texts: Can I remove write protection for all Drupal files?

texts:
Just to prevent hacks, can I remove write protection in all files and directories in my installation, except for in sites/default/files?

I mean I want to chmod to 555 and chown them all to root:root except for files within sites/default/files. For installation/uninstallation I use Drush.

I'm talking about the "Config 1: Web server is running as owner" as described as in What are the most appropriate users and permission levels for Drupal sites on shared hosting?

It seems  my four sites are working fine with this. Is it OK?

This is because to ward off hack attacks which place php files in within site folders.
This almost saved my site from this Highly Critical hack attack but the hacker was able to place php and execute file within sites/default/files as my .httacces was not protected from running php scripts within the files directory.


texts:
I am using drupal 7 built in search module, when I searched for example mechanics it will filter out the results successfully but when I used to write only mech or mechan something like this, it displays no results.

For this I have installed Apache Solr Autocomplete and Porter-Stemmer but I unable to figure out how can I improve my search filtration.


texts: How would I by default have a dropdown block expanded instead of collapsed?

texts:
I want to be able by default have a dropdown block expanded instead of the current default which is to show just the link and if the user clicks on it then it would expand.
Below is some code related to collapsing and expanding dropdown blocks which is contained within a .js file within the default theme (sites/all/themes/fusion/mapsindeed/js).
How would I, by default, have a dropdown block expanded instead of collapsed?

//ability to expand and collapse dropdown blocks
Drupal.behaviors.mapsindeedDropdownBlock = function (context) {
$('.mapsindeed-dropdown-block .content').hide();
  $('.mapsindeed-dropdown-block h2.block-title').bind('click', function(){
  $(this).siblings('.content').slideToggle('slow', function() {
     });
   $(this).parents('.mapsindeed-dropdown-block').toggleClass('expanded');
});
}


texts: How to easily alter an entity's base field definition per bundle

texts:
We are using the group module in Drupal 8, which introduces a custom entity "group". This entity features a "label" base field with the title "Title". As groups administrator, you can create several different group types, which are handled as fieldable bundles of the group entity and inherit its label base field.

Depending on the group type, we wish to override the generic label title within forms, views, templates, and so on to e.g. 'Label', 'Name', 'Branch', 'Department', 'Section', ...

However, the group entity does not expose the label title within its config form as the node module does. So we tried overriding the title using hook_entity_base_field_info_alter() like this:

/**
 * Implements hook_entity_base_field_info_alter().
 */
function mymodule_entity_base_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type) {
  if ($entity_type->id() == 'group' && !empty($fields['label'])) {
    $fields['label']->setLabel(t('Name'));
  }
}

Which works, but changes the title for all bundles.

Our next try was hook_entity_bundle_field_info_alter(). It exposes bundle information, but it does not allow for base fields to be altered. Trying to re-add the base field definition with a different title (in order to let the core merge the field definitions and override the base field definitions) caused different run-time exceptions.

So we ended up in manually altering form build arrays and widget titles, which may cause trouble later when the amount of group types is increasing.

How can we alter the base field's title on a per-bundle base without having to extend the group module or manually altering all occurrences of our group entities' field labels?


texts: How to translate products with Drupal commerce module?

texts:
I'm using Drupal commerce module. I don't see the Multilingual tab in the product type: product at admin/commerce/products/types/product/edit.

How do I make the product translatable? If that is not posible (hard to believe...) how can I just translate the product title?


texts: A hook that would check if the module is enable?

texts:
I'm not looking for hook_enable (which would trigger when the module is been enable).

I have a module that would work alone (lets call it custom_module_1) and I have another module which is an add-on (lets call it custom_module_2) to that module to the custom_module_1. I want to be able to have a different behavior on the custom_module_1 if the custom_module_2 is enable.

So I'm looking for a hook that would be be using on custom_module_1 and would check if the custom_module_2 is enable.

Or how can I check if there is a module enable as a function to have a different behavior on another module ?


texts: Using Contextual Filter to Filter "Entity Selection" on Node Edit won't pull Raw Value From URL

texts:
I'm trying to filter the values available in an Entity References "Entity Selection" list on a node edit form to only show nodes relevant to the current node being edited.

I am using views and have selected the "Views: Filter by an entity reference view" for the Entity Selection Mode.

In my view I have created an Entity Reference Display with a contextual filter. I have tested that the contextual filter works the way I want it to by using "Preview with contextual filters" and entering a sample ID to filter on (1200). It filters just fine.

When I use "Display all results for the specified field when the filter value is not available" all the results display on the node edit form. But as soon as I choose "Provide a default value" -> "Raw Value from URL" then nothing is displayed on the node edit form.

I have checked that the raw value is in the URL: content/assembly/1200 (1200 being the value that works in the "Preview with contextual filters") and am using the right path component to reference it and ticking or unticking "use path alias" makes no difference.

Does anyone know why this would not be working?

Thanks very much.


texts: Allign block content next to title - CSS

texts:
My goal is to display a button group to the right of the page title. Currently it resides in region-content, which wastes space.
I tried adding my own class to the div that contains btn-group class and use margin-top to move it up, but as soon as I save content, I get system help message that overlaps with the button group.

I also tried to add the block to other regions and get same thing if, say, I use breadcrumbs.

What's the best way or what are the classes I should use to position my block with button group to the right of the page title in main-container instead of region-content?


texts: Form elements removed during custom page render

texts:
In a table, I keep a collection of nodes, text and forms that should be rendered on particular generated pages. I run through a loop that builds an output variable based on the the tables type and values. Worked fine in D7 and the text and node pieces are working fine in D8, after some adjustments.  The piece I'm having trouble with is adding a form to the output variable.

In D7:

$output = "a variety of html";
$formname = "triagezipform"; //would be filled in by field value
$form = drupal_get_form($formname);
$output .= render($form);

In D8:

$output = "a variety of html";
$formname = "triagezipform"; //would be filled in by field value
$form = \Drupal::formBuilder()->getForm('Drupal\triage\Form\'.$formname);
$output .= render($form);

I see the form properly at the end of the function that builds the output, but as it goes through Drupal page rendering the Form elements are removed.

Pre-page rendering:

  <form class="triagezipform" data-drupal-selector="triagezipform"               action="form_action_p_pvdeGsVG5zNF_XLGPTvYSKCf43t8qZYSwcfZl2uzM" method="post" id="triagezipform"
                  accept-charset="UTF-8">

  Enter zipcode where your legal issue is
  <input data-drupal-selector="edit-triage-zip" class="form-text form-control" type="text"id="edit-triage-zip" name="triage_zip" value="04643" size="20" maxlength="5"/>

</form>

Post-page rendering:

          Enter zipcode where your legal issue is

Any ideas of how I get forms to show properly when being built this way?


texts:
Hello I would like to ask about views and exposed reference filters. I have problem with displaying my custom view for exposed filter. Can you please help?

Its kind of complex so I will try to describe the structure. I made view which should be used as exposed filter and this view works fine, but cant push it to appear in other view as exposed filter.
All of my users have some cateogies as taxonomy terms. Also every content has this category so I want to show to user only the content which is in category assigned to specific user. There can be more than one category assigned to user. Content has also single value entity reference to manufacturer.
And now I need to have a page for every content type where and I want to display all content in users category with exposed filter of manufacturers. In this filter must not be all manufacturers but only which ,there is content created with this manufacturer and the content is assigned to same category as the user.

Little example for one content type:

  user1 - category: dj, profi video
  user2 - category: hifi
  user3 - category: dj, hifi

  content1 - manufacturer: m1; category: dj, hifi
  content2 - manufacturer: m2; category:dj
  content3 - manufacturer: m2; category: profi video
  content4 - manufacturer: m3; category: hifi

In this point the exposed filter for user1 should display: m1, m2. Or for user2: m3. Or for user3: m1, m2, m3.


texts: Can I setup the Security Kit module via Drush?

texts:
Does a Drush command exist which I can use to setup the Security Kit module? Something like this command:

drush seckit --img-src:self,unsafe-inline?


texts: WSOD - White screen of death only for administrator

texts:
I'm Getting white screen of death only for administrator user for the Drupal site i'm working on. I don't have any problem with users of other roles.

Once I try to log in using admin credentials I'm getting white screen of death (In Chrome - "This site can't be reached"). Then I have to type www.mysite.com/user/logout to logout admin session.

I have removed last two modules I installed to make sure that those modules does not interfere. Please help me regarding this. Thanks


texts: How to remove markups of 'div' and 'span' from the billing info displayed through token

texts:
I am trying to add token for billing information in order confirmation email . The token does its job but also displays markups of 'div' and 'span'. Whats surprises me is all the other tokens in the same email works fine and doesn't display any mark ups, however the issue is only with the token of field type: 'Postal Address' within the billing information profile

These are the two tokens I have used:

[message:message-commerce-order:commerce_customer_billing]

[message:message-commerce-order:commerce-customer-billing:commerce_customer_address]

I added these tokens to email through admin->structure->message type, since I am also using the following three modules: Commerce Message, Message Notify and Message

Any help on how to display complete billing info without markups, as entered in the built in field: 'Postal address' will be highly appreciated. Tried all the checklists in admin->configuration->text format, but no luck


texts:
I have the following code:

print $node->field_carousel_1[0]['filepath'];

What I would like to do is changing the 1, and use a variable instead.

Do you have any idea how I would be able to do this?

What I am aiming for is using a variable to create a looping function to print
"field_carousel_1," "field_carousel_2," "field_carousel_3," etc.


texts: Cookie-less authentication with session ID

texts:
I'm building decoupled drupal site. I need to be able to authenticate REST client via session ID passed in a URL (or maybe custom header) instead of a cookie.

At first I thought about implementing my own AuthenticationProviderInterface that would work pretty much the same as Drupal\user\Authentication\Provider\Cookie does, but when I looked into the Cookie class itself I thought that I should rather play with session object and "teach" it how to read session id from alternative source instead of reading it from a cookie.

How can I do that?

Should I swap session_configuration (which directly accesses Request::cookies) or maybe session service? Do I need to swap them at all?

The crucial part is that I don't want to loose standard cookie authentication. I just want to be able to authenticate with session ID when there is no session cookie.


texts:
Basic caching settings all off:

settings.local.php is loaded:

Bottom of settings.php:

if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
   include $app_root . '/' . $site_path . '/settings.local.php';
}

And it contains:

$config['system.performance']['css']['preprocess'] = FALSE;

Issue: Add any changes to bootstrap subtheme at themes/contrib/tekatheme/css/style.css and save. Refresh page, no change. Has to run drush cr each time.

Running drush cr for each CSS edit is not a solution, it's impossible to work like that.


texts: Can Views theme/rendering be disabled programmatically?

texts:
I'm creating an RSS feed using the default Views RSS display and by default it contains a bunch of characters that cause the output to be invalid XML  (I believe this has to do with bugs within views related to double encoding or other related functions).

So, to fix this, during hook_views_pre_render() I am able to manipulate the fields with php to output valid stuff.  Within views when I "preview" the output, it's exactly as it should be.

However, when I view the actual feed output at the views url, the output has changed because views has done something to render it (I'm assuming putting it thru the theme system, etc), thereby breaking my 'fixes' again.

Manipulation of the fields in the UI (ie. using plain text as the output, etc) don't do what i need, so those aren't an option.

Is there a way, programmatically, to disable any rendering and tell views to output exactly what I'm seeing in the Views preview?


texts:
I'm using Simplenews Scheduler to automatically send a digest of new nodes, by inserting a views token into Body field of the newsletter.

I need to prevent sending the newsletter if the View in question is empty (triggers No results).

Simplenews Scheduler allows for PHP evaluation (see at the bottom of the screenshot):

What do I need to enter there to ensure no new newsletter is created and sent if a certain view (with certain exposed filter or contextual filters options) has no results?


texts:
So a client that I inherited has multiple PHP fields in each of their views.

I'd like to replace them. They're using PHP Code module as well as Views Customfield.

Would I have to write a custom views handler? Or is there some sort of alter that would allow me to basically replace each of these fields/data sources with my own information, without exposing a PHP filter to a user (even an admin user).

Basically I am trying to increase site security.


texts:
My question is; When you create a custom option list in Webforms, where or how does the list get stored?

Explanation:
In the Webforms Module (8.x-5.0-rc13) you have the ability to create custom options lists. The Options configuration page lists reusable predefined options/values available for select menus, radio buttons, checkboxes and Likert elements. (example: gender, sizes). The option lists that are included when the module is installed can be found as a yml files in docroot>>modules>>webform>>config>>install. After creating a custom option list I can not find the files anywhere or find a table in the database with the vales.

WHY?
I have a list of 500 colleges that I want to populate a select list with different option values option text. pasting the list would be much easier and faster than using the interface to create the list.

I tried using a term select but cannot figure out how to define the value. I can only define the display text in the terms.

Sample yml code customized from one of the predefined option lists:

langcode: en
status: true
dependencies:
  enforced:
    module:
      - webform
id: my_colleges
label: US Colleges
category: Demographic
likert: false
options: |
  361623: ALASKA PACIFIC UNIVERSITY
  362001: ANCHORAGE COMMUNITY COLLEGE
  362503: UNIVERSITY ALASKA
  362814: SHELDON JACKSON COLLEGE
  363495: UNIVERSITY ALASKA


texts:
I'm at a loss as to what could possibly be wrong, but I'm definitely seeing some crazy 404 errors, all of which seem to stem from /user/0/orders

For example, if I add a page using the CKeditor for the body, then edit it, the console error will be POST http://www.mysite.com/user/0/orders 404 (Not Found) and the CKeditor will not be displayed.

I'm also receiving an error on some autocomplete fields as follows:

An AJAX HTTP error occurred.
HTTP Result Code: 404.
Debugg information follows.
Path: http://www.mysite.com/user/autocomplete
StatusText: Not Found
...
Page not found
The requested page "/user/0/orders" could not be found.
...

Anyone have a suggestion I might try?

Thanks.


texts:
I have an issue with Facets on search API (Solr Integration).

Facets items are all in lowercase, and thats not how the content type save them, and I've made a query to solr server directly and the index items there have uppercase letters

can someone help me ?

Thx


texts: How do I pass field variables for a database insert helper function

texts:
I am trying to set up a database insert helper function for a group of modules for a program I m using to learn Drupal.

I can't figure out how to use my returned array in my db_insert query, can anyone assist please.

I assumed I could use a for loop as below but that's not working for me, I really appreciate any help you can offer

function my_db_insert($table, $fields) {

// Build up a string based on my returned array via a for loop
$insert_fields="";
foreach ($fields as $key=>$value) {
    $insert_fields = $insert_fields . $key . "=>" . $value . ",";
      //drupal_set_message($key . "=>" . $value . ",");
   }

  // Insert into the database.
$id = db_insert($table)
->fields(array(
  //This is where I need put the result of my array so it will add to the database
  $insert_fields
))
->execute();

return $id;

drupal_set_message(t("Record Added!"));

}


texts:
I'm trying to group content by date in views but instead of utilizing 'Fields' to stylize it, I'm trying to style using 'Content'

Here is an example of what I see right now:

Note Post Title

  This is a test comment 1
  John Doe
  Posted Date October 7, 2013 - 11:15 AM

  This is a test comment 2
  John Appleseed
  Posted Date October 7, 2013 - 11:20 AM

Here is what I'm trying to achieve:

October 7, 2013

   Note Post Title 1
     This is a test comment 1
     John Doe
     11:15 AM

     This is a test comment 2
     John Appleseed
     11:20 AM


texts:
I am trying to filter text and the result replace depends on the language of the node.
The filter process callback function accepts $langcode argument but it always pass as "und".
If I could access the Entity object to check it's langauge that would be perfect.
I've tried to understand where the "und" value comes from and understand that it's from the field settings.
Currently I'm getting the language code from the active $language object and in order to filter per language I set the filter cache to FALSE and I don't wanna do this.

How can I overcome this problem?

Thanks,
Bnaya


texts: Render entity fields retrieved by EntityQuery

texts:
I'm building a table with TableSort retrieved by EntityQuery like explained in this post.

The result fields vary a lot and I have a hard time to figure out how to render the results of the different field types, like dates, arrays of entities, taxnomomies, etc.

The most simple way to format the rows is just outputting the field values:

$row = [
    'data' => [
        $node->title->value,
        $node->field_date->value,
        $node->field_persons->value,
        $node->field_tags->value,
];

Now I want to output every column in a different way:

titles linked to the node
dates formatted and not as timestamps
persons as list with every person name linked to his node
tags as list with every tag linked to it's taxonomy

I managed to get titles and dates outputted like I wanted, but I can't figure out to do that for persons and tags:

foreach ($nids as $nid) {
    $node = \Drupal\node\Entity\NODE::load($nid);
    $link['#markup'] = '<a href="/node/'.$nid.'">'.$node->title->value.'<a>';

    kint($node);

    $row = [
        'data' => [
            \Drupal::service('renderer')->render($link),
            format_date((int)$node->field_date->value,'custom','Y-m-d'),
            $node->field_persons->value,
            $node->field_tags->value,
        ],
    ];
    $rows[] = $row;
}

Is there a more elegant way to output content of individual fields? Or do I have to find out for every field how to output it investigating it's field type and building the result on my own?

How would I do that for persons or tags outputting the list of result with links to their nodes?


texts: How to move the login form to the header?

texts:
I need help in moving over the User login form to the header of the same page in Drupal 7. I am new to Drupal and I am not very familiar with the Drupal hooks yet. How should I achieve this?
This is what I have tried so far.
template.php
function bklyn_theme() {
  $items = array();
  // create custom user-login.tpl.php
  $items['user_login'] = array(
  'render element' => 'form',
  'path' => drupal_get_path('theme', 'bklyn') . '/templates',
  'template' => 'user-login',
  'preprocess functions' => array(
  'bklyn_preprocess_user_login'
  ),
 );

 $items['user_pass'] = array(
 'render element' => 'form',
 'path' => drupal_get_path('theme', 'bklyn') . '/templates',
 'template' => 'user-pass',
 'preprocess functions' => array(
 'bklyn_preprocess_user_pass'
 ),
 );

return $items;
}

function bklyn_preprocess_user_login(&$vars) {
  $vars['intro_text'] = t('Username');
}

function bklyn_preprocess_user_pass(&$vars) {
  $vars['intro_text'] = t('Password');
}

I am not sure how I can integrate the login to show up in the header.
Before

After


texts: Filter Taxonomy reference field on Workbench Access permission

texts:
i need some help with Workbench access based on taxonomy.

This is my use case:
I have this taxonomy structure for my site:
 - Term A
 - Term B
 - Term C

And i have 2 roles:
 - editor
 - editor C

Editor c users must be able to create or update only the term C nodes.

I installed Workbench, Workbench Access and Field Property to control this behavior.
I configured Workbench Access on Taxonomy.
In admin/config/workbench/access/roles i put Roles “Editor C” only in “Term C” Section.

I created in each content type a Taxonomy Reference field, based on Workbench Access (i checked “Workbench Access control field”).
So this fields has two purposes:
 - tagging the node on my taxonomy structure
 - Assign the proper editorial group

The problem:
When an Editor C user adds a content, he can select any term value, not only “Term C”.
In other words the  Taxonomy Reference field display all result.

How can i filter/limit the record of taxonomy reference on workbench access permission?

P.S.
If i check “Require a Workbench Access form element” in admin/config/workbench/access/settings the module add a “core” access control field in each content type.
This fields are filtered on Workbench access permission but i loose my first purpose (tagging the node on my taxonomy structure).

Can anyone help me?
Thanks in advance,
Matteo


texts: Display OR between two fileds in a content type

texts:
I have two fields in a content type. one is file upload field. another one is link field.
Customer can either upload file or give the url to the field.

so I want to display "(OR)" between these two fields in content type.

How this can be achieved.


texts:
My breadcrumbs only show in the original language.
When I change the language, only the heading of the breadcrumb which is in a t() function changes language. I can't put the $breadcrumb variable in the function, the string translation interface is also not the right place for it.
I am using taxonomy menu and taxonomy breadcrumbs modules.
How can I get the breadcrumbs to use either the translated terms or at least work through string translation?


texts: How to intercept the loading of a field?

texts:
I have a field called field_price.  How do I get that field on my page to display Free when the value is $0.00, and the actual value every other time?

I tried to intercept the loading of the field by doing things like:

mytemplate_hook_load(){
// do stuff
}

mytemplate_process_field(){
// do stuff
}

mytemplate_preprocess_field(){
// do stuff
}

etc.. etc.. etc..

I tried so many different permutations of the above as modules, template, changing function names etc...  But none of them ever fire.  I know I have the Field module enabled.

What am I doing wrong?

Note: I am using drupal 7


texts: How do I create a panels variant of a node view for innaccessible content?

texts:
I want to over-ride the access denied error message when viewing a node that the user doesn't have access to.

I'm using the content_access module and panels.

Page manager node_view (Panels - node template)

Variant =>
 Selection rules =>
 Node: type Node being viewed is type "[content type]"
 Node: accessible Logged in user can view Node being viewed.

This works fine, but works the same without the Node: accessible

I create another variant, using a negation argument, everything the same except for the selection rules:

Selection rules =>
  Node: type Node being viewed is type "[content type]"
  Node: accessible NOT (Logged in user can view Node being viewed.)

The behaviour I expect is that, when a Logged in user attempts to view a node of this content type, the default "Access denied" message will be over-ridden and the panel variant will be displayed. However, the Access denied page is still being displayed.

Is there a way to over-ride the Access denied message with a panel variant? If so, how do I do it?


texts:
I am going to check whether a term belongs to a designated vocabulary.

Which function is used to get vocabulary by term or node?


texts: How to get user current location and display node attached with current location?

texts:
I am developing a deal based site in drupal 7. I am using addressfield, geocoder, leaflet and views module to display deals node on leaflet map.

I am able to attach exposed filter "city" so that use can search deals on specific city but I want it like groupon site, where they recognize visitor city and displaying all deals related to visitor current city.

How can I get user current city and display all content related to user city on leaflet map and node view.

Thanks


texts: Executing PHP code only once, when the node is created

texts:
I am using Drupal 7 with  the Token module.
I wrote PHP code using the token field that can satisfy loading a specific node, updating some field values, and saving the node (using node functions).

When editing this node the code run again; I just want to run this code when creating this node. How can I do that?


texts:
I tried to mimic the multiple user deletion feature of user.module but for some reason the confirm form submit handler never get called. I don't know where the problem lies in. Following is a working sample of module except for the function delete_multiple_server_confirm_form_submit which never gets executed.

function mymodule_menu() {

  $items['testservers'] = array(
    'title' => 'Manage Servers',
    'page callback' => 'display_servers_callback',
    'page arguments' => array('delete'),
    'access callback' => true,
  );

  return $items;
}

function display_servers_callback($args = '') {

  $op = isset($_POST['op']) ? $_POST['op'] : $args;
  $op = strtolower($op);
  $build_form = array();

  if (!empty($_POST['table']) && isset($_POST['operation']) && ($_POST['operation'] == 'delete')) {
    $options = $_POST['table'];
    $build_form['delete_multiple_server_confirm_form'] = drupal_get_form('delete_multiple_server_confirm_form', $options);
  }
  else {

    $build_form['display_servers_form'] = drupal_get_form('display_servers_form');
  }

  return $build_form;
}

function delete_multiple_server_confirm_form($form, &$form_state, $servers) {

  $path = current_path();

  return confirm_form($form, t('Are you sure you want to delete %title?'), $path, t('This action cannot be undone.'), t('Delete'), t('Cancel')
  );
}

function display_servers_form($form, $form_state) {

  $header = array(
    'server_name' => array('data' => t('Server Name')),
    'location' => array('data' => t('Location')),
    'protocols' => array('data' => t('Protocols')),
    'status' => array('data' => t('server status ')),
  );

  $servers = array(
    array('server_name' => 'us1', 'location' => 'us', 'protocols' => 'test', 'status' => 'ok'),
    array('server_name' => 'us2', 'location' => 'us', 'protocols' => 'test', 'status' => 'ok'),
    array('server_name' => 'us3', 'location' => 'us', 'protocols' => 'test', 'status' => 'ok'),
  );

  $options = array();

  for ($index = 0; $index < count($servers); $index++) {

    $options[$index] = array(
      'server_name' => $servers[$index]['server_name'],
      'location' => $servers[$index]['location'],
      'protocols' => $servers[$index]['protocols'],
      'status' => $servers[$index]['status'],
    );
  }

  $form['table'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#empty' => t('No servers found'),
  );

  $options = array();
  $operations = array('delete' => array(
      'label' => t('delete servers'),
      'callback' => 'delete_multiples',
    ),
    'suspend' => array(
      'label' => t('suspend servers'),
    ),
  );

  foreach ($operations as $operation => $array) {
    $options[$operation] = $array['label'];
  }

  $form['options']['operation'] = array(
    '#type' => 'select',
    '#title' => t('Operation'),
    '#title_display' => 'invisible',
    '#options' => $options,
    '#default_value' => 'delete',
  );

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

  return $form;
}

function delete_multiple_server_confirm_form_submit($form, &$form_state, $servers) {

  drupal_set_message('working');
}


texts: How to use a term's Pathauto URL in Views so the path can be rewritten?

texts:
I have a node view. I need to create a link to a term that the node it tagged with, but also add an additional part to this URL. So I need something like mysite.com/term-url/additional-bit

For SEO purposes I dont want to link to mysite.com/taxonomy/term/term_id?/additional-bit as is the solution below. Instead I want the nice pathauto url.

How to get or extract the link path for terms in View

Note, the reason that the url mysite.com/term-url/additional-bit works is that im using the sub-pathauto module https://www.drupal.org/project/subpathauto


texts: How to get Node Title and description when nid is avaiable?

texts:
In Drupal 7 I am using following code in Global: PHP.

$data = message_load($row->mid);

if (isset($data->field_related_flag)){
  $fid = $data->field_related_flag['und'][0]['target_id'];
  $ftype = $data->field_flagged_node_type['und'][0]['value'];
  $flag = db_query('SELECT f.entity_id content_id, f.fid flag_id, flag.title type FROM flagging f INNER JOIN flag ON flag.fid = f.fid WHERE flagging_id = :val_fid', array(':val_fid' => $fid))-> fetchAssoc();
  $flag['content_type'] = $ftype;
  return json_encode($flag);
}

And from this code, I get the following output:

'related_flag' => '{"content_id":"410","flag_id":"1","type":"like","content_type":"event"}',

Here "content_id":"410" is the node ID.

Now I need to get the node title, description, and other fields. Can anyone please tell me what code I should write to get the desired result?


texts: Add Custom Line item API or Method Drupal Commerce

texts:
I have some products in a Drupal Website using Drupal Commerce. Those products are listed via a custom modules to the front end. If the user clicks on any of the products then it goes to the product display page. There I have 2 checkbox and the Add to Cart Button. Such as

Gift Packaging ($10.99)
Custom Messages ($4.99)
These are 2 checkboxes coming from a drupal form created on my custom module.
I want to add these as line items to the Selected Product. Such as,

If user choses Product A and Gift Packaging then,
Product A ($10.00)
Gift Packaging ($10.99)
Total : $20.99

So how can I add the chosen line item to that product once the user clicks on the Add to Cart Button. I have a function that is fired once the button is clicked. The function is "my_module_add_to_cart()".
How can I show the updated Price as $20.99 to the /cart page table?


texts:
I am using drupal 8 and have a date field with the values limited to two.

This works well until I have to put it into a view. When I do so, I get two view rows, one sorted by the value of the first value and another sorted by the second value.

I have tried to use aggregation and Count Distinct, but I get a huge error:

  SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'taxonomy_term_field_data_node__field_NAME_2__taxonomy_term__FIELD_NAME_1.FIELD_NAME_1_'
  in 'field list': SELECT COUNT(*) AS expression FROM (SELECT
  taxonomy_term_field_data_node__field_NAME_2__taxonomy_term__FIELD_NAME_1.FIELD_NAME_1_
  AS taxonomy_term_field_data_node__field_NAME_2__taxonomy_te,
  node_field_data.title AS node_field_data_title,
  node__field_address.field_address_value AS
  node__field_address_field_address_value,
  node__field_NAME_3.field_NAME_3_value AS
  node__field_NAME_3_field_NAME_3_value, node_field_data.created AS
  node_field_data_created, 1 AS expression FROM {node_field_data}
  node_field_data LEFT JOIN {node__field_NAME_2} node__field_NAME_2 ON
  node_field_data.nid = node__field_NAME_2.entity_id AND
  (node__field_NAME_2.deleted = :views_join_condition_0 AND
  node__field_NAME_2.langcode = node_field_data.langcode) LEFT JOIN
  {taxonomy_term_field_data} taxonomy_term_field_data_node__field_NAME_2
  ON node__field_NAME_2.field_NAME_2_target_id =
  taxonomy_term_field_data_node__field_NAME_2.tid LEFT JOIN
  {taxonomy_term__FIELD_NAME_1}
  taxonomy_term_field_data_node__field_NAME_2__taxonomy_term__FIELD_NAME_1
  ON taxonomy_term_field_data_node__field_NAME_2.tid =
  taxonomy_term_field_data_node__field_NAME_2__taxonomy_term__FIELD_NAME_1.entity_id
  AND
  (taxonomy_term_field_data_node__field_NAME_2__taxonomy_term__FIELD_NAME_1.deleted
  = :views_join_condition_2 AND taxonomy_term_field_data_node__field_NAME_2__taxonomy_term__FIELD_NAME_1.langcode
  = taxonomy_term_field_data_node__field_NAME_2.langcode) LEFT JOIN {node__field_address} node__field_address ON node_field_data.nid =
  node__field_address.entity_id AND (node__field_address.deleted =
  :views_join_condition_4 AND node__field_address.langcode =
  node_field_data.langcode) LEFT JOIN {node__field_NAME_3}
  node__field_NAME_3 ON node_field_data.nid =
  node__field_NAME_3.entity_id AND (node__field_NAME_3.deleted =
  :views_join_condition_6 AND node__field_NAME_3.langcode =
  node_field_data.langcode) WHERE (( (node_field_data.status =
  :db_condition_placeholder_0) AND (node_field_data.type IN
  (:db_condition_placeholder_1)) )) GROUP BY
  taxonomy_term_field_data_node__field_NAME_2__taxonomy_te,
  node_field_data_title, node_field_data.nid,
  node__field_address_field_address_value,
  node__field_NAME_3_field_NAME_3_value, node_field_data_created)
  subquery; Array ( [:db_condition_placeholder_0] => 1
  [:db_condition_placeholder_1] => recent [:views_join_condition_0] => 0
  [:views_join_condition_2] => 0 [:views_join_condition_4] => 0
  [:views_join_condition_6] => 0 )

How can I have two date values with only one view result?

Thanks in advance!


texts: Features - Should I go for big or numerous?

texts: I have worked on a few Drupal projects that used features.  I am usually perplexed by the way the way functionality is grouped.  I'm guessing that most of them were created as needed and by different developers that did not want to meddle with other people's features.  The outcome is usually a mess of different naming and grouping schemes.  Currently, I have the opportunity to create a site from scratch, and I want to start using a good methodology for creating my feature groups.  I am tending towards making a gigantic feature that contains everything, and only rebuilding one feature every time an update is needed.  What is good/bad about doing this.  Also, I feel more responsible while considering building several different features for each bit of functionality.  However, I am not sure how granular to go, or if this is begging for conflicts later.  How should I be approaching this issue?


texts: when do we need to load user using  user_load($user->uid) after global $user. Why do we need to load a user because we can access user data after declaring it global. I am adding a commerce customer to his billing and shipping profiles, should I use user_load?


texts: The project manager I am working with is convinced that Drupal can be used to develop a web application that allows user input and rating of the input.  I don't see beyond the Content Management uSage of Drupal.  I claim 100% ignorance. Can anyone point me in the direction of a tutorial or articles that can help me grasp how Drupal will work for the web application I desire to develop?


texts: How to make user profile image reflect a transparent background?

texts:
I made a site with Drupal 7.26. Added on the Advanced Forums module with some other things.

Everything works fine except the user profile image is displayed with a white box/background instead of being transparent in the forums and user profile when clicking on the user name. I'm using a png image that has a transparent background.

Here's a cropped screenshot of how the picture is being displayed in the forums.

As you can see there is a white box/background instead of it being transparent. The strange thing is that when I hover over the image with my mouse the white box/background disappears and the image displays as it should.

Here's a cropped screenshot of what it looks like when the cursor is hovered over the image.

That is how I would like the profile pictures to be displayed in the forums should a picture have a transparent background.

Does anyone know of a setting or something on how to get this done?

I'd really really appreciate any help with this as I'm pretty clueless.

Thanks in advance for any replies

Barrels


texts:
I am new to Drupal 7 . I need to integrate opensrs (third party api for domain reselling) with Drupal 7 .
OPensrs provided API ([http://www.opensrs.com/][1])
I don't know how to use PHP APi provide by opensrs. Anybody tell me how to do this.

Thanks a lot


texts: Assign custom id for user on registering

texts: I need to assign custom ids for all users. The Id will come from API and its depend on other filled by user custom field. Witch hook should I use and witch variable holds id value?


texts: What are the differences between the various OpenID widgets available?

texts: There seems to be several different widgets for providing easer registration and login. I'm curious how they work and what the difference between them are? For example, there is the OpenID selector, Loginza, and Janrain.


texts: How write form validation to custom content type form?

texts: I am using the drupal 7 content type like my form i dont know how write the form validation to that particular form.


texts: Getting the user picture URL when Gravatar is installed

texts:
I'm trying to print a user's picture without the link to the user's profile which is what theme('user_picture', array('account' =>$user_item)) will render. If I use image_style_url('thumbnail', $user->picture->uri) the Gravatar hook will not be called.

So far the only way I have found to do this is:

if (function_exists('_gravatar_get_account_user_picture')) {
    $picture = _gravatar_get_account_user_picture($user);
} else {
    $picture = $user->picture->uri;
}
if (file_valid_uri($picture)) {
    $picture = image_style_url('thumbnail', $picture);
}

But this isn't very elegant, especially since I am developing a module and I'd rather not have to explicitly call the Gravatar module.

Any suggestions?

Thanks!


texts: How To Alter Nodequeue or EntityQueue search Autocomplete

texts:
I want to use nodequeue or entityqueue in Drupal 7 and want the autocomplete search for a given queue to use a custom field other than the node title.

Is there a way to do this without hacking the modules? I want the nodequeue autocomplete to work off of a speaker name, rather than the nodes title presay.

I see Nodequeue issues that add query tags to make the query modifiable by developers but all the issues are 2+ years old and none are committed:

https://www.drupal.org/node/2231793#comment-8725319
https://www.drupal.org/node/2446711


texts: Drupal 7 pager from module fuction not displaying in page.tpl

texts:
I have a function mymodule_submissions in my module which fetches rows from mymodule_table and prints as table theme with pager. Its working fine if I define a menu link in my module to call that function. Pager not printing when I call the same function from a page.tpl.

function mymodule_submissions() {

   $query = db_select('mymodule_table', 'uf');
   $query = $query->condition('uid', $user->uid)
             ->fields('mytable', array('id', 'name', 'createdtime'))
             ->orderBy('createdtime', 'DESC')->limit(3);
   $results = $query->execute();
   $header = array('ID','Name','Created Time');

   $rows = array();

   foreach($results As $result) {
      $rows[] = array( $result -> id, $result -> name, $result -> createdtime,);
   }

   $output .= theme('table', array('header' => $header, 'rows' => $rows,) );

   $output .= theme('pager');
   return $output;
}

From page.tpl, I am calling this function link below

print render(mymodule_submissions());

Anything I'm doing wrong?


texts:
I'm using boostrap 3 with modals. I've a button that opens a modal, in the modal there are some facet blocks.
The view has ajax enabled, so when I click on a facet the page is not reload but are reloaded the content of the view AND facets blocks.

I've to execute some js functions when I click on facets links, I've added this js to my theme:

Drupal.behaviors.my_theme = {
    attach: function (context, settings) {
        jQuery('#facets a', context).click(function () {
            alert('enter');
        });
    }
};

The problem is that the alert is executed only on the first click. On second, third etc alert does not appear.

What's wrong?


texts: Create a view of the first entityreferenced child item from a multifield for a list of parent nodes

texts:
I have a node type A containing a multifield of entityreferences to another node type B and using only the views admin interface I want to create a list of the first type B child entityreference on every node of type A.
I think its possible just can't quite figure out how to do it.
Thanks


texts:
Our website was developed with Drupal and we only have a small set of Spanish language pages on a primarily English website.

My question is, I'm getting THREE pages generated for every one page:

.com/node/11
.com/espanol/node/11
.com/conveniences/gift-cards -- all of these use the same English content.

The dev team says this is working as intended as long as there is no Spanish content, we get a Spanish URL as well.

We apparently have 3x the pages now because of this.

Is there something we can do?


texts: Having trouble using responsive feature of Superfish

texts: I am using the Superfish module for Drupal 7.x, and the menu itself works as advertised. However, no matter what configuration options I try, I cannot get the main menu to change into a select menu when at smaller screen sizes. It just attempts to render the original menu (which, of course, becomes a mess at smartphone size).  I'm not even sure where to start looking for a problem.  Any clues would be appreciated!


texts: Auto reply to user is working but no email to admin in contact us

texts:
I want to use contact us form in my website but it is not working. I searched on Google and found many answers but they seems not relevant to me.

I have setup the contact us page and I can see the auto reply to my test email id (GMail) however my website is hosted on some other server, and they have provided the mail box to me.

I can send email directly from the mail box provided by hosting company to GMail. I can also send email from GMail to this mail box. Also I can see the auto reply email after submitting contact us form to my test GMail but I don't see any email to my mail box.

Edit: Just now, I discovered that if I configure GMail id as form submission recipient and then submit form with my hosting mail box email id, I am able to get the email from Drupal. In this case, I am not getting any auto reply to my hosting mail box.

What's wrong here? As I don't see any error in Drupal Log.


texts: How to let a role to change field formatter under view mode?

texts: I don't mean to change view modes, I mean to change fields' formatters arbitrarily by some roles under the same view mode.


texts:
I want to create a fixed amount coupon using rule..

Please tell me how I can create a fixed amount coupon using rules in drupal commerce..
I am creating a rule for gift card by using following step-

after completing the checkout process -event
cart contain a particular product type - condition
create a entity type of commerce_coupon
set value data - entity created coupon code
save entity

Now I am getting a automatically generated coupon but I am not able to assign amount to the coupon code..

How I can assign value to generated coupon code?

& rule code-

{ "rules_gift_card_product_purchased" : {
    "LABEL" : "gift card product purchased",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "commerce_order", "rules", "commerce_coupon", "commerce_cart" ],
    "ON" : [ "commerce_cart_product_add" ],
    "IF" : [
      { "commerce_order_contains_product_type" : {
          "commerce_order" : [ "commerce_order" ],
          "product_type" : { "value" : { "product" : "product" } },
          "operator" : "\u003E=",
          "value" : "1"
        }
      }
    ],
    "DO" : [
      { "entity_create" : {
          "USING" : { "type" : "commerce_coupon" },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:commerce-coupon-code" ],
          "value" : "ord[commerce-order:order-id]ers"
        }
      },
      { "data_set" : { "data" : [ "entity-created:type" ], "value" : "commerce_coupon_fixed" } },
      { "data_set" : { "data" : [ "entity-created:is-active" ], "value" : 1 } },
      { "variable_add" : {
          "USING" : { "type" : "commerce_coupon", "value" : [ "entity-created" ] },
          "PROVIDE" : { "variable_added" : { "variable_added" : "Added variable" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:commerce-coupon-number-of-uses" ],
          "value" : "1"
        }
      },
      { "commerce_coupon_action_create_coupon_line_item" : {
          "USING" : {
            "commerce_coupon" : [ "variable-added" ],
            "commerce_order" : [ "commerce_order" ],
            "amount" : [ "commerce-product:commerce-price:amount" ],
            "component_name" : "commerce_coupon_fixed_giftcard",
            "currency_code" : "[commerce-product:commerce_price]"
          },
          "PROVIDE" : { "commerce_coupon_line_item" : { "commerce_coupon_line_item" : "commerce coupon line item" } }
        }
      },
      { "entity_save" : { "data" : [ "entity-created" ] } },
      { "mail" : {
          "to" : "[commerce-order:mail]",
          "subject" : "your order completed",
          "message" : "[entity-created:commerce-coupon-code][entity-created:commerce_coupon_fixed_amount]",
          "from" : "[site:mail]",
          "language" : [ "site:current-cart-order:state" ]
        }
      }
    ]
  }
}


texts: Successful Query Result but Unable to Display Results

texts:
I'm expecting one row query result in my query commands below:

//Retrieve ID Preview Information fom the database
$query = db_select('student', 't1',array('target' => 'import'));
$query->join('studinfo', 't2', 't1.studid = t2.studid');
$query->join('semstudent', 't3', 't1.studid = t3.studid');
$query->join('program', 't4', 't4.progcode = t3.studmajor');

$result = $query
   ->fields('t1', array('lastname', 'firstname', 'middlename', 'extname'))
   ->fields('t2', array('guardian', 'mobile', 'homephone'))
   ->fields('t4', array('progcode', 'college'))
   ->condition('t1.studid','0006-10014','=')
   ->distinct()
   ->execute();

if($result){
    watchdog('print','successful');
    foreach($result as $row ){
        watchdog('print', 'inside the loop');
    }
}else
{
    watchdog('print','not successful');
}

In my watchdog table in my database, 'successful' is the only log I saw. That means it doesn't get inside my loop which I know for sure that I have one row result. Where am I missing?


texts: How to use latest jquery version on specific page or code?

texts: i am using D7. i want to use jquery1.9 on a specific block. so at where that block visible, only load jquery with it. how it wil??? any help?


texts: Custom field widget with text field formatter?

texts:
I'm trying to create a compound field in Drupal 7 that combines and image field, text field and a textarea field.

I've successfully done this but I'm now trying to add text format option to the textarea and I'm having problems getting it working.

It seems that when I change the widget's textarea field into a text_format field Drupal expands that field into two fields value and format (see: filter_process_format), this means that when the node displaying the field is saved it stores the array into the database and not the field value.

Here is my widget:

/**
  * Implements hook_field_widget_form().
  */
function MYMODULE_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

    $elements = image_field_widget_form($form, $form_state, $field, $instance, $langcode, $items, $delta, $element);

    foreach (element_children($elements) as $delta) {
        foreach ($elements[$delta]['#process'] as $key => $process) {
            if($process == 'image_field_widget_process') {
                unset($elements[$delta]['#process'][$key]);
            }
        }
      $elements[$delta]['#process'][] = 'MYMODULE_widget_process';
    }

    return $elements;
}

/**
 * Element #process callback function.
 *
 * @param array $element
 * @param arrayreference $form_state
 * @param array $form
 * @return array
 */
function MYMODULE_widget_process($element, &$form_state, $form) {

    $element = @image_field_widget_process($element, $form_state, $form);

    $item = $element['#value'];
    $item['fid'] = $element['fid']['#value'];

  $instance = field_widget_instance($element, $form_state);

    $settings = $instance['settings'];
    $widget_settings = $instance['widget']['settings'];

    $element['title'] = array(
        '#type' => 'textfield',
        '#title' => 'Title',
        '#default_value' => isset($item['title']) ? $item['title'] : '',
    );

    $element['text'] = array(
        '#type' => 'textarea',
        '#title' => 'Text',
        '#default_value' => isset($item['text']) ? $item['text'] : '',
    );

    if($instance['settings']['text_processing']) {
      $element['text']['#type'] = 'text_format';
      $element['text']['#format'] = isset($item['format']) ? $item['format'] : NULL;
      $element['text']['#base_type'] = 'textarea';
    }

    return $element;
}

The field value in the database is "Array" and not the string the user entered. If the field is set to a normal textarea the field value is stored correctly.

I'm guessing this is something to do with the structure of the widget but I can't work it out and the documentation is non existent.


texts: Directory permissions and appearance issues after moving site

texts:
I recently moved my drupal site and am having issues with it the most pressing issue is one of permissions for temporary directory. there is also some weird css stuff going on but ill figure them ut when the errors have been fixed. the error i am getting is:
The specified file temporary://filewjfbY3 could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.

Here is where the temp directory is set:

Here is the permissions of tmp in file zilla. the tmp folder is in the root directory.

i have tried creating new temp dir and changing it in the configuration with no success.


texts: In drupal 7 how to add a link to a node which creates another node related to the previous being visible only if a user has not yet done so?

texts:
I have a node #1 of content type A. If the user equals a certain role AND has not yet done the following, show a link within node#1 saying "create node of type B".

If the user clicks this link, he may create a new node of type B. Then, when looking at node#1 again, the link disappears (or changes), since the user has already created another node from within node#1.

If you would delete that last created node and visit node#1 again, you would again have the possibility to create a node of type B which would automatically be related to the respective node, in this case node#1.

How can you do that?


texts:
I got the 2nd level main menu in a block in the sidebar, drupal 8 correctly hides the menu (and the block) when the user browses a page that is not in this menu, but the theme continues to show the empty region.
The condition {% if page.region %} is true.
is there any way to solve this problem?


texts:
In my Drupal Commerce site, I have a product type - an attribute which refers to another product type (via reference product).

The display is:

Type 1

Product 1-1 x

Product 1-2 x

Product 1-3 x

Add to Cart

Type 2

Product 2-1 x

Product 2-2 x

x produces 2-3

Add to Cart

I would like only one "add  to cart" button to be visible, and that clicking it should add  two products which were selected at the same time.

How can this be accomplished?


texts:
function news_article_node_submit($node, $form, &$form_state)
{
// Make a URI link from title of pdf being uploaded
if (isset($form_state['values']['field_upload_import_pdf'])) {
    $file = file_load($node->field_upload_import_pdf['und'][0]['fid']);
    $filePath = file_create_url($file->uri);

    // Redirect to pdf
    isset($_GET['destination']);
    unset($_GET['destination']);
    if (isset($filePath)) {
        drupal_goto($filePath);

        // Return all field behaviors to redirect to default
    } else {
        $form_state['redirect'] = 'to page preview';
        drupal_redirect_form($form_state);
        }
    }
}

I was experimenting with drupal_goto() and $form_state['redirect'], but neither of them seems to work. Using drupal_goto() hijacks the whole module and the $form_state['redirect'] doesn't do anything. Also I am getting PHP errors when else function encounters the first two lines of code above:

  Notice: Undefined offset: 0 in news_article_node_submit()

  Notice: Trying to get property of non-object in news_article_node_submit()

Is there a way to create a URI from the filename, and redirect users to domainname://NAME_OF_FILE.pdf when choosing a conditional field while, at the same time, when users use any other conditional field, the behavior is the default Drupal one?


texts:
I am new in Drupal. Now I am trying to understand basic philosophy of Home->  Administration -> Configuration -> Media -> File system. Public file system path here is:

sites/default/files

is set as public path by default and Public file base URLis therefore:

http://example.com/sites/default/files

Couple days ago not knowing about File system I created folder, where I put some pdf files.

http://example.com/custom_files/pdf

In the article I set hyperlinks to these files and everybody may download these pdfs happily.
And now I do not know at all, why should I bother with File system  public path??? What is it good for, when I may use any folder I want?

Thanks for answers


texts:
I have block with image so the easy way it's to create a content type.
I have node--nodeName.tpl.php where I built correct DOM.

But this is slider, and all nodes embedded in one div with classes

  block-system-main block block-system

I have to initialize slider. For this I need unique parent class\id

This is beginning of my node--nodeName.tpl:

<div class="<?php print $classes . ' slick_hero ' . ' ' . $zebra; ?>">


texts: Correct way to validate config entities?

texts:
In Drupal 8, how do I validate a ConfigEntity? I tried adding constraints, but then I found out this only works for ContentEntity, not ConfigEntity.

My ConfigEntity has 2 fields, and the options of the second field should be limited based on what's selected in the first.

Through Drupals #ajax mechanism I can limit the items in the second dropdown - that all works. However, with Javascript disabled or when creating the ConfigEntity programmatically, someone can still select a wrong value for the second dropdown, that doesn't work with the first dropdown selection. I checked ConfigEntityBase but couldn't find anything related to validation.


texts: How can I place an entity content field value in header markup?

texts:
I need to put an image field url into the header meta tag (open graph image). The obvious ways to put things in the header are in html.html.twig, hook_preprocess_html, and hook_page_attachments. But in any of these, how do I access the content to be rendered in order to see what the image url is?

And this is complicated by the fact that the rendered entity is a commerce product, while the desired image field is on the product_variation entity, with drupal commerce rendering the desired variation using a query string and an EntityViewBulder::alterBuild.

This means I can't use e.g. $product = \Drupal::routeMatch()->getParameter('commerce_product') because we wouldn't know what variation is being shown.

Once the variation is to be had, it would be fine to get the delta 0 image from the image field on the variation.


texts: How to have contextual filters in views accept words instead of ID numbers?

texts:
Possible Duplicate:
  Drupal 7 views contextual filters taxonomy name

I'm using Drupal 7, and what I want is to have my views use a contextual filter, so that if a view is located at mydrupalsite.com/myview I want to be able to go to mydrupalsite.com/myview/topicname and have the view use the topicname to filter the content.  Topicname in this case is a taxonomy item.

I've followed some tutorials and looked at articles about how to create contextual filters.  But the problem I have is that right now the contextual filter does not pick up the topicname in the URL.  The filter does work if I provide the ID number of the taxonomy item, so mydrupalsite.com/myview/93 will work (if 93 is the ID number of the taxonomy item).

How can I get the view to work so that the contextual filter reads the topicname?

Thanks


texts: Is there module to generate form and save into content type?

texts: I find a module to create a form like Webform or Entityform and save this one directly into a node (specific content type or entity).


texts: Migrate Multiple URLs from a Spreadsheet into ONE Link Field

texts:
I'm trying to migrate from Google Sheets into Drupal 8.9+. I have successfully configured most of the migration, but am having trouble migrating two source link fields (Event URL & Ticketing URL) into ONE multi-value links field (field_links) in my target node. I'm trying to shape all the source data in my Google Sheet so I don't have to use custom process plugins.
Here's a link to an example of the Google Spreadsheet I'm using as the source.
I found this Github Gist that led me to believe I could shape the two url fields I have in Google sheets into an array, and have that array be processed by the iterator (now, sub_process) plugin. So I now have a source column called "LinksArray" that merges the data from my "Event URL" and "Ticking URL" columns to create an array that looks exactly like this:
[
  ['title' => 'Event URL', 'uri' => 'https://coolvenue.com/etc'],
  ['title' => 'Ticketing URL', 'uri' => 'https://tickets.com/etc'],
];

And the relevant migration file looks like this:
...

    - name: src_links_array
      label: "LinksArray"
      selector: linksarray
...

  field_links:
    - plugin: skip_on_empty
      method: process
      source: src_links_array
      message: 'field_links is empty. Skipping.'
    - plugin: sub_process
      process:
        title: title
        uri: uri

When I run the migration, It appears to be successful, with no errors, but the content created is missing the links altogether (no titles, no uri's, nothing), so is obviously not working. I tried reformatting the array with and without outer brackets, with and without trailing commas, etc. Nothing works. Is my manually created array being written incorrectly? Do I need to create the array inside the migration instead? If so, I'd greatly appreciate help with that. Thank you!


texts: Beginner drupal user here, I know how to assign permissions to users to add/create content etc., my problem is I am trying to create a specific page where users can go to (from the main menu) to upload content whether it be images, video, etc. and the content is then displayed in its own page, for example, all images are displayed in a separate page called "images" and videos go in "videos", based on what file they uploaded. Is there a module that accomplishes this or am I just


texts: Redirect after a new node is added but not edited

texts:
I have a custom redirect on node submit.

function mymodule_form_alter(&$form, $form_state, $form_id) {
    $form['actions']['submit']['#submit'][] = 'custom_node_submit';
}

function custom_node_submit($form, &$form_state) {
    $form_state['redirect'] = 'request-sent';
}

However, I would like to redirect only when a new node is created but not updated.
How do I check the action being executed on the node ?


texts: Is it possible and reasonable to convert a complicated, heavily styled html page into an editable Drupal site page?

texts:
I already read this:

How to convert an HTML website to Drupal 7 nodes?

and this:

https://www.drupal.org/node/313510

and some more.

Hello,

I have been tasked with creating an editable version of an html page that is heavily based on this template's design:

http://themeforest.net/item/zayra-bootstrap-3-retina-app-landing-page-/full_screen_preview/8135956

http://themeforest.net/item/zayra-bootstrap-3-retina-app-landing-page-/8135956

(not trying to advertise, just to give an idea)

I have read and learned about Drupal in the past week and have reached the point where I feel comfortable:

Tweaking themes.
Adding articles, polls and such plain content.
Messing around with the admin panel.

I don't understand how one would add content that is less "straight forward" to a Drupal site. Is it reasonable to do? Can it be done more easily with other CMSs (like Wordpress)? Should I tell my boss that the CMS should be used for news and articles in other areas of the site but NOT this specific promotional page?

From what I read I realize that I could create a rather complex view and a gazillion nodes and use that to generate an editable promotional page that looks like this template. My concern is that it may turn out unfriendly to the content professional.

I really would like to hear some expertly advice on how reasonably doable the task of creating an editable version of the promotional html page is in Drupal (that looks like the original).


texts: How to customize the default search block form template?

texts:
How can I customize the default search block form template, I now use below template to display a search form block, but this code doesn't allow me to edit and customize each part of this form separately and doesn't have any flexibility.

form--search-block-form.html.twig

<form{{ attributes.addClass('search-form', 'search-block-form') }}>
  {{ children }}
</form>

and then print in my theme by below code:

{{ page.search_box }}

Is there any better template name suggestion with more variables and flexibility in customization?


texts: How to implement Commerce USPS Shipping?

texts:
I have installed the following modules:

Commerce Shipping module (7.x-2.2)

Shipping UI
Commerce USPS module (7.x-2.0)
Commerce Physical Product (7.x-1.x-dev)

Checkout without shipping is working fine.Now in checkout settings I have enabled shipping service and info.

I am able to see USPS shipping method config and rules which are set to default (for now). I tried using different rules but can't see any shipping method in the checkout screen.

I have set production account username and url of the USPS.com (this probably isn't the problem).

I want to know step by step procedure to configure the shipping method and rules to add USPS shipping service.

I have 3 products types from which only one will have shipping service,I can see "Shipping" line item type but how to implement it to the product type so that shipping is shown on the checkout screen or is it optional?


texts: Show the value of a node-form field inside an AJAX field added via hook_form_alter()

texts:
I have created a simple content type "reservation" with an integer field called "field_km" with a default value of 50.
On the node creation form, I want to have a markup field showing the value of the "field_km" field.
So, I have created a simple module with the following code:

/**
 * @file
 * Drupal Module : myresa
 * Adds custom code specific to this Drupal 7 site.
 */

function myresa_form_reservation_node_form_alter(&$form, &$form_state, $form_id) {
  $form[‘box’] = array(
    ‘#type’ => ‘markup’,
    ‘#prefix’ => ‘’,
    ‘#suffix’ => ‘’,
    ‘#markup’ => ‘Price not computed',
  );

  $form[‘mybtn’] = array(
    ‘#type’ => ‘button’,
    ‘#id’ => ‘mybtn’,
    ‘#ajax’ => array(
      ‘callback’ => ‘myresa_callback’,
      ‘wrapper’ => ‘box’,
      ‘name’ => ‘mybtn1’,
    ),
    ‘#value’ => t(‘Compute the price’),
  );
}

function myresa_callback($form, $form_state) {
  $element = $form[‘box’] ;
  $element[‘#markup’] = «The price for » . $form_element[‘field_km’][‘#default_value’] . » km is 35 euros» ;
  return $element ;
}

The form shows the 'box' markup, the button, and when clicked the button activates the callback and shows the wanted text, but not the value of 'field_km'.
It is probably a simple syntax mistake, but it beats me.


texts: diffrent theme for admin without use theme appearance config

texts: by default Drupal(7) use "page.tpl.php" for all(front and admin) pages.but I want use another file for example "page-admin.tpl.php" for admin layout.i don't want change admin theme in config/appearance.


texts: I have created a webform. There is one field "Send invitation to your friends" . In this field user can enter their friends email ids (Comma seperated) For example A@gmail.com,B@yahoo.com,C@hotmail.com etc. I want to send a common email "Welcome and join us" to all these people. Can anyone help me, how can I proceed?


texts: ajax pager working depends on if js file is loaded in module .info file

texts:
I'm using the code I've outlined in my blog post for a custom image search, and I'm having a problem with the pager, but only on one site. The first page of results renders just fine, but when I try to go to a subsequent page, I get a white screen with JSON; the page modal window is not rendered.

Here's the relevant code where it breaks:

  $form_state['values']['title'] = t('Search Results - Page !page', array('!page' => $pager + 1));
  $output = ctools_modal_form_render($form_state['values'], $build);

  print ajax_render($output);
  drupal_exit();

What's weird is that I have this exact same code working on two different sites, and it works fine on one, but not the other. I've looked at every possible variable I can think of, and they're all the same:

Drupal core version
jQuery version
module code (custom and contrib, Filefield Sources in this case)
form output sent to ajax_render
returned output from ajax_render

What else could I be missing that causes the JSON not to be rendered? I'm not looking for code specific info, just bigger picture items I could be missing.

Thanks.

UPDATE: So it looks like the problem has to do with the loading of my Drupal behaviors js file (seen at the bottom of this post. If I load it in the module .info file, the pager works fine, but if I attach it anywhere else - either to the node edit form or the ctools modal form - the pager chokes. I've inspected the page, and my js file is loaded in the page and ctools classes assigned to the pager buttons before clicking the pager, so it's not like they're not there. Unfortunately, for some reason, loading this file in the .info file causes other problems, so we can't do it globally.

But why would the method of loading the file make a difference as long as it's loaded?


texts: Mapping field columns with D8 migrate and d7_node source plugin

texts:
I'm trying to write a D8 migrations files but the following one isn't working on the source 'body/value' because it resolves to a null value instead of the intended string.

id: my_d7_node_news
label: 'Nodes (News)'
langcode: en
status: true
dependencies: {  }
class: Drupal\migrate\Plugin\Migration
field_plugin_method: null
cck_plugin_method: null
migration_tags:
  - 'Drupal 7'
source:
  plugin: d7_node
  node_type: news
process:
  nid: tnid
  vid: vid
  title: title
  uid: node_uid
  status: status
  created: created
  changed: changed
  revision_uid: revision_uid
  revision_log: log
  revision_timestamp: timestamp
  'body/value':
    plugin: get
    source: 'body/value'
  'body/summary':
    plugin: default_value
    default_value: some summary
  'body/format':
    plugin: default_value
    default_value: rich_text
destination:
  plugin: 'entity:node'
  default_bundle: news

I tried multiple writing for the source: 'body/value' (e,g: source: body_value, etc, ...) with no luck...

Which syntax should I use to make successful mapping on body/value: body/value using the d7_node source plugin?


texts:
I am able to create a media object with the below code

 $static_media = Media::create([
'bundle' => 'document',
'uid' => $current_userid ,
'langcode' => "en",
'status' => 1,
 'name' => [
    'target_id' =>$title,

  ],
$file_name => [ 'target_id' => $fid, 'alt' => $title, 'title' => $title, ], ]);

but when I try to do $result=$static_media->save();  I get the error

Error: `Call to a member function isEmpty() on null in Drupal\media_entity_document\Plugin\MediaEntity\Type\Document->getField() (line 43 of profiles\lightning\modules\contrib\media_entity_document\src\Plugin\MediaEntity\Type\Document.php).

How can I debug this to find out what is missing?  I tried putting an echo at that point of the code in the plugin but cannot see anything .  What would you suggest to try to see what field it is looking for at that point?

Thank you .


texts:
I have this code that I am trying to get back to d6

 $field_name = variable_get('blogger_importer_node_tag_field', '');
 $instance = field_info_instance('node',$field_name,variable_get('blogger_importer_node_type', ''));
 if (module_exists('taxonomy') && $field_name && !$instance) {
 return drupal_set_message(t("Invalid tag fields selected for node type."), 'error');
 }

I am trying to figure out how to address the $instance area in this code as it was a new field variable in d7

I am just looking for kinda of a way to get it together I saw this maybe I can get somehting out of here http://drupal.org/node/728792


texts: How to place the pager for a view in page.tpl.php?

texts:
I have a view on my front page showing the latest posts, but the design of the website implicates the pager to be located outside the content area of the view (way across in the sidebar). Is there a way I can place the pager in the sidebar in page.tpl.php? I'm using my own custom theme. Any help is greatly appreciated, otherwise I'll have to hack up some CSS positioning but I'd rather learn more about drupal 7!

Thanks!