texts: how to make view with a separate submenu that belongs to panel?

texts:
My name is Leith from Korea

I have a question

what I try to make is a dynamic pages with panel and view like this

main menu : A | B | C ( C is the menu having sub menu )

sub menu area : AA | BB | CC | DD | EE

content area : when clicking on each content, content area shows of each content.

I found the solution :

create one view page, and then clone 5 different views with filter conditions for each sub menu by using texonomy.
set the path to each views like /C/AA, /C/BB, /C/CC, /C/DD, /C/EE
and then as for the views for sub menu, menu setting be menu tab.

until now everything is good. but "I want to put this view in panel then, I can control the layout of the dynamic views".
but as far as I know view page cannot be put into panel. the only thing can be put into panel is view block rather than view page.
and also mini-panel is like block, so there is no way to create sub menu. it only show just one view with one filter condition

Is there any way to put the view page into panel page?

or is there better way you can suggest me?

I want to make a board exactly the same as this board

it has sub menu
when click the sub menu, it filters to the related posts on the table
and I think it belongs to panel.


texts: How do I only allow authenticated users to interact with Organic Groups "groups"?

texts:
Organic Groups 7.x-2.6
Domain Access 7.x-3.11
Domain Access Bridge (module that ties DA and OG together)

Hello, I am using Organic Groups with Domain Access.
I found I was unable to only allow authenticated users to see/post/subscribe to groups.

Someone mentioned Access Control.  I am using Domain Access and tried installing Access Control on top of Domain Access and Organic Groups.  I was able to only allow authenticated individuals to interact with groups, but I ran into an issue where if a group was set to "private" only group admins could see the group, even if the non group admin was actually a member of the group.  With Domain Access and OG it is not recommended to install another access control module, so it is not surprising this combination failed.

This really seems like this should be a part of OG (a sentiment that I have heard quite a bit on the net).


texts:
I am working on Drupal 6  my php.ini settings are:

SMTP = localhost
smtp_port = 25

in module in am using

function article_mail($key, &$message, $params) {
  switch ($key) {
    case 'invitation':
      // note: data can be passed to this function in the $params array
      $message['subject'] = t('EMAIL SUBJECT');
      $message['body'] = t('MESSAGE BODY');
      break;
  }
}

and in code i use

$params = array(  'myVar' => 'data you would like in your message and/or subject',);
drupal_mail('article', 'invitation', 'sanjaydev@xolva.com', language_default(), $params);

but it gives

  warning: mail(): Failed to connect to mailserver at "localhost" port
  25, verify your "SMTP" and "smtp_port" setting in php.ini or use
  ini_set() in C:\Program Files (x86)\Apache Software
  Foundation\Apache2.2\htdocs\benthamdirect\includes\mail.inc on line
  193. Unable to send e-mail. Please contact the site administrator if the problem persists.

Can anyone suggest where I am going wrong?


texts: How to include jquery.js before other javascript includes?

texts:
I'm using a jquery carousel on my site and getting some errors on some pages. My jquery guru said the cause of the problem is that currently jquery.js gets included after other javascript includes.

Making the jquery.js the first include will fix the problem according to him. How do I change the order of the javascript includes?


texts: How to unset fieldset in hook_form_alter?

texts:
I want to unset a fieldset programmatically which is available in the content type. I tried to unset like this in hook_form_alter,

 unset($form['field_first_deposit']);

But it doesn't work, where as hiding individual fields works in the same format. I tried hide() too , but still it doesn't work.

Any help will be much appreciated and Thanks in advance.


texts: Image upload: Failed to open output stream

texts:
I created a media entity browser and for the image upload widget i choose the DropzoneJS.The widget settings are in the image bellow, pretty standard.

And regardless of image type (png, jpg, jpeg) any image selected for upload returns with the follow error message "Failed to open output stream". I'm guessing the upload is ok but it can't be saved?

The public dir is writable (sites/default/files). This is tested successfully when for the widget type i choose normal file upload. The image is uploaded and saved successfully.

Dropzone lib is the most current one from their master branch on GIT (was previously on 4.0.1 but i thought that the version is outdated and that was causing the issue, i was wrong).

Core: 8.5

Any ideas?


texts:
I have a client Webform and I use a custom template for delivering the submissions to the Gmail inbox. I've set the sender's email to the component e-mail field.

The problem is that Gmail puts all the received emails into one thread as if though the sender is the same for all the emails. So it becomes impossible to manage the clients emails as everything is being mixed up.

Is it a Webform configuration or am I missing something?


texts:
I ran my site through Google PageSpeed Insights and got the following message:

Optimize CSS delivery of the following:

First it lists two CSS files I don't recognize in /sites/default/files

Second, it lists my font awesome css which I'm LINKING to from my .libraries.yml file, like so:

font-awesome:
  remote: https://fortawesome.github.io/Font-Awesome/
  version: 4.5.0
  license:
    name: MIT
    url: https://fortawesome.github.io/Font-Awesome/license/
    gpl-compatible: true
  css:
    theme:
      https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-
awesome.min.css: { type: external, minified: true }
    bootstrap/assets/javascripts/bootstrap/transition.js: {}

So my question then is two-fold:

Short of using another module such as Addvagg

1) How can I speed up delivery of the font awesome css?

2) What are those other CSS files and how can I speed up delivery of them?


texts:
I'm customizing a theme and need to have a leaderboard on top of the page. Everything good - on all pages but not the home (front-page)... Any ideas what I did wrong?

I've added a region to the .info file

regions[topad] = Leaderboard header

and printed that region to the page.tpl.php like that:

 <?php if ($page ['topad']): ?>
   <div id="topad">
        <?php print render($page['topad']); ?>
   </div> <!-- /#topad -->
 <?php endif; ?>

I added a block with the leaderboard infos to the region and told it to show up on every page (also tried specific pages with "" - didn't work).

I'm happy for every hint.

Thank you!

Best

Chris


texts: How do I change the HTML surrounding a particular node?

texts:
I'm new to Drupal and have been tasked with fixing some HTML on a page.

There are 3 seperate sections on this page, one of which needs a couple of new classes. I've identified the section I need to change is Pane within a Node (I think). However, I cannot find what .tpl file actually influences the output of this.

How do I find out which .tpl file houses the HTML for a given Pane?


texts:
I want to add a new field to node  table using db_add_field when intalling a new module, but it seems there is something wrong or missing:
here is the code used:
/**
* Implements hook_schema_alter()
*/
function smart_delete_schema_alter(&$schema) {
  // Add field to existing schema.
  $schema['node']['fields']['show_in_inbox'] = array(
    'type' => 'int',
    'length' => '4',
    'default' => '1',
    'not null' => TRUE,
    'unsigned' => TRUE,
    'description' => 'Field added by Smart_delete module',
  );
}

/**
* Implements hook_install()
*/
function smart_delete_install(){
    if (!db_field_exists('node', 'show_in_inbox')) {
        $schema = drupal_get_schema('node');
        db_add_field('node', 'show_in_inbox', $schema['fields']['show_in_inbox']);
    }
}

ADD :
I made an db_query in hook_init() inside .module file :
$result = db_query("ALTER TABLE `node` ADD `show_in_inbox` TINYINT NOT NULL DEFAULT '1';");

this is working, but the same db_query in .install file is not working when disable/enable the module again!
(I cleared the cache, also add the file in .info file)


texts: Any solution to use two different $base_url's for drupal 7. What i need to do is when i log to my site using IP/VPN, $base_url should be xxxx.xxxx.xxxx.xxxx and without any vpn connections $base_url should be aaaa.aaaa.aaaa.aaa. Any solutions? I'm Using Drupal 7.54


texts: Change field type with hook_update_n for a module

texts:
Hello I need to update the field type of one of my content types. The content type is of a module so I need to do this with the Drupal API for let users update the module for their 7.x-1.0 branch.

This is the hook for update the field, I need to change it from Integer to Decimal like this:

 /**
 * Change field_inq_description field from Integer to Decimal
 */
function field_updates_update_7100() {
  // Manual database changes.
  db_query("UPDATE {field_config} SET type = 'number_decimal' WHERE field_name = 'field_rin'");
  db_change_field('field_data_field_rin', 'field_rin_value', 'field_rin_value', array(
    'type' => 'numeric',
    'precision' => '10',
    'scale' => '2',
  ));
  db_change_field('field_revision_field_rin', 'field_rin_value', 'field_rin_value', array(
    'type' => 'numeric',
    'precision' => '10',
    'scale' => '2',
  ));
  // Clear caches.
  field_cache_clear(TRUE);
  // Apply the new field instance configuration.
}

After I apply the update with update.php script I get these notices everywhere in the test website.

Notice: Undefined index: precision in number_field_schema() (line 35 of /home/servilla/public_html/servillantasgiraldo.com.co/modules/field/modules/number/number.install).
Notice: Undefined index: scale in number_field_schema() (line 36 of /home/servilla/public_html/servillantasgiraldo.com.co/modules/field/modules/number/number.install).

What Im I doing wrong?


texts: How to change "Your name" label in comments form?

texts:
I have a blog with comments and I need to change the "Your name" field to something different and make it a required field.

Can I do this from hook_form_comment_form_alter() hook in template.php or in a comments template?


texts: Why user's rights has that impact on my Views pages?

texts:
I have two custom entities (Adhérents and Personnes) linked to each other and to User.

One 'Adhérent' is mainly a "family" and has these fields: label, adresse (postal address), Téléphone (landline phone number), date d'adhésion (Membership start date).
One 'Personne' is a "person" ;-)  and has these fields: Nom (Lastname), Prénom (Firstname), Portable (Cellphone number).

Each 'Personne' is linked to one 'Adhérent'. One 'Adhérent' may be linked to many 'Personne' (one of these 'Personne' being the 'contact').  Each 'Personne' is linked to one 'User'.

'Personne' is defined as entity_reference for 'Adhérent' (as the 'Contact'):

$fields['contactid'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('Contact'))
  ->setSetting('target_type', 'association_personne')

'Adhérent' is defined as entity_reference for 'Personne':

$fields['adherentid'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('Adhérent'))
  ->setSetting('target_type', 'association_adherent')

'User' is defined as entity_reference for 'Personne':

$fields['userid'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('Utilisateur'))
  ->setRequired(TRUE)
  ->setSetting('target_type', 'user')

I use Views to publish all these contents (see Screen captures below).

When I look at the output with a user with no specific rights (i.e. not Administrator), some of the data are not displayed:

In the 'Adhérents' view, the Contact column is empty (see capture 2) while there is a link to the entity (see capture 1).
In the 'Personnes' view, the link to the entity_reference 'Adhérents' is there but the link to 'User' that should display email address (see capture 3) is completely absent, the column header is not even there (see capture 4).

Any idea?

The Permissions as they are set:


texts: Hide a particular radio box item in a set

texts: I want to hide a particular item from an entity field that is using a radio box as widget. Can I achieve this using hook_form_alter()?


texts: Drupal Views to Display Fields for Each Nodes of One Content Type

texts:
I have a Content type which has Term reference type of fields called Tags and Categories and a default field like Body (Long text and summary).

What I want to be able to do if possible is to have a View display these fields such that when this Content type is viewed, Tags and Categories are brought up by a View which will list the values in that field specific to that node, and any other field will be brought up the default way (through Manage Displays).

I figured that since that Tags and Categories are fields I didn't want to be visible, I set them to Hidden in Manage Display. So at least this part is done.

As for making Categories and Tags appear as a View in a Block, is it possible to do this by using Views Relationships and Contextual Filters? If so, how?

Here's a little graphic to help you visualize what I'm trying to do"

http://i.imgur.com/Rn5ukNn.png

Any help is appreciated. Thanks in advance!


texts: Drupal users taking a long time to delete

texts:
I am having trouble deleting users (mainly bots) from my Drupal site. When I go through the process to even delete one user it takes SO long, and eventually times out. This was not the case a couple months ago. Would this be something to do with my hosting company, or site related? I have the bulk operations module and various other ones, but this is happening even if I go into user management and just delete one selected user.

Any ideas will help!

Thanks!


texts:
This might be a very simple question, but I can't figure out the answer.

I love the overlay module in drupal 7, but I am annoyed by the lack of visual feedback when a form is submitted in an overlay. eg. admin/structure/block, hitting submit doesn't give any indication that something is happening in the background.

I would love to know what I have to do to attach some behavior to the submit button of a form in an overlay that provides visual feedback that the form has been submitted (like greying out the overlay or something).


texts: Commerce coupon only one coupon active at a time

texts:
I have 3 types of coupons on my site, 2 of them are contrib(fixed amount and percentage amount) and 3rd one is custom(pretty much copy of percentage).
  I need to make sure, that only one coupon of custom type can be active at given time. Which hooks should I use to make sure that when one coupon of custom type is made active, the other one becomes not active?

Thanks in advance


texts: Dynamic pricing of products/line items with a "pricing entity"

texts:
I'm trying to achieve a pricing functionality in which product/line item's price is configured in an external entity. So that I can have one product which can be priced by multiple entities depending on which is being viewed.

This external entity is a "host" entity or a product display which has two fields: product reference and a price field (float).

Now, when customer visits this host entity page and adds a line item to cart it should change the price according to host entity price field.

At first I tried this with Rules but it was just so inconsistent that I decided to look other options. So here's a piece code that I think could solve this:

    // Alter the price in list and single product page.
function commerce_dynamic_pricing_commerce_product_calculate_sell_price_line_item_alter($line_item){

    if ($node_wrapper = entity_metadata_wrapper('node',_commerce_dynamic_pricing_menu_get_any_object()) ) {

        if ($node_wrapper->type->value() == "price_list") {

            $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);

            dsm($line_item_wrapper->commerce_unit_price->amount->value(). 'Old price');

            foreach ($node_wrapper->field_collection_licenses as $key => $license) {
                if ($line_item_wrapper->commerce_product->product_id->value() === $license->field_license->product_id->value()) {
                                            $line_item_wrapper->commerce_unit_price->amount->set($license->field_license_price->value());
                }

                $line_item_wrapper->save();
            }

            dsm($line_item_wrapper->commerce_unit_price->amount->value(),'New price');
            }
        }
}

The problem with this code is that the price isn't changed/updated. I'm not sure that how the price should be modified.


texts: hook_form_alter - validation function does not get called in Internet Explorer

texts:
I created my own function to validate username and password from the login form, and it's working great in FF and Chrome, but does not work in IE 8 and 9.

I'm using hook_form_alter to catch the loginform and then I replace the default validation function "user_login_authenticate_validate" with "my_own_validation_function" in the $form['#validation'] array.

But for some reason the new validation function never gets called in IE, but I've verified that the default validation function is replaced by printing the $form info, and it all looks great.

I'm not really sure of where to go from here, I've spent way to much on this now ;)

Any help appreciated!


texts: adding or remove multiple classes with attributes.addClass

texts:
In my page template I can add a single class and remove a single class like this
<aside{{attributes.addClass(sidebar_first_classes).removeClass('content_classes') }}> But now I want to add a single class and remove two classes, and this does not work
 <asideright{{attributes.addClass(sidebar_second_classes).removeClass('content_classes','sidebar_first_classes') }}>


texts: How to change the view for a "Views: Filter by an entity reference view"-mode entity reference field on the node/add or edit form?

texts:
I have 2 content types: registration (R) and class (C). R has an entity reference field which is referencing to C using the "Views: Filter by an entity reference view" mode. The entity reference field must use the select list widget. User account also has an entity reference field field_default_class which is referencing to C. Because of business logic, the field_default_class's value never exists in the entity reference view's filtered result which is used in the R node.

Now if an authenticated user adds or edits a node of R, I need to check if current user's field_default_class is set or not. If set, I need to pragmatically set the R's entity reference nodes' select list to the user's field_default_class's value, then disable the select list for disallowing user to change the value.

I guess it's difficult to set a select list's option value which is not in the view's filtered results. Or maybe my codes as below have errors. But I don't know where is wrong :-(

/**
 * Implements hook_form_alter().
 */
function sisucustom_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'registration_node_form') {
    global $user;
    $account = user_load($user->uid);
    if (isset($account->field_default_class['und'][0]['target_id'])) {
      $entity_node = node_load($account->field_default_class['und'][0]['target_id']);
      $options = array($entity_node->nid => $entity_node->title);
      $form['field_register_for_class'][LANGUAGE_NONE][0]['target_id']['#options'] = $options;
      $form['field_register_for_class'][LANGUAGE_NONE][0]['target_id']['#default_value'] = $entity_node->nid;
      $form['field_register_for_class']['LANGUAGE_NONE']['#attributes']['#disabled'] = TRUE;
    }
  }
}

Or, is it possible to change the associated view to the entity reference field in node R? Because I can create another entity reference view which filters out only the one C which equals the current user's field_default_class's value. If it is, how to do it (in which hook)?

PS: I heavily use conditional fields module in node R. So maybe there are some pits against my goal. How to avoid those?


texts:
I have write a migration class to enter the value in custom table. But I want to know that how to rollback custom table entry.

I used :

public function complete($entity, stdClass $row) {
  // db_insert in my custom table
}

I want to rollback the above changes. For this I tried the completeRollback method below but it is not working.

public function completeRollback($entity_id) {
  dsm($entity_id);
}


texts: I have my location module enabled but I cannot see a location field while creating a new form.How can I add location field to a content type.


texts: Using AJAX to access the content of a view

texts:
I have a simple view with one exposed filter that displays a table view of contents.(for example nodes are some addresses with the exposed filter of the city). And I made a map for cities;I want that whenever user clicks on a city in the map, the selected city become exposed filter of view and view become refreshed without refreshing the whole page.is it possible?
I thought that I can use something like:

$.get(
'/myviewpage',
{myfield=14},
function(data){  $('#SomeOtherDiv').html(data) }
);

I tried that but I got unauthorized error. if it's correct; how can I make a page view-able for everyone?
thanks


texts: What is an alternative and easy way to test if Webform is in fact sending mail?

texts: I'm not sure if its the webform module or my server, but a few days ago i was receiving webform submissions via email, but today its not working when I did a test on the same webform. Is there a easy way to test if its webform that's the issue or my server?


texts: Get pre-processed data from nested Paragraphs

texts:
I am new to Drupal and building a theme with Drupal 8 + PatternLab. Instead of printing the actual paragraphs, I just extract the data from the fields and pass it to the front-end twig modules. For example, I have a "Hero" paragraph with a nested "Video" paragraph. The "Hero" paragraph has a "Title" field and the "Video" paragraph has a "Video URL" field. The "Video URL" field is of type "Media", which would be a reference to an entity. Here is the template for the paragraph:

// paragraph--hero.html.twig
{%
  include '@organisms/o-hero.twig'
  with {
    title: data.title,
    video_url: ???
  }
%}

Here is the THEME.theme:

function THEME_preprocess_paragraph(&$variables) {
  foreach ($variables['content'] as $field => $fieldData) {
    if (isset($fieldData['#field_type'])) {
      $newField = preg_replace('/^field_/', '', $field);

      // text
      if (in_array($fieldData['#field_type'], ['string', 'string_long', 'text', 'text_long'])) {
        if ($fieldData['#is_multiple']) {
          $variables['data'][$newField] = array_map(function ($item) {
            return $item['value'];
          }, $fieldData['#items']->getValue());
        } else {
          $variables['data'][$newField] = $fieldData['#items']->getValue()[0]['value'];
        }
      }

      // link
      if (in_array($fieldData['#field_type'], ['link'])) {
        $link = $fieldData[0];
        $title = $link['#title'];
        $url = $link['#url']->toString();
        $target = $link['#options']['attributes']['target'] ?? null;
        // echo '<pre>'; var_dump($link); exit;
        if (!$fieldData['#is_multiple']) {
          $variables['data'][$newField] = [
            'title' => $title ? $title : null,
            'href' => $url ? $url : null,
            'target' => $target ? $target : null
          ];
        }
      }

      // image
      if (in_array($fieldData['#field_type'], ['entity_reference'])) {
        if (!$fieldData['#is_multiple']) {
          if (isset($fieldData[0]['#media']->field_media_image)) {
            $image = $fieldData[0]['#media']->field_media_image;

            $imageUri = $image->entity->uri->value;
            $imageUrl = file_create_url($imageUri);

            $variables['data'][$newField] = [
              'alt' => $image->alt,
              'sizes' => [
                'default' => $imageUrl
              ]
            ];
          }
        }
      }
    }
  }
}

This way I get the data variable with only the data I need in the front-end. But the problem is that when using a nested Paragraph, it won't go through the pre-process functions since it's not actually being rendered, only its data are being extracted. Now, I can access the "Video URL" media inside the "Video" paragraph, but it only gives back the Entity ID value, and it doesn't get populated with the actual Entity values so I can extract the video thumbnail / title / url.

I am not sure if I could explain this correctly, but I want to be able to access content.field_video_paragraph fields same way I access the main paragraph field content.field_title.


texts: How to get File entity in media_presave hook?

texts:
I want to get the file entity out of an media image bundle to the get the filename to check if the image is cmyk or not.

/**
 * Implements hook_ENTITY_TYPE_presave().
 */
function hook_media_presave(MediaInterface $entity) {
  if ($entity->bundle() == 'image') {
    $field_definitions = $entity->getFieldDefinitions();
    foreach ($field_definitions as $field_definition) {
      if ($field_definition->getType() 'image') {
        // get File entity here.
      }
    }
  }
}

How do I do this?


texts: Show initially 4 fields for Text field with unlimited value

texts:
I am building a website using Drupal 7. In my website there is a form for user to add some content.

In the form there is a field of type "Text Field" (core). The "Number of values" for this text field is "unlimited". Thus, when the form appear in the first time,there is only one text field and a button- "add another item". Then users can add more items / fields just by clicking on the button. the problem is that every clicking takes time to process, and this is not best-practice for my opinion.

I want that always will appear at least 4 fields on the form (and not one). If the users will want, they will be able to just click on the button and "add another item" (regularly).

How can I can display 4 text fields (and not only one)?

here is a screen-shot for example:


texts:
I'm using 6, and I CANNOT get hook_menu to take me to the page where the form is. I go to www.myurl.com/test_form (and for good measure, www.myurl.com/?q=test_form) to check.

If I clear the caches, then I get a WSOD. If I don't, I get a 404. I have changed permissions and cleared caches and tried to figure out what Drupal wants with no luck. What did I do wrong?

function module__menu() {
      $items = array();
      $items['test_form'] = array(
            'title' => 'New Form',
            'page callback' => 'drupal_get_form',
            'page arguments' => array('module_form'),
            'description' => 'Form',
            'access callback' => TRUE,
            'type' => MENU_CALLBACK,
      );
      return $items;
}

function module_form($form_state) {
$form = array();

    //my form stuff.....

    return $form;
}

UPDATE: Thanks for the advice. Did what you guys said. Still no luck. Error log doesn't show any errors either, so I'm totally lost here.


texts:
We sell hosting and domain name registrations. My problem is with the hosting where you have, for example: "Shared Hosting" with Package A and Package B. Prices are as follows:

|           | Package A | Package B
| 3 months  | 5 USD     | 15USD
| 6 months  | 8 USD     | 20USD
| 12 months | 14 USD    | 30USD

Now, I can add two attributes, one for "package type" and another for "period". So you can choose, for example, package A for 6 months. The problem is, ubercart doesnt quite work like that. It would ADD an amount, depending on what you choose, when I need fixed pricing for a specific combination. Woocommerce does this beautifully.

How do I do it with Ubercart and Drupal 7?


texts: Price field with Currency outside of commerce and ubercart

texts:
For a real-estate (realty) website I need to store and display the price, but the best D7 module for this is the price component of Commerce module. Is there a Price/Money field on D7?

I have found the following modules:

Measured Value Field - Cool idea spans a lot of value types - D6
only
Units API - Really more for measurement, integrates with MVF
Format Number - Most recent dev version but not sure how rough this version is


texts: Getting translations programmatically from non-default language

texts:
Scenario: I have the original string: "Perro", which has its translations: EN => "Dog", FR => "Chien".
Mission: In my custom module, I have the string "Chien" and I need to get its English translation, "Dog".


texts: template.php function for adding field CSS classes

texts:
I'm using Drupal 7 with Bootstrap. I copied the sub-theme and renamed all the files accordingly and everything works fine, however I'm having problems with my sub-theme's template.php not doing what it should.

I am trying to add specific CSS classes to my form field while editing the form or adding new content. I tried following http://atendesigngroup.com/blog/adding-css-classes-fields-drupal, but I can't change the field's classses.

This is the code I have in template.php.

/**
 * Overrides theme_field()
 * Remove the hard coded classes so we can add them in preprocess functions.
 */

function MojCrm_field($variables) {
  $output = '';

  // Render the label, if it's not hidden.
  if (!$variables['label_hidden']) {
    $output .= '
' . $variables['label'] . ':&nbsp;
';
  }

  // Render the items.
  $output .= '
';
  foreach ($variables['items'] as $delta => $item) {
    $output .= '
' . drupal_render($item) . '
';
  }
  $output .= '
';

  // Render the top-level DIV.
  $output = '
' . $output . '
';

  return $output;
}

/**
 * Implements hook_preprocess_field()
 */

function MojCrm_preprocess_field(&$vars) {
  /* Set shortcut variables. Hooray for less typing! */
  $name = $vars['element']['#field_name'];
  $bundle = $vars['element']['#bundle'];
  $mode = $vars['element']['#view_mode'];
  $classes = &$vars['classes_array'];
  $title_classes = &$vars['title_attributes_array']['class'];
  $content_classes = &$vars['content_attributes_array']['class'];
  $item_classes = array();

  /* Global field classes */
  $classes[] = 'field-wrapper';
  $title_classes[] = 'field-label';
  $content_classes[] = 'field-items';
  $item_classes[] = 'field-item';

  /* Add specific classes to targeted fields */

  switch ($name) {
    case 'field_baza_direktor':
      $title_classes[] = 'inline';
      $content_classes[] = 'col-sm-6';
      break;
  }

}


texts: Multilingual pages links showing node instead of URL alias

texts:
My web has 2 languages, English and Malay. The language selection is by session of ?lang=en or ?lang=ms.

English is the default language and it is working fine. All internal links are using the correct URL aliases. The problem arises when switching to Malay language. All links became node/(some-number).

For example:
About Us Page
all using about-us as URL Alias

In English
www.example.com/about-us

In Malay
www.example.com/node/2

Even when I type out the URL www.example.com/about-us?lang=ms it doesn't work. It will still show the English language.


texts: How to display field_tags of a node in html.html.twig?

texts:
I want to display fields "field_summary" and "field_tags" of a node in html.html.twig (without using a module for that). I was already able to get "field_summary" value in html.html.twig with this code:

function universaldenker_preprocess_html(&$variables) {
  $node = \Drupal::routeMatch()->getParameter('node');
  $variables['node_summary'] = $node->get('field_summary')->value;
  $variables['node_tags'] = $node->get('field_tags')->getString();
}

Then I just used {{ node_summary }} in html.html.twig. It works perfectly. But I couln't display values of "field_tags". If I use {{ node_tags|join(', ') }} then I get the field_tags ID's.

How can I get the values and not ID's?


texts: Create a product after form submission using commerce and rules

texts:
I want to set up a rule which would create a product when the user saves a submission form. The submission form is embedded into a simple node (using entity reference) presenting the "product" being sold. What I would like to do is to use information from that node when the rule creates the product.

The problem I am having is that I cannot find any valid way to get these fields to display in rules' data selector. The only way I found was to add the event "content is viewed" in addition to the event "after saving a new entityform". But I only want to keep the event related to the submission form.

So my question is the following: how can I display the fields contained in the node being viewed in rules' data selector without using this event? Thanks in advance for you help!


texts:
I have EU Cookie Compliance installed on my website.
In the settings I have selected Opt-in option.
On the site front end, I only agreed to the functional cookies but there are cookies set by third party websites which are still saved.
I checked the module's issue queue and found this.
https://www.drupal.org/project/eu_cookie_compliance/issues/3109974#comment-13459494
https://www.drupal.org/project/eu_cookie_compliance/issues/3059471
It seems that this module will not block the third party cookies.
Is there any other way to do this?


texts: Using custom .tpl.php for fieldable panel pane view mode

texts:
I'm having a difficult time getting a view mode on an FPP to use my custom .tpl.php file.

Here is hook_preprocess:

function mymod_preprocess(&$variables, $hook) {
  $element = $variables['elements'];
  if ($element['#entity_type'] == 'fieldable_panels_pane') {
    $entity_type = $element['#entity_type'];
    $bundle = $element['#bundle'];
    $view_mode = $element['#view_mode'];
    $variables['theme_hook_suggestions'][] = "{$entity_type}__{$bundle}__{$view_mode}";
    $variables['theme_hook_suggestions'][] = "fieldable-panels-pane-banner-banner-full-bleed";
    kpr($variables);
  }
}

The relevant output of the kpr() (the theme_hook_suggestions part of it:

array(3) {
    [0]=> string(29) "fieldable_panels_pane__banner"
    [1]=> string(48) "fieldable_panels_pane__banner__banner_full_bleed"
    [2]=> string(46) "fieldable-panels-pane-banner-banner-full-bleed" }

I hard-coded that last one thinking that it might just be a mishap in the naming conventions.  I've tried every combination of dashes and underscores that I can think of; theme_devel isn't suggesting any of the ones in theme_hook_suggestions, the only ones it recommends are: panels-pane--fieldable-panels-pane--fpid-4.tpl.php < panels-pane--fieldable-panels-pane.tpl.php

I have the templates in /sites/all/modules/custom/mymod/templates with the module file in /sites/all/modules/custom/mymod/mymod.module.

Thanks for any direction!


texts: File Field description field default using tokens?

texts:
Using Drupal 8 File Field and enabling the optional description field works normal.

I want to have a default value populated for the field using tokens from other fields in the content type (to create a standard formatted description).  Is there a way to enable this or must I disable this field and override the twig for the content type to display the desired description for the file link?

Note that this question pertains the optional description field (not the filename - that works perfectly well with the tokens using File (Field) Paths module.)


texts: Checking if a machine_name exists or not

texts:
My EntityForm has a field where

  '#machine_name' => array(
    'exists' => array($this, 'load'),

To check the validation of this, I wanted to know about writing the function load() in my EntityListBuilder to check its validation.

A way around would be to use ctools:

ctools_include('export');
$result = ctools_export_load_object('module_entityname', 'names', array($field_id));

However, I wanted to avoid using ctools.
Are there any Drupal 8 APIs available to check the validation of #machine_name?


texts:
I would like the user to be able to edit or delete comments from contextual links.  From an example module I've replaced $items['node/%node/example-action'] with $items['comment/%comment/edit'] But I've had no joy. Here's the code for the example module.

function comment_contextual_links_menu() {

$items['comment/%comment/example-action'] = array(
 'title' => 'Example action',
 'page callback' => 'drupal_get_form',
 'page arguments' => array('comment_contextual_links_node_action_form', 1),
 'access callback' => TRUE,
 'type' => MENU_LOCAL_TASK,
 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  'weight' => 80, );

$items['examples/contextual-links/%comment_contextual_links_object'] = array(
 'title' => 'Contextual links example object',
 'page callback' => 'comment_contextual_links_object_page',
 'page arguments' => array(2),
 'access callback' => TRUE,);

$items['examples/contextual-links/%comment_contextual_links_object/view'] = array(
 'title' => 'View',
 'type' => MENU_DEFAULT_LOCAL_TASK,
 'weight' => -10,  );

$items['examples/contextual-links/%comment_contextual_links_object/edit'] = array(
 'title' => 'Edit object',
 'page callback' => 'drupal_get_form',
 'page arguments' => array('comment_contextual_links_object_edit_form', 2),
 'access callback' => TRUE,
 'type' => MENU_LOCAL_TASK,
 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,  );

$items['examples/contextual-links'] = array(
 'title' => 'Contextual Links Example',
 'page callback' => 'contextual_links_overview_page',
 'access callback' => TRUE,  );

return $items;
exit('yes');
}


texts: Commerce Licence Renewal Date defaulting to January 1970

texts:
I'm renewing Licenses in Drupal Commerce and running into a weird issue.

I'm going to mysite.com/admin/commerce/licenses/list

Using the Filter Widget I type the username of the user whose license I'd like to renew. Using the Operations widget, I select Renew Licence and press Execute.

After typing the number of days (for example 1 day) to renew each licence for and pressing Next, the date is defaulting to 2nd January 1970

Ids this a bug or am I missing something in my Commerce set-up. ie: a timezone configuration?

Using D7.34, Commerce 7.x-1.10 and License 7.x-1.3


texts: How to customize the output of node content in Drupal 6?

texts:
I am looking to customise the templated output of the $content variable in node.tpl.php Can you tell me how I could achieve this? Is is possible with another template file?

The reason for this is to achieve AJAX pagination thus I need an ID on node_body and also to pull out the paging nav from this same DIV.

Any help appreciated :)


texts:
I've two nodes Person and Mission. A Mission can contain many Person's. Now if I'm browsing Person node, then in right side bar block I want to show all Mission's associated with this Person.

Example:

Mission1 contains ( 1 field containing multiple values):

Person-A
Person-B

Now if I go and view Person-A then in a block I should see Mission1 as it is associated with it.


texts: I'm setting up rules, trying to setup HTML emailing. I've it setup but not sure how to configure it. What does Switch to data selection mean?'


texts: Attaching Callbacks to Standard Drush Commands

texts:
I would like to add a callback to fire after anyone runsdrush cc all. Ideally this behaviour would be enabled in a drush alias file. Is this possible?

By way of example, in this particular instance I am managing multiple developers across several environments. Each environment is capable of flushing one or more CDN caches, and will do so during various system routines.

I don't want dev, qa, or local environments flushing production caches. Given that drush cc all is an integral part of the deploy and local build processes, which runs right at the beginning no less, I would like to have calls to cc all (other than those against @prod) call a method to disable any CDN modules before exit.

Additionally, I may wish to run patch files or other bash scripts to ensure certain environments are up to date in situations where a developer may not be able to merge a dev branch but has resources accessible online which must be updated against security vulnerabilities. And so on.


texts: Using panels everywhere... without Panels Everywhere

texts:
I recently discovered how awesome Panels is and I want to use it as a replacement essentially for the default theming mechanism that comes with Drupal (I'm using version 7).  In fact, I want to use it just about everywhere.  Unfortunately, it looks like the Panels Everywhere module for Drupal 7 is completely dead.

I noticed that any panel that you create is just dropped into the content area.  So, with an out-of-the-box Drupal installation that is going to leave all the heading information at the top of the page intact, even if you've defined a header section in your panel.

So, right now I'm thinking that the best way to deal with this is to tell Panels to disable output to regions, and to also override page.tpl.php so that it doesn't include any extraneous junk with the exception of wrapper HTML and the content region.

Does this approach make sense or is there a better way to go about accomplishing this?


texts:
I used the blog module for what I am calling "story" on the site I am building.

The URI and various parts of the site still say "BLog" -- most noticeably when the user attempts to add a new blog.

I have figure out I can just override the URI using aliases through admin, but I am wondering if it would make more sense to simply rename the 'blog' references in the table itself, via a module or one time hack?

Opinions?

EDIT | I also want to change the "forum" module to "forums" making all references plural not singular


texts: How to relate a field to another field in content type like a foregn key?

texts:
Can anyone guide my to the best method or module to connect 2 fields together?
I want to create a field called (Author) in a content type book, which will refer to a field called (name) in a content type author.

So a book author, will refer to field name of an actual existing author.

It's like creating a foreign key from the a book field to the author author field.

But the modules that I found (like node relation, relation and entity reference) only do a node reference, which is not what I want.

Not sure if I did use the modules correctly. But am I missing something here?

I am kind of new to Drupal as well as the web development era.

Any help?


texts: I just started using profile2 module to implement 2 types of profile for my site visitors (sellers, buyers for example). Both type of users can post content (say articles). I know whenever someone posts an article, a relationship is created in the db between that user and article. What I want to do is to show a user's articles under that user's profile page (the page that the profile2 module creates). With drupal 6 and content profile, this was easily done with a few modules since profiles were nodes back then. I'm guessing I'll have to code up a module to do this since profile2 profiles aren't nodes anymore. Can you guys give me some pointers on how you'd/you've gone about accomplishing this? Much thanks!


texts: Can you resume sending mails to a list of which only part of the addresses are having had a newsletter?

texts:
I set cron throttle to 500 and then cron to run every hour. Using a shared server on hostgator, apparently this appears to be too much. So what ended up happening is only 1000ish of my 2500 mail address were being sent a simplenews newsletter.

So is there any way of picking up where I left off so these 1000 people will not receive the same mail again (and unsubscribe).  And if not, would there be any way to export the simplenews log in a way where you can easily edit the adresses that were begint a newsletter and make a temporary list?

Update; my question comes down to whether a log of the actual successful (or failed) email adressess is accessible. I've looked into the watchdog table and queried SELECT messages FROM watchdog. This gave me a list where the column that's supposed to contain the 'To:' addresses, actually contains a wildcard. So instead of the value being an actual email adres, the value is %To.

Yet, on the site, I could go to admin/reports/dblog and would be able to filter simplenews. This way I can consult emailadresses that have been sent, but I would have to click each rown over 1.000 times and then copy/paste the email adres in excel or plain text to create a new list for the remaining addresses? I hope there is a way that I can link these wildcards with their actual address and then be able to export it into something that I can use to bulk operate?


texts: Disable page compression only on specific pages

texts: I am running drupal 6 and have page compression enabled. When page compression is enabled, drupal caches all the pages. But I do not want certain pages to be cached. How do I force drupal not to cache certain pages?


texts: How would I be able to get the full URL from an image field?

texts:
In a node template, how would I be able to get the URL from an image field?
Like if it were something like this:

  {{ content.field_image.URL }}

Or if there is a similar alternative perhaps?


texts: How to use ip to visit AcquiaDevDesktop's site?

texts:
I want to visit drupal site through 'Local area network'.

For example, my server ip address is 192.168.0.1, My drupal site is http://daxuebao.local:8083/

I try to use 192.168.0.1:8083/daxuebao.local, 192.168.0.1:8083/daxuebao. But can not be visited.


texts:
Is it possible to render only the field label from $view->result ,
like render the field value only

$display['label']='hidden';

print render(field_view_field('node',$node,'field_date',$display));


texts: Filter the Node Locations view in the navigation menu

texts:
I'm using Gmap Views to show where each Eastern Star Chapter in Maine is, both extant and historical. The automatic Node Locations map in the Navigation menu is displaying them correctly so far. What I would like to do is filter this so only nodes of type "chapter" are displayed, and preferably only ones marked as "active", although I won't generally have an exact geocode for the inactive ones. Thanks!

(This is very similar to a question I asked before, but it didn't get much input, so I'm asking it a different way this time.)


texts: Ubercart UPS Shipping Method not working?

texts:
I completed the configuration option on UPs Shipping quote page, after that i will go to the checkout page means it will show the  following error:

  Hard 110002: No packages in shipment

<?xml version="1.0" encoding="UTF-8"?>
<AccessRequest xml:lang="en-US">
  <AccessLicenseNumber>3CAA21FCE19Ass83BA</AccessLicenseNumber>
  <UserId>thewdddallsticker</UserId>
  <Password>wallsticfdgkeR1</Password>
</AccessRequest>

<?xml version="1.0" encoding="UTF-8"?>
<RatingServiceSelectionRequest xml:lang="en-US">
  <Request>
    <TransactionReference>
      <CustomerContext>Complex Rate Request</CustomerContext>
      <XpciVersion>1.0001</XpciVersion>
    </TransactionReference>


texts:
A good question was raised in this comment by EGHDK:

  Why do these modules have bug reports. Shouldn't this be a simple task for a module to complete with no errors?

He was referring to limiting the viewing of pages to users of a certain role, but the question applies broadly.


texts: How to display different menu in a panel depending on node nr?

texts:
I created a panel page. Say foopanel. This panel is displaying information based on the node nr. So in case of node nr 1 the url call will be: foopanel/1 (

I want to display a specific menu e.g menu-abc with node/1 and e.g menu-cde with node/2. So menu-xxx should be displayed in a block of foopanel.

How to implement this?

I see visibility rules in panels but do not see the nodeid. Should I do some php here? If so how should it be like?

I installed contexts but don 't see how I can manager this within a panel.

Every suggestion is very welcome to this. Thxs already.


texts: View to display user points and the reason for the points

texts:
Using user points module, the users of my site are successfully being assigned points for any content they post or revisions they make and so on. Now when a user logs in, i want the user to be able to see his points and the reason for the points being assigned. The view output would be something like this:

1.Blog Pic A, Blog Title A, Blog TeaserA  (and then)  Points

2.Blog Pic B, Blog Title B, Blog TeaserB  (and then)                     Points

Here then user gets points for their blog uploads. How can i create a view showing the above result. I tried but was not successful. I created a view of user points with Contextual filter  Userpoints Transactions: User and fields as  Userpoints Transactions: Points (Points) . However i am not getting any fields as content:body and so on. I understand i have to add a relationship but i am a bit confused here. I tried adding the relationship  Userpoints Transactions: Entity ID  but the  i get an error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'userpoints_txn.nid' in 'on clause'. What is this. How can i create the view for the above shown usecase. It seems a simple solution. What am i missing?

Edit: I tried different views but none are showing what i need. Would appreciate if someone can export a view, or at least, and preferable, guide me so that i also understand where i am going wrong.


texts:
here is my question:

I need to implement a content approval process, my client wants content to go through an approval process before being published.

I need to create 3 administrative roles, like Content Editors, Content Publishers and Super Admins.

Content Editors can edit content, but not publish it. Content Publishers can edit and publish content (which includes approving/rejecting any changes made Content Editors). Super Admins would have access to everything in Drupal 7.

Any help is appreciated.

Thanks.


texts: ajax callback add more on a select field

texts:
I am trying to implement a "add x" on a select field but it doesn't seem to work.

I've tried to follow this example but they use a submit for that.

$form['myfield'] = array(
    '#type' => 'select',
    '#options' => $optionsServer,
    '#ajax' => array(
        'callback' => 'ajax_select_change',
        'wrapper' => 'names-fieldset-wrapper',
        'method' => 'replace',
        'effect' => 'fade',
    ),
);

$form['#tree'] = TRUE;
if (empty($form_state['num_names'])) {
   $form_state['num_names'] = 1;
}
$form['myfieldset'] = array(
        '#type' => 'fieldset',
        '#title' => t('myfieldset'),
        '#prefix' => '
',
        '#suffix' => '
',
    );
for ($i = 0; $i < $form_state['num_names']; $i++) {
   $form['myfieldset']['field'.$i] = array(
       '#type' => 'textfield',
       '#title' => t('field'),
       '#size' => 60,
       '#required' => TRUE,
   );
}

function ajax_select_change($form, &$form_state){
    //$form_state['num_names'] is used to create x new textfield
    $form_state['num_names'] = $form_state['values']['myfield'];
    //rebuild this form to get the new count
    $form_state['rebuild'] = TRUE;
    //change the fieldset containing the code to build textfield
    return $form['myfieldset'];
}

Is it doable?
I can try to create a button then trigger it when I change the select value but this is clearly a crappy hack.

Any idea?

EDIT: I find out some solution:

function my_form($form, $form_state){
    $form['container']['myField1'] = array(
        '#type' => 'select',
        '#options' => $optionsField1,
        //don't forget the $form_state['values']['container']['myField1'] as default, it will keep the same value after the rebuild
        '#default_value' => isset($form_state['values']['container']['myField1']) ? $form_state['values']['container']['myField1'] : $form_state['num_names'] ,
        '#ajax' => array(
            'callback' => 'ajax_select_change',
        ),
    );
}

function ajax_select_change($form, $form_state){
    $new_state = array();
    $new_state['build_info'] = $form_state['build_info'];
    $new_state['rebuild'] = TRUE;
    $new_state['values'] = $form_state['values'];
    $new_state += form_state_defaults();

    $new_form_array = drupal_rebuild_form('my_form', $new_state);
    $new_form = drupal_render($new_form_array);

    $commands = array();
    //reload form
    $commands[] = ajax_command_html('#formId', $new_form);
    //change inside Id #price
    $commands[] = ajax_command_replace('#price', drupal_render($form['container']['myField2']));
    return array('#type' => 'ajax', '#commands' => $commands);
}

EDIT 2: see the proper solution below (in the comment), much more simple and make more sense!


texts: Create custom language not based on english

texts:
I would like to add Canadian French as language, since there already is a French version of the site it would be very handy to just start from there.

When you create a new custom language it always copies the english language into the new one, you cannot select the language it should copy from. I also tried to set the default language to french and then create the new language but that doesn't change anything.

Anyone an idea how to do something like this? Or an easy way to switch the english for french after the language is copied?


texts:
I want prevent any user from being able to change the value of a field, yet I want to display its value.

How can I achieve this?


texts: Site keeps redirecting to core/install.php

texts:
I keep having this problem of drupal redirecting to core/install.php as shown below:

I already set the max_allowed_packet to 64MB on AWS RDS. I am not sure what else I am missing. Please help

The error in the logs is:

  Fatal error: Cannot redeclare
  _drupal_shutdown_function_handle_exception() (previously declared in /var/www/html/web/core/includes/bootstrap.inc:1066) in
  /var/www/html/vendor/drupal/core/includes/bootstrap.inc on line 1066

and the following is my composer.json

{
  "name": "xxx/yyy",
  "description": "zzz",
  "type": "project",
  "license": "GPL-2.0-or-later",
  "authors": [
    {
      "name": "QQQ EEE",
      "role": "Developer"
    }
  ],
  "repositories": [
    {
      "type": "composer",
      "url": "https://packages.drupal.org/8"
    }
  ],
  "require": {
    "php": ">=5.6",
    "aws/aws-sdk-php": "^3.108",
    "composer/installers": "^1.2",
    "cweagans/composer-patches": "^1.6.5",
    "drupal-composer/drupal-scaffold": "^2.5",
    "drupal/console": "^1.0.2",
    "drupal/core": "^8.7.0",
    "drupal/ldap": "^3.0@beta",
    "drupal/redis": "^1.1",
    "drupal/s3fs": "^3.0",
    "drush/drush": "^9.0.0",
    "predis/predis": "^1.1",
    "vlucas/phpdotenv": "^2.4",
    "webflo/drupal-finder": "^1.0.0",
    "webmozart/path-util": "^2.3",
    "zaporylie/composer-drupal-optimizations": "^1.0"
  },
  "require-dev": {
    "webflo/drupal-core-require-dev": "^8.7.0"
  },
  "conflict": {
    "drupal/drupal": "*"
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "config": {
    "sort-packages": true
  },
  "autoload": {
    "classmap": [
      "scripts/composer/ScriptHandler.php"
    ],
    "files": ["load.environment.php"]
  },
  "scripts": {
    "pre-install-cmd": [
      "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
    ],
    "pre-update-cmd": [
      "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
    ],
    "post-install-cmd": [
      "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
    ],
    "post-update-cmd": [
      "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
    ]
  },
  "extra": {
    "composer-exit-on-patch-failure": true,
    "patchLevel": {
      "drupal/core": "-p2"
    },
    "installer-paths": {
      "web/core": ["type:drupal-core"],
      "web/libraries/{$name}": ["type:drupal-library"],
      "web/modules/contrib/{$name}": ["type:drupal-module"],
      "web/profiles/contrib/{$name}": ["type:drupal-profile"],
      "web/themes/contrib/{$name}": ["type:drupal-theme"],
      "drush/Commands/{$name}": ["type:drupal-drush"]
    },
    "drupal-scaffold": {
      "initial": {
        ".editorconfig": "../.editorconfig",
        ".gitattributes": "../.gitattributes"
      }
    }
  }
}


texts: Why isn't Drupal aggregator configurable?

texts:
I am trying to display the RSS feed of this page: http://groups.yahoo.com/group/actventurers/, on a drupal website.

I have the aggregator module enabled, but when I go to /admin/config/services, only RSS Publishing is available.

Any ideas as to why it won't allow me to add any feeds?


texts:
I'm working on a content migration between a d7 and a d8 sites.
I'm trying to use migration and I've a doubt: the d8 site is empty and every user, content, file, term will be filled with migration from the d7 installation.

Is it safe to migrate also ID (uid, nid, tid, fid) from d7 to d8?
Or is better to migrate UUIDS and use them to match content relations?


texts:
I have a module function which needs to get the raw results of a view, so I use this bit of code:

$view = views_get_view('sluitingsuren_bakker');
  $view->preview();

  return $view->result;

The views machine name is sluitingsuren_bakker. I also tried some other views, but it seems the module can't find any of the views.

Also I set my permissions on this view to none, because I thought that was the problem.


texts: There is Google tag manager (GTM) on the site I am working on but when we inspect the navigation with the GTM there is no element id. At this point i don't know where to begin. Do i rework the GTM in the module or the navigation in the code base?


texts: How to allow integer and decimal fields with default values to be saved as empty.

texts:
If I set a default value on a decimal or integer field, the user cannot delete the default value and save the node.

They can set the value to another value including zero, and that is saved correctly.

But if the contents of the field is deleted, on save, the field is automatically populated with the default value again.

This doesn't seem right.  I guess I could intercept the empty field and set it to zero, but surely that's not necessary?  Am I missing something?


texts: Node template only on specific page (Drupal 7)

texts:
I've been reading through a ton of Drupal 7 theming docs but can't seem to find my answer.

Here's what I'm trying to do. I have two content types article and feature.

Nodes of both content types are displayed on my /blog page via the Views module. All working great so far.

When the node of type article is listed, it uses the node--article.tpl.php template, and when a node of type feature is listed on the blog listing page, is uses node--feature.tpl.php.

This is all as expected, BUT for feature types, I want to display the node--article.tpl.php template only on the /blog page, and use node--feature.tpl.php (the default) for that type otherwise.

In other words, I'd like to keep the templates separate, but use the same template for both article and feature types on the blog listing page (node--article.tpl.php).

Is there way to create a node-page-specific template file (use this template for this node ONLY if on this page)?


texts:
I'm trying to add a token to Product using the below code. The problem is that, although this adds the token I'm after, it also removes a number of standard tokens that are needed (e.g., the title).

/**
 * Implements hook_token_info().
 */
function fw_product_token_info() {

  $type = [
    'name' => 'Product',
    'description' => t('Useful additional tokens for products'),
    'needs-data' => 'commerce_product',
  ];

  $tokens['fw_product_parent_url'] = [
      'name' => t('Parent URL'),
      'description' => t('The full path to this product\'s parent'),
  ];

  return [
    'types' => ['commerce_product' => $type],
    'tokens' => ['commerce_product' => $tokens],
  ];

}

/**
 * Implements hook_tokens().
 */
function fw_product_tokens($type, $tokens, array $data = [], array $options = [], BubbleableMetadata $bubbleable_metadata) {

  $replacements = [];

  if ($type == 'commerce_product' && !empty($data['commerce_product'])) {
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'fw_product_parent_url':
          $entity = $data['commerce_product'];
          if ($parent_entity = \Drupal::service('fw_product.parent')->getEntity($entity)) {
            $replacements[$original] = $parent_entity->url('canonical');
          }
          else {
            $replacements[$original] = '';
          }
          break;
      }
    }
  }
  return $replacements;
}


texts: Is it possible to get the last number of a views pager to display after and before the elipses?

texts:
I'm trying to create a custom pager similar to the Amazon pager:

  < 1 2 3 4 ... 82 >

and after a certain point:

  < 1 ... 7 8 9 10 ... 82 >

But, I cant figure out how to display the last pager number after the elipse. Is this possible? What would be the best way to go about this?


texts:
I'm in the process of building an entity that extends DrupalDefaultEntityController, and I have some questions about the uses of the revisions mechanism, namely if I need to duplicate all the fields inside the base table within it, and what concerns there are for fieldable entities that extend the DrupalDefaultEntityController, and how to implement those as well.

For example, the base table would contain the following fields:

Primary ID (int, serial)
Title (varchar)
Bodytext (text)
Date Created (int for Unix timestamp)
Date Modified (int for Unix timestamp)
Type (varchar)
Revision ID (int)


texts: How to unfocus button after ajax form was rebuilt?

texts:
I have a form that is completely ajaxified and when I submit the form the submit button stays focused.

I have styling in place and it results in bad UX. How should I unfocus the button? Do I have to implement ajax response and some custom JS for this? Seems like a hacky solution :(


texts: Alter views style using regenerate feature?

texts:
I created a views using feature and export the views in my second site. After some time I need to change in views style. After change in style I regenerate the feature and export again.

I disabled the previous version and enable this version. The changes in fields are altered but changes of styles plugin are not altered. I cleared the cache and also uninstalled and installed again, but it didn't work at all.

Anyone used feature module like this? Am I missing something?


texts: Is it possible to get node template suggestion per views row on Drupal 8

texts:
I need to theme the first row of a view page with a different image size and the theme debug suggested me:

node--view--article--page-1.html.twig

This is new on drupal 8.

I was wondering if is possible to get template suggestions per row number.


texts: Make t() function translate string on template file?

texts:
I created a custom page, with my custom module.

Hook_Menu

$items['registered-products/%'] = array(
    'title' => t('Hello World'), // TRANSLATES FINE
    'page callback' => 'mymodule_product_page',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
    'file' => 'includes/mymodule.product_page.inc',
);

Template File

I created a template file (.tpl.php) for my custom page, in here I have:

<?php print t('hello world'); ?> <!-- DOES NOT TRANSLATE -->

RESULT

The t() translates in hook_menu, but on the template file it does not.

What do I have to do so the t() works to on template file?


texts: Form inputs being disabed during the Ajax request

texts:
I'm working on a module where I have a form inside of a block, I'm using Ajax to submit the form, but I noticed that the form's inputs are disabled when sending a request with Ajax. Well in my case I want to keep using the form's input (keyup event) and displaying the result for each request.

// my current code
$form['combine'] = array(
    '#type'       => 'textfield',
    '#size'       => 255,
    '#maxlength'  => 128,
    '#attributes' => array('placeholder' => 'Search'),
    '#ajax'     => array(
        'callback'  => 'ajax_filter_callback',
        'effect'    => 'fade',
        'wrapper'   => 'result-content',
        'event'     => 'keyup',
    ),
);


texts: Ajax callback change "checked" radio button

texts:
I have a radio button group like this:

$options = array('2' => t('Active (2)'), '1' => t('Upcoming (1)'), '0' => t('Finished (0)'));
$form['active'] = array(
'#type' => 'radios',
'#title' => t('Update state:'),
'#default_value' => $default_entry->active,
'#options' => $options,
);

which works fine. However, based on a drop-down list of entries, it calls an ajax function which should update the selection:

foreach (array('name', 'test') as $item) {
$form[$item]['#value'] = $entry->$item;
}
foreach (array('active') as $item) {
???
}

Now, the "name" and "test" work as expected as they are text fields.... but the active radio button stays the same as it was (i.e. based on the '#default_value').

I have tried

$form[$item]['#value'] = $entry->$item;
$form[$item]['#default_value'] = $entry->$item;

but neither change which radio button is selected. Is there something I'm missing based on updating the "checked" attribute for that radio group?

Any help and/or points in the right direction much appreciated.


texts: Keep info in one place to be use in several locations

texts:
As per title, what is the best practice, say if i want to save/keep info such as details of the website in one place so that when i want to change something i dont have to go thru every pages/blocks to amend it.

For example : company phone number.

Right now i have it in footer and contact page. Is there a way to change it so that every place that have the phone number will automatically change too?


texts:
I am trying to alter the route for the login and registration pages. I followed Altering existing routes and adding new routes based on dynamic ones. I cleared the cache repeatedly, and re-enabled the module several times, but it looks like alterRoutes() is not triggered, even when I try to add a kint() debug or any code.

What I noticed is that alterRoutes() -> kint() is triggered when I use Drush to enable the module. In this case, I see kint() output in my terminal. However, alterRoutes() is not triggered when viewing the site.

This is the code I am using.

md_routes/src/Routing/RouteSubscriber.php

namespace Drupal\md_routes\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Drupal\Core\Routing\RoutingEvents;
use Symfony\Component\Routing\RouteCollection;
/**
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    kint($collection);
    // Change path '/user/login' to '/login'.
    if ($route = $collection->get('user.login')) {
      $route->setPath('/login');
    }
    if ($route = $collection->get('user.register')) {
      $route->setPath('/register');
    }
  }
}

md_routes/md_routes.services.yml

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


texts:
I work with views bulk operations and I wanna change status of selected items in a view. I applied db_update query, but something went wrong. I was debugging my code following:

  $status=$context['status'];

foreach($context['rows'] as $order) {

    db_update('orders')
        ->fields(array(
            'status' => $status
        ))
        ->condition('oid',$order->oid,'=')
        ->execute();
}

foreach($context['rows'] as $order) {
    $result = db_select('orders','status')
        ->fields('status')
        ->condition('oid',$order->oid)
        ->execute()
        ->fetchAssoc();
    if($result) {
        drupal_set_message($result['status']);
        drupal_set_message($result['oid']);
    }
}

So first is db_update and after that I did db_select and printed it out.The result of this db_select behaves like status would be updated. But in the node is status still the same. Also in database it stayed unchanged. I have no idea what's wrong. It behaves like it was updated and then immediately got back.I would be very helpful for any help. Sorry for my english. Thanks.


texts: How to display a View Block based on number of characters in Body?

texts:
I currently have a view that creates an "About the Author" box that pulls information from the user's profile and displays the appropriate author box based on the author of the node (content). I only want to display it on nodes that have a minimum amount of characters in the body of the node. (It currently displays for all nodes the block is enabled for.)

The desired result is that long pieces of content have an "About the Author" box, while short pieces of content do not.

The problem I am having is that when I select the filter criteria for the view, the body field for the node is not listed, so I cannot filter off of it. And I do not see any other way to test how long the content is, in order to determine whether the "About the Author" block should display or not.

How can I make it so the Author Box only appears on long content (i.e. content body > 1000 characters)?


texts: Why I should use dependency injection in Drupal 8?

texts:
Why is this

__construct(MyService $my_service ) {
   $this->my_service = $my_service;
}

create (ContainerInterface $container) {
  return new static(
      $container->get('my.service'));
}

better than

__construct() {
    $this->my_service = new MyService();
}

?


texts: Form from another module not rendering properly

texts:
I am attempting to call uc_shipping_new_shipment() (apart of Ubercart) in my custom function that handles its own shipping.  When I load my page dpm() prints out what looks like an appropriate form.  However, the form does not load on the page.  What am I doing wrong?

function my_module_ship($uid, $order_id) {
  $order = uc_order_load($order_id);
  module_load_include('inc', 'uc_shipping', 'uc_shipping.admin');
  $form = drupal_render(drupal_get_form('uc_shipping_new_shipment', $order));
  dpm($form);
  return $form;
}

I have tried it with and without drupal_render().


texts:
I have a custom form with a custom schema. The schema has an ID that auto increments.

Now I want to show the content on custom pages; each id should have its own page.

What I want to do is if I'm going to recipe/1 than the page should show me all content from the recipe which has the id "1".

I tried to tell drupal that there is a new page called "recipe/%", but when I go to recipe/1 for example drupal tells me that the page is not found.

How do I tell drupal that there is a page?

function recipe_submit_menu() {
  $items = array();

  $items['recipe/add'] = array(
    'title' => 'Submit a recipe',
    'description' => 'A form to submit a recipe',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('recipe_submit_form'),
    'access arguments' => array('add_recipe'),
    'access callback' => TRUE
  );

  $item['recipe/%'] = array(
    'title' => 'Recipe details',
    'page arguments' => array('3'),
    'page callback' => 'recipe_submit_page',
    'access arguments' => array('recipe_manage'),
  );

  return $items;
}

function recipe_submit_form($form, &$form_state) {

  $form['recipe_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Recipe title'),
    '#required' => TRUE,
  );

  $form['author_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Author name'),
  );

  $form['author_email'] = array(
    '#type' => 'textfield',
    '#title' => t('Author email'),
    '#required' => TRUE,
  );

  $form['recipe_description'] = array(
    '#type' => 'textarea',
    '#title' => t('Recipe description'),
    '#maxlength' => 500,
    '#required' => TRUE,
  );

  $form['recipe_instructions'] = array(
    '#type' => 'textarea',
    '#title' => t('Recipe instructions'),
    '#required' => TRUE,
  );

  $form['recipe_ingredients'] = array(
    '#type' => 'textarea',
    '#title' => t('Recipe ingredients'),
    '#required' => TRUE,
  );

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

  return $form;
}

function recipe_submit_form_validate($form, &$form_state) {
  if (!filter_var($form_state['values']['author_email'], FILTER_VALIDATE_EMAIL)) {
    form_set_error('author_email',t('You have to enter a valid email address'));
    $form_state['redirect'] = FALSE;
  }

}

function recipe_submit_form_submit($form, &$form_state) {
  global $language;
  $query = db_insert('recipe_submit')
    ->fields(array(
      'submitted' => time(),
      'site_language' => $language->language,
      'recipe_title' => $form_state['values']['recipe_title'] ,
      'author_name' => $form_state['values']['author_name'],
      'author_email' => $form_state['values']['author_email'],
      'recipe_description' => $form_state['values']['recipe_description'],
      'recipe_instructions' => $form_state['values']['recipe_instructions'],
      'recipe_ingredients' => $form_state['values']['recipe_ingredients'],
      ))
    ->execute();
  drupal_set_message(t('The recipe was sucessfully submitted.'));
  $form_state['redirect'] = '/';
}

/**
 * Implements hook_permission().
 */
function recipe_submit_permission() {
  return array(
    'add_recipe' => array(
      'title' => t('Permission to add a recipe'),
    ),
    'recipe_managed' => array(
      'title' => t('Permission to manage recipes'),
    ),
  );
}


texts: Search for product displays based on info from products in Commerce

texts:
I have a website with various articles of clothing for sale. Here's how I have it set up:

Product Display content items:

Mens V-Neck Tshirt
Mens Tank Top Tshirt
Womens Tshirt
Childrens Tshirt

Product content items (in Commerce):

Mens V-Neck Tshirt - Red - Large
Mens V-Neck Tshirt - Blue - Large
Mens Tank Top Tshirt - Green - Small

etc...

Colors (Red, Blue, Green) and sizes (Large, Small, etc) are set up as Select-List fields with the Enable this field to function as an attribute field on Add to Cart forms option enabled.

I need to allow my shoppers to search for shirts that have Red as an available color, or that have Small as an available size. So if they searched for shirts that are Red and Small, they would receive no results based on the product list above, but if they search for Green and Small, they would see the Mens Tank Top Tshirt product display item in their search results.

How can I set this up? With Views/exposed filters, perhaps? Or...?

Thanks!


texts: How to set block visibility by role in Drupal 8

texts:
In Drupal 7 it was easy to set block visibility by role in "block configuration" page.

How it can be done in Drupal 8?


texts: How to remove exposed filter if value is supplied in url?

texts:
We have a view page (path = /some-path/) that has an exposed filter called category. The detailed view setup is below. How would we hide the exposed filter if it is supplied from the url?

View setup:

Filter criteria:

Settings:

Operator = is one of (list of all tags term values)
Filter type to expose = single filter

Advanced

Require relationships for field_tags
when the filter value is not in the url --> display all results for the specified field
when the filter value is in the url or default is provided

a. specify validation criteria -> validator -> taxonomy term name where vocabulary = tag

b. action to take if filter value does not validate = display contents of no results found

c. case = lower case

d. more -> transform spaces to dashes in url -> enabled

Expected behavior:

when /some-path/ is navigated to, then the exposed filter should show
when /some-path/term-value/ is navigated to, it will filter the results and hide the exposed filter

Current behavior:

navigating to /some-path, shows all results with the exposed filter displaying allowing a visitor to change it.
navigating to /some-path/value2/ filters the results and displays the exposed filter.


texts:
I have a multilingual site which supports English and Arabic. I added the following code to get breadcrumb on my view result page.

drupal_set_breadcrumb(array(l('Home', '<front>'), 'mytest'));

I only want two links on the page, Home page link and title without any link. I am getting the following result.

Array(
  [breadcrumb] => Array(
    [0] => Home
    [1] => mytest
    [2] => mytest
  )
)

I want the output to be like the following.

Array(
  [breadcrumb] => Array(
    [0] => Home
    [1] => mytest
    [2] => mytest
  )
)

Why do I get the unexpected result?


texts: Disable form or block cache for anonymous users?

texts:
I have two forms in Drupal 8 that I am prepopulating values with if a value exists in the query string.

$keywords = Xss::filter($this->requestStack->getCurrentRequest()->get('keywords'));

$form['keywords'] = [
      '#type' => 'textfield',
      '#maxlength' => 128,
      '#size' => 64,
      '#default_value' => Unicode::strlen($keywords) ? $keywords : '',
      '#prefix' => '
',
      '#suffix' => '
',
      '#required' => TRUE,
      '#attributes' => [
        'placeholder' => Unicode::strlen($keywords) ? $keywords : t('Search Site'),
      ]
    ];

Works great for authenticated users, but for anonymous users, they are always seeing the last term entered, despite the query string having nothing in the URL. Even if I close the browser and come back, the term is still in the input field. I assume it gets cached.

The form is being attached as a twig variable to a block containing other content:

/**
 * Implements hook_preprocess_block().
 * @param $variables
 */
function mytheme_preprocess_block(&$variables) {
  if (isset($variables['elements']['content']['#block_content'])) {
    $variables['block_content'] = $variables['elements']['content']['#block_content'];
  }

  // inject main nav search form to block template for main_nav only
  if ($variables['elements']['#id'] == 'main_nav') {
    $variables['main_nav_search_form'] = \Drupal::formBuilder()->getForm('\Drupal\mymodule_search_forms\Form\MainNavSearchForm');
  }
}

Is there a way to change this so that does not happen? Any cache tag I could use?


texts: Drupal 7: View filters impact on performance

texts: Does having multiple view filters affect the overall performance of the site. for example having a category and search filter on main pages of articles and galleries?


texts: How do I pass the nid of the current node to the first step multistep modal form?

texts:
I am using the ctools plumbing to create a nodal form. This is what the relevant part of my code now looks like:

/**
 * Implements hook_entity_view_alter().
 */
function mymodule_entity_view_alter(&$build) {
  $nid = $build['body']['#object']->nid;

  // Set up ctools etc. to use modal omitted for brevity.

  $build['links']['popup']['#links']['mylink'] = array(
    'title' => 'show popup',
    'href' => 'mymodule/nojs/modals',
    'html' => TRUE,
    'attributes' => array(
      'class' => array(
        'ctools-use-modal',
        'ctools-modal-mymodule-style',
      ),
    ),
  );
}

The nid of the node this link will be attached to is known at this point. (See first line of function.)

However, my code need to be aware of the nid at each step in the modal form.

I think it possible to do this by stashing it in a session cookie, but I would like to avoid using cookies, if possible.

Is there another way to do this?


texts: How to integrate Views with apache solr search?

texts:
In my site I am implementing zip code based search, for that I created one view of user profile and add one expose filter to it which is exposing result on postal zip code entered by user. Now I am thinking that exposed filter integrate with Apache solr.

Help me out for which module I have to use for it and how I configure it?

List of modules I have used in my project:

addressfield
geofield
geocoder
geophp
apachesolr
facetapi
profile2


texts: Request a page - as admin - via command line to build up cache

texts:
Folks:

I have a pretty hefty view page which has been overridden with template files to produce a custom gantt chart for a long list of users. For each row of gantt data - the outputted html is cached to speed things up..

I've written a function which I call via drush that deletes the cached key:values from my custom cache table.

drush eval 'custom_tweaks_clear_cache_codes()'

The plan is to 1) flush the cache every morning via cron using this drush command. Then, 2) 'warm the cache' essentially request this page via command line to build the cache table up again.

The issue is, I could leave it and let the first user who views the page, take the hit so the cache gets built - but I can't allow this, the user needs to be an admin..

Essentially: I need a way to hit the page but as admin - which doesn't involve me loading the page every morning manually before the day starts.

Has anyone got any ideas?


texts: How to report about how many users have registered in a given timeframe?

texts:
We want to know how many users registered to our website as a report.

I'm looking for a way (or a solution) in D7 that allows me to give me a report of how many user have registered to my website. Ideally will show me how many user register yesterday, weekly, monthly and annual.


texts: Where is the service container compiled to?

texts: Where is the service container compiled to in Drupal 8, in the database or in a file?


texts: How to convert taxonomy term name to term id at time of importing and create custom node from csv in drupal?

texts: I am creating content type programmatically. I am importing content from csv file.. Everything working fine. But I am not able to select category at the time of import like other fields.. and how to convert term name to term id ,because csv giving me term name.


texts: Why are my custom email messages sent without styling?

texts:
I have a Commerce Kickstart website working, everything works fine. Recently I wanted to create another notification email once I give an order certain status. Well I created the rule, also created the message (actually I cloned the Commerce Order: order confirmation message)

All the emails sent from my commerce kickstart are with the right styling, they show good, but only the custom message I created does not have any styling, it is sent in html but does not have styling.

I do not understand why my custom message is sent without styles, I copied the styles and html that is in the Commerce Order: order confirmation message, but all the other messages have styles, I could not figure out what's going on.


texts: Strip HTML tags from Field Collections in Services Views

texts:
I'm trying to strip the HTML tags from a JSON response I generated using Services Views, but I'm not having any luck so far.
I have a content type with a Field Collections field in it that is outputting HTML tags no matter what I do.
I've tried the following:

Check Strip HTML tags in the field settings in the view
Set customize field HTML to 'None'
Set Customize field and label wrapper HTML to 'None'
All combinations of the above
Making sure to turn of all 'Provide default field wrapper elements' options

Am I missing anything? My output still looks like this in my json:

"Animals": [
            "
\n
\n

Animal:&nbsp;

Big

Withdrawal time:&nbsp;

25 dg

\n
\n",
            "
\n
\n

Animal:&nbsp;

Rund vlees

Withdrawal time:&nbsp;

21 dg

\n
\n",
            "
\n
\n

Animal:&nbsp;

Pluimvee ei

Withdrawal time:&nbsp;

6 dg

\n
\n"

Any help on this is greatly appreciated.


texts: How can I avoid users can change the "Make revision" field?

texts:
My users can edit any content, but I really need to know what they did. I need revisions.
I tried the Hide revision module, but when the Make revision field is unchecked, the revision isn't created. They see that field, they uncheck it, and the revision isn't created.
How can I avoid they uncheck that field?


texts: How to install another module when a module is being installed

texts:
I have created a module (travel_list) that uses the Field Group module. I want the Field group module to be automatically downloaded and installed whenever the travel_list module is installed.

How can I achieve this?


texts: Search form escaping characters and spaces?

texts:
Drupal 7.

I'm thinking it must be in the htaccess file, as I just went live, and suddenly if I search for something like "two words" it ends up searching for "two%20words" and obviously I get no results.

Same goes for quotes, etc.  Any ideas?


texts: How do I set a grouped exposed filter of boolean fields in a view?

texts:
I have a view with fields used as filters and exposed to user in a dropdown.
They are "grouped" in the filter section. These fields are boolean.
I can't get them to work together. It's working if I set a single one which "starts with" O or 1. As soon as a add a second condition, there is no result.
A wonder if there is any rule to concatenate the values of the filters (like 0,1,0,0 or 0010) but none of my shoots in the dark made it.
In other words, how do I make combined boolean exposed filters to work ?


texts: Building a View or Panel(?) from an existing node and customize path and breadcrumb

texts:
I have this requirement I don't know how to approach.
The site's taxonomy is used in a hierachical way.

I have a Conference content type and the breadcrumbs and url's follow this pattern:

home/conferences/conference-type/continent/conf-title where conference-type and continent are taxonomy terms

A Conference has an image gallery contained in an Image field, which is not visible on the Conference page itself but to a dedicated page located to    home/resources/gallery/conference-type/continent/conference-name

My question is how do I build this page dynamically from the conference node's content ?

I could use a view or a panel and pass the nid contextual filter, but then:

How do I build the path/breadcrumb from the nid passed as argument?
How do I make sure the view is invoked on this specific path?


texts: I know there is option to preview content type after save. But i want to customise that preview by my css..i want to use image i upload to content type as background and put text on it from content as well. I am learning about modules/themes but i dont know the right way to do this. Opinion of someone experienced would be nice. Thanks a lot!


texts: How to disable the comment for a specific node programmatically?

texts:
I'm using Drupal 8. I would like to close the comment for the node, once someone commented on that node. But I don't know how to disable the comment for a specific node programmatically.

my_module_comment_insert ($entity) //implement the comment insert hook
{
    $node = $entity->getCommentedEntity();//get the attached comment node.
    // How to implement code here to disable comment for the $node?
}


texts: Automatically overwrite existing file, and keep same filename when uploading new.

texts:
I am building a site with D8, where I have a content type 'user' where among other fields, I have two 'file' fields where users will be uploading their CVs (one for english, one for greek language).

I have successfully used File (Field) Paths to give desired, certain filenames to each file, say 'username_EN.XXX and username_GR.XXX' .. This works ok.

My problem is that users will obviously be renewing their CVs, and whenever a new file is uploaded, its filename is automatically incremented to 'username_EN_0', 'username_EN_1' etc.

I need to have new files overwriting old ones and keeping the same filename.

I have researched a lot for this functionality, and it seems it's not yet standard for D8.

This issue presents a summary of this problem, and there are various patches and solutions offered, but it's ambiguous whether they do work, and/or whether they apply to specific scenarios. The issue is still open, and unassigned.

The module itself, has a very similar issue thread, with some solutions offered, but only for the 7.x branch.  There is nothing similar for the 8.x version, and obviously no such functionality.

Other searches point to very old similar threads (from 8-9 years ago) like this one  or module descriptions that never came to life.

I believe that this functionality must have been needed before, I thought there would be a simple way of solving this.  Am I missing something?

Any help would be greatly appreciated ..


texts: product in cart but when clicking on cart it shows empty

texts:
I really don't understand this one...
I have Drupal commerce on Drupal 7.

When I'm adding a product it shows in the cart summary just fine. but when I go on mysite/cart ...the cart is empty. It is not a browser issue I think. Any help on that odd problem would be more than just appreciate, please.

I tried clearing the cache on the server, browser ..none worked


texts: Voting not done with Advanced Poll on Views page for Zen sub theme

texts:
I am using the Views Infinity Scroll and the Views modules. I am using Advanced Poll for the polls. I tried to list all the Advanced poll content types.
The voting for the polls is done quite good in the Bartik theme. It is not working with the Zen theme and the Bootstrap theme. I have checked the scripts loading with the page. All is well with that.

Can anyone help with it?


texts: Set up a Git version control repository that integrates with OpenAtrium

texts:
Is it possible to have OpenAtrium function like the git repository on Drupal.org?

If so, then how can I do it?


texts: Limit taxonomy terms display on hierarchical select

texts:
I need to limit the taxonomy terms visible in a field type 'taxonomy term' using the module 'hierarchical_select' when creating a post.

There is a way to do this?

I have a vocabulary called 'cities' in this format:

state
-- City 1
-- City 2

I have a content type called 'condominiums' and this type of content I have a field called 'city' of type 'taxonomy term' (vocabulary cities) using the HS module.
I have a user with role 'city' and in this paper there is also a field called 'city' of type 'taxonomy term' (vocabulary cities) using the HS module.
I need the user with role 'city' look in the 'city' (when you create a new content) only city that is attributed to him.

Something like:

superadmin user (city 1) can see:

state
-- City 1
-- City 2

user city (city 2) can see:
state-
-- City 2

Tanks :)


texts: Why is Backup Migrate advanced options link going to content page?

texts:
See video: http://screencast.com/t/PqKnaYbB5

I am using backup/migrate and when I click advanced options it just takes me to the content page. Also having a issue with clicking the configuration link for CKE Editor and it goes somewhere else. Any ideas why Drupal 7 would do this?


texts:
I am trying to convert a template to a custom drupal 8 theme and am having trouble with it covering the admin toolbar when logged in. I tried to inspect bootstrap when installed to see what was added but to no avail.  I am trying to create a custom theme from scratch and not a subtheme.  Any help is appreciated to find out what css that I can add that will push the content down while logged in?

Thanks


texts:
I am using Seven for the theme of a internal application. I have custom items setup in the mainmenu, but cannot get it to show?!?!

The blocks for seven are limited to content and help (despite the .info file suggesting a few more???).

/admin/structure/menu/settings

I have set main menu to both Main and Secondary links.

/admin/appearance/settings

I have checked both main and secondary links

What am I missing? How do I get he mainmenu (or any menu) to show in the default Seven theme (without deriving a new theme from it and tweaking it's template.php, etc)???

I can do this with any other default theme...


texts: I use Scheduler when i need to public/unpublish nodes and it works pretty well, but i would like to  schedule the modification of an specific node? is there any module or something?


texts: SQL queries in theme functions - is it a bad practise?

texts:
I know, that calling SQL queries in template files is bad practise. But is it bad practise also for theme functions?

For example when my form is rendering with my custom theme function:

<?php
$form['#theme'] = '_my_custom_theme_form_method';
?>

My custom method *_my_custom_theme_form_method* is placed in .module file.
Is it the same bad practise  as it is for template files?

Is it any serious performance issue, calling SQL queries form theme method?

thanks
Tomas


texts:
How can I get a link with the correct csrf token for an internal path? Here is what I have:

in mymodule.routing.yml

mymodule.test:
  path: '/mymodule-test'
  defaults:
    _content: 'Drupal\mymodule\TestController::handleTest'
    _title: 'Handles test'
  requirements:
    _permission: 'access content'
    _csrf_token: 'TRUE'

building the link:

//$url = Url::fromRoute('mymodule.test');
//$settings['url'] = $url->toString();
$settings['url']=Drupal::url('mymodule.test');

the url contains the token in the query string as I expect, but it doesn't validate if I try to visit the link. When I edit CsrfTokenGenerator and dump out the token and the expected token, they do not match. All I can come up with is that the token is being generated for the page that I'm currently viewing rather than the route that I'm generating the url for.

Am I missing something? any ideas are appreciated!


texts: Rule with if statement prevents users from saving their user account

texts:
I have set up a rule that is causing some odd behaviour.

The event of the rule is: "After updating an existing account"

However the rule is preventing the user to save the data of his particular useraccount.

Allthough drupal says "The changes have been saved." non of the filled in data of the useraccount is saved.eg password etc

It looks like the second condition (If: NOT Data value is empty) is causing the bug.
However i dont know what the alternative should be.

Thanks

Here my rule:

{
  "rules_if_oginvite_redirect_to_oghome_after_userpagesave_and_remo" : {
    "LABEL" : "If registered by mail redirect to oghome or mypage",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Redirect" ],
    "REQUIRES" : [ "rules", "rules_conditional", "php" ],
    "ON" : { "user_update" : [] },
    "IF" : [
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "2" : "2", "4" : "4" } },
          "operation" : "OR"
        }
      },
      { "NOT user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "3" : "3" } }
        }
      }
    ],
    "DO" : [
      { "user_remove_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "4" : "4" } }
        }
      },
      { "CONDITIONAL" : [
          {
            "IF" : { "NOT data_is_empty" : { "data" : [ "site:current-user:og-membership--1" ] } },
            "DO" : [
              { "php_eval" : { "code" : "global $user;\r\n$uid = $user-\u003Euid;\r\n$result = db_query ( \u0022SELECT * FROM {og_membership}\r\nWHERE etid = :uid\r\nand entity_type = \u0027user\u0027\r\norder by gid DESC\u0022, array (\u0027:uid\u0027 =\u003E $uid ) );\r\n\r\n\/\/ get the results\r\nforeach ( $result as $row ) {\r\n\/\/ Do stuff with $record, which is an object\r\n$gid = $row-\u003Egid;\r\nbreak; \/\/get the latest one by breaking here\r\n}\r\n$_SESSION[\u0027ses_user_group_gid\u0027] = $gid;" } },
              { "redirect" : { "url" : "\u003C?php print \u0022node\/\u0022.$_SESSION[\u0027ses_user_group_gid\u0027];  ?\u003E" } }
            ]
          },
          { "ELSE" : [ { "redirect" : { "url" : "mypage" } } ] }
        ]
      }
    ]
  }
}


texts: Mapping regular SQL to Drupal's Database API - using 'exists'?

texts:
I have the following SQL that I'm trying to translate using Drupal's Database API:

select nid,biblio_type from biblio where not exists
    (select * from biblio_types where biblio_type = tid);

What would the translation be?  Currently I have this which is not working:

$sub_query = db_select('biblio_types','bt');
$sub_query->fields('bt',array('tid'))
         ->condition('biblio_type','tid','=');
$query = db_select('biblio','b');
$query->fields('b',array('biblio_type'))
      ->notExists($sub_query);
$result = $query->execute();

EDIT #1: Changed exists to notExists.

EDIT #2:

After changing exists to notExists and replacing the condition statement in the subquery with where per Clive's instructions, this is the SQL that is placed in $result->queryString:

SELECT b.biblio_type AS biblio_type
FROM
biblio b
WHERE  ( NOT EXISTS  (SELECT bt.tid AS tid
FROM
biblio_types bt
WHERE  (b.biblio_type = bt.tid) ))

...which is what I expect.  If I place this statement verbatim in MySQL Query Browser I get the exact results I want.  It returns exactly 9 rows of data.  Perfect!


texts: How to have custom ajax commands on element using InvokeCommand

texts:
How can i use custom ajax command using #ajax api , i have the following code working well

        $ajax_response = new AjaxResponse();
        $ajax_response->addCommand(new InvokeCommand('#edit-event-trigger', 'attr', array('disabled',true)));
        $ajax_response->addCommand(new InvokeCommand('#edit-event-trigger', 'removeAttr', array('placeholder')));
        $ajax_response->addCommand(new InvokeCommand('#edit-event-trigger', 'css',array("background-color", "")));
        //Return the AjaxResponse Object.
        return $ajax_response;

But suppose if i want to focus() or hide() the edit-event-trigger element , how could i do that ?


texts:
I have a Paragraph with an Entity Reference Field "link". This Paragraph belongs to Content Type B.

I want to create a reverse Entity Reference for "Link": all nodes that have the paragraph with this Entity Reference should be listed.

I tried

content_dependency - does not seem to work with Entity References within Paragraphs
reverse_node_reference - not working at all?
Custom View: did work with a entity reference without a paragraph (relationship referencing ER field) but not with the paragraph....

Any ideas?


texts: Pass a preprocess variable to a template?

texts:
In subtik.theme, I have:

/**
 * Implements template_preprocess_field().
 */
function subtik_preprocess_field(&$variables) {
  if ($variables['field_name'] == 'field_language') {
    $variables['language'] = $variables['element']['#object']->get('field_language')->getString();
    ksm($variables['language']);
  }
}

All good. It dumps 'php' to my page, which is correct.

I also have, in field--node--field-body.html.twig, I have:

...
{{ kint(language) }}
...

Not so good. It dumps 'null' to my page. Why not 'php'?