texts: Drupal 7 AJAX error when running batch with Internet Explorer

texts:
I'm getting an AJAX error when running any batch with Internet Explorer 8, 9 and 10.

This error occures when I'm using "feeds" module, "views send" module or when I delete a user.

For example, when I try to send multiple mails with "views send" module, I get this error:

  "An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: >/batch?id=1613&op=doStatusText: OK ResponseText: {"status":true,"percentage":"50","message":"Sent 1 of 2 messages.\u003Cbr /\u003E"}"

The first mail is sent, whereas the following mails are not.

I'm not getting this error with Chrome and Firefox.

Thanks in advance !


texts: how to update the form values after pressing the submit button

texts:
Below I have written code for update but when I change the value in form and press submit button still those old values goes to the database. My question is how to get current edited value of my form after it is displayed?

function upgrade_menu(){
    $items = array();
    $items['upgrade_page'] = array(
    'title' => t('Upgrade'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(' upgrade_update'),
    'access callback' => TRUE,
    );
    return $items;
}

function upgrade_page($form, &$form_state) {
    if (!isset($form_state['storage']['upgrade_module']['search_criteria'])) {
        return drupal_get_form('upgrade_form');
    }
    $title = $form_state['input']['Name'];
    $query = db_select('form_test', 'n')
    ->condition('name', $title, '=')
    ->fields('n',array('name','Id','age','email','salary'));
    $results = $query->execute();
    $res = $results->fetchAssoc();
    $form['Name'] = array(
        '#title' => t('Name'),
        '#type' => 'textfield',
        '#value' => $res['name'],
    );
    $form['Id'] = array(
        '#title' => t('Id'),
        '#type' => 'textfield',
        '#value' => $res['Id'],
    );
    $form['Age'] = array(
        '#title' => t('Age'),
        '#type' => 'textfield',
        '#value' => $res['age'],
    );
    $form['Emailid'] = array(
        '#title' => t('Emailid'),
        '#type' => 'textfield',
        '#value' => $res['email'],
    );
    $form['Salary'] = array(
        '#title' => t('salary'),
        '#type' => 'textfield',
        '#value' => $res['salary'],
    );
    $form['submit'] = array(
        '#value' => 'Update',
        '#type' => 'submit',
        '#submit' => array('upgrade_update'),
    );
    return $form;
}

function upgrade_form($form, &$form_state) {
    $form['criteria'] = array(
        '#type' => 'fieldset',
        '#title' => 'Update',
        '#attributes' => array('class' => array('container-inline')),
    );
    $form['criteria']['Name'] = array(
        '#type' => 'textfield',
        '#title' => t('Name'),
        '#value' => (isset($form_state['input']['Name'])) ? $form_state['input']['Name'] : "",
        '#size' => 10,
        '#maxlength' => 20,
    );
    $form['criteria']['submit'] = array(
        '#type' => 'submit',
        '#value' => 'search',
        '#submit' => array('upgrade_submit'),
    );
    return $form;
}

function upgrade_submit($form, &$form_state) {
    $form_state['storage']['upgrade_module']['search_criteria'] = $form_state['values'];
    $form_state['rebuild'] = TRUE;
}

function upgrade_update($form, &$form_submit) {
    $name =  $form_submit['values']['Name'];
    $Id = $form_submit['values']['Id'];
    $age = $form_submit['values']['Age'];
    $email = $form_submit['values']['Emailid'];
    $salary = $form_submit['values']['Salary'];
    drupal_set_message(t('You provided a  name',array('name' => $name)));
    drupal_set_message(t('You provided a  Id',array('Id' => $Id)));
    drupal_set_message(t('You provided a  age',array('age' => $age)));
    drupal_set_message(t('You provided a  email',array('email' => $email)));
    drupal_set_message(t('You provided a salary',array('salary' => $salary)));

    $entry = array(
        'name' => $form_submit['values']['Name'],
        'id' => $form_submit['values']['Id'],
        'age' => $form_submit['values']['Age'],
        'email' => $form_submit['values']['Emailid'],
        'salary' => $form_submit['values']['Salary'],
    );
    $table = 'form_test';
    $return_value = db_update($table)
    ->fields($entry)
    ->condition('email',$email,'=')
    ->execute();
    print drupal_set_message('Database is successfully Updated..');
    return $return_value;
}


texts: How do I delete an old node when a new node is created?

texts:
When a user submits a new node, I want the Rules module to look for other nodes with the same email field, then delete the older node and keep the new node.

When a user adds a new node, there is an email field that always stays the same which can be used as field to find nodes.

Is there any way to do this?


texts: How to re-publish nodes after unpublishing with hook_cron?

texts:
Good morning,

I'm running some tests with hook_cron in Drupal 8. My goal is to unpublish nodes of a specific content type ('event'), and once I enabled my module, I was able to accomplish this. However, after setting $node->setPublished to 'true,' I was unable to accomplish publishing said nodes again after running cron, running Drush CR, and restarting Apache.

Anyone know of any good hooks to resolve this?

function scheduler_publish_cron() {
  $nids = \Drupal::entityQuery("node")
    ->condition('type', 'event')
    ->execute();
$storage_handler = \Drupal::entityTypeManager()->getStorage("node");
$nodes = $storage_handler->loadMultiple($nids);
foreach ($nodes as $node) {
// Unpublish nodes
// $node->setPublished(false);
 // Publish nodes
$node->setPublished(true);
    $node->save();
  }
}


texts: The best way to list persons information

texts:
I am new to Drupal and have recently started using Drupal 8. I am creating a website to act as a business profile.
One of the main content of this website is the profiles of the team members. I'd like one of the items of the main menu to be 'team members' and it should drop down into list of members.
The link of the top menu item should show a page with a summary of all members and the sub-menu items each should show a full article about a single member.

What I've tried so far is:

1- Create a user for each member, and I've added some fields as full name, etc. I'v created a view to show all users.
The problem I faced with this solution is: The view to list users cannot be seen by anonymous. The other issue is I couldn't filter this view to only show team members, for example it also shows 'admin'

2- The second approach was to create a content type called 'Team members' with fields like full name, image, etc.
I am not sure if this is the correct approach. For instance the field 'Title' is an obligatory field that doesn't make sense for a team member.

What is the correct way to add such a feature to my website.


texts: How can I format a cell to not wrap in a themed table with the Antonelli/Bartik theme?

texts: I want to limit the text in a cell so it truncates whatever would be wrap to the next line. However, I want there to be a minimum width, so if a user is viewing the table on a phone oriented vertically it won't just show 1 or 2 characters because of the narrow width.


texts: Is there a way to hand-code a reference to a block?, in a .tpl file?

texts:
Is there a way to hand-code a reference to a specific block?, in a .tpl file?

Specifically what i’m trying to do is this. I have a Drupal commerce site and the shopping cart contents are displayed via a block view. The contents are nicely hidden until the user mouses over a link.
This is accomplished via the Ajax commerce cart module.

My global nav is hand-coded via a block-myNav.tpl.php file.
So within the nav UL the pseudo code might look like

<?php print $my_block_reference here ?>

is that crazy? is there a way to accomplish this?


texts: How to add a specific number of Field Collection items drived by a textbox with OnChange event?

texts:
Here is a FieldCollection of "FirstName, LastName"

As you can see, there is a Textbox "Spaces" and under that a tables which is comming from my Field Collection. Right now if I want to add a combination of "Firstname / LastName" I need to click on Add another Item button. I want to remove that button and controle the numbers of items with the "Spaces" textbox. If I put 4 in the "Spaces" textbox, 4 rows should appear in the Guest List.
How can I do that?


texts: 403 forbidden error loading "sites" files

texts:
I had an installation of Drupal 7.24 and I was doing a new install with 7.26. Everything went well until the end, when I tried to login. When I try to login or submit any form the page just refreshes back to where I was.

I inspected element to see what was going on and noticed a bunch of files from site/default/... were returning 403 forbidden. I chmod-ed all the files in sites/default to 777 to try it out and it still did the same thing.

What part of Drupal could this problem reside in?

EDIT:
deleted cookie,
fore refreshed,
tried in incognito.


texts:
I am trying to create a custom field widget to be used by the taxonomy term reference field.
Basically I would like to select which taxonomy terms can be shown in the select list.

So far I am able to register the widget along with a custom settings page but when I use the widget on a node edit form. The values are not saved.

Here is the code below I have implemented a hook_widget_info hook_widget_settings_form and hook_field_widget_form from my understanding those three hooks should be enough

function my_module_field_widget_info() {
  return array(
    'my_module_term_reference_limit' => array(
      'label' => t('my module Term reference select'),
      'field types' => array('taxonomy_term_reference'),
      'description' => t('Allows you to limit the number of terms allowed in a select list'),
    ),
    'settings' => array(
        'terms' => array(),
      ),
  );
}

function my_module_utils_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $settings = $widget['settings'];
  $vocabulary = taxonomy_vocabulary_machine_name_load($field['settings']['allowed_values'][0]['vocabulary']);
  $type = $instance['widget']['type'];
  $terms = taxonomy_get_tree($vocabulary->vid);
  $options = array();
  $default_value = array();

  foreach($terms as $key => $term){
    $options[$term->name] = t($term->name);
  }

  $form = array();
  if($instance['widget']['type'] == 'my_module_term_reference_limit') {
    $form['terms'] = array(
      '#type' => 'checkboxes',
      '#title' => t('My module terms'),
      '#options' => $options,

      '#description' => t('Select compatible templates'),
  );
}
  return $form;
}

function my_module_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $settings = $instance['widget']['settings'];

 $type = $instance['widget']['type'];

  $options = array();
  foreach($settings['terms'] as $key => $value){
    if($value !== 0){
     $options[$value] = t($value);
   }
 }

$widget = $element;

  switch ($instance['widget']['type']) {
    case 'ii_term_reference_limit':
      $field['cardinality'] = 1;
      $widget += array(
       '#title' => t('my term select box'),
       '#type' => 'select' ,
       '#options' => $options,

  );
      break;
  }

  $element +=  $widget;
  return $element;

}

Thank you for your help


texts: Warning: Invalid argument supplied for foreach() in form_select_options() (line 2837 of includes/form.inc)

texts:
I get the following erros on selecting the selectbox.
Here onchang of this field will populate another checkbox with city details id zipcode using ajax callback.

 $zipcode_options = get_all_zipcodes_ascending();

  // Populate Ort on auktion clone.
  $selected = isset($auktion->zip_code) ? $auktion->zip_code : NULL;
  $selected = isset($form_state['values']['zip_code']) ? $form_state['values']['zip_code'] : $selected;
  $ort_options = _ajax_city_dropdown_options($selected);

  $form['zip_code'] = [
    '#type' => 'select',
    '#title' => t('PLZ'),
    '#options' => $zipcode_options,
    '#default_value' => isset($auktion->zip_code) ? $auktion->zip_code : "",
    '#select2' => ['width' => '100%', 'placeholder' => t('Enter a zipcode'), 'allowClear' => TRUE],
    '#empty_option' => '',
    '#validated' => TRUE,
    '#required' => TRUE,
    '#ajax' => array(
      'event' => 'change',
      'callback' => 'ajax_example_dependent_dropdown_callback',
      'wrapper' => 'dropdown-second-replace',
    ),
  ];

Referenced many links but cannot find a solution to resolve this issue.

References:

https://www.drupal.org/node/586576

populate drop down from results using ajax

http://techqa.info/drupal/question/203725/help-understand/solve-this-warning:-invalid-argument-supplied-for-foreach%28%29-in-views-that-requires-class-registry-clean-to-mend


texts: D6->D8 Migrate failing to copy any nodes

texts:
I am trying to migrate a measily 200nodes from a Drupal 6 site to the latest Drupal 8. The web based Migrate seems to be partially working in that I have the users migrated, content types, but none of the content/nodes did. I get errors like

Operation on Node revisions (page) failed

and then

Migration d6_node_revision:page did not meet the requirements. Missing migrations d6_node:page. requirements: d6_node:page.

Or

Operation on Nodes (page) failed
followed by
Migration d6_node:page did not meet the requirements. Missing migrations d6_user. requirements: d6_user.

I am also quite often getting an AJAX timeout after less than 60 seconds. I don't know if one is causing the other or what. It sounds like they are separate problems.

(I am using Krystal hosting in the UK. I can pick whatever PHP I want - I tried 5.6 and 7.2). Webserver is LIghtwave I think.

I don't really know what to do with this as I don't really know what that message means.

Any suggestions for diagnosing more and getting a better understanding of the problem?

PS - Just this evening I successfully migrated a D7 to D8 site - but that was using a different host.


texts: Symfony\Component\HttpFoundation\Response is never cached

texts:
My custom controller is returning data but it is never being cached.
My controller function:
use Symfony\Component\HttpFoundation\Response;

 $build = [
            '#theme' => 'search_form_suggest',
            '#nodes' => $nodes,
            '#term' => $term,
            '#type' => $type,
            '#cache' => [
                'keys' => [
                    'sg_search_term_suggestions_' . $term . "_". $type
                ],
                'tags' => [
                    'sg_search_term_suggestions_' . $term . "_". $type
                ],
                'contexts' => ['route']
            ],
        ];

$response = new Response($content);
return $response;
//retrun $build; //this does serve from CACHE

Looks like it never ends up hitting the cache mechanism. When I return $build then it does serve from cache.


texts:
I've created page with Views, which is displaying gallery (image fields).

I've set the path to node/%/gallery.

Page is working when I access "http://example.com/node/9/gallery" but it doesn't work when I access it with alias "http://example.com/event/example-name/gallery"

Any ideas?


texts:
When I change some block info, in my custom module, sometimes the block doesn't change in my page, even if I clear all cache.

Is there anything I can do for force change?


texts: Drupal 7 - Reorder Folders in a File Browser

texts: I was looking at a way to reorder the folder structure into alphabetical order, under the "root" folder in the file browser window, of a drupal user account. I am using Drupal 7. I looked every where but couldn't find any help. Hope some body can give me an answer. Thanks for your time in advance.


texts: Button on user profile page to send email

texts:
I think this is pretty simple, but I don't know what's the best way to achieve this.

This is what I need:

Add a button on each user profile page. When another user clicks on the button, it opens a form (in a popup window would be great) to write the message. The email should be sent to the user of the profile page we are seeing.

If it's not possible to add a form, I just need a "mailto:useremail" so when i click the button opens the outlook our gmail, wtv.

How can I do this? Is there a simple way?

Thank you!


texts: Why didn't the Drush command bam-restore work?

texts:
I'm a new admin of a Drupal site (core 7.38 on an OpenSUSE 11 server). Yesterday I ran Drush up to update VBO to 7.x-3.3 and suddenly I could no longer access the site. The homepage displayed the site's header/logo with the generic error message "The website encountered an unexpected error. Please try again later." I tried accessing /?q=user and some of the other pages via their clean URLs, but nothing worked.
The server was working fine and I was able to access the tar.gz archive created that morning through the Backup & Migrate module. So I followed instructions I found online for restoring from a Backup & Migrate archive (using bam-restore) but it failed. Drushcommands.com says bam-restore accepts three arguments: source, destination, backup id. I entered the parameters but got another ambiguous error message. Subsequently I found different instructions that avoided the bam-restore command and opted for mysql commands.

Why didn't the bam-restore work?
 Is there a way to get more specific error message or access what's actually going on with Drush in a specific circumstance?


texts: Auto add image to node listing from node body field

texts: Hi I have news content type, where are fields Title(textbox), Body(text with CKeditor) and Summary Image(multimedia asset). Is it possible to auto add first image from Body to summary image field?


texts: Making all REST Server calls to Drupal site as an authenticated user through Services

texts:
I am making REST Service calls to my Drupal 7 site to either retrieve or create content.

Is there a way I can make all these calls through one specific authenticated user?

Thanks.


texts: Is it possible to attach a single field collection to multiple nodes? (And so make updating easier)

texts:
Firstly is it possible to attach a single field collection to multiple nodes (so when you opened each node, you'd see the same field collection. If you altered one, they'd all change.)

And secondly, if the answer to the first question is yes, how would you go about doing this? Has anyone ever tried this before?

I've been looking through the database tables and it seems like there's no reason you couldn't just point multiple nodes to one fc, however I can't find anything on the topic.

Brief Example

A quick use case to clarify Geoff's question:

When I create node b, I have the option to populate a field collection from node a rather than a blank field collection.

Editing the field collection on node a, would then also change the value in b.


texts:
I'm creating a video hosting website, the thumbnails are uploaded manually, because i couldn't configure ffmpeg because of shared hosting. I would like to retrieve a videos thumbnail from the server, but every thumbnail is in an oddly named directory. For example I have a video node with the id of 32, now the respected thumbnail is in a directory like this:
/public_html/sites/default/files/videos/thumbnails/108. I would like to know how drupal creates that '108' directory, based on what?


texts:
With the Drupal 7 module Internationalization Views it was possible to add in a view a different url-path in each active language.

In D8 i found only a solution with a redirect, but i'ts the way i want it.

Any suggestions?


texts: Moving a Drupal website from one server to another, an error needs to be fixed

texts:
I set my test Drupal 7 website on my Macbook in a XAMPP environment, and I've now moved the site to another computer with  Windows xp, using the following steps:

Export the database use the phpmyadmin to a .sql file.
Import the database in the XP computer using the sql file.
Copy all the  website's files in the htdoc directory to the new server's same directory
Alter some parameters in settings.php associated with database.

OK, I did it. Everything goes well, except one thing. The Configuration Menu for the Administrator doesn't work. When I click the Configuration menu, nothing happens after waiting for a long time, only a blank page appears.

And I don't know what had happened, or how to solve it.


texts: I have a view that prints the titles of my 10 most recent news item content.  I also want to print the URL to these news items.   How do I do this?  When I edit the view, under Fields, I see a Link field, but the problem is that it prints the word "view" instead of http://mysites.com/my-first-news-item


texts: Using SQL functions in conditionals in Drupal 7 db_select()

texts:
I am trying to write a condition into a SQL WHERE clause that forces the column comparison to a variable to be compared in lowercase. However the addExpression function isn't accomplishing this (since that is putting the expression in the field selection, not the where clause.

Here is what I have tried:

$category = 'mobile wifi';
$query = db_select('taxonomy_term_data', 'ttd')
    ->fields('ttd', array('tid'));
$query->innerJoin('taxonomy_vocabulary', 'tv', 'ttd.vid = tv.vid');
$query->addExpression("LOWER(ttd.name) = $category");
$result = $query->condition('machine_name', 'images_cat', '=')
    ->execute()
    ->fetchAssoc();

And this:

$category = 'mobile wifi';
$query = db_select('taxonomy_term_data', 'ttd')
    ->fields('ttd', array('tid'));
$query->innerJoin('taxonomy_vocabulary', 'tv', 'ttd.vid = tv.vid');
$result = $query->condition('machine_name', 'images_cat', '=')
    ->condition('LOWER(ttd.name)', $category, '=')
    ->execute()
    ->fetchAssoc();

The second one becomes invalid and the first one causes the problem I mentioned above. Any thoughts or suggestions?

Thanks,
Patrick


texts: How to add onBlur attribute to ZIP code field in Address Field

texts:
In order to control the input format in the ZIP code field in the dynamic address fields provided by the Address Field module (I use it in Drupal Commerce) I need to add the attributes onKeyUp and onBlur to this field. My plan is to use Javascript to manage the formatting, but I need to add the above attributes first. How do I do that? I imagine I should use hook_form_alter in my template.php, but I could need a pointer on how to do it.

if($form['#id'] === "edit-customer-profile-billing-commerce-customer-address-und-0-postal-code"){
  dsm($form); // devel message does not show up in the checkout page in question
  $form['#attributes']['onBlur'] = '(this)';
}

EDITED: I have now managed to add the attributes this way:

  function mytheme_form_alter(&$form, &$form_state, $form_id) {
    if($form_id === "commerce_checkout_form_checkout"){
      // Merge new attributes with existing ones.
      $form['customer_profile_billing']['commerce_customer_address']['und']['0']['locality_block']['postal_code']['#attributes'] = array(
        'onBlur' => 'setZip(this)',
        'onKeyUp' => 'setLimit(this,5)',
      );
      $form['customer_profile_shipping']['commerce_customer_address']['und']['0']['locality_block']['postal_code']['#attributes'] = array(
        'onBlur' => 'setZip(this)',
        'onKeyUp' => 'setLimit(this,5)',
      );
    }
  }

And this is the js script (I found it here):

(function($) {
        $(document).ready(function(){
            'use strict';
        var setZip, setLimit;
        console.log('outside');

        function setZip(theField){
          console.log('setzip');
          var num = theField.value.replace(/\D/g,"");
          theField.value = num.substr(0,3)+" "+num.substr(2);
        }

        function setLimit(theField, maxDigit){
          console.log('setlimit');
          var num = theField.value.replace(/\D/g,"");
          if(num>maxDigit){
            theField.value = theField.value.substr(0,maxDigit);
          }
        }

    });

})(jQuery);

The problem now is that I get a javascript reference error like this:

  Uncaught ReferenceError: setZip is not defined at
  HTMLInputElement.onblur

I suspect this has something to do with the scope, so I have tried to place the js script with the setLimit and setZip functions in the header, in the body and in the footer, with the same error message. I also tried to remove the $(document).ready(function()... but the reference error reamins.

Any ideas?


texts: Just updating a module for Drupal 9 and Drush 10 and drush_set_error() no longer appears as a function in the Drush code (as far as I can see). What should I be using instead?


texts: Redirect when translation of node is unavailable

texts:
I have installed pathauto and i18n and I would like to create a node which is only available in one language. Lets say I have a Basic Page with the URL:

www.example.de/test-page-in-german

so I dont want this page to be available from

www.example.pl/test-page-in-german

because I am afraid google is gonna ban my site for double content.
Ive already selected "Require language (Do not allow Language Neutral)" for my content type and for "test-page-in-german" I have selected german and their is no translation but the node is still visible from other language domains.


texts: Showing all Sibling nodes that share the same Taxonomy term in Drupal 7

texts:
I made a Taxonomy named Category which has terms as following:-

Term 1
Term 2
Term 3
Term 4

As a requirement, any node that I create has to select one term mentioned above.

Now, what I wanna do is; that when I visit any node page, it should show me all the node titles that share the common term.

As an example, if I selected Term 2 as a category when creating following nodes:-

Node 1
Node 2
Node 3
Node 4
Node 5
Node 6

I want the list of all these nodes when I visit any of these nodes.

My URL, when I visit any of these nodes is:-

http://www.mysite.com/term_name/node_name

Thanks.

P.S.

I tried Views arg parent term within a view and followed instructions here (https://www.drupal.org/project/views_arg_parent_term), but it seems it works with a Taxonomy Term ID and I guess my URL has Taxonomy Name in it.

Any help would be highly appreciated.

Best.


texts: How to fix error Undefined index: parent in taxonomy_form_term_submit()?

texts:
I got below error on my site recently.

  Notice: Undefined index: parent in taxonomy_form_term_submit() (line 829 of /var/www/Sites/xxxxx/modules/taxonomy/taxonomy.admin.inc).

I google it and find there is an old issue but seems nothing solved.

In the issue, @Cracu did mention some part of core code may cause this error:

  if (!variable_get('taxonomy_override_selector', FALSE)) {
    $parent = array_keys(taxonomy_get_parents($term->tid));
    $children = taxonomy_get_tree($vocabulary->vid, $term->tid);

    // A term can't be the child of itself, nor of its children.
    foreach ($children as $child) {
      $exclude[] = $child->tid;
    }
    $exclude[] = $term->tid;

    $tree = taxonomy_get_tree($vocabulary->vid);
    $options = array('<' . t('root') . '>');
    if (empty($parent)) {
      $parent = array(0);
    }
    foreach ($tree as $item) {
      if (!in_array($item->tid, $exclude)) {
        $options[$item->tid] = str_repeat('-', $item->depth) . $item->name;
      }
    }
    $form['relations']['parent'] = array(
      '#type' => 'select',
      '#title' => t('Parent terms'),
      '#options' => $options,
      '#default_value' => $parent,
      '#multiple' => TRUE,
    );

  }

I try to look into the latest core, this part of code is still there with same logics. Unfortunately, I need taxonomy_override_selector be TRUE.

Apart from setting taxonomy_override_selector to FALSE or adding new form validation handler to set $form_state['values']['parent'].

Do anyone know if there is solution for that?


texts:
I am trying to port the Infusionsoft module to Drupal 8 and I need to load the infusionsoft/php-sdk library.  I have been racking my brain all day trying to figure this out, but I cannot get the class to autoload.  I do not know if this is because it is a custom module and not hosted on drupal.org yet or what.

I have added the requirement to a composer.json file in the module:

{
  "require": {
    "infusionsoft/php-sdk": "dev-master",
  },
}

And told the root composer.json file to include the module's composer.json file:

{
  "extra": {
    "merge-plugin": {
      "include": [
        "core/composer.json",
        "modules/infusionsoft/composer.json"
      ],
      "recurse": true,
      "replace": false,
      "merge-extra": false
    },
  },
}

Ran

composer update

and also tried

composer install

Both give me the vendor files.  I have uploaded those files to the remote server's vendor directory, yet they are still not being loaded.

I have read several other posts on here and many other sites, but none of the answers are up-to-date with Drupal 8.5.2.  And the composer manager module method is depreciated.

I don't know if this is an issue with their sdk's structure or if I need to upload a another/different file(s) to the server, but instantiating the class breaks.

use Infusionsoft\Infusionsoft;
$infusionsoft = new Infusionsoft([
  'clientId'     => $id,
  'clientSecret' => $secret,
  'redirectUri'  => $redirect,
]);

Any help is greatly appreciated! Thanks!


texts:
I am trying to handle multiple submit buttons, but the handlers does not get called.

I am following http://www.hooksupport.com/blog/drupal-8-how-handle-multiple-submission-buttons-drupal-8-form, and this is the code I am using.

$form['add_field'] = array
    (
      '#type' => 'submit',
      '#value' => $this->t('Create field'),
      '#submit' => array('::create_field_submit'),
    );

 public function create_field_submit(array &$form, FormStateInterface $form_state){
     drupal_set_message(t('Form Submitted Successfully'), 'status', TRUE);
}

The message I've trying to send does not appear. Why?


texts: Drupal changes my markup in full html mode

texts:
While editing body of the node in Full HTML format, i enter these lines:

    string 1

    string 2

    string 3

But the real generated html is:

    string 1

    string 2

string 3

What's wrong with that? Why Drupal changes my code in full html? I don't want any extra
's because it breaks the layout.


texts: Is it possible to hook to variable_set() event?

texts:
I would like to track the system changes event, to make them revertable. When checking variable_set(), I see there is no hook provided for that event. Is there any way for me to do this?

I can alter to hook to settings forms, but there's a lot of settings form to track, if I can hook to variable_set() directly, code becomes much simpler.

I can also track the variable changes with features + strongarm modules, but it's better if Drupal admin can browse the variable history without code touching.


texts:
I know how to add or attache a jquery/javascript file on the specific page.

My problem is that I'm trying to add jQuery file (included in theme) at the end of every thing in the body tag so any other file or module would not override it but can't figure out yet.

Is there any way to do that?

Example:


texts: Error with drush clear-cache: Base table or view not found

texts:
There are similar questions out there, but I think this warrants a new thread.

I am getting the following error when running drush clear-cache all

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbname.cache_rules' doesn't exist: TRUNCATE {cache_rules} ;"

However, when I run the show tables command on the database, it clearly lists the cache_rules table.

Any ideas what is going on here and what I can do to fix it?


texts: It is possible to add some extra content to the rendable array of a node?

texts:
I have a hook_node_view_alter implementation in which a recive a node rendable array with its fields, data and stuff

It if possible to add like a fake field to it?

My goal is to print some data but it is nowhere in the node entity, it is not a field or a view or whatver

It is possible?

Edit:

For example i have this array

I have this node rendable array from &$build in my node_view_alter implementation

Can i like

$fake_field = $build['field_hotel'];
$fake_field['#field_name'] = 'field_hotel_2';
$fake_field[0]['#markup'] = 'Some data';
$build['field_hotel_2'] = $fake_field;

It still would be rendered?


texts: How can I enable the Front Page on minimal profile?

texts: I installed D8 using the minimal profile but it does not have or does not enable the front page view, redirecting requests to the user page. How can I enable the standard front page (with the recent posts)?


texts: How to get the parent name if chid taxonomy term id is known?

texts: How to get the parent name if child taxonomy term id is known??


texts:
I have a custom form on my site, and on submission, I'd like to update a Views page path.

Within my module, I have a form alter which eventually attaches a custom submit function where I plan to run this Views path change. Within my submit function, so far I have:

function _my_module_custom_submit() {
    $view = \Drupal\views\Views::getView('custom_view');
    $view->setDisplay('page_1');
    // TODO: Change Views path

    // Save View
    $view->save();
}

This function is running fine, however I cannot find how to change the Views Display path at all. I've tried the setHandler() and setHandlerOption() methods, but these don't appear to be working for this case.

I've found plenty of examples to change the Views path programatically in Drupal 7, but have yet to come across an example for Drupal 8.


texts: How to show new nodes in a Group node view for users who are not a Group member?

texts:
In my Drupal 8,

Defined New User Role: Manager
Added one user into the role.

I have created a group "Group-x" with corresponding group type "Group-Type-x".

I have updated the permission(view, edit, create) in group type "Advanced outsider permissions" under role Manager.

I can able to create node in group. After creation the node is not listed in the group nodes

While checking it, the user is not a member of the group. If I add the user as a member it works fine.

Since I have some thousands of users, every time I can't add it in the group. Can anyone help me out?

Is there is any possibility to add members dynamically while creating node in the group?

As you mentioned configured the outsider permission too.


texts: How to add views exposed filter blocks into views

texts:
I am trying to move a views exposed filter into a custom block, and then add it back to the views header. The reason for this is because I would like to intersperse the filter with other blocks/markup in the views header. When I selected the option to turn the filter into a block, it does show in the Block UI, but not as an option to add to the view header.

Is this possible in views?


texts: Trouble updating Modules in Drupal 7 with FTP

texts:
I'm developing in localhost. When I try to update modules, it requires FTP access. I've tried several ways by installing vsftpd and adding my user account to ftp group, chowing the files, etc. But, I'm ending up with following message:

File Transfer failed, reason: Unable to remove to file /media/location-of-drupal/module/blahblah

Now, I've decided not to use FTP. Can I just manually download latest copies and unzip > paste the modules? Will that work? And is it applicable to updating Drupal core?

Thanks :)

EDIT: I've managed to fix FTP, and is now updating modules by FTP. But still, I'd like to know the answer, i.e. does copy-paste works perfectly? I posted my answer here: http://bdhacker.wordpress.com/2011/11/26/update-drupal-modules-using-ftp-in-localhost/


texts: Views: attachment inherits exposed filters when set to No

texts:
I created a page with an attachment to it.
Its a Glossary for the Username.

And here is my attachment setting:

i Have exposed filters on the page where it is attached to:

And the Filters works together: When i write something to the name it searches it and when i click on the glossary it retains the name's search value. I don't want that.

If i click on the Glossary i oly want that search, any other filters should reset. How do i achive that?


texts:
I would like to disable a product as soon as it's stock drops to 0 in Drupal commerce.

I think this might be possible by using rules, but then I don't know what will happen to the product display. I figure that when there are no more active products attached to a product display, the display will still appear in my views but without any product information attached to it. In this case I would also like the product display to be "unpublished".

I can't unpublish the product display immediately after a given product is out of stock because there could be more products added to a single display...

Can some one help me to achieve this through rules or is there some other method that I could use?

I'm using Drupal Commerce and the stock module for it.


texts:
This thread contains the most information I've been able to find about this: #986558: "Aggregate and compress CSS files" and "Aggregate JavaScript files" in performance settings, is not working

I have 2 d7 sites. One is in public_html/ on my server and has no problems. The other is in a sub-directory, and breaks when turning on Aggregation/Compression of css & js files (in admin/config/development/performance ).

When I turn on js performance, my js doesn't work. When I turn on css performance, no css loads on my site in Firefox or Chrome, but does load in Safari. According the the above-mention issue, it's because of Drupal & my server sending compressed info to the browser, which can't decompress it and thus, I get no js or css.

Following a recommendation, I disabled these in my .htaccess file:

#Header append Content-Encoding gzip
#Header append Vary Accept-Encoding

What that did, however, was break some of my css, and load a "skip to content" area in the top of my website (which, if you do theming, you might be familiar with seeing that as a hidden html element that is loaded).

I'm not sure what to do to fix this. I encountered it the first time I built this site, but was using D7-rc1. I rebuilt it hoping new core/module updates would fix it, but this site is running on D7.7 now.

Please help. Thanks.


texts:
I've inherited a website that I need to fix.  Currently I'm working on a sidebar menu functionality has stopped working for no apparent reason.  We have an old copy of the website where the sidebar menu is working.  I've compared the Main Menu Links and configuration of Blocks>sidebar first.  Everything appears to be the same.  I've run windiff at the sites/all/themes level and any differences are either comments or recent font changes I've made. One thing I've noticed is a change to the title of a php file under /sites/all/themes/ccom/templates/block--menu_block--3.tpl.php to ...5.tpl.php.  I've changed any references to the 3 to the 5 in the style.css and that style part starts functioning, sort of, but I can't get it to function how it does in the old version.  I've even reverted the menu_block module (ver 7.x-2.7) back to the original version (ver 7.x-2.4). Didn't fix anything.  I haven't done that to the block module (current 7.43 old 7.31).  Block_Class is the same in both (7.x-1.3).

Old Version
https://webtest.ccom.nh/theme/law-sea
 (Click on any sidebar item and a sidebar will appear above the sidebar-first area with additional menu items.  Sometimes there are no submenus, but at least the main menu item will show bolded.)

Current Version
https://webdev.ccom.nh/theme/law-sea
 (Click on any sidebar item and nothing shows above the sidebar-first menu.  Click on Law of the Sea, then click on a coordinate on the image of the earth and the desired menu appears. It is also showing orange arrows to indicate active and nothing on hover.)

I am at a loss as to why it is not working and where to look.  Thanks for helping me figure this out in advance.


texts:
Is there any module that allows me to put a block in a menu?
I wanted to add some related content, or a big image about the link.


texts: Views - "Add no results behavior" not doing what I would like it to

texts: I've selected a "Add no results behavior" option for my Views page which consists of a search form. The problem with the "Add no results behavior" feature is that it displays by default, even before I've attempted to do a search. How do I change this so that it only displays AFTER the user has attempted to do a search (for which there are no results)?


texts: Is it possible to alter the form in element_validate?

texts:
I have an #element_validate function and I'd like it to be able to alter the form values that are sent back to the user in the case of other validation errors.

i.e.

User submits form with field1 invalid, field2 valid.
field2 has my #element_validate function on it. It's valid and I now want to set the value of it to something else, say foo.
User gets form again with message about field1 being invalid, and hopefully with field2 set to foo.

I've tried this in my element validate callback:

form_set_value($element, 'foo', $form_state);
$form_state['complete form'][$element['#name']]['#value'] = 'foo';

But it seems neither of these result in foo coming through in the form.


texts: How to use "content entity" type in a View?

texts:
I have used the "content entity example" coming from the example project.
This example module/:

defines a "Contact" entity; it can have extra fields, displays can be configured (web/admin/structure/content_entity_example_contact_settings),
gives the user the form to add content (contact info) to it. (/web/content_entity_example_contact/add)
shows a list of the contacts (/web/content_entity_example_contact/list)

I want to make my list as a View, but this content entity type "Contact" is not there to select it. (I see only the node content types, users, taxonomy etcI
How can I use this content in a View ? What do I have to do to make this content available in the Views UI ? Where can I find the content entity types to create a view ? Or how can I add those ?


texts: Drupal Time field for hour:minute:second.tenth of a second

texts:
Is there a drupal field type to represent time for athletics sports events. e.g. for 100m sprint: 10.42 seconds but for 800m 1:40.89 (1 minute, 40.89 seconds)
In the format : hour:minute:second.tenth of a second


texts: Get the value of one field from another in the same form

texts: I have a form with multiple fields. How can I get the value of field B  from within the formElement method of my widget class for field A?


texts: Various "Undefined" notices on content admin screen

texts:
I get these sporadically on the content admin screens.  These seem to be referencing fields that I do have in my templates, that are working just fine for those actual screens.  I just don't get why this content admin screen would be looking for those values.

Here are the error messages:

•   Notice: Undefined property: stdClass::$field_pcast_fname in include() (line 64 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/node.tpl.php).
•   Notice: Undefined variable: messages in include() (line 13 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/comment-wrapper.tpl.php).
•   Notice: Undefined index: field_twithandle in include() (line 14 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/user-profile.tpl.php).
•   Notice: Undefined variable: field_headshot in include() (line 24 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/user-profile.tpl.php).
•   Notice: Undefined offset: 1 in include() (line 94 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/user-profile.tpl.php).
•   Notice: Trying to get property of non-object in include() (line 94 of /mnt/drive2/vhosts/ainonline.com/httpdocs/drupal/sites/all/themes/ain_core/templates/user-profile.tpl.php).

And for example, the field_twithandle code that's in my user-profile.tpl.php:

<?php if($user_profile['field_twithandle']) { ?>

        <a href="http://twitter.com/<?php print $field_twithandle[0]['value']; ?>" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false">Follow @<?php print $field_twithandle[0]['value']; ?>

<?php  } ?>


texts: drupal_http_request times out on Google Maps geocoding URL

texts:
When I navigate to http://maps.google.com/maps/api/geocode/json?address=1200+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false (the Google Maps Geocoding API test address) in my browser (Chrome), I get a json response as expected. However, when I drupal_http_request() the same url, I get a request timeout error. I tried setting the timeout to 60 instead of 30 but it doesn't help.

Why does drupal_http_request('http://maps.google.com/maps/api/geocode/json?address=1200+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false') return a timeout error?


texts:
I used Drush to install Amazon S3 module. AWS SDK was installed as part of the process. No error was thrown

[root@ip-10-128-146-179 zencoder]# drush dl amazons3
Project amazons3 (7.x-1.0-beta7) downloaded to                         [success]
/var/www/html/drupal/sites/all/modules/amazons3.
[root@ip-10-128-146-179 zencoder]# drush en amazons3
The following projects have unmet dependencies:
amazons3 requires awssdk
Would you like to download them? (y/n): y
Project awssdk (7.x-5.4) downloaded to                                 [success]
/var/www/html/drupal/sites/all/modules/awssdk.
Project awssdk contains 2 modules: awssdk_ui, awssdk.
The following extensions will be enabled: amazons3, awssdk
Do you really want to continue? (y/n): y
amazons3 was enabled successfully.                                     [ok]
awssdk was enabled successfully.                                       [ok]

Now I see an error in my Drupal admin dashboard:

Failed to load the AWSSDK
Please make sure the AWSSDK library is installed in the libraries directory. Use the drush make file for easy installation.

What shoud I do?

This is my drush status:

Drupal version                  :  7.22
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database hostname               :  localhost
 Database username               :  drupal
 Database name                   :  drupal
 Database                        :  Connected
 Drupal bootstrap                :  Successful
 Drupal user                     :  Anonymous
 Default theme                   :  bartik
 Administration theme            :  seven
 PHP configuration               :  /etc/php.ini
 Drush version                   :  5.9
 Drush configuration             :
 Drupal root                     :  /var/www/html/drupal
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Temporary file directory path   :  /tmp


texts:
I am working with aegir 3 (hostmaster-7.x-3.130). After migration of Drupal website from an older platform (drupal version 8.3.7) to a newer version (drupal 8.5.0). Website is sucessfully verified after migration (all drupal modules are updatet as expected). No Error or Warning. Task queue turns green.

However, I figure out that database (as well as drupal entity) updates did not run during the migration, so I have to run "drush updb" and "drush entup" manuelly after the aegir migration.

How can I get aegir-migration automatically updating the database (entity) etc.?

Many thanks and regards

Tom


texts:
Creation of new content type by D7 core is intuitive, fast and nice looking. We don't have to worry about db tables and simple validation. We have widgets, displays, etc. And actually we are building a form (company_node_form).

Example:

Custom content type: Company

Field group: Company address (vertical tab)

Field (simple text): Street
Field (simple text): No.
Field (simple text): Zip code
Field (simple text): Country

Field group: Company contact (vertical tab)

Field (check box): Has phone
Field (simple text): Phone
Field (check box): Has fax
Field (simple text): Fax

Field group: Privacy (vertical tab)

Field (check box): Show address
Field (check box): Show phone

Question

How to add alternation using custom module "my_module" to provide AJAX behavior while adding or editing content type, i.e. to show "Phone" field only if "Has phone" is checked or show text "Sorry, we don't have authority to add companies from selected country." when UK goes to "Coutry" field?

Exclamation

I know that the above form is very simple to code inside my_module, but I wish to use core node constructor to build that form instead of coding.


texts: Why does a try block affect drupal_set_message?

texts:
I have a try block set up:

try {
//some code
throw new Exception ( 'My exception message' );
}
catch ( Exception $e )
drupal_set_message('Caught exception: '. $e->getMessage(),1);}

But instead of using 'status', 'warning' or 'error' I used an integer and get a greyish looking message box. Are there any other "hidden" drupal_set_message options? Thx


texts: Use swatches and not the color picker widget

texts:
The Color core modules allows for a user to perform css color overrides via the theme settings page. This is handy for exposing the means for users to update color specifications without touching a line of CSS code. I've successfully integrated the Color module with an Omega 3.x subtheme. However, we have a range of branded color swatches that I'd like to make available to our users, rather than the too-broad color picker that the color module uses.

So; I'd like to swap (it can be additive, i.e., use one or the other) the Drupal color picker with a pane of swatches that I can configure.

How to do so?


texts: How to migrate content (fields and paragraphs) into another content type?

texts:
My problem is following:
Initial situation
At my Drupal 8 site I have a node content type (let's calling it node content type A). node content type A has normal (core) fields included and also holds a field with paragraphs items.
Problem/proposed solution
Now I have to change my data model. Due to it's not adviced to change node content type machine name in a Drupal 8 site, I should go another way:

Clone the content type (would use Entity type clone module for this step). Let's calling it node content type B
Clone all already existing content of node content type A into new nodes of node content type B
Modify each content/content type as needed by the requirements of the new data model.

Question
How can I perform step 2, especially with the existing paragraphs items?
Thanks in advance for help and/or alternative ways.


texts: 7- OG 'og_users_roles' table doesn't seem to update on Group creation

texts:
I recently noticed that when a user of my site create a new group, the og_users_roles table do not get updated. Witch basicly means that unless the Group creator goes to the "members management" interface to give himself "Group admin", the newly created group do not have an administrator. So og_get_users_by_roles return empty when searching for the "Group admin" rid.

Is this normal? If so how would i go to give a group creator the "Group admin" role by default on group creation ?


texts: Views group different number of divs of a view by wrapping them

texts:
I have a views block that is displayed in the content section of a node. What I need is wrapping the rows of the views block by divs. I have a list of 10 divs like so:

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

Now I want to wrap the first 3 divs, div 4 to 8 and div 9 and 10 in a separate wrapper div like so.

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

Some Text here

How would I edit my views.tpl.php? Thanks!


texts: Prevent WYSIWYG+CKEditor from stripping html classes

texts:
I'm using WYSIWYG editor with CKEditor. I'm finding that when adding custom classes to my elements from the "source" view, CKEditor strips those classes when switching out of the source view.

When googling for a solution to this, I found the CKEditor module page which describes how to fix this when using CKEditor alone. (Basically, we need to set up a JS config config.allowedContent = true in its Advanced Content Filter settings).

However, when using CKEditor via WYSIWYG, these settings are not exposed in the admin interface. How do you achieve the same when using CKEditor via WYSIWYG?

PS: I cannot use CKEditor alone because it does not integrate with the media plugin.


texts:
say my custom content type has 3 different fields: max, min, mean. What I want to achieve is group them into a new field say statistics so the new statistics field will have all the values in fields max, min, mean.

In terms of display, I now have several walk around solutions.

in node--examplecontent.html.twig template:

statistics:{{ node.field_max }}/{{ node.field_min }}/{{
node.field_min }}

but the problems with this is that "statistics" is hard code so it
can't benefit from the translation module if I want to build a
multi-lang site.
or I could define a dummy field "statistics", and hide it in the
form display so user wont need to enter the value of "statistics"
when create new content of the content type. then in
node--examplecontent.html.twig template:

{{ node.field_statistics.fieldDefinition.label }}:{{ node.field_max
}}/{{ node.field_min }}/{{ node.field_min }}

this will allow me to translate to label of field statistics to have
it dispaly as a different language.

I wonder if there are some better ways to achieve it, thank you.


texts: Show PDF/print icons inside a template file

texts:
I am using a template file to render a content type. So I print variables as with the following code.

print $node->body

I have installed the Print module, and I have selected the option to display print icons for this content type to, but the icons are not getting printed.

How can the icons be printed inside a template file?


texts: Does "Maximum image resolution" resize before saving on the site?

texts:
I am building a site using Drupal 7, in which users can upload content and images.

When I set the "Maximum image resolution" (on the core image field settings) to be, for example -  800x600.

Is that mean that the pictures will first be resized and weight reduced, and only then will be saved on my Drupal site?

I don't want to have many pictures that weight a lot on my server. I prefer to save only the images that has been resized, in order to have more space on my server.


texts: How to allow anonymous user register Civicrm event without create drupal account

texts:
I'm using D7 CiviCRM 4.4.6.

I had a civicrm event with profile fields for user to fill in.

Anonymous users are allowed to register the event and create civicrm profile.

But there is a "Username" field, which force anonymous user to create a drupal user account when registering the event.

Is there anyway which anonymous user can register in my event, creating profile, without create a drupal user account?


texts: How to create a new block programmatically?

texts:
I need to programmatically create a new block. The block must show 3 last news (site content): title as a link + date of publication (format dd-mm-yyyy).

Any suggestions?


texts: Drupal Commerce : modify Collection Products view

texts:
In my webshop, I use Price Savings formatter for my discounts. In the product page, it shows list price, price with discount and savings.
In the Category overview (Collection Products view), it only shows the list price, without the discount.

I'm trying to get the category overview to show either discounted price, or a striked through list price + discounted price.
Because now, people won't notice if something is discounted until they open the product page.
I can't seem to find any simple solution anywhere, while this seems as a rather essential part of a webshop.

I've already tried editing the view, but the difficulty level goes beyond my skill at the moment. Can anyone explain how I can edit or change the fields that are shown in the Collection Products view, because it only has taxonomy name and global:custom text as fields. I've looked through the tpl files for the view, but nowhere is there a mention of which fields from the database should be shown.


texts: How to change the duration of user access?

texts:
By default Drupal keeps users logged in 2.000000 seconds, i modify in settings.php at the line:

ini_set('session_cookie_lifetime',2000000);

It is right ?


texts:
I'm a newbie in Drupal site development and I'm using Drupal 9.x. In directory web/sites/default I have 2 files:
settings.php
if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
  include $app_root . '/' . $site_path . '/settings.local.php';
}

settings.local.php
<?php

assert_options(ASSERT_ACTIVE, TRUE);
\Drupal\Component\Assertion\Handle::register();

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
$config['system.logging']['error_level'] = 'verbose';
$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;
$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['discovery_migration'] = 'cache.backend.memory';
$settings['cache']['bins']['page'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
$settings['rebuild_access'] = TRUE;
$settings['skip_permissions_hardening'] = TRUE;
?>

I think this settings are okay but everytime I modify template and reload page it doesnt change, I must go to admin and then clear cache. Please tell me how do I fix it?


texts: Redirect /user/login to HTTPS, all other requests to HTTP

texts:
I'm using Drupal 7. The login page for my users is located at /user/login, so the default login path.  I need that page to be encrypted using SSL so people aren't transmitting their passwords in the clear.

I have Apache configured so that the site can be navigated either over HTTP or HTTPS.  However, I want to implement some rewrite rules so that all requests other than /user/login are made over HTTP because it is INFINITELY faster and will result in better user experience.  I refuse to use Secure Pages at this point in time because of the bugged support in Drupal Core and I'm not going to patch Core manually.  That means I'm left with using Apache rewrite rules.

I have the following rules:

<VirtualHost *:80>
  ...
  RewriteCond %{HTTPS} off
  RewriteCond %{REQUEST_URI} ^/user/login$
  RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [L,R]
  ...
</VirtualHost>

<VirtualHost *:443>
  ...
  RewriteCond %{HTTPS} on
  RewriteCond %{REQUEST_URI} !^/user/login$
  RewriteRule ^/(.*) http://%{HTTP_HOST}/$1 [L,R]
  ...
</VirtualHost>

Now to me, that makes sense, but Drupal doesn't seem to like it.

What's happening is as follows:

If I navigate around the site using HTTP to any page other than /user/login, it works fine.
If I navigate to /user/login over HTTP, I get redirected to the front page.
If I navigate to any page over HTTPS, I get redirected to the front page over HTTP.


texts: How to write page.tpl.php header section

texts:
I am using bootstrap subtheme with drupal 7.I have a requirement to design the header as following:

My tpl file looks like this:

// copy the header code here from the default page.tpl.php

// login block goes here

I have done google searches. I am still not sure if I did it correctly. Can you please advise?


texts:
I have 1 blog block in the home page where i am displaying the title and body of the body of the blog up to 2 lines.After that I want to add read more link which redirect to the blog content type.I am using views there in the preview it is read more link is showing correctly. but not displaying in the content page.
I used this code below  in node.content type.tpl.php to display the read more link. But the read more link is not adding to the blog . but to some other content in that page.
Please suggest how to do this?

<div class="content"<?php print $content_attributes; ?>> <?php hide($content['links']); hide($content['links']['#links']['node-readmore']); print render($content); if($teaser) { print l(t('Read more'), 'node/' . $nid, array('attributes' => array('class' => t('node-readmore-link')))); }?>
 <?php print render($content['links']); ?>


texts: How can I auto-increment available options for an integer field?

texts:
I have a set of available options for an integer field:

2011|2011
2012|2012
2013|2013
...etc

The thing is I want years all the way to 2050. Is there a way to set a step increment in this field? I could create the list in a text editor and paste it, but I'd love to find a more elegant solution using code or some way of incrementing the options.


texts: Drupal module to hide part of body field initially

texts:
I'm having trouble finding results for this because there are so many conflicting search terms.

I have a content type in which I want to hide most of the Body to start, but add a Read More type of link which would just use javascript to reveal the rest of the body.

Here is an example of what I'm talking about (I'm converting this site to drupal):

http://www.inadaydevelopment.com/app-10biiFinancialCalculator-iOS.php

I'm having trouble searching for something because "Read More" returns a ton of results about the standard Read More link.

Do you know of a module that will let me do this easily?


texts: Our group has a multi-site drupal-D7 installation -- approximately 70 sites -- we need to identify which site have an RSS view. I've been trying to find a signature in the databases' that we could search for to identify which ones have one or more. So far we've been unsuccessful. Is there a way, perhaps a drush command?


texts: How do I ignore a module .git directory?

texts:
I've got a Drupal 8 installation that I manage with Drush 8.1.2, with nothing in that installation in Git except a custom module I am writing (module directory = location of .git directory = /sites/all/modules/mymodulename).

Whenever I do a drush pm-update it complains about my module:

  Project was not packaged by drupal.org but obtained from git. You need to enable git_deploy module

I don't see how I can follow the suggestion of git_deploy which, as far as I can tell, provides an update source for modules checked out of drupal.org... so how can I let Drush know that my module is a stand-alone Git installation, and stop it from generating that warning every time?

The --lock option to drush pm-update is probably not appropriate, since my module is neither a core or a contrib module, and it doesn't change the warning in any case.  The only thing I've found to make that warning go away is to delete or rename the module's .git directory.

p.s., one thing I noticed later: the warning also goes away if the module is uninstalled: probably because uninstalled modules aren't checked for upgrades.


texts:
I'm using

Content: Translation language (exposed)

in my code, And I Have two Options
- autocomplete
- dropdown

I'd like to have Checkbox, How Can I enable it?

I'm using Drupal 8


texts: What am I doing wrong in my theme that's breaking CAPTCHA?

texts:
I have a bug in my CAPTCHA implementation. When I click the "Get new captcha!" link, it does not refresh the image CAPTCHA.
After a ton of research in issue queues, testing and breaking my local, and finding everything that was NOT causing it I finally turned off my custom theme and lo, the "Get new captcha!" link works again.
My custom theme is built on USWDS Base theme.

not using a CDN

I'm using:

Drupal 9.0.11
CAPTCHA and Image CAPTCHA 8.x-1.1
USWDS Base Theme 8.x-2-4

No errors are produced in the log or in the console. I "feel" like it might be something related Ajax, but I can't figure out how to sniff it out or narrow it down.
Can anyone give me suggestions for settings I can test and change or specific places in code I might check to try to fix this? Thank you.
Update: I just tried using straight USWDS Base theme, no custom theme, and CAPTCHA bug is still there. So not my custom theme, but my contrib base theme.


texts:
I need to setup a textarea field which will provide game cheats. So I have small gifs of each and every button of Xbox, PLaystation and so on. So when someone wants to publish a cheat for Xbox he needs to insert this small gifs into the text area field. How could I go about this?
I thought it would be possible to setup a custom button for each gif in the ckeditor but I can not find out how to do it. Or is there a better way?
Thanks


texts: How do I add onclick Google Analtyics custom event "add to cart" to add to cart button in Drupal Commerce?

texts:
I want to fire a Google Analytics custom event called "add to cart" when someone adds a product to the cart.

I am using classic Google Analytics, not Universal.

I tried adding this to the commmerce_add_to_cart_confirmation.js:

_gaq.push(['_trackEvent', 'Button', 'Add to Cart']);

Didn't work.

Then I found the module that builds the add to cart form, commmerce_cart.module, and updated it to go from this:

else {
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add to cart'),
    '#weight' => 50,
  );

to this:

else {
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add to cart'),
    '#onclick' => "_gaq.push(['_trackEvent', 'Button', 'Add to Cart']);"
    '#weight' => 50,
  );

That didn't work either. I would have preferred the former because the confirmation overlay only is presented when the add to cart is successful, whereas the latter would fire the custom event every time the add to cart button is clicked, even if there was an error.

Any help would be appreciated.


texts: Filters list in custom module in a table

texts:
I've been searching to add filters in custom module based on MySQL table data.

I've created custom modules in which there are different list, now I want to add filters as it is in content, where content can be filtered based on status and type.

custom filters http://www.imagesup.net/?di=8140773687515

I've list as above where client details are listed, now I need to filer the list based on email address, phone number or his name. So I want a filter like below

custom filters http://www.imagesup.net/?di=10140773699416

I don't want to use Views.


texts: JWPlayer in Drupal has container ID starting with Numeric Character

texts:
Following up this question on SO, I am looking to change the default DIV container name that JWplayer provides to JWPlayer Div. The problem is that it starts with a numeric and that creates loading problems.

Is there a way, I can customize this JWPlayer ID ?

This is how it looks btw,

jwplayer('141ef7fe77391234fc105767808cc0a5').setup({"file":"my_video.mp4",
      "width":"838","height":"383","controlbar":"none",
      "modes":[{"type":"html5"},{"type":"flash","src":"http://path/jwplayer/player.swf"}]});


texts: Can you set an image that is part of a custom content type as the background image in a view?

texts:
Hoping someone can help me.  I have a custom content type that contains a bunch of fields with one of them being an image field.  I'd like to have the view display the image field as the background and the rest of the fields to overlay that image as text.

Can anyone make any recommendations on the best approach here?

Any guidance would be appreciated.


texts:
Are there any Drupal 7 modules for creating organizational charts? So far I have only seen one for Drupal 6.

Any solution you might have used to incorporate organizational charts in Drupal 7 will be appreciated.


texts:
I have a custom form in Drupal 8, which has a image upload field. I am storing the file ID of that uploaded image. Now I need to generate the URL of that image.

How can I achieve this?


texts: Edit profile2 tab in view profile2 rendered with views

texts:
I have a profile created using profile2 module. I want this profile to be rendered as a separate page and I have done so using views. The profile can be viewed in a url: www.example.com/application/authors/username.

I want to provide to the owner of the profile a tab on the page for editing it.

This should be simple using hook_menu, but it doesn't seem to work for me.

function MY_MODULE_menu() {
  $items['application/authors/%author/edit'] = array(
    'title' => 'Edit',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('profile2', 1),
    'access callback' => 'MY_MODULE_access_check',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
  );

  return $items;
}

Is the above code correct? Do I need to register the view as a parent tab?


texts: How to let selected role submit multiple data for 1 node?

texts:
I want to do a product price compare site. So a product is a node and product can have many different price at different store. I want to allow selected user's role able to submit new price or new store from time to time but I want them to submit data on the node page similar to submitting comments, NOT on node edit page.

I'm looking onto entityreference but i'm not sure where to start and what others module needed to accomplish my objective.

Thanks for helping.


texts: How to call a custom function when Migration(Import) is done?

texts:
I am using migration to import nodes from a csv.
I want to change the file name when import is done.
How can I call a custom function when Import/Migration is done from a specific file to change its name?

I knwo about the postimpot but I am looping thorugh directories to import data from each csv file in each directory. So postimport is called every time a file has been imported. But in posImport I cant use argument to change the last imported file name only.


texts: hook_nodeapi() is great on nodes, but what can I use on non-node pages?

texts: I'm building a module that needs to do stuff wherever the user is browsing, but I used hook_nodeapi(), which is ordinarily great but it is not coping with non-node pages (such as views, and user profile pages). Does anyone have any idea on which hook should I run in such circumstances?


texts: Create a field to type in name of body class

texts:
I want to create a field where I can put in what will be a class on the body of the node that I'm creating.  The picture below depicts my local and live environments:

How can I do this?


texts: How to remove the shipping flat rate for particular products in Drupal commerce kickstart?

texts:
I am using Commerce kickstart. I have to add the products for category wise. Categories are DVD,Audio CD and edownload.I have to use term reference field for field_category in the products content types.

Now the user purchase the edownload products means shipping charge should be 0rs. How to set the edownload term reference field products for shipping charge is 0. Anyone guide to me?.

Thanks in advance.


texts: Why are my custom fees disappearing from my orders?

texts:
I've set up my shop so that I am able to create an entire order programmatically. Line items register fine. However, I can't get fees to stick through the ordering process. I'm using the following code:

$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$fee = 'machine_name_of_fee';
commerce_fees_apply($order_wrapper, $fee, 500, 'USD');
commerce_order_save($order);

I then push the order through to checkout so that I can manage it on the backend:

commerce_order_status_update($order, 'checkout_checkout');

I get no errors, but when I check the order in the admin backend, there are no fees that show up. I've double checked that the machine name is correct, and have even confirmed that the commerce fees module returns as 'empty' if the machine name doesn't exist. This leads me to believe that the fees are indeed being added, but that they are being removed at some point after a checkout stage. Is there a specific stage where fees have to be added in order to stick to and affect the order total? Am I implementing commerce_fees_apply() incorrectly?


texts: Views and Filtering Data not getting results

texts:
I have created a view to grab all of the invoices in a system, which it does. I have two types of invoices either payable or receivable. I have two filters to start with Published Content = Yes and Content Type = Invoice. I want to be able to filter this on the invoice type so only receivable invoices show up on the view.

I have added another filter that says content type = invoice type but when I do that I get no results at all.

If I leave off the content = invoice type I get all of the invoices. How can I create a filter that will pass the invoice type to the view so I only get the receivable invoice for this particular view.


texts: Approach to create a custom search form for an apache solr search

texts:
I am creating a search similar to the example shown below:

I am looking for the best approach to do this. My current approach is to alter the drupal default search form and add the additional elements, and then use a custom submit handler to pass the search query on to the appropriate solr search path, i.e: /search/courses/funky%20widgets.

An alternative approach would be to create the form from scratch with Form API, which may give me more flexibility, but at this stage I don't know.

It would be great to hear how others would approach this, or if there is a best practice method.

Thanks


texts: AJAX login/register login works only once

texts: I'm using an AJAX login/register module. And there are two links: Login and Register. If I click login and then close it, I can click again and it will open. But if I click register, close it and click it again, it doesn't load, it is just showing me the loading bar. What's the problem?


texts: How do you build an auto-generating menu for forums?

texts:
I am using Drupal 7 with advanced forum and taxonomy menu and cannot figure out how to create a menu that will automatically add topics as menu items to forum containers with the right URL path structure. Taxonomy menu gets close but will not allow URLs other than taxonomy/term/[tid] (See: http://drupal.org/node/1161114). They need to generate in the pattern: forums/[container name]/[topic title]. I cannot seem to do this using the URL alias.

Has anyone built a drupal forum that generates a menu when topics are added and deleted that follow the standard forum URL path structure?


texts: Twig date function not working on custom field within node

texts: Even if content.field_my_date contains a date like 2021-10-01, twigs date function outputs today's date when using {{ content.field_my_date|date("M.d.Y") }}. Simply printing {{ content.field_my_date }} to make sure the field isn't empty, outputs the correct date and label.


texts: Views: List content NOT authored by the logged-in user

texts:
I want to list all the content that was NOT authored by the logged-in user in Drupal 9.
Getting the list of content authored by the logged-in user is pretty easy.

Create a View showing content.
Add a required relationship to Author.
Add a contextual filter User ID and set When the filter value is NOT in the URL to Provide default value User ID from logged in user.

But I'm stumped about how to negate this; I want the opposite (all content not created by the logged-in user).


texts: Request header field X-CSRF-Token is not allowed by Access-Control-Allow-Headers in preflight response for Drupal 7 REST API

texts:
I have few APIs created in Drupal 7 which uses session authentication. Now when I get the CSRF token and try to use it in my API call, I get following error:
Request header field X-CSRF-Token is not allowed by Access-Control-Allow-Headers in preflight response.

Here is my javascript code:

var url = "http://dev/api/v1/macc/*";
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
    if (this.readyState == 4 && this.status == 200) {
        console.log(xhttp.responseText);
    }
};
xhttp.open("GET", url, true);
// xhttp.setRequestHeader('Content-Type', 'application/json');
xhttp.setRequestHeader('X-CSRF-Token', 'xxxxxxxxxxxxxxxxx');
// xhttp.setRequestHeader('cookie', cookie);

xhttp.send();

If I run the same API from Advanced Rest Client, I get the correct response.

Any help will be appreciated.


texts: What causes "Page Not Found" messages with a "null" path as the log message, even when the page is displayed correctly?

texts:
Once every four or five pages I visit, I get "Page not found" messages in my log, even though the page is found and displays properly.  The errors suggest part of the page path is null.

For example, if I visit a (node) page like...

https://www.example.com/path/to/my-page-title-slug

...I get a "page not found" warning in the log, and the message in the log is simply...

/path/to/null

In the log entry, the "Location" is...

https://www.example.com/path/to/null

...and the referrer is...

https://www.example.com/path/to/my-page-title-slug

In every case, the page displays correctly.  To be clear, the pages are nodes.

In what appears to be a related issue, I have also found that if I have a simple custom page like...

/**
   * Test page.
   *
   * @return array
   *   A simple renderable array.
   */
  public function my_page($some_arg) {

    \Drupal::logger('mei_library')->notice($some_arg);

    $output['my_key'] = array(
      '#type' => 'markup',
      '#markup' => t('hey there'),
    );

    return $output;

  }

I will see two messages in the log: one with the appropriate value for $some_arg, and one with a null value for $some_arg.  The log entry with the appropriate value for $some_arg appears first, followed directly by the log entry of "null".

What could possibly be causing the logger method to fire twice?  And how could $some_arg ever be null?

I am seeing this happen in Drupal 8.8.2 and 8.8.3.


texts: How to filter groups of paired values in Views

texts:
I have a Field Collection field in a node. The field collection has two fields, so I can associate a group of paired values to a node. For example, {a,1}, {b,2},{c,3},{d,4}.

I have a View in which I want to filter by the values above. If I use a filter for the first type of values and put a, it will return the first 2-tuple. If I put 2 in the second filter (and nothing in first filter), it will return the second 2-tuple. But if I look for c in first filter and 4 in the second filter simoultaneously, it will return the 2 last values, because c matches the condition and 4 matches the condition, separatedly. How can I make  the View filter so I get the desired result, which is empty result in this case?


texts:
I want to add images to my article body field dynamically. Just like displaying advertisements in between the content.

Please help.


texts: Fatal Error Call to undefined function SearchApiViewsQuery():placeholder

texts:
I am using search api and views module
When I add fields Indexed user first name and indexed user last name
and then use field views combine fields filter and add those two fields I get the undefined function error

Basically I want to add a keyword search option to the views which is using index values of a search api
Is there any other option to implement keyword search in drupal


texts: Filter criteria are not working with featured content blocks

texts:
I am trying to create a featured content block for my front page. To start I have set up a "featured" vocabulary with the two terms 'featured', and 'not featured'. I have then added that field to all my content types that I use.

Now when constructing the view to get all content that has the 'featured' term works if in the filter criteria it has only one content type.
For example if I put the filter criteria to only check against the book term, then it brings back all book pages with the featured term.  However, if I set up the filter criteria to check for book page feature, or article page feature, no content is found.

Is there a limitation on mixing content filtering in this way?


texts: When should the "container" form element be used?

texts:
The System module defines the container form element, but that form element is not documented in the Form API Reference.

When should that form element be used? What is its purpose?


texts: Drupal Lightbox2 fails W3C validation because of rel="lightbox[field_image][]" attribute

texts:
I am using the latest Lightbox2 module for Drupal which works great but for my field images it adds a rel="lightbox[field_image][]" which fails W3C validation.

Is there a way to work around this so it passes validation? I have been reading somewhere to change the "rel" to "data-rel", but how would you apply this? Any ideas?


texts: Composer package is updated, but core still asks to update

texts:
I am using Drupal 8.5.5. On admin/modules/update I red the following message.

Bootstrap (Theme)
Bootstrap (Theme) 8.x-3.11 update to 8.x-3.12 (Release notes)

The composer.json contains the following text.

"require": {
    ...
    "drush/drush": "^9.3",
    "drupal/core": "~8.5.3",
    "drupal/bootstrap": "^3.12"
},

I then ran composer install and installed Bootstrap 8.x-3.12. When I run composer show drupal/bootstrap it outputs the following.

name     : drupal/bootstrap
descrip. : Built to use Bootstrap, a sleek, intuitive, and powerful front-
end framework for faster and easier web development.
keywords :
versions : * 3.12.0
type     : drupal-theme
license  : GNU General Public License v2.0 only (GPL-2.0) (OSI approved)
https://spdx.org/licenses/GPL-2.0.html#licenseText
source   : [git] https://git.drupal.org/project/bootstrap 8.x-3.12
dist     : [zip] https://ftp.drupal.org/files/projects/bootstrap-8.x-3.12.zip 8.x-3.12
names    : drupal/bootstrap

requires
drupal/core ~8.0

When I go back to admin/modules/update Drupal still says Bootstrap 8.x-3.11 is installed. I have ran drush updb and drush cr to no avail. I am confused as to why it is not running composer's version of Bootstrap.

Why?

EDIT:
When I run drush pm:list --package bootstrap the command line returns:

Bootstrap (bootstrap)  Enabled    8.x-3.11 . Yet composer's version is on 8.x-3.12.


texts:
I'm trying to get the select field below only to show only when the value of the platform field is 4 or greater. Is it possible to nest an operator within the array statement? The code below works if I change >= to => 4 however that only works when the platform value is 4 and I need to to be any time it's 4 or greater.

$form['model'] = array(
  '#type' => 'select',
  '#title' => t('Select a Model'),
  '#options' => array(0 => t('- Select -')) + $options,
  '#default_value' => 0,
  '#states' => array(
    'visible' => array(':input[name=platform]' => array('value' >= 4)),
    'required' => array(':input[name=platform]' => array('value' >= 4)),
  ),
);


texts:
I've got a content type that has a link field in it. I added this link: '
https://wwwdev.ebi.ac.uk/interpro/' and saved. Then I realised this was an old address. It should have been 'https://www.ebi.ac.uk/interpro/' so I went back in, added the new address, and saved again. But the value didn't change! It was still showing 'https://wwwdev.ebi.ac.uk/interpro/'. Here's what I've done:

Flushed the Drupal caches
Flushed the browser cache
Tried in a new private/incognito window in another browser
Checked the database - it has the correct value, not the one showing on the page
Tried another url in the link field (like 'www.google.com') and that works fine
I put the correct address back in the field and it shows as the wrong address, even though the wrong address doesn't exist in the database.
Tried adding the correct address to the body field and it was transformed to the wrong address!
In 'Manage display' I tried the different settings for the link field. 'Domain as link' resulted in the right domain showing in the link text  ('www.ebi.ac.uk') but with the link 'https://wwwdev.ebi.ac.uk/interpro/' in the href attribute.

Does anyone know what might be happening? I'm not using Conditional Fields, incidentally.


texts: How to add/ edit a node link pointing to a file url?

texts:
When rendering a node's links, I would like to show a link to a node's uploaded file instead of the read more link. I tried to replace:

$links['node']['#links']['node-readmore']['url']

with the file's url object, but that just throws the error:

  Uncaught PHP Exception
  Drupal\Core\Entity\Exception\UndefinedLinkTemplateException: "No link
  template 'canonical' found for the 'file' entity type"

My code so far:

/**
 * Implements hook_node_links_alter().
 */
function mymodule_node_links_alter(array &$links, $entity, array &$context) {

  $entityType = $entity->getType();

  if (isset($links['node']['#links']['node-readmore'])) {
    $readmore =& $links['node']['#links']['node-readmore'];

    if ($entity->hasField('field_data_sheet') &&! $entity->get('field_data_sheet')->isEmpty()) {
      $readmore['title'] = t('Download data sheet');

      $fileValue = $entity->field_data_sheet->getValue();
      $fid = $fileValue[0]['target_id'];
      $file = \Drupal\file\Entity\File::load($fid);

      $readmore['url'] = $file->toUrl(); // throws error

      // doesnt do anything:

      $links['file'] = [
        '#type' => 'link',
        '#title' => 'test',
        '#url' => $file->getFileUri(),
      ];
    }
  }
}


texts: Why is product reference showing title:sku as product title during registration?

texts:
I am using drupal commerce, when I am putting an product reference for showing products to be added during registration: the title is rendered as title:sku.
But when I see the product in the store, it is showing fine.
How can I change the title?

I have installed auto sku, but I am not using it.

edit:
I have added screenshot


texts: How to prevent comments from being indexed in drupal 7?

texts:
I've just found answers to drupal 6 to this, is it easily/nicely possible to do this by now?

I am using the search config module, but it has no setting to exclude comments from indexing. Would you still do this by altering db queries?


texts: Menu is not highlighted when viewing its corresponding page

texts:
I'm using D7. In it, one of the menu in left sidebar is not highlighted when viewing its corresponding page.

Case 1 : If I gave the path to the menu link as node/15, it is highlighted but the anonymous user can't see the menu at all.

Case 2: If the path will be www.sitename.com/blah/blahbla means its not highlighted and the anonymous user can see this menu.

Since that page is not to be accessible by anonymous user, hence this problem?
Can any one help me to get rid of this?


texts: how to define entity preprocess function

texts:
My custom module defines a custom entity, which extends the EntityAPIController class. I managed to make it basically working, i.e. displaying fields etc via my custom tpl.php file. But I would like to create a mymodule_preprocess_entity function (as suggested here) to add custom variables to the tpl.php file. But such function is not running (is not called).

Also, when I display this entity, I noticed that the function template_preprocess_entity(&$variables) from entity.module is not running, either.

What else needs to be defined to make the preprocess function for custom entity being called?


texts:
I work with Drupal almost everyday. I am constantly scouring the web for help on my current Drupal project. I come across many code examples and samples. I'm wondering how the code relates to Drupal from a module standpoint. Does anyone create a "general" module to add and interact with their Drupal site? Like a gateway to actually code things in their Drupal site instead of using the countless forms and views that encompasses normal Drupal development. Or am I getting it all wrong and the code examples are for specific modules that people are making?

A couple of code examples I come across and think to myself - "This is very general. I would like to use this but do I need to make an entirely new module?" are:

<?php
global $user;
print_r($user);
?>

or

function HOOK_views_api() {
  return array(
    'api' => 3.0,
    'path' => drupal_get_path('module', 'HOOK')
  );
}

function HOOK_views_default_views() {

  // Paste code form views export.

  $views[$view->name] = $view;
  return $views;
}

It seems like a lot of extra nonsense to create an entirely new module just to add some simple programming functionality to the site and to take advantage of the Drupal API, and to do this every time I want to program something instead of work with the UI.

Sorry for such a weird and general question but I'm just trying to wrap my head around it. Let me know if I'm completely wrong too.

Thanks!


texts: how to compare two content type fields and filter the output by drupal views?

texts:
I have two content types.

*content_type1
*content_type2 [set as content profile]

In content_type1, I have a taxonomy term [user has to choose any one of term] and content_type2 has cck select list field with same terms as content_type2.

I created two roles:

*role1 users can create content_type1
*role2 users can create content_type2

Now I want to display list of content_type1s in user role2 profile page whose "select field  Value" is as same as the "taxonomy term " of content_type1.

How can I implement this using drupal views?


texts: How to display a block if a user does NOT have a selected role?

texts:
I am thinking this has been solved elsewhere, but I haven't found anything.

I am looking for a way to display a block if the current user doesn't have a role. So, whilst the typical permissions allow a block to be displayed to everyone (by not selecting anyone) or to users with specific roles (by selecting a role), I need the inverse, displaying where the user doesn't have a selected role.

DO you have any ideas?


texts: Add another item button goes missing with unlimited, repeating dates

texts:
Unlimited + repeating date fields seem to not work together. I would like to be able to add unlimited date fields that may or may not have repeating functionality.

I currently have both unlimited and repeating options enabled on a date field:

But the "Add another item" button is missing when utilizing the field on node creation:

It should be more like this except with the repeat functionality as well:

Is this possible? Has anyone seen this issue before?

Thanks!


texts:
I have a customised form template 'user-profile-edit.tpl.php' and i'm trying to add some custom variables so I can get a block of dynamic content (users current friends / requests etc) to display in the middle of the form.

I can use 'MODULE_form_user_profile_form_alter()' to add to the form but this is not ideal as they are not form items but arbitrary markup from a custom module. I'm having to hack the form structure as follows:

$form['my_custom_stuff'] = array(
    '#markup' = 'some markup',
    '#description = 'some more markup',
    '#title' = 'yet more markup',
);

which is not nice.

Ideally i'd like to find a way to pass variables created in 'MODULE_preprocess_page()' to the 'user-profile-edit.tpl.php'. Is this possible?

Alternatively - is there a way to add custom elements to the form array without getting 'Fatal error: Unsupported operand type'?

And, no I can't change the order of the fields - the design was signed off a long time before I got involved with this project!

Thanks


texts:
When I inspected the rendered source code of my page I noticed, that the canonical link is sort of broken, in that it has the language prefix doubled as in: mysite.com/en/en/page.html. When I click that link, the mysite.com/en/en/page.html opens correct, but its source code contains canonical link of mysite.com/en/en/en/page.html - and so on, and so on.
What could be the reason and is that something that could cause search engines' ban?


texts: Using token_replace in php filter with webform2pdf

texts:
I'm trying to use submission id of webform in webform2pdf.

My problem it is possibility of usage result of token_replace in php filter.

<?php
  $node = node_load(53470);
  $sid_token = '[submission:sid]';
  $sid = token_replace($sid_token, array('node' => $node));
  print 'strlen($sid) = '. strlen($sid);
  foreach (str_split($sid) as $position => $symbol) {
    print 'Position ' . $position . ', symbol ' . $symbol . '<br>';
  }
  print 'echo($sid) = '; echo($sid);
?>

[submission:sid] must return string '145', but result is:

strlen($sid) = 16

Position 0, symbol [
Position 1, symbol s
Position 2, symbol u
Position 3, symbol b
Position 4, symbol m
Position 5, symbol i
Position 6, symbol s
Position 7, symbol s
Position 8, symbol i
Position 9, symbol o
Position 10, symbol n
Position 11, symbol :
Position 12, symbol s
Position 13, symbol i
Position 14, symbol d
Position 15, symbol ]

echo($sid) = 145

As I understand it means that token_replace function is called after php filtered expression execution but I need to use result of $sid inside php

<?php $submission = webform_get_submission(53470, $sid); ?>


texts: Give permissions to a specific role to edit specific terms

texts:
I have a vocabulary (Foods) with these terms.

Meet
Fruits

I want every user with the Gardner role to be able to edit the description of Fruits only. How can I do that?

This is just an example, on my site I have several terms, and I need specific users roles to edit specific term descriptions.

https://www.drupal.org/project/private_taxonomy does what I need, but I already have the taxonomy terms and I don't know how to change the ownership.


texts:
I want to compare a term_reference field in a node with a term_reference field in a user profile. If certain terms match, I want to message the users with those matching terms. Is this something that could be achieved with rules?

EDIT:
This is my code so far:

dpm($node->field_project_resources);
dpm($node->field_project_resources['und']['0']['tid']);

$users = entity_load('user');
$arrayuids = array_keys($users);

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'profile2')
    ->propertyCondition('uid', $arrayuids, 'IN');

$profile = $query->execute();

$arrayofpids = array();

foreach($profile as $obj){

     foreach($obj as $objinner)
     {
     array_push($arrayofpids, $objinner->pid);
     }

}
$profile2s = profile2_load_multiple($arrayofpids, FALSE);
foreach($profile2s as $obj){dpm($obj);
    foreach($obj as $objinner){
            if(is_array($objinner)){
           foreach($objinner as $i)
           {dpm($i);
                   foreach($i as $n)
                         {

                        }
           }}
    }
}

I want to compare for each value in array field_project_resources result with the profile2 array field of field_resources for each user and then return an array of users that have matching fields.
I am quite new to this and I would appreciate some help.


texts: How to validate 3 or more fields when creating content in D7

texts: I have a custom content type with 3 fields (integer). How can I check when content is created or edited that the sum of those three fields are equal to a predefined total. For instance, if the three fields represent percentages of a task to be completed, I would like to issue an error message if the sum of the three fields is not 100%


texts: When user is registered to drupal site ,disable admin approval notification

texts: I want to disable admin approval notification when user is getting registered to a drupal site. I don't want to send notification mail to the admin.


texts: how create then trigger ajax action with D7 ajax API in js

texts:
i modified views_load_more module and create a custom ajax command:

Drupal.ajax.prototype.commands.custom_views_ajax_command = function(ajax, response, status) {
    //append new content has been loaded to old (scroll auto load: slimScroll + waypoints)
};

and this's my behaviors:

Drupal.behaviors.cva_autoLoad = {
    attach: function(context, settings) {
        $.each(Drupal.settings.cva_autoLoad, function(i, st) {
        //if scroll down to last row: $(views li.pager-next a).click();
    }
}

everythings work fine, but i dont know how to trigger the next link click event if height of views is shortern than window.height()

when views is initial, if its height is shortern than scroll bound height, i want to trigger ajax load automatically

i tried this, but no luck

if(/*this height < window height*/)
    $(next_link).click();

even without condition, nothing happens

i call drupal_add_js in function render($input) (views_plugin_pager)

how to fix this? or does anyone have any better ways?

sorry about my urgly english

EDIT

maybe my question is so stupid. if yes, plz let me know.

i really need help

i found this when read ajax drupal core and views:

var setting = Drupal.settings.views.ajaxViews['views_dom_id:'+st.view_dom];
setting.page = 1;
$.ajax({
    url: Drupal.settings.views.ajax_path,
    type:'POST',
    data: setting,
    dataType: "json",
    success: function(response) {
        console.log(response);
        /*call Drupal.ajax.commands here ( it should be custom_views_ajax_command above*/
    },
});

does anyone know how to call Drupal commands or some ways are more legal?


texts: Trigger highlight in maparea when mouseover on link

texts:
I've created a content type where I can load an image into a text editor and use Image Map Editor to create area to be highlighted when mouse moves over mapped region. At the same time, below the image, a list of persons in that image is displayed. This names are coming from a taxonomy terms list. How can I highlight the area when I move my mouse on the name below the image? I guess I need a javascript which looks for the id namelist, grabs the text for each link, finds in the map with the map id "mapname123" the area hith the same name and changes its state to hovered. I hope I've used the correct words to describe the situation. Thanks in advance.

  <canvas style="width: 800px; height: 450px;"></canvas>

<map id="mapname123" name="mapname123">
  <area shape="circle" coords="213,301,36" alt="John Doe" title="John Doe" href="#1">
  <area shape="circle" coords="334,312,32" alt="Fred Flintstone" title="Fred Flintstone" href="#2">
  <area shape="circle" coords="437,317,33" alt="Wilma Flintstone" title="Wilma Flintstone" href="#3">
</map>

Name List:

  John Doe,
  Fred Flintstone,
  Wilma Flintstone,