texts: What's a good way to split a 'item_list' into two columns?

texts:
I'm working in a custom module that will output to my custom theme in D7. This theme & module will never be used apart.

Say I have a simple list in a block (six items), I want it split into two adjacent columns of three items...

Can this be done only with CSS? (just curious, not a constraint)
What seems easier; should I render two lists & just float the second right?


texts: Fatal error: Class 'DrupalDefaultEntityController' not found in comment.module

texts:
I'm trying to update the Drupal Core of a website, specifically from 7.65 to 7.67.
I've followed the instructions from here. After the process, I've try to access the website without luck, because I'm getting the following error: Fatal error: Class 'DrupalDefaultEntityController' not found in /var/www/html/modules/comment/comment.module on line 1698

I've tried to run the update.php file and clearing the cache from the db several times, without fixing the error. I've also tried to update from 7.65 to 7.66, but the problem persists.

What am I doing wrong?

UPDATE 1

I've tried to follow the instructions written here suggested by the user sivani. Here is the message I am getting:

DRUPAL_ROOT is /Users/DamianFox/tests/drupal-website/website.

Bootstrapping to DRUPAL_BOOTSTRAP_SESSION

Additional uncaught exception thrown while handling exception.

Original

PDOException: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in lock_may_be_available() (line 167 of /Users/DamianFox/tests/drupal-website/website/includes/lock.inc).

Additional

PDOException: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in system_list() (line 165 of /Users/DamianFox/tests/drupal-website/website/includes/module.inc).

%


texts:
I have tried a lot to remove path that you can see in below picture:

I am new to drupal and learning it.So right now I am converting HTML template in to Drupal theme.

So for that I have copied bartik folder and I am changing in that.

For the content, I have used an article and from configuration I have set that article on front and removed title using function in template.php.

But I am not able to find, from where that path is coming from.

Inspect element of that specific part :

My page--front.tpl.php and template.php.

Ask me if more code is needed.

I have also tried by clearing cache but it did not help me out.


texts: How can the admin of a group edit all members default profiles? Is that possible? (Drupal 6 installation)

texts:
I need to do this in a Drupal 6 installation, with the Organic Groups module:

The user that has administrator rights within a group can edit all members default profiles.

I just want the admin of an OG to be able to change each user´s email address, but the line above reflects the generic use case.

Any thoughts on how to complete that task?

Thanks!!!

Rosamunda


texts: background_process module hogging system resource?

texts:
I Ran a script using Background Process module which hogged my system resources.
I somehow managed to kill that.
Then i ran the script again with changed parameters.
My system hanged again..

I noticed that there were about 8-9 entries in background_process table .
Is it possible that they all start running as soon as background_process module is enabled ?


texts: drupal 8 Restore client's original IP address from apache behind nginx

texts:
Is there any simple method can i restore client's original IP address behind nginx?

i've tried to add the following code in settings.php, but not work

$settings['reverse_proxy'] = TRUE;
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
  $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}

i use contact form to test and see the ip flood table it is still a server ip address. any ideas?


texts:
After enabling the JWT module. and following Using JSON Web Tokens (JWT) to Authenticate Requests to REST Resources in Drupal 8 on how to use it, it is working.

I know I can access the user JWT token by visiting /jwt/token. My problem is when I try to log in via web services. It returns me the following.

{
    "current_user": {
        "uid": "4",
        "name": "cravushedal"
    },
    "csrf_token": "OlTb7fak5ZS-r1BRiGtBh4IWLm_Z7F1xMpY3KYTGkrU",
    "logout_token": "5DiupHgr9iDxIDVmhHTI3PMX2-Shd6sjuN8hNHrHv7E"
}

With postman
In postman, after login, I receive a cookie, and with that cookie, I can access the jwt/token route and receive the bearer token.

But, I am using angular 5, and what I want is to access to that rout without the cookie, just by csrf token. Is that possible? I mean, I am trying to include it in the header, but not result. Any idea?

Thanks


texts: theming username field in user-register form

texts:
i'm trying to theming my user register form. i would like to have a custom function for the username part. So, i'm doing

$form['account']['name']['#theme'] = 'my_custom';

i define my hook_theme and just for testing purpouses, this is my custom function

function theme_my_custom( $variables ){
  return 'testing code...'
}

My problem is when i go to user/register, i still can see the label for my username. Only the input is replaced by the code of my function. I would expect replace the element entirely, but this is not happening.

Any clues? Thanks.


texts: Avoid random number cached in preprocess hook

texts:
I have a random set of images that appear on the homepage which needs to show each time the page is refreshed. My holding page was doing this comfortably in PHP, but since building the whole site and migrating the PHP into Twig I ran into issues with the cache. I tried moving the code into a preprocess hook for the content type however that too is subject to the caching.

Is there anyway around this problem by disabling caching for anonymous users in the preprocess hook, or updating the random number variable in the cache on each reload etc.?

Ideally I'd like to avoid doing this in JS as per the recommendation here Ignore cache in preprocess function

Here is my preprocess function PHP code which feeds a loop.

function freadman_white_preprocess_node__3(&$variables) {

$imageset = (rand(1,8));
$time = array(
    '01:14',
    '10:37',
    '11:16',
    '09:38',
    '04:51',
    '03:24',
    '10:39',
    '10:58'
);
$date = array(
    'pm Saturday 18.08.18',
    'am Sunday 05.08.18',
    'am Sunday 05.08.18',
    'am Wednesday 15.08.18',
    'pm Tuesday 21.08.18',
    'pm Tuesday 21.08.18',
    'am Wednesday 25.07.18',
    'am Saturday 25.08.18'
);

$variables['imageCount'] = 33;
$variables['imageSet'] = $imageset;
$variables['imageTime'] = $time[$imageset-1];
$variables['imageDate'] = $date[$imageset-1];

}


texts: Displaying a list of all the content types

texts:
I need to display a list of all the content types which links to their respective page, displaying the contents of that type.

I tried a bunch of wild guesses like $row->content and couldn't manage.

How should I achieve this?


texts: Calculate time between start and end time

texts:
I'm building a website where I need to know the time (in hours) between the start and end time from a date field. So I want to know how long it took. It's usually from one day to another, sometimes just on one day (don't know if that matters).

I made a field Date (Unix timestamp) with month, day, hour and minute. Users need to choose both start and end time.
I also made a Computed field. The first part is the Computed code and the second part is de display code:

<?php
$field_tijden = array_pop(field_get_items($entity_type, $entity, 'field_date'));

$start = $field_tijden['value'];
$end = $field_tijden['value2'];
$timezone = $field_tijden['timezone'];

$date_start = new DateTime($start, $timezone);
$date_end = new DateTime($end, $timezone);

$interval = $date_start->diff($date_end);

$entity_field[0]['value'] = $interval->format('%h');
?>

<?php
$display_output = $entity_field_item['value'] . " hours";
?>

I checked "Store value in the database", checked "Float", data length "3,2" and the other settings I kept on default. This is what I copied from another website and all I tweaked was changing it to $field_tijden which is the name of the field.
I know almost nothing about PHP, so I have no idea what to change to get this to work. Right now when I save a node the field is not being displayed.

Is there anyone who can help me getting this to work?
Thanks in advance!

Edit: These are the settings I put in a Rule, but it's not working yet. Does anyone see what I'm doing wrong?

Events:
 - After saving node

After updating existing node

Conditions: nothing

Actions:

Convert data type. Value: Integer. Selector: node:field-tijden:value (this is the start time). Label: conversion-result-start.
Convert data type. Value: Integer. Selector: node:field-tijden:value2 (this is the end time). Label: conversion-result-end.
Calculate a value. Selector: conversion-result-end. Operator value: (-). Selector 2: conversion-result-start. Label: result-calculation.
Calculate a value. Selector: conversion-result-calculation. Operator value: (*). Selector 2: 60. Label: result-in-minutes.
Calculate a value. Selector: conversion-result-in-minutes. Operator value: (*). Selector 2: 60. Label: result-in-hours.
Convert data type. Value: Integer. Selector: result-in-hours. Label: conversion-result-in-hours-converted.
Set a data value. Selector: node:field-tijden:duration (I'm not sure where the :duration is coming from)


texts: Holistic Design Critique for a Volunteer Matching Service

texts:
I'm a new Drupal developer, and  I made an initial implementation of a project, but some of the things that I'm doing probably aren't the best solutions, so I was hoping to get some critiques of my design.  What the site will do and how I'm doing it is below.

The motivation:

I'm making a volunteer matching service in Drupal 7.  Specifically, community representatives from nonprofits can point our service to their issue tracker (ie, GitHub), we'll turn their issues into nodes, they can organize those nodes, and volunteers can sign up to work on some of those issues.  Also, those volunteers will belong to an organization with a Corporate Social Responsibility (CSR) representative, and the CSR representative can administer their volunteers (email them, modify the tasks that they signed up for, etc).

The implementation:

Community managers are a user type.  I use profiles2 and fields to give them an issue_tracker_url that they can store in their profile.  I implement hook_menu to add a link to their profile that they can click to grab issues from the issue tracker based on their specified issue_tracker_url.  The function that pulls stuff down from the issue tracker is the callback in hook_menu.

"Issue" is a custom node type that has some fields like the issue's id within the issue tracker so that we don't get duplicate nodes if the nonprofit pulls issues multiple times.

Each community manager can have several projects.  Each project can have smaller sub-components.  The issues from the issue trackers all belong to a given sub-component.  The community manager should be able to manage which issues are in each component, which components are in each project, and which projects are in their organization.  Allowing them to create nodes of each type and organize everything in a book would work, but it seems like a kludge.  Taxonomies seem like they might be a more elegant solution, but I wasn't sure how to get one set up for what I'm looking for or how to let the community managers manage their own organization's taxonomy.

The volunteers also need to be able to view using this hierarchy.  That is, they should be able to see a list of all organizations (all community managers).  An organization page should have a list of all projects; a project page should have a list of all sub-components; a sub-component page should have a list of all issues pulled from the issue tracker that were organized into that component.  I have tried using a view with filtering, but I haven't found a way to do that so that it will automatically generate pages based on the hierarchy described above.

I haven't yet figured out how to set it up such that the CSR representatives can manage volunteers from their company.

All of this should be easy to setup in case we want to have multiple instances of this service.  Thus, the manual setup stuff involved in setting up the views and fields should be automated.  Could I use the features module to automate this?

I have tried to do as much of this as possible using existing modules for the sake of maintainability, but if any of the functionality that I'm describing doesn't exist well in an existing module, I'm perfectly comfortable programming it myself.

Thanks for reading through my lengthy description and for your critique!


texts: How to show two dropdown select lists using a single ajax call in form api .?

texts:
I have a form in which user needs to input his height. I have two radio buttons to select the format in which the user wishes to input his height. one is  "feet-inch" and  another is "centimeters". I want to show a dropdown if "feet-inch" is selected, or else a textfield if "centimeters"is selected using ajax.

Am being able to show the textfield and a single dropdown successfully with ajax call triggered from the selection of the radio buttons, But I need to have two dropdowns, one to select "feet" and another to select "inches" right..?

So my problem is that am not being able to show two dropdowns with one single ajax call.
How can I achieve it...?? Or in other words, how can I replace two separate divs (both containing a dropdown select) with one single ajax call..?

Alseo do let me know, if there are  any other better ways to achieve this kind of height selection form..?

Please provide, codes for both form elements and the ajax call if possible.

Thanks in advance.

////  EDIT   /////

I put both select fields inside a fieldset and wrapped that fieldset with the wrapper to be replaced. and put it inside the something_form() function with an if statement. I dont know where am going wrong... Below is my code, please show me wats wrong....

<?php
function my_form($form,&form_state)
{
$form['health_set']['height_set'] = array(
        '#title'=>t('Input your height'),
        '#type'=>'fieldset',
            '#tree'=>TRUE,
            );

$form['health_set']['height_set']['height_radio'] = array(
    '#title' => t("Height input format"),
    '#type' => 'radios',
    '#options' => array(
      1 => t('feet'),
      2 => t('centimeters'),
      ),

    '#required'=>TRUE,
    '#ajax' => array(
       'callback' => 'health_height_callback',
       'wrapper' => 'health_height-wrapper',
      'effect'=>'slide',
     ),
    );

if($form_state['values']['health_set']['height_set']['height_radio']==1)
{

$form['health_set']['height_set']['feet-inch'] = array(
   '#type'=>'fieldset',
   '#tree'=>TRUE,
    '#prefix'=>'
',
    '#suffix'=>'
',
  );

      $options1 = array(
    1=>t('1 ft'),
        2=>t('2 ft'),
        3=>t('3 ft'),
        4=>t('4 ft'),
        5=>t('5 ft'),
    6=>t('6 ft'),
    7=>t('7 ft'),
     );

$form['health_my_bmi']['height_set']['feet-inch']['feet'] = array(
        '#type'=>'select',
        '#options'=>$options1,
        '#required'=>TRUE,
        '#description'=>t('Whats your height in feet?'),
      );

$options2 = array(
    1=>t('1 inch'),
        2=>t('2 inch'),
        3=>t('3 inch'),
        4=>t('4 inch'),
        5=>t('5 inch'),
    6=>t('6 inch'),
    7=>t('7 inch'),
        8=>t('8 inch'),
        9=>t('9 inch'),
        10=>t('10 inch'),
        11=>t('11 inch'),
     );

$form['health_set']['height_set']['feet-inch']['inch'] = array(
       '#type'=>'select',
        '#options'=>$options2,
        '#title'=>t('Inches'),
        '#description'=>t('how many inches ?'),
        '#required'=>TRUE,

      );

}

else if($form_state['values']['health_set']['height_set']['height_radio']==2)
{

   $form['health_set']['height_set']['centi'] = array(
        '#type'=>'textfield',
        '#title'=>'Height in centimeters',
        '#prefix'=>'
',
        '#suffix'=>'
',
         '#maxlength'=>3,
         '#size'=>6,
        '#required'=>TRUE,
      );

}

  return $form;

}
?>

below is the code of the callback function,

<?php
function health_height_callback($form, $form_state)
{
       if($form_state['values']['health_set']['height_set']['height_radio']==1)
           return $form['health_set']['height_set']['feet-inch'];

      else if($form_state['values']['health_set']['height_set']['height_radio']==2)
           return $form['health_set']['height_set']['centi'];

}
?>


texts:
I wanted to provide feature where non-logged in users can click on "Rate" button, which will lead them to login and after login they come back to the page. Upto this, it is working fine.

But I want user's to go to particular section of page, div with id = "id1".

How can I achieve this?

-- Many thanks for your time.

This is what I have tried:

$destination = drupal_get_destination();

$options = array( 'query' => $destination,'fragment'=>'div_id');

print l('Review', 'content/login', $options);


texts: D8 generate double URL for commerce product

texts:
I need to create double URL alias for commerce product. I tried with code below :

function mymodule_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
    if($entity->getEntityTypeId() == 'commerce_product'){
        $alias = '/store/'.$entity->getTitle();
        $source = '/product/' . $entity->id();
        $path = \Drupal::service('path.alias_storage')->save($source, $alias, "en");
    }
}

but doesn't work. My alias is overridden by pathauto and I have 2 equal alias.
I need to create /catalog/[commerce_product:title] and /store/[commerce_product:title] URLs.

The first one is set with pathauto pattern and created succesfully. The second one is create with the code above.

After updating the product i have 2 equal URLs:

/catalog/product-title
/catalog/product-title

why do not I have

/catalog/product-title
/store/product-title

how can I save double different alias?

Thanks in advance.


texts: What date format is required to import entityform submissions via feeds?

texts:
I am trying to import entityform submissions. When using feeds and feeds entity processor it asks for a default value for the "date submitted". I have tried several date formats and none of them are accepted.

I have tried

m/d/y

mm/dd/yy

mm/dd/yyyy

month dd, year

unix timestamp

What format does this need to be in?


texts: Drupal 8: How to retrieve field values when i use loadMultiple to load multiple node ids

texts:
I am loading multiple node ids like below

$node_storage = \Drupal::entityTypeManager()->getStorage('user')->loadMultiple($nids);
foreach ($node_storage as $node){
  $value = $node->get('field_merchant_id')->value;
}

After this, I am getting an object and I don't know how to access my values. I have used get('field_name')->value but its saying Error: Call to a member function get() on array. How can I get an array that contains all values of one specific column from all nodes?


texts: Accessing contents of a node id not working in .theme file

texts:
I have a page(node) with a certain ID.
On the front page, I want to pull a field called field_image1 and field_link1.

To do that I added the following to my themename.theme:

function themename_preprocess_page(&$variables) {

    $variables['vanilla_spice'] = Node::load(61);

    $variables['variable'] = "tetsing the variable";

}

page--front.html.twig:

{{ kint(vanilla_spice) }}
{{ kint(variable) }}

When I visit the page, the variable is null :(

How can I load this information inside the variable?

Note: I based myself in this answer here, but even if I assign a normal string to the vanilla_spice variable

$vanilla_spice = "tetsing the variable";

I still see a null.


texts: function uc_stock_adjust($sku, $newStock); not returning any value

texts:
Iam using uc_stock module functions of ubercart module in my function but not getting result as i want. here is my code:

function my_module_node_presave($node) {
  if ($node->type == 'add_stock') {
    if (module_exists('uc_stock') && function_exists('uc_stock_adjust')) {
      $newStock = $node->field_stock_value['und'][0]['value'];
      drupal_set_message('new stock :' . $newStock);

      $sku = $node->field_sku['und'][0]['value'];
      drupal_set_message('sku :'. $sku);

      $key = $node->field_reference['und'][0]['nid'];
      drupal_set_message('key :'. $key);

      $items = field_get_items('node', $node, 'field_sku');
      drupal_set_message("
" . print_r($items, true) . "
");
      $sku = $items[0];
      drupal_set_message("
" . print_r($sku, true) . "
");

      $stock_adjust = uc_stock_adjust($sku, $newStock);
      drupal_set_message('stock_adjust :'.$stock_adjust);

      $stock_set = uc_stock_set($sku, $newStock);
      drupal_set_message('stock_set :'.$stock_set);
    }
  }
}

in my code

$stock_adjust = uc_stock_adjust($sku, $newStock);

$stock_set = uc_stock_set($sku, $newStock);

the above two functions were returning no value. now anyone can tell me whats the problem in my code


texts:
Should be pretty straightforward but I am kinda stuck. I am prepopulating a mandatory field's value according to the URL, so I want to prevent the field from showing up, but not in a CSS level.

hide() and #access do not seem to submit the field leading to a validation error. Any clues on how would I go about doing this?

P.S. not a field of #type => hidden. An actual field. A select list if you want.

Comment trail clarifications:
1) the field is an entity field, a user field
2) the field is mandatory
3) the field is prepopulated using #value and #default_value (for safety (?))
4) the field should not be either visible or editable
5) I'd like to avoid adding a hidden and/or value field myself and write another submission/validation function since the user_register one works just fine. I want to use the value that the field has upon the form's rendering taking into consideration point 4.


texts: Add value to field using hook_webform_submission_presave()

texts:
I am at my wits end trying to use the hook_webform_submission_presave function on a webform that I have created for a Drupal 7 site. Ideally I would like to capture a list of nodes that a user has flagged and transfer that data into a field before the user submits their form. But the function is just not adding the data.

First I get the flags:

$flags = flag_get_user_flags($node->type);

Then I want to transfer that variable into a field with a component ID of 32.

// Update some component's value before it is saved.
  $component_id = 32;
  $submission->data[$component_id]['value'][0] = $flags;

Here is the full function:

function get_flags_webform_submission_presave($node, &$submission) {
$nodes_list = array();
$title = '';
  // Get the flags.
  $flags = flag_get_user_flags($node->type);

  // Get the nodes.
  if (!empty($flags)) {
foreach ($flags as $flag) {
    $nid = $flad->entity_id;
    // Get node data. Delete to not get node titles.
    $node = node_load($nid);
    $title = $node->title;
    // Combine data.
    $nodes_list[] .= 'node/' . $nid . ' ' . $title . ",\n";
    }
  }

  // Update some component's value before it is saved.
  $component_id = 32;
  $submission->data[$component_id]['value'][0] = $nodes_list;
}

What am I doing wrong? I'd love some help!


texts:
I have a website with a lot of furniture products.
Each node page has a link to "ask for more info" that opens the sitewide contact form. When I receive the e-mail message, I need to know to which product (node) the request refers to, because many people forget to say it. So I need to pass node url, title or nid to the form in order to insert it automatically in the sent contact e-mail.

Thank you very much


texts:
I am trying to call a custom form in a block. The form is written in my custom module.
I tried different ways to call the form, but not getting the form.

Here is the syntax, I last tried.

$form = drupal_get_form('my_custom_form');
print drupal_render($form);
//my_custom_form is my form_id

(or)

drupal_render(drupal_get_form('my_custom_form'));

Here is the link I found a similar question, but didn't get the correct solution for my question.
Form within a block


texts: webflo and behat issue preventing patch via composer

texts:
I am attempting to install a patch for the smtp module on a Drupal 8.8.4 vagrant dev instance.

Trying to do so fails with the following error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - webflo/drupal-core-require-dev 8.8.4 requires behat/mink 1.7.x-dev -> no matching package found.
    - webflo/drupal-core-require-dev 8.8.4 requires behat/mink 1.7.x-dev -> no matching package found.
    - Installation request for webflo/drupal-core-require-dev 8.8.4 -> satisfiable by webflo/drupal-core-require-dev[8.8.4].

I don't have behat/mink required at all. This error seems completely unconnected to smtp and I have never seen it before on any other updates.

I understand behat/mink 1.7 doesn't exist but there is a 1.8 version. However, when I try to install it I get the following:

  Problem 1
    - Installation request for webflo/drupal-core-require-dev (locked at 8.8.4, required as ^8.6.0) -> satisfiable by webflo/drupal-core-require-dev[8.8.4].
    - Can only install one of: behat/mink[1.7.x-dev, 1.8.x-dev].
    - Can only install one of: behat/mink[1.8.x-dev, 1.7.x-dev].
    - Can only install one of: behat/mink[1.7.x-dev, 1.8.x-dev].
    - Conclusion: install behat/mink 1.7.x-dev
    - Installation request for behat/mink 1.8.x-dev -> satisfiable by behat/mink[1.8.x-dev].

I feel like I have tried every possible version of 1.8: 1.8, 1.8.0, 1.8.x-dev. Regardless off what version I ask for composer tries to install 1.7 every time and will not allow behat/mink to install.

How can I fix this? Do I even need webflo/drupal-core-require-dev? I am still not completely sure what it does.


texts: How to translate a custom Constraint message?

texts:
I have a custom constraint in the Allow a content type only once (Only One) module that is working and is defined as:

<?php

namespace Drupal\onlyone\Plugin\Validation\Constraint;

use Symfony\Component\Validator\Constraint;

/**
 * Checks that Only One node of locked languages exists.
 *
 * @Constraint(
 *   id = "LockedLanguages",
 *   label = @Translation("Locked Languages Constraint", context = "Validation"),
 *   type = { "entity" }
 * )
 */
class LockedLanguagesConstraint extends Constraint {

  /**
   * Message shown when a node of a locked language exists on a content type.
   *
   * @var string
   */
  public $nodeExists = "The content type %content_type is configured to have Only One node per language but the node @title exists for the %language language.";

}

And I want to be able to translate the message, the problem is that you can't use the t() function in the property definition. How can I accomplish this?


texts:
During making of new variants performing steps.
node edit form->add new variant->variant type ->panel->selection rules->node type->context continue->choose layout 2 column->continue->render->standard->continue after this white display occur,i am stuck here.what is the problem.


texts: How can I print the number of the current pager in Views template?

texts:
I have a node View with pager configured Paged output, full pager, Items per page：30

So the view lists only 30 nodes per page.
Now I would like to print the number of the current page and the total number of pages on views template page-my-view.tpl.php.

For example, "2 / 10" when the current page is the 2nd one and the total number of the pages is 10.

How can I do this?


texts: Force Rebuild of Custom Entity's Task Menu

texts:
My module has a custom entity along with custom menu tasks. I would like the tasks shown for a specific entity to be dependent on its properties. Once the properties change I would like the task menu to refresh.

I use custom permissions to determine which menu tabs to show.

I have tried to invalidate the entity's tags after a user changes properties but the task menu does not change (I don't see the permissions being checked again either).

\Drupal\Core\Cache\Cache::invalidateTags(array(
        '[my_custom_entity_type]:' . $entity->id()
)

If I clear all caches, the entity's menu changes as needed but that is a very expensive operation.

Would love some help.


texts:
I have a problem that too many of the orders coming in don't get completed and remain in checkout. It appears as though it doesn't even try to send to paypal.

I don't think that the issue is that the form is failing validation because of 2 reasons:

wouldn't most of these people try to correct their info and submit again?
i have also javascript validation on the page.

This issue has been with me for quite some time, and I would LOVE to get rid of it...


texts: The menus menu items appear twice as shown in the image below. I have tried to disable menu items in the Management menu which had no effect. How can I solve this issue?


texts:
I have the following code in my form.

$form['new']['upload'] = array(
  '#type' => 'file',
  '#title' => t(''),
  '#size' => 40,
);

On the submission handler, it returns the file name but it does not save the file and return a file object. What else do I need to do?

What I am trying to do is create a block where you can upload a file that it is saved in a node's file field.


texts: Slow query with large dataset in Drupal views — better to process in SQL or PHP?

texts:
I have a large userbase in my Drupal 7 site, which contains a People finder. Because there are hundreds of thousands of users and we want to display the People finder in a random order on page load, I presume it's transferring the whole userbase into memory at some point, in order to paginate (using the Pager built-in to Views2 Views3).

I've noticed that the query has no limit against it (presumably because of pagination) and that it joins against users_roles twice (because I need to include all users of rôle A but not also of rôles B, C and D). I've added comments against the WHERE clause to explain each line's purpose and how it's come out of my View.

SELECT
    users.uid AS uid,
    'user' AS field_data_field_user_image_user_entity_type,
    'user' AS field_data_field_user_field1_user_entity_type,         -- custom field
    'user' AS field_data_field_user_field2_display_user_entity_type, -- custom field
    'user' AS field_data_field_user_field3_user_entity_type,         -- custom field
    'user' AS field_data_field_user_field4_user_entity_type,         -- custom field
    RAND() AS random_field
FROM
    users users
    INNER JOIN users_roles users_roles ON users.uid = users_roles.uid
    LEFT JOIN users_roles users_roles2
        ON users.uid = users_roles2.uid
        AND (users_roles2.rid = :views_join_condition_0
          OR users_roles2.rid = :views_join_condition_1
          OR users_roles2.rid = :views_join_condition_2)
WHERE
    (( (users.status <> :db_condition_placeholder_3)      -- Active users only
    AND (users_roles.rid = :db_condition_placeholder_4)   -- Must be in rôle A
    AND (users_roles2.rid IS NULL)                        -- Must not be in rôles B, C, D
    AND (users.uid != :users_uid OR users.uid IS NULL) )) -- Must not be current user
ORDER BY random_field ASC

So I have two questions:

Is there some way in Views2 that I can somehow get this query to be limited (potentially by sorting on something else that pretends to be random)? I assume that transferring fewer result rows per query is likely to help with the memory overhead?
If I want to mess with that WHERE clause, am I better off using a PHP Filter Criterion to do the roles messing (which would presumably remove the double-join) or should I move the whole damn query into either a custom module[a] or a mySQL view[b]?

a: I assume that would attach to the relevant hook with a function modulename_views_pre_execute(&$view).
b: I assume a mySQL view would still need to do both joins, one inner join and one left join, so I can't quite see how this would help.

For what it's worth, I know that my site will have a relatively short lifetime and, during that, the rôles won't change, so I am happy to hardcode the rôle IDs, if that will give me a performance benefit.


texts: Change form_state values with custom ajax call but without #ajax commands (fapi)?

texts:
(Sorry for my bad English)

I’m building multi steps form with help of FAPI in front-end section.
In the final step of my form I want use some third party js libraries for few task (like uploading file). But my problems begin here.
How wrap these js libraries to the FAPI and make ajax callback function. This libraries make dynamic elements and I don’t know how connect theirs event to FAPI system.
(Plupload is good example of this js libraries that create dynamic upload button )
I know already that I can use default #ajax callback, but this is for predefined drupal elements like textbox, button,… in FAPI system.

My first idea (didn’t work): deceive drupal FAPI.
I get form_id and form_build_id of my form with help of jQuery and make ajax post to q=system/ajax url. But drupal make new form and reset form_state of my old form.

My second idea (I don’t know how implement it): make custom FAPI element for each js library and used it on form. I’m familiar with _element_info hook but unfortunately for complex library like plupload it’s hard for me to accomplish this.

#

https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7

http://www.plupload.com/

My form made of thousand lines of code but I try to explain more:
In drupal FAPI you use ajax like this
(In below code if you click on ‘click me’ button, drupal call
ajax_append_callback($form,$form_state){} function but keep value of $form, $form_state and doesn’t make new form. So in the function you can modify $form_state each time. In this case you could hold the number of user click on ‘click me’ button. (if $form_state reset each time of callback invoke, form is stateless.

But remember, you could do this operation only on predefine type of FAPI elements like , button, checkbox,select,…

   $form['anyform'] = array(
  '#value' => t("click me"),
  '#type' => 'submit',
  '#ajax' => array(
  'callback' => 'ajax_append_callback',
),

);

So I made a multistep form with help of $form_state. After each steps state(or values) of form elements stored in $form_state. In final step of my form, I like to use some third party library like plupload. But plupload buttons, are not defined in FAPI system and you can’t use something like below (maybe with help of _element_info hook, it would be possible)

      $form['anyform'] = array(
'#value' => t("click me"),
'#type' => 'plupload',
'#ajax' => array(
  'callback' => 'ajax_append_callback',
),

);

In plupload, when you press upload button, it send files to custom url that you set already.
I set url path of upload to ‘system/ajax’ (default drupal path for handling ajax request). In addition force plupload to post ‘fomr_id’ and ‘form_build_id’ of my form to ‘system/ajax’ path. This doesn’t work too.
I set url path of upload to my form page menu path. But drupal make my form reset and clean $form_state.


texts: How to exclude an user previously referenced in a field (User reference) from a Views block listing users?

texts:
Using Drupal 7.69

I have built a views block to list all users from a team, based on a taxonomy field as contextual filter (the team content type and users share the same taxonomy field).

This block is displayed on the team page.

One user is the leader of the team and he is referenced in an User reference field within the team content type.

This leader is listed in the block.

Now I need to exclude the leader from the block, since he is displayed in another block of the team page.

How to build the Views block so this user referenced does not appear on the users list when viewing the team page?

Thanks for any tips.


texts: Using an F5 server as reverse proxy cache (instead of Varnish)

texts:
Does anyone have any experience, positive or negative, with using Drupal behind F5?

Did you succeed or fail?

In either cases, what functionality did you achieve? How far did you get?


texts: How can I run functional tests from a custom module to test one specific mult-site instance?

texts:
I have tried to do a simple test of a module located on a sub site (Drupal multisite), but when the test looks for the module to activate it, it can not be found, if I move the module from the sub site to the modules folder that it is at the root of the installation if it finds it.

Is it possible to do the tests from the subsite? or do I necessarily have to move them to the root folder?

namespace Drupal\Tests\gonza_multiple\Functional;

use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;

/**
 * Simple test to ensure that main page loads with module enabled.
 *
 * @group gonza_multiple
 */
class LoadTest extends BrowserTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = ['gonza_multiple'];

  /**
   * A user with permission to administer site configuration.
   *
   * @var \Drupal\user\UserInterface
   */
  protected $user;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->user = $this->drupalCreateUser(['administer site configuration']);
    $this->drupalLogin($this->user);
  }

  /**
   * Tests that the home page loads with a 200 response.
   */
  public function testLoad() {
    $this->drupalGet(Url::fromRoute('<front>'));
    $this->assertSession()->statusCodeEquals(200);
  }

}


texts: Drupal 8 - Use the current node ID (on node edit form) to filter an entity-reference view as a contextual filter

texts:
I've got this view I just created, which lists all the events && publications related to a program (field_program, an entity-reference field) on my website (Drupal 8). Call it "view_program_related_contents".

I've got this content type (program), with a entity-reference field (field_promoted_contents). About this field, I want to use a view, because I don't want the webmaster to be able to promote events|publications related to any program but the one he's editing, so I have to filter the results based on the field_program field.

I did set a contextual filter (field_program) on my view. When this filter is not available, I fill it whith a default value : "Content ID from URL".

I can't manage to get my field_promoted_contents field populated with the well-related contents. If I set a static value (node id 1) in the contextual filter, it works, I only have the contents related to this first program. But when I set this "Content ID from URL".. I get no results :(

Do I have to pass a token (such as [node:nid]) as an argument to the view in the entity-reference field configuration ? Is there a module for that ?


texts:
I have this scenario in DRUPAL 7

A content type named "Students" with a field "Legal guardian" that references to a User (her/his legal guardian).

A content type named "Reports" with a field "Student" that references to a Student.

With these reports I can do a view with 2 contextual filters (student id/date) to display a chart with the data provided from an specific report (using google chart tools).

All works like a charm, the problem is about the security because the url can be altered by anybody and get info for any student.

With Rules I can control:

A student is visible if you are the legal guardian (or if you are an admin)
A report is visible if you are an admin. I don't know how to control the legal guardian (in Students) of the Student field specified in this content type. But anyway, cos this information is used only to generate the charts, I don't really mind.

The problem is, as you can guess, that I need to control the access to the view. Only users that are legal guardian of student specified in that report can access the information.

All that comes into my mind is to set some rules to change the owner of the contents (Student, Reports) to the legal guardian's user and control the permissions, but maybe isn't the best way.

Could you please help me?


texts:
I want to do a similar filter like at this page:
http://www.nasdaq.com/screening/companies-by-industry.aspx?industry=Technology

I have two vocabularies. Countries and Industryes.
We chose an industry, and then we choose from what country we want the company.
It show me a firms, witch are in one industrie, an example Technologies and in one country, an example Afrika. Not all countries, not all industries. Can someone help me with this? I´m sorry for my english. I will be grateful for any help. I use Drupal 7.


texts: Why does my site fail after restoring the database?

texts:
I tried migrating my Drupal live site to localhost to test it there. I followed the instructions in Migrating a site.

Cleared the cache
Disabled clean URLs
Enabled mod_rewrite

Then I backuped my live site database. On my localhost, I created a database with the same name as my live site and ran a clean install of Drupal 7.25. Everything worked. I installed the Backup and migrate module, and tried to download the database; after submitting the form, the local site simply became blank and I could not access it.

I checked the local database and found that the backup database was properly copied into it. So, probably, the issue is not with the database access permissions on localhost.

I cannot figure out what causes the local site to fail.

What are the possible reasons for such a failure?


texts: How to embed generic file media entities?

texts:
I'm using modules Media entity and Entity embed and Entity Browser, which all work fine for images and video.

Now I'd like to use the Media framework to also manage some PDF and other non-image documents and embed them into my nodes and other places. Uploading and managing generic documents works – I've tried both the "Generic file" provider, as well as the contributed "Media entity document" module.

But embedding is a nightmare. The embed dialog will let me display generic file media entities as either ID, title or thumbnail and optionally link to the media entity's page. All of this is useless to me. I don't want to allow visitors to access media pages, I'd like a simple link to the (downloadable) file instead.

Can someone tell me how to embed and make use of generic file media?


texts:
Given the following code, how can I print the SQL that is generated?

$bundle='my_bundle_type';
$query = \Drupal::entityQuery('node');
$query->condition('status', 1);
$query->condition('type', $bundle);
$entity_ids = $query->execute();

What I have tried:

__toString() doesn't work
dpq($query) throws an error


texts: insert read-only multilingual text to user registration form

texts:
I've added a 'Term of use' read-only description into the Drupal user registration form, but I would like to make it multilingual.
The corresponding code is in the begin of template.php (responsive is the theme name):

function responsive_form_alter(&$form, &$form_state, $form_id){
switch($form_id) {
case 'user_register_form': // the value we stole from the rendered form
$multi_regform = array(
'#type' => 'checkbox',
'#title' => t("Elfogadom a moderálási elveket"),
'#description' => t("A Magyar Térinformatikai Társaság (HUNAGI) hivatalos honlapján való publikálás és kommentelés lehetőségét a HUNAGI regisztrált tagjai ..... A közzététellel a regisztrált felhasználó lemond a bejegyzés feletti rendelkezés jogáról, későbbiekben anyagi vagy más jellegű követeléseket ezekre alapozva nem támaszthat. - A HUNAGI vezetősége - "),
'#required' => TRUE,
'#localize' => TRUE, // Does not function...
'#weight' => 1, // Adjust so that you can place it whereever
);
$form['terms_of_use'] = $multi_regform;
break;
}
}

You can check it here: http://hunagi.hu/hu/user/register

Now the text is Hungarian, can I add an English one someway?

ps: I've already tried this by Field addition by Field Group, Field Permissions modules, that did not work.


texts: PHP XML parsing + daily authentication request

texts:
I have a news provider who sends me non-RSS XML feeds through HTTP requests that then need to be parsed to be used on my site. However, my first request to the external server always has to be an authentication request which expires after 24 hrs. The authentication ID gets sent back to me as an XML tag attribute in the source code of an otherwise empty document. I then have to include this ID with every news request I send back to the news server.

Is there any way to automate this entire process through a series of Drupal 6 modules, or is it just best to write the code directly in the template files and schedule a daily task to request the authentication ID?


texts: Uploading xlsx-file changes permissions of the file? Errors when loading via PHPExcel

texts:
My goal is to let the user upload a xlsx-file and then read the file to create objects.
So i created a file upload page in my custom module where the user can upload a file via the 'file' form field and the read the file via PHPExcel (which was already present when i started working on the module so i used this instead of PHPSpreadsheet).

The problem is, that after uploading the file and loading it via PHPExcel, i get several errors:

ZipArchive::getFromName(): Invalid or uninitialized Zip object in PHPExcel_Reader_Excel2007->_getFromZipArchive()

ZipArchive::close(): Invalid or uninitialized Zip object in PHPExcel_Reader_Excel2007->load()

Trying to get property 'Relationship' of non-object in PHPExcel_Reader_Excel2007->load()

When reading the file directly from a folder via PHPExcel it works (with the same file) and the uploaded xlsx file opens without problems in Excel 2016.

After reseraching i suspect that this has something to do with file permissions and the uploaded file indeeddiffers from the original file in the permissions:

In the security tab of the uploaded file an entry "Authentificated Users" was added.

My question is: What causes my problems? Am i on the right ttrack? Why does this permission entry gets added? How can i stop the uploader to do this?

My code:

$form['file'] = [
    '#type' => 'file',
    '#title' => t('Choose a xlsx-file based on the template.'),
  ];

and:

  // Process the file provided by the user.
  $form_file = $form_state['values']['file'];

  $file_destination = 'public://';

  $validators = ['file_validate_extensions' => ['xlsx']];

  $file = file_save_upload('file', $validators, $file_destination, FILE_EXISTS_REPLACE);

  if (!$file) {
    watchdog('my_module', 'PHPExcel could not import! Import file missing.');
    return NULL;
  }

  $file_name = $file->filename;
  $import_file = $file_destination.$file_name;

  // Load the library and initialize.
  module_load_include('php', 'my_module', 'lib/phpexcel_1.8.0/PHPExcel');

  // Load the import file.
  try {
    $objReader = PHPExcel_IOFactory::createReader('Excel2007');
    $objPHPExcel = $objReader->load($import_file);
  }

  catch (Exception $exception) {
    drupal_set_message($exception);
    watchdog('rdp_cellmodel', $exception);
  }

  // read file etc.


texts: How to alter entity reference autocomplete field drupal 7

texts:
I have a node which have entity reference autocomplete widget field. I am referencing node of particular content type. But when I come to select node from entity reference field it shows all node created on particular content type. I don't want all node of  a content type only wants those node created by current user. Following code is working for select list and I am able to filter node created by specific user where $cType is the name of content type.

    function nirvana_item_offer($cType) {
      global $user;
      $nirvanaQuery = db_select('node', 'n')
        ->condition('uid', $user->uid, '=')
        ->condition('type', $cType, '=')
        ->condition('status', 1, '=')
        ->fields('n', array('nid', 'title'))
        ->execute();
      $result = array();
      if($nirvanaQuery){
        $result['_none'] = '- None -';
        foreach ($nirvanaQuery as $node) {
          $result[$node->nid] = $node->title;
        }
      }

      return $result;
    }

Above function is returning only those node created by current user. How can I achieve same for autocomplete widget.


texts: How do I migrate an image field with migrate 2 module on drupal 6

texts:
I have created my .module and .info and (one) .inc file.

I also have successfully used drush mi to import the data minus the images.

The images are in a related table in the database and are not being copied over when I run the migrate class. Here is my code:

    abstract class RoRMigration extends Migration {
     public function __construct() {
     parent::__construct();

     }
   }

    class RoRPagesMigration extends RoRMigration {
      public function __construct() {
      parent::__construct(MigrateGroup::getInstance('pages'));
      $this->description = t('Ruby on Rails Pages');

$this->map = new MigrateSQLMap($this->machineName,
  array(
    'page_id' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'description' => 'Page ID',
      'alias' => 'pid',
    )
  ),
  MigrateDestinationNode::getKeySchema()
);

$query = db_select('migrate_ror_pages', 'pid')
         ->fields('pid', array('page_id', 'title', 'content_subtitle', 'body_html', 'page_type',
          'redirect_url', 'published', 'meta_data', 'pretty_url'));

$source_fields = array(
 // TODO: Will add these other files later
 // 'banners' => t('Banners attached to this page; populated in prepareRow()'),
 // 'files' => t('Files attached to this page; populated in prepareRow()'),
  'images' => t('Images attached to this page; populated in prepareRow()'),
);

$this->source = new MigrateSourceSQL($query, $source_fields);
$this->destination = new MigrateDestinationNode('page_data');

// Mapped fields
$this->addFieldMapping('title', 'title');
$this->addFieldMapping('field_legacy_guid', 'page_id');
$this->addFieldMapping('field_legacy_content_subtitle', 'content_subtitle');
$this->addFieldMapping('field_legacy_html_body', 'body_html');
$this->addFieldMapping('field_legacy_page_type', 'page_type');
$this->addFieldMapping('field_legacy_redirect_url', 'redirect_url');
$this->addFieldMapping('field_legacy_published', 'published');
$this->addFieldMapping('body', 'meta_data');
$this->addFieldMapping('field_pathauto', 'pretty_url');

// We will get the image data from a related table in prepareRow()
$arguments = MigrateFileFieldHandler::arguments('file_copy', FILE_EXISTS_REPLACE);
$this->addFieldMapping('field_gallery_images', 'images')
     ->arguments($arguments);

// No unmapped source fields

// Unmapped destination fields
$this->addUnmigratedDestinations(array('status', 'promote',
  'revision', 'language', 'uid', 'revision_uid', 'created', 'changed', 'teaser', 'sticky', 'field_file_attached_file', 'field_legacy_link', 'field_legacy_byline', 'field_banner_image', 'path', 'pathauto_perform_alias'));
      }

      public function prepareRow($current_row) {

        $source_id = $current_row->page_id;

// This adds the images to the image_gallery field
$result = db_select('migrate_ror_pages_images', 'pic')
          ->fields('pic', array('filename_path', 'title'))
          ->condition('page_id', $source_id)
          ->execute();
$current_row->images = array();
foreach ($result as $row) {
  $image_data = array(
    'path' => $row->filename_path,
    'alt' => $row->title,
    'title' => $row->title,
    'description' => $row->title,
  );
  $current_row->images[] = drupal_to_js($image_data);
}

return TRUE;
    }
   }

So to be clear. There are two data tables migrate_ror_pages and migrate_ror_pages_images. The first table imports fine but the images do not import. The image table has a url to the image like this /sites/all/default/files/uploads/page_assets/images/filename.jpg and it has a title column, page_id, and image_id. There are more than one images per page.


texts:
On my user registration page, I would like to add a field where users can type in and select specific key words.

It is possible to make such a field using webforms. It would look as below:

However, my user registration form is not a webform, it is a standard Drupal form, provided by the user module.

I have managed to add a field to the registration form, of type 'List (text)' and then in the 'Manage form display' section there is an option to display it as radio buttons so the user can select more than one option. This works successfully, but what I would really like to achieve is the look above.

Are the use of webforms the only way to achieve this? I guess if I have to use webforms I would have to replace the whole user registration form with a webform.


texts:
I am maintaining a Drupal 7 site that was developed by another developer and I'm trying to
 move the search field on the results page to appear under the H1.  Currently the site has a search field that appears at the very top (above the top navigation) > after the user submits a keyword in the search field, they are taken to the Results page which has a second search field that appears right above the H1.

I know that the second search field on the Results page is within the $content['main'], but I can't seem to locate how to move the search field to save my life!  The script in the template.tpl.php file that contains the $content['main'] is pasted below.  I've checked the MySQL database (field_revision, field_data, & node tables), Structure (Panels, Mini Panels, Views, Pages, & Blocks), and content types -- all to no avail.

<?php if (!empty($content['main'])): ?>
<?php print render($content['main']); ?>

<? // debugging  ?>

<?php print_r($node); ?>

<?php
print '
var_dump
';
var_dump($content);
print '
';
?>
<? // debugging  ?>

Output from debugging script that was pasted below the $content['main']

var_dump
array(5) { ["search"]=> string(798) "

" ["header"]=> string(0) "" ["main"]=> string(4492) "

I've looked into Where does Drupal store the content of a node's body? but haven't found the search field in any of the suggestion yet.


texts: "Add an item to a list" using rule just works for plain text

texts:
I created a rule with an action which "Add an item to a list".
The value of the item to add is this (also see my picture bellow)

Voucher: [node:title].
The code for this voucher is [codigo-otorgado:value].
View the voucher: [node:url]

This item will be added to a field of the user which I created at admin/config/people/accounts/fields The details of this field are:

Name: My voucher codes
Type: Long text
Widget: Text area (multiple rows)
Text processing: Plain Text
Number of values: Unlimited

So far so good. When the rule is fired all is working right, but The problem is that the text is shown as plain text. As you can see there is a url and breaks lines that I need to print out.

I guess the first suggestion will be to change the Text processing of the field  to Filtered Html or Full Html, and so I did.

But then the tokens ([node:url], [node:title]..) inside the value doesn't work. The tokens are printed as it, instead of their values.

I know that Rules is very mature module and I'm sure there must be a way to do this. What am I missing here?


texts: How can I get Views pages with taxonomy arguments display to fire after URL Alias (Path Auto)?

texts:
Right now I have a Views page that shows all results of the content type it filters by. If there is a taxonomy argument present (Contextual argument: Taxonomy ID: validate by Name to taxonomy ID) then of course it filter those results as specified.

Everything works fine. My views structure is this:

Page:  for-sale (displays all for sale items).

w/ argument: for-sale/cars (filter just the items that have the taxonomy ID cars).

Everything falls apart when I turn on Path Auto. Path auto has to have the name as my views path with argument.

Before I turn path auto on, my views with argument display correctly. Once I switch it on, taxonomy takes over, and I get the default list of taxonomy terms as if you were viewing them at taxonomy/term/ID.

Obviously path auto, or url aliases, to show taxonomy is firing after my views and rerendering their output.

How can I reverse this? How can I have views fire after PathAuto and maintain the integrity of my view with argument?  I know there are a couple modules out there that could help, but I would rather adjust the firing order (weights) in Drupal somehow so that I can void the overhead of a module for just this.

Note, if you are wondering why I am trying to get these to work at the same aliased URL, it's all about duplicate content.  For-sale/cars shows the same thing (more or less) as taxonomy/term/23. I need global redirect to automatically handle this issue.  Please leave a comment if you know if a way to achieve this differently than how I am currently trying to achieve it.


texts: How to update a field programmatically and keep the fields format and array structure?

texts:
I'm trying to update a field with the format full_html. But when I'm updating the field, all the html tags will disappear and the old text is still there in the safe_value. So how can I update the the text in field and keep the existing structure and the html-tags?

I have tried this:

$node = $node_load($my_node_id);
$node->body['und'][0]['value'] = 'My new text.';

My field before editing

[body] => Array
    (
        [und] => Array
            (
                [0] => Array
                    (
                        [value] =>
My old text.

                        [summary] =>
                        [format] => full_html
                        [safe_value] =>
My old text.

                        [safe_summary] =>
                    )

            )

    )

My field after editing

[body] => Array
    (
        [und] => Array
            (
                [0] => Array
                    (
                        [value] => My new text. //All the html-tags are removed
                        [summary] =>
                        [format] => full_html
                        [safe_value] =>
My old text.
 //The old text is still there

                        [safe_summary] =>
                    )

            )

    )


texts: views_embed_view is overriding the output in hook_services_views_execute_view_alter

texts:
I'm working with Drupal 7.x with services 3.x and views 3.x module, below is the code which I've in my custom module. When I'm executing the same, views_embed_view() overrides the output of the whole view and displays only those values that are called by using views_embed_view(), any suggestion on this?

function module_services_views_execute_view_alter(&$output, $view) {
  if ($view->name == 'web_services' && $view->current_display == 'articles') {
    foreach ($output as $key => $value) {
      // I'm getting only this output
      $value->relatedArticles = views_embed_view('web_services', 'related', 140, 120);
    }
  }
}


texts:
How to add a translation file to a custom theme?

I did

my_theme.info.yml

'interface translation project': my_theme
'interface translation server pattern': themes/my_theme/translations/my_theme-%language.po

twig template:

 {% trans %}
  status
{% endtrans %}

{{ 'status'|t }}

/my_theme/translations/my_theme-fr.po:

msgid "status"
msgstr "statut"

msgid "statut"
msgstr "status"

followed by a

drush cr

The output is not translated when I am on the fr page (the default language being english).


texts: How to conditionally change email content from Webform submissions

texts:
Reading the docs I can see that you can conditionally change the recipient of a webform email based on a field value, but that's not quite what I want to do. I want to modify the content of the message based on a form input. For example, based on a webform field like:

Favorite Color:
[] Blue  [] Yellow  [] Red

Upon submission the user should receive totally different email messages saying either:

  You probably like the sky...

or

  You probably like bananas...

etc. (you get the idea).

Note: it would be clever and would solve this minimalistic example to create the options like

the sky|Blue
bananas|Yellow

and then use their tokens, but that's not an option in this case as it's multiple paragraphs of text I want to be different in the conditional messages.


texts: Failed opening install.inc' when upgrading Drupal 7.x core with Drush 7.x

texts:
I have Drush 7.x installed and when I run 'drush up', on a Drupal 7.x codebase, I get the following error:

Drush command terminated abnormally due to an unrecoverable error.
[error]Error: require_once(): Failed opening required '/home/user/public_html/core/includes/install.inc'

It seems like Drush 7.x may be looking for Drupal 8.x file structure. How should I be running this command?


texts: Making user profiles publicly accessible in Drupal 7

texts:
How can I make user profiles publicly available to anonymous users and search engine bots accessing my website?

Details: User profiles are not publicly accessible by default. Without being logged in to Drupal, if you try to access /user/123 for example, you get the You are not authorized to access this page error message. I want to display the user profile details instead.


texts: Create new content type with a user reference

texts: I have a process of adding contents where user1 has to search for user2, when user2 is found, there is a button that adds a specific content type (i.e. "Create a report for this user") for the searched user. then it goes to a page where i can enter information and save the content. how can i do this?


texts:
I've been trying to add a class to a drupal_set_message() function. i found one article that said it worked, but i could not get it to work on mine. am i missing something?

I have drupal_set_message(t('an error has occured'),'custom-error');

these are the only output i get from the html

×
an error has occured

any help would be appreciated.


texts: How to create a copy of ResultRow without reference?

texts:
I need to have different values in each row based on the same row, so I create $this_row from $row. But field_x contains the same value in rendered view. I guess the $row reference is the same and I tried clone $row without success and also deep_copy but it exceeded memory.

What else can I try?

# in ..._views_pre_render

$new_rows = array();
foreach ($view->result as $row) {
   foreach ($xs as $x) {
      $this_row = $row;
      $this_field = $this_row->_entity->get('field_x');
      $this_field->setValue($x);
      $new_rows[] = $this_row;
   }
}
$view->result = $new_rows;


texts: Can I change an element's key on a duplicated webform?

texts:
I was able to duplicate one of my forms and give its own unique machine-readable key. My concern is that the keys of its elements are the same as the keys on the original form.

I'm not given an option to edit the machine-readable key of an element on a duplicated form. Is there any harm in leaving that alone?

Would a unique machine-readable form key suffice?


texts: How to externally register a new user without accessing /user/register?

texts:
I have a (Drupal 7) site which uses LDAP to authenticate logins according to an Active Directory groups only.

In the Apache config file, the URLs '/user' and '/admin' are both blocked externally. This has been tested and they can't be accessed, neither can '/user/register'.

I have found that some randomly-generated-looking username/email address combinations have appeared on the site. They're created in a blocked state due to the new accounts setting of requiring Administrator approval for a new account. All of their 'last accessed' fields are 'never'.

My question is how the accounts could have been created from an external connection without accessing the URL '/user/register', or any of the other blocked URLs?


texts: Why is the method attribute removed from ?

texts:
I work on submitting form via Drupal's Mail API. I want to pass all data with POST method. While I add this parameter to my form it disappear after rendering.

Before rendering:

<form method="post" action="{{ current_path }}">
  [...]
</form>

After rendering the method is removed:

<form action="http://localhost/drupal/contact" data-drupal-form-fields="">
  [...]
</form>

Is there any other approach to get the POST method instead of default which is GET?


texts: Admin approval notification based on role choose by user on registration form?

texts:
I need to set admin approval for a particular role. I am using auto assign module to provide user to choose role on registration form.

authenticated users: Do not need admin approval

$form_state['values']['status'] = 1;

$form["account"]["status"]["#default_value"] = FALSE;

Try to use above line on validate function but not getting any success.


texts: Setting a date field via entitity_metadata_wrapper

texts:
I am trying to set a field of date type through usage of entity_metadata_wrapper but the although the field is created as datetime in mysql, and creating a node sets it with expected YYY-MM-DD HH:MM:SS format, when using entity_metadata_wrapper it fails.  The only thing I have managed to insert is timestamps, I have tried both Iso date format and the standard one.

Here is the line I am trying to use to update:

   // sets reminder date in db
   $wrapper->field_event_reminder_date->set($reminder_date->format("Y-m-d H:i:s"));

Thanks!


texts: Drupal Calendar highlight all days in block with views

texts:
I have calendar showing dates (start and end dates). When I create a calendar from the views template it adds several displays. The month display shows shows all days from the start to the end day highlighted with another color. But in the block display it does not highlights those days.

Below is the month display. I need the same in the block display.


texts:
Is it possible to use a WYSIWYG Editor such as a CKEditor for node titles in the node creation form?

Update: Okay, so let's suppouse that I am developing a newspaper, and I want the journalists to be able to set the size of the title (i.e. if it is a very important news, they will select big font size for the title, otherwise, if it's a regular news, the title size will be medium).

Is the correct way to achieve this through Display Suite Extras, and some CSS classes?


texts: How to configure node.js module on localhost

texts:
I am trying to setup node.js module on my localhost environment. I have tried different configurations but still not found correct way to make it work. In my log messages I get:

nodejs.config.js

    backendSettings = {
  "scheme":"http",
  "host":"localhost",
  "port":8080,
  "key":"/path/to/key/file",
  "cert":"/path/to/cert/file",
  "resource":"node_modules/socket.io",
  "publishUrl":"publish",
  "serviceKey":"",
  "backend":{
  "port":80,
  "host":"localhost",
  "messagePath":"/drupal738/nodejs/message"},
  "clientsCanWriteToChannels":false,
  "clientsCanWriteToClients":false,
  "extensions":"",
  "debug":true,
  "transports":["websocket",
  "flashsocket",
  "htmlfile",
  "xhr-polling",
  "jsonp-polling"],
  "jsMinification":true,
  "jsEtag":true,
  "logLevel":1};

server.js

var channels = {},
authenticatedClients = {},
sockets = {},
onlineUsers = {},
presenceTimeoutIds = {},
contentChannelTimeoutIds = {},
tokenChannels = {},
settingsDefaults = {
  scheme: 'http',
  port: 8080,
  host: 'localhost',
  resource: '/node_modules/socket.io',
  serviceKey: '',
  debug: false,
  baseAuthPath: '/nodejs/',
  publishUrl: 'publish',
  kickUserUrl: 'user/kick/:uid',
  logoutUserUrl: 'user/logout/:authtoken',
  addUserToChannelUrl: 'user/channel/add/:channel/:uid',
  removeUserFromChannelUrl: 'user/channel/remove/:channel/:uid',
  addChannelUrl: 'channel/add/:channel',
  checkChannelUrl: 'channel/check/:channel',
  removeChannelUrl: 'channel/remove/:channel',
  setUserPresenceListUrl: 'user/presence-list/:uid/:uidList',
  addAuthTokenToChannelUrl: 'authtoken/channel/add/:channel/:uid',
  removeAuthTokenFromChannelUrl: 'authtoken/channel/remove/:channel/:uid',
  toggleDebugUrl: 'debug/toggle',
  contentTokenUrl: 'content/token',
  publishMessageToContentChannelUrl: 'content/token/message',
  getContentTokenUsersUrl: 'content/token/users',
  extensions: [],
  clientsCanWriteToChannels: false,
  clientsCanWriteToClients: false,
  transports: ['websocket','polling', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'],
  jsMinification: true,
  jsEtag: true,
  backend: {
    host: 'localhost',
    scheme: 'http',
    port: 80,
    basePath: '/',
    strictSSL: false,
    messagePath: 'nodejs/message',
    httpAuth: ''
  },
  logLevel: 1
},
extensions = [];

I am using WAMP and I have installed node.js on my system and required packages(connect, express, request, socket.io,) in my sites/all/modules/contrib/nodejs directory.


texts: Grouping or adding classes to CCK form fields

texts:
I'm looking for a way to group sections of my CCK add/edit forms so that I can give users a form with sections instead of one long page. I'm already using Fieldgroup to group fields for display so what I'm looking for is something similar for grouping fields for editing.

I realize I can do this with large amounts of CSS, jQuery or adding custom templates but I'm looking for a more elegant solution.


texts:
I've a form that allow the customer to download every photos that a photograph uploaded before.
Here is my submit form :

 public function submitForm(array &$form, FormStateInterface $form_state)
  {
    $parameters = \Drupal::routeMatch()->getParameters();
    $shooting = Node::load($parameters->get('shooting_id'));

    $destination = \Drupal::service('file_system')->realpath('temporary://');

    $zipname = $destination . '/vos_photos_'.$shooting->id().'.zip';

    header('Content-Type: application/zip');
    header('Content-disposition: attachment; filename='.$zipname);
    header('Content-Length: ' . filesize($zipname));

    $zip = new \ZipArchive();

    $zip->open($zipname, constant("ZipArchive::CREATE"));

    foreach ($shooting->field_shooting_photos as $media) {

      $uri = $media->entity->field_media_image->entity->uri->value;
      $file_path = \Drupal::service('file_system')->realpath($uri);

      // Ajout de chaque fichier dans le zip //
      $zip->addFile($file_path, $media->entity->field_media_image->entity->name);

    }

    $zip->close();

    readfile($zipname);
    exit;

  }

This works great.
The only problem is when I unzip it, I get var/www/drupalvm/web/sites/defaults/files/{My content}
I would like to just have a simple folder files/{my content} without the long path before, or if it's not possible, simply {my content} when you extract the zip. Thank you
I'm pretty the problem can be solved in the addFile by giving a localname, I just can't figure out how to


texts:
I have a problem concerning the blocks in drupal.

I need to create a block that has additional fields, image and files, I am currently using the add block feature in Home » Administration » Structure and I just need to add two fields there so I can upload pdf's and images.

I was thinking that there must be a way to add those fields from the admin panel, without programming it by hand or installing modules? Is it possible ?


texts: Where can I add this jquery code to apply to a view block?

texts:
I have some jquery that I need to apply to a view that's being displayed as a block. The only template we're using for this particular view is views-view-grouping--my-view.tpl.php. I've tried adding the jquery to the beginning of this file, but as expected (because it runs recursively for each group) it's being added to the rendered source before every rendered group, instead of just once.

Where is the best place for me to add jquery code so that it's only added to the rendered source once? It's just two lines of code aside from the document.ready declaration, so I'd rather not have to put it in a separate file and call it conditionally from various page templates.


texts:
As you now, when we use node reference field in a data type, during inserting a content, a list is very simple and it shows only node title.

I want to know is there any way to customize the list. for example I want to add css classes to list or add additional field such as thumbnail image and other field in this widget.

Please guide me. How can I do that ?


texts: Views contextual filter by same Taxonomy Term Name with different Parent

texts:
I'm trying to filter a view with a path like this  "/view/%/%/%" , i'm having a hard time trying to filter nodes that belong to different childs but have the same taxonomy term name. This is the structure :

Term 1 (Ex Name : "Category grandfather1 test")

Term 2 (Ex Name : "Category parent test")

Term 3 (Ex Name : "Category child test")

Term 4 (Ex Name : "Category grandfather2 test")

Term 5 (Ex Name : "Category parent test")

Term 6 (Ex Name : "Category child  test")

And 2 nodes which belongs to Term 3 and the other to Term 6

When i get the results i always then those who belongs to Term 3 independently of the term that i put before as the parent and grandfather.

I'm using taxonomy term reference tree to load categories , already try auto checking both parent and grandfather.

Could anyone please help me with this ?

pd: sorry for my bad English!


texts: Can Drush make include username, password and settings in one file?

texts:
I hear some talk about Drush make and features.

But not sure how to use them in combination.

Is there a way to have a Drupal site install with ALL settings, including install procedure (enter database name, site name, username ect...)

Include what modules to enable, set user permissions.

I know that Drush can do some of that.

But is it possible to have it ALL done within the drush.make file, can I add standard drush commands to that?


texts:
I have a site where I use AngularJS to connect to Services module paths.

Now, we know that I need to send (for every put connection) the CSRF token into headers request, and this token is linked to user's session id.

My problem is that some users are currently logged into the system for Drupal (I can see all content for authenticated users ) but when I send a PUT request, Drupal return me the error of invalid CSRF token.

So, how can I retrieve a new CSRF token without logout the user ?

M.


texts: Webservice API for fblogin and twitterlogin

texts: I have to create an mobile app where user should login into drupal from their fb or twitter accounts. I have created an api to login into drupal but should I also need to pass the oauth token from mobile to Drupal?


texts:
Possible Duplicate:
  OG groups: How to check if user is a member or not?

I don't know how to use this: http://api.drupalize.me/api/drupal/function/calls/og_is_member/7

I want to check if user is a member of group or not.

Can someone help me?

Thank you!


texts:
I need to create a custom implementation of MailSystemInterface.

I created a file called my_module.mail.inc but I don't know how to load it and how to tell Drupal to use it by default.

I installed the mailsystem and autoload modules but don't know what to do next.

Any help would be greatly appreciated. Thanks


texts: Migrating Only DRUPAL7 DATABASE from Microsoft SQL to MYSQL

texts:
I have Drupal7 site which is running on Microsoft database,

My current requirement is to migrate from microsoft database to mysql database.

if we can migrate will there be no breakage in the present working site,

Any help on this?


texts: Having trouble getting Reference field option limit and Entity reference autofill to work together

texts:
I am working on an inventory system that would take a shipment and autofill the customer name which would then limit the commodity type. I am able to get the autofill and the limit to work separately but I can't them to work together so in one click both modules execute. As of right now, I have it so when you type in the shipment it autofills but then you have to press the customer again in order for the commodity to limit. Any help on getting these two modules to work together will be greatly appreciated.

Also, in the autofill module I have taken out the $overwrite or else the option to limit to commodity type doesn't exist.

Reference field options

Entity reference autofill


texts:
I want to post the content to facebook groups from a Drupal site. I am able to post the content to Facebook group by using the Facebook autopost module.

How to post the Drupal contents to Facebook group? How can I achieve this functionality? Facebook autopost has not implemented this feature yet.


texts: Commerce: How to manage line item fields for custom product type?

texts:
Drupal commerce works as follows:

When I add a product to the cart, system creates new line item (of type: product)

I have several product types. Could I achieve, that product line items would be specific for each product type?

What I would like to achieve is, that I can manage fields in line item type separately for each product type.
For now, I can manage fields (or manage displays) only generally for all product types (When I go to Store -> Configurations -> Line item types -> Product)


texts: How to create a custom frontpage using page--front.tpl.php and keep theme responsiveness

texts:
I want my frontpage to be displayed with a full width image, some H2 header text and a navigation menu.

However using a page--front.tpl.php and applying custom css i am losing the natural responsiveness of my theme (at-subtheme), leaving me to apply mediaqueries.

What would be the apporiate way to set up a custom front page using my theme responsiveness?


texts:
I need to display the outlook calendar in the same calendar format in a page. I need to add events to the calendar and synchronize it with Outlook.

What module should I prefer to both synchronize with Outlook and display as calendar?


texts:
I have a group of universities that have a director.  However, BYU has 2 directors.  I try and "group multiple values" and turn on distinct in the "basic settings", but then fields for only one director appear while both director names appear.

Basically I want the same layout as below, but Tracy and Carl to be on the same row with their contact information.

I've tried for a few hours and googled for another few hours... Thanks!

http://i.stack.imgur.com/awWQ4.jpg
http://i.stack.imgur.com/TdFxS.jpg


texts: How to use relations in Views to get Content type fileds when I use Taxonomy

texts: Good day. I have Content type with Taxonomy field. Right now I try to build Views by this Taxonomy vocabulary. And I want to use (how?) relations to get access to Content type fields. So, idea is to have View by Taxonomy, but use fields of content type, which has this taxonomy as field.


texts: How to add a 3rd party library and call it using Libraries

texts: I've installed the Libraries module. How can I add a 3rd party PHP library in my Drupal 7 project. How do I use hook_libraries_info()?


texts: how do I get the user ID other than the one for the current logged in user?

texts:
How do I the user ID of the account profile that an administrator user is currently viewing/editin? I can't use \Drupal::currentUser() as it always returns the administrator details.

I tried \Drupal::routeMatch()->getParameter('node') and \Drupal::request()->attributes->get('node'), but it returns this error:

  Call to a member function id() on null...(file path)


texts: How to create field instance with display none programmatically

texts:
I tried to create some fields and field instance programmatically in .install file.

And I need to set a specail field instance with display none.

I have google, but got nothing.

Does anyone have a solution ?


texts: I've been looking around the Internet trying to investigate how to publish a blog post via either rest APIs or other command line tools. However, I have not found a way to do this. How can I publish a blog post (or node) either through a command line, rest APIs, or another way programmatically?


texts: Trying to make changes to page (post/article) text just before they are rendered

texts:
I have a module that works fine but I cannot seem to get node_view hook to work - seems to never be called. As a test, I tried adding this to the dennis.module in sites/all/modules/dennis, but nothing happens (Drupal 7).

function dennis_node_view($node, $view_mode, $langcode) {

  echo "AAAAAAAAAA";

  $node->content['body'] = array(
    '#markup' => "bonjour!"
  );

  $node->content['body'][0]['#markup']="hello";
}

Ultimately I need to find keywords in the content and replace with other text. So easy in WordPress and Joomla but after days of trying I have got nowhere with Drupal. Please help!


texts:
This is not a question about how I translate the View's (display) title.

My scenario is that I have a views without a title, and use the Page Title module to still have a title for SEO.
The problem is that this title does not seem to be translatable.

I have looked at the hooks that are made available by the Page Title module, but they don't seem to get me where I want to go with this.

Can anyone suggest an approach to be able to solve this?


texts: Display/hide CCk field with custom PHP and rules or

texts:
I have custom variables stored in sessions, those variables are obtained remotely via URL arguments fired by remote website.

I am currently using Drupal 7, and I want to enable custom custom field A or B based on the value of the custom variable; if the custom variable is empty, it should enable field A, otherwise, enable field, B.

Can you please assist on what needs to be done?


texts:
I have run into an odd error with my gmap module where I allow users to use the map to choose the location (rather than enter coordinates, they are allowed to enter an address too of course) but back to the map.

What's off is that the map 'works' it's just that it starts off greyed out, but if you double click the map it pops up as normal (Google Streets). Has anyone run across this error before?

----- Edit-----

It appears that if you open up the page and the map is greyed out, if you adjust the size of the browser window even the slightest, the map will appear as normal. So where could this problem be originating from?


texts: How to grant a permission to edit terms for a specific user?

texts:
I have taxonomy terms with a user reference field. I want users to be able to edit taxonomy terms they related with.

I'm looking for something similar to hook_node_access or hook_node_grants with hook_node_access_records for nodes.

Is there a code/module to grant taxonomy permissions to specific users?


texts: How can I enable download link in the Media browser library tab

texts:
My media browser has a list of powerpoint and visio files:

How can I add a download link or preview it next to each file? The idea is to make it easier for user to choose which file they want before saving the content. I am using media module 7x-2.8.


texts: Preventing redirects from being cached for anonymous users

texts:
I have a content type that needs to redirect only when it is tagged as "External". All of these "External" items have a field where a URL is supplied for the redirect.

During initial setup of the content type the redirection was being done in the .theme file in preprocess_html but we discovered that after the first time someone was redirected when accessing one of these nodes, it would get cached and the redirection would not longer happen.

I then built a module to do the redirection with and event subscriber and this fixed the problem when logged in as an admin but not for anonymous users.

For the third iteration, I built a module to set up middleware that implements HttpKernelInterface in order to do the redirection there.
This particular content type had a url pattern so I used that to determine when the middleware should run based on the $request->getPathInfo(); and then testing for the node type and the "External" tag being applied to it.
That solved all of the redirection problems, but other started to pop up. For example, the edit form for all of the nodes started displaying on the the title field and nothing else and views using the content type would start displaying as empty as well.

Is there a more effective way of doing this redirection and avoiding the page cache than doing it with middleware or has anyone experienced an issue like this when implementing HttpKernelInterface?

handle function being used in the middleware:

public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {

$newsPrefix = "/news";

$current_uri = $request->getPathInfo();
if(substr($current_uri, 0, strlen($newsPrefix)) === $newsPrefix){
  $path = \Drupal::service('path.alias_manager')->getPathByAlias($current_uri);

  if(preg_match('/node\/(\d+)/', $path, $matches)) {
    $node = \Drupal\node\Entity\Node::load($matches[1]);

    if (isset($node)) {

      $nodeType = $node->getType();
      if($nodeType === 'news'){

        if(isset($node->news_type_of_content) && isset($node->news_type_of_content->target_id)){
          $typeID = $node->news_type_of_content->target_id;

          if(isset($typeID)){
            $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($typeID);
            $name = $term->getName();
          }

          if(isset($name) && $name === "External" && isset($node->news_source_url->value)){

            $response = new RedirectResponse($node->news_source_url->value, 302);
            $response->send();
            exit;
          }
        }
      }
    }
  }
}
return $this->httpKernel->handle($request, $type, $catch);

}


texts: Where is documentation for $entity->data property? I.e. $commerce_order->data

texts: I've searched google and the Drupal API, but I can't seem to find documentation for the data array that serializes/unserializes automatically that is attached to entities and stored in the data column on some entities, particularly commerce_order. Searching for the world "data" is like searching for the word "the." Where/how is the data array serialized and unserialized?


texts: How can I display a block content when a button clicked Drupal 7

texts: I want to display a block content when clicking the button on same page in drupal7. it will be like that  "hi" msg and button in same page and when clicking to the button "Welcome to Drupal" should come on the top of the page.How will I do that..


texts:
I have noticed in mysql that cache_form.MYD table is 14GB. Why did it grow so big? Is it safe to empty it? and how can I avoid this happening in the future?

Thanks


texts: Dynamic Form Elements state with multiple conditions

texts:
Can someone please help me figure this one out.  I have a form element that is dependent on certain values from another select.  It is only visible if certain values are selected.  I know i can do multiple conditions using different form elements.  However, how can i specify the same form element having multiple values.  Right now this only works for the last value.

$form['listing_attributes']['sort_by'] = array(
'#type' => 'select',
'#title' => t("Sort By"),
'#description' => t('How you would like the listing to be sorted by.'),
'#options' => array(
    'alphabetical' => t('Alphabetical'),
    'program_type' => t('Program Type'),
    'level' => t('Degree Level'),
    'subject' => t('Subject'),
    'category' => t('Category'),
),
'#states' => array(
  'visible' => array(
    ':input[name="listing_page"]' => array('value' => 'school_page'),
    ),
),
);

$form['listing_attributes']['group_by'] = array(
'#type' => 'select',
'#title' => t("Group By"),
'#description' => t('How you would like the sorted list to be grouped by.'),
'#options' => array(
    'program_type' => t('Program Type'),
    'level' => t('Degree Level'),
    'subject' => t('Subject'),
    'category' => t('Category'),
),
'#states' => array(
  'visible' => array(
    ':input[name="sort_by"]' => array('value' => 'level'),
    ':input[name="sort_by"]' => array('value' => 'category'),
    ':input[name="sort_by"]' => array('value' => 'subject'),
    ),
),
);


texts: Make a form that leads to a view with GET that won't overwrite proceeding AJAX filters on exposed filters

texts:
I built a custom form using the Form Render API on a page that is meant to lead to a view.
You can select a region and it will bring you to the page containing the view with the fields and results already generated from the GET variables. The form appears like this

<form method="get" action="/products" accept-charset="UTF-8" data-drupal-form-fields="range_selector">
<div class="js-form-item form-item js-form-type-select form-item- js-form-item- form-no-label">
<select id="range_selector" name="field_product_range_target_id" class="form-select"><option value="">Focus Area</option><option value="782">Poultry</option><option value="920">Protection</option><option value="787">Rabbits</option><option value="917">Soil</option></select>
        </div>
<input class="js-form-submit form-submit" type="submit" name="op" value="View Products">
</form>

Then on the /products page there is a view with an exposed taxonomy filter that accepts the GET var field_product_range_target_id as the default value. There are other fields being used in the form, but I removed them for the sake of brevity. I'm letting you know in case having multiple fields matters.

This works at first but then there's an issue, whenever the user uses the exposed filters when they've visited the page the GET vars overwrite whatever was being put in the fields, since it is using AJAX and not another GET request. I understand that it probably would work if I didn't use AJAX but it'd be nice to use AJAX and I'm running into a bug where everything is blank and the filters aren't shown in AJAX is turned off. I figured I could solve my problem by using a POST request instead of a GET one but that didn't work either.

How can I use a custom form to lead to a view with default values using the GET method without overwriting anything from an AJAX request from the exposed filters?

Is there a hook I can use to give the AJAX values priority over GET vars?

UPDATE: For more info here's the format of how the form is being created

                'form' => [
                    '#type' => 'form',
                    '#attributes' => [
                        'class' => [''],
                        'method' => 'get',
                        'action' => $this->configuration['url'],
                    ],
                    'range' => [
                        '#type' => 'select',
                        '#options' => $range_options,
                        '#attributes' => [
                            'id' => 'range_selector',
                            'name' => 'field_product_range_target_id',
                        ],
                    ],
                    'view_all' => [
                        '#type' => 'button',
                        '#attributes' => [
                            'class' => ['more-info'],
                        ],
                        '#value' => 'View Products',
                    ],
                ],


texts:
CKeditor adds many <p>&nbsp</p> tags for all new lines when editing as HTML source. I found a discussion:

http://drupal.org/node/669114

But I don't understand, how to fix it. If anybody fixed this, please, tell me, what should I write in CKeditor config file.


texts:
I am having a custom menu created in admin/structure/menu configured to nice-menus. and now I am trying to print that menu using my section.tpl.php file like

$nice_menu = block_load('nice_menus',"1");
print drupal_render(_block_get_renderable_array(_block_render_blocks(array($nice_menu ))));

What I see is only the menu title displaying on the page, when I inspect the html source in firebug I see the html needed for the menus are generated. This is frustrating me for the last couple of hours, is there is another way to print my nice menu using the template file?


texts: location fields are not appearing on feed mapping while location module is used inside field collection

texts:
I want to import field collection through feeds but since I’m using location module inside the collection module due to this it’s not appearing on target list as you can see the below screen short.
Field collection

Feeds Mapping

Guy can you please help me and I'm using Drupal 7.


texts: How to add custom page.html.twig for views page?

texts:
I have a view page with url and machine id search

I need to add a custom page.html.twig for that specific view page so that it does not affect the rest pages.

How can I implement it?

I tried adding page--search.html.twig but it did not work.


texts: Rendering a simple PHP array into an HTML table

texts:
I am trying to render a simple PHP array witch isn't a drupal render array, basicly it s something like this:

array(
  array(
    'Some Index:',
    ' Some value',
  ),
  array(
    'Some Index:',
    'Some value',
  )
);

I would like to render it as an HTML table, is there any out of the box API to do that ?

Thank all for the help,

Cheers


texts: Why I cannot change views page title using views_post_render?

texts:
I have view that uses url args: parent term id and term id/ids, so the url structure is like page/%/%

Title pattern for this view is: %1(%2)

However I have few pages with multi tids as second argument, so generated title is strange (very long). I am trying to change this title programmatically:

function bip_title_alter_views_post_render(&$view, &$output, &$cache)  {

    if ($view->name == 'kategorie_artykulow' && $view->current_display == 'page_9')
    {
        $args = explode(' ', $view->args[1]);
        if (sizeof($args) < 2) {
            return;
        }
        $title_pattern = 'Archiwum Oświadczeń Majątkowych w %dr.';
        $term = taxonomy_term_load($args[0]);
        if (! $term) {
            return;
        }
        $title = sprintf($title_pattern, $term->name);
        drupal_set_title($title);
    }
}

function bip_title_alter_module_implements_alter(&$implementations, $hook) {
    if ($hook == 'views_post_render') {
        $group = $implementations['bip_title_alter'];
        unset($implementations['bip_title_alter']);
        $implementations['bip_title_alter'] = $group;
    }
}

but title remains the same, I am sure that I am altering proper view.

Adding another display to view is not good option for me, because I have a lot existing urls and if I create another display with the same url structure and different args config always first display is handling request.

edit

I changed my custom module weight in system table to 9999 and I still see that title is altered after my module hook :/ It's so annoying


texts: How to get the node ID in jQuery/JavaScript

texts:
Is there a definitive, universal way to do this? For example using some environment variable that comes with Drupal.behaviours?

I have done some research and there seems to be no common answer.


texts: Loading term references into a custom module

texts:
I have a term reference field in my content type. I'd like to be able to access the vocabulary items from that field in a custom module so I can pre-select one based on a users selection of an item from a field list. How is this possible?

An example might help illustrate the problem:

Content type: resource
field 1: Category (field list)
field 2: Group (term reference, hidden)

User selects one of eight options in the 'field 1' drop down select box. Selections include things like 'paper', 'metal', 'stone', etc.
The hidden 'Group' field detects which selection the user made above and auto-fills itself by selecting the vocabulary item in the associated taxonomy that maps to the selection they made. There are only three possibilities for 'Group' however so I'd also have to specify in the module WHICH selections from the field list map to which terms from the taxonomy to make sure the selections are correct.

For example, if a user selects 'paper' in the field list then Group should auto-select the term 'recyclable' before saving the record.

Anyone know how to do this?

I was going to approach it with hook_form_alter and hook_node_presave...but I'm not very comfortable with coding in modules yet.

Thanks!


texts: give value to form element after select event - value should be catched with JQuery

texts:
I'm pretty new with Drupal & JQuery. I post this question because I was not able to find a solution in the net.

I have a select form element to choose a country. This select displays de country names but keeps the country_code because this is the value to be stored in the DDBB once the form submitted. This select element is linked to ajax because there is a second select field which should show values depending on the selected country.

As soon as the complete address is introduced, JQuery should show a map with the location of the entered address. For that reason I need JQuery to access the country name before the form is submitted.

There is a function that returns the country name for a given country_code but I do not know how to run that function so that the result can be catched by JQuery. One solution would be keep the country_name instead of the country_code (in the select element) but then , into the submit function of the form, I would need a function to get the country code and I would like to avoid this.

$country_list=get_country_list();

$form['c_pais'] = array(
'#title' => t('Address - Country'),
'#type' => 'select',
'#options' => $country_list,
'#required' => TRUE,
'#default_value' => $value_country,
'#ajax' => array(
    'event' => 'change',
    'callback' => 'call_region1_select',
    'wrapper' => 'dropdown_region1',
),
);

function get_country_list()
{
    db_set_active('mydb');
    $result=db_select('country_list')
    ->fields('country_list',array('country_id','country_name'))
    ->orderBy('country_name','ASC')
    ->execute();
    $llista_paisos['0']='--- chosse a country ----';
    while($node = $result->fetchAssoc())
    {
        $llista_paisos[$node['country_id']]=$node['country_name'];
    }
    db_set_active();
    //print_r($llista_paisos);
    return $llista_paisos;
}