texts: Painfully slow, Devel Query logs show culprit

texts:
I have been having a few problems with one of my clients site. Its a big site, theres a few thousand nodes, 10k users, and it holds large images galleries with 100+ images that are 500kb each.

At its slowest, the average page load is 45 seconds!! And the worst i when you are logged in.

After enabling devel query logs, this one stands out as the worst...

3923.69 ms  1  node_tag_new  P A
INSERT INTO history (uid, nid, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2)

Thats the first page load, the second is much much worse....

65594.921 ms  node_tag_new   P A
UPDATE history SET timestamp=:db_update_placeholder_0 WHERE ( (uid = :db_condition_placeholder_0) AND (nid = :db_condition_placeholder_1) )

What is the history table? Any idea why it is taking so long to run the query?


texts: PHP cli script for flushing drupal cache

texts:
So I have created script that flushes drupal's cache and it's ran in CLI.

The problem is after first use, I can't use the script again, because some classes ('SelectQueryExtender' or 'DrupalDefaultEntityController') are missing. Clearing cache via drupal admin menu (admin_menu/flush-cache) fixes it and I can rerun.

Now the question is why clearing cache from via HTTP works and from CLI doesn't?

I'm running on Drupal 7 and code can be found below:

define('DRUPAL_ROOT', '/srv/www/'); // Drupal root folder.

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Clear cache.
drupal_flush_all_caches();

EDIT: when I clear cache via drupal_flush_all_caches and later make curl call for cache clearing through apc-status.php, then even website itself gives Fatal on above mentioned classes missing.


texts:
I am using a zen subtheme and I am trying to add some javascript using the drupal_add_js
 on a certain node.
When I use the drupal_add_js from within the html--node--XX.tpl.php file, it does not work.

But when I use it in the page--node--XX.tpl.php it does. I don't understand what causes the difference in the behavior. I thought that this would be the same.
These are the lines I am adding in both cases:

drupal_add_css("sites/all/libraries/shadowbox/shadowbox.css", $type = 'file', $media = 'all', $preprocess = FALSE);
drupal_add_js("sites/all/libraries/shadowbox/shadowbox.js", array('type' => 'file', 'scope' => 'header', 'weight' => 5));
drupal_add_js("Shadowbox.init({skipSetup: true});", array('type' => 'inline', 'scope' => 'header', 'weight' => 6));

Can anyone illuminate me here?


texts:
I have two pages, the first page 'test' has links to test/%.
On test/% I want to have different titles but some how this wildcard
and the title callback aren't working properly.

/**
 * Implements hook_menu().
 */
function cjgimport_menu() {
  $items['test'] = array(
    'title' => t('Test title'),
    'title callback' => 'function_title_callback',
    'title arguments' => array(0),
    'type' => MENU_NORMAL_ITEM,
    'access arguments' => array('access content'),
    'page callback' => 'function_content_callback',
  );

  $items['test/%'] = array(
    'title' => t('Test title'),
    'title callback' => 'function_title_callback',
    'title arguments' => array(1),
    'type' => MENU_NORMAL_ITEM,
    'access arguments' => array('access content'),
    'page callback' => 'function_content_callback',
  );

  return $items;
);

/**
 * Custom callback function for title
 */
function function_title_callback($arg) {
  if($arg == 0) {
    $title = ucfirst(arg(0));
  } else {
    $title = ucfirst(arg(1));
  }
  return $title;
}

Can anyone tell me why the title doesn't work on the test/% pages?


texts: View of date field showing time on all day events

texts:
I have a Event content type with a body and date field from the Date module.

I have a view that shows the events as a block in ascending order, and everything looks cool when I view as an admin. All day events are displayed without a time.

  Event Foo
  12/06/2014 to 12/09/2014

However when I look at the block as an anonymous user all day events show up as starting and ending at 2:00

  Event Foo  12/06/2014 - 02:00 to 12/09/2014 - 02:00

How can I get rid of the time?

Edit:
How the Date field looks in the node edit form:


texts:
In my computed field I'm trying to make it display the field and it's label only if the value is negative.  If it is above 0 it should not display anything, not even field label.

So far in "Display Code (PHP)" I have:

if $entity_field_item['value'] < '0' { ;
$display_output = $entity_field_item['value'] . '%';
}else{$display_output = ''};

But it just returns the label with no value.

The classic

$display_output = $entity_field_item['value'] . '%';

works fine though.


texts:
I have a tree of taxonomies, these taxonomies are the menu of my site and they are working with taxonomy_menu module, I am displaying the menu through a view, but I'm only showing the children as low level, for example:

Parent 1

Child 1
Child 2
Child 3

Test 1
Test 2
Test 3
Test 4

Parent 2

Child 4
Child 5
Child 6

Parent 3

If access to view link parent1 show me only:

Child 1
Child 2
Child 3

If access to Child 3 links show me the children of child 3

Test 1
Test 2
Test 3
Test 4

But if access to test 1 show brothers need taxonomies:

Test 1
Test 2
Test 3
Test 4

If filter by parent term works for me but when the taxonomy have more children, but when you have no more children need to show the brothers.

Any idea?


texts: Logic on Node Add Page for Specific Content Type

texts: I created a new content type in Drupal 7 and I want to make a template to customize the node add page for that content type. I want to be able to check if the user is authenticated with Facebook before they can use the node add form. If user is not authenticated then I will show them a paragraph explaining that they need to authenticate via facebook before they can use this form. I want them to always see the form link but they can only use the form if they are authenticated to facebook. I just don't know where to put it. Is it possible to make a template file specifically for that node add page so that I can include my logic?


texts:
Situation :

I have added few more fields in user registration form using account settings->manage fields. The type of the field is cck address field.
I created a new view as json document, and I added that field to the view as well, but the problem is its not expanding it as the way I wanted.
What I mean is, I filled the user registration form address field as first name, last name, street etc etc. but I am either seeing the whole field in a single line under Address tag in json or just a tag like this {"nodes":[{"node":{"name":"admin","field_address":"1"}}]}
but what I want is like this:

{"nodes":[{"node":{"name":"admin","first_name":"xyz","last_name":"sdas","street":"ssdsf"}}]}

Any suggestions?


texts: How to get the commerce subscription status for current user on particular product page?

texts: How can I get the product subscription status for current logged in user on particular product page. Suppose user can subscribe for a video tutorial and we have video as a product then how can we know that current user had already subscribed to this product or not.


texts:
When I want to add my user picture, the picture can't upload and when I inspect it the link is broken and get this error:

  Warning: array_key_exists() expects parameter 2 to be array, null given in theme_image_formatter() (line 605 of /home/webpenir/public_html/modules/image/image.field.inc).

However, when I add a picture for another user, it works pretty good.

how can I solve this?

EDIT

Only user 1 can't upload but other users can do, which is really strange.


texts: How to hide particular field for specific role?

texts:
I have Article page content type with field title,description,ad_article_top,video etc.
Also have one other role writer.writer can create article page content.

My issue is how to hide the ad_article_top field for writer role at the time he create content but if super admin create article page content the ad_article_top field not hidden

Give me some solution for solving this issue.


texts: How to get the first non-empty field value of a referenced entity in views?

texts:
The website has two content types:
Magazine and issue.
I'm using the Entity Reference module to create a magazine archive website.

I have a views that list all magazines. Each magazine is with an image of issue that related to this magazine. There is a relationship (entity reference: referencing entity) and the aggregation setting is active (use aggregation).
Everything is OK but there is a problem I couldn't solve.
The image for each magazine is the image of the first issue of this magazine. But not every "first issue" has an image and it shows the default image.
What I want to do is to show the first issue's image that's image field is non-empty or show any related issue's image on this views. How can I do that?
Note: Some magazine's any issues doesn't have any image and if I filter out these issues, then the related magazine will not be shown. I think what I want to do is if any of the issue has an image show it or show the default image.


texts: Views doesn't like multiple entity references in my entity

texts:
I have a couple of custom entities defined by my module against plain tables in my database (because I have a lot of data and don't want to unpack it all into fields).

My contact entity has a entity_reference field to my subject entity with unlimited cardinality:

$fields['subjects'] = BaseFieldDefinition::create('entity_reference')
                    ->setLabel(t('Subjects'))
                    ->setSetting('target_type', 'pw_subject')
                    ->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
                    ->setdisplayOptions('view', array(
                      'type' => 'entity_reference_entity_label'))
                    ->setDisplayOptions('form', array(
                      'type' => 'entity_reference_autocomplete'));

The subject entity is very simple with just id and name fields.

This causes the Entity API to create a join table and it all seems to work with regular node viewing and editing.  However when I try to add a relationship in view a view based on contact to subjects I get an SQL error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'pw_contact__subjects.subjects' in 'on clause': SELECT pw_contact.id AS id, pw_subject_pw_contact__subjects.id AS pw_subject_pw_contact__subjects_id FROM {pw_contact} pw_contact LEFT JOIN {pw_contact__subjects} pw_contact__subjects ON pw_contact.id = pw_contact__subjects.entity_id AND pw_contact__subjects.deleted = :views_join_condition_0 LEFT JOIN {pw_subject} pw_subject_pw_contact__subjects ON pw_contact__subjects.subjects = pw_subject_pw_contact__subjects.id LIMIT 11 OFFSET 0; Array ( [:views_join_condition_0] => 0 )

It looks seems views is looking for a subjects column rather than the subjects_target_id that it should use - it seems to think this is a value field rather than a reference?

Anyway I'm a bit lost in the code trying to work out what's going on so any pointers appreciated.


texts: How can I get translated path aliases for a custom language switcher?

texts:
The Drupal 8 standard "Language switcher" dropdown does not give me what I need.
What I need is to break everything apart into groups and subgroups, in a div, and have custom text for each Language, some of which are custom languages.

As ugly as my code is, I'm almost there, but I'm getting a node, instead of the actual page.

if I click on U.S. Spanish, I get:
http://website.com/es-us/node/123
but I want:
http://website.com/es-us/contactenos

if I click on U.S. English, I get
http://website.com/en-us/node/123
but I want:
http://website.com/en-us/contact-us

(note the difference in URL alias, by language)

I've found this page, and used it as my starting point: https://www.drupal.org/docs/8/multilingual/enable-language-negotiation

As I attempt to understand how I might do it, I have in my themename.theme:

<?php

/**
* Implements hook_preprocess_page().
*
* @param $vars
*/
function themename_preprocess_page(&$vars) {
 $current_path = \Drupal::service('path.current')->getPath();
// not used yet...
$language = $vars['language']->getId();

  $fr_ca = '';
  $en_ca = '';
  $en_us = '';
  $es_us = '';
  $en_gb = '';

  $vars['en_us'] = '/en-us' . $current_path;
  $vars['es_us'] = '/es-us' . $current_path;
  $vars['en_ca'] = '/en-ca' . $current_path;
  $vars['fr_ca'] = '/fr-ca' . $current_path;
  $vars['en_gb'] = '/en-gb' . $current_path;
 }

Then I was going to hardcode into the page.tpl.twig (for now, while I learn) something similar to:

Americas

U.S.

      English
      Español

Canada

      English
      Francais

Europe

I'm sure there are better ways to do this for a more experienced coder. But for now, I'm hoping I can get the alias in there.

I can't use "$current_uri = \Drupal::request()->getRequestUri();"

Because that is different for each page... For example, "contactenos" in Spanish versus "contact-us" in English


texts: How to sort $nodes after executing an EntityFieldQuery

texts:
Am using Drupal 7 and EFQs. After executing the query and geting all the nodes listed in a custom module, I need to sort them on node title field.

I can use usort and other php functions but my problem is the field am sorting on can't seem to get it from $nodes. How can I achieve this? Nothing that I must sort after the EFQ execution therefore I can't use fieldOrderBy.

The thing is, am callling 2 EFQs with different fields and merging them. That is why I need to sort them after -> execute

Below is the code after the EFQ execution:

    $nidsMall = array_keys($resultMall['node']);
    $nidsStore = array_keys($resultStore['node']);

    $nodesStore = entity_load('node', $nidsStore);
    $nodesMall = entity_load('node', $nidsMall);

    $nodes = (object) array_merge((array) $nodesStore, (array) $nodesMall);

I'm making sure that both EFQs return the wanted results.

I need to sort $nodes on node title or any other field. (both content types mall and store have that field, naturally)

Appreciate any help given.

Thanks


texts: How to update old CAPTCHA to use reCAPTCHA V2

texts: I am very new to drupal I am trying to update a drupal site to reCAPTCHA V2 but I can't figure out how to. I know I need a new site key and secret key which I have gotten; but how do I actually make the CAPTCHA module update so I can put in my new keys. And so I can get the new reCAPTCHA check boxes instead of the images. I am using Drupal 7. Thank you for any help.


texts: Limiting number of multiples in a drupal webform in an ajax callback

texts:
I have a form with a select element to choose the number of guests you want to add to an event.  This select has an ajax callback that updates a container that holds a contact composite element.

I am trying to in my ajax callback update the number of multiple contact elements to the value of the number of guests select box.  Anyone have any thoughts?  If I use a form alter like below on initial load the number of elements updates correctly.

My alter attempting to just set multiple number outside ajax

function lebow_events_webform_submission_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
  $form['elements']['guest_info']['guest_contact']['#type'] = 'webform_multiple';
  $form['elements']['guest_info']['guest_contact']['#webform_multiple'] = TRUE;
  $form['elements']['guest_info']['guest_contact']['#multiple'] = 10;
  $form['elements']['guest_info']['guest_contact']['#cardinality'] = 10;
  $form['elements']['guest_info']['guest_contact']['#sorting'] = FALSE;
}

My webform source

registration_type:
  '#type': select
  '#title': 'Registration Type'
  '#options': registration_types
guests_container:
  '#type': container
  '#states':
    invisible:
      ':input[name="registration_type"]':
        value: ''
  number_of_guests:
    '#type': select
    '#title': 'Number of guests'
    '#options':
      - '0'
guest_info:
  '#type': container
  '#title': 'Guest Info'
  guest_contact:
    '#type': contact
    '#title': 'Contact Info'
    '#multiple': 2
    '#multiple__add_more': '2'
    '#company__access': false
    '#phone__access': false
    '#address__access': false
    '#address_2__access': false
    '#city__access': false
    '#state_province__access': false
    '#postal_code__access': false
    '#country__access': false

My alter to add ajax callback (and try setting number of multiples)

function lebow_events_webform_submission_form_alter(array &$form, FormStateInterface $form_state, $form_id) {

  $form['elements']['guests_container']['number_of_guests']['#options'] = ['' => '- None -'];
  $form['elements']['registration_type']['#ajax'] =
    array(
      'callback' => 'lebow_events_registration_change',
      'wrapper' => 'edit-guests-container',
    );
  $form['elements']['guests_container']['number_of_guests']['#ajax'] =
    array(
      'callback' => 'lebow_events_guests_change',
      'wrapper' => 'edit-guest-info',
    );

  $form['elements']['guests_container']['number_of_guests']['#validated'] = TRUE;
  $form['elements']['guest_info']['guest_contact']['#type'] = 'webform_multiple';
  $form['elements']['guest_info']['guest_contact']['#webform_multiple'] = TRUE;
  $form['elements']['guest_info']['guest_contact']['#multiple'] = 10;
  $form['elements']['guest_info']['guest_contact']['#cardinality'] = 10;
  $form['elements']['guest_info']['guest_contact']['#sorting'] = FALSE;
}

My ajax callback

function lebow_events_guests_change(&$form, \Drupal\Core\Form\FormState $form_state) {

  $form['elements']['guest_info']['guest_contact']['#type'] = 'webform_multiple';
  $form['elements']['guest_info']['guest_contact']['#webform_multiple'] = TRUE;
  $form['elements']['guest_info']['guest_contact']['#multiple'] = $form_state->getValue('number_of_guests');
  $form['elements']['guest_info']['guest_contact']['#cardinality'] = $form_state->getValue('number_of_guests');
  $form['elements']['guest_info']['guest_contact']['#sorting'] = FALSE;
  $form['elements']['guest_info']['guest_contact']['#element']['#webform_multiple'] = TRUE;
  $form['elements']['guest_info']['guest_contact']['#element']['#multiple'] = $form_state->getValue('number_of_guests');

  $message = $form['elements']['guest_info'];

  $response = new \Drupal\Core\Ajax\AjaxResponse();
  $response->addCommand(new \Drupal\Core\Ajax\HtmlCommand('[data-drupal-selector=edit-guest-info]', $message));

  return $response;

}


texts: Use custom field in header (Another region)

texts:
I'm new to drupal 8. I have a content with couple of custom fields in it. Let's say its name is Title In Header. So whenever you need to add new content you have to fill this too.

Now this whole content is in Content Block (And Content Block is in Content region).

My template has Header region, Content region and Footer region.

My problem is that I want to have access to that custom field (Title In Header) in a block in header region. But I don't know how to do this and what block should I use to add it in header region. I think it's not a good approach to add another Content Block in Header region to show just a custom field as it shows the whole content. So what should I do?


texts: Why do OG Vocabulary terms not list content?

texts:
Drupal 7.41, OG 2.7, og_vocab 1.2.

I've created a group, and a group content type. I added a og vocab to the group and enabled it for the content type. The og_vocab field shows on the node edit page, and the terms in the og_vocab are displayed on the node view. But when I click a term to view all content that has been tagged with that term, the term page does not list any content.

It looks something like:

# Term
Primary tabs
View(active tab)    Edit

There is currently no content classified with this term.

If I do the same thing with a normal vocabulary, the term page does list the content.

I've tried just the taxonomy/term/<term id> path, as well as the alias pathauto generated <og vocab name>/<term name>. Both show the same thing.

As far as I can tell, the only modules that could be overriding the path are views and page manager. I made sure neither was doing so.

So, how do I get the term page for og_vocab terms to list the associated content?


texts: Migrating csv data as array into multi-field

texts:
How do I migrate a sequence of data into a multi-value field?

I am learning D8 migration and working on a large CSV of historic census data from around the world. Example below:

id,Country Name,Country Code,Indicator Name,Indicator Code,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018
1,Aruba,ABW,"Population, total",SP.POP.TOTL,54211,55438,56225,56695,57032,57360,57715,58055,58386,58726,59063,59440,59840,60243,60528,60657,60586,60366,60103,59980,60096,60567,61345,62201,62836,63026,62644,61833,61079,61032,62149,64622,68235,72504,76700,80324,83200,85451,87277,89005,90853,92898,94992,97017,98737,100031,100834,101222,101358,101455,101669,102046,102560,103159,103774,104341,104872,105366,105845

My migration yml file is as follows:

uuid: 6c54b8f4-96c7-4678-8919-b20c8b318c82
langcode: en
status: true
dependencies: {  }
id: World_Census_Data
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags:
  - CSV
migration_group: random_migrations
label: 'International census csv data'
source:
  plugin: csv
  path: /var/www/random-migrations/modules/custom/random_migrations/sources/census-58-years.csv
  ids:
    - id
  delimiter: ','
  track_changes: true
process:
  type:
    plugin: default_value
    default_value: census
  title: 'Country Name'
  field_country_code: 'Country Code'
  field_count:
    plugin: array_build
    default_value: 0
    value:
      - 1960
      - 1961
destination:
  plugin: 'entity:node'
migration_dependencies: {}

Instead of manually creating an individual field for each year, I created the field_count field which is an Interger field set to allow unlimited entries. My idea is to import all the population numbers from 1960 to 2018 as new entries of field_count for each country.

My problem is the population data is not being imported. Can anyone advice if my proposed solution possible and if it is, what I need to change/fix in my yml to get my migration working?

Help, please.


texts:
I am looking to print a simplified gmap macro builder in a page so users can submit maps on pages.

I am having difficulties printing any of the gmap macro. Ultimately I would like to print the simplified form into a modal but any help towards that would be appreciated.

Has anyone programmatically printed a gmap macro builder into a page?

Thank you for your help

This is what I have started for my code. I am stuck as where to go from here though. I have just pulled pieces that I believe relevant.

<?php
// Implementation of hook_menu()

function gmap_macro_builder_menu() {
 $items['map/macro'] = array(
 'type' => MENU_NORMAL_ITEM,
 'title' => 'Build a GMap macro',
 'access arguments' => array('create gmap macro'),
 'page callback' => 'drupal_get_form',
 'page arguments' => array('gmap_macro_builder_form'),
);
return $items;
}

//Simplified gmap macro builder form

function gmap_macro_builder_form($form, &$form_state, $settings = array(), $hide = array()) {
$path = drupal_get_path('module', 'gmap');

$form['macroform'] = array(
 '#type' => 'fieldset',
 '#title' => t('Gmap Macro Creation'),
 '#theme' => 'gmap_macro',
);

$form['macroform']['mapdiv'] = array(
 '#type' => 'gmap',
 '#map' => 'macro_map',
 '#settings' => array_merge(array(
  'points' => array(),
  'pointsOverlays' => array(),
  'behavior' => array(
    'dynmarkers' => TRUE,
  ),
 ), $settings),
);

$defaults = array_merge(gmap_defaults(), $settings);
gmap_widget_setup($form['macroform']['zoom'], 'zoom', 'macro_map');

$form['macroform']['macro'] = array(
 '#type' => 'gmap_macrotext',
 '#map' => 'macro_map',
 '#default_value' => '',
 '#title' => t('Macro text'),
);

foreach ($hide as $field => $mode) {
 if (isset($form['macroform'][$field])) {
  if ($mode == 1) {
    $form['macroform'][$field]['#type'] = 'hidden';
    $form['macroform'][$field]['#value'] = $form['macroform'][$field]['#default_value'];
  }
  elseif ($mode == 2) {
    $form['macroform'][$field]['#prefix'] = '
';
    $form['macroform'][$field]['#suffix'] = '
';
  }
 }
}

return $form;
}

?>


texts:
I am creating a Drupal Commerce website to sale Custom Stitched Thobes in which I need to get the Measurement from the customers. I am unable to understand where & how should I add fields to take the measurements for the product he adds to cart.

Actually the idea is to offer some standard sizes like S,M,L or XL in case he don't want the standard sizes he can select Custom in Sizes Drop down, which will show up custom size text fields.

I was looking for a straight forward way to add text fields in Product Type through manage fields and check Enable this field to function as an attribute field on Add to Cart forms. so those fields can be appeared on add to cart form but unfortunately this option is not available for text fields.


texts:
I have a webform where there are conditional elements that are reliant on the user being a bona fide affiliate of our organisation. Both Anonymous and Authenticated users can use this form.

I currently have it using the CiviCRM elements to look for an existing contact in order to fulfill the conditional; however we have found that if we have had contact with the user (ie they previously were bona fide, or have submitted other forms in the past) then the conditional is fulfilled.

(Yes, that is kind of obvious.... we overlooked it)

I think I have three options;

Have a webform field, hidden, pertaining to the user role. this can then be used as a conditional.
Use a Workflow Rule to redirect users with particular roles to a different, but identical, webform. Then I would have two webforms each witht eh appropriate elements.
Completely remove the connection to CiviCRM for the webform and rely on our staff to filter the wheat from the chaff.

Option 1 is probably the most logical solution in my mind, but I can not find a way to poll Drupal for the user role.


texts: Template suggestions periodically not being recognized

texts:
I have some simple template suggestions setup in my THEME_preprocess_node() function. Example:

function my_theme_preprocess_node(&$vars) {
  if ($vars['node']->type == 'MY_TYPE' && $vars['view_mode'] == 'MY_VIEW_MODE') {
    $vars['theme_hook_suggestions'][] = 'my__template';
  }
}

Then I have the template file (named my--template.tpl.php) setup in my theme. I cleared the cache, and this is recognized right away and works fine.

Then, after about an hour, if I refresh the page that uses the template, it suddenly is not recognized anymore. I clear cache again and it comes back.

Has anyone experienced this before?

Just FYI, I am using hook_theme() in a custom module to specify the theme for this page based on the URL alias.


texts: Views exposed date filter creating wrong query

texts:
I created a simple view page of content with an exposed date filter. The resulting query is:

SELECT node.created AS node_created, node.nid AS nid
FROM
{node} node
WHERE (( (node.status = '1') AND (node.type IN  ('press_release')) ))
ORDER BY node_created DESC
LIMIT 10 OFFSET 0

When I tried to create the same view as a block, it gave me another query:

SELECT node.created AS node_created, node.nid AS nid
FROM
{node} node
LEFT JOIN {field_data_field_date} field_data_field_date ON node.nid = field_data_field_date.entity_id AND (field_data_field_date.entity_type = 'node' AND field_data_field_date.deleted = '0')
WHERE (( (node.status = '1') AND (node.type IN  ('press_release')) AND (DATE_FORMAT(ADDTIME(field_data_field_date.field_date_value, SEC_TO_TIME(-14400)), '%Y-%m-%d') = '') ))
ORDER BY node_created DESC
LIMIT 3 OFFSET 0

The later query is not correct. The resulting view is empty by default and it doesn't even show the exposed date filter. What is happening here?

EDIT:
Here is a screenshot of the page view edit screen:

EDIT:
Here is a screenshot for the date filters of the page and the block. Neither is required and the settings are the same:


texts:
In a custom D8 theme, we have some strings in twig using |t filter and in php using $this-t() funtion.

example :

{{'More Headlines'|t}}

$this->t('replies')

These strings are not listed in /admin/config/regional/translate. What's the right way to translate it via the administration interface like it was possible with D7?


texts: scheduling backup_migrate with elysia cron

texts: I am looking at scheduling backup & migrate jobs with the elysia cron module. Can I ask how to call backup & migrate directly from the elysia script? Or should I be calling "drush bam"?


texts: Problems with additional trailing slash in when using drush rsync

texts:
If I use drush rsync the output is as follows:

user@drupal:~/html$ drush rsync @live @local
You will destroy data from var/www/ and replace with data from root@eso-
meetu.de:/var/www/virtual/eso-meetu.de/htdocs//
Do you really want to continue? (y/n): y
root@eso-meetu.de's password:
rsync: mkdir "/var/www/var/www" failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(605) [Receiver=3.0.9]
Could not rsync from                                                [error]
root@eso-meetu.de:/var/www/virtual/eso-meetu.de/htdocs// to var/www/
user@drupal:~/html$

The alias file I've created contains:

<?php

$aliases['live'] = array(
'uri' => 'www.eso-meetu.de',
'root' => "/var/www/virtual/eso-meetu.de/htdocs",
'remote-user' => 'root',
'remote-host' => 'eso-meetu.de',
'ssh-options' => '-o PasswordAuthentication=yes',
'path-aliases' => array(
'%dump-dir' => '/tmp',

),
'command-specific' => array (
'sql-sync' => array (
'no-cache' => TRUE,
),
),
'databases' => array(
'default' => array(
'default' => array(
'driver' => 'mysql',
'database' => 'meetu_original',
'username' => 'removedhere',
'password' => 'removedhere',
'host' => 'localhost',
'prefix' => '',
'collation' => 'utf8_general_ci',
 ),
 ),
 ),
 );
 $aliases['local'] = array(
 'uri' => 'www.drupal.dev',
 'root' => 'var/www',
 'databases' => array(
 'default' => array(
 'default' => array(
 'driver' => 'mysql',
 'database' => 'drupal',
 'username' => 'drupal',
 'password' => 'drupal',
 'host' => 'localhost',
 'prefix' => '',
 'collation' => 'utf8_general_ci',
 ),
 ),
 ),
 );'

I have no Idea how to get rid of the sceond slash behind htdocs This shalsh causes an rsync error.

Has anybody an idea what I have to do here?


texts: Language switcher doesn't switch to the correct language view

texts: I am using Drupal 7 and have built views with two languages. I can display the English view normally but when I click on the link of the other language on the language switcher the view only switches direction to the right without changing to the translated view. All the needed core modules enabled, I also installed the i18n latest version module. As for normal pages, everything works perfect. I have tried using the filter (content language) with no results. I have googled the issue and got some solutions that has given no fruitful results. I would appreciate any help. Thanks


texts: Include View In Node That References Other Nodes Based On Joined Field

texts:
I'm getting a little confused trying to get this one, thought I'd get some help.

I have two content types (A and B) both with the same list field (My List). I want to include a view in content type A that finds all nodes of content type B with the same My List value.

I've looked through Context, Entity Reference (which I didn't really get) and Views Relationships and Contexts but couldn't make much sense of it.

What's the best way to accomplish this?

Edit:

I've added an image of my desired output (from actual site) and the current fields of content type's A and B.

An important note is that the Views block/whatever showing content type B needs to be shown in the normal node page of content type A.

I know this isn't the best way to do this, but this feature wasn't planned and the client just wants it to work as fast as possible

Content Types Fields:

I've excluded irrelevant fields such as path and meta tags.

Content type A:

Title - text
Body - HTML (w/ text inside)
Department - List

Content type B:

Title (name) - text
Description - text
Department - List

Desired Output:


texts:
I have a webform for students to select their teachers.
The data displayed in Views to show the submitted values are the following:

----------------------------------
Instructor  | student
----------------------------------
teacher A   | student name A
teacher B   | student name B
teacher A   | student name C
teacher A   | student name D
--------------------------------

When "teacher A" login, I am expecting "teacher A" can see all his students, without entering filter value "teacher A"

----------------------------------
Instructor  | student
----------------------------------
teacher A   | student name A
teacher A   | student name C
teacher A   | student name D
--------------------------------

I want to have something like automatic filter with the field "Instructor", not typing own name in the exposed filter. So every teacher can get his own students automatically in the table.

Is there any specific module to do that, or a way to get that?


texts: Is it properly to include a third-party php library via composer without creating drupal module for it?

texts:
I want to ask a theoretical question.

For example, there is a project on Drupal 8. Working on the project, developers find a php library on the GitHub, include it via Composer and use it in their modules.

They don't create drupal 8 module which would present the library and contain files of the library, copied from GitHub before. And to use the library it would be necessary to install the module.

Is it the correct way to attach an external php library via composer and afterwards use it without creating a module for Drupal 8 for this library ?


texts: The standard method for adding css classes to twig templates

texts:
What is the standard method for adding classes in twig template?
I'm going straightly to the main subject point:

Scenario-1:
I have some classes and I want to collect them in a group and add this group to the existing group that added before:
I try below code but it seems that something is wrong.

{%
  set classes = [
    'block',
    'block-' ~ configuration.provider|clean_class,
    'block-' ~ plugin_id|clean_class,
  ]
%}

{%
  set my-classes = [
    'class-name-1',
    'class-name-2',
    'class-name-3',
    'class-name-4',
  ]
%}
<div{{ attributes.addClass('classes my-classes') }}>

What tips should I consider for a class group name, For example, Is it important to follow PHP variables name convention, Can I use hyphen character in class group names?

Scenario -2:
I have few classes names and I want to add theme straightly to default added classes, like below:

views-view-unformatted:

<div {{ row.attributes.addClass(row_classes 'class-name-1 class-name-2') }}>


texts:
How do you pass a filter value by url in drupal 8?

On my website I have a view with a select to filter the results. This result is based on taxonomy term.

I have 4 options, All, badkamerrenovatie, elektriciteit and verwarming.

How can I set the filter by url so that I directly have a filtered list if people click on a link related to the taxonomy term. For example if people are on page elektriciteit and click trough to realisatie they see the filtered list and don't have to choose from the select.


texts: How can I convert an existing image field into a Media image reference field?

texts: I have an image field that I created before Drupal 8.5, when media was introduced in the ui. The field already contains content and I would like to make use of the reusable media functionality that is now in core. How can I make use of media for this image field without deleting the current content and having to create a new media field?


texts: After adding a new field to a feature, my dev site crashes

texts:
I added a new field (field_acc_guide) to my user accounts in a feature.  Then, I reset my dev site by overwriting the database and files with those from production.  However, this results in an error:

WD php: PDOException: SQLSTATE[42S02]: Base table or view not found:     [error]
1146 Table 'pantheon.field_data_field_acc_guide' doesn't exist:
SELECT t.*
FROM
{field_data_field_acc_guide} t
WHERE  (entity_type = :db_condition_placeholder_0) AND (entity_id IN
(:db_condition_placeholder_1)) AND (language IN
(:db_condition_placeholder_2)) AND (deleted =
:db_condition_placeholder_3)
ORDER BY delta ASC; Array
(
    [:db_condition_placeholder_0] => user
    [:db_condition_placeholder_1] => 0
    [:db_condition_placeholder_2] => und
    [:db_condition_placeholder_3] => 0
)
 in field_sql_storage_field_storage_load() (line 412 of
/srv/bindings/3e6587f55074463ea17292eda4e1ac67/code/modules/field/modules/field_sql_storage/field_sql_storage.module).

I have tried re-copying from production into dev but the same error occurs.  I try to reset the feature (that contains the field) with Drush in order to create the field but I continue to get the same error.

How can I prevent the error so that I can revert the feature so that my site doesn't crash?


texts:
I'm using Drupal 7, and I need to retrieve data from a web service. This data cannot be stored in the Drupal database due to regulations.
What would be the best practice for retrieving this data: using Java, Drupal Entities, or storing in tokens?

We are currently making calls based on an ID stored in the database and displaying the data from the web service associated with that ID.

The problem with this is that it's all being done outside of Drupal, and we are unable to use Drupal to manage any of this content. So we have many modules with custom code to do everything from creating forms, pre-filling forms, tying into a users account on Drupal, etc.

We are at a point where we can totally refactor how this works.

Do you have any suggestion on how we can improve this?


texts:
Secondary menu links are listed with the default theme.

I want to add a hover option to it so that menu links will always pop up when a user hovers on a button.

I already built it with html but I couldnt integrate the existing codes in it.

html

drupal default code

    <?php if ($secondary_menu): ?>

        <?php print theme('links__system_secondary_menu', array(
          'links' => $secondary_menu,
          'attributes' => array(
            'id' => 'secondary-menu-links',
            'class' => array('links', 'inline', 'clearfix'),
          ),
          'heading' => array(
            'text' => t('Secondary menu'),
            'level' => 'h2',
            'class' => array('element-invisible'),
          ),
        )); ?>

    <?php endif; ?>

  <?php if ?>

FYI: I couldnt locate to function links__system_secondary_menu in any of the files.


texts: #attached property doest't work!(render array/form api)

texts:
the css file style.css never get loaded when using the form api #attached properties. here is my code:

mymodule_menu() {

  $items['test'] = array (
            'title' => t('test css'),
            'page callback' => 'drupal_get_form',
            'page arguements' => array('test_attach_css'),
            'access callback' => TRUE,
            );

return $items;

}

function test_attach_css($form,$form_state) {
   $markup = '
style the font as red
';
   $form['content']['#markup']  = $markup;
   $form['content']['#attached']['css'][] = drupal_get_path("module",       "mymodule")."/style.css";

return $form;
  }

the content of css file:

.test {

 color:red;

}


texts: Show a view on a custom nodetype only if the logged in user is the author of this node

texts:
I'm using Drupal 7, with the Views module version 3, and the Context module (no block).

I have a draggable view I want to show on a gallery node. The draggable view shows the image nodes belonging to this gallery node for sorting.

Now I want to limmit the display of this view to the author of the gallery node. (Only the author of the gallery node should organize the image nodes.) I think this could be done with context or relationship (and some coding) inside views, but I don't know how.

I know how I can display the view only on the gallery-node (via Context module). So I only need a way to limit the display of the view to the author of the gallery.

Maybe someone has a solution.


texts: How should I change the permissions PRIVATEMSG for users in order them to have the access?

texts:
Good day,
I've marked read, write and delete the privatemsg for the authenticated users but they don't still have access to the pages such as user/user-id/messages. The access is only granted with "read all" permission.
I use privatemsg 6.x-1.5
Thanks.


texts: Drag and drop module - Display uploaded images inline

texts:
Using drag and drop module I am able to upload multiple images but once it is uploaded, it is displaying in table format creating new row for each image uploaded.

How do I display images inline and remove link below each image.

This is the current rendered structure

File information	Weight	Operations

..
..
..

Thanks!


texts: Add roles to user during create and save account

texts:
I want to add a custom role to a user during hook_user_create() and hook_user_update(). All goes well during user create, as long as I do $user->save() in the end. The site crashes during hook_user_update() if I do $user->save(). No role is added if I simply add the role with $user->addRole('role_name'), but don't save it.

This is for Drupal 8.

What am I doing wrong?


texts: How to display another message instead of 403 when trying to open a display of an unpublished product?

texts:
When somebody tries to open the product display page for the product which is unpublished, it results in the access denied 403 page being shown.

I want to display a message ("This product is not available as of now, check other products.") instead of showing 403 page.


texts: How do I access my fields in a .tpl file

texts:
I have a file views-view--MyView--block-2.tpl.php

there is no $fields variable, it doesn't exist.

if I do a foreach($view->field as $v=>$f)  and print both $v will show me all my fields in that view and display

created
title
field_op_author_nid
field_main_image_fid
field_teaser_value
comment_count

but $f is always empty.

How do I access my fields?

[EDIT]
Ok, let me clarify. the .tpl file I have renders just fine. the markup I have in that file shows up. The issue is that I cannot access the fields I set up in the view and displaye. I tried changing the filename to include -fields- and I indeed did get the $fields variable. This looks to be exactly the same as the $view variable that I had before, which I don't know how to get data out of. I can see the fields I need in there but the var_dump($fields( or $ view)) is about 20 pages long and every example I have seen has been just using $fields["fieldname"], which does not work.

Am I just maybe doing this wrong entirely? What is the best way to set these up, is it to have multiple tpl files, one for each field and row?


texts:
Is there any way to add a role permission to specific node? I have a block-view Home slider, and I want to add a php validation to a specific slide.

I have to edit the node.tpl of my slide ? Or maybe the view output tpl? I'm in a Drupal 7 installation.


texts: How can i put popup box captcha on managed file remove button?

texts:
Can We write function for remove button as I want to display Captcha in popup on Remove button for security reason.

same type of some function like used in below post.

How can I automatically upload images on file selection rather than pressing the upload button?


texts: Set Default Value for Image Field contain Multiple Images

texts:
I've added a multiple image field to the user account that uses the multiupload_imagefield_widget and it works when I edit the account.
On the other hand, I have a custom module with a form that I would like to edit just this field (I have a submit handler to update the user data). I call user_load to display the data and I can see the data is there in the debugger, but no images are displayed on the form.
What do I have to do to make them show up?
Here's my code:
$user_data = user_load($user->uid);
$form['my_imageGallery'] = array(
  '#type'             => 'image',
  '#title'            => t('Image Gallery'),
  '#default_value'    => isset($user_data->field_galeria) ? $user_data->field_galeria : null,
  '#upload_location'  => 'public://user_galleries/',
  '#upload_validators' => array('file_validate_extensions' => array('png jpg gif')),
);


texts:
I made a custom module that extends TwigExtension, where I define all sort of custom twig filters. It worked well until the update to 8.3, where TwigExtension changed slightly:

/**
* Constructs \Drupal\Core\Template\TwigExtension.
*
* @param \Drupal\Core\Render\RendererInterface $renderer
*   The renderer.
* @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
*   The URL generator.
* @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
*   The theme manager.
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
*   The date formatter.
*/
public function __construct(RendererInterface $renderer,
  UrlGeneratorInterface $url_generator, ThemeManagerInterface
  $theme_manager, DateFormatterInterface $date_formatter) {
  $this->renderer = $renderer;
  $this->urlGenerator = $url_generator;
  $this->themeManager = $theme_manager;
  $this->dateFormatter = $date_formatter;
}

My service yaml looked like this:

services:
  custom_twig.twig.extension:
    arguments: ['@renderer']
class: Drupal\custom_twig\TwigExtension\LabTwigExtension
tags:
  - { name: twig.extension }

And I changed the services to have the new required ones.

services:
  custom_twig.twig.extension:
    arguments: ['@renderer', '@url_generator', '@theme.manager','@date.formatter']
class: Drupal\custom_twig\TwigExtension\LabTwigExtension
tags:
  - { name: twig.extension }

Although I set the correct arguments, Drupal throws an error:

  Recoverable fatal error: Argument 2 passed to Drupal\Core\Template\TwigExtension::__construct()
      must implement interface Drupal\Core\Routing\UrlGeneratorInterface, none given, called in /A

I am fairly certain that url_generator implement UrlGeneratorInterface. Is there anything else I got wrong?


texts: Form submits before File Upload completes

texts:
I have a form. It works... but the user must wait for the large file to upload first or they won't be processed by the form. The upload form will change from the Upload button to the name of the file with a Remove button.

    $validators = [
      'file_validate_extensions' => ['zip'],
    ];

    $form['static_archive'] = [
      '#type' => 'managed_file',
      '#name' => 'static_archive',
      '#title' => t('Static archive'),
      '#size' => 200,
      '#description' => t('ZIP format only'),
      '#upload_validators' => $validators,
      '#upload_location' => 'private://imports/uploads/',
    ];

    ...
    other fields here
    ...

    $form['actions']['#type'] = 'actions';
    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Import Archive'),
      '#button_type' => 'primary',
    ];

This form is outputted on a route like I want, file is processed, etc. The only catch is the user having to wait.

I'm hoping there is some JS method for disabling the Submit button while the file is uploading. Bonus if there's a way to show upload progress or has a message explaining why it's disabled. The file upload is not a required field, so when the uses the form and the file doesn't upload before they hit submit, it's lost in the wind and the user doesn't even get an error.

This isn't webforms, so this doesn't solve it.
https://www.drupal.org/project/webform/issues/3010084

This isn't solve via this patch:
https://www.drupal.org/project/drupal/issues/2869855

I also tried clientside_validation:
https://www.drupal.org/project/clientside_validation
b/c of this:
How to prevent an Ajax form from submitting

But I am having no luck solving this. Hoping someone has ideas to share.


texts:
I'm using the following modules versions on Drupal 7.

OpenCalais   7.x-1.0-alpha2+22-dev
Feeds    7.x-2.0-alpha8

I have a Feed that is creating my content correctly into the Feed Item content type. When I click on the edit tab, I can see that OpenCalais is suggesting tags.

But it does not 'autotag' the content and requires me to actually click the tag before it gets added to the autocomplete textbox. This kind of defeats the purpose. According to this http://www.lullabot.com/blog/article/introduction-calais, it is supposed to do this out of the box. the only different I see is that this is for Drupal 7. I have also installed RDFx just in case it had that requirement for the D7 version.

How can I get OpenCalais to input the suggested tag into the field automatically?


texts: List 2 fields of a content type and group them based on one of them with views

texts:
I have on coupon content type with 2 fields. One is named "Campaign Owner" and the other one "Campaign Name". One owner might have several coupons generated by the site for a campaign. So the owner will have for example 20 coupons with the same campaign name. I want to create a list of campaign names and group them with campaign owner. So the list should be something like this:

JACK(Owner Name)

Camp1
Camp2
Camp3

JOE (Owner Name)

camp4
camp5
camp6

I've tried to create this with views but what I get is not what I'm looking for. Here is it:

JACK

Camp1
Camp1
Camp1
Camp2
Camp2
Camp2

JOE

Camp4
Camp4
Camp4
Camp5
Camp5
Camp5

As you can see. It lists all the similar campaign names. But kneed to get rid of the
similar items.
How can I do such a thing?


texts: Problem with session ID and Drupal cookies when trying to establish a connection

texts:
I tried to established a connection between my app and Drupal services.
When I try to login to remote Drupal site using Mozilla add-on Poster everything is working... POST request return OK 200 and I'm logged into the site.

When I make the POST request from my app, I always get 200 repose OK, but when I visit the site in browser I'm not logged in.
I suppose that Cookie header is not correctly structured in POST request...but I don't know how to fix it.

Does anyone have idea how can I solve this?


texts: How to specify the default installation profile

texts:
I want to specify my custom installation profile as default one, like acquia profile in acquia drupal.

For example when installing acquia drupal, acquia profile will be selected by default thus choose profile and language will be skipped. Now I need to overcome this, because I'm, writing my installation profile in the acquia drupal. So I should set my custom profile as the default one instead of acquia profile.

How can I achieve this?


texts: Create a custom filter in Views related to a custom table

texts:
I have a table where I keep some logs, for example, when a user visits a node, I record of the form:

The user 34 visited node 235.

Then I have a Views what show me the following fields:

NID
Title
Body

How to display only the nodes that the current user has visited or not?

EDIT:

Example of my custom table:

------------------------------------------------------
| UID | action                        | IP           |
------------------------------------------------------
| 34  | The user 34 visited node 235. | 200.54.21.24 |
------------------------------------------------------

UID = User ID


texts: Passing a contextual filter value to a view via a link with entityreference prepopulate?

texts:
I have two content types, Ad and Reply (think of how posting works on Craigslist for the Ad, and the Reply is an on-site form to reply).  I am using Entity Reference Prepopulate to automatically create an entity reference back to the Ad when users click a link to make a Reply.  The link looks like this:

  node/add/reply?field_reply_orig_node=NID

Where NID is the node ID (filled in with a token using Panels).

Using Panels, I'd like to display the original Ad on the Reply edit page (to make it easier for users to write their message.  I have overriden the node edit page (using Page Manager) and I added a view that has a contextual filter (NID).  However, I don't understand how to pass a value for NID to the content pane using the reply link.

Ideally, I could make use of the ?field_reply_orig_node=NID that is already present in the link (how?), but if that is not possible, I could rewrite the link in Panels.  I just don't understand how to rewrite it so that the contextual filter can pick up the value.


texts: Clear views cache after node inserted in Drupal 7

texts:
I've views which list the list of node details. I've set views cache for 30 mins.
I want to clear particular views cache when insert a node.
I've tried below code to clear cache but there is no difference in my page.

function phponwebsites_node_insert($node) {
 if ($node->type == 'tasks') {
   views_invalidate_cache();
 }
}


texts: Programmatically attach image to a content type from local system folder

texts:
I am in middle of coding creating nodes programatically. Here i have one problem. I need to programmatically attach image to the content type from local system folder. I mean my image path example 'c://xxxxx/xxxx/images/img.jpg'.

Thanks in advance for your advice.

Hi i used this code and work fine in the localhost. But it's failed when i work on the server.

$filepath = drupal_realpath('misc/druplicon.png');
// Create managed File object and associate with Image field.
$file = (object) array(
 'uid' => 1,
 'uri' => $filepath,
 'filemime' => file_get_mimetype($filepath),
 'status' => 1,
);

// We save the file to the root of the files directory.
$file = file_copy($file, 'public://');

$node->field_image[LANGUAGE_NONE][0] = (array)$file;

Reference link : attaching-files-to-nodes-programmatically-in-drupal-7

  I didn't get the solution yet. Can any one have the experience?


texts: What's are the variables can be used from content.field_name with multiple values

texts:
I have created a field using test list type and rendering using custom twig code as below:

 {% for key, item in content.field_scope if key|first != '#' %}

{{ item }}

 {% endfor %}

In "for" argument, I manage to get value of key and item from the field. What are the other value which can be used?


texts: How to convert an existing field from Text to Link in Drupal 7

texts: If I have a field in Drupal which of type Text, how do I convert it to to allow a link if the field is already being used on the site without losing data?


texts:
I use drupal 6 . I have some menus in the site. I 'm going to add other language support to my website. I know how to create multilingual content (nodes) but I don't know how to do it with menus like navigation menus.

would you help me?


texts:
When a user is creating content I need them to confirm (once clicking publish) that they are sure that they want to publish their post. I've been searching but cannot find an answer anywhere. I'm hoping for a modal window of some description that pops up with a message and confirm/cancel/save as draft buttons.

Any ideas?


texts: Display the 'commerce_user_orders' view in node

texts:
I'd like to display the table on the Orders page made by Drupal Commerce on another node along with other content. I believe this table is the commerce_user_orders view so I have tried using the following PHP code but all I get is a white screen when I try to view the node. Is there anyway I can overcome this?

<?php

$view = views_get_view('commerce_user_orders');
print views_build_view('embed', $view);
?>


texts:
I have seen in code:

AccessResult::neutral()
AccessResult::allowed()
AccessResult::forbidden()

allowed() and forbidden() are pretty obvious, but how does neutral() work?

I have been debugging and sometimes neutral() allow access and sometimes it doesn't.


texts: Rendering a content type with Views, in Drupal 7

texts:
I have 3 content types and I'd like to render two of them using Views. But there is not option when I can mark this 2 types.
I can mark "show all," "show first type," or "show second type," but I can't choose 2 of 3 types.

How can I do it?


texts: How to migrate products display nodes with multiple product references?

texts:
I have a site being migrated from Drupal 6 to 7. The old site had a home grown system for adding payments to signups for event nodes. We plan to use commerce module to selling the registrations for events going forward.

In the new site, we are planning to import the preexisting SKUs from the old site with feeds but I want to include the product references with the event migration we have written. This migration is already working and just needs to have the product references added to it.

My question is about how to prepare the source data to be mapped when it looks something like this:

nid | sku
---------
1   | a
1   | b
1   | c
2   | a
2   | d

When it seems like it would be better if the data was like this:

nid | sku
---------
1   | a,b,c
2   | a,d

I think if I had the like the second table, I could join the source table

// Join payment_options_skus table
$query->join('payment_options_skus', 'pos', 'pos.nid = n.nid');
$query->fields('pos', array('sku'));

and then map like so:

$this->addFieldMapping('field_registration', 'sku')
     ->separator(',');

Is there a better way to do it using the existing data in the first example table? I would like to limit the number of manual massaging steps needed. Thanks.


texts: How to call pages by Ajax using javascript

texts:
I've a created an Ajax-callback page using my module available as myModule/somepage/%/% - you can see that last two arguments in this page changes dynamically.

I want to make an AJAX call to this page, writing javascript. Say, when I click a button an ajax call will be made to this page (POST method preferably for the two arguments).

I know how to create hyper-links that handle Ajax calls automatically, but in that way links are static, and I can not send arguments to my Ajax-callback page. So how do I write JavaScript to make an Ajax call to my page?


texts: How to avoid Pathologic module to change a javascript src value?

texts:
I need to insert a javascript code in a textarea field of a node. This one:

<script type="text/javascript" src="http://www.avaibook.com/js/avaibook.js"></script>

The problem is that this line becomes:

<script type="text/javascript" src="about:blank"></script>

The real source value: http://www.avaibook.com/js/avaibook.js is replaced by about:blank.

I already know that the pathologic module is the cause (if I disable it it works fine), but can't disable since I need it for other purposes.

Is there any way to avoid this?


texts: set permissions on an entity as though it were a node

texts: I am using the Field Collection module to create entities for other nodes.  I would like to administer the creation/editing/viewing permissions for these entities using the permissions page in the same way as other node content types.  Is this possible (maybe with another module?)


texts:
How can i check if user is logged in for the first time on site?

If it is, i want to show him a message...

Can someone help me?

Thank you!


texts: What is the purpose of rerender FormState property?

texts:
I am trying to understand With a taxonomy term view Exposed form in block has incorrect action URL /taxonomy/term/all, not taking into account term id and breaking filtering without AJAX/JS and in the process I see the rerender property is mentioned in code a lot, such as on Render exposed filter without creating block and How to programmatically render a view exposed filter inputs with form state maintain? The original problem is that the code runs the second time and it doesn't get view arguments, but I don't see where the rerender property can influence this process and how it's reasonably used at all. The only place I see is in an Ajax sub-folder, but I don't have Ajax enabled on my view yet.
What problem does this property solve?


texts: Running functional test, the actual tests pass, but PHPUnit throws an error about rmdir() for a simpletest directory

texts:
Running from CLI... my tests all pass, but the framework itself is throwing an error when trying to clean up a directory. I am not sure what it is coming from, and how to fix it. The directory sites/simpletest has 777 on it.

vagrant@local:/var/www/mysite/docroot$ ../vendor/bin/phpunit -c ../phpunit.xml modules/custom/netforum_auth
PHPUnit 4.8.35 by Sebastian Bergmann and contributors.

E.......

Time: 24.07 seconds, Memory: 8.00MB

There was 1 error:

1) Drupal\Tests\netforum_auth\Functional\AuthenticationTest::testAdminUserUsesDrupalAuthentication
rmdir(sites/simpletest/52528722): Operation not permitted

/var/www/mysite/docroot/core/lib/Drupal/Core/File/FileSystem.php:256

I'm stuck.

edit: possibly related

edit 2:

Running the command with sudo shows no error. Why? I tried adding vagrant to the web data user group, no difference. Only sudo works. This is in DurpalVM, Drupal 8.3.5.

edit 3:

Per the docs:

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

Therefore, this should work:

sudo -u www-data -E ../vendor/bin/phpunit -c ../phpunit.xml

However it works sometimes, and not others. 50% success rate at the moment, with the same file permissions error.

edit 4:

Similar yet different error:

1) Drupal\Tests\netforum_auth\Functional\AuthenticationTest::testAdminUserUsesDrupalAuthentication
Exception: Warning: file_put_contents(sites/simpletest/61504822/files/php/twig/597a393cb6709_form-element.html.twig_dJcTIbdx1y7B0dbOtEyyZSSZ1/.htaccess): failed to open stream: Permission denied
Drupal\Component\PhpStorage\FileStorage->ensureDirectory()() (Line: 122)


texts: How to dynamically populate the condition method argument in a Dynamic Query

texts:
I am writing a query that will retrieve nodes that match a set of criteria. Though the number of cirteria is unknown. I was hopping i could pass to the condition() method an array of criteria with a key as the 'column name' and that value as the 'value to match' for that colum. For instance :

$criteria = array ('nid' => 1, 'etid' => '1')

$query = db_select('table', 't');

$query
  ->condition( $criteria)
  ->fields('t', some_field);

I have almost 10 criteria and no way to know which will be selected so writing a query for each wont be possible.

Is there a way to achieve that ?

EDIT:

i thought about using that :

if (empty($criteria1)){
    $criteria = array (":criteria1"= '*');
}else {
 $criteria = array (":criteria1"=$criteria1);
}
$query = db_query('SELECT nid FROM { parce_index } WHERE criteria1 = :criteria1 AND criteria2= criteria2...',$criteria));

Would that make sense ?


texts:
On my drupal 8 website I have created a view, with list of content. As an output format I have chosen HTML list. So currently it looks like following:

 <form id="views-form">

    ....

</form>

For formatting I would need to wrap the html list in some other div, is there a way to do it ? Can not find anything in the interface.

Expected:

<form id="views-form">

   ....

</form>


texts:
I recently used drush to update my site. This is the current drush status:

$ drush status
 Drupal version                  :  7.29
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database username               :  %$^&*(
 Database name                   :  %$^&*(
 Database                        :  Connected
 Drupal bootstrap                :  Successful
 Drupal user                     :  Anonymous
 Default theme                   :  openchurch_theme
 Administration theme            :  seven
 PHP configuration               :  #$%^&*
 PHP OS                          :  Linux
 Drush version                   :  6.4-dev
 Drush configuration             :
 Drush alias files               :
 Drupal root                     :  #$%^&*
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Temporary file directory path   :  /tmp

But when I visit my admin page, I still get the "You need to upgrade" message. How do I get it to stop?

Here is the update screen:


texts: Possibility to reinstal module without deleting old configuration for module permissions by term

texts: I tried to upgrade my site from Drupal 8 to Drupal 9. In this process I upgrade the module Permissions by Term to Version 3.0. The upgrade failed due to problems with extension of CiviCRM that were not covered by update report. So I turned back to D8. Afterwards I got the messages that the module Permissions by Term 3.0 was not compatible to D8 and thus disabled. So I downgraded that module by Composer successfully to version 2.31. After trying to reinstall it I got the error message that it couldn't be installed because of existing configuration. In the web I found several ways to delete old configurations, but of course I would like to keep it since I'm afraid I would have to review every page to set permissions again. Thus my questions: Is there any way to reinstall the module without deleting my old configurations (or was my fear wrong)?


texts: Simplenews unsubscribe link shows a 404 Page

texts:
In my Newsletter the unsubscribe URL which is inserted by a token, returns a 404 page.
The URL of my Link is:

http://www.mysite.info/newsletter/confirm/remove/

What could be the issue?


texts: Display number of pending messages and friend request on the user menu

texts:
I'm using Privatemsg & User Relationships and the built-in user menu as a sidebar block. What I want is to display the unread messages count and the pending friends requests beside the links "My messages" & "My friends".

Any ideas of how can I do this? Thanks in advance.

Mock-up:


texts: Tracking number of attempts via Form API

texts:
I'd like to track the number of times a user has failed a form validation.

It doesn't necessarily matter if the end user has access to the variable, or even the ability to manipulate it client side, as the purpose is to provide additional help to the user by detecting when they might not be in trouble.

At this point I think I'm leaning towards adding a hidden field and incrementing that value, but I'm interested to know if there's a cleaner method that does prevent access and manipulation in my quest for knowledge :)

Thanks for any advice.

UPDATE

As per tunic's advice below, I'm trying the $form_state route but this doesn't appear to be persisting. In my form validation function I have:

// Track the number of attempts.
if (!isset($form_state['mymodule']['attempts'])) {
  drupal_set_message('attempts not set');
  $form_state['mymodule']['attempts'] = 0;
}
$form_state['mymodule']['attempts']++;
drupal_set_message($form_state['mymodule']['attempts'] . ' attempts');

However repeatedly submitting a form with errors results in the following output each time:

attempts not set
1 attempts

SOLUTION

Having difficulty arguing with $form_state I instead went for the core flood module as suggested below, with the following code, in my validator:

function mymodule_booking_register_online_form_validate($form, &$form_state) {
  if (form_get_errors()) {
    form_set_error('', 'There was a problem registering your online account, please try again.');
    flood_register_event('mymodule_booking_register');
  }
}

And then to handle the result of this event, back in my form definition:

function mymodule_booking_register_online_form($form, &$form_state) {
  if (flood_is_allowed('mymodule_booking_register', 5, 3600)) {
    ...
  else {
    drupal_set_message('You have incorrectly entered your personal details too many times. Please call us on 12345678 to ask for your user code and then enter it in the form below.');
    ...
  }
}


texts: In Tinymce editor, how to set default font family style in select list?

texts: I have TinyMCE editor configured and under font family select list, I am able to see 'styles' label as default when loading. But I want to see any font family as default. Suppose, Times new roman as default in select list.


texts:
In Drupal 6, I'm writing a custom module that generates several pages (as a Drupal newbie). Mainly public form pages for soliciting donations - users fill out their info (amount, frequency, etc.) and we bundle it and send the user to payment processor.

On the admin side, this module gathers several items so that the form can be generated. Dollar amounts, benefit levels for donors, summary info, etc. So the vast majority are small text fields, with just a few words or a few integers. Nothing from the user submission is stored in Drupal.

What I've been doing up to this point is storing each item with variable_set and retrieving it on the public form pages with variable_get. This works fine, but I'm starting to worry that I might be getting myself into a performance problem.

Currently I see that there are 36 rows in the variable table that come from this module. I don't know if that's bad, but I'm also not finished. As there are ~four "pages" associated with this module and I've only done one of them, there could conceivably be ~100 rows.

This leaves a few questions in my mind.

Am I at the point where I need to make a custom table for my module?
Will these rows all be cached (I'm aware of cache_set but I'm not sure how that relates to variable_set if it does)?
If they are cached (either automatically or because I use cache_set for them) will that solve any potential issues?
If I should use cache_set what is the best method for caching a bunch of tiny things? Should I try to bundle them and cache them all at once after the admin form is submitted?
The same for cache_get - what is the best way to retrieve these kind of things?

I'm asking this because I'm seeing a lot of places where variable_set is discouraged once there gets to be a lot of data, but I'm not sure if I'm at that point or not.

Thanks.


texts:
I want to show images on my website. website example

When I hover over the images, the page title shows up. But when you move with your cursor over the text it won't link to my colorbox popup.
How can I solve this problem. I've been looking for a long time.

I've used the rewrite results to get the title on hover.


texts: How can I serve different view blocks based on media queries?

texts: I have 4 view blocks that I want to show up as carousels on mobile. I'd like to be able to clone them, turn the clones into carousels with this module https://www.drupal.org/project/slick, then serve them in place of the others somehow. I know I can use css to serve both and hide them but that doesn't sound like a good idea.


texts: User landed on cached page instead of language selection page

texts:
Problem :

On multilingual site, varnish caching is enabled. When any user call www.example.com, page gets cached to the first visitor's language preferences. All subsequent visitors get pages in that first visitor's language rather than their own.
For Example :
first visitor browse www.example.com then language selection page apears and visitor select language and entered to the website. (www.example.com/fr)
Then second visitor browse same url www.example.com then visitor redirected to www.example.com/fr instead of language selection page.

Some details :

We are using cookie to determine the language which gets set when user select language preference. If we exclude homepage from cache it works fine but we don't want to exclude this page as this is the homepage of website.

Question :
How we can set varnish or Drupal to read cookie from browser and display language selection page ?
OR
Varnish should detect language cookie and if not set then display language selection page ?

Thanks in advance.


texts: How to rewrite link to taxonomy term in Views when using Pathauto?

texts:
The default language of my site is English.  Taxonomy terms are translated using Entity Translation.  I have created a view that uses aggregation to show Japanese terms (name provided by the Title module).

However, the Japanese terms do not have a path alias, so I need to rewrite the link provided by the view to point to the English term.  The URL aliases of the English terms are generated by Pathauto, which strips some words ("to" in "Things I like to do").

Example:

English term: Listening to Music
Pathauto alias: listening-music
Japanese term: 音楽鑑賞
Desired output: 音楽鑑賞 (link pointing to listening-music)

I tried rewriting the link to [name] (the English term) with conversion to lowercase and spaces converted to dashes, but this causes the link to be listening-to-music, not listening-music.  Ideally, I would like to keep pathauto settings as they are and somehow grab the URL of the term within views.  Is this possible?


texts: How can I sum up the totals of groupings in views?

texts:
I am trying to sum up my sales in my Commerce store by month.

I have created a view of completed payment transactions that is grouped by payment year (first grouping) and then payment month (second grouping).  The config looks like this:

This gives output look like this:

Now what I'd like to do is sum up each month (the second grouping) to show the total sales for that month.  I think I can use aggregation for this but I'm not sure how to set it up.


texts:
Using Drupal 7 and Clean theme and installed Views module. Everything is worked but now, when click Save in Views get this error:

''Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.''

My site is on MAMP local. Whats this problem?


texts: How to get url of Product image field of Entity Reference field

texts:
Trying to create a view (a block) with associated products on product pages. Products have a field "Related products" (Entity Reference) and in my view (show products' fields) I can get images and titles of them using contextual filter (Content: Nid) and relationship (Entity Reference: Related products). But there's a problem with the url of titles and images, they're leading to editing pages (like admin/commerce/products/1), but not to content.
I tried to add a field Content:Path, but I get a link to a product itself, not to related with it products.


texts: How to fire a Rule after adding a new file in multi-value field?

texts:
Working with Drupal 7.56, Rules 2.10, Conditional rules 1.0-beta2 and File Entity 2.4

I can't fire a rule when I add a new image in a multi-value Image field (related to File Entity for inline fields).

I need to act when a new file is added and also when an existing file is updated (each image has inline fields for caption and details) but I can't find the right way to build my Rule?

At the end, I need to fire a rule when a new image (file) is added to send data (fid, url, inline fields values) to an external database and I need another rule when I updated the inline fields of an image (file) to update the external database.

Does anybody has a tip here?

Already tested : Event "Before saving content", Condition "Data comparison" between updated and unchanged node (NOT equals returns always true...), module File Field Rules...

Related :

Using Drupal 7 Rules, how to react to a file upload and change a node field?

Writing custom PHP code in Rules to check if a file field has a new value

Here is my last try (a little bit modified for clarity) with a simple message on site to check if the rule fires :

{ "rules_image_insert" : {
    "LABEL" : "image insert",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "rules_conditional" ],
    "ON" : { "node_update--article" : { "bundle" : "article" } },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_pictures" } }
    ],
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "node:field-pictures" ] },
          "ITEM" : { "list_item" : "Current list item" },
          "DO" : [
            { "entity_fetch" : {
                "USING" : { "type" : "file", "id" : [ "list-item:file:fid" ] },
                "PROVIDE" : { "entity_fetched" : { "picture" : "picture" } }
              }
            },
            { "CONDITIONAL" : [
                {
                  "IF" : { "entity_is_new" : { "entity" : [ "picture" ] } },
                  "DO" : [
                    { "drupal_message" : {
                        "message" : "NEW picture!!",
                        "type" : "warning"
                      }
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    ]
  }
}


texts: Ajax call for autocomplete reference field

texts:
I do not succeed to fire the ajax when an autocomplete reference field widget is populated or changed inside a paragraph form.

TO BE MORE CLEAR: I Succeed when using a simple select list but not when using an autocomplete widget

Edit to add: I am not quite sure this is a paragraphs problem... I added this information to make sure I provided all the key elements.

If the Ajax callback is called, it should adapt the #options of a select field depending on what is selected in the autocomplete field.

Note: there are many paragraphs of this type in the main form (many autocomplete field with their select field)

Here is my code:

function mymodule_field_widget_paragraphs_form_alter(&$element, &$form_state, $context)
{
    if ($element['#paragraph_type'] == 'my_paragraphs_type') {
        //I have also tried with ['my_autocomplete_ref_field']['widget']['#ajax']
        $element['subform']['my_autocomplete_ref_field']['widget']['target_id']['#ajax'] = [
            'callback' => 'ajx_rebuild_parag',
            'event' => 'autocompleteclose',
            //easy way to get the paragraph's form wrapper #id
            'wrapper' => 'my_parent_field' . $context['delta'] . '-item-wrapper'
        ];
        $options = [];
        if (isset($element['subform']['my_autocomplete_ref_field']['widget']['0']['target_id']['#default_value'])) {
            $value = $element['subform']['my_autocomplete_ref_field']['widget']['0']['target_id']['#default_value'];
            $options=... //logic to construct the options according to $value
         }
        $element['subform']['my_select_field']['widget']['#options']=$options;
     }
}

//This callback works well if the Ajaxified widget is a select list
function ajx_rebuild_parag(array &$form, FormStateInterface $form_state)
{
   $el=$form_state->getTriggeringElement();
   $delta=$el['#field_parents'][1];
   $form_state->setRebuild(true);
   return $form['trigger_parent_field']['widget'][$delta];
}

=>Nothing happends when I select something with the autocomplete fieldd


texts: I'm actually trying get the count of total rows retrieved by view. When I added count($row) in Global:PHP of views field it returned 1. That also ten times, Means query executed 10 times to retrieve 10 row of data. When I printed the query with dpq($view->build_info['query']); it returned same query 10 times. How can I avoid multiple execution of same query.


texts:
I have a webform where I've used form alter to do some functionality and validation.

Now in my validation I want to disable a field for a purpose. How can I do so? Is it possible in form validation?


texts: How do I use a referenced entity in a Views contextual filter?

texts:
I'm building a media server for my university.   I have an "artist" content type for each performer, and then a 'track' content type for individual track (there are no 'albums', BTW).  For each track, you can select the artist in edit mode, using an Entity Reference.  So far so good!

On each Artist page is a block view with a table listing that artist's songs (the filter is 'show all tracks with a contextual filter of "artist").  Still good!

On each track page, I want to show "all tracks by this artist" as a table.   I've tried "artist" as the contextual filter, and even tried both "referencing entity" and "referenced entity" as relationships, to no avail.    If I put an artist NID in to the fixed value in the 'artist' contextual filter, it works fine.  But I'm pulling my hair out, trying to get the artist to dynamically be referenced by the block's contextual filter, using the tracks 'artist' entity reference.

Am I missing something here?  It really seems like it shouldn't be that hard.    Thanks in advance!


texts:
Edit
apparently they belong in the includes folder, were they also are. could it be of any use for a hacker to have these two folders in the root?

I've been checking my drupal site and noticed in the root folder were two folders, database and filetransfer:

I dont know if this is hacked or belonging to some module or stuff, does anyone know something about this?


texts:
I have a complex View that needs to utilize multiple contextual filters. Currently to access the filters I need to separate the values with a "/". I'm attempting to code a solution that passes arguments to a View (via URL) and it would be ideal to have the query string look like this:

http://www.example.com/query?nid=1450&tid=543

vs (the current way)

http://www.example.com/query/1450/543

so that I can better parse this. How can I get a View to accept parameters like this?


texts: How do I separate the "Product" select list & "Add to cart" submit form in a node product display?

texts:
I have a node product display which references 2 different products.

When I use the code below, it prints out both the "product select" form + the "add to cart" submit form. How do I print them out separately?

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

Alternatively, how do I change the HTML to print this 2 form out? I am looking for a way to theme my product display differently.


texts: drupal commerce discount product for base price

texts:
I made several rules for discount. 10% off, 9% off, 8% off etc. The only problem is that the discount is calculated from the price included VAT. I want the discount calculated from the Subtotal price, without the VAT. But in rules i can't select that.
I followed this tutorial: https://drupalcommerce.org/user-guide/price-components

Strange thing is that when i only have 1 rule with discount it does work.

I am trying for hours, please help


texts: When building a SelectQuery, why can't I use the alias from addExpression() in a condition()?

texts:
I'm trying to search for nodes with field values that satisfy a mathematical formula. I can build a SelectQuery that will find all nodes and return the value of the computation for each result using addExpression(), but I cannot seem to accomplish the final step of only returning the correct nodes using condition().

Here is a simplified example:

$myquery = db_select('node', 'n');

// Use innerJoin() since node field values are stored in separate tables
$myquery->innerJoin('field_data_field_number_one', 'one', 'n.nid = one.entity_id');
$myquery->innerJoin('field_data_field_number_two', 'two', 'n.nid = two.entity_id');

// Add basic node fields and the two value fields so they will be available in the results
$myquery->fields('n');
$myquery->addField('one', 'field_number_one_value', 'one');
$myquery->addField('two', 'field_number_two_value', 'two');

// Add the computation using addExpression()
// In this example the computation has been reduced to a simple sum
$myquery->addExpression('(one.field_number_one_value + two.field_number_two_value)', 'sumcalc');

// Only return nodes of type desired_type
$myquery->condition('n.type', 'desired_type');

// The query will execute properly without the following line
$myquery->condition('sumcalc', 5, '<');

$prex = $myquery->preExecute();

if ($prex) {
  $qresult = $myquery->execute();
  foreach ($qresult as $qrecord) {
    // Without the erroneous condition above, this line will print each result
    // and each result will contain the value of the calculation added via addExpression()
    dpm($qrecord);
  }
}

If I try to execute the code above, I get the following error:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sumcalc' in 'where clause'

What am I doing wrong here?


texts: how to make config fields stick at admin/structure/types/manage/?

texts:
I am adding a config option to all content types. I have textfield and checkbox now.

How to SAVE what I write in the textfield and state of checkbox when I hit submit?? Do I need to alter submit function for this form?

function neil_misc_form_node_type_form_alter(&$form, $form_state) {
  global $user;
  if (isset($form['type'])) {
    $form['followbtn'] = array(
      '#type' => 'fieldset',
      '#title' => t('Follow Button settings'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#group' => 'additional_settings',
    );

$form['followbtn']['comment'] = array(
  '#type' => 'textfield',
  '#title' => t('Email address to send updates to'),
  '#default_value' => $user->mail,
);

$form['followbtn']['followbtn_default_mode'] = array(
  '#type' => 'checkbox',
  '#title' => t('Add Follow button to this Node Type?'),
  '#default_value' => variable_get('comment_default_mode_' . $form['#node_type']->type, ADD_FOLLOWBTN),
);
  }
}


texts:
I have link CCK field but the field does not validate "HTTP://" like this

how I can make the validate "HTTP://" for this field


texts: Delete the original image after cropping it with the imagefield crop module

texts:
The title says it all.
When I upload a big image of 5MB but I only need a small part of it I can cut out a part (=crop).
I can then use that cropped piece for other purposes.
But I never need the original image anymore because I have that one on my computer already.
Is there some secret option to enable so that the original image gets deleted after the cropping?

Do I have to change something in the code?

Thanks in advance!


texts:
I'm actually testing a website with Drupal 7.

I am searching a way to get the visitors' IP, when they submit a new node; the users can also be not logged-in, as anonymous users are allowed to submit new content.

I can't find a module to do that, and I don't know how to use hooks or PHP to achieve this.

What should I do?


texts: How to compare before and after state in whatever_submit($form, &$form_state)

texts:
In a custom module, I have a form allowing some Create/Update/Delete data in a specific table of the database.
In the submit part of the code, I'd like to compare 'before' state (what was displayed to the user) to 'after' state (what he has actually entered) in order to properly update the database: create what has been added, update what has been changed and delete what has been removed.
How can I do that?
By the way, the site is running Drupal 6.37.


texts: I am trying to sort blog by title. The blog does not appear at view. Taxonomy does not has any setting related to sort. What else I should check?


texts:
I have a content type with CCK fields that make up contact information.  I was asked to add a VCard / Add to outlook feature.

I have a few ideas on how to do this but not sure which one is good.  My only actionable idea at the moment is to edit a template file for where it is displayed and create the vCard link within there.  However, I also use these in views and I'm not sure if that would translate to the view (I think not)

Is there such a thing as a field that is totally generated? For instance, I could add a vcard field that would then take you to the generated vCard?

I know that there is a module for this but it seems to only work with user profiles.


texts: How to create a slideshow of different views?

texts:
I am trying to create a slideshow of different Views.

I am thinking that the "view field" might work with "views slide show" - possibly sending the "view result counter" through as an argument. I am struggling though as I'm not sure this is a readable contextual filter when it reaches the "view field" view.

Can anyone point me in the right direction? If the "view result counter" is readable, what contextual filter should I add in the "view field" view.


texts: Drush cc all doesn't flush and rebuild templates?

texts:
I am trying to clear the cache using Drush cc all because I deleted a function in the module/theme files and the site won't render...

I always have to login in as admin, performance > Clear all caches

This works...what is the equivalent Drush command?


texts: How to override formatting for a CCK field?

texts:
I have a CCK field called "stock". I dont want visitors of the website to see the value of "stock". I want them to see either "In Stock" if the value is more than 0, or out of stock if the value is less than zero.

Any idea how I can do that without actually editing the node display template?


texts: Adding menu with description like mega menu

texts:
I would like to create a menu with a description of the menu like megamenu. My menu looks like the following model:

How can I create this?


texts:
I can't setup a drupal multisite on my sever. I don't get errors but I can't show my other site.

I do the following:

First, Install my Site master Drupal with drush.
Then, created the master database for my Site Maste Drupal.
Then, setup installation with the database.
Then, created a directory named blogsite inside of directory sites/ of my Site Master Drupal.
Then, created a other database for my second site.
Then, copy the file settings.php of my Site Master Drupal in blogsite and change the configuration of my access to the database.

Now, when I access to my Site Master Drupal with: http://xxx.xxx.xxx.xxx/masterDrupal

Display the main site drupal. But, How to access to the other site?

I put in my browser: http://xxx.xxx.xxx.xxx/masterDrupal/blogsite but i don't get results.

I need that my second site have the url: http://blog.site.com and my Master site have the url: http://site.com (I assume that only I need get a Domain for my Site Master Drupal and Sub Domain for my second site)

I only use the command prompt, I don't have cPanel or something like this.

The version of Drupal is 7 on LAMP.

Thanks.


texts: Did anyone have success in configuring Mod security?

texts:
I am trying to set up Mod security (the Apache module) for my Drupal site, but it affects basic Drupal functionalities like node submission, module enable/disable and people permission submissions etc.

I am using:

Drupal 7.56
Mod Security 2.91
Owasp crs 3.0
Apache 2.4

Did anyone have success in configuring Mod security based on Drupal application?


texts: How can a div at the top of the page coexist with Adminstration Menu?

texts:
I want to place the Page execution times at the top of the page. I first tried it in a block as mentioned in this question, but the code for the block executes before the page is fully rendered, resulting in the wrong time.

Devel places the Page execution time is place in a div class .dev-query and I tried placing it at the top of the page.

The problem is it gets obscured by Admin menu and after reading a few solutions such as this one on stackoverflow 1 and stackoverflow 2 and I wonder if someone has been there and done that in relation with Admin menu


texts: How do I avoid the error "out of memory"?

texts:
I'm currently working with Drupal 7, and I've the following modules installed, all updated to their respective last version:

Views - 7.x-3.0-beta3
CTools - 7.x-1.0-alpha4
Panels - 7.x-3.0-alpha3
Rules, ACL, Advanced forum, Forum Access, User Points, BUEditor

I keep getting "PHP Fatal Error: Out of memory." My server's limit is at its maximum allowed by my provider (32 MB). Those errors appears mostly when interacting with the modules page, but it's also appearing for any user who tries renewing his password, or editing nodes.

Thus, would you have any advice on how to lower the memory usage?

P.S.: I've noticed most of those errors include views and views plugins .inc files. But it also concerns .inc files from the core modules and system... I could copy some there if you want me to.


texts:
I want to track page views to a user's profile page similar to what the core "statistics" module does for node page views.

I don't want to use profile2 for my site, otherwise I could probably use the statistics module.

Eventually I want to use the Google Analytics module to track page views to cached pages as well.

I'm looking for a simple solution/workaround that I can use right now.


texts: Alternate ways to call a function inside a .module file of a module

texts:
I have installed quickdraw module and it needs some additional functions to be executed using drush commands. For that, I used the following drush commands:

drush php-eval "quickdraw_xx_xx_additionalfunction();"

But it returns an error

Fatal error: Call to undefined function quickdraw_facet_navmenu_materialize() in /usr/local/Cellar/drush/6.3.0/libexec/commands/core/core.drush.inc(1100) : eval()'d code on line 1
Drush command terminated abnormally due to an unrecoverable error.                                                                [error]
Error: Call to undefined function quickdraw_facet_navmenu_materialize() in
/usr/local/Cellar/drush/6.3.0/libexec/commands/core/core.drush.inc(1100) : eval()'d code, line 1

As discussed in this post. I have tried module_load_include(), which returns the same Fatal error.

Also tried drush eval 'quickdraw_xx_xx_cron();' - Didn't work!!!

Is there any alternate ways to execute the function or how can I resolve the issue. Any ideas??

NOTE: The additional function is defined in quickdraw_xx_xx.module file, I assume it is not being recognized.


texts: node_load() in a form and display it in an attached form markup

texts:
How can i show every node title which is related to the taxonomy term in a form field? I work a little bit around and think i'm really close for a solution, but thats a little bit too tricky for me. I get one node title, but if i related 2 nodes to one term, i still get only one with an error message. I think i need to built an extra array, but I didn`t know how to handle it with the $link[$data->tid].

        $terms = taxonomy_get_tree('1', 0, NULL, TRUE);
        $image_style = 'medium';

        foreach ($terms as $data) {
          if(!empty($data->field_term_image['und'])) {
            $output[$data->tid] = '<img src="'.image_style_url($image_style ,$data->field_term_image['und'][0]['uri']).'" />'. $data->name;
          } else {
            $output[$data->tid] = $data->name;
          };

          $term_nids = taxonomy_select_nodes($data->tid, FALSE);
          $nodes = node_load_multiple($term_nids);

          foreach($nodes as $node){
            $link[$data->tid] = $node->title;
          };
        }

        $form['step_1']['city_default'] = array(
          '#type' => 'radios',
          '#title' => t('Default category'),
          '#options' => $output,
          '#description' => t('The selected category will be shown by default on listing pages.'),
        );

        foreach ($form['step_1']['city_default']['#options'] as $key => $city_text) {
          $form['step_1']['city_default'][$key]['#description'] = $link[$key];
        }

Glad about every help.


texts: How to delete Content Type created through features

texts:
I was trying to use a project feature from openAid features based distribution.
So I copied all the features from that distribution and required contrib and custom modules in my drupal installation.

Then I enable the project feature from admin/structure/features which enables few other features like resources and partners.

Any how I was unable to make it work as per my requirement so I deleted all three folders including the features, contrib and custom modules.

but the issue is that it has created three content types Project, Partners and there is no option to delete them.

Please let me know if there is a way to delete those content types which were created through the features which I have already deleted.


texts: How to make the Views Slideshow controls actually work?

texts:
I installed the module Views Slideshow 7.x 3.1, including the dependent modules as well as the jquery.cycle.all.js (version 3.03) in sites/all/libraries/jquery.cycle.

I am able to create a slideshow with a numeric pager showing 1 2 3 for the 3 slides I have added.

However, the pager numbers aren't linked and the previous and next buttons look like links but nothing happens when I click them.

Have searched for a solution but found nothing.

Also, the slideshow doesn't cycle, just stays on the 1st slide.


texts:
I'm using the moduke Permissions by Term and I love it. It works great and my complete system is now build around it. But I ran into a certain case and I am wondering if this is even possible.

I want a node to be visible for Anonymous users but not for a logged in user with a certain role.

Is it possible to do this. Is it possible to hide content or deny access for a certain role to content that is available for Anonymous users?


texts:
In my D7 webform result, table format, the default result table is "#, SUBMITTED, USER, IP ADDRESS"

I want to add a "Edit" in "ACTION" column, to make it as "#, ACTION, SUBMITTED, USER, IP ADDRESS".

I found the codes in theme_webform function as below.

function theme_webform_results_table_header($variables) {
  return array(
    array('data' => t('#'), 'field' => 'sid', 'sort' => 'desc'),
    array('data' => t('Submitted'), 'field' => 'submitted'),
    array('data' => t('User'), 'field' => 'name'),
    array('data' => t('IP Address'), 'field' => 'remote_addr'),
  );
}

But it is selecting from database table, which adding a row like below doesn't work

    array('data' => t('Action'), 'field' => 'sid/edit'),

Is there anyway I can add in the edit link?


texts:
I have products with a few options.

Option 1: Same price.
Option 2: -50 cent ($9.50).
Option 3: -$1 ($9).

Can I change the display so that it looks like this?

Option 1:
Option 2: ($0.50 off)
Option 2: ($1.00 off)


texts: I have a content type that has a media field that can contain audio, video or image, I created  a view and I want to filter the view depending on the media type is that possible using Drupal views or do I need to make custom code for this


texts:
I was wondering how I can get a list of the available checkout fields of Drupal Commerce like:
Billing information:

first name
last name
[custom field]
country
...etc.

So i'm only interested in listing the available field names, not the actual values. With code in my custom module.

Does anyone have a suggestion how to do that? Thanks!