texts: How to use custom code to change the node form layout and group fields while maintaining values?

texts:
I am trying to alter the node form layout in a form alter hook.

I altered the node form and added a field set in which I grouped couple of existing fields into a fieldset. Then hid the existing fields so that they don't show up twice:in the fieldset and standalone.

However, after changing the structure, the field content are not being saved on submission. I thought this is due to drupal internal validation. So I thought I would use a validation hook to map the new fields structure  to their existing (hidden fields). But I am facing couple of issues:

can't retrieve the values in the validation function using $formstate->getValue().
Changing the structure causing the fields to not be processed correctly.

    // Group 2 fields: 1 date field and another text field in custom group
    $form['custom_group'] = [
      '#tree' => TRUE,
      '#type' => 'details',
      '#title' => t('Custom Group'),
      '#weight' => 19,
      '#collapsible' => TRUE,
      'existing_field_1' => $form['existing_field_1'], // is a date field
      'existing_field_2' => $form['existing_field_2'],
    ];
    // Hide the original fields.
    $form['existing_field_1']['#access'] = FALSE;
    $form['existing_field_2']['#access'] = FALSE;

    // Add our validation to try to force the values to be saved:
    $form['#validate'][] = 'my_module_form_node_form_validate';
    // make my validation first but probably unnecessary:
    $form['#validate'] = array_reverse($form['#validate']);

And in the validation function:

function my_module_form_node_form_validate($form, $form_state) {
  // grab the field values:
  $my_values = $form_state->getValue('custom_group')
}

But I cannot access them this way.

After digging into the issue I was able to access the values:

    function my_module_form_node_form_validate($form, $form_state) {
      $values = $form_state->getUserInput();
      $form_state->setValue('existing_field_1', $values['custom_group']['existing_field_1'];
    }

However issue #2 remains.
For example, ->getUserInput(); is returning the raw value of the existing_field_1 which has type date. And the value is just a raw string instead of the normal DateTime object.  So it's failing validation. To clarify ->getUserInput() returns raw string as expected 01-01-2019 and not valid datetime. So I end up with datetime validation error.

I could do the processing myself but that would be an overkill. So, in short, is it possible to use an alter hook two group fields (date/text/esle) into a field set and let drupal process the values?


texts: How can I dynamically add drupal behaviors to a form from php using ajax?

texts:
I am creating a form which dynamically changes based on the value of a select element.  What happens is this:

The user selects a value from the select element
The select element uses Drupal's ajax methods to reload the form, now with some new elements for further configuration
Some of the new elements need to be turned into jQuery widgets.

Now, the obvious solution here is to use behaviors to run the widget initialization code.  The issue is that I don't know ahead of time which elements need to have what code run on them.  I will only know that at the time the ajax portion of the form loads.

Currently, my solution is to have a very short JavaScript file which is solely responsible for adding new behaviors which in turn run the jQuery UI code that I need.

An alternate solution is to pre-load all of the possible configuration elements and inject all of the behaviors ahead of time.  For various reasons this isn't a good idea, not least because I rather like lazy loading.

My question is: is there some way to attach behaviors in php through Drupal's ajax mechanism, like there is a way to modify the settings?


texts: How can I allow a user to send private messages but prevent other users from sending that user a private message?

texts:
I have a "system" user that sends "Welcome to the website" private messages as well as announcements to users.  I am able to send these messages via rules; however, I don't want users to be able to reply to these messages.

I tried disabling private messages for the system user but that option disables both the receiving and sending of private messages (I checked-- if private messages are disabled for a user, no private message can be mailed from that user using rules).

I don't need a solution that is bulletproof; hiding the reply form on the private message view screen is sufficient.  However, I dug through the private message module code and was unable to find any way to do that.


texts: In Drupal, how can I set a role to allow/deny user account requests but not be able to change User 1's password?

texts:
I created a Drupal 6 site for a client which I, as user #1, will edit and maintain. However, I want the client to be able to allow/deny new authenticated user requests. I have created a new role and assigned it the following user permissons:

access user profiles
administer user
change own username

This works and the users with that role can manage new user requests exactly like I want. However, they now also have the ability to change the User 1 password and do some serious damage to the site.

Is there a setting, permission, or module I can use to prevent this?


texts: IE Stylesheets being ignored - only on production server though

texts:
Production server - http://speysideleisure.com

Dev server - http://superallan.com/dev/speyside/

On IE the Dev site is referencing the css properly but the Production site isn't. The Prod is hosted on different servers with a different host - all the files are the same though. The only thing is that I noticed the problems once I'd uploaded it to the Prod server so then I made the changes. I've cleared the Cache a million times but that's the extent of my knowledge in how to solve it. The Dev site changed pretty much instantly.

Is it a setting somewhere on the Prod server?

Cheers for any help - it's appreciated.


texts:
I'm learning Drupal and am trying to wrap my head around it. Recently I have been studying Panels. I wanted to see if my understanding of it was correct.

Basically, you use panels for different layouts: 1col, 2cols, 3cols, etc. You can add or apply different content to each of these columns (aka regions?), eg: a node, custom content, a block, widget, form, etc. You can drag and drop where you want these to be within your layout.

You can either set up a 'panel' as a page, by going Structure>>Panels>>Panel Page

Or, you can make turn an existing page (node?) into a panel page by going Structure>>Pages>>Enabling Node view then creating a 'variant' with a Node type specific to the node (page?). We can then select a layout and place elements from the node in panel's regions, like above.

So the reason to use Panels is to simply allow you to place elements, nodes, blocks, widgets, etc in multiple region layouts.

Is this correct?


texts: How to set checkbox if validation fails?

texts:
I am creating a form which has checkbox, and options for checkbox are coming dynamically. In submit function I am rebuilding form if validation fails. all values are rendering but previously checked checkbox is not checking.

below is the code:

function modulename_form(){
      $header = array();
      $rows = array();
      $conditions = '';
      $orderby = array( 'pass_lname' => 'ASC');
      $unmapped_data = capcup_get_unmapped_passengers_data($conditions , $orderby);

      foreach ($unmapped_data as $key => $value) {
        $user = user_load($value->pass_uid);
        $insertion = !empty($value->pass_insertion)? $value->pass_insertion . ' ': '';
        if (empty($buttons)) {
          $row['name'] = 'mail . '">' . check_plain($value->pass_lname . ' ' . $insertion . $value->pass_fname) . '';
        }
        else {
          $row['name'] = 'passenger_uid . '">' . check_plain($value->passenger_lname . ' ' . $insertion . $value->passenger_fname) . '';
        }
        $row['phone'] = $value->pass_tel;
        $row['practicecode'] = $value->pass_practcode;
          $form['active'] =  array(
          '#type' => 'checkbox',
          '#return_value' => $value->pass_uid,
          '#attributes' => array(
              'name' => array('nodes[' . $value->pass_uid . ']'),
            )
          );
          $row['active'] =  drupal_render($form['active']);
        $rows[$value->pass_uid] = $row;
      }

      $form['nodes'] = array(
        '#theme' => 'table',
        '#header' => $header,
        '#rows' => $rows,
        '#empty' => t('No passenger available.'),
      );
return $form;
}

submit function:

function modulename_submit($form, $form_state) {
  if (in_array('boat', $account->roles)) {
      $form_state['rebuild'] = TRUE;
      form_set_error('boat_user_info][emailaddress', 'Dit e-mailadres is al in gebruik.');
      return FALSE;
    }
}

I am writing form function like above because to get structure like below image:

When form will rebuilt all fields will remembered there previous value but checkbox is not remembered its value. I tried by adding default_value and all but not worked. Please suggest me how can I achieve that.


texts: How to include cck field image in Forward module template (forward.tpl.php)

texts:
I'm using the Forward module and need help adding a custom field into the forward.tpl.php template.  I've found a similar thread on d.o:
https://drupal.org/node/2078479

However, this is for using user profile fields, not node fields.  Here is the code that I came up with, but it's not fully working:

<?php
$path = drupal_get_normal_path($_GET["path"]);
$path = explode("/", $path);
$nid = $path[1];
$forwardthumb = node_load($nid);
$img_uri = $forwardthumb->field_thumb['und'][0]['uri'];
$fid = $forwardthumb->field_thumb['und'][0]['fid'];
$thumbfilename = file_load($fid)->filename;
$derivative_uri = image_style_path($style, $image_uri);
$success = file_exists($derivative_uri) || image_style_create_derivative($style, $image_uri, $derivative_uri);
$new_image_url  = file_create_url($derivative_uri);
?>

In my testing, I've gotten the following text to output in my forwarded-email:
http://mysite.com/sites/default/files/styles/blog_thumb/public

(from the $new_image_url variable)

Which tells me that I've got it partially working, as it was able to indicate the correct folder / location... but I was never able to actually get it to spit out my image-file-name (e.g. thumbnail.png), just the path to the folder containing my image. Please let me know what I'm doing wrong?

Seems like part of this is a bit wonky, as it seems the $node variable in the template isn't the same $node variable used elsewhere in Drupal...?

[Edit] Wanted to also share the code that WORKS in a node.tpl file, but not in forward.tpl:

<img src="<?php print file_create_url($node->field_main_blog_image['und'][0]['uri']); ?>" />

But, when I set this code up in forward.tpl:

$path = drupal_get_normal_path($_GET["path"]);
$path = explode("/", $path);
$nid = $path[1];
$forwardthumb = node_load($nid);

And:

<img src="<?php print file_create_url($forwardthumb->field_main_blog_image['und'][0]['uri']); ?>" />

No luck...


texts:
goes away when I clear the cache but comes back as soon as I visit another page.

new standard installation (drupal 7.32)
lighttpd + php 5.4 (fpm)
mariadb


texts: How to wrap module output with common html?

texts:
I am using Drupal 7.14. I have a custom module with a number of different output pages. I define the paths in hook_menu and then in the callback functions I do some work and call echo theme('mytemplate', array(..args...)) at the end to output my content.

I also have a second custom module that does different work but outputs its content in a similar way.

I want to output some wrapping html that is common to the two module page outputs. At the moment the way I do this is to require a head and foot html file in each of the module template files.

This doesn't feel like a very Drupal approach so I'd appreciate some guidance.

Note: the wrapping html is specific to these two modules so I'd prefer not to pollute my main page.tpl.php file with it.


texts: Passing variables from hook_mail to cutom twig template

texts:
Custom twig template into hook_mail()

$body_content = array(
    '#theme' => 'mail_body_content',
    '#node' => $node,
);

I would like to access to node Entity and display value into the twig

myfield_name: {{ node.get('field_myfield_name').value }}

Render code

$renderedContent = \Drupal::service('renderer')->renderPlain($body_content);

Only myfield_name: is display.
How to get / pass the variable to twig ?


texts: Setting base_url in a multidomain setup?

texts:
I have functionality that relies on having $base_url set in the settings.php file, but I have a multidomain site in order to keep languages separate.

The sections of my site are www.mysite.com and www.de.mysite.com. If I set base_url to "www.mysite.com" I get German language content on www.mysite.com.

How do I set the base_url for a multi-domain, multi-lingual setup so that things like my image style generation can work correctly?

This is a single install, not multisite.


texts: Change decimal separator to comma using commerce-order:commerce-order-total:amount_decimal

texts:
I use D7 in a commerce website. I am setting up an email that will be sent to the user who just made an order.
In this mail, the token [commerce-order:commerce_order_total] is used to display subtotal, vat, shipping and total.

As you can see in the screenshot i use EURO as currency where the decimal separator is comma ','. (The translation is in Greek). So far so good.
After some information in the email, i need to indicate the exact amount that should be paid. I tried with token [commerce-order:commerce-order-total:amount_decimal] but as you can see the decimal separator is the dot and not the comma...

Is it something i can do to fix that ?


texts: trying to dynamically change drupal commerce order

texts:
I am trying to create a pane on the drupal commerce checkout page which will will give the user some options to change which product is in the cart. I want this done with ajax, without leaving the checkout page.

This is the code I have written so far:

  global $user;
  $product_id = 3;
  $order_id = commerce_cart_order_id($user->uid);
  commerce_order_delete($order_id); //delete the present order
  $newOrder = commerce_order_new($user->uid); //and create a new one
  commerce_order_save($newOrder);   //NEED?
  $product = commerce_product_load($product_id);
  $lineItem = commerce_product_line_item_new($product, 1, $newOrder->order_id);
  commerce_line_item_save($lineItem); //NEED?

  // Add the line item to the order using fago's rockin' wrapper.
  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
  $order_wrapper->commerce_line_items[] = $line_item;

  // Save the order again to update its line item reference field.
  commerce_order_save($newOrder);
  commerce_cart_order_refresh($newOrder);

  return $form;

However, this code gives me an ajax error

  Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://example.com/system/ajax

Am I making a code error? A Commerce error?


texts: How are Field API fields transfered from config entities to content entities?

texts:
So I am creating a content and config entities - exactly like node and node type.
After I've created them I've noticed that I can add fields to the config entities, which is ok but then I've realised that I'm working with two separate entity types, so I wonder how re Field API fields "transferred" from the config entity to the content entity?


texts: Strings send for translation inside twig never displayed as translated

texts:
I have this code inside node.html.twig

{{ 'string'|trans }}`

I can see the string and translate it inside the UI but the string is never displayed  I have also tried {% trans %} string {% endtrans %} and {{ 'string'|t }} and I have also tried using this with default Bartik theme.

NOTE: The site DOES show title and body translations of nodes correctly and I clear cache every time I try.

Getting the string to be translated from inside bartik_preprocess_node

$variables['transvar'] = t('new string for translation');

and inside node.html.twig

{{transvar}}

The string can be translated inside UI but still does not display translated string. Title/body are translated.

Interface and content language is detected by prefix /LANG/node/xx and node is displayed using node.html.twig with default bartik theme.

SOLUTION: Its seems that chrome was suffering from some weird caching problem.  I had restarted chrome but apparently a computer restart was all it needed.  When I restarted the problem was gone.


texts: how to programmatically check if a context is active

texts:
I am reading through the API of the drupal 7 context module, and searching for examples, but I can't find a working example of how to programmatically test if a context is active for the current page.

I tried to call the context_isset() function defined in context.module, but what are the namespace and the attribute values? I only know about the context name and it's tag.


texts:
I have a Drupal 7 site that runs on Windows 7 and SQLServer.

Recently, when users try to upload pictures or files they get an error message:

  File could not be saved. An unknown error has occurred. The file was unable to be uploaded.

I have a development and a test site. The site was on Drupal 7.20, then upgraded to 7.23 and it worked for the development and the test sites. However, it did not work in production.

In production I upgraded to 7.23 and verified the elfinder is using library files 1.2.

I am not sure why this is happening: No code was changed before the Drupal core update, and the error is sporadic.


texts: I have created a plain HTML page. I want that the when ever a submit button is clicked, It submits the values to a form that is present on a drupal Site. Its a simple form with only text field. Any idea ?


texts: User's Name, Roles and Mail not accessible throughout the CMS

texts:
I'm trying to access different properties of a Drupal user, such as name or mail, but they are not accessible, either from Drupal Rules module or from the emails sent when a new user has been created according to the configuration set on People's Account settings:
[user:name] and [account:mail]
The same happens with [site:name].
Also in Drupal webform these variables are not appearing on the tokens available either. The only tokens available are: [current-date], [current-page] and [random].
Any clue what should be the cause that these variables are not accessible?
Some time ago they were available throughout the CMS and I don't know what I have changed.
I'm using Drupal 7.69, Rules 7.x-2.12, php 7.3.14 and mysql 5.7.27.
Any help will be very much appreciated.


texts:
I'm trying to write a PHP script that launches a colorbox window when a user attempts to leave the page. Using jQuery Cookie, it's supposed to launch just once per visit. However, with the cookie code in place, the colorbox isn't launching, but when I remove those statements, the colorbox launches. What am I doing wrong?

<?php
drupal_add_js('https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js','external');
drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js','external');
drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/jquery.colorbox/1.6.3/jquery.colorbox-min.js','external');
drupal_add_js('jQuery(document).ready(function() {

        jQuery(".iframe").colorbox({
          iframe:true,
          width: 850,
          height: 700,
            });

});','inline');

drupal_add_js(jQuery(document).ready(function() {
    jQuery(document).mousemove(function(e) {
            if (e.pageY <= 5) {
              if (jQuery(.cookie('pop') === undefined)) {
                jQuery("#colorbox").click();
                jQuery(.cookie('pop', '1' ));
            }
        }
    });
});,'inline');
?>


texts: subtheme preprocess functions inheritance

texts:
I'm using Drupal 7 with Boostrap Theme.

I put the main theme inside sites/all/themes/
And as a recommanded I put sub-theme in sites/my-site.com/themes/

It's working fine but my question is about preprocess hook.

The main theme using bootstrap_preprocess_region() to add some attributes to regions.
In my subtheme, I want to alter attributes of a region already "hooked" by main theme.

So, in my sub-theme template.php file I did

<?php
mytheme_preprocess_region(&$variables){
$region = $variables['region'];
switch ($region) {
 case 'header':
 $variables['attributes_array']['id'] = 'main-header';
 break;
}
?>

But there is no effect in my output ; main theme preprocess function is called after my subtheme preprocess function :(
(I dumped string inside each preprocess to see which is called first)

Is that normal ? Is there a global workaround ?


texts: Hide parent term and show only second level

texts:
I'm getting frustrated figuring this out for a couple of hours. I was not able to make work what I've wanted to achieve.

I have taxonomy which has sub-child. Here is my taxonomy structure:

Parent 1

Child 1
Child 2

Parent 2

Child 1
Child 2

When the parent term is visited, then it will list its sub-child. Like below:-

Parent 1 title

Child 1
Child 2

I've created a views taxonomy terms, I don't want to use content  because the term will not show if that term is empty.

In contextual filters, the taxonomy id with depth and modifier is not available.


texts: Enable / Disable comment form in a module?

texts:
I would like to set a given node's comment flag to 1 or 2 (to either show or hide the comment form) via my custom module, depending on certain conditions.

I have tried using hook_node_view, but this approach seems not to have worked:

function custom_node_view($node, $view_mode, $langcode) {
  $node->comment = 1;
}

Even if I explicitly set the comment flag to 1, it will remain 2 for a given node. If I dpm($node); just after setting the flag, the correct value will show in the devel information, but the comment form will still show...

According to comment.module, the values are such:

/**
 * Comments for this node are closed.
 */
define('COMMENT_NODE_CLOSED', 1);

/**
 * Comments for this node are open.
 */
define('COMMENT_NODE_OPEN', 2);

Is there a different hook I should be using to show/hide the comment form programmatically?


texts: Why jCarousel displays only single item?

texts:
This question is related to: Why Views Slideshow JCarousel plugin isn't available on view format settings?

I've managed to carousel started working but I have only single item visible at a time. However number of Visible Items is 8 and I have 10 pictures. So AFAIC displays 8 pictures at a time

Modules
- jquery_update
- views slideshow jcarousel 7.x-2.x-dev

and jcarousel: https://github.com/jsor/jcarousel/releases/tag/0.3.1

My widget


texts: Is there any way in drupal to get all primary links through views?

texts:
My objective is to get the primary links or any kind of menus items, to be shown as JSON, so that an app could consume it and show it.

I tried it using views and I have services module and views_datasource as well, but no success.

If there is no easy way then I am open to build a custom module as well.
Any suggestions?


texts:
I'm using drupal 9 for a project with a large taxonomy structure. On the parent page I want to show the child terms of the node. Multiple guides i've found have suggested using the contextual filter in a view for "Taxonomy: Parent Term" but that contextual filter doesnt seem to exist in Drupal 9.
anyone have suggestions? Thanks


texts: How do I show a product attribute in a cart?

texts:
I don't know why the item name shows "price" in the shopping cart.

My product variation type have 2 fields: Certificate choice (attribute) and Course period.

How can I customize my formatter in the cart?

The last image is my views "Cart form"


texts: How to select only time without attaching a date?

texts: Is there a field in Drupal 8 that lets you select a time without actually selecting a date? Or should you just use datetime?


texts: Add permission to existing role in custom module using configuration

texts:
Permissions may be added to existing roles programatically as described in this answer. However, I would like to put that into configuration.

I can create a role calling king by putting user.role.king.yml with the following contents at my_module/config/install/:

langcode: en
status: true
dependencies: {  }
id: king
label: 'An actual king.'
weight: 0
is_admin: false
permissions:
  - 'make war'
  - 'judge'
  - 'collect taxes'
  - 'eat'

But in this kingdom, anonymous users may also eat. Adding user.role.anonymous.yml with the following contents to my_module/config/install/ produces an error:

langcode: en
status: true
dependencies: {  }
id: anonymous
label: 'Anonymous'
weight: 0
is_admin: false
permissions:
  - 'eat'

The error, when trying to re-install using devel:

Unable to reinstall modules. Error: Configuration objects (user.role.anonymous) provided by my_module already exist in active configuration.

So it seems that this config may not be duplicated. Is there a way to put anonymous permissions into config, other than hacking /core/modules/user/config/install/user.role.anonymous.yml?


texts: Is it possible to change the output created with the Search module? I want to show custom fields, and I want to hide the description, user and date...


texts: Entity token availabe in Rules but non-functional

texts:
I'm building a submission-review page where submitters select a reviewer. Submissions show up on reviewers profile page and have accept and decline buttons implemented with Button Field module. When the reviewer clicks the accept button, he gets redirected to a new review content form.

Review content type has a node reference field to submission content type which should get populated automatically using Node Reference URL Widget.

I use the Rules module to check if accept button has been clicked and to fire the Page redirect action:

After defining condition Entity is of type Node replacement patterns show up and seem to be available:

So I fill URL to redirect to with the relative url and the entity id:

node/add/review/[entity:nid]

But it doesn't have effect. Rule gets fired correctly but [entity:nid] is empty and reviewer gets redirected to node/add/review/ and so node id to prepopulate node reference field is not available.

Am I doing something wrong or is it a bug in Button Field? Any hints to implement that funcionality in a different way?


texts: Random lost _page_build implementation in cache

texts:
We have an interesting trouble on couple of our sites. The hook_page_build implementations sometimes looses some value from cache.

Using this cose, I get the following result: block, panels_everywhere, rules, admin_menu.

  $implementations_cache = cache_get('module_implements', 'cache_bootstrap');
  $cache = $implementations_cache->data['page_build'];

Using the following code, I get the following result: block, metatag, panels_everywhere, toggle_page_elements, rules, admin_menu, admin_menu_toolbar.

  $hook_info = module_hook_info();
  $hook = 'page_build';
  $implementations[$hook] = array();
  $list = module_list(FALSE, FALSE, FALSE);
  foreach ($list as $module) {
    $include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']);
    if (function_exists($module . '_' . $hook)) {
      $implementations[$hook][$module] = $include_file ? $hook_info[$hook]['group'] : FALSE;
    }
  }

We are using the latest dev of the Memcache module as cache backend.

As I see, only  hook_page_build() is affected. I can't catch any event, which causes that, and I don't see any relevant in the log. Clear class registry fix it, but became wrong 1-2 times in a day.

Why does this happen?

Adding debug code to cache_set(), I experienced the following.

This starts when a user load two pages close to same time:

user/%user/points 1358402424.7797
user/%user/subscriptions 1358402424.0462

Other hooks are affected: init, ctools_plugin_api, entity_view, flag_default_flag, element_info_alter, ctools_render_alter, page_build, form_alter. The following modules seem affected: rate, a custom feature, metatag, metatag_opengraph, better_formats, admin_menu_toolbar, toggle_page_elements (this is a custom module).

I didn't see anythimg relevant in the system table.

If this makes a difference, the site uses a master-slave database environment with with the Autoslave module.


texts: Profile types with unique fields (Profile2?)

texts:
I'm trying to achieve the following with Drupal 7:

Admin user will create all user accounts, users can not
Admin has a choice of two profile types (Coach, Player)
Coach and Player's user registration forms will have different required fields

I've been able to successfully setup the Profile2 module, and create two profile types. However, when I add fields to the Coach's profile those fields also show up in the Player profile when I go to /admin/people (add-user player-profile button)

Perhaps I'm going about this the wrong way, or perhaps I have something configured incorrectly with Profile2?

Thanks in advance for any advice!


texts: Is it possible to create an expression within the fieldCondition?

texts:
I'd like to patch a contributed module that has a nasty bug. Is it true that we can't use fieldCondition() for expressions (e.g. a + b < 10)?

This is the code I am using.

  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', 'node')
    ->fieldCondition($field_name, 'runtime', 0, '!=')
    ->fieldCondition($field_name, 'runtime', $time, '+ node.created <') // BAD $operator!
    ->fieldCondition($field_name, 'active', 1, '=')
    ->propertyCondition('status', 1);
  $result = $query->execute();

According to the current API, it's not possible to use '+ node.created <' as an $operator. Is there anything I could use other than a complete rewrite of this (custom SQL)?


texts: How can I override the node edit in Drupal 6?

texts:
I'm trying to override the "node edit"(using a "page-node-CONTENT-TYPE-edit.tpl.php") in drupal 6, and I'm stuck with the fact that I can't choose which field I want to publish in a specific edit page. I have to publish the whole $content or nothing !
I tried with drupal_render, $form etc... but nothing.

Does anyone have some clues on how I would be able to display the fields I want so I could design my edit page by content type?

I finally got it! It is quite simple; in fact, I just had to make a hook form filter, some "if" on user_access(), and rock and roll!


texts: How to unflag/reset a flag again, when matching some conditions in onFlag event?

texts:
in my custom module I have an event subscriber service for flag module. I used the tutorial here as a base for learning: Link to Tutorial
Here is my code:
namespace Drupal\MYMODULE\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\flag\Event\FlagEvents;
use Drupal\flag\Event\FlaggingEvent;
use Drupal\flag\Event\UnflaggingEvent;
use Drupal\user\UserInterface;
use Drupal\user\Entity\User;

class MYMODULEFlagSubscriber implements EventSubscriberInterface {

  /**
   * Do the logic when the upgrade flag is triggered to flag.
   */
  public function onFlag(FlaggingEvent $event) {
    $flagging = $event->getFlagging();
    $flag = $flagging->getFlag();
    $flag_machine_name = $flag->id();
    if ($flag_machine_name === 'my_awesome_flag') {
      $entity_nid = $flagging->getFlaggable()->id();
      $user = User::load($entity_nid);
      $user_is_active = $user->isActive();
      $field_1 = $user->get('field_1')->value;
      $field_2 = $user->get('field_2')->value;
      $break_with_error = FALSE;
      $upgrade_message = '';
      $roles_to_ignore = [
        'administrator_junior',
        'team_sales',
        'administrator',
      ];
      if (!$user->hasRole('authenticated_level_2')) {
        if (($user_is_active == TRUE) && ($field_1 == 1) && ($field_2 == 1)) {
          foreach ($roles_to_ignore as $role_to_ignore) {
            if ($user->hasRole($role_to_ignore)) {
              $break_with_error = TRUE;
              $upgrade_message = 'The User has a company role already and can not being upgraded as a Level 2 user.';
              break;
            }
          }
        }
        else {
          $break_with_error = TRUE;
          $upgrade_message = 'The User can not being upgraded as a Level 2 User. Reasons: 2. The account is not activated yet, 3. The user has not yet checked field 2';
        }
      }
      else {
        $break_with_error = TRUE;
        $upgrade_message = 'The User was upgraded as a Level 2 User already.';
      }

      switch ($break_with_error) {
        case TRUE:
          \Drupal::messenger()->addError($upgrade_message);
          $flagging->unflag($flag_machine_name, $entity_nid);
          return;

        case FALSE:
          $user->addRole('authenticated_level_2');
          $user->save();
          \Drupal::messenger()->addStatus('The User was upgraded as a Level 2 User sucessfully.');
          return;
      }

    }
  }

My Problem is
How can I unflag the flag again, when my logic checks settings and my variable $break_with_error becomes true?
$flagging->unflag($flag_machine_name, $entity_nid);

throws me an PHP error.
Update:
My intention was the following:
I use the flag here as a substitute for a link/button to trigger the "business logic" checks and to give the user a additional role with more privileges if the checks are passed.
In my opinion it's a easy way to quickly have a link/button in multiple variants (e.g. in a view or as a field in user account). Another advantage is, that other people (in my case sales team or other admins) see the business logic checks have performed already when the user entity is flagged. But in case the logic checks are failing, the user entity should unflagged again.
For other opportunities to have a "business logic trigger" I'm open and thankful of course.


texts:
I am trying to override the field rendered in a view. The field name is: this_is_field

I copied the /core/modules/views/views-view-field.html.twig and placed it my theme folder.

I renamed with both methods below

views-view-field--this-is-field.html.twig
views-view-field--display-name--block-name--this-is-field.html.twig

I have turned on Twig debugging and still the copied template isn't working.

Am I renaming wrong?


texts: Interfacing Data back and forth: JSapp  Drupal

texts:
I want to create custom products for every single one of my customers, and to add a thumbnail and custom order data from a JSAPP.

Seen on #2 My JS application must get the unique id from the user.
regardless if they are logged in or not (i dont know how which is the exact data or variable in the db i should send, and how do i send it?)

in #3 i must recieve custom information generated on the jsapp, i can send this as a  Json , XML or URLstring from the jsapp to drupal commerce; im unsure how could i somehow, inject this information or update a variation of my product.
or maybe there's a more easy way to do this.

Does anyone have some pointers on how to address this communication problem?


texts: How to add comment to a node with ajax (ctools modal)?

texts:
I' trying to create custom module that should add comment to a content type in a modal window, with ajax. I wrote following code, but when I click on the 'Add review' link, browser loads new page when I can add 'reviews about shop' content type. I want to do this in a modal window, without reloading

function current_posts_menu() {
 $items['add/%ctools_js/review'] = array(
   'page callback'    => 'current_posts_ctools_modal_review',
   'page arguments'   => array(1),
   'access arguments' => array('create review content'),
 );
 return $items;
}

function current_posts_popup_style() {

  static $added = FALSE;
  if ($added == FALSE) {
    $added = TRUE;

    // Include the CTools tools that we need.
    ctools_include('modal');
    ctools_include('ajax');
    ctools_modal_add_js();

    $popup_style = array(
      'first-popup-style' => array(
        'modalSize' => array(
          'type' => 'fixed',
          'width' => 420,
          'height' => 'auto',
        ),
        'modalOptions' => array(
          'opacity' => (float) 0.3, .
          'background-color' => '#000000',
        ),
        'closeText' => '',
        'loadingText' => '', .
        'animation' => 'fadeIn',
        'animationSpeed' => 'fast',
      ),
    );

    drupal_add_js($popup_style, 'setting');

  }
}
function current_posts_block_info(){
 $blocks['add_review'] = array(
   'info' => t('Add review'),
 );
 return $blocks;
}

/**
* Implements hook_block_view().
*/
function current_posts_block_view($delta = '') {
    $block = array();
 switch ($delta) {
   case 'add_review':
     ctools_include('ajax');
     ctools_include('modal');
     ctools_modal_add_js();
     current_posts_popup_style();
     $comment_site_id = arg(1);
      $block['content'] = l(t('Add a review'), "add/nojs/review/{$comment_site_id }", array('html' => TRUE, 'attributes' => array('class' => "ctools-use-modal ctools-modal-first-popup-style")));
/*ctools-modal-first-popup-style */
     break;
 }
 return $block;
}

function current_posts_form_alter(&$form, &$form_state, $form_id) {
 switch ($form_id) {
   case 'comment_site':
     $comment_site_id = arg(3);
     if (is_numeric(arg(3))) {
       $lang = field_language('node', $form['#node'], 'field_news');
       // Declaration the default value for field on the comment creating form.
       $form['field_news'][$lang][0]['nid']['#default_value'] = $comment_site_id;

     }

 }
}

function current_posts_ctools_modal_review($js = FALSE) {
 // loading libraries ctools'a
 ctools_include('node.pages', 'node', '');
 ctools_include('modal');
 ctools_include('ajax');

 $type = 'reviews_about_shop';
 $node = (object) array(
   'uid' => $user->uid,
   'name' => (isset($user->name) ? $user->name : ''),
   'type' => $type,
   'language' => LANGUAGE_NONE
   );
  // Loading node form with disabled scripts.
 if (!$js) {
   return drupal_get_form($type . '_node_form', $node);
}
 // Create array $form_state.
 $form_state = array(
   'title' => t('Add Review'),
   'ajax'  => TRUE,
 );

    $form_state['build_info']['args'] = array($node);
    $output = ctools_modal_form_wrapper($type . '_node_form', $form_state);
    // Actions after form submit.
    if (!empty($form_state['executed'])) {
    $output = array();
    // Close pop up.
    $output[] = ctools_modal_command_dismiss();
    $comment_site_id = arg(3);
    // Insert  updated  view into a  page.
    if (is_numeric(arg(3))) {
     $output[] = ajax_command_html('.latest-reviews-full-style', views_embed_view('reviews_on_main_page', 'block', arg(3)));
    }
 }
    print ajax_render($output);
}

Note: I need like adding content type in a modal window. In my module reviews_about_shop is a content type that linked to a content type comment_site.


texts: New tab added to existing admin menu not displayed (plus a bit more!)

texts:
In my custom module I have an admin menu opton with 2 tabs and it worked fine for times. Then I now added a 3rd tab.

But this 3rd tab didn't appear (although obviously I'd cleared the cache).

After checking all I could think to (including the presence of the right page arguments function), I tried to "shake" it a bit, hoping to observe something meaningful:

First I dropped my new 3rd tab to check that nothing changed: ok, 2 tabs.
Then I intentionally introduced a typo in the 2nd tab's page arguments and cleared the cache again: quite surprisingly I got the 2 first tabs still showing!
So having kinda blurred impression that clearing the cache seemed to have no effect, I dropped the 2nd tab too: this time it resulted as expected, with only the 1st tab's page shown (without physically displaying any tab).
Then I restored the 2nd tab, so going back to exactly the same as before my first attempt: but it kept showing only 1st item's page!
And the same after also restoring the 3rd tab.

Here is the code:

function mymodule_menu() {
  return array(
    'admin/config/regional/mymodule' => array(
      'title'            => 'mymodule',
      'description'      => 'mymodule configuration',
      'page callback'    => 'drupal_get_form',
      'page arguments'   => array('mymodule_rendering_form'),
      'access arguments' => array('access administration pages'),
      'type'             => MENU_NORMAL_ITEM,
      'file'             => 'mymodule.admin.inc',
    ),
    'admin/config/regional/mymodule/rendering' => array(
      'title'            => 'Rendering',
      'description'      => 'Configure how mymodule must render',
      'type'             => MENU_DEFAULT_LOCAL_TASK,
      'file'             => 'mymodule.admin.inc',
    ),
    'admin/config/regional/mymodule/tokens' => array(
      'tab_parent'       => 'admin/config/regional/mymodule',
      'title'            => 'Tokens',
      'description'      => 'Choose which tokens mymodule must clone',
      'page callback'    => 'drupal_get_form',
      'page arguments'   => array('mymodule_tokens_form'),
      'access arguments' => array('access administration pages'),
      'type'             => MENU_LOCAL_TASK,
      'file'             => 'mymodule.admin.inc',
    ),
    // Above is the initial part, which worked fine.
    //
    // Below is the new tab I just added.
    'admin/config/regional/mymodule/default' => array(
      'tab_parent'       => 'admin/config/regional/mymodule',
      'title'            => 'Default values',
      'description'      => 'Reset some or all of the configuration options back to default values',
      'page callback'    => 'drupal_get_form',
      'page arguments'   => array('mymodule_default_form'),
      'access arguments' => array('access administration pages'),
      'type'             => MENU_LOCAL_TASK,
      'file'             => 'mymodule.admin.inc',
    ),
  );

I hope I'm merely missing something obvious...


texts:
The paths to css/js/images in a theme look like /sites/mysite.org/theme/*

Is there a way to rewrite those paths to – let's say – /mytheme/* ?


texts:
Is there any way to instantly change all the PNG images in a D7 site to JPEG (with or without backup creating)? By all PNG images I mean to those uploaded via image-field as well as those uploaded via CKeditor.

Going through page after page and changing them manually would take much time, therefore I'm looking for a more automatic way.

Thanks for your advice.


texts: Settings for cache and proxy with Vesta Control Panel in a Drupal site

texts:
In a site powered by Drupal 7 and a Vesta Control Panel I have a problem with cache, or proxy settings. When a visitor respons to a poll, the IP recorded is the IP from the servor, not from the anonymous user. I have the same problem in a Webform contact page, the IP is not from the sender.

In Vesta Control Panel, I have check "Support ProxyNGINX" and select "caching". I have the same problem with another site with NGINX desactivated in Vesta.

Thx for your help


texts: How can I bypass required fields when saving a node as unpublished?

texts: I am saving node as unpublished without adding data in required fields. How can I achieve that in Drupal 8 ? Basically I need something like Save as Draft option for nodes in content types.


texts: How to Give abilty to filter content by geography, separate from language?

texts:
I'm not sure if this is feasible, or how to go about it. I want a dropdown (and use IP detection) to provide users with content based on Region - Not Language. Because we will Also be using the normal Language functionality in Drupal 8 to provide translated content, if they choose to read it in another language. Because languages and countries are not synonymous.

I want the same functionality that's in language filtering, where a user can select "Spain" from a dropdown field and they get page content and blocks that are related to the region. Then, if they desire, also an ability to filter by language.

Here's a scenario:

User, in the U.S., goes to Website.com
They see content that is related to the general global market, in English because they were auto-detected as a U.S. based IP.
User chooses Sweden from the dropdown. Page reloads as
Website.com/Sweden/English (or maybe just website.com/Sweden ?)
Now home page reloads the page, with content specific to Sweden. Similar to how language filters.. but filtered BY COUNTRY.
Now, the user DOES want to change the language. They choose Swedish from a second "language" dropdown on the page, and the home page reloads again with Sweden-related content, translated into Swedish, with this url.
website.com/Sweden/Swedish

Any thoughts on this? I know the language modules can do half of this, but how do I also provide a way for the user to view site content by region. I know views can do some of this, but I'm not sure Views is the appropriate way to present the Entire website.

Maybe someone can clear my head on this.


texts: Automatically Subscribing Nodes to Organic Groups based on Taxonomy Term

texts:
Use Case:
We want to automatically add nodes to groups based on existing taxonomy terms. So when we create a new group it is populated with existing site content such as case studies and white papers that may be relevant.

I was hoping the rules module would allow this but it is not immediately obvious as I was thinking you could set up a series of rules to run that have a logic of if node has taxonomy term x then place in Organic Group Y. This would be nice as removes error and also means editors do not have to add taxonomy terms and then also decide which groups to post into.


texts:
With simple css and javascript code i have created image pop-up which loads automatically after page load, i want to load the pop-up between two specific days (example from date and to date)
please help me with this, is there any module in drupal


texts:
In my drupal admin content page when I search for something it keeps displaying the searched items.

Even when I leave the page and go back it is still displaying items from the search querie

When I press the Clear button the results are normal again. How can I fix this when I leave the content page that it automatically clears the search results?

Thanks in advance!


texts: When I am logged-in the page doesn't look the same as when I am logged-off

texts:
Do I need to include something in the code or in settings.

I have a problem which is that pages don't look the same when I am login or not. Like on photo down. Some help or suggestion?

This is my code. Does I need to add Edit and view bartik?

Whan I change base theme: stable with base theme: bartik bug is fixed.

        {# link is in html.html.twig #}

            {{ page.content }}

{# /.layout-content #}

            {% if page.sidebar_first %}
                    {{ page.sidebar_first }}
            {% endif %}
            {% if page.sidebar_second %}
                    {{ page.sidebar_second }}
            {% endif %}


texts: Drupal 8 Configuration API - cant access variables

texts:
I have made a simple example to practice using the configuration api in drupal 8. I created the following twitter_pull.credentials.yml file in the config/install folder:

oauth_access_token: "12345"
oauth_access_token_secret: "67890"
consumer_key: "54321"
consumer_secret: "09876"

and flushed my cache. In a custom block, I pulled in the configuration

$config = \Drupal::config('twitter_pull.credentials');

and when I did a dpm

dpm($config);

I did not get a null result. However, when I tried accessing a property:

drupal_set_message($config->get('consumer_key'));

now the result was null. Even when I tried using a configuration object which already exists

 $enabled = \Drupal::config('system.maintenance')->get('enabled');
dpm($enabled);

it still returned null. What am I missing here?

EDIT:
If it helps anything here is the full code:

namespace Drupal\twitter_pull\Plugin\Block;
use Drupal\block\BlockBase;

/**
 * Provides a block for executing PHP code.
 *
 * @Block(
 *   id = "twitter_pull_tweets_block",
 *   admin_label = @Translation("Twitter Tweets")
 * )
 */
class TweetsBlock extends BlockBase {

  /**
   * Builds and returns the renderable array for this block plugin.
   *
   * @return array
   *   A renderable array representing the content of the block.
   *
   * @see \Drupal\block\BlockViewBuilder
   */
  public function build() {
    $config = \Drupal::config('twitter_pull.credentials');
    $enabled = \Drupal::config('system.maintenance')->get('enabled');
    dpm($enabled);
    dpm($config);
    drupal_set_message($enabled);
    return 'this is a block: ' . $config->get('consumer_key');
  }
}


texts: How do I set a cookie using $response->headers->setCookie() in a form submission handler?

texts:
I read on Deprecate user_cookie_save() and user_cookie_delete(). that user_cookie_save() will be deprecated in Drupal 9 and that we should now use the Symfony's method, as in the following code.

$response = new Response();
$response->headers->setCookie(new Cookie('foo', 'bar'));
return $response->send();

If I use that code in a submission handler of a custom form, $response-send() just returns an empty page, rather than my site. What am I missing here?

EDIT:

OK, so I moved my cookie setting code to a controller method:

public function setusercookies($zip, $license){
    $destination = urldecode(\Drupal::request()->query->get('destination'));
    $response = new RedirectResponse(!empty($destination) ? $destination : '/');
    $response->headers->setCookie(new Cookie('zip', $zip, strtotime( '+1 year' ), '/'));
    $response->headers->setCookie(new Cookie('license', $license, strtotime( '+1 year' ), '/'));
    $response->send();
    return $response;
}

And in my form's submitForm function:

$form_state->setRedirect('mycontroller.setusercookies', [
      'zip' => $zip,
      'license' => $license
    ], [
      'destination' => $destination
    ]);

In both Chrome and Firefox inspectors, I can see that the cookies are set, but now I can't get them back out. I've tried both:

$zip = \Drupal::request()->cookies->get('zip', 'oops');
/* and */
$zip = $_COOKIE['zip'];

UPDATE 2:
Starting to think it's an environment issue ... lando with pantheon recipe.

SOLVED:
The entire time it seems it was a platform issue:

https://pantheon.io/docs/caching-advanced-topics/#using-your-own-session-style-cookies


texts:
I have been trying to make a slide show on the front page but I am facing an issue on how to upload images of my choice in the slide show. I.e. the images that I have in my computers folder.

I have created a view and placed an image field in it, everything is set. I have also added the block to the main page content. All I can see on the front page is the slider title obviously since i have not been able to add any images.
Can any body tell me how to set my own images to the slider?
I don't want to use fixer slider.

I have used views slide show and some other js files for cycle.


texts:
I'm making a website (don't open in IE) where I use Ajax to load a view. I now want to use BOOST to cache the view as HTML.

These pages should be "BOOSTED":

http://www.spanjevakantiewinkel.nl/regio/ajax/8
http://www.spanjevakantiewinkel.nl/regio/ajax/9
...

Should I use JSON instead of my way to load the view? Any idea how?

The ID (8,9,...) is given by hovering a small image beneath the large header image. Then the view will be loaded, but always within the database, I want HTML pages made with BOOST.

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

  $items['regio/ajax'] = array(
    'title' => 'Dynamic Regio',
    'page callback' => 'dynamic_regio_get_by_category_id',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK
  );
  return $items;
}

function dynamic_regio_get_by_category_id($cat_id){
    $viewName = 'regio_submenu'; // The name of the view we are going to load

    $args = array($cat_id);  // Array of arguments we set for the view.
    $displayId = 'block'; // The display id of for the view.

    // Call the views_embed_view function to returned themed view output
    $html = views_embed_view($viewName, $displayId, $args);
    echo $html;
}

xhr = $.ajax({
  type: 'POST',
  url: '/regio/ajax/' + this.parentNode.getAttribute('tid'),
  success: updateData, dataType: 'html',
});


texts: Attaching a library to the header only as needed

texts:
I'm building a new module. For some reason the jQuery only works when the jQuery library is attached to the header instead of the default footer.  While building the module I was attaching the libraries with the following in the file flot_d8.module

function flot_d8_page_attachments(array &$page) {
  $attach_footer = FALSE;
  $attach_header = FALSE;
  if ($attach_footer) {
    $page1['#attached']['library'][] = 'flot_d8/flot';
  }

  if ($attach_header) {
    $page['#attached']['html_head'][] = [
      // The data.
      [
        // The HTML tag to add, in this case a

Checking the page source shows that when the library is defined in the twig file, both the jquery and flot libraries are included in the aggregated js at the bottom of the page.  Also, on pages which do not render this module, no jquery or flot code is included in the footer. However, the code only renders correctly when I manually force the inclusion in the header using hook_page_attachments()

So I have two questions.
Can anyone help me understand why footer-included libraries do not function in this case, and if I can change something to make them work?
If there is no way to make footer-included libraries to function, what is the best way to force their inclusion in the header only when needed?


texts: Error 500 when adding contextual filter in a view

texts:
I am working on a site for a radio.
I need to show the programmes in a schedule table.
People in the radio used to do it with an Excell document saved in html, I displayed in an iframe. Now I want the Calendar module to generate it, so it's possible to edit the schedule on the Drupal site.

I created a node type for the various programmes, it has a date field to indicated the time it is broacasted (with repeat).
Some programmes are aired more than twice. My content type has a second and third date field for these informations.

I set the ‘week’ display of the ‘calendar’ view to grab that precise content type. I added a contextual filter to take into account a second broadcasting in the week.
It works (though some programmes do not show up on Sundays).
When I wanted a third date taken into account I got an Ajax alert about a Error 500.

I get an error when I choose [Contenu: RE-rediff - date de début(field_rediff3)], though it is shown as available.

/* Filtre contextuel: Date : Date (node) */
$handler->display->display_options['arguments']['date_argument']['id'] = 'date_argument';
$handler->display->display_options['arguments']['date_argument']['table'] = 'node';
$handler->display->display_options['arguments']['date_argument']['field'] = 'date_argument';
$handler->display->display_options['arguments']['date_argument']['default_action'] = 'default';
$handler->display->display_options['arguments']['date_argument']['exception']['title'] = 'Tout';
$handler->display->display_options['arguments']['date_argument']['default_argument_type'] = 'date';
$handler->display->display_options['arguments']['date_argument']['granularity'] = 'week';
$handler->display->display_options['arguments']['date_argument']['granularity_reset'] = 0;
$handler->display->display_options['arguments']['date_argument']['add_delta'] = 'yes';
$handler->display->display_options['arguments']['date_argument']['date_fields'] = array(
  'field_data_field_date.field_date_value' => 'field_data_field_date.field_date_value',
  'field_data_field_rediff.field_rediff_value' => 'field_data_field_rediff.field_rediff_value',
);


texts:
I have a Taxonomy Menu Block, displaying the whole tree of a taxonomy category.

However if I change the order of the taxonomy terms it does not affect the Taxonomy Menu Block. Does anyone know if it is possible to make the Taxonomy Menu Block sort the terms in the order they are sorted in the taxonomy tree..? An illustration of the problem:

My menu block is showing:

Item A
Item B
Item C

If i then go to the tree of taxonomy terms and move Item C above item B like this:

Item A
Item C
Item B

the Taxonomy Menu Block still shows:

Item A
Item B
Item C


texts:
I have written this code to render a list of profiles (using the Profile module). It works fine.

// render profiles
$accounts = \Drupal\user\Entity\User::loadMultiple($uids);
$storage = \Drupal::entityTypeManager()->getStorage('profile');
if (!empty($storage)) {
  foreach ($accounts as $account) {
    $profiles[] = $storage->loadByUser($account, 'profile');
  }
  if ($profiles) {
    $content = \Drupal::entityTypeManager()
      ->getViewBuilder('profile')
      ->viewMultiple($profiles, 'teaser');
  }
}

I have applied the same logic to rendering a list of groups (using the Group module). It fails with the error below.

// render groups
$groups = \Drupal\group\Entity\Group::loadMultiple($ids);
$storage = \Drupal::entityTypeManager()->getStorage('group');
if (!empty($storage)) {
  foreach ($groups as $group) {
    $test[] = $storage->loadByGroup($group, 'my_group');  // FAILS HERE
  }
  /* if ($groups) {
    $content = \Drupal::entityTypeManager()
      ->getViewBuilder('group')
      ->viewMultiple($group, 'teaser');
  } */
}

  Fatal error: Call to undefined method Drupal\Core\Entity\Sql\SqlContentEntityStorage::loadByGroup()

What method should I use to load a group? or how should I programatically load a group?

Thanks


texts: How to programmatically create a title for a new node?

texts:
I want the title field of each new node of the Agenda content type to be constructed automatically from a date field in that same node.

I have variously tried setting the #default_value and #value on the $form array in hook_form_FORM_ID_alter() but without effect.

How can I achieve this?


texts: Redirect to a custom page in hook_init()

texts:
I need to redirect users to a custom page using hook_init().

I have tried drupal_goto(), but it is not working fine. By using drupal_goto(), it is looping and it is not giving the correct result.

So, for that, I have checked a condition using drupal_get_destination(). But, it is not working correctly.

Here is the code:

$destination = drupal_get_destination();

foreach($compatible_arr as $key => $val) {
if(isset($browser_arr[$key])) {
    if(version_compare($browser_arr[$key], $val, '<')) {
        //print strpos($destination['destination'], 'browser-limitations');
        if(strpos($destination['destination'], 'browser-limitations') == '') {
            drupal_goto($base_url.'/browser-limitations/', array('query' => array('version' => $val)));
        }
    }
}

I am using this condition in order to check the browser version using the Mobile Detect module. But, I am not getting the correct result. Is it safe to use drupal_goto() in hook_init()? Or else, is there any function to use it?


texts:
I am using Drupal commons. I am using I18n and other related modules for my website as it is created in English but is being used in French also. I am using translations provided. My issue is that I have string translations but for some strings, text is not being translated, although the translations are available in the drupal.

UPDATE
After going through code, I found that this "Request Message" field is not a normal form field, but it is being rendered using

     field_attach_form('og_membership', $og_membership, $form['membership_fields'], $form_state);

The issue is with this "field_attach_form()". Do ANYONE have any idea what can be done for this??


texts: Is "settings" needed in hook_field_widget_info()?

texts:
hook_field_formatter_info() and hook_field_widget_info return an array containing a "settings" index. I want to know when is it used. What happens if it is empty, or just omitted?

My formatter and widget for my custom field does have settings. It's just that during widget/formatter definition the settings are not known yet.


texts: How do I change the default country on the billing address form in Commerce 2?

texts: I want to set the default country when customers check out in Commerce 2.  How do I do that?


texts: Conflict between Omega and Views 3 exposed sort (Ajaxified)

texts:
I have made a subtheme out of the Omega 4 with the responsive structure.
I tried to use exposed sort for views inside the layouts of the subtheme.

The exposed sorts are not working under the activation of AJAX inside the views, but the exposed filters are working.

Any recommendations?!


texts:
We are using Drupal Core v8.6.2 and we have a url variable in our node--page.html.twig template. While using ksm() and {{ kint() }} we are finding that if we use hook_preproces_node($variables) that the url is inserted into the $variables array. Unfortunately this url is relative, but we need an absolute URL in our twig template.

How can we convert this url variable from our node--page.html.twig template to be absolute?

node--page.html.twig

I have reduced the comments section to only include comments that were relevant to the question.

{#
/**
 * @file
 * Theme override to display a node.
 *
 * Available variables:
 * - node: The node entity with limited access to object properties and methods.
 * - label: The title of the node.
 * - content: All node items. Use {{ content }} to print them all,
 * - url: Direct URL of the current node.
 * - attributes: HTML attributes for the containing element.
 * @see template_preprocess_node()
 *
 */
#}

<a href="{{ url }}> {# url is the variable we want to be absolute #}
  <h2> {{ label }} </h2>
  {{ content.body }}
</a>


texts: Services Module - 500 Internal Server Error When Accessing REST URL

texts:
I created a services endpoint but any time I access the REST URL, e.g. http://www.mysite.com/endpoint I get a WSOD and the following in the firebug console:

"NetworkError: 500 Internal Server Error"

No errors in the dblog.  No errors in the apache error log.

The site is hosted on aegir.  So as a troubleshooting step I moved the entire drupal files and database to my local machine, hoping that I could step through with a debugger.  Guess what, everything works fine!

I've tried uninstalling modules one by one - no luck

I've tried with a clean drupal install on aegir - same 500 error

I'm wondering if anyone can suggest any further troubleshooting steps?

It seems that it could be something to do with the server or aegir configuration.


texts: What are Hooks, Actions and Triggers in basic terms

texts:
In basic terms what are hooks,actions and triggers.

My ideas are that hooks allow you to do something when an event takes place and that the "something" is the action.

I am having a bit of trouble figuring out where triggers fit into the equation.


texts: How to define custom widget for datetime field type

texts:
I want to define a custom widget for datetime field type. I search in www but I found no suitable help and example.

Also I studied date pop-up module but really it was very complicated.

Do you know how can I do this.


texts: How to download files uploaded in a webform through views module?

texts:
I have something like this in registration form and I am using webform module.

I need to show the uploaded file link in reports (using views module) When they click they should be able to download that file.


texts: Get fields of other content type by view relationship?

texts:
I have two content type called 'Department' and 'Student'. I have created a view of content type 'Student', where  i want to fetch fields of Department.I followed below steps:

1.Created one reference field content of type 'Department' in Student content type.
2.Added relationship in the view for that field
3.Added field in the view table fields.
But output is not fetching the field value of other content type.

Reffered link: https://www.drupal.org/node/1841004


texts: How to sort in accordance to best match on the results returned by a views filter?

texts: I have a search functionality which lets user search for people based on their names. To achieve this I am using a view with an exposed filter on the field and the operator being "Contains any word". Now I want to sort the results with the best matched result appearing first. Say I am searching "Amy Jackson", I get all the users with "Amy" first and then the results with "Jackson", thus Amy Jackson does not appear first.


texts: Where is the Rule component_rules_payment_component_delete_all defined?

texts: In Commerce Kickstart 2. Can't seem to find this code.


texts: How to theme the blog module - node--blog.tpl.php?

texts:
I'm really struggling to theme the blog module, all the tutorials I find seem to revolve around creating a node-blog.tpl.php but this template is not picked up by my theme (omega sub theme, Drupal 7).

I have created a node--blog.tpl.php and it seems this template can be used to theme a single blog, and each single blog on a blog/uid page.

I'm looking for a base template I can use for this purpose - is there one?  Or do I simply have to do a $arr = get_defined_vars(); and pull everything out of the page variables.  Seems a bit laborious to save the least?

Thanks in advance,


texts: D7 jquery dropdown menu categorized/ordered by content type and taxonomy

texts:
In D7 I want to create a jquery dropdown menu categorized/ordered by content type (first level) and (if content type has taxnonomy tags) taxonomy via views.

What is the best approach? thnx!


texts: Custom POST Resource Not Working but GET is

texts:
I created a custom resource and my GET Resource works but my POST does not:

<?php

namespace Drupal\xeno_dashboard\Plugin\rest\resource;

use Drupal\Core\Session\AccountProxyInterface;
use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Psr\Log\LoggerInterface;

/**
 * Provides a resource to get view modes by entity and bundle.
 *
 * @RestResource(
 *   id = "snap_shots_resource",
 *   label = @Translation("Snap shots resource"),
 *   uri_paths = {
 *     "canonical" = "/snapshots"
 *   }
 * )
 */
class SnapShotsResource extends ResourceBase {

  /**
   * A current user instance.
   *
   * @var \Drupal\Core\Session\AccountProxyInterface
   */
  protected $currentUser;

  /**
   * Constructs a Drupal\rest\Plugin\ResourceBase object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param array $serializer_formats
   *   The available serialization formats.
   * @param \Psr\Log\LoggerInterface $logger
   *   A logger instance.
   * @param \Drupal\Core\Session\AccountProxyInterface $current_user
   *   A current user instance.
   */
  public function __construct(
    array $configuration,
    $plugin_id,
    $plugin_definition,
    array $serializer_formats,
    LoggerInterface $logger,
    AccountProxyInterface $current_user) {
    parent::__construct($configuration, $plugin_id, $plugin_definition, $serializer_formats, $logger);

    $this->currentUser = $current_user;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->getParameter('serializer.formats'),
      $container->get('logger.factory')->get('xeno_dashboard'),
      $container->get('current_user')
    );
  }

  /**
   * Responds to entity GET requests.
   * @return \Drupal\rest\ResourceResponse
   */
  public function get() {
    $response = ['message' => 'Hello, this is a rest service'];
    return  new ResourceResponse($response);
  }

  /**
   * Responds to entity POST requests.
   * @return \Drupal\rest\ResourceResponse
   */
  public function post() {
    $response = ['message' => 'Hello, this is a POST response!'];
    return  new ResourceResponse($response);
  }

}

This is the response from the POST:

{
    "message": "No route found for \"POST /snapshots\": Method Not Allowed (Allow: GET, HEAD)"
}


texts: How to restrict user posting a node in certain circumstances

texts:
I've created a new user role (country_admin) and I have created a field for these users called user_country. This can be set when registering a user to UK or USA.

I have created a taxonomy 'Countries' and have added UK and USA as terms. I have also created a term reference on my articles so that articles can be assigned to a country.

The functionality I require is that only the user who has UK in the user_country field can post an article with the term set to UK.

I am looking at hook_node_access_records() and hook_node_grants() and have got the functionality working so UK users can only VIEW or UPDATE UK articles using this, however, in hook_node_grants() there doesn't seem to be an "ADD" operation.

How would I do this?

Current hook_node_grants() below

/**
* Implements hook_node_grants().
*/
function curator_scraper_node_grants($account, $op) {
    if ($op == 'view') {
        if (array_key_exists(DRUPAL_AUTHENTICATED_RID, $account->roles)) {

            //Let's get the country id the user is linked with
            $uid = $account->uid;
            $user = user_load($uid);
            $country = $user->field_user_country['und'][0];

            $grants[MYMODULE_REALM] = array(
                MYMODULE_GRANT_ID_PUBLIC, // Allow public data
                $country, // this should be users' country link
            );
        }
        else {
            // this is an anonymous user, give them the 'public' grant ID
            // that allows them access to public nodes
            $grants[MYMODULE_REALM] = array(
                MYMODULE_GRANT_ID_PUBLIC,
            );
        }
    }
    if ($op == 'update'){
        //We can grant update permissions here similar to the above
        // but where is $op == "add"???
    }
    return $grants;

}


texts: How to list out Flag content User in event page in Drupal Commons

texts:
I tried to create the equivalent of the RSVP module (for which no D7 version exists ...) in combination with Drupal commons. But I didn't succeed in that.

So I then decided to use the Flag module, and created a flag for Participant Flag (Participant/Maybe/No) using the answer to my question about "How to implement RSVP Functionality?".

The implementation of the Flag for this is OK, but my next question now is "How to get the exact list of Participants, with some User details?". Some of the User details I want to get included in the list are:

User Name
User Picture

Assume that user A will attended a "Sample event" and user C will not attended that event. Also assume that user B will maybe attended that event.

How to create these 3 lists, for each of the 3 flags I am using (1 flag for each of these lists):

Participant List
Not attended List
Maybe Attended list

Anybody any suggestions?


texts: Is learning Drupal 7 a bad option now after release of Drupal 8

texts:
Hi I am WeB developer and have recently started  learning drupal 7.
I have finished learning basics of PHP and have started learning drupal along with learning how to program the individual elements. Thankfully i have also got no. of materials ranging from books and video tutorials but what i also find is Drupal 8 has now also been released though i think it will take a lot of lot of time for people to build learning materials for that.

But i also think that it will take atleast 1.5 years to learn entire aspect of drupal and by that time Drupal 8 will be the worldwide adopted version.So do you guys think that learning Drupal 7 will be a waste as ppl will sign it off by then due to advent of Drupal 8.
Please guide me on the same


texts: How show time period in one concrete time unit?

texts:
How can I show "time period" in one concrete time unit?

E.g.: I have a movie node type with "length" field with display formatted by time period. But if you put more then 60 minutes into it then it's displayed as "1h XX m".

I've tried to tweak this widget in settings but there is only "Granularity." which allows me to limit display to one hour ("1h") without minutes.

How can I format time period only in one time unit (e.g.: in only hours or in only minutes or in only seconds)?


texts: Fatal error: Class name must be a valid object or a string in /home/dsmedia/blog/public_html/includes/common.inc on line 7749

texts:
I installed a module in drupal called Views Media Browser, that is when I first noticed the issue.

I properly uninstalled the module (unchecked it, uninstalled it, then removed the folder from my sites/all/modules folder).  Now when I go to any article content I've created I am welcomed to the above mentioned error.

I checked the file and the location of it mentioned in the error

/**
 * Get the entity controller class for an entity type.
 */
function entity_get_controller($entity_type) {
  $controllers = &drupal_static(__FUNCTION__, array());
  if (!isset($controllers[$entity_type])) {
    $type_info = entity_get_info($entity_type);
    $class = $type_info['controller class'];
    $controllers[$entity_type] = new $class($entity_type);
  }
  return $controllers[$entity_type];
}

I even compared it to a vanilla version of Drupal and the files are the same.

I noticed that it does not occur with basic pages or any other content type I have. I would prefer not to have to restart the site, so if there is a way to correct this fatal error I would appreciate it.


texts: How do I override the base URL for private files?

texts:
Why in Drupal 8 is possible to override the base_url for public files using the file_public_base_url but not for private files?
There are scenenarios where Drupal is installed behind a reverse proxy. The private files point to the hostname where the backend server is, instead of pointing to the frontend server.

Perhaps a workaround is to use the mod_substitute module (http://httpd.apache.org/docs/2.4/mod/mod_substitute.html) but I don't know if it's the best on.


texts: Is there a module to translate blocks and pages with language modules?

texts:
I am working on drupal 7, and I want to translate each Block/Pages/Node to multiple language.

Is there any module available that will provide facility language tabs to enter language specific content and save?

[<English>]  [Spanish]
|---------------------------------|
| Lorem Ipsum                     |
|                                 |
|---------------------------------|

<Save Content>

I have tried following modules:

Internationalization.
Locale (core module).

It only works on Plain/Text format to translate, I need module which allows me to support all Format to translate content in Block/Page/Node, etc.


texts:
I have an openlayers map view that is populated with user IP address.
I need the map to update automatically (without refreshing) when a new users visits the site.

Much like the behavior of the map on http://drupal.org/ i.e markers would appear but stay on map.

If anyone can point me into the right direction it would be much appreciated.

Thanks in advance!


texts:
I have to convert the following D7 to D8 in my view twig file. I tried the following but its not working.

D7 Code :

<?php print $view->result[$id]->field_field_document_upload[0]["rendered"]["#file"]->filesize; ?>

D8 code in Twig :

   {{ view.result[id].field_field_document_upload[0]["rendered"]["#file"].filesize }}

What's the issue


texts: How to implement custom Checkboxes in Checkout

texts:
How can I implement custom checkboxes to drupal commerce checkout?

Those information I want to have attached to the order.

I have checked extra panes, but I haven´t found a way how to include those checkboxes.


texts: 10,000+ nodes vs. 1 node with 10,000+ field collection items

texts:
I need a sort of term database with around 3 fields that won't be used during normal site operations.. Only when I, the administrator, add content.

I'm wondering about how to minimise performance impact for regular users.. My intuition tells me that a field collection would be better so the nodes table is smaller.

I will be likely be using some code to add data from APIs and Rules to fetch the data by property.

Which should i use? I don't have much interest in creating a custom entity type unless it's really easy.. I want image and audio fields and I don't know if that complicates things.


texts:
I have a content type called Image, it has 2 fields: a image field and a copyright field (with value yes or no).

I've created a view to display them a list. I have a requirement that if a user isn't logged in to our site (anonymous) and the value of copyright field is yes, the images in the view should have a mask added to them by default.

If user is logged in (authenticated), the images should be displayed normally.

Please tell me how can I do this?


texts: clearing cache to call hooks in .module file

texts:
I have created a token in .module file. that gives current node title.

But every-time I change the title of node, I have to rebuilt cache so that updated title get reflected in my token.

Of-course clearing cache again and again on every page refresh is not a good idea.

Any other way to call hook_token_info and hook_tokens automatically on every page load?

PS: I also installed "token" module and this module is using hook_module_implements_alter(&$implementations, $hook).

@edit:

function hook_token_info() {
    $info = array();
    $info['tokens']['etf']['node-title'] = array(
    'name' => t('Node Title'),
    'description' => t("Provides current node title."),
    'type' => 'etf',
    );
    return $info;
}

function hook_tokens($type, array $tokens, array $data = array(), array $options = array(), BubbleableMetadata $bubbleable_metadata) {
  $replacements = array();

  $url_options = array('absolute' => TRUE);
  if(isset($options['langcode'])) {
      $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
      $langcode = $options['langcode'];
  }
  else {
      $langcode = NULL;
  }
  $request = \Drupal::request();
  $route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT);
  $title = \Drupal::service('title_resolver')->getTitle($request, $route);
  if ($type == 'etf') {

    foreach ($tokens as $name => $original) {
      switch ($name) {
              case 'node-title':
              $replacements[$original] = $title;
//              drupal_flush_all_caches();
//              sleep(2);
              break;
       }
    }

  }
  return $replacements;
}

All code is written in .module file


texts: {{ language }} variable not available in block template

texts:
We are trying to generate a language dependent link in a custom block we created though the UI and placed it into a region.

If I {{ dump(language) }} in page.html.twig, I've got it there. But not in the block. Is this by design? Where/How can I get access to it?


texts:
I'm trying to install Drupal 8 with Composer. Drupal Console is already installed (in case that's relevant), so I go to my localhost folder (working locally) and type:

composer create-project drupal-composer/drupal-project:8.x-dev cmpsprjct --stability dev --no-interaction

Everything runs well with the composer installation in the terminal. When I try to proceed with the installation in the browser I get following error:

Additional uncaught exception thrown while handling exception.
Original

TypeError: Return value of Doctrine\Common\Annotations\AnnotationRegistry::reset() must be an instance of Doctrine\Common\Annotations\void, none returned in Doctrine\Common\Annotations\AnnotationRegistry::reset() (line 55 of /var/www/html/cmpsprjct/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php).

Doctrine\Common\Annotations\AnnotationRegistry::reset() (Line: 113)
Drupal\Component\Annotation\Plugin\Discovery\AnnotatedClassDiscovery->getDefinitions() (Line: 86)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 283)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 174)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 109)
Drupal\Core\Render\ElementInfoManager->buildInfo('seven') (Line: 76)
Drupal\Core\Render\ElementInfoManager->getInfo('form') (Line: 806)
Drupal\Core\Form\FormBuilder->prepareForm('install_select_language_form', Array, Object) (Line: 272)
Drupal\Core\Form\FormBuilder->buildForm('install_select_language_form', Object) (Line: 898)
install_get_form('Drupal\Core\Installer\Form\SelectLanguageForm', Array) (Line: 1324)
install_select_language(Array) (Line: 670)
install_run_task(Array, Array) (Line: 548)
install_run_tasks(Array) (Line: 117)
install_drupal(Object) (Line: 44)

Additional

TypeError: Return value of Doctrine\Common\Annotations\AnnotationRegistry::reset() must be an instance of Doctrine\Common\Annotations\void, none returned in Doctrine\Common\Annotations\AnnotationRegistry::reset() (line 55 of /var/www/html/cmpsprjct/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php).

Doctrine\Common\Annotations\AnnotationRegistry::reset() (Line: 113)
Drupal\Component\Annotation\Plugin\Discovery\AnnotatedClassDiscovery->getDefinitions() (Line: 86)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 283)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 174)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 109)
Drupal\Core\Render\ElementInfoManager->buildInfo('seven') (Line: 76)
Drupal\Core\Render\ElementInfoManager->getInfo('html') (Line: 298)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 139)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 576)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 140)
Drupal\Core\Render\Renderer->renderRoot(Array) (Line: 66)
Drupal\Core\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Error', 'install_page', Array) (Line: 76)
Drupal\Core\ProxyClass\Render\BareHtmlPageRenderer->renderBarePage(Array, 'Error', 'install_page', Array) (Line: 1004)
install_display_output(Array, Array, Array) (Line: 264)
_drupal_log_error(Array, 1) (Line: 584)
_drupal_exception_handler(Object)

I have searched in Google and found that a composer update could solve the problem, but it didn't.
Any hints about how to proceed?

Working with Ubuntu 17.04 and php 7.1


texts: How to finally disable comments on content type?

texts:
I am trying to disable comments on webform.
I tried all settings I could find, but:

Link to comment form still appear
Name field and submit button still appear on comment form

Could somebody give me any advice?


texts:
I am using the module Views Tree. Apparently, it gets the hierarchical listing of taxonomy terms, and outputs a tree with indentation levels (two levels).

However, I am not able to style or css it, because the overriden tpl.php ( views-tree.tpl.php ) does not exist, and when I copy views-view-row.tpl.php in the theme folder, renaming the file to views-tree.tpl.php I almost get it, except that the rendering is: first the parent taxonomy terms, and next the children terms. Exactly as without the module.

So I am unable to use none of the available .tpl.php for Views, and cannot change the style, only with css, which is not adequate (there are ul tags which I want to have different classes, for example).

So, sadly, I must use template.php and views_get_view_result to recover the View and css it, which is exactly as not having the module installed at all! What am I doing wrong?


texts: How to remove Input format from comment form?

texts:
I used following code to create a module to remove input format from comment forms, but it doesn't work. Is there anything I'm missing or another way to do this ?

<?php
function comment_custom_form_alter($form, $form_state, $form_id) {
  if ($form_id == 'comment_form') {
    foreach ($form['comment_filter']['format'] as $i => $filter) {
      if (is_int($i) && !$filter['#type']) {
        $form['comment_filter']['format'][$i]['#value'] = '';
        $form['comment_filter']['format'] = '';
        unset($form['preview']);
        unset($form['_author']);
      }
    }
  }
}
?>


texts:
Trying to do https://developers.sendinblue.com/reference#createcontact, the cURL command they provide in their API help works from the command line, but I can't get it to work in the Webform handler.
I tried setting the headers in the remote post handler "Advanced" tab in the "Custom options" box.
header:
  Accept: application/json
  Content-Type: application/json
  api-key: xkeysib-XXXXX

The request looks correct in the devel/debugging.
header:
  Accept: application/json
  Content-Type: application/json
  api-key: xkeysib-XXXXX

It gives an error.

Response status code: 401

Response body
   {"message":"Key not found","code":"unauthorized"}

Response data
  message: 'Key not found'
  code: unauthorized

How do I correctly send the request?


texts:
I need to do a lot of sort criteria based on the number of profile pages viewed in Views , but I do not have any fields related to statistics and I cannot find any module which would help me to add fields to Views displays. Is there any module that would do the job or what do I have to do to get statistics about certain pages?

Someone said to alter the view query but how do I know in which table and what reference is between that table and the page that I want the statistics for?


texts: how to chnage appearance and look and feel of pop-up modal with CTools in drupal?

texts:
how to remove header in pop-up modal with CTools?
resizing of pop-up modal with CTools?


texts: What do you do in a Views field theming function to change the output?

texts:
[warning: Views newbieism ahead...]

I've got a View working with the FullCalendar module, which shows items from one of my content types in the calendar.  The title of the item appears in the calendar on the day specified by the "target date" field; all of this is working fine.  I now want to change the string that shows up in the calendar from the title of the item to something different, which I'll work out based on the item being shown in the view.

This is a matter of theming, I presume.  I've defined a template file called views-view-field--fullcalendar--field-target-date.tpl.php in my theme's template folder.  Some dsm() statements in this file confirm that it is getting picked up by the Views system, and its $row and $view variables have appropriate values.  But nothing that I do in this file changes what's presented in the view -- I thought print "something" would do it, but it doesn't; I've tried setting the passed-in $output and other values to something on the hope that they would magically find their way back to some code that would print them, but again without luck.

So I seem to be in the right place -- what do I have to do to change what gets displayed on the page?


texts:
I am trying to create a custom form in my drupal 8 instance, and I have followed a few different tutorials, but every time I try to go to the forms path I see the following error on the page:

The website encountered an unexpected error. Please try again later.

When I check my apache log, I see it came because of this error:

Uncaught PHP Exception InvalidArgumentException: "Class "Drupal\report_service_call\Form\ReportServiceCallForm" does not exist." at /var/www/html/abcnj/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php line 24

I do have my ReportServiceCallForm set up at the following path under my module:

lib/Drupal/report_service_call/Form/ReportServiceCallForm.php

this is the contents of that file:

<?php
/**
 *@file
  *Contains /Drupal/report_service_call/Form/ReportServiceCallForm
  */

  namespace Drupal\report_service_call\Form;

  use Drupal\Core\Form\FormBase;
  use Drupal\Core\Form\FormStateInterface;
 /**
  *Implements Drupal form Interface
  */
 class ReportServiceCallForm extends FormBase{

 /**
  *{@inheritdoc}
  */
  public function getFormID(){
     return 'report_service_call_form';
  }
 /**
  *{@inheritdoc}
  */
public function buildForm(array $form, array &$form_state){
  $form['company_name'] = array(
    '#type'=> 'textfield',
    'title'=> $this->t('Company Name')
  );

$form['cotact_name'] = array(
  '#type'=> 'textfield',
  'title'=> $this->t('Contact Name')
);

$form['current_system_type'] = array(
  '#type'=> 'textfield',
  'title'=> $this->t('Current System Type')
);

$form['telephone_number'] = array(
  '#type'=> 'tel',
  'title'=> $this->t('Telephone Number')
);

$form['email'] = array(
  '#type'=> 'email',
  'title'=> $this->t('Email Address')
);

$form['service_request'] = array(
  '#type'=> 'textfield',
  'title'=> $this->t('Service Request')
);

$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => $this->t('Save'),
    '#button_type'=>'primary',
);
return $form;
}

  /**
  *{@inheritdoc}
  */
  public function validateForm(array &$form, array &$form_state){

  }

 /**
  *{@inheritdoc}
  */
  public function submitForm(array &$form, array &$form_state){

  }
}

Also I have the contents of my routing.yml as follows:

report_service_call.form:
    path: '/Customer-Service/Report-Service-Call'
defaults:
  _title: 'Report Service Call Form'
  _form: 'Drupal\report_service_call\Form\ReportServiceCallForm'
requirements:
  _permission: 'access content'


texts: How to use Drupal as static website generator?

texts:
When I want to convert my Drupal 7 site to html files I have used Static module, which converts Drupal 7 site to html files. However, I will like to know how I can convert a Drupal 8 into static html pages.

Any ideas on how I can make a Drupal 8 website into static html pages ?


texts: l() is printing "http://node/16" when gets "/node/16" as argument

texts: This site was copied to a new domain when it started breaking. Is there some setting somewhere I need to update, so it knows how to build working URLs again?


texts: How do I get an array of all entitytypes of a specific entity?

texts:
Hey there what I'm trying to do is to get all entity type ids from my custom config entity.
To load them all.

Example give:

I have an entity 'foo' and I create a new 'foo' named 'bar1' and another 'bar2' and so on how do I get those ids programmatically?

Better question

How do I get all entity_type_ids(or bundles dunno don't found a good entity hirarchie doku yet :( ) of an entity for example all types of the node entity?


texts: How to add an exist term reference to a new node?

texts:
I have already add a term reference to the article, I want to create a new node by programmatically. When the new node was save, I hope the node was signed with the term data.

In the taxonomy_vocabulary table, I create a column named content_type. In the taxonomy_term_data table exist several terms with the vid of content_type. I hope when the node was created the node was tagged  by one of these terms. Can somebody help me?


texts: What is the correct syntax to embed JS from Jquery UI website in Drupal 7?

texts:
I'm trying to get simple JS to work on my site for testing, but having a hard time with the syntax.

The script I want to enable is simple hide script, html is:

Click anywhere to toggle the box.

JS is:

$( document ).click(function() {
  $( "#toggle" ).toggle( "slide" );
});

Example is here:

https://api.jqueryui.com/slide-effect/

What should I put in JS file to make this work with Drupal 7?


texts:
I want to embed a view into the body of a node on Drupal 7. I've tried the module Insert View and that didn't work.

I also saw support from Drupal on inputting PHP code, but I have no idea where to put that code.


texts: How to get an entity reference's field in a database query

texts:
I have a simple query right now, a db_select that returns the fields I need, but the problem is that one field is entity reference and I don't know how to get its fields from the db_select.

The other thing is that entity reference I'm talking about has another entity reference in it, and I would like to get its fields too.


texts: How to schedule a Rules component at the end of the month?

texts:
The users on my website can flag articles with Flag. I want them to be able to do this exactly once every month, but they do not have permission to unflag content. Therefore, my plan is to create a Rule that triggers when an article is flagged and that schedules a Rules component that takes care of the unflagging.

How can I schedule this component at the end of the month, i.e. which value should I add in the field Scheduled evaluation date of the action Schedule component evaluation?


texts: Is it possible to add taxonomy filters to the standard advanced search?

texts: I wonder if is possible to add select boxes from my taxonomy to the standard Drupal 7 advanced search form. I'd like to search for document containing the word "test" and which have the word "High" in the vocabulary "Height".


texts: Data export import module node id different after imported

texts:
I using Data export import module in my new Drupal 7.

I imported Drupal 6 database into Drupal 7 site.

But unfortunately the node id for the same article is different.

How do I fix this?


texts: How to change the title of the button in the user profile form in Drupal 7?

texts:
How do I change the name of the button in the user_profile_form in Drupal 7?
I alter the user profile using hook_form_alter().

function userform_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_profile_form' ) {
    // I define a submit button like:
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Continue'),
    );

    //Then I can change it with this code:
    // Change 'Continue' to 'Sign in'.
    $form['submit']['#value'] = t('Sign in');
  }
}

It works for all elements (buttons) I define myself, but it doesn't work for the default button in the user profile form.
This the rendered HTML for the "Save" button:

<input id="edit-submit" class="form-submit" type="submit" value="Save" name="op">


texts: Custom Search works on all pages except front

texts:
I have a custom search block in my header. When I search for something i am redirected to a new page and shown my products (this is the desired effect). The problem I'm having is on the front page. When I search for a product on my front page my front page is reloaded. I assume this has to do with aliases, but I have not messed with them on any of the pages so I'm not sure why it doesn't work on my front page, but works perfectly on all the other pages.  Any help would be great.

Thanks!

update: I solved the issue by replacing my search with and advance search. If anyone knows why a custom search wasn't working for me, I'm still interested in knowing why.


texts: Manage/Assign Roles to Users Other than Administrators

texts:
I was asked to create a module that allows a user with the specific role to assign roles to other users w/no 'administer user' permissions or not an administrator. The user must not be allowed to edit info about the users with 'administer user' permission/admin.

How can I do this? Do I have to create a custom module for this? Is it possible to use Views module for this?


texts: How to create private links to unmanaged files ?

texts:
I have created my own module with custom block to display private downloads to authenticated users. The downloads files are provided by 3rd-party system and stored in private folder of Drupal downloads/private/. Drupal should limit downloads to authenticated user to specific folder e.g. userA sees only downloads folder /download/private/userA. Important side note: Solution must work with shared hosting provider enviroment.

Currently I have tried few versions download link creation:

$Relative => /download/private/userA/foo.txt => 403
'private://' . $Relative => http://localhost/en/system/files/download/private/userA/foo.txt => 404
'public://' . $Relative => http://localhost/sites/default/files/download/private/userA/foo.txt => 403
Url::fromUri(file_create_url($Relative))->getUri() => http://localhost/download/private/userA/foo.txt => 403

403 responses are delivered from Apache and Drupal is not involved.

My code looks like this:

<?PHP
class DownloadBlock extends BlockBase {

    private build() {
        // Check user has permission + lookup download folder

        $Path = 'C:/xampp/htdocs/drupal/download/private/userA/'
        $aFiles = file_scan_directory(, /.+/, ['recurse' => FALSE]);

        $aLinks = [];
        foreach ($aFiles as $File) {
            // eg download/private/userA/foo.txt
            $Relative = makeRelativeLink($File->uri);
            $link = file_create_url('private://' . $Relative);
            // value $link => http://localhost/en/system/files/download/private/userA/foo.txt
            array_push($aLinks, $link);
        }
        return $aLinks;
    }
}

I am aware that I need links which causes Drupal to handle the download and hits my custom download hook in myplugin.module:

<?PHP
function myplugin_file_download($uri) {
  \Drupal::logger("download")->debug("Hook download was triggered " .  $uri);
  // Check current user + permission
  // return headers or permission denied
  return [];
}

Configuration: Drupal - Private file system path is downloads/private/ Default download method: Private local files served by Drupal. Apache blocks all attemps to download a file with plain links. Content downloads/private/.htaccess:

# Deny all requests from Apache 2.4+.
<IfModule mod_authz_core.c>
  Require all denied
</IfModule>

# Deny all requests from Apache 2.0-2.2.
<IfModule !mod_authz_core.c>
  Deny from all
</IfModule>
# Turn off all options we don't need.
Options -Indexes -ExecCGI -Includes -MultiViews

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
  php_flag engine off
</IfModule>

I currently developing with XAMPP and Drupal 8.0.5 on Windows Box. I'm out of ideas. My google foo exhausted. Please, somebody point me to missing pieces for my puzzel. Thanks!