texts: How to resolve Integrity constraint violation: 1062 Duplicate entry on node_access?

texts:
So I am looking all over and have yet to find out how to remedy this table issue.

Rules is the likely culprit because the violation occurs when creating a new node (with Workflow) and trying to have it move forward to a state called publish. It fails with PDO Integrity Constraint Violation 1062.

Now the problem is that NO new nodes can be created without error, by any user. How can I fix this? The error message references a node ID that doesn't exist in any table rows, I guess because the node was never actually saved.

I have adjusted Rules so this doesn't happen again on new nodes, but I need to get that error off without losing data.

The error message is the following one:

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry "694-7-workflow_access" for key "PRIMARY": INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES ....

This is weird because I have completely truncated the table, deleted and added it back, and tried to build a new copy of the DB all without success. I can't for the life of me find the primary key duplicate in ANY table. These nodes, node revisions, or node access records simply don't exist for nid 694 (or anything above 660 really).

So far I have traced it to Workflow's use of hook_node_access_records(). If I comment out module_invoke('node_' . $op, $node) the nodes will submit, so it is definitely the access table/process causing the problem. Workflow returns a $grants array just fine.


texts:
I have a select box named field_ee_project . I want to add the select box options dynamically on hook_form_alter .

What i have tried

    function gamodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {
       //check whether the form is effort estimation
        if($form_id = 'node_effordestimation_form'){
            $form['field_ee_project']['und']['#options'] = effort_estimation_project_autoload();
        }
     }

    /*
     * Effort estimation project field select box
     */
    function effort_estimation_project_autoload(){
            $matches = array();
            $result = db_query("SELECT ga_id,name FROM ga_projects");
            $row = $result->fetchAll();
            $row = json_decode(json_encode($row), True);
            foreach ($row as $key => $value) {
                $matches[$value['name']] = $value['name'];
             }
            return $matches;
    }

But it is not working . Any idea ?


texts: I can't set a default value on hook_form_alter()

texts:
I have form alter for the user_register_form which is called.
In this hook, I try to set a default value for a textfield but it doesn't work.
I've tried all the syntax possible #default_value, #value, value, default_value, event in the attributes array.

This is my code.

function pre_registration_form_user_register_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $form['field_code_postal']['#cache']['max-age'] = 0;
  $form['field_code_postal']['#default_value'] = 'COUCOU';
  $form['field_code_postal']['#value'] = 'COUCOU';
  $form['field_code_postal']['value'] = 'COUCOU';
  $form['field_code_postal']['value']['#value'] = 'COUCOU';
  $form['field_code_postal']['value']['#default_value'] = 'COUCOU';
  $form['field_code_postal']['value']['value'] = 'COUCOU';
  $form['field_code_postal']['value']['default_value'] = 'COUCOU';
  $form['field_code_postal']['default_value'] = 'COUCOU';

  $form['field_code_postal']['#attributes']['value'] = 'COUCOU1';
  $form['field_code_postal']['#attributes']['#value'] = 'COUCOU2';
  $form['field_code_postal']['#attributes']['default_value'] = 'COUCOU3';
  $form['field_code_postal']['#attributes']['#default_value'] = 'COUCOU4';
}

How can I set a default value?


texts: View Template Override that is full page

texts:
I need to create a template for a view i've created (which I know how to do) but I don't want the page to be wrapped in the drupal html.php code. I want the resulting page to be only what is in the template file I create.

How do I do this? I looked online for examples but coudn't find anything.

Thanks
C

EDIT:

I found this which does what I need for content types lab

function yourthemename_preprocess_html(&$vars) {
  if ($node = menu_get_object()) {
    if($node->type == "lab") {
      $vars['theme_hook_suggestions'][] = 'html__lab';
    }
  }
}

Then created a file called: html--lab.tpl.php

Can this method be used for me view?
does it have to be if($node->type == "lab")?
can I use something like if($view == "viewname")

Thanks


texts:
I'm using sharethis 7.x-2.4 with panels 7.x-3.2

Previously, when I was using sharethis 7.x-2.2, there was no option to insert sharethis in panels. Since upgrading, it appears in the 'miscellaneous' category. But after inserting it into a pane, the sharethis buttons don't appear on my panel node pages.

I've tried setting the sharethis location to 'block' (as described in ShareThis in header rather than content type?)
and then re-entering it in the panel, but it still doesn't show.

Sharethis is displaying normally for content types that aren't using panels.

Any help greatly appreciated!


texts: I'd like to attach a library to a custom 404 page.  I'd like to do this in my theme file.  How can I know if the current response will be a 404 Page Not Found?


texts: Composer install dependency error drupal/drupal dev-master

texts:
I'm managing my site dependencies via composer, most of the times works really well. Now I installed my site on a new server, using the exact same code-base as before (but with composer 1.8.0 instead of 1.7.x as before though). On running composer install I get the following error:

  don't install drupal/core 8.6.4|remove drupal/drupal dev-master
  remove drupal/drupal dev-master|remove drupal/core 8.6.4
  Installation request for drupal/drupal dev-master -> satisfiable by drupal/drupal[dev-master].
  Installation request for drupal/core 8.6.4 -> satisfiable by drupal/core[8.6.4].

Usually I can solve these sorts of errors but this time I'm having a hard time. What's the meaning of drupal/drupal dev-master, because usually you do not specify this anywhere directly?


texts: How to remove the comma between Link multi-value field

texts: I am using the Link module's link field. When I create a multi-valued field, it automatically adds a comma between them. I would like to remove this comma. For some other field types, such as term reference, I believe there is a way to set this in the UI, but I don't see this for the Link field.


texts: How to override function system_send_email_action_validate

texts:
The following is in the core system.module

/**
 * Validate system_send_email_action form submissions.
 */
function system_send_email_action_validate($form, $form_state) {
  $form_values = $form_state['values'];
  // Validate the configuration form.
  if (!valid_email_address($form_values['recipient']) && strpos($form_values['recipient'], ':mail') === FALSE) {
    // We want the literal %author placeholder to be emphasized in the error message.
    form_set_error('recipient', t('Enter a valid email address or use a token e-mail address such as %author.', array('%author' => '[node:author:mail]')));
  }
}

This is stopping VBO send email from sending email to a CCK email field.
How can I override this function? I want to change it to the following...

/**
 * Validate system_send_email_action form submissions.
 */
function system_send_email_action_validate($form, $form_state) {
  $form_values = $form_state['values'];
$has_tokens = count(token_scan($form_values['recipient'])) > 0 ? TRUE : FALSE;
  // Validate the configuration form.
  if (!valid_email_address($form_values['recipient']) && !$has_tokens) {
    // We want the literal %author placeholder to be emphasized in the error message.
    form_set_error('recipient', t('Enter a valid email address or use a token e-mail address such as %author.', array('%author' => '[node:author:mail]')));
  }
}

But without hacking core. Is there a way to do this in my custom module? Im having a bit of trouble understanding how overriding a module function works, in theme functions, I can just replace the function in mt template.php using the name of my theme, however MYMODULE_system_send_email_action doesnt work.


texts: Geolocation and view proximity filter - Can you default proximity to zero?

texts:
I'm trying to see if there is a way to default the views proximity filter to input zero for proximity values when the filter is empty, so we can sort the data using a different field by default.

What I've got currently

A view that lists location nodes (that use the geolocation module) using the 'Content' show/render. The format settings is set to force fields, so we can set the proximity field information. The view has an exposed proximity filter using Google Geocoding, and the proximity field is set to center off of this proximity filter.

Additionally, the view is sorted first by proximity, and second by title.

Proximity filtering works

When users type in an address, the view sorts by proximity, and works as expected.

Desired Outcome

A user visits the page, the locations are sorted by title alphabetically, then if an address is entered into the filter the locations are sorted by proximity first and then title second.

What happens now

When the page is initially loaded and nothing is entered into the filter the proximity the locations appear to be sorted in an arbitrary/random order. If you display the proximity, it's clear it's still sorting by proximity, but I don't know based on what.

Are there any suggestions to configure this differently? Are there hooks I could access to override the proximity value to zero if the filter is empty?

I've Googled a fair bit, and tried searching the issue queue, but haven't been able to find any direction that way so far. So thanks in advance to anyone that is able to offer any help or direction.


texts: JSON:API error unprocessable entity status 422 entity_id this value should not be null

texts:
I'm trying to post a flag with JSON:API but I'm getting the following error:
"errors": [
    {
        "title": "Unprocessable Entity",
        "status": "422",
        "detail": "entity_id: This value should not be null.",
        "source": {
            "pointer": "/data/attributes/entity_id"
        }
    }

I'm very confused because in the data I'm posting, the entity_id is definitely included...


texts: How to get rid of the '-' sign before sub taxonomy term?

texts:
when I choose a taxonomy term with a parent, it shows -termName instead of termName, to indicate it is a sub-category. I checked the database, it only stores the termName, which means that somewhere we can rewrite the output to show just termName.

How can I achieve this?


texts:
I asked a question a few days ago about getting the height of images to adjust in Slideshow along with the width. Unfortunately, I received no responses.

So, I went about writing some JavaScript that adjusts images in a page the way I would like the images in Slideshow to be adjusted. The code works fine on regular Drupal pages, but does not work for the images in Slideshow.

Does anyone know how to get the JavaScript to work for the images in the Slideshow? I should state that I am brand new to coding and JavaScript, so there may be some issues with the code below, but it does work.

Here is the JavaScript code:

function myFunction() {
  var x = document.getElementsByClassName("slide");

  for (i = 0; i < x.length; i++) {
    var viewHeight = window.innerHeight;
    var viewWidth = window.innerWidth;
    var viewAspect = viewWidth / viewHeight;

    var imageHeight = x[i].height;
    var imageWidth = x[i].width;
    var imageAspect = imageWidth / imageHeight;

    if (imageAspect < viewAspect) {
        x[i].style.height = viewHeight + "px";
    }
    else {
        x[i].style.width = viewWidth + "px";
    }
  }
}

window.onload = function() {
  myFunction();
};

window.onresize = function() {
  myFunction();
};


texts:
I want to move the page breadcrumb to the content region in Bartik (D7.)

I assume it is theming but I can't find anywhere (style.css, layout.css) where the breadcrumb is assigned in the first place.

Does anyone know how to do this?

Thanks. :)


texts: Drupal installed with Drush doesn't display home page

texts:
I installed Drupal with Drush and it all works fine and the welcome page appears as well. But when I try to log in (with whatever account) it shows me the: "Object not found! The requested URL was not found on this server...." page.

I am on Arch Linux. I checked the httpd.conf file and mode_rewrite engine is enabled:
  "LoadModule rewrite_module modules/mod_rewrite.so"

I was also suggested to check the .htaccess file extension, but it has no ".txt" extensions.

Also, I went to index.php?q=user url and it did respond: opened the User account page.

I am still suspecting something with httpd.conf and .htaccess fils, but they look fine to me. I failed to find any resource related directly to this problem.

Just to clarify further. Both /drupal and /drupal/index.php urls are displayed without errors. But when I try to log in as an admin (or any user) and submit it, it shows the error page I described above. Which is a problem, because I can't even enable clean urls, as it requires permissions for that.

I checked if the httpd.conf file (as suggested by comment below) is configured
 to read the .htaccess file:

AccessFileName .htaccess

And although the file was missing that section, I found out that httpd.conf file
 reads .htaccess file by default, if not configured otherwise. Despite this, I added that line, but it still shows the same error when logged in.

Also, the following are the httpd.conf lines:

DocumentRoot "/srv/http"

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
</Directory>


texts:
How to integrate number search along with string search in drupal 7?
As of now,I was able to implement string search i.e a user can search via name,place etc but I want to  implement number search so that users can search via postal code, date of birth, etc.


texts: Taxonomy menu - link to first node associated with term?

texts:
I have a taxonomy menu block using the vocabulary 'Projects' that links to the terms: 'Bridges', 'Buildings' and 'Boats'.

Currently, each menu item links to a page that lists teasers of all the nodes associated with the menu term. For example, I click on 'Buildings' and it goes to a page with teasers of all nodes associated with 'Buildings'.

How could I have the menu term link to the latest node associated with that term directly? To continue the example, I click on 'Buildings' and it takes me to the latest 'Buildings' node.

The list of teasers is unnecessary as I will be employing elements of the teasers in an aside on each node directly.


texts: node_save() casing 500 Internal Server Error - 48s when using with AJAX

texts:
global $user;
$node = node_load($_POST['expire_offer']);
$node->field_status['und'][0]['value']=0;
$node->field_expire_date['und'][0]['value']=time();
$node->revision = TRUE;
$node->uid = $user->uid;
$node->log = 'This offer expired from rate manager expire ' . date('m-j-Y');

node_save($node);

When I remove node_save($node); it loads properly.


texts: States visibility in type select and radio in drupal 7

texts:
I have a custom form

$form['basic']['legal_form'] = array(
  '#type' => 'select',
  '#options' => array(
    'option1' => 'option1',
    'option2' => 'option2',
    'option3' => 'option3',
  ),
  '#title' => 'My Dropdown',
);
//radio button to show if selected option3
$form['basic']['bearer_shares'] = array(
  '#type' => 'radios',
  '#title' => 'Radio Button to show',
  '#options' => array(1 => t('yes'), 2 => t('no')),
  '#states' => array(
    'visible' => array(
    ':input[name="legal_form"]' => array('value' => 'option3'),
    ),
  ),
);

I try too

':input[name="legal_form"]' => array('selected' => 'option3'),

If I change type to textfield it works as expected but not when I try to use radio. Can anyone suggest me what I am doing wrong.


texts: added date filter to one of the views shows ajax error:length undefined

texts: I have added a date module to my site and used date filter in views i.e. to search news content through date. This filter works fine in preview section, but in main page it shows Ajax error as length undefined.


texts: Why does deleting a node ALSO invoke hook_node_update?

texts:
I need to respond to an update event and regenerate a file, but when the node is deleted, the file should also be deleted. However, the problem is, everytime a node is deleted, the hook_node_update is ALSO called, which regenerates the file.

How can I differentiate between a node being updated (NOT deleted) and a node being deleted?


texts: How to force a cron run after a Rules component is scheduled?

texts:
This question is a sequel on Why is the database not updated before a next Rule is launched?. I have a Rule that schedules a Rules component 5 seconds after the current time (this number is arbitrarily chosen). Since this component uses information from a frequently changing View, it should be executed as soon as possible. However, in my current configuration, that only happens when cron is run; which takes place once in an hour.

Can I somehow force a cron run (eventually with Rules) when the Rules component is scheduled?


texts: Added fields don't show up at a content creation form

texts:
I tried adding location type of field to gather reviewed place's location. I did everything properly and it didn't show up at a creation form, when trying to submit it said I was missing my location info but I couldn't see where to fill them. I checked everything * Things that I tried to do:

Re-creating field
Adding simple text field
Flushing all cache
Deleting my custom style for creation form
Checking Developer tools with F12 to see if there is a div element for these entries

I am not sure what else should I try. Maybe someone can put me on a track?


texts: How to implement a "switch" in a rule set?

texts:
I would like to make a rule set that functions as a switch with breaks in PHP.  Example:

Rule 1- User has role A, redirect to 1
Rule 2- User has role B, redirect to 2
Rule 3- User has role C, redirect to 3
Rule 4- no conditions, redirect to 4

In other words:

If a user has role A, redirect to 1.
If a user has roles B and C, redirect to 2.
If a user does not have roles A, B, or C, redirect to 4.

Is there an easy way to do this in Rules?


texts: How to display only one block in custom page using tpl?

texts:
How to show only block and hide all other menus,blocks etc.,
This is my code

function example_menu() {
  $items['appointcal'] = array(
    'page callback' => 'example_show',
    'access callback' => TRUE,
     'type' => MENU_CALLBACK,
   );
     return $items;
}

function example_show() {
  return theme('example_cal');
}

function example_theme() {
  return array(
    'example_cal' => array(
      'render element' => 'elements',
      'template' => 'templates/examplecal'
    )
  );
}

My examplecal.tpl.php is

<div>
  <?php
    $block = module_invoke('views', 'block_view', 'example-block');
    print render($block['content']);
  ?>
</div>

There is need to show only region that is in red color and hide all other regions.


texts: Is there a module that helps link similar articles together and insert them into each other?

texts:
I'm looking for the module that would allow me to manually link related articles together and to then set them to appear within the body of content - as links.

What would be your recommendation?

I tried to find different modules, but I need specifically something that could work by me simply creating links between different articles on a separate module settings page, so I don't have to enter into the EDIT mode for each article to add the connection.


texts: Drush, Omega 4 - Does not seem to recognize Drupal site

texts:
I've installed Drupal 7, Drush 7.0 and the Omega 4 theme. I'm using MAMP. Drush does not seem to recognize the /Applications/MAMP/htdocs/newsite/ as a Drupal folder (which it is). I'm attempting to create an Omega subtheme with the command line.:

drush omega-wizard

I then receive the following error:

And then this when I debug:

Thoughts? Help!!!

-Logan


texts: Autosave nodes, when editing or creating new ones, in database

texts:
Looking for a way to actually save nodes every x seconds when creating or editing.

I am aware of the Autosave module, which is a great module but it only saves the forms on clientside and has quite it's issues and conflicts with several other modules on my website (jQuery Update, Drag 'n' Drop Upload,...)

So basically I'm looking for a way to save a node automatically in the drupal system, even when creating a new one. Some sort of "draft" function like Gmail uses for unfinished mails.

I think the best shot is to use an ajax script which runs every x seconds, but have no idea how to get it into the database...

Anyone who is aware of a similar module or could point me in the right direction how to achieve this?


texts: Is it OK to programatically access fields defined through the UI?

texts:
This is a question about "best practise". I've taken over a project which I'm working on right now, and the custom modules this project comes with all access fields defined through the UI. In other words, the field names are "hard coded" in code - even though the fields are not defined in code. Is this alright?

I'm thinking that the code depends on data (in fields) which it has no guarantee will be there. Anyone could delete the fields at any time.

If you need to access fields from code, how do you make sure that the fields exist? Do you make sure that the modules define the field (programatically)?


texts: How to optimize APC when running many sites with common codebase?

texts:
When having many (+100) drupal sites on a server with a common codebase, what is a good setup to achieve good APC performance?

a) Increase APC memory to something really large (>10GB)

b) Less sites per server

c) Drupal multisite

d) Pseudo multisite. Shared Drupal core symlinked to each site.

e) ?

I would prefer option d). Will APC cache the absolute path to each file?


texts: How to build drupal-twitter bot like the one on drupal.org

texts: I'm really impressed by this bot:  drupal8changes which gets changes from http://drupal.org/list-changes/drupal and posts it on to Twitter. I think it might be something like, when a new node is created of D8Changes content-type, then post it on to twitter. Isn't it awesome? I want to know how that could be implemented? Not just limited to twitter, but for Facebook, Google+ etc.


texts: how to notificate users about new created referenced nodes

texts:
I have a content type called "A" and content type called "B". When a user creates node "A" other users can create node "B" referenced to node "A". How can i notify user which created node "A" about newly created nodes of type "B" referenced to his node "A"? I've tried notifications module but as i can understand there's no such options for that.. Tried this solution: how to create rules to send email notification for node reference content?
but it's not working on D7


texts: minifying css in drupal and getting the original source css

texts:
We have inherited a drupal 7 installation.  We have the source code. When we look on the front end there are series a of minified css files named like below. We are interested in getting the original source css files. I have no experience in drupal css minification. Does this kind of output look like out the box drupal minification. If so is there a location that specified the exact css that was used?

 <link type="text/css" rel="stylesheet" href="http://www.mydomain.com/sites/default/files/css/css_pbm0lsQQJ7A7WCCIMgxLho6mI_kBNgznNUWmTWcnfoE.css" media="all" />
<link type="text/css" rel="stylesheet" href="http://www.mydomain.com/sites/default/files/css/css_hYCLW089C9S9sP3ZYkuG6R-Q5ZHbEhblZBFjwZ_bE_I.css" media="all" />
<link type="text/css" rel="stylesheet" href="http://www.mydomain.com/sites/default/files/css/css_YYoEBheeHSoZ5EBVRncs-cuvNClW-5FNm_tmYaEdRwM.css" media="all" />
<link type="text/css" rel="stylesheet" href="http://www.mydomain.com/sites/default/files/css/css_5-5L742ZPRdlG5Jq9Yz3AIRJ3MBxYr6H_bolFIoqd68.css" media="all" />

Each css file that we see on the front end is collection of multiple css files.


texts: How can I add a "target" attribute to a custom form?

texts:
I've made a custom form in a module in Drupal 8, but I'd like to add target="_blank" in the form tag. When I try to add it in $form['#attributes']['target'], the attribute is shown in the wrapper of the form and not in the form tag itself.

Does anyone have an idea where this could be done?


texts: In Drupal 7, teaser view doesn't show the image filed because the image filed in the content type can have multiple images?

texts:
I've added an image field in a content type, and set the 'Field Settings' -> 'number of values' to unlimited, which means users can upload unlimited images for this field.

then I build a view for this content type and expose the image filed to the view. what I 'd like is to expose only image in teaser view, and all images in the full view.

I use a template preprocess function

function MYTHEME_process_field(&$vars) {
  $element = $vars['element'];
  // Field type image
  if ($element['#field_type'] == 'image') {
    // Reduce number of images in teaser view mode to single image
    if ($element['#view_mode'] == 'teaser') {
      // something might be wrong here
      $item = reset($vars['items']);      // not working
      $vars['items'] = array($item);      // not working
    }
  }
}

In debugging this function, this 2 lines

  $item = reset($vars['items']);
  $vars['items'] = array($item);

doesn't seem to work. any suggestion?


texts: Converting a timestamp to PHP date format for a field in a node template

texts:
I have an imagefield, 'event_image' and printing all possible variables for the field tells me I have timestamp as a possible variable of the image to render. I use:

print '<pre>';
var_dump(get_defined_vars());
print '</pre>

// renders:
["timestamp"]=>
string(10) "1348629688"

... in node--mycustom.tpl.php to get the variables.

Now I can render the timestamp as such:

<?php print $node->field_event_image['und'][0]['timestamp'] ?>

... and it prints a UNIX formatted timestamp as:

1348629688

I'd like to convert this to a PHP date format. So I am guessing I would need to convert the UNIX timestamp somehow using the PHP gmdate function. Typically I would use something like this for raw php:

  $mytimestamp=1348629688;
  print gmdate("m-d-Y", $mytimestamp);

Which would take my timestamp and output:

09-26-2012

... but I just don't know how to do within the context of my drupal 7 field and the node template.

UPDATE:

Base on clive's comment below, it turns out a preprocess function is the way to go:
So in my theme's template.php file I now have:

function MYTHEME_preprocess_node(&$vars, $hook) {

$node = $vars['node'];
$field_items = field_get_items('node', $node, 'field_event_image');
$vars['upload_date'] = format_date($field_items[0]['timestamp'], 'mdy');

}

... and then in my custom node template, I have:

<?php print $upload_date; ?>

Note, 'mdy' is a custom format I set in the Drupal UI. That's better than using gmdate I suppose.


texts: I can use "content access module" to make the nodes un accessable to other users. but the issue is i have is the number of users in this is more than 2000 and applying content access manually is a difficult task. so kindly suggest me how to make it automatic so that it should activate at the time of user registration


texts: Changing Template of a Category Page and showing all the posts of the category

texts:
I am trying to change the template of the category page in Drupal 6.

What I am hoping to do is that when a certain category's link is clicked the template page that opens shows all the posts with the category.

I did create the page page-taxonomy-term-tpl.php which opens when I click on category but how do I personalize it by showing all the posts within the category?

Many Thanks.


texts:
Short question:
How do you modify the destination on comment post?

Long question:
Say, my comment limit is set to 10 per page. When I post the 11th comment, Drupal takes me to /node/#?page-1#comment-#. Instead, I want it to take me to the node it was posted to, i.e. /node/#.

I need this because I'm using the More Comments module, which doesn't use pagers and not compatible with permalinks.


texts: Programmatically alter custom checkout panes depending on cart quantity

texts:
In a checkout process, I need to collect additional data depending on the quantity in the cart.

What is it about ?

Customers book travels
For the sake of argument, let’s say 2 couples of lovers book a week in Venice : they will add 4 "Venice trip" to the cart
During checkout, I  collect usual customer data, plus additional information (name, passport, birthday…) for each other participant in a dynamic custom pane.

My current work :

Set up a custom pane with Commerce Fieldgroup Panes, disabled by default
Add a rule with Commerce Rules Extra, which enables the pane if qty > 1 for specific product type
Then with MYMODULE_form_FORM_ID_alter, I tried 2 different ways to add the relevant fields :

First one:  duplicate the whole custom pane into the checkout page :

function vts_commerce_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id) {

  $order = $form_state['build_info']['args'][0];
  //load line item
  $line_item = commerce_line_item_load($order->commerce_line_items['und'][0]['line_item_id']);
  //get quantity
  $qty = round($line_item->quantity);

  //duplicate the pane for each participant (minus the customer user)
  for($n=1; $n<$qty; $n++) {
    $form['commerce_fieldgroup_pane__group_pax_sup_'.$n] = array_merge(array(), $form['commerce_fieldgroup_pane__group_pax_sup']);
  }
}

The pane is duplicated fine, but the fields of duplicated panes are not saved, nor displayed at next step. Maybe because I have to tell the system these ARE checkout panes, + subsequent  callbacks (as incheckout_pane_example module) ?

If so, I don't find how to declare the added panes are checkout ones inside that loop.

Second one : duplicate each field of the custom pane inside the checkout pane itself :

function vts_commerce_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id) {

  $order = $form_state['build_info']['args'][0];
  //load line item
  $line_item = commerce_line_item_load($order->commerce_line_items['und'][0]['line_item_id']);
  //get quantity
  $qty = round($line_item->quantity);

  //duplicate the pane for each participant (minus the customer user)
  for($n = 1; $n<$qty; $n++) {

    foreach ($form['commerce_fieldgroup_pane__group_pax_sup'] as $key => $value) {

      //searching fields into the fieldgroup array
      if(substr($key, 0, 5) == 'field') {

        //we duplicate the field
        $form['commerce_fieldgroup_pane__group_pax_sup'][$key.'_'.$n] = array_merge(array(), $form['commerce_fieldgroup_pane__group_pax_sup'][$key]);
        //rename field to have it unique
        $form['commerce_fieldgroup_pane__group_pax_sup'][$key.'_'.$n]['und'][0]['#field_name'] = $form['commerce_fieldgroup_pane__group_pax_sup'][$key.'_'.$n]['und'][0]['#field_name'].'_'.$n;
        //add it to the fieldgroup : NOT SURE WHICH IS THE RIGHT ONE OR IF I MUST LEAVE ALL
        $group_pax_sup = $form['commerce_fieldgroup_pane__group_pax_sup']['#groups']['group_pax_sup'];
        $group_pax_sup->children[] = $key.'_'.$n;
        $form['commerce_fieldgroup_pane__group_pax_sup']['#group_children'][$key.'_'.$n] = 'group_pax_sup' ;
      }
    }
  }

This is adding the fields correctly, but again nothing is saved or displayed in next steps. Here it seems that I don't manage to add the fields to the fieldgroup correctly?

How could I achieve this ? Thank you so much!


texts: How do I alter the complete url, not just the path, of nodes?

texts:
When a node's field "External URL" is filled, I want the URL of this node to be that field's value wherever it is rendered/ teasered.

Writing my own service and class using (implementing) InboundPathProcessorInterface and OutboundPathProcessorInterface I can only alter the path, but the base url still gets prepended.

So, whats the correct way?

I thought maybe extending the entity and extending the toURL() function might be the trick, but that seems like a lot of work for a simple feature, does it not?

Edit: I know I can just setup redirects, but for the sake of completeness I'd like to know.


texts: Page not found when trying to access my custom module

texts:
Something is very strange. I have built 8 modules and they all work fine.
When I installed the 9th one, it said "Configuration options have been saved"
but when I access the path, I receive a "Page Not Found".

Tried :
 reinstalling module / clearing cache / recoding the whole module / renaming the module / using other path / rebuild permissions / ... even reinstalled the whole site and reconfigured it all.

All other modules are working but the 9th one fails.

I have seen many posts about this, but none of the options have helped me so far.
Where did I make a mistake? Where can I look in the database to find out more?


texts: How do I get the base URL from the feed content?

texts:
Basically, I'm using the Aggregator module to import content from an RSS feed. The content is just a bunch of articles. I display this content in a view.

This is my current output, it shows the title and the date in a jcarousel.
The thing I'm missing is the webpage source.
Currently, source url in views will have me a full link like:
https://whatiwant.com/the-article-name-i-dont-want
From the above, all I want to display is:
whatiwant.com

Here are my view settings:

I have tried adding different types of fields but none of them see to return the right value. Is there any way to perhaps strip the whole source url down to the base of it? I was thinking maybe it could be done programmatically however I need someone to point me in the right direction.


texts: Override name of file field link in Drupal field.tpl template

texts:
I have a file download field in a node. The field displays as a simple link with the name of the file that will be downloaded, eg:

picture.png

What I want to do is rename the name on the link, i.e. I want it to stay the same but say:

Download the picture,

instead.

I have created a field--resource.tpl template, I don't know how to get started to get the name that is displayed overridden.

Here is what is in my field--field-source--resources.tpl file:

<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if (!$label_hidden): ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;

  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item): ?>
      <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?>

    <?php endforeach; ?>

Thanks!


texts: Is it possible (and within convention) to insert a hidden field in an views exposed filter to control form content (e.g for re-submit search)?

texts:
Examples:

(my requirement) when wanting to control the content of the view title for a listing of locations (E.g. title "venues near you") created using a view with Drupal module ip_geoloc ("IP Geolocation Views & Maps") based on the user's detected location (via html5 geo location) and then offering further searches (e.g. a different specific location) and wanting to display a different title in those results "venues near New York City"
simpler example "search again" for subsequent displays of the form (an user-visible views exposed filter).

For example 1., I'm currently using hook_views_pre_render in my own custom module to compare the submitted value with the detected location to be able to set a custom title for the view, snippets (note, not full declaration and module) of how I get each of these here:

    $locationAsString = "";

    if (function_exists('ip_geoloc_get_visitor_location') ) {
      $locationAsArray = ip_geoloc_get_visitor_location();

      // debug
      //dpm($locationAsArray);

      if ( isset($locationAsArray['locality']) ) {
        $locationAsString = t($locationAsArray['locality'].", ".$locationAsArray['country']);
      }
    }

    $submittedLocationAsString = "";
    if ( isset($view->exposed_raw_input['field_geofield_distance']['origin'] ) )
    {
       $submittedLocationAsString = $view->exposed_raw_input['field_geofield_distance']['origin'];
    }

    // debug:
    //drupal_set_message( "submitted location is: ".$submittedLocationAsString );
    //drupal_set_message( "actuallocation is: ".$locationAsString );

    if ( $locationAsString == $submittedLocationAsString )
    {
      $view->build_info['title'] = "We think you're near ".$locationAsString.". ".$thereAreAsString." here.";
    }
    else
    {
      $view->build_info['title'] = $resultsAsString." near ".$submittedLocationAsString;
    }

My ideal solution

But as you can see, this straight compare is not necessarily that robust. To determine the title I want, I think it may actually be better to insert a hidden field in the form, in hook_form_alter and detect the value/presence of this field in cgformutils_views_pre_render - is this approach within convention and not 'illegal' or bad practice?


texts:
Is there a quick, easy, safe way to check what database a Drupal 8 install is using?

I'm trying to do a Drupal backup but when I look in phpmyadmin I see 5 different DBs listed on the left. I'd prefer to only backup the one I'm using because I've had issues before backing up and restoring the "under the hood" DBs like information_schema.

I've searched a bit but none of the suggestions I've found seem to apply to Drupal 8. Everything I see like this, this, this, etc is from 5+ years ago and says to check the sites/default/setting.php for a db_url line, but I don't see that in that file for my site. Has the location of this info moved in Drupal 8?

FYI:

I'm using Drupal 8.3.7 via Bitname WAMP
I know there are some good backup modules - I've already backed everything up via the "Backup and Restore" module, but I'm paranoid and like to do a parallel manual backup in case something goes wrong with the module-based backup.

Thanks.


texts: How to attach JSON data to JS variable without it being escaped

texts:
I'm having so much trouble with drupal 8 right now.

when in Drupal 7 I could do:

drupal_add_js("var a = 'b';");

and be done with it, for the life of my, I can't figure out how to attach data to a JS variable in Drupal 8

I had to write a custom THEME_preprocess_page function to add the JSON value to drupalSettings like this:

$variables['page']['content']['#attached']['drupalSettings']['customPricelist'] = $result;

but in reality the result get's escaped with quotation marks like:

"{"some":"stuff"}"

and is not usable..

Any ideas?


texts:
On my website we don't get any e-commerce tracking in Google Analytics. Usual analytics works fine. How do I troubleshoot?

Have sold around 200 products since installing & configuring the Google Analytics and Commerce Analytics modules.

The module maintainers haven't replied on the same request on drupal.org https://www.drupal.org/node/2612390

Cheers,

EDIT:
I updated from Commerce Analytics from 7.x-1.1 to 7.x-2.0-beta2. Still nothing in Google Analytics, but now ga_push appears in source code.


texts:
What is Drupal 8 file pattern name for a specified content type?

Suppose I have  a Movie content type. What is the pattern name for its page? Is it page--node--movie.html.twig?


texts: Using ajax in form api to insert a view on select list change requires 2 change events to start inserting/replacing content

texts:
I'm embedding a fullcalendar view into a node edit form.  When the user first lands on the form, he/she does not see a calendar and is prompted to select a room first.

Issue: On the first room selection, all of the JS is loaded but no calendar appears.  On subsequent selections it works as desired.

Based on the attached screenshot the first call loads everything that fullcalendar needs for the view, so the question is: how do I pre-load that stuff on the page?  I don't want to load up the view display if it's possible to accomplish this without doing so.  (In the interim, I'm using a hidden form element; doing this allows for it to work fine and there are other ways to add it to the page so that the user doesn't see it, but I'd prefer to avoid it).

// in hook_form_alter()
...
$form['field_time_and_place'][LANGUAGE_NONE][0]['field_room_reference'][LANGUAGE_NONE] += [
  '#ajax' => [
    'callback' => 'cela_events_ajax_update_calendar_view',
    'wrapper' => 'js--cela-events-room-schedule',
    'method' => 'replace',
  ],
];

$form['field_time_and_place'][LANGUAGE_NONE][0]['field_room_calendar'] = [
  '#title' => t('Room Calendar'),
  '#markup' => 'Please select a room to view the calendar',
  '#prefix' => '
',
  '#suffix' => '
',
];
...
// end hook_form_alter()

function cela_events_ajax_update_calendar_view($form, $form_state) {
  $room = $form_state['values']['field_time_and_place'][LANGUAGE_NONE][0]['field_room_reference'][LANGUAGE_NONE][0]['nid'];
  $view = views_embed_view('cela_calendars', 'block_2', $room);
  $form['field_time_and_place']['field_room_calendar']['#markup'] = $view;

  return $form['field_time_and_place']['field_room_calendar'];
}

In case it helps, here is a screenshot of kpr() after the #ajax has been added to the form element.  This is kpr($form['field_time_and_place'][LANGUAGE_NONE][0]['field_room_reference'][LANGUAGE_NONE]);


texts: I want to export block with features.I have installed features_extra and enabled fe_block and then exported my block into my feature. But there's only hook_default_fe_block_settings. I want to export into code also a content of block. So block viem etc. How can I do that? Thanks for help.


texts: How to create a custom design of an existing view block?

texts:
I have a block I created via views ui. It is in a table format. It has 3 columns with 3 fields. Every field shows in a separate column.

Now I want to change the design of this block in an easy way to my likings.

For example here is the screenshot of one of the blocks to explain what I mean.

This shot is showing user-pic, username and follow-flag resp. As indicated in the snapshot, I want to show follow-flag below the username.

How to easily change the design of my view or block? The best would be a drag & drop. I guess this is an easiest way.


texts: how to set a global variable that is referenced throughout the site?

texts:
i'm trying to avoid programming and hoping i could do this with modules:

I have a classified ad's website which has about 100 categories where users can add an advert. The thing is these are all linked to a location. So i use two vocabularies- one of categories and one of locations.

I want to be able to allow the user to select a location when they first land on the site from a dropdown and then when the user moves through the site this is referenced. I have two specific use cases

When the user goes to add a listing, their location is pre-selected in reference to the one they already selected at the initial visit.
When the user returns they only see adverts relating to their town/city (consider them being already registered)


texts: How do you get Solr Views to query Acquia Search?

texts:
I'm looking to build a set of sites which are all indexed by Acquia Search into a single index.

I also plan to build an umbrella site to help people discover content on the sites below. I was looking to the Apace Solr Views module for this. How do I get this module to build views from the Acquia Search index?


texts: Redirect after login for specific role on specific day using Rule

texts:
I want to create a rule for specific user to redirect to his profile page on specific day like Monday and Thursday. For this, I used the Rules module, together with the Rules Once per Day module. If you're not familiar with this last module (which is pretty new), here are some quotes from its project page:

... to easily enable Rules to be fired once per day at, or soon after, a specific hour.
The module also provides a "Day of the week is a" Rules condition, to further restrict actions to being run on specific day(s) of the week, on working days only, or at weekends only.

But that didn't work so far.
I have also tried with PHP code, but that's not working either.


texts: Is it possible to translate image Title and Alt fields and sync images between tranlations?

texts: Since it would be much easier to manage site with images synchronized. But I have to translate Title fields too.


texts:
Assume that I've created a view that outputs a list of cars. For each car, I display the name and the age of the car. This is all done with the Drupal UI. Now I'd like to add a simple button (Set as favorite) at the end of each line that when clicked saves the ID of the chosen car in a user's session variable. So my view table should look like the following:

Name Age Button
car1 23  'set as favorite'
car2 10  'set as favorite'

I am not asking about the session-variable part, but only how I can alter the view output to add a simple button to each row of the list output (I bet it'll be a form in each row).

I've done a lot of reading and I bet this could be done with hook_views_data_alter or some other hook_views_* but I'm not proceeding. I've already tried drop-buttons as suggested on Drupal 8 Add custom action buttons to a view, but that does not solve the things I need. I need the car's ID I want to save in a session variable, so basically I need a form functionality.


texts:
I'm using colorbox module to load the login form, but after submit the form the page reloaded inside the "iframe" .

what i want to close the color box "iframe" and reloading the main page.

i searched for a long time but i can't find any solution.


texts:
I am trying to display related nodes block using a single view for all the taxonomy terms. So that if user click on any node title he/she will see the related nodes based on the node's taxonomy term.

I tried adding contextual filter with taxonomy term by selecting all the vocabularies, but doing this will display nodes from other terms as well.

The reason I am trying to use single view is, I have tabs (Quick tabs) structure on a node page, with related nodes as a Tab. So I cannot create different views for nodes based on terms, and cannot specify different views in quick tabs settings.


texts:
I want to display a button on the homepage. The best solution i've thought about was to render it in a block. The code is the following :

  $button['my_tickets'] =array(
    '#type'       => 'link',
    '#title'      => t('My tickets'),
    '#href' => '',
    '#class' => 'btn btn-default',
    '#id' => '',
    '#options' => array(
      'html' => true,
    )
  );

And here's the theme :

  function My_module_theme() {
    return array(
      'my_module_my_button' => array(
        'variables' => array('vars' => NULL),
        'template' => PATH_TO_TEMPLATE,
      ),
    );
  }

Problem : The link isn't rendered with the classes inside the "a" tag. How can I do that ?


texts: Wrap 'full html' output with CDATA in Service view?

texts:
I'm using Services and Services Views modules. I have created service display view which includes body field(full html type). In the output url view source body is rendering with &lt;p&gt; which i want to avoid.
Can anybody help me to wrap body element with <![CDATA[ ... ]]>.
I tried rewriting field and view template both are not effecting the output.
Sevice view format setting is the following.

The body configuration is the following.

I tried adding a global custom field, and wrote [body], which was printing properly, but when I wrap [body] field with <![CDATA[ ... ]]> , nothing is coming in the output.

How do I write <![CDATA[ ... ]]> in a custom field?


texts: Don't show user fields on admin/people/create

texts:
Basically I don't want to have fill out all the required fields that I have added to a user when I am adding a user via admin/people/create. In Drupal 6 there was an option to not even show those fields when the admin makes a user. I have looked around for that but have failed to find it in drupal 7. I suppose I could do a hook_form_alter but I was hoping there might be something already made that I can drop in.

I was using content profile in D6 for this and it has become profile2 for D7. Since posting I have found this issue which states that a module needs to be made in order to have that same type of option.


texts: Due to Clean Url issue, the site is not working

texts:
I have downloaded Drupal 8 from official site.But during installation it shows following error:

but i continue installation, and it installed properly. The problem is that except home page whenever i click on any link it shows "Page Not Found".

I have enabled mod_rewrite for apache . Also i uncomment and edit "RewriteBase/d8" in.htaccess file.

I tried all whatever i found on drupal.org but nothing work for me.I desperate to work in d8 but helpless to continue.
Million of Thanks in advance.


texts:
I am unable to alter a settings of a leaflet map generated by a view using the method described here in a custom module. https://www.drupal.org/node/1883788

Using the code below in my custom module does not work.

  function MYMODULE_leaflet_map_info_alter(&$map_info) {
      $map_info['esri-world-street-map']['settings']['scrollWheelZoom'] = TRUE;
      $map_info['esri-world-topo-map']['settings']['scrollWheelZoom'] = TRUE;
  }

Where MYMODULE is the name of my module.

Someone else had this same issue and we have been talking trying to solve the issue. https://www.drupal.org/node/2831593


texts: Drupal 7 "Page not found. The requested page "/" could not be found" after enabling module

texts:
While enabling a module (Imagecache External), Drupal showed an error related to memory limit, then the site crashed. I'm unable to login anymore, since any page shows now:

  Page not found. The requested page "/" could not be found.

I get the same result when I try to go http://www.example.com/index.php?q=user.

phpinfo() says mod_rewrite is enabled.


texts: Drupal 7, Default value php snippet missing?

texts: Im using drupal 7 and created a content type abc. In abc there is a CCK field called seller. When a logged in user create a new item for content type abc, the value of the seller field would be the name of the person who is logged in. So what I want is a default value for the sellers fiels or you can say that a small piece of php code. But I am not able to find the place for the php code to enter in drupal 7. In drupal 6 there is text area for the php code to enter. But how can this be done with the drupal 7. Any ideas?


texts:
I have two routes (from views module) with path "/test".

Route N1 required "role_1" user role, route N2 required "role_2" user role.

Rote N1:

class Symfony\Component\Routing\Route#9524 (9) {
  private $path =>
  string(5) "/test"

...

  private $defaults =>
  array(3) {
    '_controller' =>
    string(47) "Drupal\views\Routing\ViewPageController::handle"
    'view_id' =>
    string(4) "test"
    'display_id' =>
    string(6) "page_1"
  }
  private $requirements =>
  array(2) {
    '_role' =>
    string(6) "role_1"
    '_method' =>
    string(8) "GET|POST"
  }

...

Route N2:

class Symfony\Component\Routing\Route#9524 (9) {
  private $path =>
  string(5) "/test"

...

  private $defaults =>
  array(3) {
    '_controller' =>
    string(47) "Drupal\views\Routing\ViewPageController::handle"
    'view_id' =>
    string(4) "test"
    'display_id' =>
    string(6) "page_2"
  }
  private $requirements =>
  array(2) {
    '_role' =>
    string(6) "role_2"
    '_method' =>
    string(8) "GET|POST"
  }

...

How to skip route N1 if current user have "role_2" but does not have "role_1"?


texts:
I ran into a problem using Secure Pages with multiple subdomains. Secure Pages only seems to allow you to put one domain for SSL and not secure pages. I found the following module in Drupal 6, but I'm wondering if there is another project people know about to solve this problem in Drupal 7?

https://drupal.org/project/securepages_domain


texts: Is caching certain parts of a page possible?

texts:
I have created a drupal 7 commerce site that displays some real time data to visitors as current number of purchases, upcoming products in the next day or so etc. Is there a way to cache parts of the site / page so that not everything is reconstructed on every request?
For example for each product everything can be cached except from the number of current purchases, so I would like to cache images, prices, theme etc, but not the number of current purchases.
Is it possible?


texts: Migrate content from drupal8 to drupal8 programmatically with Node::load and Node::create

texts:
Basicly I want to migrate content from one drupal8 instance to another. they are mostly identical with some small changes.

first step is to migrate the content type via drush gen module module and drupal-console drupal config:export:content:type

then i export the content type via script:

<?PHP
define('DRUPAL_DIR', __DIR__ . "/web");

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

require_once DRUPAL_DIR . '/core/includes/database.inc';
require_once DRUPAL_DIR . '/core/includes/schema.inc';
$autoloader = require_once DRUPAL_DIR . '/autoload.php';

$request = Request::createFromGlobals();

$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$kernel->boot();
$kernel->prepareLegacyRequest($request);

use Drupal\node\Entity\Node;
use Drupal\Component\Serialization;
$serializer = \Drupal::service('serializer');

echo "Node Export Starting... \n\n";

// Nodes
$node_ids = \Drupal::entityQuery('node')->condition('type', 'content-type')->execute();
echo count($node_ids);
$single_nodes =  \Drupal\node\Entity\Node::loadMultiple($node_ids);
$data = $serializer->serialize($single_nodes, 'json');
file_put_contents('nodes.json', $data);

i serialize it and write it into a file.

on the new page I install the exported module to receive all fields for the content type + dependencies and so on.

if I try now to run my importer script i get serveral errors that the (exported) nodes can not be created.

 $json = json_decode(file_get_contents(__DIR__ . "/import/nodes.json"));
foreach ($json as $nid => $nodeImport) {
    $node = Node::create($nodeImport);
    $node->save();
}

Node::create() doesnt seems to accept whole exported/loaded NodeArrays nor casted arrays like (array)$nodeImport

Am I missing something?


texts: Is translation an option in Drupal 8's logger?

texts:
Drupal 7's watchdog() function has a transaltable $message and a $variables argument.

The logger in Drupal 8 doesn't seem to have option. Is it recommended to pass the output of t() to logger?


texts: How can I create menu links to external URLs?

texts:
With my module MYMODULE I would like to create external link and place it into main menu.
Is it possible to do that in MYMODULE.links.menu.yml file or MYMODULE.routing.yml?

Something like this???

mymodule.links.menu.yml

mymodule.googlecom:
  title: 'Google'
  route_name: 'googlecom'
  menu_name: main

mymodule.routing.yml

googlecom:
  path: 'http://google.com/'


texts: Can someone help with a few problems with a specific permission setup

texts:
I'm currently involved in a project which needs a pretty specific permission system that I just cannot figure out how to implement and wonder if anyone could help me.

This project is currently using Drupal 7.8 as a base.

There is a need for Anonymous users to be able view certain content but not other content - this is pretty simple and has been done already. Registered users have more permissions to be able to see more of the content and filter views more - again moderately simple and already implemented.

The main issue is that these registered users can be a part of a company, these companies should only be able to see content related to them with certain 'company admin' users having the ability to view all the content on the site regardless.

This last bit has me completely stumped as I don't want each company to have a company page but rather want 1 site to handle everything and look the same to everyone, but once logged in the content becomes relevant. The content on the site is mostly OpenLayers map data and tables created by Views so whatever solution there is to this has to work with Views and most likely Panels.

Can anyone help me please?

Thanks
Adam


texts: How to disable CKeditor for a particular node?

texts:
I want to style the content within a particular node but the CKeditor seems to interfere with that by introducing unnecessary tags.

In Drupal 6 you could disable it by adding the generated id on the node form to the profile settings of ckeditor.

I could find no similar settings in the Drupal 7 version.

Am I missing something here? Is there no similar configuration for Drupal 7?

or should I go with a hook_form_alter?

Any help is appreciated.


texts: Unable to override default translation publishing status using entity_translation module

texts:
We are using the entity_translation module in a large site, and we have 57 defined languages. We have some custom date fields in each locale, and we are using some custom code to only publish the locale when the current date is within the specified date range. However, one problem we are running into is that when an entity (node, taxonomy term) is created, the Published status for the default language (en-us in our case, defined at admin/config/regional/entity_translation) is automatically set to Published, which we don't want, so I need to override that value and set it to 0.

After delving into the module code, I found the hook_entity_translation_insert hook, which is called from EntityTranslationDefaultHandler:saveTranslations():

  foreach ($translations->hook as $langcode => $info) {
    $translation = isset($translations->data[$langcode]) ? $translations->data[$langcode] : $langcode;
    $data = isset($info['data']) ? $info['data'] : NULL;
    module_invoke_all('entity_translation_' . $info['hook'], $this->entityType, $this->entity, $translation, $data);
    // Provide Rules events integration if available.
    if (module_exists('rules')) {
      // Pass the entity as a wrapped one since rules can't do it for us
      // when using the variable type 'entity'.
      rules_invoke_event('entity_translation_' . $info['hook'], $this->entityType, entity_metadata_wrapper($this->entityType, $this->entity), $translation, $data);
    }
  }

where $op = 'insert'. I tried implementing my hook like so:

function mymodule_entity_translation_insert($entity_type, $entity, $translation, $values = array()) {
  // Set the publishing status for en-us to 0.
  if ($translation['language'] == 'en-us') {
    $translation['status'] = 0;
  }
}

but that doesn't change the status that gets passed on. If I try passing $translation in by reference:

function fluke_staging_entity_translation_insert($entity_type, $entity, &$translation, $values = array())

krumo gets into a huge recursive loop, and my computer maxes out the CPU.I can return a value like so:

function mymodule_entity_translation_insert($entity_type, $entity, $translation, $values = array()) {
  // Set the publishing status for en-us to 0.
  if ($translation['language'] == 'en-us') {
    $translation['status'] = 0;
    return ['translation' => $translation];
  }
}

but that's worthless, too, because the hook invocation doesn't do anything with it:

module_invoke_all('entity_translation_' . $info['hook'], $this->entityType, $this->entity, $translation, $data);

as compared to

$new_data = module_invoke_all('entity_translation_' . $info['hook'], $this->entityType, $this->entity, $translation, $data);

or something like that.

So my question is, how can I override the translation status in this hook, since it doesn't seem that it's a) passable by reference, or 2) it accepts any data from the hook_entity_translation_insert implementation?


texts: Is it possible to add a second `drupal.behaviors` to your module?

texts:
I have a module that uses a bit of jQuery.

But when I submit a form I want it to call an other bit of jQuery on the landing page.

So I thought adding another Drupal.behaviors to my module.
But this doesn't seam to work.

(function ($) {
  Drupal.behaviors.popover_hide = {
    attach: function (context, settings) {
     // open link in new window.
     var linky = $('clickedme').attr("href");
     alert(linky);
     alert('linky');
     // remove class from link

     // set focus on new window eventueel
    }
  };
})(jQuery);

when I already have a Drupal.behaviors.popover loaded. ("popover" is the name of the module)


texts: Drupal Commerce: How to perform a complex calculation of order's final cost (VATs & discounts)?

texts:
Here's is what I want to accomplish:

There are 2 taxes in my country: 6.5% & 23%. Every product has to be matched with 1 of these 2 VATs (I'm currently using a taxonomy vocabulary holding these 2 VAT values instead of using commerce tax module)
A discount should always be available, based on total order's amount, excluding tax e.g. an order's total (with no tax included in base prices) of €0,01-€50,00 awards the customer with a discount to the order's total (including tax) of -5%, from €50,01 to €80,00 gives a discount of -8% etc etc

What I want to accomplish:
- Customer adds products to cart (product prices are displayed excluding tax, ie w/o components) and heads to checkout. According to order's total (addition of products' base prices w/o tax), the appropriate discount will be applied.
- Final Price = (Products' base prices + their appropriate taxes)*Pre-calculated Discount + Shipping Cost

Example:
Shopping cart includes:
- Product 1: €20 base price (6.5% VAT)
- Product 2: €25 base price (23% VAT)
Checkout Process:

Discount pre-calculation: Total base price is €20 + €25 = €45. As a result, the customer should be awarded with a -5% discount (see available discount rates above).
Order's total including products' VATs = (€20 + €20*0.065) + (€25 + €25*0.23) = €21.30 + €30.75 = €52.05
The pre-calculated -5% discount from step 1 is applied: €52.05 - €52.05*0.05 = €49.45 and that's what the customer has to pay for the products in his/her cart.
Order's weight is calculated and a shipping flat rate is applied (I have this functionality already working). As a result, the shipping cost is added to €49.45 and we finally get the sum that the customer will have to pay using one of available payment methods.*

I would appreciate your suggestions on how to make this happen.

Tricky parts:

different products can have different VAT (23% or 6.5%).
The discount has to be calculated by adding all products' base prices (NOT including tax) and THEN applied to line item (including tax) prices.
It would also be nice if VATs & discount were displayed to customer in order's review.


texts:
I'm trying to club Drupal & Magento together. So I want to make the registration seamless. If any user register in Drupal they want to register in Magento automatically using a custom module in Drupal. I have scripts to register in Magento by sending data to Magento script file.

I want to know how to make a AJAX call to that script file, using a custom Drupal module. I'm using Drupal 7 version.


texts: Is it possible to use drush migrate-import to import custom fields?

texts:
I am trying to migrate a Drupal 7 site to Drupal 8 on a new server
I have copied the db so it can be used locally.
I have run the drush migrate command and migrate-status shows a bunch of things that are ready for import.
I can import users with drush migrate-import d7_upgrade_users. However the users have custom fields associated with them and I can't find how to import those fields through drush.
Trying to export a csv from the old host is virtually impossible as it crashes out trying to do the export.

Is it possible to import all user data including passwords and custom fields from the command line using drush (or other command line tools) without the need to import everything?


texts: How to migrate nodes from a dev site to a production site?

texts:
I have a staging site and a production site.

For an error some nodes was updated on the production site and now I have to update it but, if I will do that I will lose the production site changes.

What is the best [and faster] approach to migrate some nodes from production to staging before migrate staging to production?


texts: How can I set a placeholder variable in page.tpl.php from a page callback?

texts:
I have a value in page.tpl.php that I would like to set in page callbacks, independently from the main content.

In page.tpl.php:

<?php print $placeholder ?>

<?php print render($page['content']); ?>

What I would like to do in the page callback:

function my_module_page_callback_foo() {
  $placeholder = 'foo';
  return 'Page Content';
}

Obviously, that isn't going to get me very far.

I'm hesitant to use hook_preprocess_page because then I'll have unnecessary conditional logic to determine what the menu item is (won't I?). Is there another, 'drupal way' of doing this?

I'm coming from a more 'Zend-y' world where I have access to my view and my layout variables from the controller.


texts: What token should I use while sending email when I am programmatically adding the content?

texts:
When I fill the form. I get this email

  A new Event "Event name" has been created. To approve this Event
  please go to http://websitename.com/content/content-name and click
  ‘publish’.

I have set this in the rules to send an email which is this.

  A new [node:content-type] [node:title] has been created To approve
  this [node:content-type] please go to [node:url] and click ‘publish’.

But the problem is, for some contents, I don't want to fill the form, as I am using programmatic way to add content. I use this code:

<?php
ini_set('display_errors','1');
ini_set('memory_limit', '512M');
define('DRUPAL_ROOT', getcwd());
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
module_load_include('inc', 'node', 'node.pages');
$node = new stdClass();
$title                =  "This is the Title of the Content";
// $summary            =   "summarry";//$_POST['summary'];
$body                  =  "This is testing of body section of Automated Script";// $_POST['body'];
  $node->uid      = '0'; //author
  $node->type     = 'event';    //content type
  // $node->created  = time() - (rand( 1,240) * 60);
  $node->created  = strtotime("now");
  $node->changed  = strtotime("now");
  $node->status   = 0;
  $node->promote  = 0;
  $node->sticky   = 0;
  $node->language = 'und'; // undefined
// $node->body['und'][0]['summary'] = $summary;
  // Body Format
  $node->body['format']  = 'full_html';

  // Title
  $node->title = $title;
  // Body
  $node->body['und'][0]['value']   = $body;
  // City
  $node->field_location['und'][0] =  array('value' => 'Oxford');
  // Country
  $node->taxonomy_vocabulary_6['und'][0] = array('tid' => 10921);
  // Research Community
  $node->taxonomy_vocabulary_7['und'][0] = array('tid' => 16069);
  // Project/Organisation
  $node->taxonomy_vocabulary_8['und'][0] = array('tid' => 16126);
  /*
   * 10921, 16069, 16126 are the IDs of the the taxonomy terms.
   */
  // Date
  $node->field_event_date['und'][0] =  array(
      // The start date.
      'value' => '2014-04-05T10:00:00',
      // The end date.
      'value2' => '2014-04-06T11:00:00',
  );
  // Duration
  $node->field_duration['und'][0] =  array('value' => '2');
  // Email
  $node->field_user_email['und'][0] =  array('email' => 'exampleemail@gmail.com');
  // Event Link
  $node->field_url['und'][0] = array('url'  => "https://www.google.com");
  // Number of Places
  $node->field_people_expected['und'][0] =  array('value' => '25');

node_submit($node);
node_save($node);
print "ok";
?>

PROBLEM HERE:
When I add content using this method. I get this email.

  A new Event "Event name" has been created. To approve this Event
  please go to http://./content/content-name and click ‘publish’.

Instead of website name, it shows only a "." (dot). How to solve this problem?


texts:
With Drupal 8 and Commerce 2.10

I created a php code to display the link of my store.

When I go to the link, it displays:

https://www.domaine.com/shop/name

I want to display without alias:

https://www.domaine.com/store/id

How to do ?

$link = Link::createFromRoute($this->t('my business'), 'entity.commerce_store.canonical', ['commerce_store' => $store_id], ['attributes' => ['target' => '_blank']])->toString();


texts:
I've got a Drupal 7 site on Apache and Varnish, sitting behind the CloudFlare CDN. Everythin on mysite.com goes through cloudflare... I also have a "direct access" subdomain set up at direct.mysite.com, which is a CNAME alias that bypasses cloudflare.

One issue with Cloudflare is that it limits the upload size of files passing through its servers to 100MB. I want my users to be able to upload files that are larger than that.

What I would like to do is allow my users to add content like normal via mysite.com/add/node/type... but pipe the actual file uploads through to my direct subdomain (direct.mysite.com), so that the upload process itself (and only the upload process) bypasses CloudFlare, allowing files larger than 100 MB to be uploaded.

Any idea of how I would go about something like that?

I've tried a simple htaccess rewrite without any luck (the upload button seems to send the ajax request to the right place, but I get an "ajax http request terminated abnormally" error).

RewriteCond %{REQUEST_URI} ^/file/ [NC]
RewriteRule !^index\.php$ http://direct.mysite.com%{REQUEST_URI} [L,R]


texts: Any risks associated with habitually updating/reverting ALL features in drush?

texts:
I want to start using drush commands to simply update all or revert all features (depending on which environment I'm in) instead of doing them one by one. What are the risks involved or questions I should ask myself before habitually just updating all or reverting all features?

drush fra (to revert all on production and test servers)

drush fua (to update all on dev environment)

Thanks!


texts: how to print view title in views-view-unformatted.html.twig?

texts:
I have to style the view title
and print it in the unformatted twig. how can i achieve this ?


texts: The new version of my module depends on more modules than the old version ... how to ensure module users install them?

texts:
I am updating an existing module I have developed. The new version requires a "helper" module that the old version did not (fwiw, specifically "Nodereference Count"). How do I ensure that when people upgrade from the prior version of my module to the new version, they make sure to install the newly required helper module first?

Is there something I should put into hook_update_n function?

Thanks.


texts: Pages with embedded views - a good aproximation?

texts:
I have a view with a listing of nodes. I want to create a page which contains the view as a block and lots of others features. I have followed this approach, but it seems to me that it is a little clumsy and there are better ones:

1) I have created a new type of content, with no fields.
2) I have created a new node of that content.
3) In the template.tpl.php I have made a suggestion for that type of content, to load a specific page--type-of-content.tpl.php page.
4) In that page I embed (php) my view and all the other features.

Is there a more straighforward method? This one works, but it seems rather convoluted.

Maybe creating the view as Page and altering the page? How can I do that?


texts: Unset required attribute with multiple submit buttons and multistep form

texts:
I have a multistep form created with msnf for an content type.
I set multiple submit buttons that each one has its own submit callback, and also i want every single button with its validation callback :

function MYMODULE_form_alter(&$form, &$form_state, $form_id){
  switch ($form_id){
        case "my_form_id" :
          $form['actions']['submit_2'] = array(
                '#type' => 'submit',
                '#name' => 'button_name',
                '#value' => t('Name'),
                '#weight' => 6,
                '#submit' => array('node_form_submit'),
                '#validate' => 'MYMODULE_validate_2'

            );
            // Add submit callback (works fine!)
            array_unshift($form['actions']['submit_2']['#submit'], 'MYMODULE_form_submit_2');
            // rest of code ...
  }
}

inside the validation callback i put this test code :

function MYMODULE_validate_2($form, &$form_state){
  dpr('test');
  exit;
}

Here i have two problems :

1) this validation callback didn't triggered i don't know why ? (the system must show me a dump 'test' and then exit but nothing happen!)

2) I want to disable all the required fields only when i click on this submit_2 button.

I found sth in this post, but like i said the validation callback is not handled so i can't test the code inside that post.

Thanks in advance.

EDIT
 I was blind :p I must put the callback function inside an array() like this

'#validate' => array('MYMODULE_validate_2')

sometime i made stupid error :)

Now my problem is only the second one :

I want to disable all the required fields only when i click on this submit_2 button.


texts: How to show a block on pages with url parameters?

texts:
I have a block that I want to show on pages matching news and news?page=1. In the 'only show on these pages' section I have news and news/* but it doesn't match the second url. Is there a way to do this?

Update 1: I have also tried this:

<?php
    $url = request_uri();
    if (strpos($url, "news")) {
    return TRUE;
        }
    ?>

But even after clearing all the caches it doesn't seem to have worked either.

I also tried the pattern news?page=* but that doesn't work either! Surely somebody considered being able to show blocks on paginated pages?

Update 2: Found the answer Restrict block to specific pages is broken when using view pagination

Turns out the block I was trying to display was a View which was also set to display a pager (even though one doesn't appear). Turning the pager off resolved the issue.


texts: How to cancel user accounts without e-mail confirmation?

texts:
I want to allow users to cancel their accounts immediately instead of having to confirm the cancellation by email (because users forget passwords, lose access to email, and other problems).

There is a great answer to the Drupal 7 version of this question and it inspired a module.

So I attempted to adopt the code in the module for Drupal 8.

First, though, you need to prevent the "account cancellation confirmation email from being sent; otherwise, users will receive an email to click a link when they don't need to.

You can do this as follows:

drush cex
Edit user.settings.yml
Change cancel_confirm to false
drush cim

Here is my code with a problem:

function MYMODULE_form_user_cancel_form_alter(&$form, &$form_state, $form_id) {
  $form['#submit'][] = 'mymodule_user_cancel_form_submit';
}

function MYMODULE_user_cancel_form_submit(&$form, &$form_state) {
  $uid = $form['uid']['#value'];
  $user = \Drupal::currentUser();
  if (!$user->hasPermission('administer users') && $uid == $user->id()) {
    // Hide "A confirmation request to cancel your account has been sent to your email address."
    $messages = drupal_get_messages('status', FALSE);
    if (!empty($messages['status'])) {
      unset($_SESSION['messages']['status']);
    }

    // Cancel the account, from user_cancel_confirm()
    user_cancel($form_state->getValues(), $uid, $form_state->getValue('user_cancel_method'));

    // Since user_cancel() is not invoked via Form API, batch processing needs
    // to be invoked manually and will redirect to the front page after
    // completion.
    batch_process('');

  }
}

The main problem is that after calling the submit callback, I get the message "The update has been performed.", but the user account is not cancelled.

I used kint() to debug and the submit callback is evaluated and user_cancel is called, but the account is not actually blocked.  Users do have permission to cancel their own accounts.


texts: How to add some custom text after a taxonomy field in panels?

texts:
I have a taxonomy field called cvtype.

This cvtype is containing several names like
- Standard
- Complete

I can add this to a Panel by adding content > node.
I would like to add the letters CV behind each term in this panel.

How to do this in D7?


texts: Email a Whole Node (Including template contents)

texts:
I have created my own custom node.tpl.php file.
I now want to email the entire node, each time the user creates a new node of that content type (I have made sure that all the HTML in my node.tpl.php file is email friendly).

How can I do this?
Ideally I would like the email to go to a specific email address automatically when the node is saved.

I have found that a combination of Rules and HTML Mail can achieve what I want. Except... When creating a rule action, there isn't the option to email the entire node (including the node.tpl.php theming). Rules only gives the option to email out specific node fields (without theming).

Any suggestions would be most appreciated!


texts: FTP sites/all and sites/default/files files zipped and unzip on server or FTP as is?

texts:
I have cpanel with hostgator, and it's faster to zip the folder sites/all and sites/default/files and then unzip on the server.

Is that the best way to do things or can it get corrupted?

Is it safer to FTP the files as is from the localhost environment?


texts: Having Problems configuring Sharethis Module with Drupal 6

texts:
Firstly, this is my first post in this forum so if I am posting in the wrong place or anything similar then please point me in the right direction!

What I have is the Sharethis module - http://drupal.org/project/sharethis

Basically it is easily to setup (by the looks of things) in Drupal 7 by clicking on configure, whereas Drupal 6 on the other hand only has a box where I can paste 'custom code' into.

If I work through the configuration on the site - http://sharethis.com/publishers/get-sharing-tools# -and select website I get some custom code consisting of a set of spans and 2 scripts to add in my header.

What I have done is added the span code to the custom code box and placed both scripts in the header section of my page.tpl.php file, yet it doesn't seem to work. I can't seem to find any documentation on sorting this out in Drupal 6 neither, as it all points back to how to set it up in 7 (Very frustrating!)

Thanks,

Rick


texts: views slideshow jQuery Cycle Custom Options how to use?

texts: I display a view using slideshow format. To slide images I use controls only. After installing json2.js library I can add additional options displayed here http://malsup.com/jquery/cycle/options.html I think, using options it might be possible to add active classes on controls for better styling. I need to add first and last class. Has anyone experience how to use it? Thank you. Adding first/last classes typical way (checking this option in views does not work and in this situation it would not solve it)


texts: Why can I not set Workbench Access Control fields?

texts:
I am attempting to set the workbench access control fields on two content types. Under the "Access Control Fields" section of the Access settings page, my two content types can be seen. I drop down the menu and select the taxonomy that already exists on each page, which I would like to control the permissions of who can alter and publish changes on these pages.

However, every time that I set these two fields to the correct field, then hit "save," the changes are NOT saved and they still say, "No Access Control Field" on each content type. "Require a Workbench Access form element" is NOT checked.

Can anyone shed some light on why these changes would not be saving? Am I missing a setting somewhere that would be necessary for these access control fields to be valid?


texts:
I added new code to the template.php and tried clearing the cache but it does not seem like the cache is being cleared. I tried the Admin ->settings->performance and drush (not sure if I installed it properly). Would there be any suggestions?

Drupal 6.


texts: Insert my files inside a custom table after upload?

texts:
How to insert my uploaded files inside a custom table (as managed_file) after upload inside a custom form on DRupal 8 please ?

For moment, I have :

$form['images']['new']['local'] = array(
  '#title' => t('Upload Images'),
  '#type' => 'managed_file',

I need to use jquery, element_validate ? Other ?
Thanks.


texts: Organic Groups and Workbench or Revisioning together. Will this work?

texts:
I'm building a D7 site using Organic Groups and would like some revisioning control.

Is it likely that something like Workbench or Revisioning will work nicely with Organic Groups?

I'm interested in hearing of any good or bad experiences or advice.

I've done some initial tests and Workbench appeared to work okay. Of course the number of configurable options tends to explode with two node access modules. It gets quite complicated. The Revisioning module wasn't quite so smooth. I seemed to get into a situation where an item wasn't visible to a normal group member when it should be but it could be fixed if the author / moderator simply edited the item and saved without doing anything. Maybe I need to have another play with that.

These modules actually do a lot more than we need. We don't really need multiple roles for author, moderator etc. Mostly "all" we'd like is the ability for a user to edit and save an existing node but see what it looks like before making it public. The "Preview" button does that (sort of) but it would be nice to be able to save changes, take a break, and come back later. Also, the public view maybe in a panel so "Preview" doesn't really show the final result.

Thanks


texts: How to embed javascript into content region

texts:
I am trying to embed javascript into the content page of my page. I decided to use php filter and the following is my code:

<?php
$scripty = "http://blah.com/plugins/embedvanilla/remote.js";
drupal_add_js($scripty, array(
'type' => 'external',
'scope' => 'content',
'group' => JS_LIBRARY,
'every_page' => FALSE,
'weight' => -1,
)
);
?>

The script shows on this page if scope is not set (which means it defaults to header).

How can I get it to display in the content region?


texts: Avoid repetitive API calling in form rebuild while submitting

texts:
I am calling external API in form build function. While submitting form gets rebuild and call external API again.

How can I avoid repetitive API calls in the form's build function? I used form_state->set() but it's doesn't seem to be working.


texts:
I have a multi language website, one of languages is a RTL language, in Drupal 7 I put my CSS in style.css and RTL CSS to style-rtl.css and by default drupal also load style-rtl.css file, Now in Drupal 8 ,I have a multi language theme, how can I tell Drupal to load my RTL style in RTL language?

update
I found this link but I am not sure about that because  I have a CSS file with almost 1400 lines, I should put [dir="rtl"] before all of any selector ? !!!


texts:
Is there a way on Drupal 8 to clear all "pages" cache or all "nodes" pages?

I was thinking about a custom drush command but I don't understand how to do this.


texts: Where/How to use a custom query in Views 3.5 D7

texts:
I have the following SQL query which produces the result I need in PHPMyAdmin and but I am lost on how I can use this query in D7.

SELECT sum(month.field_oct_value)
FROM uc_orders u,  field_data_group_audience ga, field_data_field_oct month
WHERE u.uid = ga.entity_id
and u.order_id = month.entity_id
and ga.bundle='user'
and ga.group_audience_gid=10
and (u.order_status='pending' OR u.order_status='payment_received' OR u.order_status='completed')

The query pulls integer values from field_data_field_oct for orders created by users from specific groups.  The output required is a single integer, being the sum of field_data_field_oct values retrieved.

I am looking at views_php as a way of using the above, because I will be using the resulting views panes in Panels. But my php/drupal code knowledge is poor (but improving).

If anyone has any pointers on how I would use the above as the value code and an example of output code for a views_php global PHP field, I would be very grateful.

For bonus points: Ideally I would like the GID to be pulled from the viewed node's group_audience field...

Cheers,
Nick


texts: on('load') is not working with jQuery 3?

texts:
I used to use the following function to load a video in the background (jquery 2.2.4):

function getVideo() {
    if ( $('video').length ) {
        $('video').each(function() {
            if (Modernizr.mq('(min-width: 1024px)') && $(this).children().attr('src') === undefined ) {
                var src =  $(this).children().attr("data-src");
                $(this).children().attr('src',src);
                $('video').load();
            }
        });
    }
}

After updating to 8.5.6, I must use jquery 3.2.1. So, I had to change the line $('video').load() to $('video').on('load', function(){});. However, the video is not loading anymore. I have tested the code, and each line gets executed until it comes to $('video').on('load', function(){});. I don't know why it is not loading. Is it because .on('load', function(){}) is only accessible by windowproperties? If so, then how can I load the video using document properties?

The markup in the theme of that specific block would be:
$variables['video_markup'] = '<video autoplay loop muted id="bgvid"><source data-src="'.$video_link.'" type="video/mp4"></video>';

Which roughly translates to:

<video autoplay="" loop="" muted="" id="bgvid" data-video="0"><source data-src="https://somevideo" type="video/mp4"></video>

I have been targeting this video element here. ANy suggestions will be appreciated.

Also, is there any way to force Drupal 8.5 to use Jquery 2.x? I tried this How do I use a jQuery version different from the default one used by core?, but it didn't work for me.

Edit:
@Jaypan Thanks for your answer. You are still using the .load() method in your addVideoHandler, which has been removed in Jquery3. I am not sure if it will work.


texts:
I need to display an image url in a metatag item.  The problem is on one of my node types, the editors only upload an image as a media entity inside the body.

What is the best way to handle this?


texts: How to map user/password to a mobile theme?

texts:
I'm working on a mobile version of a forgot password page, the problem I have is the mobile theme is triggered when users are on a page with a URL like:

example.com/m/about

Here, about would be a node and it's a mobile version of the example.com/about.

So I read through drupal documentation and looked at Customizing and Overriding User Login page...but the issue I have is, how do I go about mapping example.com/user/password to a mobile version since it's not a node it's a template (node--user.tpl.php)?


texts: How to create Country, State, City and Zip Code field in D6

texts:
I am having a registration page which contains the field Country, State, City and Zip Code Which needs to be hierarchical select.

My question may be very basic. But kindly clear it.

I have used content profile module to create all the registration fields.

My question is what field type i need to give for the above fields what i mentioned (Country, State, City and Zip Code). Which needs to be hierarchical select.

Is there any examples or tutorials related to this topic will help a lot for me.

Any help will be thankful and grateful.

thanks in advance..


texts:
I need to add a OR condition to my query so that I can get all nodes related to a particular term. Here is what I have done :

$query = \Drupal::database()->select('taxonomy_index', 'ti');
$query->fields('ti', ['nid']);

// OR CONDITION
$or_group = $query->orConditionGroup()->condition('ti.tid', $params[1], 'IN');

$query->condition('ti.tid', $params[0], 'IN');
$query->condition('ti.status', 1);

// Added OR CONDITION TO QUERY.
$query->condition($or_group);

$query->execute()->fetchAllAssoc('nid');

This is the how the query get build :

  QUERY

  SELECT ti.nid AS nid

  FROM {taxonomy_index} ti

  WHERE (ti.tid IN (:db_condition_placeholder_0))

  AND (ti.status = :db_condition_placeholder_1)

  AND (ti.tid IN (:db_condition_placeholder_2));

  PARAMS

  Array (

  [:db_condition_placeholder_0] => 170

  [:db_condition_placeholder_1] => 1

  [:db_condition_placeholder_2] => 227

  );

As you can see the last "AND" condition should be "OR".

Thanks.


texts: Need To Update One Entity Through Another

texts:
I've been trying every angle I can, but I keep running into Revision ID errors when I try to update a referenced or related entity of another entity. I believe this might be on the right track? I'm not sure why these are occurring. I just need a simple field to be updated when the related entity is updated.

It also throws this error:
DatabaseTransactionNoActiveException

Is there any documentation on how to update one entity when another is updated? I just need to be pointed to the right track on this one.


texts: Multiple currency  displayed in ubercart product page

texts: I have a website where I need to display the product in 2 different currencies. Once the user selects one price, adds the product to cart, and tries to checkout, the currency can be posted to the payment gateway in USD. For example, if the user selects the price in Indian Rupees as 450 INR and tries to checkout, the value is converted into USD if the user pays through Paypal, but if the user selects the Indian Payment gateway, the same will be posted as 450 INR. How can we do this?


texts:
I have a bit complex work on Drupal 8 site, exporting everything via Features

I created groups using the Group module. I also have a content type installed as plugin-a group content to the group named "Biz Articles". I have views relating to the groups and group contents.

So, when I try to use Features to export my work. I have the listed dependents modules below:

I import the module and enabled to the fresh Drupal 8 installed site. My intention is to test if my work would still be properly function and for me to easily back up everything using features.

Unluckily I am getting this unmet dependencies issue:

[error]  exception 'Drupal\Core\Config\UnmetDependenciesException' with message 'Configuration objects (core.entity_form_display.node.biz_page.default, core.entity_view_display.node.biz_page.default, field.field.node.biz_page.field_type_of_business, group.role.test_biz_group-670dfcb37, group.role.test_biz_group-a416e6833) provided by biz_articles have unmet dependencies' in /Applications/MAMP/htdocs/drupal-8.2.6/core/lib/Drupal/Core/Config/UnmetDependenciesException.php:84
Stack trace:
#0 /Applications/MAMP/htdocs/drupal-8.2.6/core/lib/Drupal/Core/Config/ConfigInstaller.php(460): Drupal\Core\Config\UnmetDependenciesException::create('biz_articles', Array)
#1 /Applications/MAMP/htdocs/drupal-8.2.6/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php(132): Drupal\Core\Config\ConfigInstaller->checkConfigurationToInstall('module', 'biz_articles')
#2 /Applications/MAMP/htdocs/drupal-8.2.6/core/lib/Drupal/Core/Extension/ModuleInstaller.php(141): Drupal\Core\ProxyClass\Config\ConfigInstaller->checkConfigurationToInstall('module', 'biz_articles')
#3 /Applications/MAMP/htdocs/drupal-8.2.6/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\Core\Extension\ModuleInstaller->install(Array, true)
#4 /Users/johnreytanquinco/.composer/vendor/drush/drush/commands/core/drupal/environment.inc(131): Drupal\Core\ProxyClass\Extension\ModuleInstaller->install(Array, true)
#5 /Users/johnreytanquinco/.composer/vendor/drush/drush/commands/core/drupal/environment.inc(198): drush_module_install(Array)
#6 /Users/johnreytanquinco/.composer/vendor/drush/drush/commands/pm/pm.drush.inc(1168): drush_module_enable(Array)
#7 [internal function]: drush_pm_enable('biz_articles')
#8 /Users/johnreytanquinco/.composer/vendor/drush/drush/includes/command.inc(422): call_user_func_array('drush_pm_enable', Array)
#9 /Users/johnreytanquinco/.composer/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#10 [internal function]: drush_command('biz_articles')
#11 /Users/johnreytanquinco/.composer/vendor/drush/drush/includes/command.inc(199): call_user_func_array('drush_command', Array)
#12 /Users/johnreytanquinco/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(73): drush_dispatch(Array)
#13 /Users/johnreytanquinco/.composer/vendor/drush/drush/includes/preflight.inc(93): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#14 /Users/johnreytanquinco/.composer/vendor/drush/drush/drush.php(11): drush_main()
#15 {main}

That biz_page is my other content type, unused with some fields. One of the fields has reference to the taxonomy term that is also used in the Biz Article module.

What should be done to clear this unmet dependencies?


texts: drush archive-restore fails with DRUSH_UNKNOWN_OPTION":["Unknown options: --e, --g

texts:
Here's what I input at the command line:

drush arr /var/backups/backup_migrate/scheduled/[archive name].tar.gz/var/www/vhosts/[sitename]  --overwrite

It didn't restore either the code or database and gave me the confusing result:

Archive restored to /var/www/vhosts/[sitename]/[archivename]
[ok]/var/www/vhosts/[sitename] [archivename]
/var/www/vhosts/dev.youngamericansunited.org/[archivename]

So I ran it with -debug:

drush arr /var/backups/backup_migrate/scheduled/[archive name].tar.gz
/var/www/vhosts/[sitename]  --overwrite -debug

It didn't restore either the code or database
and I got this output:

DRUSH_BACKEND:{"error":"DRUSH_UNKNOWN_OPTION","message":"Unknown options: --e, --g.

I have run this with drush 6, 7 and 8 with identical results. I have also tried copying the archive to the target Drupal directory and running arr.

Drush status outputs:

 PHP executable         :  /usr/bin/php
 PHP configuration      :  /etc/php.ini
 PHP OS                 :  Linux
 Drush script           :  /root/.composer/vendor/drush/drush/drush.php
 Drush version          :  8.0-dev
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :  /etc/drush/prodyau.alias.drushrc.php
/etc/drush/prodyaunet.alias.drushrc.php
/etc/drush/stageyaunet.alias.drushrc.php /etc/drush/devyau.alias.drushrc.php
/etc/drush/stageyau.alias.drushrc.php
/etc/drush/devyaunet.alias.drushrc.php

Here's the alias file for this site:

 <?php
$remote_sites = '/var/www/vhosts/[sitename]'; // usually /var/www/drupal-
root-name
$aliases['devyau'] = array(
'uri' => '[sitename]',
//'remote-host' => '[ip-address]',
'remote-user' => 'root',
'root' => $remote_sites,
//'ssh-options' => '-p {if you ssh in on another port like 2222}',
'path-aliases' => array(
// '%drush-script' => '/root/.composer/vendor/bin/drush', // This is so you
can have multiple drush installs and use different ones on different sites.
// 'php'=> '/usr/local/bin/php', // Again if you have different php's for
different sites.
'%site' => 'sites/default/', // This is the important part here, it will
ensure the proper bootstrap
'%dump-dir' => '/tmp', // This is where you want to dump your databases,
normally /tmp folder I think.
//'%files' => $remote_sites . '/files' // Your sites file folder, incase it
is somewhere else.
),
// You may actually need this, especially if you are running D7 since I
haven't ever tested the db-url thing on D7 or above.
'databases' => array (
'default' => array (
  'default' => array (
    'driver' => 'mysql',
    'database' => '[databasename]',
    'username' => '[username]',
    'password' => '[password]',
   ),
  ),
 ),
);

My alias files all work with drush rsync and drush sql-sync...I can move sites with the the aliases without any problems. I't just that I can't restore a backup archive using arr or archive-restore.


texts: Smart IP Not showing Country of the user

texts:
I want to get the (lat $ Long) and country name of the visit users. For this I am using the Smart IP module but it will not show the full detail of the users.

Please help me out for this. How I get the whole data of the user?

PS: I need this info in the Drupal views for creating the conceptual filters.


texts: How to modify a view's empty text to show a different message depending the user viewing it

texts:
I have created a view displaying a user's blog entries. In view's empty text i have put the simple php code showing below
    You have not created any blog entries.
    You can create a
Now i want to modify it to implement the following scenario.
1. When a user visit his/her profile page the above empty text should be appear. 2. If a user visit an another user profile page then i want the empty text to have the following value
        [username of the user that own's the profile page] hasn't created any blog entries.
Can anyone help me to achieve this? Thanks in advance.


texts: How to add recurring to all product by default monthly?

texts:
I am using ubercart and uc_recurring module and Drupal6.  I wanted to add monthly payments to all products by default.  How can i do this ?

I added a rule to add the data to the DB  using php code while creating new product

$data = array(
  'pfid' => ' ',
  'nid' => $node->nid,
  'fid' => 'recurring',
  'description'=>'When this product is purchased, add a fee for the same amount as the product selling price charged first after 0 days and every 1 months after that 99 times.',
);
drupal_write_record('uc_product_features', $data);

$q = "SELECT pfid FROM {uc_product_features} WHERE fid= '%s' AND nid = %d";
$result = db_query($q, 'recurring', $node->nid);
$num = db_result($result);

$data2 = array(
  'pfid' => $num,
  'model' => ' pro',
  'fee_amount' => ' ',
  'initial_charge'=>'0 days',
 'regular_interval'=>'1 months',
  'number_intervals'=>100,
);
drupal_write_record('uc_recurring_product', $data2);

Still recurring is not working? When i go to the path /node/*/edit/features and simply submit the form without updating any fields it works?

Am I missing anything?