๐Ÿ‡ฎ๐Ÿ‡ณIndia @shrikant.dhotre

Account created on 29 March 2019, almost 6 years ago
#

Merge Requests

Recent comments

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

shrikant.dhotre โ†’ changed the visibility of the branch 3353786-typeerror-cannot-assign to hidden.

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Hi @markdorison, can you please release this. MR.

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

shrikant.dhotre โ†’ made their first commit to this issueโ€™s fork.

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

But still not resolved still looking for answer.

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Hi @Prashan.c,
I have implement below code.

/**
 * Implements hook_block_access().
 *
 * Hide Open ID connect block if Drupal Login form is enabled.
 */
function custom_module_block_access(Block $block, $operation, AccountInterface $account) {
  $drupalLogin = \Drupal::state()->get('drupal_login_active');
  if ($drupalLogin && $block->id() == 'openidconnectlogin_3' && $operation == 'view') {
    return AccessResult::forbiddenIf(TRUE)->addCacheableDependency($block);
  }
}
๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Certainly! In Drupal, using hook_views_query_alter to change the sorting based on a formula involves altering the query by implementing logic to dynamically set the sorting criteria. This can be achieved by manipulating the query object within the hook.

Hereโ€™s an example of how you might use hook_views_query_alter to change the sorting of a View based on a formula:

/**
 * Implements hook_views_query_alter().
 */
function YOUR_MODULE_NAME_views_query_alter(&$view, &$query) {
  // Check if this is the view you want to modify.
  if ($view->name == 'your_view_name') {
    // Check if the display is the one you want to modify (e.g., page, block, etc.).
    if ($view->current_display == 'your_display_name') {
      // Manipulate the sorting based on a formula.
      $new_ordering = your_custom_sorting_formula(); // Call your custom function to determine the sorting order.

      // Set the new ordering in the query.
      $query->orderby = $new_ordering;
    }
  }
}

/**
 * Custom function to define the sorting order based on your formula.
 */
function your_custom_sorting_formula() {
  // Implement your logic to determine the sorting order.
  // This function should return an array defining the sorting order.

  // Example: Sort by a computed value or any custom logic.
  $sorting_order = array(
    0 => array(
      'field' => 'your_field_name', // Replace with your field name.
      'direction' => 'ASC', // Change this to 'DESC' for descending order.
      // Add more sorting criteria if needed.
    ),
    // Additional sorting criteria can be added here.
  );

  return $sorting_order;
}

Replace 'your_view_name' and 'your_display_name' with the actual name of your View and its display. Adjust 'your_field_name' with the field you want to sort by or replace it with the computed value you want to base the sorting on.

The your_custom_sorting_formula() function should contain your logic to determine the sorting order, returning an array that defines the sorting criteria based on your formula.

This approach allows for dynamic sorting based on any custom logic or formula you need within your Drupal View. Adjust the function your_custom_sorting_formula() as per your specific requirements for sorting.

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Hi Team,
 

I want to add numbering sort for text column, so I have added lpad formula in order by field. but it escaping the characters "(", "," in the formula

I am using hook view_query_alter, module code is below,
 

function mymodule_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {

  if ($view->id() == 'view' && $view->current_display == 'display') {
    // Traverse through the 'orderby in static_id' part of the query.
    foreach ($query->orderby as &$orderby) {
      $pos = strpos($orderby['field'], 'field_static_id_value');
      if ($pos) {
        $orderby['field'] = sprintf("lpad( %s , 20 , 0 ) ", $orderby['field']);
      }
    }
    // die();

}

Kindly help that I am doing correct way or any another way to add this formula in view query.

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Hi @cilefen,

I am using this hook one of my module and it giving me below error

Warning: Undefined array key "#markup" in Drupal\Core\Render\RenderCache->getCacheableRenderArray() (line 333 of D:\xampp\htdocs\project\docroot\core\lib\Drupal\Core\Render\RenderCache.php)

Inside this hook, I am calling a block which created bin OpenID module. which need to be display in custom login page.

I am getting this warning. Need help to resolve the warning

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

I have removed PFB,
I am getting warning which I am adding block on login page.

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Hi @Quietone,

I created fields machine names with numeric, with implementation of workflow module.
created below fields and nested paragraphs with content type using content moderation state, paragraph and view field as view contributed
Modedration stage are defiend like : Draft, Pending, Approved, Archived.
field_name_1,
field_name_2 >> field_name_22 >> field_name_222,
field_name_3 >> field_name_333 >> field_name_444

Now requirement is like, we have impleted drupal with headless arch.
Created a Json API with using content revision, so each field is comming with historical data with revision_id
field_name_1-revision_id

For Json API, created a views in rest export nested.

view output is giving an error with
TypeError: Cannot assign null to property

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Yes, this is valid Scenario, when we are creating a field with machine name having suffix numeric view will not work,
e.g.

field_1
field_2

And when we are using views field as view this fields arguments are giving an error.
TypeError: Cannot assign null to property

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Hi,
I am facing the same problem, for paragraph translation in content moderation, using drupal 9.5.7
Translation of paragraph content is not rendering latest change done in default language. I need to re-publish the translated content then its rendering properly.

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Thanks for highlighting, I will deep analyses whether NULL is valid scenario or not

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Hi @nginex , Thanks fix now its working for all the translation

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Yes @nginex, I have updated the module and tried multiple times with clearing cache with drush as well as browser link as well.

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

I am having two translations of content and if I am export translated content I am getting above issue.

๐Ÿ‡ฎ๐Ÿ‡ณIndia shrikant.dhotre

Thanks for this translation help

Production build 0.71.5 2024