texts: Batch API times out when running a single operation

texts:
I'm trying to print ~100 nodes worth of content (Performance Plans) out to the private file system using the batch API. My process works perfectly up until about 10 of them and then times out. The timeout page happens before it even gets to the batch page with the progress bar. It appears to me like it might be running all 100 as a single batch vs breaking them up. I'm not sure exactly what I'm missing... Any help would be greatly appreciate.

BulkPrintForm.php

<?php
 namespace Drupal\bulk_print_to_files\Form;
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\node\Entity\Node;
 use Drupal\Core\Url;
/**
 * Class BulkAddForm.
 *
 * @package Drupal\create_perf_plan_for_new_year\Form
 */
class BulkPrintForm extends FormBase {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'bulk_print_form';
  }
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['bulk_add'] = array(
      '#type' => 'submit',
      '#value' => $this->t('Print Performance Plans'),
    );
    return $form;
  }
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $nids = \Drupal::entityQuery('node')
      ->condition('type','perf_plan')
      ->condition('field_performance_plan_year', 18)
      ->range(0, 100)
      ->sort('created' , 'DESC')
      //->condition('nid', 6273)
      ->execute();
    //$year = "1920"; //$year being left here as an example of passing a variable to the bulk process. Not currently in use.

    $operations = [];

    foreach ($nids as $nid) {
      $operations[] = [
        [
          $this->batchFunction($nid),
          [$nid]
        ],
      ];
    }

    $batch = array(
      'title' => t('Bulk Print happening within the Bulk Print Form file...'),
      'operations' => $operations,
      'progress_message' => t('Processed @current out of @total. Estimated time: @estimate.'),
      'init_message'=> t('Performance Plans are being printed to the private directory!'),
      'finished' => '\Drupal\bulk_print_to_files\BulkPrintNode::bulkPrintFinishedCallback',
      'error_message' => t('The migration process has encountered an error. (Make sure the folder you are placing these in exists!)'),
    );
    batch_set($batch);
  }
  function batchFunction($nid) {
    $print_engine = \Drupal::service('plugin.manager.entity_print.print_engine')->createSelectedInstance('pdf');
    $print_builder = \Drupal::service('entity_print.print_builder');
    $path = 'private';
    $filename = "perfplans/{$nid}.pdf";
    $nodes = \Drupal::entityTypeManager()->getStorage('node')->load($nid);
    $uri = $print_builder->savePrintable([$nodes], $print_engine, $path, $filename);
  }
}

BulkPrintNode.php

<?php
namespace Drupal\bulk_print_to_files;
use Drupal\node\Entity\Node;
use Drupal\Core\Url;

function bulkPrintFinishedCallback($success, $operations) {
    if ($success) {
      $message = 'Performance plan printed.';
      $type = 'status';
    }
    else {
      $message = t('Encountered an error during bulk performance plan creation.');
      $type = 'error';
    }
    drupal_set_message($message, $type);
  }
}

Is there a way to limit these to say doing 5 at a time and then moving on to another set? Im under the impression I just have the batching process setup incorrectly.


texts: How do I set my custom module to use a template for a specific page?

texts:
I have created a custom module that adds some form elements to nodes of specific content types. Another part of this module requires a specific formatting output of data that is a little more complex than using $form[''].

How can I tell my module that for a specific function, it should load a certain template file?


texts: Determine source of data corruption in Metatag module

texts:
I've run into data corruption issues on my site that seem to be stemming from the Metatag module. I've currently disabled Metatag and its associated modules, but previously, in addition to the base Metatag module, I'd also been using the Facebook, Panels, Verification, and OpenGraph Metatag functionality.

The reason I believe it to be related to Metatag is that the hosting support tech helping troubleshoot initially solved the issue of mysql crashing and restarting by truncating the cache_metatag table. The site was fine for a few days, then again I saw the issue of mysql crashing. To try to stem any further issues, I disabled the Metatag Facebook, Panels, Verification, & OpenGraph modules. This brought the site down entirely and hosting support had to dump all of the databases and re-import. As this process cleared any temporary data, presumably, the problematic cache table was truncated again.

Without being able to replicate consistently, I'm not sure how to troubleshoot or pinpoint the problem enough to submit an issue on the project.

How can I go about pinpointing an issue like this?
Is disabling these modules enough to prevent data corruption in an associated cache table? Sorry if that's a silly question, my guess is that cache data wouldn't be generated if disabled, but I want to be sure to prevent any further data corruption + site downtime.


texts: How to access services display view in Postman?

texts:
I have used Services view display in views. If I give this url(http://ram.sample.dev/newapi/books) in the browser its showing me the results of the created view.

But same url if I try in postman it says couldn't find the controller. Here books is the resource name which I have created in views. I have tried using the below samples but still I got the same issue.

http://ram.sample.dev/newapi/books

http://ram.sample.dev/newapi/views/book_search

following patterns like this :

http://example.com/<endpoint path>/<resource name>

http://example.com/<endpoint path>/views/<view name>

How should I access the url for services display view in the postman ? Any help will be much appreciated.


texts: Drupal 8 : Add Product SKU as search filter for Orders view of the Commerce module

texts:
I like to achieve below solution using Drupal configuration instead of code.

The commerce module has been installed for one of our Drupal CMS site. In the admin interface there is an Orders view for the Commerce module. This view basically shows all orders placed by users on the website.

Within this view I like to add Product SKU field as one of the search filter. I noticed SKU field exists in the Product variations table that is child table of the Products table. And Product table is linked to Order Item table. And Order Item is the child table of Orders table. This is something I checked on the MySQL DB database table relations otherwise I don't know how to find our such relationships from Drupal admin interface.

I went to EDIT section for the Orders view. Then clicked on Add button for Advanced >> Relationship but can't find find any product or product variation entity there. So not sure how to achieve the solution of my problem?

Can you please help?

Looking forward to getting your reply.

Thanks - Hitesh


texts: Fatal error when calling drupal_goto from hook_boot

texts:
When I am trying to call drupal_goto from hook_boot I get an error:

  Fatal error: Call to undefined function drupal_goto()

What am I doing wrong and why is that happening?

My code:

function custom_mobile_redirect_boot() {
  include_once 'Mobile_Detect.php';
  $detect = new Mobile_Detect();
  if ($detect->isMobile() || $detect->isTablet()) {
    drupal_goto('http://testsite.local');
  }
}


texts: Need a more specific price calculation rule in Drupal Commerce

texts:
I have a price calculation rule like this:

Event: Calculating the sell price of a product

Conditions: Order contains products of particular product types AND User has roles

Actions: Multiply the unit price by some amount

Now, the problem is that when the cart contains products of the type that I selected as a condition AND the user has a specific role, the multiplication in the Action element is executed also on products of other product types. I only want to affect the prices of products with a specific type.

The cart can contain a mix of products of different types, but the rule should only affect the line items with the specific type.

How do I do that?


texts: Multiple Arguments for Views for Contextual

texts:
I have a special path_alias for my content in the form of /profiles/username/1234.

When a user goes to /profiles/username it goes to one view. Usernames are a taxonomy vocabulary
- That view has a path as /profiles/% and I validate that argument against the term id.

When a user goes to /profiles/username/1234, I would like it to go to a special view just for that node.
- I tried doing /profiles/%/%, and created two contextual views - one similar to the first view for profiles but having "Provide default value" and "Raw value from URL" and path component 2 (for /profiles/%); 2nd contextual view was same format, but with path component 3 (for /profiles/%/%) and that validating to Content, my content type, and filter value format as "Node ID"

Doesn't seem to override the normal node display with my view.

Any advice would be super helpful thanks!


texts: Request an Ajax form through Ajax [solved]

texts:
I want to load a form through Ajax in a custom Javascript Event as it is explained in this tutorial. I receive the form, but its ajaxified behaviour is very strange.

My Javascript:

var address = $(location).attr('protocol') + '//' + $(location).attr('hostname');
var url_get_button = address + 'mymodule/get_button/';

Drupal.ajax.prototype.specifiedResponse = function() {
  var ajax = this;
  try {
    $.ajax(ajax.options);
  }
  catch (err) {
    return false;
  }
  return false;
};

var ajax_settings = {};
ajax_settings.event = 'onload';
ajax_settings.keypress = false;
ajax_settings.prevent = false;
ajax_settings.url = url_get_button;
Drupal.ajax['get_button'] = new Drupal.ajax(
  null, $(document.body), ajax_settings);

//the following is somewhere at the right js event...
Drupal.ajax['get_button'].specifiedResponse();

My php code:

function mymodule_menu() {
  $items['mymodule/get_button'] = array(
    'page callback' => 'mymodule_send_button',
    'type' => MENU_CALLBACK,
    'access callback' => 'user_is_logged_in',
  );
  $items['mymodule/next_ajax'] = array(
    'page callback' => 'mymodule_next',
    'type' => MENU_CALLBACK,
    'access callback' => 'user_is_logged_in',
  );
}

function mymodule_get_form ($form, &$form_state) {
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#ajax' => array(
      'event' => 'click',
      'path' => 'mymodule/next_ajax/',
      'effect' => 'fade',
    ),
  );
  return $form;
}

function mymodule_send_button() {
  $form = drupal_get_form('mymodule_get_form');
  $form = ajax_pre_render_element($form);

  $commands = array();
  $commands[] = ajax_command_replace('#replace-this', render($form));
  $commands[] = ajax_command_invoke(NULL, "some_js");

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

function mymodule_next() {
  commands = array();
  $commands[] = ajax_command_alert('works!');
  $message = array('#type' => 'ajax', '#commands' => $commands);
  ajax_deliver($message);
}

function mymodule_node_view() {
  drupal_add_library('system', 'drupal.ajax');
  drupal_add_library('system', 'jquery.form');
}

Well, if Drupal.ajax['get_button'].specifiedResponse();is called in the Javascript event, the button will be loaded, but if I click on the button, the page is reloaded with url_get_button (which was used to request the button) instead of getting the alert window with 'works!'.

But if I add another form builder function and call this function with drupal_get_form() within the hook_node_view() (without returning anything!!), it will work.

So I add:

function mymodule_get_another_form ($form, &$form_state) {
  //I have to add the following line in order that it works
  $form2['submit'] = array();
  return $form2;
}

and change my hook_node_view() to:

function mymodule_node_view() {
  drupal_add_library('system', 'drupal.ajax');
  drupal_add_library('system', 'jquery.form');
  $form2 = drupal_get_form('mymodule_get_another_form');
  //I don't return $form2...
}

Well, in summary: I want to request an ajaxified button through a custom Javascript event. I receive the button, but it is not ajaxified and on top the wrong url is linked. But if i call drupal_get_form() with another 'empty' form builder function during the page load, it will work and I will get the alert message after clicking on the button.

I use Drupal 7.

Does anyone have an advice for me? Why isn't it working without the second form builder function and why does it work with it?

I would welcome every advice.
Thank's a lot.

Daniel


texts: How can I insert a comment form into my view?

texts:
In Drupal 7, I'm building a module that has a view page that lists all nodes of a certain type. I want users to be able to comment on each node in the view from this view page.

I tried using hook_node_view but it only seems to apply to the full node page view. What kind of hook do I need to get the comment form of a node in a view?


texts: Multiple page versions and caching for anonymous users

texts:
Is there a standard, or well accepted, method for allowing page caching when you have multiple versions of page, that don't involve using Page Manager?

For example, if you render out different versions of a page based on IP address, User-Agent, etc., page caching renders the code-based decisions useless, so some users may see the wrong pages.

The only method that I know about involves adding code to settings.php to alter $_SERVER['REQUEST_URI'] to make the code-based decision and then to tack on extra variables, but gets messy.


texts: Views page menu shows up on all languages

texts: I am working on a old website built on Drupal 6 which has two languages. There is a views on which I created a page for each language, but their menus shows up on both languages. I tried different combinations of relationships, arguments and filters, which works on the content but not on the menus. How can I force a views page menu to display only on the correct language?


texts: How do i attach a an element to user account?

texts:
I have added a custom form element in login form. I need to link this new element to user account on logging in.

I need to add and get entry to the table "users_data" in Drupal 8.
This can be done by defining a class EmployeeDetails and then fetch the value like this :

$employee_details = new EmployeeDetails($account);
$employee_details->setEmployeeNumber($value);

My Question is in which file should i define EmployeeDetails class? What should be file name, should i use .inc extension and where in the module should be this file placed?


texts: How can I use UUID in a Views relationship?

texts:
Two content types: subscriptions and sites. Each site belongs to a subscription. I use the UUID module, since subscriptions and sites are synced from websites elsewhere. Each site has a field_subscription_uuid field to identify the subscription it belongs to. There can be multiple sites on each subscription.

I want to make a view that lists sites alongside some of the data from their subscription. I thought I would use the Equi Join module to relate a site's field_subscription_uuid to a subscription's uuid. However, Equi Join only lists custom fields (and body), not UUID.

Although I could create a new custom field for subscriptions and sync its own UUID to that field to make it visible to Equi Join, I would rather not because it would be redundant (since the UUID is already a column in the node table).

So I think I have to write a views relationship handler in order to bring a node's uuid into the scope of Views relationships, but I don't know where to start and the API documentation has only confused me more.

How can use a specific node type's UUID in a views relationship without storing the UUID in a custom field?


texts: Calculate percentage based on two fields, one of which is an embedded view

texts:
I am trying to calculate a percentage based on two fields in my table. I am using views and I have a table which has 2 fields, one field is an aggregation of of all records and the other is an embedded view which has another number - I used the Views Field View module for embedding the field.

How can i get a percentage between these 2 fields. The Math Expression field is not supported in drupal 8 and I have also tried the views_simple_math_field and it didn't help me at all. Please help!


texts: Translated node does not use translated entity reference, how to fix this?

texts:
So I have 2 translatable content types: event and artist.
I've also created an English artist and his French translation.

I now create an English event and link my English artist to it through Entity References. If I now translate my English event to French, my French event will have a reference field with my English artist instead of my French artist...

How can I solve this problem?

I want it to try to fetch the translated reference and if it does not exist, I want to entity referenced field to stay empty.


texts: Node Gallery not using administration theme for its custom tabs

texts:
I'm using a very minimal custom theme for the website, but Bartik for administration.

Node Gallery plugin adds tabs to the Edit Node page (e.g. node/46/edit): "Manage Items", "Sort items" and "Upload new items". When I click on them, the custom theme is used instead of Bartik. I suspect this is because these pages weren't properly flagged as admin pages, or something like that.

How can I make Node Gallery use administration theme for its custom tabs?


texts: How do I programmatically set cache age?

texts:
Drupal 8:

I have the code for a block successfully doing its work and returning it. The block is called "RacerProfile" and it dumps all its content into variable "$pageContent". At the very end it returns the #markup. Ok. Now how do I tell this to invalidate every six hours?

/**
 * Provides a 'Racer Profile' Block
 *
 * @Block(
 *   id = "racer_profile",
 *   admin_label = @Translation("Slider v1 block")
 * )
 */
class RacerProfile extends BlockBase {
  /**
   * {@inheritdoc}
   */
  public function build()
    {
    // does all the work to make $pageContent via non-drupal database queries
    return array('#markup' => $this->t($pageContent),  );
    }
 }

In other Drupal answers, I've seen "D8 has cache tags and contexts that will automatically invalidate the block if something changes." Ok, my code is checking a second database. There's no way for Drupal to know what's changing over there. (Without checking, obviously.) So how do I add cache tags with specified timeouts? I can't find examples.

Notes:

-Obviously, this is not related to the Maximum Cache age within the admin area of Configuration > Performance > Caching > Page cache maximum age. I don't want this to apply to the entire site, just this block.

-Obviously, this is not related to settings.php in any way either, since again I don't want to have this apply to the entire site, and the various modules will have different timeout requirements.

-The traffic for the site is relatively low volume, so if rendering a thing four times a day even it only needs to be done once a day isn't a problem. Every six hours means that it's changed before people wake up across four time zones. Mostly. ;)

-(edit addition) The block needs to have its cache controlled for anonymous users.


texts: Need to add a JS file into  using a custom module with custom twig template

texts:
I have created a custom module and created a config page which we need to input the url on that page.

Created a twig template within my custom module:

<script src={{ js_file_url }}>test</script>

In my .module file

<?php

/**
 * @file
 * Add the url to the header section.
 */

/**
 * Implments hook_page_attachments_alter().
 */
function custom_module_page_attachments_alter(array &$attachments) {

  $js_file_url = \Drupal::config(' custom_module.settings')->get('url');

  $renderable = [
    '#theme' => 'my_template',
    '#test_var' => 'test variable',
  ];

$attachments['#attached']['html_head'][] = [
    [
      '#theme'  => 'my_template',
      '#js_file_url'   => $js_file_url,
    ],
  ];

}

function  custom_module_theme($existing, $type, $theme, $path) {
  return [
    'my_template' => [
      'variables' => ['js_file_url' => NULL],
    ],
  ];
}

My output:

<><script src=http://google.com>test</script></>

Expected Output is

<script src=http://google.com>test</script>

How to get rid of empty tags =>  <>,

By default $attachments['#attached']['html_head'][] is adding the '#tag' even if i dont declare it.

Can someone help me, please.


texts: Join a table through a field attached to entity

texts:
I'm working on a site that has a Field created through the Field API on the user that defines what district the user is in. The field stores the ID of the district, which is a custom entity in the district table.

In the admin/people view, I need to display the district's name. I can do this if the user would have the district_id on its table. But I can't figure out how to get the district name (from the district table) in the view if the district_id is on a field associated with the user.

This is similar to Views joining/relating a custom table entity to users through a field? but I need to do the opposite. The field is on the user and I need to grab district table values.


texts:
By mistake I deleted a translation item instead o editing it in admin/config/regional/translate/translate, and now it seems to be gone. Is there any way to get it back to the list of translatable fields?

Cheers
/bo


texts: Load all nodes from content type on front page without views

texts:
I want to create a one-page website. What I hope to be able to do is load all the created pages from one content type under each other, prefably in a for each loop.

So in page.tpl.php it would be something like:

foreach($pages as $page){
    print $title;
    print render($page['content']);
}

This way I could also bind views/blocks to certain pieces of the page. The reason I'm looking for this kind of approach is to keep the website manageable.

The structure would be as follows:

home
about
 - slide one (view)
 - slide two (view)
 - slide three (view)
other page
 - slide one (view)
 - slide two (view)

So the mentioned slides are items from a different content type, loaded from a view.

If someone can point me in the right direction, or if some pieces of the question need clearing up, please let me know.

If people are still interested in this, I will give my solution here:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->propertyCondition('status', 1) /* Status to make sure it is published */
  ->propertyCondition('type', array('page', 'webform')) /* get pages and webforms */
  ->fieldOrderBy('field_volgorde', 'value', 'ASC') /* a custom field to set the order */
  ->range(0, 9999); /* amount of pages to get */
$result = $query->execute();
$nodes = node_load_multiple(array_keys($result['node']));

foreach($nodes as $node):
    // Do your code magic
endforeach;

Within the foreach, fields can be echoed by using the following code examples:

echo $node->title;
echo $node->body['und'][0]['value'];
// ['und'] = language undefined

If there are any questions, feel free to let me know.


texts: How do I enable editing the body of a block?

texts:
I have a block (in Drupal 7) with information in the body of it.

I want a specific user to be able to edit that information.

After assigning that user Administer blocks and Contextual links permissions the user can edit everything except the body and the following message shows:

Is there any way to enable the field for that user?


texts:
I just want to send address information to drupal for check content existence through the AJAX.

Request is sending successfully and callback function also executing.
but I am not getting any data in $_POST array.

here is my AJAX code.

    var address = [{'add1':'address line1','add2':'address line2','add3':'address line3'}]
    $.ajax({
            url: Drupal.settings.property_check.base_url + '/search/property-by-address',
            type: 'POST',
            data: JSON.stringify(address),
            headers:{
              'Content-Type': undefined,
            }
        })
        .done(function(response) {
            console.log(response);
        })

This is callback routing & function

  $items['search/property-by-address'] = array(
     'title' => 'property by address',
     'page callback' => 'search_property_by_address',
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );

  return $items;

function search_property_by_address(){
  drupal_json_output($_POST);

}

At where I am making mistake? is there any other way? Or is there any problem with headers?


texts: Prompt registration based on number of free articles read

texts:
When an anonymous user reads 3 free articles, the system should prompt them that they have reach the limit of free articles, and they now need to register to read more.
How can i achieve this. I have just started writing modules. Any help would be beneficial. Thanks in advance


texts: Inline css is not working in ck editor full html

texts:
I have installed updated version of the CKEditor - WYSIWYG HTML editor module with CK editor library.

Every time I put inline css in my HTML full editor, it vanished.

I have searched the web for it, but not found proper solution.

Anybody any suggestions about this?


texts: Any way to add something similar to Olark or Zopim

texts: Olark and Zopim are live chat services. Is there any module to add this feature to a Drupal site? I took a look to 'chat room' module but it is not what I need.


texts:
Normally View Bulk Operation (VBO) will lead to separate page for asking details and performing actions.

Is there any module readily available to show pop-up for views bulk operations. Searches did not help.


texts: How to add pagination (pager) to field collection module?

texts:
How to add pager to the content created by the Field collection module?

I tried to achieve it with the Views module but Views takes the whole field collection content as single item, so it is not feasible.

I tried the Smart Paging module, but smart pager is for breaking one single content in many, so it is also not applicable.


texts: Block display using wildcard, non-greedy

texts:
I have a block that I have configured to display "Only on the listed pages"

commerce_store/store/*

The problem is, it displays not only on the view link, which I want it to, but on the edit and other menu tabs

commerce_store/store/1        <-- good
commerce_store/store/1/edit   <-- bad
commerce_store/store/1/sales  <-- bad

I've tried switching to PHP code, but this doesn't seem to have any effect whatsoever. I've even changed the code to var_dump($path); exit; and it doesn't exit.

Edit: This code works, just enclose it in <?php and ?>

$path = current_path();
$url_parts = explode('/', $path);
if( $url_parts[0] == 'commerce_store' && $url_parts[1] == 'store' && count($url_parts) == 3 ) {
  return TRUE;
}


texts: I need to find where the field label for a content type is stored within the database. I tried the field_config_instance, it's not there.


texts: How to add a "Last Updated at" field in footer area?

texts:
I wanted to add a field in my website (in footer area), which can automatically display the "last updated" date.

I found the same question in SO but it is not working properly. While accessing some pages, I can see this field as blank with follow errors-

Notice: Undefined variable: node in include() (line 207 of O:\xampp\htdocs\rutag\sites\all\themes\skeletontheme\templates\page.tpl.php).
Notice: Trying to get property of non-object in include() (line 207 of O:\xampp\htdocs\rutag\sites\all\themes\skeletontheme\templates\page.tpl.php).

By saying "Last Updated at", I mean to say that the last date on which admin has updated (published/modified any content) the website.


texts: Can IMCE or elFinder be used to insert Media tags instead of ?

texts:
Is it in any possible way to get a file browser like elFinder or IMCE to insert the Media tags supported by the Media module.

e.g.

[
  [
    {"type":"media","view_mode":"media_original","fid":"4","attributes":
      {"alt":"","class":"media-image","height":"35","style":"float: right;","typeof":"foaf:Image","width":"33"}
    }
  ]
]

Instead of having insert image tags?


texts:
I want to create a simple websites listing. I have created a content type named Sites and a taxonomy vocab named Sites to handle Sites nodes categorization. i.e every Site node (a content of type Sites) belongs to one term under Sites taxonomy vocab.

In the Views module, I have created a new Page view which has the path /sites-cats-listing and it shows Taxonomy terms of type Sites. The format is Unformatted list and it is only has one field Taxonomy term: Name

It renders a simple list of Taxonomy vocab Sites terms as expected. However, I want to list all of sites titles that belongs to each taxonomy term, so, I will get two levels list something like the following example:

-term1
--Site1
--Site2
--Site3
-term2
--Site4
--SiteA
etc...

Also I need to be able to rewrite the site's title field to make it linked directly to the destination website.

So, I need to know is there any way to attach a block to field which the block takes its contextual filter from the field value? Or is there any other workaround to complete this task? I have tried EVA but I could not able to find what I want to get.


texts: How to delete all duplicate node with the same field value in drupal type

texts:
I need to bulk delete the duplicate nodes based on the same field and keep just one node.

How can I do that ?

I tried that :

$query = \Drupal::entityQuery('node')->condition('type', "diffusion");
$query->groupBy('field_id_diffusion');
//$query->having('COUNT(field_id_diffusion) >= 1');
$duplicate = $query->execute();


texts: How can I block an abusive person who endlessly tries to register more accounts?

texts:
I have a free site with open registration; anyone can register and I am not able to change that.  However, accounts must be approved by an administrator after completing a profile, so I have access to a variety of info to identify duplicate users (date of birth, "self introduction" comment, email address, photos, reported location in profile, geolocated IP, IP address, etc.)

Recently the site has become subject to the attacks of a single user who is extremely abusive and seems to have unlimited time to register multiple accounts.  These accounts can be blocked relatively easily, but it's a lot of work for the administrator (me) and I'm afraid I will miss one among the legitimate accounts (this user registers about 6 accounts per day).

I have already:

banned the user's known IP addresses
blocked registration from known domains that are used for "disposable" email addresses
added a special view to help me identify accounts based on known patterns of access from the user

Is there anything I can do with cookies, etc. to make it even more difficult for this user to register?

This is a Drupal 7 site.

EDIT: In my case, this is a human user, not a bot.  But the bot answers are useful for those who are being specifically targeted by spammers.


texts:
Looking for a way to export menu configuration. The Configuration management system will export the menu itself, but not the menu links configuration. I am looking for a way to put one of those mega menus into version control to import/export through multiple environments.

If anyone has found a good way to do this. I would be greatly appreciative.


texts: What exactly is "Overridden", "Needs review" & "Revert component" in Features?

texts:
I can see Overridden, Needs review & Revert component in Features.

If I want to get latest updated features always, what I will do?

What drush fr, drush fu will do internally?

What I understood is, overridden is the state where our current config/settings changed with new features. If we do revert component, all the new changes will be reflected. So here what is the drush command shall I use?.

Anyone can explain all these three?


texts: Facet filter in Views wrongly returns "No results"

texts:
I'm running into a strange behavior with Search API and Facets API, and I hope someone can point what I'm doing wrong.

I am working in Drupal 7 with Views, Search API, Database Search (search_api_db), Facets API, and Search Facets (search_api_facetapi). My view is working fine otherwise: exposed filters and facet filters work fine in isolation.

The problem happens when I search using an exposed filter, and then try to narrow it with a facet filter.

First step: I search using a exposed filter (see image 1). I get 606 results which display fine.

Then I try to narrow clicking "2" in the facet "Filter by level". The field level is an Integer, and is indexed by Search API as an Integer. Weirdly, I supposedly get 33 results (the View says "Displaying 1 - 20 of 33") but NOTHING gets displayed in the View body (the View says "No results"). Still, the pager at the bottom correctly indicates that there are 2 pages.

Any help will be appreciated.

PS: The field "Composer" is indexed as Fullsearch.


texts: How to create a block to show a digital clock?

texts:
I need to create a block to show a LIVE digital clock?

I tried to use the http://drupal.org/project/clock and the http://drupal.org/project/jstimer  modules but it doesn't use javascript to refresh the time, it shows the time when the page is load, to refresh the time I need to reload the page.

How can I do this?

Something like this http://drupal.org/project/timeblock but for D7


texts: "Drupal already installed" Message on Restored site

texts:
We had an issue on a Drupal 8.8.2 site, had to restore DB, Core and Vendor, now anyone visiting the site gets the site as normal, but if admin logs in I receive:

Drupal 8.8.2
Drupal already installed
- To start over, you must empty your existing database and copy default.settings.php over settings.php.
- To upgrade an existing installation, proceed to the update script.
- View your existing site.

Of note:
Rather then restore over existing db I created a db2, restored the DB to it and pointed the settings to it (not sure if that is the issue)

I can't figure out how to stop that page from loading. I don't want to start over, running the update script does nothing but bring me back to the same page. View your existing site does take me to site but can't edit anything (looks like it just logs me out).


texts:
It seems like Drupal is ignoring check_markup(). What is wrong with the code below?

print check_markup($node->body, 'microblog', TRUE);

Site's default input format filter is = 'Filtered HTML'. All users have access to the 'microblog' filter, but I see my 'microblog' filter is kind of not working, and it uses filtered HTML.

What am I doing wrong?


texts: Sticky Navigation 8.x-1.1. Funny padding-top

texts:
In in Drupal 8.5 Theme Bartik and using the Sticky Navigation 8.x-1.1.
When by any chance I reload a page of my site and at that moment I’m positioned in the middle of that page and the menu is “sticky”,  the module add a padding-top equal to the height of the sticky menu bar to the tag Body (as an inline styling). If you go up to the top of the page, after reloading, there is a white strip at the very top of the page (originated by the padding top). Can some tell me how to fix it?


texts: Letting only user #1 pass all the validations of required fields when saving content

texts: Is there any way I can let the user #1 save the content of some content type without validating required fields?


texts: How to filter a view when day, month and year are separate fields

texts:
I am trying to filter a view to show content that happened today on this day in previous years.

We have day, month and year fields but they are not dates.

How can I filter on day = today's day and month = today's month without converting them to date fields.

Current fields are:

Day - integer
Month - List (integer)
Year - integer


texts: Adding extra fields to Site Contact Form

texts: This seems strangely difficult to me. What I thought would just be a case of adding extra fields a bit like adding fields to Content Types. But no. I can't locate any facility to add say a phone number field to the Contact form? Anyone out there know?


texts:
Is there a way to convert Flags links into check boxes within a view? I tried the Flag Form module, but it did not work (at least not in a view). I've reviewed the Flags Add Checkboxes as Display Type feature request. The discussion points to using CSS, JavaScript, or hacking the flags template file. Are there any other methods?

I'm not adverse to using JavaScript to do this, but I know little about it.


texts:
I wrote db_query in two ways, I followed the drupal documentation to write safe db_query, one of them doesn't work, I want to know what I'm doing wrong in the code below.

// Worked perfectly
function custom_get_user_account_id() {
  global $user;
  return db_query("SELECT `field_account_target_id` FROM {field_data_field_account} where `entity_id`=:user_id and `bundle` = 'user'", array('user_id' => $user->uid))->fetchField();
}

// doesn't work
function custom_get_user_account_id() {
  global $user;
  return db_query("SELECT field_account_target_id FROM {field_data_field_account} fa where 'fa.entity_id = :user_id and fa.bundle = :user' ", array(':user_id' => $user->uid, ':user' => 'user'))->fetchField();
}


texts: How to give a path to a link with filter?

texts:
I am trying to give a path to a submenu with Filter(field) as

my-view&field_subject=C

but it shows error like 'path is either invalid or you do not have access to it.'

when i give 'my-view' it works perfectly.

But i want to show the view with 'Subject' column with Value C only.


texts: PCI compliance with authorize.net payment- Drupal7.x

texts:
I am looking for a solution where I can collect simple payments from my users but not collect the payment details on drupal server. SO i need to

Attach a payment component to a webform
User can fill up the details and click on pay
On clicking on pay user will be redirected to Authorize.net servers where the user can fill the details and on successful completion return back to Drupal end.

I am using webform_pay module to achieve this. It satisfies most of the points but only problem with this module is it collects the payment details on drupal server which I dont want.
Any suggestion?


texts: Drupal commerce update to 1.14 from 1.13 - breaks checkout screen

texts:
I have also a different problem with commerce update with latest 1.14 version. After update via drush, order created and it reached checkout:shipping step, but when I do final order confirmation step, it stuck at payment page [checkout:payment] step, it shows blank page, actually I've skipped the checkout payment step on my previous 1.13 version and it worked fine.

what will be the issue? how to track drupal page and functions execution?


texts:
I have put a site in maintenance mode. Before I could visit the administration pages as user #1 (which was the user account I was already using before to put the site in maintenance mode), I had to reset the computer; when I tried to visit the administration pages, Drupal didn't give me access to those pages.
I cannot change the content of the settings.php file because the installer tool that I used from the control panel for the domain probably created the files using credentials different from the ones I use to connect through FTP, which is the only way I have to upload files to the server, or change them.

Apart re-installing the Drupal files manually (and in a different directory), what can I do to access the administrative pages?


texts:
Is there a way to add fieldsets inside of a custom composite? Not looking to add anything repeatable, just simply group the fields together.

This get's the fieldset to show but I don't know how to add fields as children.

$elements['grouped_fields'] = [
  '#type' => 'fieldset',
  '#title' => t('Grouped Fields')
];


texts: How to hide roles from user_profil_form while keeping value?

texts:
After loading user_profil_form form, I tried to hide the roles fields.
It worked fine, however after submitting the form, my user roles are removed and it's only linked to "authenticated user".

Is there a way hide this field but keeping the value ? I would not like to user the alter hook in order to keep the full form in the admin pages.

Thank you


texts: Manage Display of Entity Reference Field: How to link to nodes instead of plain-text?

texts:
I've got two Content-Types: Releases, and Scenes.

Releases contain Scenes as Entity reference fields.  I would like to link to the Scene Nodes rather than what the current options allow.  At the moment my only options for Format under Manage Display are:

Label
Entity Id
Rendered Entity.

These Display:

Plain-Text Name of Entity
Entity Id #
Renders Scene Nodes within Release Node

How can I make Drupal render a link to the Scene Nodes that have been selected in Entity reference fields?

Or, as an alternative, is it possible to display a Teaser instead of rendering the full Scene Node within the Release Node when using "Rendered Entity"?


texts: Build custom module with similar maintenance mode behaviour

texts:
I'm building a custom module that denies access to the site based on some custom rule.

I;ve already build the module form, variables get stored, in hook_init I do my check against the variables I set on my custom module.

What I would like to do now is to have a template behaviour like the maintenance mode one.

By default it should be a blank page with Site name and message like maintenance mode(maybe overriding html.tpl.php). The default mymodule-page.tpl.php should leave in mymodule/templates/

This page can be overridden in theme folder so the user can apply its own style, logo, region etc...

function my_custom_module_menu{
  $items['my-custom-module-page'] = array(
    'title' => t('My custom module  title'),
    'page callback' => 'my_custom_module_page_callback',
    'type' => MENU_CALLBACK,
  );
}

function my_custom_module_theme($existing, $type, $theme, $path) {
  return array(
    'my_custom_module_template' => array(
      'template' => 'my-custom-module-template',
      'variables' => array('variable' => NULL),
    ),
  );
}

function my_custom_module_page_callback() {
  return theme('my_custom_module_template');
}

The code above keeps the layout of the page but I would like to override the entire page.

Which hooks should I use to achieve this?
How can I call this template from my hook_init?

Thanks in advance.


texts: Force Drupal to attach Drupal behavior to new ajaxed content [only Drupal.attachBehaviors() is not working the right way]

texts:
I was doing lot of posts on drupal.org about this topic, but unfortunately in the wrong context.

Ajaxed content is not attaching needed JS and CSS (forum)
Ajaxed content is not attaching needed JS and CSS (issue)

I think that is not the problem, so i try it with a different approach, and maybe this could be the solution. Loading the whole PHP Page and extract a certain div with ajax didn't works the right way. So i thought, that i could let drupal load just the content and inject it with ajax into the div. I made a query with the hook_preprocess_page and hook_preprocess_node that is looking for a "ajax=1" in the requested URL and then only gives out the content without the whole page. And now with help of certain tpl.php files, in theory, i could limit the output of drupal to only $content. And here is the problem. My approach is working even when i leave the tpl.php files the original way, but removing the "$content" from node-ajax.tpl.php. With "working the right way", i mean that drupal doesn't reload the whole page, but off course not the content. But i can not explain that to myself, cause in the $content variable, so i thought, is only the html of the generated content. So my question is, how can i limit the output of drupal, to just the content, or am i doing the wrong steps to get this working. Here is the module and js file i'm using: my_ajax.module:

<?php

function my_ajax_init()
{
    drupal_add_js(drupal_get_path('module', 'my_ajax') . '/my_ajax.js');
}

function my_ajax_preprocess_page(&$vars, $hook)
{

    if (isset($_GET['ajax']) && $_GET['ajax'] == 1)
    {
        $vars['template_file'] = 'page-ajax';
    }
}

function my_ajax_preprocess_node(&$vars, $hook)
{

    if (isset($_GET['ajax']) && $_GET['ajax'] == 1)
    {
        $vars['template_file'] = 'node-ajax';
    }
}

my_ajax.js:

Drupal.behaviors.my_ajax = function (context) {
    $('#content-group-inner .node a').live('click', function (e) {
        var url = $(this).attr('href');
        //$('#content-region-inner').slideUp('slow');
        $('#content-region-inner').empty().html('<img src="ajax-loader.gif" style="margin-left:50%;"/>');
        xhr = $.ajax({
            data: 'ajax=1',
            type: 'GET',
            url: url,
            success: function (data) {
                $('#content-region-inner').html(data);
                Drupal.attachBehaviors(context);
            }
        });
        return false;
    });
};

Please help me with this. Every suggestion is appreciated.


texts: How to render a field of a taxonomy term inside a view template?

texts:
I'm trying to display an image as a banner above the items of a view (which creates a block). The image is a field associated to a taxonomy term and the view is used to display all items which have this term. Is it possible to inject the image into the render array using a hook in order to access and render it on a specific location inside the view's template (for example block--views-block--example.html.twig)? I can't find a good solution anywhere on the web. I'm thinking of something like this (pseudo code):
function suitable_hook(&$vars) {
  $image = getFieldOfTaxonomyTerm('taxonomy_term', 'image_field_name');
  $vars['associated_image'] = $image;
}

If there are better approaches to this problem in general, please let me know as well. Thanks a lot in advance for your suggestions!


texts: Setting field value's according to user input in a custom form?

texts:
Possible Duplicate:
  Setting field value’s according to user input in a custom form?

i am using drupal 7 FAPI to create nodes through a custom form. the code below creates the nodes and assign them with a title and a body, so if i wanted static field values everything was perfect. my problem is, i want the value of $body_text to be determined by the user's input in the "order" textfield. i tried doing something like -

$body_text = $form['name'];

but that didn't work.

this is the code i'm using -

<?php
function nodeform_menu() {
  $items = array();
  $items['nodeform/form'] = array(
    'title' => t('My form'),
    'page callback' => 'nodeform_form',
    'access arguments' => array('access content'),
    'description' => t('My form'),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function nodeform_form() {
  return drupal_get_form('nodeform_my_form');

}

function nodeform_my_form($form, &$form_state) {

  $form['box'] = array(
    '#type' => 'markup',
    '#prefix' => '
',
    '#suffix' => '
',
    '#markup' => '
Initial markup for box
',
  );

    $form['order'] = array(
    '#type' => 'textfield',
    '#title' => t('My order'),
    '#default_value' => 'Products',
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#ajax' => array(
      'callback' => 'ajax_example_submit_driven_callback',
      'wrapper' => 'box',
      'name' => 'submit1',
    ),
    '#value' => t('Submit'),
  );

$body_text = $form['order'];
$node = new StdClass();
$node->type = 'page';
$node->status = 1;
$node->title = "name";
  $node->language = LANGUAGE_NONE;
  $node->body[$node->language][0]['value']   = $body_text;
  $node->language = LANGUAGE_NONE;

node_save($node);
  return $form;
}

can anyone help me understand how to do this? i tried googling and reading the FAPI guide's but couldn't figure it out... plus, this is the first time i am using FAPI so in-spite the code is working, if anyone have any insights on this code (such as coding it more properly) i would also very appreciate that. thanks a lot!


texts: How to make the date field of authoring information in Create Article page a date field?

texts: In the page to create new article, at the bottom in the authored on tab, how do I make the date textbox to a date field with date picker? I mean, I want it to be easy for the publisher to choose custom date.


texts: How to schedule content every Wednesday at 18.00 (6 PM)?

texts:
Looking for something which was easy in Drupal 7, but can't find it or can't get it to work in Drupal 8.

import feed
do not publish content immediately
run a rule that sets the content to publish every Wednesday at 18.00 (6 PM)

Any suggestions how to do this in Drupal 8?

I've tried:

https://www.drupal.org/project/scheduled_publish
https://www.drupal.org/project/scheduled_updates
https://www.drupal.org/project/moderation_scheduler
https://www.drupal.org/project/scheduler
https://www.drupal.org/project/business_rules
https://www.drupal.org/project/rules (seemed obvious I already tried that)
and other stuff that I already forgot since I've been trying this for
several weeks now ...

And only Scheduler came close (as I used it in Drupal 7).

Where does it fail?
When making the rule (after saving new content ...):

it does not allow me to use 'wednesday 18:00' but instead I need to
use a 'unix timestamp', which means I need to change it every week
and even if I use a 'unix timestamp' the 'schedule options' tab stays
blank (if I insert a date when manually creating the content it
works)

After testing the business rules module for two days I'm starting to suspect the problem is Drupal itself: it's simply not excepting anything except unix timestamps.

I tried making a field with php code to calculate 'wednesday 18:00', tried it with strotime, ... all to no avail. I have some hope this could still work, but my coding skills are to limited.

So ... any other options? (I'm not a developer, can't build custom modules.)


texts:
I need to add rel=canonical meta tags to some views. There are a couple of sandbox modules for the metatag module but I'm looking for a more simple solution.

Couldn't I just use views_php and drupal_add_html_head()?


texts:
I have two categories and each one has subcategories. I put the parent categories in a menu. What I need is: when I click a parent category its subcategories should be shown in a new page.

How I should that? I'm using Drupal 7.


texts: Is it acceptable to change the vid column of a term programmatically in the database?

texts:
I need to move some terms from one vocabulary to another by retaining all their data: translations, aliases, and node references.

Is it acceptable to change its vid column value directly in the database? The terms don't have hierarchy relationships which needs to be handled.


texts: User's Domain Roles not recognized by Views

texts:
We have upgraded our Drupal platform from 7.32 to 7.41, and upgraded Domain Access from 3.9 to 3.12.

After the upgrade our Views that evaluate user's domain roles are not returning any role for the logged in user (not even "authenticated user"), but if I add a PHP field and print_r($user), then all the roles are displayed.

If I edit the user and assign a role, then the View evaluates correctly, but we need the roles applied per domain and not per user.

Any suggestions?


texts: How can you print the field class you entered in a View 's style settings?

texts:
So in Views you can add a CSS class (under style settings) to your field.
I need to print the same class in a parent div of the calendar module.

The fields are rendered to calendar content with the calendar-item.tpl.php
That file looks like this:

$index = 0;
?>
<div class="<?php print !empty($item->class) ? $item->class : 'item'; ?>">
  <div class="view-item view-item-<?php print $view->name ?>">
  <div class="calendar <?php print $item->granularity; ?>view">
    <?php print theme('calendar_stripe_stripe', array('item' => $item)); ?>
    <div class="<?php print $item->date_id ?> contents">
      <?php foreach ($rendered_fields as $field): ?>
        <?php if ($index++ == 0 && (isset($item->continuation) && $item->continuation)) : ?>

&laquo;

        <?php endif;?>
        <?php print $field; ?>
      <?php endforeach; ?>

    <?php if (isset($item->continues) && $item->continues) : ?>

&raquo;

    <?php else : ?>

&nbsp;

    <?php endif;?>

So I need to get that class in the first DIV

<div class="<?php print !empty($item->class) ? $item->class : 'item' . ENTER-FIELDCLASS-HERE; ?>">

I've been looking in the VIEWS module and the code taht checks if you entered a CSS class should be this part in the THEME.inc file:

if ($classes = $object->handler->element_classes($view->row_index)) {
          if ($class) {
            $class .= ' ';
          }
          $class .=  $classes;
        }

A more complete part:

$previous_inline = FALSE;
  $vars['fields'] = array(); // ensure it's at least an empty array.
  foreach ($view->field as $id => $field) {
    // render this even if set to exclude so it can be used elsewhere.
    $field_output = $view->style_plugin->get_field($view->row_index, $id);
    $empty = $field->is_value_empty($field_output, $field->options['empty_zero']);
    if (empty($field->options['exclude']) && (!$empty || (empty($field->options['hide_empty']) && empty($vars['options']['hide_empty'])))) {
      $object = new stdClass();
      $object->handler = &$view->field[$id];
      $object->inline = !empty($vars['options']['inline'][$id]);

      $object->element_type = $object->handler->element_type(TRUE, !$vars['options']['default_field_elements'], $object->inline);
      if ($object->element_type) {
        $class = '';
        if ($object->handler->options['element_default_classes']) {
          $class = 'field-content';
        }

        if ($classes = $object->handler->element_classes($view->row_index)) {
          if ($class) {
            $class .= ' ';
          }
          $class .=  $classes;
        }

        $pre = '<' . $object->element_type;
        if ($class) {
          $pre .= ' class="' . $class . '"';
        }
        $field_output = $pre . '>' . $field_output . '</' . $object->element_type . '>';
      }

Not the most clear code to me.
It can't be that hard. If only something like $field->class would work!

Thanks in advance!


texts: Remove terms from taxonomy vocabulary for node type

texts:
I have two node types that share a taxonomy vocabulary. I'll call them type1 and type2. type2 uses two terms from the vocabulary that type1 does not. Both type1 and type2 have views that allow filtering by the taxonomy terms. I need to have the two terms that type2 uses not show in the view for type1. Any ideas?

[EDIT]
The terms are in a dropdown menu.


texts: How to exclude items from search api solr by negative keywords field

texts:
Drupal 8, Search API SOLR.

I'd like to not return nodes if there are any matches between a field of negative keywords (on the node) and the query string the user has entered.

Module search_api_solr currently set up with several fields, matching in node titles, body and keyword fields.

e.g.
node titled "I can't find my elephant" with a negative keyword field containing "wallet" to not show up in a search "I can't find my wallet".


texts: How do I not cache dynamic content but cache everything else (or similar workaround)?

texts:
I have a production site with page caching enabled (this is not negotiable). One very popular feature requires dynamic content to be queried from an external socket and displayed; this content is required to be fresh at all times and cannot be cached. Current implementation has a vanilla, non-Drupal .php script polling the socket, whose output is either pulled into the page via javascript, or put in an iframe if no js. The vanilla .php is not cached by Drupal, but the rest of the page (menus etc.) is cached. It's fast.

Due to new requirements, the hard-coded config in the vanilla .php must instead be configurable through the Drupal UI. I have a working admin implementation, and have brought the socket-polling code inside the Drupal module. It's slow.

Putting the dynamic content in a block with DRUPAL_NO_CACHE doesn't help, because the whole page is being cached, ignoring block-level settings. Excluding the whole page (including menus etc.) from the cache will not meet performance requirements. I don't think I can use the javascript/iframe trick again, unless there's a way to get Drupal to render a minimal uncached page without building any of the rest of the site. Using 'print $my_html;' in the hook_block_view rather than 'return $my_html;' renders a page with just the dynamic content, but it performs slowly enough that I think Drupal is doing a lot of unnecessary work. Is there a better way of rendering a very-minimal page while still having access to e.g. variable_get()?

Is there a better way to approach this? Being able to set block caching independently of its parent page caching would be nice...

(Using local dev servers, a fully uncached page takes about 1000ms to render. The 'minimal print-don't-return' page takes about 400ms. The actual module code for getting the dynamic content takes 6ms of this. A fully cached page renders in 20ms.)


texts: Batch API to process millions of records

texts: I need to run Batch API on a huge dataset. Specifically I have a custom table with a lot of rows which I need to iterate over. The batch process works fine using small numbers. When using the full set I run out of memory before it even starts because I am loading a very large array of IDs to pass in to the batch function. Think of a 5 million item array. What is a good way to handle this? Break it into smaller chunks somehow to then pass in to Batch API? Increase the memory limit to an (ungodly) amount?


texts: Dynamically update main navigation URLs with prefix

texts:
This is some code from my theme_menu_link in Drupal 7.

function mytheme_menu_link($variables) {
  $element = $variables['element'];
  if(arg(0) === 'x') {
    if($element['#href'] === '<front>') {
      $element['#href'] = 'x';
    } else {
      $element['#href'] = 'x/' . $element['#href'];
    }
  }

At this point, I just need to do the same thing in Drupal 8:
If the visitor arrived at the page with an arg(0) of 'x', then prepend all of the menu links with 'x' keeping them in the "x" experience of the site.

I appreciate any help you can offer. Please provide detail if possible.


texts:
I'm trying to Run the Test from Administrative User, and it bring me below Error message:

  An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging
  information follows. Path:
  /drupal7.50/batch?render=overlay&id=18&op=do StatusText: OK
  ResponseText: Fatal error: Maximum execution time of 30 seconds
  exceeded in C:\xampp\htdocs\drupal7.50\includes\database\database.inc
  on line 2204

How can I fix that?


texts: How to change html of CAPTCHA module in another module?

texts:
I add captcha field to form in this way

$form['captcha'] = array(
    '#type' => 'captcha',
    '#title' => 'Simple title',
    '#captcha_type' => 'captcha/Math',
    '#description' => 'Please solve it'
);

This element will be rendered as

<fieldset class="captcha form-wrapper"><legend>CAPTCHA</legend>

Please solve it
<input type="hidden" name="captcha_sid" value="102">
<input type="hidden" name="captcha_token" value="bf6179f1c98e4291e1bb2e11c733d991">

  Math question *
 20 + 0 =  <input type="text" id="edit-captcha-response" name="captcha_response" value="" size="4" maxlength="2" class="form-text required" autocomplete="off">

Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

</fieldset>

How to change this html template ?


texts: How to combine several form objects into one?

texts:
i'm working with Drupal 8 and i want to combine the user form and a node creation form into my custom form.

So i've created the form skeleton :

<?php

namespace Drupal\fritr_register_friterie\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Class RegisterFriterieForm.
 *
 * @package Drupal\fritr_register_friterie\Form
 */
class RegisterFriterieForm extends FormBase {

    /**
     * {@inheritdoc}
     */
    public function getFormId() {
        return 'register_friterie_form';
    }

    /**
     * {@inheritdoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state) {
        $form = [];

//        $form = \Drupal::formBuilder()->getForm();

        return $form;
    }

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

    }

}

But i don't know how to import the user_profile form and the node creation form of a custom content that i've created in the back office.

I know drupal_get_form('form_id') is replaced in drupal 8 by \Drupal::formBuilder()->getForm(class, parameter);

Maybe it's something like this : \Drupal::formBuilder()->getForm(Drupal\user\Form\UserForm::class);

But i have not find the documentation which show all the locations of form or examples.... And i have not find how to load a node creation form :/

Can you help me please ? Thanks :)

EDIT : i've found how to include my node creation form (but i don't know how to modify my fields... D8 So complex u_u) by :

$type = node_type_load('friterie');
        $node = \Drupal::entityManager()->getStorage('node')->create(array(
          'type' => $type->id(),
        ));

        // OPTIONAL - Set default values for node fields
        // $node->set('field_age', "32") ;
        $node_create_form = \Drupal::service('entity.form_builder')->getForm($node);
        $form['friterie'] = array(
            '#type' => 'markup',
            '#markup' => render($node_create_form),
        );
        return $form;

need to find how to load user_profile form ^^


texts:
I am using mongodb as the backend for the node_save functionality and I have migrated my custom fields. So for every node save it calls the hook_field_storage_write() . Thus the data is saved in the mysql and then calls the mongodb implementation. This hook inserts the document in mongodb and calls the mongodb_migrate_write_helper. In the function the migrated fields are set with the value of deleted column as 2.

Thus if I have migrated a field 'field_email' from mysql to mongodb the mongodb_migrate_write_helper sets the field_email for the entity as deleted = 2. What does the deleted flag do? Are the rows marked as deleted = 2 deleted in a specific point of time or by some hook calls? . I have seen in many instances in the core modules where deleted is set as 1. Are there any purge scripts that are run at specific points of time for deletion of fields marked as deleted.

function mongodb_migrate_write_helper($entity_type, $entity_id) {
  $migrate_fields = variable_get('mongodb_migrate_fields', array()); // Migrated field names are stored in variable.
  foreach ($migrate_fields as $field_name => $v) {
    $field = field_info_field($field_name);
    db_update(_field_sql_storage_tablename($field))
      ->fields(array('deleted' => 2))
      ->condition('entity_type', $entity_type)
      ->condition('entity_id', $entity_id)
      ->execute();
    }
}


texts: Calendar: How to limit the range of hours in Days display?

texts:
I´m using the calendar module in d7.

In the  Day display it shows 01.00 to 23.00 in the hour column. How do I set it to be: 08.00 to 18.00?

I´m sure this is setteable in somewhere but I can´t find it...

I upload a picture which shows the hours to change:


texts:
I have a ViewExecutable object and would like to remove the filters depending on certain arguments. I'm passing in different arguments to the View using setArguments but can't seem to find a way to either see the current filters or remove them.

There a $filter property on the object but Xdebug comes back with null on that. Is this something I can do with the ViewExecutable object or will there be some theming involved?

Thanks!


texts: Which hook do I use to alter product entity data in a product display?

texts:
In Drupal Commerce, which hook do I use to alter product entity data in a product display?**  And it needs to be a hook that fires each time I change an attribute that causes a different product entity to be loaded in the display.

I added a line item to my product type called "Comments". It is a textarea, and it has a field description too. Then, on my product type, I added the following fields:

Customizable? (On/Off checkbox)
Custom Field Label
Custom Field Description

As each product entity is about to be displayed (whether it's the first one shown when the page loads, or I make a drop down selection to change which one shows), I want to check if that product entity is "Customizable".  If it is, I want to rename the title of the "Comments" line item with the value stored in "Custom Field Label".  And I want to change the Comments field description with the value stored in "Custom Field Description".  If the product entity is NOT "Customizable", then I want to hide the field completely (such as by converting the field type from a textarea to a hidden field).  This way, the "Comments" line item really only shows for the product entities we want it to, and it can have a custom label and instruction when it does show.

Any help someone can give is greatly appreciated.  I am having a lot of trouble even figuring out which hook fires each time a product entity is loaded, either the first time, or when switched via ajax.


texts: Add an html snippet some within body of the theme using preprocess

texts: I want to add a small html within the body tag of the site. I believe I can use template preprocess for this. I don't want to touch the template files. I am doing this from a module.


texts:
I can barely cut and paste JS stuff and have not seen an example of this anywhere. I have added a vertical tab to the node admin page and I want to show either "Limited" when the value of a field in the tab is not zero or "Not limited" if it is.

I see lots of examples of using check boxes, but this is a numeric field.


texts: Get title field from another content type in exposed filter

texts:
I have two content types: Project and Task. Project has an node reference field of Task - when you create a Task, you add reference to one of Project.

I need to create a view of Project and add the expose filter of title of the Task. I've selected both content type like Project and Task in a filter, I can see all of the fields from the Task content type EXCEPT Title. The only Content: Title that's available is the one from the Project nodes.

Need help.


texts: Naming convention for field type templates?

texts:
It seems that the naming convention for field types is undocumented. Looking at the classy theme shows a seemingly arbitrary convention. For example, the Text (formatted, long, with summary) type as displayed in the UI is apparently named field--text-with-summary.html.twig as a template file.

What are the naming conventions for field types and how could I have determined them myself?


texts: How do I enable aggregation in the settings?

texts:
I have the same problem as in Views sorting by number of values in field".  I would really like to try the solution that is given.

How can I enable aggregation in the view settings? I can't find it anywhere.

The following is a screenshot of the view panel. Is there any other name for "aggregation"?


texts: AJAX doesn't work for "flag" field print in node.tpl

texts:
In node.tpl I use this code:

<?php print flag_create_link('prova', $node->nid); ?>

Flag links work fine, but JavaScript toggle not. The flag link doesn't change to "Unflag link" after click.
Any idea?

Why put me on hold? What's not clear about that?

Update

At moment I solved with views. Set view full content node and set "Ajax" and "Flag refresh" under Other settings of views.
In original node view the problem remains.


texts: How to exclude product variations from product teaser display?

texts:
I am developing an online shopping website using Drupal Commerce.

In my products teaser display all my products variations are also shown. I want only the main product to be displayed and not its variations on teaser display. Right now I am using in-build taxonomy term view to display my product teaser.

Any suggestions?


texts: Intercalary values of field photos and fields cck

texts:
I have a field file in cck with 2 photos.  I like intercalary fields  between the values of photos.  I have attached an image for explain my doubt.  Is it possible?

I thanks your options.


texts: How to access to form field in views-exposed-form.html.twig (exposed filters)

texts:
I am trying to customize the template for the exposed filters of a view.

I have created the views-exposed-form.html.twig and Drupal loads it fine, following How do I theme exposed filters?.

For now, I have the standard code:

/**
 * @file
 * Theme override of a views exposed form.
 *
 * Available variables:
 * - form: A render element representing the form.
 *
 * @see template_preprocess_views_exposed_form()
 */
#}
{% if q is not empty %}
  {#
    This ensures that, if clean URLs are off, the 'q' is added first,
    as a hidden form element, so that it shows up first in the POST URL.
  #}
{{ q }}
{% endif %}
{{ form }}

and that works fine. Nevertheless, if I try to show only one field of the form (e.g., {{ form.field_city }}) nothing is shown in the filter block, though the page loads fine and there are no apparent errors.

I am working with Drupal 8.7.7 and PHP 7.3.9.

Any help will be more than welcome.

Thank you in advance.


texts: How to pass value generated in the form submit function to another function?

texts:
I have a question related to drupal 7 form api and module development.

I have a very simple module with a function like this. It gets called by hook_menu when a certain path xyz is visited.

function myview_mainpage() {

  $content .= drupal_render(drupal_get_form('myview_form'));
  $content .= "Some additional stuff here";
  return $content;
}

My form looks like this (it's from the examples module):

function myview_form($form, &$form_state) {
  $form['description'] = array(
    '#type' => 'item',
    '#title' => t('A simple form with a submit button'),
  );

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

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

And my submit handler looks like this:

function myview_form_submit($form, &$form_state){

 // I do some sql stuff and generate html content based on the value that was submitted in the form
  $variable = "

Some stuff
...';

}

And now I need to somehow pass the value of $variable to the function myview_mainpage() so it can print it out.
So in a nutshell: User submits a from, some processing is done based on the value submitted and then the results are displayed under the form when it is displayed.

Maybe I could use $form_state['redirect'] to redirect the user to the page xyz but I don't want to send the value of $variable in the address bar of a browser.

Any ideas? This feels like it should be done quite easily but I can't find a way to do it.


texts:
I've a plain text field, where I've added few text in wrapped in  tag. I've tried to get the processed html text in the twig by using

   {{ content.field_front_page_description|field_value }}
    {% set text = content.field_front_page_description|field_value %}
      {% set build = {
      '#type':   'processed_text',
      '#text':    text|render,
      '#format': 'full_html',
      } %}
      {{ kint(build) }}
      {{ build }}

But it is returning an array with not processed text. How do I do that


texts:
I've created a display called 'stats' for some views I've created - its cached and its generic and its quick and I use it for things like this

$result = views_get_view_result($view_name,'stats');
$count = count($result);
if ($count) $variables['title'] .= ' ('.$count.')';

However, not all views have this display.
How can I check, in php, if a given view has a display called 'stats' ?


texts: Generate drupalSettings in Ajax Callback

texts:
I'm returning a form with #ajax functionality in an Ajax response. The form is properly loaded into the page, however it is not #ajaxified, as the drupalSettings are not being returned. In D7, we could generate the JS settings AKA Drupal.settings using the following code:

$scripts = drupal_add_js();
if (!empty($scripts['settings']))
{
    $settings = '<script type="text/javascript">jQuery.extend(Drupal.settings, ';
    $settings .= drupal_json_encode(call_user_func_array('array_merge_recursive', $scripts['settings']['data']));
    $settings .= ');</script>';
}

I'm trying to find the D8 equivalent of this code, but not having much success. At the moment I'm returning a JsonResponse from my ajax callback, but I'm thinking I probably need to return an AjaxResponse. What I can't figure out is how to pass my generated form to the AjaxResponse, in order for it to return the settings along with the HTML for the form.


texts:
I use the following code in a theme whose machine name is yokai.

// works like expected, output visible
function yokai_preprocess_html(&$variables) {
  dpm('yokai_preprocess_html');
  dpm($variables);
}

// does not work, no output visible
function yokai_preprocess_node(&$variables) {
  dpm('yokai_preprocess_node');
  dpm($variables);
}

Why doesn't hook_preprocess_node() get triggered?


texts: How can i hook into a failed registration?

texts:
I need to send an email to a user who tried to register, but the registration failed due to some reason.

How can I do this? where do I hook into? I thought about it and searched for a while,

Hooking into hook_form_alter won't work because on submitting the form, I still don't know whether it would be a failed registration or not.
Hooking into hook_user_insert also won't work because this would only fire when the registration is successful.


texts:
I'm working on an API that pulls data from a Drupal site. Everything has gone pretty well I normally use Drupal Bootstrap to load Drupal use the functions I need then spit out a JSON array. I am having one issue though with a module, for some reason Drupal's schema doesn't seem to think the table exists. The module I am working with is VotingApi.

So in my API call I connect to the drupal db. Then if I run:

print_r(module_list());

I get a big list of modules installed and votingapi is included. If I run:

var_dump(module_exists('voting_api'));

I get a true response. I can also run:

var_dump(db_table_exists('votingapi_vote'));

And get a true response. However if I run:

print_r(drupal_get_complete_schema(true));

The votingapi_vote and votingapi_cache tables don't show up in the list. So then when I try to write a record to those tables with drupal_write_record() it doesn't work because that function checks the schema to see if the table exists. I have tried clearing the schema cache like this before I call drupal_get_complete_schema():

cache_clear_all('schema', 'cache');

It doesn't help, when it is rebuilt from the API the voting tables never show up. If I go into Drupal's admin and Clear All Cache then the table schema is rebuilt correctly and includes the voting tables. Any ideas on how I can get the schema to rebuild correct for the API?


texts: How is a field's key (rather than value) obtained?

texts:
In Drupal 7, I have a page content type that has a field called group (so the machine name is field_group).  The field is a List (integer) field type.

This field might have allowed values as follows:

0|Description 1
1|Description 2
2|Description 3

If I want to see the value of this field for the current page, the following code correctly works:

echo render(field_view_field('node', $node, 'field_group'));

If the key were set to 1 for this page, the above code would display the value "Description 2."

However, is there a way to instead get the key (e.g., 0, 1, 2, etc.)?


texts: Get the latitude and longitude from the user ip

texts:
I am trying to get the latitude and longitude from the user who connected to my website to draw or show his position on a map, but it showed him in the wrong postion. Is there any way to get the accurate latitude and longitude?

    <?php drupal_add_js('http://maps.google.com/maps/api/js?sensor=true'); ?>
     `
    <?php

     echo "

";
?>


texts: Services REST API and special characters

texts:
I'm using REST Services to communicate between two websites.

Once a node is updated on the website 1, part of the information is sent to the website 2. This works without any problems.

However, all special characters, e.g. apostrophes, are received escaped.

For example: "It's a sample page", will be received as "It\'s a sample page".

Here is the code I'm using:

// $data is just an example. It's more complex and the only relevant part is the
// way node title is passed.
$data = array('title' => $node->title);

$curl = curl_init('http://example.com/rest/node/1');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);

How can I avoid this? Is there any encoding/decoding I need to do prior to building HTTP query?

Thanks!


texts: url() not providing links to correct language alias using i18n in D7

texts:
We have a site that features two languages, EN (primary/default) and JA.  On one content page, we link to another node using it's nid: url('node/123').  In EN, this returns the alias and not the node based url.  When in the JA language, this returns a url like /ja/node/123 which then shows text in the EN variant when we expect JA.  There are aliases set for both EN and JA, which both point to the same desired URL like: /products/new-fancy-product and their respective node id urls.  In EN, url returns this alias correctly.

Also, if I change /products/new-fancy-product to /ja/products/new-fancy-product in the address bar, I get the correct JA version of the page as I want.

Why is url not returning me the correct alias instead of the node id path, which then just shows EN content?


texts: Send Mail After Checking Date Field Value

texts:
My content type (product) has a date field named Expired Date. All I want is like this:

check value of expired date field from content type product. If value equal to 7 days from now, send mail with list of node title and node url.

How to do this with Rules? or any suggestion modules?


texts: Can a database serve two different installations on localhost?

texts:
I have a Drupal 6 live site backed up to my localhost and I want to transition the localhost version to 7 before uploading to become the live site.

In my mind the ideal process would be to have a separate 7 install accessing the same (or mirrored) database so I still have a clean 6 backup in case of trouble with the live site. Does anyone have an opinion if this possible and/or the best way to do it?

I have MAMP Pro driving the localhost.


texts: Module invoke webform redirecting validation

texts:
On one page I have this code, that loads my Webform:

$block = module_invoke('webform', 'block_view', '660');
print render($block['content']);

But when I click on submit button, validation leads me to another page (webform page). How  can I stay on current page, where webform is loaded?


texts:
Background

A quick summary of where I stand right now:

We have a low traffic site here that was redone in Drupal about 8 months ago, before I was in the picture. An external design firm sold the owners on the technology as a way to enable non-programmers to update site content easily. Unfortunately, they did it wrong - they built our theme in-place over the Bartik theme instead of subclassing it, things like login boxes are written directly in the Basic Page Body textareas that our non-programmers are supposed to be updating, on and on and on beyond what's relevant to this post. Had I been here when it was forked over, I'm not even sure I would have taken delivery.

I've been meaning to pick up Drupal one of these days to go in and try to refactor this hot mess, but the non-Drupal work that actually keeps us all employed around here has prevented that.

Fast forward to now. I've got a feature request for the Drupal site that they want ASAP. It's a very simple application. Given the rush, I decided to develop the application as a straight PHP app to monkey patch onto the Drupal site. Based on some forms I had to maintain within the Drupal frontend (not using webforms, mind you) that I am able to $_POST back to some non-Drupal PHP with, I thought I could get away with this.

Now as I am trying to integrate my super vanilla PHP code into our Drupal environment I am running into all sorts of problems. At first my $_SESSION array wasn't persisting from page to page but I was able to figure that part out on my own by googling.

TL;DR: The question

Where I am stumped is with my $_POST array. I POST form data (an honest to God, completely naive HTML form) from one non-Drupal .php file to another non-Drupal .php file and it never arrives. The right way to do this - and the way it will get redone someday - is clearly to use the provided Drupal APIs for building forms.

Unfortunately, I am in such a position that there is absolutely, positively no time to rewrite this the right way today. With that in mind, is there a way to pass this POST data directly to the php file I am using for form processing?

EDIT:

It looks like maybe I am getting redirected internally and the data is not coming along for the ride. Could this be it? If so, it looks like Forms specified using the API Drupal provides can do something like :

$form['# redirect'] = false;

to prevent their being redirected. Is there some perhaps hidden input field I could pass in with my non-Drupal forms to accomplish the same thing?


texts: Custom Field Not Being Saved programattically through node_save()

texts:
So there is a custom field I added called 'qid'.  I can see that it is being created with each node.  My issue is that I cannot programmatically save a value to my custom field.  In the code below I will display and instance where I add two values, one to my custom field qid and another to the Ubercart uc_product field height.  Height will be saved successfully and qid will not.

function my_module_test_page() {
  $output = t('foo');

  $node = node_load('151');
  dpm($node);
  $node->height = '555';
  $node->qid = '222';
  dpm($node);
  node_save($node);
  $test = node_load('151');
  dpm($test);

  return $output;

}

While I understand that this is probably not enough code to get to the root of the problem I have no idea where to look.  I have scoured the node_save() function and I dont understand why my field is having a problem.  If it helps I have checked field_data_qid in my MYSQL db; however, the table is empty.

EDIT: So the next interesting fold is that when I enter the QID field through the GUI it saves fine.


texts: I want to have two styles of a specific field. How can I display the field twice so I can style each one differently?


texts: All custom fields are missing in views 'add field' and 'add filter' forms (Drupal 7)

texts:
I'm experiencing some very bizarre behaviour on a live website.

I've just added a new date field to a bunch of content types. I now need to add this as a filter criterion to a view. The problem is that when I go to add the filter, it doesn't show any custom fields at all in the Add Filter list, and this is the same for Add Field. It happens in all views.

The really strange thing is that I've copied the live database down to my local dev machine to debug, ensured that I have the live tag checked out, and on my local machine it works absolutely fine.

I've tried clearing caches, logging in as a different user, disabling a new custom module (which shouldn't make any difference). I just don't get what could be causing this, because the code and db are exactly the same in the live and local environments.

Almost certainly I'm overlooked something small. Can anyone think what it could be? Has anyone seem this weirdness before?

Thanks


texts: How to make one node relate to another node?

texts:
Ok, I'm going to toss out an example of what I'm trying to do with US states and counties, but I'm not looking for a module to handle them... It's just an example.

Assume I have two content types, the US State and US County content types.  So now I have some nodes of US State (alabama, alaska, etc) that have some fields, like maybe population size, square feet of territory, etc.  Now I have counties, so I've got some N counties that belong to alabama, some for alaska, etc., each as its own node.

How can I make a US County node know what US State node it belongs to?  How can I make US State nodes know what US County nodes belong to them?  For like querying in a view or whatever, basically the functionality of foreign keys in a SQL table.  This seems like it would be very simple and obvious to do, but I must be missing it.

Remember, this is just example data types, I'm not really working with US States and US Counties, so I don't want some specific module for them, just the idea of how to setup content types and the like to have foreign keys.

And if anyone knows, how efficient is this?  If I'm dealing with millions or maybe billions of nodes with some hierarchy of relations, how well can drupal query this stuff with joining linked data from multiple content types based on these "foreign keys"?  Is it 10x slower than mysql tables with foreign keys, faster than that?

edit: Using Drupal 7.  Maybe this will make things clearer: I've tried making a taxonomy vocabulary or whatever, but I don't see how to specify relations between nodes. I can say a US County is under US State, but how can I say "Baldwin County" is in "Alabama"? Where do I put that data in?


texts: What is the difference between profile and content profile module?

texts:
There is a core module called Profile which adds the profile fields; there is also a contributed module called Content Profile that does the same thing (up to my knowledge.)

May anyone clear me the difference between these two modules?
In which case should we go for the Profile module, and in which case for Content Profile module?


texts: Adding multiple taxonomy terms to a node via code

texts:
I've been editing nodes in code (Drupal 8) like so:

$node = \Drupal\node\Entity\Node::load($nid);
$node->body->value = $body;
$node->title->value = $title;
$node->taxonomy_field->target_id = $value;

If the 'taxonomy_field' entity reference supports multiple terms, how do place them in the $node object? I have tried at least a dozen ways I found on other threads, but none worked. Either errors were thrown, of the code just silently failed.


texts: attach an programmatically generated pdf file to a node

texts:
Im using PDF Using MPDF module to generate 4 files when a node is saved using its API function pdf_using_mpdf_api:

function MYMODULE_node_insert($node){
        // PDF generation :
        // Generate standard version
        $view = node_view($node, 'PDF');
        $html = drupal_render($view);
        pdf_using_mpdf_api($html, 'reference_'.$node->nid);

        // Generate short version
        $view = node_view($node, 'pdf_short');
        $html = drupal_render($view);
        pdf_using_mpdf_api($html, 'reference_'.$node->nid.'_short');

        // Generate Standard EN version
        $view = node_view($node, 'pdf_en');
        $html = drupal_render($view);
        pdf_using_mpdf_api($html, 'reference_'.$node->nid.'_en');

        // Generate short EN version
        $view = node_view($node, 'pdf_short_en');
        $html = drupal_render($view);
        pdf_using_mpdf_api($html, 'reference_'.$node->nid.'_short_en');
}

this code above generates 4 pdf files correctly and save them under default/files/pdf_using_mpdf directory.
users should be able to download these PDFs, so I added 4 fields in my content type for each PDF version (field_pdf1, field_pdf2, field_pdf3, field_pdf4).

I want to attach these stored files into their corresponding fields inside private directory (after success, i'll remove them from default/files/pdf_using_mpdf directory).

Before Im used to use field_attach_update to attach fields to a node, but for file fields how can I do this ?

What should be the value of the field : $node->field_pdf1['und'][0]['value'] ? and how can I store them into private directory ?

Thanks in advance.


texts: Additional parameters to aliased panels paths

texts:
I'm trying to build a news/blog feed for each of our internal departments.  I have a vocabulary with terms for each department, and have successfully created a panels page at extranet/news/<tid> which displays a content pane view of the most recent N posts.  The departments want to be able to alias their newsfeed, to something like hr-news, so add a url alias hr-news => /extranet/news/<tid-for-hr>.  This all works fine thus far.

The problem comes when I try to put a summary view in another pane on the same panel to link to previous months of posts, where the goal would be to use a path like hr-news/2011/10 or similar.  But to do this, it seems that I would have to create a url alias for each month/year/department combination.

The other option would be to use GET parameters, but I cant figure out how to load a GET parameter into a panels context so i can pass it to the view.  Am I approaching this problem wrong?


texts: Navigation links in a region rendering vertically

texts:
I am trying to place a block, that contains a navigation menu, within the Navigation region of a Bootstrap themed Drupal 7 site.

The menu is drawn vertically, I assume from the fact that it's a block within the region, and it's overwriting some of the CSS..

It also seems that the UL that is generated for the menu doesn't have the necessary "nav navbar-nav" classes.

Is my only option to override the region.tpl.php, block.tpl.php and the definition for UL (which I have yet to find)?


texts: Trigger 'Add another term' using javascript

texts:
Is there any way to simulate the click event of 'Add  another term' using javascript?
I tried like this

 jQuery('#edit-field-attribute-und-add-more').trigger('click');

but no effect


texts:
Dursh works very well with my Drupal 7, but when I try running Drush on Drupal-8 directory it throws some error message,

$drush pm-list

Command pm-list needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal environment to run[error]
this command.
The drush command 'pm-list' could not be executed.                                                                                [error]
A Drupal installation directory could not be found

could anyone tell me the solution for this problem?

any help is appreciated. Thank you.


texts: Why taxonomy term view is showing only a single content?

texts:
I'm working on customizing some templates on an existing Drupal 8 site. I was about to start working on the taxonomy term page but noticed only a single content is showing in it. I already checked and there are several contents associated with the taxonomy I'm testing.
It's not the pager settings, which could be limiting the results to 1. Neither the filter apparently, I've disabled all filter and sort criteria.
Another thing I tried was clearing the cache. I even disabled the cache for this view, completely.
Finally, it seems the theme has no custom hook that could be changing this view in some way.
Here are the settings I currently have for this view:

What else could I check in order to show the correct results?


texts: Best practice: needs private and public contents of same type

texts:
The website need News, Image Gallery and Announcement. But all of the News, Image Gallery and Announcement has 2 types: public and private.

The private content is tend to be a "collaboration platform" for specific user role.

I've created two content types for News (news & private_news), and so on for Image Gallery and Announcement.

So the website has 6 content types. I'm using content_access to make the content type public or private.

The problem with this, I dont know the future of the website. It will fails if in the future it needs public and private forum (where forum cannot exist in 2 content types).

Choice 2: Make single content types. It needs single News content type. The field accessibility is done by using field_permissions (not yet tested) and the node visibility is same as above; using content_access

But the problem is the content types become more complex. It maybe become very heavy for the server.

Choice 3: Use different sobdomain: www.site.com for public contents, and somename.site.com for private contents (not sure what name I should choose as subdomain).

I'm not sure which one the the best if the website growing bigger (in terms of traffic and website features).


texts:
I have implemented hook_menu_link_alter so that a menu link is altered for some authenticated users, but not for all. My implementation of hook_menu_link_alter changes properties of the link (HTML attributes), not the destination of the link. The thing that I'm changing is adding an HTML class and other attributes for some users, and not for others. A 3rd party JavaScript that is also loaded reacts differently depending on the attributes.

In Drupal 6 I must clear the cache so that the menu links are rebuild and so that the changes that I have in the hook are applied.

However, that also means that the modified link in stored in the cache. So if another user then logs on who doesn't need the change, then this user also sees the change because it was cached?

I know that a solution could be to have 2 menu's and use PHP code to decide which one is shown to which user, but this is not what I want. I'm building this in a generic module that is available from drupal.org, so I don't was to go duplicating menu's in other people's websites.
Another solution could be to rebuild the menu cache after every logon, but I fear that this is quite resource intensive.

Does anybody have advice on how this can be handled?


texts: How can I allow users to send private messages without revealing sender's address?

texts: I have a community application which allows users to send private messages and it is built using 'Private Message' module. When a message is sent, the recipient sees the sender's original email address which he has used to register with the system. I would like to use a system generated email address without revealing sender's original email address.


texts:
I have created a frontpage with views. Also I have added the content field called Volume. The frontpage is arranged with 10 views and it shows the Volume by descending order, so the latest volume should be displayed in the front page. There is a page that shows the all released volumes, what I want to do that is when we clicking the volume number, then the frontpage will display all contents belongs to that volume number.

e.g. example.com will shows the default front page and example.com/volume/1 will have to show the volume number 1 and so on, but when we take the page example.com/volume/1 it displays the "Page not found " error


texts: How to remove format description in date_popup form field?

texts:
How can I remove format description in date_popup form field?

$form['payable_by'] = array(
    '#type' => 'date_popup',
    '#title' => $amount !== '' ? t('Instalment payable date for instalment @label', array('@label' => $amount)) : t('Instalment payable date for new instalment'),
    '#title_display' => 'invisible',
    '#default_value' => $payable_by,
    '#parents' => array('instalment', $key, 'payable_by'),
        '#date_format' => 'Y-m-d',
        '#date_year_range' => '-0:+1',
  );

Please check the image


texts: How do I test a paragraph bundle entity reference with Behat?

texts:
I am learning Behat with Drupal 8 and I'm stuck on trying to test a paragraph bundle (field_related_content) which has a title and description field, the title is an entity reference field to content type marine_notices. Currently I have the below, but the results are 'No link to Post Title', am I missing something?

  @api
  Scenario: Reference site pages from within a "marine_notices" node
  Given "marine_notices" content:
    | title      |
    | Post title  |
  When I am viewing a "marine_notices" content:
    | title                | Post title         |
    | field_related_content | Post title - <front> |
  Then I should see the link "Post title"


texts: D7 Views 3: Filter by relationship based on nid and uid

texts:
I have a content type 'contest' that users submit guesses on. The guesses are entities that have uid and nid properties (and of course their own primary key, gid) to record the user and the contest to which they belong.

How can I display only contests on which a given user has submitted guesses?
A similar problem might be how to return only nodes of a certain type that a given user has commented on.

By using this within hook_views_data and setting the query to distinct (which I'd also prefer not to have to do) within the Views UI, I was able to confine the results to nodes that have guesses whose nid property match - but I can't figure out how to confine the results to nodes with guess entities whose nid AND uid properties match:

$data['node']['nid'] = array(
    'relationship' => array(
        'handler'        => 'views_handler_relationship',
        'base'           => 'entity_guess',
        'base field'     => 'nid',
        'title'          => t('Has guesses'),
        'label'          => t('contests with guesses'),
    ),
);

Thanks so much!