texts:
For the past few days I have been trying to update a rather simple table with ajax.  The table cannot be rebuilt.  This is of my own accord, if the table is rebuilt all of the colors data that was already put in is ruined.  The table must remain unchanged, only appended on.

Drupal's append does not seem to give me this functionality.  Even if I set up the form and theming properly the big issue is that on submit the node will not recognize the new data.  It only accepts that which was built on start and my appends although showing up on the screen do not show up at all on submit.  Each input is not named either despite being put in.  I cannot figure out what is going on here.  This is just a mess...  Please help.

IN HOOK_FORM

$form['recipe_ingredients']['recipe_more_ingredients'] = array(
    '#type' => 'submit',
    '#value' => t('More ingredients'),
    '#description' => t("If the amount of boxes above isn't enough, click here to add more ingredients."),
    '#weight' => 1,
    '#submit' => array('recipe_more_ingredients_submit'),
    '#limit_validation_errors' => array(),
    '#ajax' => array(
      'callback' => 'recipe_more_ingredients_js',
      'wrapper' => 'thistobe',
      'effect' => 'fade',
      'method' => 'append'
),
);

function recipe_more_ingredients_js($form, &$form_state) {

    $form['recipe_ingredients']['ing'][$id] = array(
        '#theme' => 'ingredients_row',
    );

    $form['recipe_ingredients']['ing'][$id]['quantity'] = array(
        '#type' => 'textfield',
        '#title' => t('Quantity'),
        '#size' => 8,
        '#maxlength' => 8,
        '#attributes' => array('class' => array('form-item-recipe-ingredients-quantity')),
);

  return $form['recipe_ingredients']['ing'][$id];
 }


texts:
I'm installing a new Drupal site using Red Hat... Getting Clean URLs to work was a pain in the you-know-what. I followed all the steps in the official drupal.org helpguide, but ended up needing extra help for a guide specific to RHEL users here: https://www.tecmint.com/install-drupal-in-centos-rhel-fedora/

I went into my httpd.conf file and made AllowOveride All as shown here: https://www.tecmint.com/wp-content/uploads/2013/07/Enable-Clean-URL-in-Drupal.png

I then fixed all of my directory issues in .htaccess (because my .htaccess file is in sites/web), and then all my admin links work perfectly. So Clean URLs is definitely enabled, but the issue now is the site is broken.

This was probably caused by enabling Clean URLs through the httpd.conf issue, but I'm not sure. I ran drush cr and it did nothing. Help?


texts: Drupal 7, commerce shipping 2.0, and usps shipping method. Configured the product types with weight and dimension physical field. All products have weights and dimensions. All USPS services checked. The username and the connection address are set. The shipping service pane is in the correct sequence in checkout (after shipping info). At shipping services during checkout I get "No shipping rates found for your order. Please continue the checkout process."


texts: Conflicting realm variables when using i18_variable

texts:
I'm using i18_variable, and I'm using the hook_variable_info, hook_variable_group_info....I enabled the custom variables I defined after that from the admin/config/regional/i18n/variable page.

But I'm getting this error on the variable configuration page in the module

There are conflicting realm variables in the form. The variable New Name is enabled for more than one realm. Review your realm settings

Any particular reason on what could be triggering it?

Here is the relevant code.

function embed_form_menu() {

    $items = array();
    $items['embed-form-configuration'] = array(
        'page callback' => 'drupal_get_form',
        'page arguments' => array('get_embed_form_configuration'),
        'access arguments' => array('Embed Form Configuration Permission'),
        'access callback' => TRUE
      );
    return $items;
}

function get_embed_form_configuration() {
  return drupal_get_form('variable_module_form', 'embed_form');
}

function embed_form_variable_info($options) {

  $variable['embed_form_newname'] = array(
    'title' => t('New Name', array(), $options),
    'description' => t('Enter your new name, please.', array(), $options),
    'type' => 'string',
    'default' => t('Drupal user', array(), $options),
    'group' => 'embed_form',
    'localize' => TRUE,

  );

  return $variable;
}

/**
 * Implements hook_variable_group_info().
 */
function embed_form_variable_group_info() {
  $groups['embed_form'] = array(
    'title' => t('Embed Form'),
    'description' => t('Embed Form Config'),
    'access' => 'Embed Form Configuration Permission',
    'path' => array('admin/config/system/embed-form'),
  );
  return $groups;
}

function get_embed_form_configuration() {
  return drupal_get_form('variable_module_form', 'embed_form');
}


texts: Unable to override subtheme for any base theme

texts:
"Overriding inherited .tpl.php templates: Add a template file with the same name in your sub-theme folder to have it override the template from the parent theme." on drupal.org

Made subthemes with base Omega / Framework and more for testing if anything showed. Then I checked whether regions are shown in Blocks with modifying info file and they appeared just fine. Then when I copied page.tpl.php into subtheme's templates folder, I tested by putting dummy text in page.tpl.php and see if text showed up. It didn't. I tried every base theme with sub theme but nothing changed by modifying template file in subtheme's template folder.

I even drush cc drush a few times, but nothing shows up.

I am not sure why it is not working for subtheme with any base theme :(

Help appreciated.

Update

I had to uninstall Drupal and drop database. I redo install drupal with fresh database. Then tested overriding a few theme bases with a few subthemes. it worked charm.


texts: Best Practice of Extending Another's Theme?

texts:
I have a standard theme developed by others that I would like to add a custom view template to.

Is it OK to just create a new "views-view-table--MYVIEWNAME.tpl.php" file in the theme directory itself?

Or, is there a way to create a "sub-theme" for my stuff that inherits everything from the original theme?

Thanks. Bill


texts:
I've written a module that reads a csv of user records and imports them into Drupal 6 using the Batch API. The Batch API operations callback basically just does a user_save(). It works fine when I test it manually. I'm now writing a SimpleTest to verify it.

What I've found is that when I run my test (which extends DrupalWebTestCase), it actually creates new users in my primary Drupal's tables, rather than into the "simpletest" prefixed tables. I suspect this has something to do with the combination of SimpleTest and the Batch API.

Has anyone experienced this before?

SimpleTest 6.x-2.11
Drupal 6.22

Edit: Adding a very simple test case that duplicates the problem. After running the SimpleTest, my primary Drupal site will have 3 new users (u1, u2, u3) created in it. The test will fail, because no users will be created in the 'simpletest*' prefixed tables.

Module code:

function user_import_batch($user_data) {
  $batch = array(
    'title' => t('Importing users'),
    'operations' => array(
      array('userimport_process', array($user_data))
    ),
    'progress_message' => '',
    'finished' => 'userimport_finished',
  );
  batch_set($batch);
}

function userimport_process($user_data, &$context) {
  // Initialize
  if (empty($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['max'] = count($user_data);
    $context['results'] = array();
  }

  // Process max 20 users at a time
  $processed = 0;
  while ($context['sandbox']['progress'] < $context['sandbox']['max'] && $processed < 20) {
    $index = $context['sandbox']['progress'];

    // create user
    $account = user_save('', $user_data[$index]);

    $context['sandbox']['progress']++;
    $processed++;
  }
  $context['sandbox']['import_object'] = serialize($Import);

  // Finished yet?
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}

Simpletest code:

class ImportTestCase extends DrupalWebTestCase {
  protected $privileged_user;

  public static function getInfo() {
    return array(
      'name' => 'User Import Test',
      'description' => 'Test',
      'group' => 'User Import Test',
    );
  }

  public function setUp() {
    parent::setUp();

    // Create and log in our privileged user.
    $permissions = array(
      'administer users',
    );
    $this->privileged_user = $this->drupalCreateUser($permissions); // user id 3
    $this->drupalLogin($this->privileged_user);
  }

   public function testAddUsers() {
     // import 3 users
     $user_data = array(
       array(
         'name' => 'u1',
         'mail' => 'u1@example.com',
         'pass' => 'password'
       ),
       array(
         'name' => 'u2',
         'mail' => 'u2@example.com',
         'pass' => 'password'
       ),
       array(
         'name' => 'u3',
         'mail' => 'u3@example.com',
         'pass' => 'password'
       ),
     );

     user_import_batch($user_data);

     // verify that the users have been created
     // this will fail, as the users will be created in the host site that is running the SimpleTest
     $imported_count = db_result(db_query('SELECT count(uid) FROM {users} WHERE name LIKE "u1" OR name LIKE "u2" OR name LIKE "u3"'));
     $this->assertEqual(count($user_data), $imported_count, 'Imported users appear in users table. Found ' . $imported_count);
   }
}


texts: Why block id is generating with encrypted id

texts:
When I am creating one block view using Views in drupal7 it is creating perfectly but when I am seeing the id using firebug, I am seeing ecrypted id like below.

block-views-f4lsdfjiodfofsdfnsdkfbb6213e4c0fece99305

How can I remove or override this encrypted value in the id.


texts: Restrict content access by term reference in profile

texts:
What I would like to accomplish is to have the following.  Please let me know if anyone is aware of modules that can accomplish this already or what direction I should take developmentally to accomplish this.  Thanks.

Nodes

All nodes are tagged with terms from a particular vocab through the use of a taxonomy reference field.  The nodes are only accessible to specific users that have permissions to view the tagged terms.

Taxonomy

I have one vocab that I am working with for all of this control and it is enabled for all content.

Users

All users are tagged with terms from a particular vocab through the use of a taxonomy reference field added to their profiles.  This field should only be editable by a certain administrative roles.  Additionally, the user will only be able to access content on the site that is tagged with the terms set in this field.


texts:
I installed and configured statistics module and I am successful of obtaining reports. However, I wanted to view the page hit count on each page, which I am not getting. What I did:
1. Installed and configured statistics module
2.Enabled Access Log --> discard access logs older than 3 days
3. Checked count content views
4. Administer statistics and view content access statistics permission only for the administrator
5.view content hits permission for all users (authenticated/administrator/anonymous).
After all these, when I open a node or a page, I am not able to view anything related to reads or hits or page views.
Please suggest me, what should I do?


texts:
I have installed this module on a clean Drupal 7 installation. But I can't activate the Google API. I have added the API key in the GEOCODE field. But I still get the error.

Also I got a blanc screen when I add location via the content type Store Location. Maybe because the API key isn't working?

My API key:

Got it from Google API:

After clearing the cache, I still get the error:

And no Google Maps:

Thanks.


texts: How to get the body trimmed when loading nodes programmatically?

texts:
I'm getting my nodes directly using db_query (I'm applying some specific conditions), so I can't use the render function allowing me to get the trimmed (or the summary) version of the body that I configured in the Manage display tab of my content type.

For perfomance issue I don't want to use the node_load function on each of my nodes.

Is there a way that I can use a Drupal internal function that would help me to trim the body value?


texts: Add to Custom Entity Content on Node add/update

texts:
I am new to Drupal. Now, learning drupal 8.

I have added a module from command drupal generate:module named 'my_module`

I have added an entity for my_module:

drupal generate:entity:content
//bundle "NO"

What I want

I would like to add/insert in to this entity on every Node add/update.

I have got this code into my my_module.module

function my_module_form_node_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state)
{
    foreach (array_keys($form['actions']) as $action) {
      if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
        $form['actions'][$action]['#submit'][] = 'my_module_node_form_submit';
      }
    }
}

function my_module_node_form_submit($form, \Drupal\Core\Form\FormStateInterface $form_state) {
   $node = $form_state->getFormObject()->getEntity();

   $url = $node->field_website->uri; //my node field
   $name = $node->field_com->value; //my node field

   //HOW TO ADD $url, $name IN TO above custom ENTITY
}

My entity table:

1: my_module

id
uuid
langcode

2: my_module_field_data

id PrimaryIndex
langcode PrimaryIndex
name
url
status
created
changed
default_langcode Index

Please help.


texts: Without page refresh views exposed filters have to work (without AJAX)

texts: I want to create the Gallery like Example gallery link. Taxonomy filed in views exposed filters. Anyone guide to me?


texts: How to programmatically assign (attach) a file to file field while creating/saving the node?

texts:
I'm trying to assign (not upload) files to nodes programmatically.
This is the scenario:
I will create 2000 nodes and there are 2000 PDF files (one PDF per node). I don't want to upload these files via Drupal interface. I will upload all these PDF files via FTP.
These PDF files are well-named, I mean all of them have a standardized name such as {field_magazine_name}-{field_issue_number}.pdf (under sites/default/files/pdf for example).
What I want to do is to assign these PDF files to related nodes while creating/saving the nodes.

Possible Method 1
One method to do this would be to use the File Field Sources module.

I think remote file transfer can be used with some JavaScript code. The remote file transfer input can be automatically filled with the fields I want and it will work (for example http://example.com/sites/default/files/pdf/{field_magazine_name}-{field_issue_number}.pdf)... but I don't create nodes manually, I'm creating the nodes via Feeds. So, using JavaScript isn't the method I can use.
Is there any way to programmatically assign (attach) a file to file field while creating/saving the node?


texts: Setting the permission for editing block content with a specific role

texts:
I have installed the modules below, but still can not set the permission for editing a block body with an specific role. Does someone know how to solve this issue?

Thanks

Block Access

Block Content Per Role


texts: Programatically redirect to node/nid doesn't redirect to url alias

texts:
From what I understand the module 'GlobalRedirect' has been merged into the 'Redirect' module. So the redirect module should also redirect links as node/nid to it's url alias. When creating redirects trough the interface this works perfectly. But if I programatically do a redirect to a node/nid page it isn't being redirected to it's url alias..
Not sure if this is bad coding on my part, or feature not implemented in the module.

  /* @file EventSubscriber.php */

  public function onRequest(GetResponseEvent $event) {
    $baseUrl = $event->getRequest()->getBaseUrl();
    $attr = $event->getRequest()->attributes;
    if(null !== $attr && null !== $attr->get('node') && $attr->get('node')->get('type')->getString() == 'product_group' &&
    $attr->get('_controller') == '\Drupal\node\Controller\NodeViewController::view') {
      $node = $attr->get('node');
      $references = $node->get('field_references');
      $values = $references->referencedEntities();
      if($values){
        $nid = $values[0]->id();
        $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
        $event->setResponse(new RedirectResponse($baseUrl. '/' . $language . '/node/' . $nid));
      }
  }

  static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = ['onRequest'];
    return $events;
  }

I'm using this code to redirect a product group to it's first referenced entity node, which uses automated url structure generated by a pathauto pattern, but the url alias isn't being shown after the redirect, it shows node/nid. I've verified that the url alias on that page actually works, and even added a redirect from that specific node/nid to it's url alias trough the interface, but no luck.

Am I doing something wrong? Is this working as intended? Is there a cleaner/better way for me to redirect? Still quite new to Drupal 8..

Using:
Drupal 8.1.3
Redirect 8.x-1.0-alpha1
Pathauto 8.x-1.0-alpha3


texts: jQuery ui buttonset is not a function in Drupal 7

texts:
Like the title of this post suggests, I'm trying to add a fancy jQuery ui buttonset to my custom Drupal 7 module. But I'm getting the error message "TypeError: jQuery(...).buttonset is not a function" in Firebug. How can this be fixed? Do I need to update Drupal's internal jQuery ui version or something? Or maybe I need to add the buttonset widget manually?

Thanks for the help.

HTML:

<input id="edit-service-amount-0" class="form-radio" type="radio" value="0" name="service_amount">
Enkel

<input id="edit-service-amount-1" class="form-radio" type="radio" checked="checked" value="1" name="service_amount">
Dubbel

JS:

jQuery(document).ready(function() {
 jQuery('.form-item-service-amount').buttonset();
}


texts: Requesting REST-GET gives me 403 but works fine in DHC

texts:
I am stuck for hours now with a JSON REST problem:

I have a simple REST endpoint in my Drupal 8 App. If I call it with the DHC Chromium REST Extension like GET http://proreos/api/v1/checklawyer/1?_format=json, I get

127.0.0.1 - - [07/Jul/2016:15:03:54 +0200] "GET /api/v1/checklawyer/1?_format=json HTTP/1.1" 200 477 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/51.0.2704.79 Chrome/51.0.2704.79 Safari/537.36"

That's wonderful. Also Drupal does all the requested processing.
But if I call it from curl like

curl 'http://proreos/api/v1/checklawyer/1?_format=json'

I get the bad 403 response:

127.0.0.1 - - [07/Jul/2016:15:10:27 +0200] "GET /api/v1/checklawyer/1?_format=json HTTP/1.1" 403 409 "-" "curl/7.35.0"

Well actually, I want to call it from a JS plugin like:

function checkLawyer() {
  var server = drupalSettings.bootasde.proreos_server;
  var id = drupalSettings.bootasde.asdeid;
  var jUrl = server+'api/v1/checklawyer/'+id+'?_format=json';
  console.log('Q: '+jUrl);
  jQuery.getJSON(jUrl);
}

It works fine, but unfortunately, it also gives me a 403 without any further Drupal backend processing:

127.0.0.1 - - [07/Jul/2016:15:06:03 +0200] "GET /api/v1/checklawyer/1?_format=json HTTP/1.1" 403 464 "http://proreos/asde/anwalt/1" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0"

Console says:

15:17:22.973 "Q: http://proreos/api/v1/checklawyer/1?_format=json"
XHR HTTP/1.1 403 Forbidden

Any idea would be great! Thanks.


texts: How to create a Custom Content type without Title?

texts:
I'm trying to make an auction website. Therefore I made 2 Custom Content Types:
1)Item for sale
2)Offer(Bid) from user(with node reference url to Sale item)
I need to receive only 1 field(Price) from the user while making a Bid (creating the second content type).

I deleted the 'Body' field from my Content Type but I could not find a way to remove 'Title' field because it is mandatory(required) field :(
The user that makes a Bid(offer) has nothing to do with Title (he doesnt need to know that he's creating a content)

How can I remove the 'Title' field?


texts: Redirecting Pages from Standard Node page to views page

texts:
How can I redirect all of my nodes created by a content type to a views page with a different url? For example, I created content types for publications and then have pathalias creating a url for a created node:

publications/form-one

I am then using views to reformat that look and feel of the node fields and also add in some other data from other content types via Relationships and Context. In the end my new url is:

publications/001

Now, my search results will find the /form-one url and bring the user to that page, but I'd like to only return the user to the /001 page that I have compiled in views with the additional data.

Some thoughts I have had, but not sure how to implement:

If I take all the url alias away from publications and reset it back to node/nid and then .... not sure here? Some Context Redirect?
Redirects? I have a TON of pages.
hook_node_view()?

Thanks for any thoughts and please ask for clarification if needed.


texts:
I have a client who is an architect. I've created a content type called "project" that allows them to select multiple images to display on a page. These project items get promoted to the home page as teasers, however I'd like the customer to be able to select a featured image to display in the teaser, rather than having every image display.

Anyone know an easy way of doing this without having multiple image fields?


texts: Load Aegir's site credentials from a php function

texts:
I'm using Aegir and want to inject some data into a site's vhost.
And I managed to do it thanks to this post.

My problem is I can't find an Aegir function to load a site's dabase configurations from this Aegir functions listing to do it programmatically on each site-verify.

I need to find a function or method that would return a site's data:

db_name
db_user
db_passwd
etc

I tried Provision_Config('mysite.com') but I have a template argument missing error.

Does anyone know which function I should use to get the data?
I usually use drush sql-connect in ssh, but here I'm not sure it would be a clean way as it should be in a php script.

The goal is to make Drupal work with multi-site / multi-folder (I'm aware of that post and patch, but my solution seems to work for me without having to patch anything):

<VirtualHost *:80>
  DocumentRoot /var/aegir/platforms/myplatform

  ServerName mysite1.com
  SetEnv db_type  mysql
  SetEnv db_name  mydbname_1
  SetEnv db_user  mydbname_1
  SetEnv db_passwd  *********
  SetEnv db_host  localhost
  SetEnv db_port  9854

  # Credentials from other Aegir's site
  # located in a subfolder /blog.
  <Location /blog>
    SetEnv db_type  mysql
    SetEnv db_name  mydbname_2
    SetEnv db_user  mydbname_2
    SetEnv db_passwd  *********
    SetEnv db_host  localhost
    SetEnv db_port  1258
  </Location>

</VirtualHost>


texts: Migrating sha1 user passwords into drupal 7

texts:
I have an old zend 1.8 cms site and I wish to import users into a drupal 7 site so that a user can login with their sha1 password without having to changing it. Once verified convert the submitted password to drupal 7 password in the users table. I would guess I would need to import users without their passwords into the users table and create a separate table to store their sha1 passwords in the database. I would be very grateful if someone can point me in the right direction to achieve this.

<?php
$str = 'password';//Users password

if (sha1($str) === '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8') {//from imported users table
    echo "Your password is valid";
    //let user into the site
    //insert into user.pass table password $str $S$DUygh2WJWU3caajVD3mgjIHShYgOTbaZnt9uC8lf6fMNo9lX50nr
}
?>


texts:
I have a View with a table display format and all columns are set as being sortable. Although the issue isn't specific to Date fields; I am specifically trying to figure out an issue with Date fields.
I have 2 Date fields, one is primary and the other is secondary. I have tried various ways in adding the login for "if (pri) pri, else sec".

using no results option for pri date field
using twig in a custom text field

The results are:

sorts only on the base field; not the rewritten value
wsod when selecting to sort on this column

I have tried this both with db search as well as Search API - same results. I seem to be able, with Search API, to create an aggregated "First" field which seems to work; although the date format is not adjustable. I have also seen a patch which allows formatting of the base date fields; but my guess is that this will then give a string sorting of the aggregated field (i.e. Dec comes before June).
My next shot is to use the aggregated date field formatted as SOLR is giving by default and assume that is a valid date sort (I think it is, YYYY-MM-DD) and then do up a field formatter to display the correct date format.


texts: How to understand and fix a Reflection does not exist error?

texts:
I am trying to get my head around using EventSubscriber for adding HTTP Headers. In D7 I would have simply used

drupal_add_http_header('Content-Type', 'application/javascript');

But I see that this is now deprecated in D8. I have been hunting on Google for hours and it seems I need to use EventSubscriber now. My understanding of the EventSubscriber in D8 is a bit weak

I have created an EventSubscriber directory in my module

In that directory I added a file called Unsw_blocksSubscriber.php and it contains the following code

<?php

namespace Drupal\unsw_blocks\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class HeaderResponseSubscriber implements EventSubscriberInterface {
  public function onRespond(FilterResponseEvent $event) {
    $response = $event->getResponse();
    $response->headers->set('Content-Type', 'application/javascript');
  }
  public static function getSubscribedEvents() {
    $events[KernelEvents::RESPONSE][] = array('onRespond');
    return $events;
  }
}

I also added unsw_blocks.services.yml in my module and it contains the following code

services:
  unsw_blocks.subscriber:
    class: Drupal\unsw_blocks\EventSubscriber\Unsw_blocksSubscriber
    tags:
      - { name: event_subscriber }

When I try to view my site I am getting he following error

ReflectionException: Class Drupal\\unsw_blocks\\EventSubscriber\\Unsw_blocksSubscriber does not exist in C:\\xampp\\htdocs\\unsw-d8-modules\\core\\lib\\Drupal\\Core\\DependencyInjection\\Compiler\\RegisterEventSubscribersPass.php on line 30 #0 C:\\xampp\\htdocs\\unsw-d8-modules\\core\\lib\\Drupal\\Core\\DependencyInjection\\Compiler\\RegisterEventSubscribersPass.php(30): ReflectionClass->__construct('Drupal\\\\unsw_blo...')\n#1 C:\\xampp\\htdocs\\unsw-d8-modules\\vendor\\symfony\\dependency-injection\\Compiler\\Compiler.php(120): Drupal\\Core\\DependencyInjection\\Compiler\\RegisterEventSubscribersPass->process(Object(Drupal\\Core\\DependencyInjection\\ContainerBuilder))\n#2 C:\\xampp\\htdocs\\unsw-d8-modules\\vendor\\symfony\\dependency-injection\\ContainerBuilder.php(573): Symfony\\Component\\DependencyInjection\\Compiler\\Compiler->compile(Object(Drupal\\Core\\DependencyInjection\\ContainerBuilder))\n#3 C:\\xampp\\htdocs\\unsw-d8-modules\\core\\lib\\Drupal\\Core\\DrupalKernel.php(1307): Symfony\\Component\\DependencyInjection\\ContainerBuilder->compile()\n#4 C:\\xampp\\htdocs\\unsw-d8-modules\\core\\lib\\Drupal\\Core\\DrupalKernel.php(884): Drupal\\Core\\DrupalKernel->compileContainer()\n#5 C:\\xampp\\htdocs\\unsw-d8-modules\\core\\lib\\Drupal\\Core\\DrupalKernel.php(466): Drupal\\Core\\DrupalKernel->initializeContainer()\n#6 C:\\xampp\\htdocs\\unsw-d8-modules\\core\\lib\\Drupal\\Core\\DrupalKernel.php(656): Drupal\\Core\\DrupalKernel->boot()\n#7 C:\\xampp\\htdocs\\unsw-d8-modules\\index.php(19): Drupal\\Core\\DrupalKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#8 {main}

It appears I am making what is probably a simple mistake but I am having trouble finding my issue. I would appreciate it if someone could steer me in the right direction


texts:
I have create view where it get an image banner from custom post type.
Using multilingual module I could translate all nodes. except the view.
any way in how to achieve this?

I followed this answer but i cant make it work how do i translate a view page title

Steps I used:

I have 3 products so I translated each product by clicking the button translate.
I have set the filter in view to select based on selected language.

with the steps I used I can't get the translated products

I have done some debuging and I found the issue is because relationship is linked using revision_id not id

Here is the query that I found

SELECT * FROM node_field_data
LEFT JOIN node__field_product_overview ON node_field_data.nid = node__field_product_overview.entity_id AND (node__field_product_overview.deleted = '0' AND node__field_product_overview.langcode = node_field_data.langcode)
INNER JOIN paragraphs_item_field_data ON node__field_product_overview.field_product_overview_target_revision_id = paragraphs_item_field_data.revision_id
WHERE (node_field_data.status = '1') AND (node_field_data.type IN ('product')))

see this:
node__field_product_overview.field_product_overview_target_revision_id = paragraphs_item_field_data.revision_id

is there way to modify query to use target_id instead


texts: How get views advanced dynamic URL contextual filter to work with full taxonomy path?

texts:
I've tried all settings, with joint paths etc...but I just can't get the filter working properly, I know it's a settings thing, watched a whole bunch of videos but can't put my finger on it!

This is for advanced contextual filter, the dynamic one that can change depending on URL, not the static one.

Like this:

Animals
-Pets
-Farm

Path is:

localhost/animals/pets/cats.htm
localhost/animals/farm/cows.htm

I would like the filter animals/pets to show cats.htm content

I would like the filter animals/farm to show cow.htm content

I can get the filter working with single taxonomies, but not with full path.

animals works, but not animals/farm and not animals/pets

Attaching an image with the screen where I should set this up


texts: When I upload an image in drupal 8 the imagestyles are not shown for the first time

texts:
My settings are,

allow_insecure_derivatives: true
suppress_itok_output: false

Editing the itok token for the image src works at the browser level.

Does anyone know what causes the issue and a fix for it?

Notes :

When I hit CTRL+SHIFT+R in the browser the imagestyle images reappear. So the issues seems to be image is not present for the first time and browser is caching it.
The actual image can be accessed even for the first time without any issues. The issue is only with the image style images.
When I look at the actual image in the files folder, I see that there is an additional image with _0 attached to it. So looks like when the image is uploaded for the first time, it is assuming there is a duplicate and creating a new image. But still not sure why it would cause this issue.


texts: How to list all inactive modules on a multisite?

texts:
I have kept several hundreds of modules in my D6 Drupal multisite. I have had them there so that when I need any of them I don't have to download it first - I just go to /admin/build/modules and switch on what I want.

The problem is that that list of modules takes ages so long to load that the work becomes inefficient. Also Drupal monitoring services, such as the excellent droptor.com, have a hard time (literally, very time consuming calls) to retrieve the current status of each site. The PHP memory allocation is stretched as well.

In short, I am looking for a programmatic way to select and then delete all inactive and uninstalled modules in any site of a Drupal 6 multisite.

I know there are complications -- module folders often do not correspond exactly to their module names (e.g. module "CCK Privacy" is in folder "privacy"). Also, some modules might actually be in subdirectories in cases where one project ships several modules at once. The problem is especially confounded in case of multisites, where some modules might be inactive for one of the sites, but they need to be in the directory because some of the other sites use them.

(There was an interesting thread on this at http://groups.drupal.org/node/123179 but it did not offer any practical solution for multisites.)


texts: What causes composer.lock to add/remove security coverage and change GPL license string on every commit?

texts:
It seems like every time we run composer require drupal/some_contrib on a particular project multiple lines in the lock file change in small ways that have no effect but make it hard to see the real dependency update changes if any. These changes are usually reverted on the next commit. These changes are mainly of two kinds:

The license text changes from/to "GPL-2.0+"/"GPL-2.0-or-later"
The Drupal security coverage status is added or removed.

What causes this?

I verified if it is only one developer machine that makes the changes or makes the changes in a particular "direction". This is not the case. Sometimes the same developer's commit will add the security coverage and sometimes remove it.

Seeing if some developers have a different version of composer. We all have similar versions: 1.6.3 or 1.6.4

Here is a sample from a composer.lock file that had the coverage added during the last composer update command:

        {
        "name": "drupal/admin_views",
        "version": "1.6.0",
        "source": {
            "type": "git",
            "url": "https://git.drupal.org/project/admin_views",
            "reference": "7.x-1.6"
        },
        "dist": {
            "type": "zip",
            "url": "https://ftp.drupal.org/files/projects/admin_views-7.x-1.6.zip",
            "reference": "7.x-1.6",
            "shasum": "a56a61d203f9cc79ab17c497c59a56ded1ef1d3c"
        },
        "require": {
            "drupal/drupal": "~7.0",
            "drupal/views": "*",
            "drupal/views_bulk_operations": "^3.2"
        },
        "type": "drupal-module",
        "extra": {
            "branch-alias": {
                "dev-1.x": "1.x-dev"
            },
            "drupal": {
                "version": "7.x-1.6",
                "datestamp": "1470247980",
                "security-coverage": {
                    "status": "covered",
                    "message": "Covered by Drupal's security advisory policy"
                }
            }
        },
        "notification-url": "https://packages.drupal.org/7/downloads",
        "license": [
            "GPL-2.0-or-later"
        ],
        "authors": [
            {
                "name": "damiankloip",
                "homepage": "https://www.drupal.org/user/1037976"
            },
            {
                "name": "dawehner",
                "homepage": "https://www.drupal.org/user/99340"
            },
            {
                "name": "fizk",
                "homepage": "https://www.drupal.org/user/473174"
            },
            {
                "name": "sun",
                "homepage": "https://www.drupal.org/user/54136"
            }
        ],
        "description": "Replaces all system object management pages in Drupal core with real views.",
        "homepage": "https://www.drupal.org/project/admin_views",
        "support": {
            "source": "http://cgit.drupalcode.org/admin_views"
        }
    },


texts: Button that changes form field value based on other field values (D8)

texts:
I made a simple form with two input fields and a button. The button is supposed to enter the sum of the two input fields in a third field. I want the value in the third field to be editable by the user.
I've tried to change the default_value with an ajax callback, but that doesn't work. I can change all other field properties though (description, placeholder, title, ...), but not default_value.
I also tried changing the value through form_state -> setValue() in a custom validate function that I attached to the button. But form_state seems to be reset to the initial value upon form rebuild.

This is my code:

  class calculatorForm extends FormBase {

  public function getFormId() {
    return 'calculator_example';
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['#prefix'] = '
';
    $form['#suffix'] = '
';

    $form['number1'] = array(
      '#type' => 'textfield',
      '#weight' => 0,
      '#title' => $this->t('number 1'),
    );

    $form['number2'] = array(
      '#type' => 'textfield',
      '#weight' => 1,
      '#title' => $this->t('number 2'),
    );

    $form['button_sum'] = array(
      '#type' => 'button',
      '#name' => 'sum',
      '#value' => t('+'),
      '#weight' => 2,
    );

    $form['sum'] = array(
      '#title' => $this->t('sum'),
      '#type' => 'textfield',
      '#weight' => 3,
    );

    // attempt with validation function
    $form['button_sum']['#element_validate'] = array([$this,'calculator_example_custom_validate']);

    // attempt with ajax callback
    $form['button_sum']['#ajax'] = array(
      'callback' => [$this,'sumValues_ajax_callback'], //'sumValues_ajax_callback',
      'event' => 'click',
      'wrapper' => 'calculator-form-wrapper',
      );

    $form['sum']['#description'] = t('calculated sum');
    return $form;
  }

  function sumValues_ajax_callback(array &$form, FormStateInterface $form_state)  {
    $n1 = $form_state->getValue('number1');
    $n2 = $form_state->getValue('number2');
    $sum = $n1 + $n2;
    $form['sum']['#placeholder'] = $sum;
    $form['sum']['#default_value'] = $sum;
    return $form;
  }

  function calculator_example_custom_validate($element, &$form_state, $form) {
    $n1 = $form_state->getValue('number1');
    $n2 = $form_state->getValue('number2');
    $sum = $n1 + $n2;
    $form_state->setValue('sum' , $sum);
    drupal_set_message($this-> t('sum is '). $sum);
    $form_state->setRebuild('true');
  }

  public function validateForm(array &$form, FormStateInterface $form_state) {  }

  public function submitForm(array &$form, FormStateInterface $form_state) {  }

}

Does anyone know why $sum doesn't appear as a value in the 'sum' field? What am I doing wrong?

Thanks a lot!!


texts: allow role to change passwords only for authenticated users

texts:
We would like to create a role that can reset passwords for accounts but only for authenticated users, for security purposes, we do not want this role to change passwords to administrators or other roles.

I created a new role called user-admin and provided access just to:

administer users
view user profiles

When I login with this role and go to /admin/people, the role works fine except that it can change ANY profile including administrators.

I thought that changing the order of the roles would take care of this but that is not the case.

I am debating if I should create a View and filter the users on the view to only authenticated users with a link to edit the user, or if it would be better to use hooks limiting the results for the user on the /admin/people

Thanks in advance


texts: How do I retrieve a menu using its link?

texts:
Let say I have a menu item with these attributes

'title' => 'Menu Title',
'link' => ['uri' => 'internal:/taxonomy/term/1217'],
'menu_name' => 'my-menu',
'expanded' => TRUE,

I can find all the menus by their title, e.g.,

 $menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')
                ->loadByProperties(['title' => 'Menu Title']);

if ($menu_link = reset($menu_links)) {
// Get the pid of the first menu
    $menu_pid = $menu_link->getPluginId();
}

Then I tried to retrieve menu by the link property, and I couldn't.
I tried:

 $menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')
                ->loadByProperties(['link' => array('uri' => 'internal:/taxonomy/term/1217')]);

 $menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')
                ->loadByProperties(['link' => ['uri' => 'internal:/taxonomy/term/1217']]);

 $menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')
                ->loadByProperties(['uri' => 'internal:/taxonomy/term/1217']);

None of them worked.


texts: Does leaving the Views UI module enabled affect performance?

texts: I noticed that the "Disable Developer Modules" link in the Administration Menu module disabled the Views UI module. I'm under the impression that the purpose of disabling the developer modules is to reduce performance impacts. But I didn't think the Views UI module would have an affect on performance. Does leaving Views UI enabled in production have any performance impact? Is there any other reason to disable this module on a production site?


texts:
I am using Drupal 7 and I need to change classes for ALL input textfield wrappers (class='form-item').
How can I do this without JS? please help

I could change form's, form-submit's and submit-wrapper's (form-actions) classes with this code in template.php:

    function mytheme_form_alter(&$form, &$form_state, $form_id) {
        $form['actions']['submit']['#attributes'] = array('class' => array('my_class', 'my_own_class'));
    }

but I cant do anything with textfields and their wrappers


texts: how to create a free shipping coupon code in drupal commerce

texts: coupon code with free shipping ,example if coupon is applied to the order, estimated shipping rate (of $4.95) should become $0.00,i have a expedited_shipping in shipping methods with base amount of 4.95 which will be applied on order .how should i create a coupon for making the expedited shipping to amount zero.


texts: Is there ever justification for adding HTML before passing content to a twig template?

texts:
There seem to be many people trying to pass HTML markup into a twig template and having trouble doing it. It sounds like the best solution is to use something like:

$variables['test'] = ['#markup' => 'some markup'];

But, when would this be preferable (or necessary) over adding the markup in the twig template instead?


texts: Missing form state values after adding submit function

texts:
I added a submit function in the form_alter hook when inserting a node:
$form['actions']['save_as_draft'] = [
  '#type' => 'submit',
  '#value' => t('Save as Draft'),
  '#submit' => ['save_as_draft'],
  '#limit_validation_errors' => [],
];

In the save_as_draft() function, I want to get the address value from the form state, but there are no values (except for the additional submit button).
function save_as_draft(&$form, Drupal\Core\Form\FormStateInterface $form_state) {
  var_dump($form_state->getValue('field_address'));                      // outputs NULL
  var_dump($form_state->get('field_address'));                           // outputs NULL
  var_dump($form['field_address']['widget'][0]['value']['#value']);      // outputs 'Address value'
  var_dump(array_keys($form_state->getValues())); // outputs { [0]=>  "save_as_draft" [1]=> "op" }
}

How can I get the form_state values in this alternative submit function without validating the whole form?
Is there another way of retrieving the form values instead of digging through the widget arrays?


texts:
A great many of my nodes are not showing up at all on their node page (e.g. mysite.com/node/1234) but they are showing up in views, and they do exist in the database. What could cause a node to be unable to be viewed or edited on its node page, but still show up in Views and the database?

To clarify, "Not showing up at all" means I get a 404. I have cleared all caches.


texts: How do I get the user ID from the $user_profile variable?

texts: How can I get the user ID and load the user with user_load() using the $user_profile variable in the user-profile.tpl.php template file?


texts:
This is a follow-up to this question about automatic node title generation.

I'm using the "Question of the Week" content type. Its fields are "Date," and "Answer;" "Question" is its title.

What I want is a view with a collapsible field for "Answer." The view is used in a block shown in the front page ("This week's questions"), and on a page ("Past questions").

How can I get a view that has a collapsable field?

Automatic Node Title doesn't work the way I want it (can't hide hours, Doesn't update title when content is changed, etc)
View Accordion won't let me hide last of three fields (so I can't show two fields, "Date," and "Question," while hiding answers with VA).
Collapsable Text plugin screams about depreciated functions and breaks other stuff.
I don't see how to combine two fields into one in Views.

I either need to be able to collapse/hide a single field within a view, or combine two fields into one for the view. I'm looking "Computed field" now; I am not sure how to create a field via PHP, though.

I'm trying to make this into a computed field that adds the two fields together, "Date" and  "Question," but all the examples I can find are Drupal 6.


texts:
I've created a view with two fields(field_img & field_pdf) and the Format as Fields.

Now I want to download the field_pdf file when I click on the field_img.

How to achieve this one?

Thank you.


texts: Views: linking fields from different content type

texts:
I created a content type: Battle and Content type: Map.
In the content type battle I have fields "name", "date", "image", "text".
While in the content type of the map I can add one or more photos.
I would like to be able to bind fields between them, so that with a view, I can extrapolate the result so:
"date", "name of the battle," pictures of the map.

I think in the content type: Map, I expect a field to enter the link to the content type: Battle, which I need, but I do not know how.


texts:
We have a custom menu mymenu where we use menu_link_attributes to add CSS classes per menu link.

The problem we are running into is that we have one generic css class that we always want added regardless of whether it is entered through the Menu link attributes. In the twig template, it is using {{ link(item.title, item.url) }}.

We tried the following, but it will only replace myCssClass with whatever was their before and I cannot seem to find the right array when calling mymodule_preprocess_menu().

{{ link(item.title, item.url, item.attributes.addClass('myCssClass')) }}

How can I append a CSS class to a menu link to the item.attributes array?

menu--mymenu.html.twig

{{ menus.menu_links(items, attributes, 0) }}

{% macro menu_links(items, attributes, menu_level) %}
  {% import _self as menus %}
  {% if items %}
    {% if menu_level == 0 %}
      <ul{{ attributes.addClass('menu') }}>
    {% else %}
      <ul class="menu">
    {% endif %}
    {% for item in items %}
      {%
        set classes = [
          'menu-item',
          item.is_expanded ? 'menu-item--expanded',
          item.is_collapsed ? 'menu-item--collapsed',
          item.in_active_trail ? 'menu-item--active-trail',
        ]
      %}
      <li{{ item.attributes.addClass(classes) }}>
        {{ link(item.title, item.url) }}
        {% if item.below %}
          {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
        {% endif %}
      </li>
    {% endfor %}
    </ul>
  {% endif %}
{% endmacro %}


texts: How do I clean up image uploading by removing the additional upload fields?

texts:
I am running a Drupal 6 site, and I have a content type in which the user can upload a maximum of 6 images. The problem I am having is that I don't like the fact that Drupal displays all 6 file upload slots. I would prefer that it would just display one upload slot and then display the add additional image button like it does when it is configured to upload unlimited images.

Is it possible to configure Drupal to do this? I have searched high and low, and I can't find anything.

Can anyone point me to a module or to some code to accomplish this?


texts: Calendar view doesn't display node titles upon first view, but will after Prev/Next are pressed

texts:
Our calendar is doing some strange stuff. At first, all of the node title are missing.

But by pressing Prev/Next, they then appear

I can't think of what might be causing this issue.


texts:
I have created a registration form via webform 7.x-3.18. In my custome module I wrote following hooks

  MYMODULE_node_submit($node, $form, &$form_state)

  MYMODULE_node_insert($info)

But on form submission none of the hooks are triggered.
I tried submission with normal article page content form and at that time my custom module hooks are triggered.
Could someone tell the problem with my code??


texts:
I am using Colorbox (v.  7.x-2.8) and Colorbox Node (v.  7.x-3.5) to display some nodes in a Colorbox. I would like to move the controls (previous, next, etc) into the node that is displayed in the Colorbox. I have created (by using a DS code field) a div with id cboxControls. So the following piece of jQuery should make it:

$('#cboxPrevious').prependTo('#cboxControls');
//And so on for the other controls.

The prroblem is, where should I place the code? My first attempt were to put it in the .js of my Colorbox style, that is here:

Drupal.behaviors.initColorboxPlainStyle = {
  attach: function (context, settings) {
    $(context).bind('cbox_complete', function () {
      //Put the code here?
    }
  };
})(jQuery);

This doesn't work, since the cbox_complete seems to fire before the HTML of the node is put into the page - there is no cboxControls yet.

So where can I put the code instead? Or can I solve this in some other way?


texts: How and when to use filter_xss() and check_plain()?

texts:
There are lots of template files like this one views-view-fields--magazine--magazine.tpl.php in my website. how and when I should use the filter_xss()  and check_plain() to improve security? for example this is the code:

<?php print $fields['title']->content; ?>

<?php print $fields['field_magazine_body']->content;?>

<?php print $fields['field_magazine_image']->content;?>

How do I can apply those functions in it?


texts: D7 Organic Groups - Set group context in panel

texts:
I'm using Organic Groups for committee membership on a university intranet. Each group has a landing page created with panels per these d.o instructions. This is working fine, however, I cannot get the panel to pass the group context (gid / group ID) to views contained within the panel. In D6, Group ID (gid) and Node ID (nid) were the same; in D7 they are different. I need to pass the group ID to a view in order to show content generated by that group on the landing page. I've been struggling with this for a while. Am I missing something really basic?

Versions:

Context 7.x-3.0-beta2
Context OG 7.x-1.x-dev
Organic Groups 7.x-1.4
Panels 7.x-3.2
Views 7.x-3.3

Thanks,

Jordan


texts:
I am trying to create a simple time tracking app and for this purpose, I need an entity reference field with some additional filtering of referenced entities (only active projects can be selected).

I read some guides and it seems that what I need is to

1. create entity reference field

This is done in the buildForm() function of the src/Form/TimesheetForm.php class like this:

    $form['project'] = [
  '#type' => 'entity_autocomplete',
  '#title' => $this->t('Project'),
  '#weight' => '0',
  '#target_type' => 'project_entity',
  '#selection_handler' => 'default:active_projects',
  '#selection_settings' => [

  ],
  '#tags' => FALSE,
];

2. create custom plugin

This is done in src/Plugin/ActiveProjectsSelection.php like this:

    <?php

    namespace Drupal\timesheet\Plugin\EntityReferenceSelection;

use Drupal\node\Plugin\EntityReferenceSelection\NodeSelection;

/**
 * Provides specific access control for the node entity type.
 *
 * @EntityReferenceSelection(
 *   id = "active_projects",
 *   label = @Translation("Active projects selection"),
 *   entity_types = {"project_entity"},
 *   group = "default",
 *   weight = 3
 * )
 */

class ActiveProjectsSelection extends NodeSelection {

  /**
   * @param null $match
   * @param string $match_operator
   *
   * @return \Drupal\Core\Entity\Query\QueryInterface
   */
  protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
    \Drupal::logger('timesheet')->debug('buildEntityQuery');
    $query = parent::buildEntityQuery($match, $match_operator);
    //$query->condition('project_start_date', time(), '<');
    //$query->condition('project_end_date', time(), '>');
    return $query;
  }

}

However, even when I commented out all the logic, the autocomplete does not work. When I type in the field, no autocomplete popup appears. Not even the debug message is logged when I try to trigger the autocomplete.

I have also tried to extend DefaultSelection instead of the NodeSelection as I am using a custom entity which is not a node, but the result was the same.

It looks like my plugin is not even reached, but I do not know why.

I cleared the cache, my local site is in dev mode.


texts: We are trying to migrate website from joomla 3.4 to drupal 8. We followed this Tutorial , but could not able to succeed in migration. And came to know that Drupal default migrate module will only support drupal 6, 7 to drupal 8.


texts:
How can I add a CCK field that has a checkbox and a textfield in Drupal 6? so I want to have something like this:

[x] Option1 _______________
[ ] Option2 _______________
[ ] Option3 _______________
[x] Option4 _______________


texts: How to achieve order fulfillment in drupal commerce like ubercart?

texts:
I'm new to drupal commerce. I would like to know how to achieve Order fulfillment in drupal commerce like ubercart. I'm using UPS,FedEx & USPS for shipping. I had seen package options in each shipping methods configuration. I'm confused to handle shipment process for orders. Is there shipment requirements has send automatically to respective shipping service(UPS,FedEx & USPS) after creating an order?

Please help me to get clear about handle order shipment process in drupal commerce.


texts:
I'm looking for solution for following scenario in my D7 site.
I have form with 2 empty text fields. If user enters value in field 1 and submits form next time when he opens this form only field 2 will be available for input.


texts: How to use responsive design with bootstrap views

texts:
I've come a little confused and stuck with my current learning. Whilst my efforts using Workbench, Panels, Views with Bootstrap 3 looks pretty good on my desktop, when testing the Responsive layout with the Web Developer plugin, it looks pretty dire for use with smaller resolutions ie phones, tablets etc. In this day and age, I'd rather now focus my efforts on those mediums primarily.

My issue is, my Views grids matrix (say 3*4 cells) works well on the (1600*900) desktop, but repeats the Views matrix layout on the smaller mediums, obviously not right; hoping it would be say, a list. I've done a little research and maybe I'm missing an extra enabled module and found this:

https://www.drupal.org/project/views_responsive_grid

Others say it's merely using the CSS (SPAN etc) but I'm confused with what I generally need to do as my findings aren't Drupal specific.

I need to get things like my user dashboard looking well for mobile, tablet layout etc and maybe my approach using Panel pages was now the wrong way, so I'm happy to restart those pages again, or do simply what I may be missing in the first place.

Can someone give me some indicators to the norm one needs to do to get things going?

Thanks for your help.

Please be gentle, I have an ongoing illness and the ongoing meds don't help with my cognitive ability so I'm not that dumb (-;


texts: Until the Video JS Drupal project supports the CDN version, how can we go about overriding the default URL in a custom theme? It looks like there is a plan to include it in the future but not yet implemented.


texts:
I've inherited a site running a custom Zen sub-theme.

It uses standard CCK content types with several "page-node-" and "node-" template files for layout control.

The original designer used the .tpl files to manually embed various views and blocks (with specific HTML structure for styling) into different pages throughout the site.  As you can imagine, these views and blocks can not be directly configured through the UI.

One page however has some block like sidebar image elements that cannot be manipulated through the UI and appear to be embedded via a template file, but I can't find a template file in either the sub-theme or base theme (zen) directory that would affect this page at the page level. There is a node level template, but it only affects the content area, not the right sidebar.

From the source, I can see that they are not actual blocks as they simply have "
" tags around them

 ...

The element between #sidebar-right-inner and #block-block-39 simply has a
 tag with no drupal classes or ids.  This is what needs to go.  Block-block-39 has been configured through the "blocks" administration page and is supposed to be there.

If it were indeed embedded via template file, I should have a file like sites/all/themes/mytheme/pages/page-node-15.tpl.php, but I don't.  I've checked Page.tpl.php in both sub-theme and base theme (and every other .tpl file) and cannot figure out how these elements are getting there!  Is there somewhere else that a block of HTML could be embedded?

I've tried disabling Javascript on my browser with no change.  And if it were created through the UI somehow, I'm thinking it would have additional divs wrapped around it or other classes / ids.

I think I have a pretty good handle on how templates work (hierarchically speaking), and I've spent days searching for an answer. I'm sure I'm missing something silly, but I'm pretty stumped at the moment.

I basically need to just get rid of them.


texts: How to submit a node form with AJAX Drupal 7

texts: How can I set up a node form to submit via ajax. I can't find examples that show how to do this explicitly.


texts:
I am using Drupal 6 for a client and i want to export Blog entry as a CSV along with the title and Body content and images.

I have installed Views data export Module and went to

views ---> Add and gave views name like: blog, blog_entry, export_test

and from view type I tried: node, node_revisions

but it says: It seems the page you are looking for does not exist. Please make sure you typed the address correctly, or try again later.

How do I export it?
I want title, body and images


texts: How Can I Prevent Webform Being Displayed in Front Page

texts:
I've installed panopoly distribution and Webform module. I've also created a webform called contact form and added the contact form in a pane as a block. The problem is: The contact Form (webform) is being displaying in the front page as new content.

I've also tried various settings including:

Untick all options from publishing option (Administration » Structure » Content types » Webform)

to remove that but nothing works.

How can I remove webform from being displayed in the front page in Drupal 7?


texts: How to load a user field in template_preprocess_comment()

texts:
I added a country field to users and want to show it below the username on comments (in the Bartik theme).
How can I load that field into the bartik_preprocess_comment() function?


texts: error when transfering my existing drupal site to Acquia desktop

texts:
I've installed Acquia but am having trouble getting our website onto it.
I've backed up our website as a local copy on my PC and have created the mysql dump file and plugged it in. When I point the mysql database I get the following error:

  This folder contains a site that is configured for a different MySQL
  database server. If you continue, new database settings will be added
  to the site's settings.php so it will work in Dev Desktop, and it will
  no longer work using that other MySQL database server. Do you want to
  continue?

Array
(
[datbase]=>censored
[username]=> webadmin
[host] => localhost
[port] =>
[driver] => mysql
[prefix] =>
)

Can you tell me what went wrong?


texts: How can I disable the default PHP error catching in Drupal?

texts:
I'm not accustomed to being so limited by a CMS whereby I have to use it's built-in error reporting instead of more specific logging with native PHP error logging.

Is it possible to disable the error catching which happens at [site-root]/admin/reports/dblog so that I can output my own variable dumps to my PHP logs via error_log(print_r($var,true))?


texts: Make custom textfield autocomplete compatible with slashes?

texts:
I have a form which uses a textfield with a custom autocomplete path and it works just as it should. However, I get some unexpected behavior when the title/search string contains a backslash (e.g. '10/07/2016 Meeting').

After some investigation I realized that Drupal seems to interpret those as 4 separate parameters with only the first (in this case 10) being passed to the autocomplete function.  I'm not sure how I can prevent this behaviour as the passing of the string to the form is handled internally by Drupal via the '#autocomplete_path' on the textfield itself.

I checked how entity reference handled this, but it is using an entirely custom field and not the '#autocomplete_path' on a regular textfield and wasn't of much use to me.

However it would seem odd to me that the textfield autocomplete shouldn't be able to support search strings with slashes - I just can't find out how to hook into the Drupal form to encode the string somehow.

How can I make my autocomplete field compatible with slashes?


texts:
Using Views 6.x-3.x-dev

I have a content type called Images and a Content stype called Stars.  Both Types share a Vocabulary Called Name. The vocab is tags.

Via a View, I want to display all the images associated with that Star when viewing that particular Star node.

So say I am currently viewing Brad Pitt's Node. This node is tagged the term 'Brad Pitt' in the Names Vocab.  I want all his images (too who are tagged 'Brad Pitt') to be displayed below the his node.

So I need to get NODES from type IMAGES that are tagged the same term in vocab NAMES as the currently viewed node

So in the Brad Pitt Node,
get NODES from type IMAGES tagged BRAD PITT from the vocab NAMES


texts: Using sticky-enabled Table Headers causes IE10 to crash on printing

texts:
A customer complained that printing a Views page on my Drupal 7.23 (Marinelli 7.x-3.0-beta11) Site causes IE10 to error ("Internet Explorer has stopped working").  And he's right.  Works fine on Firefox, Chrome, Opera, even IE9 (but not IE 10 Browser Mode IE9).  It does work in IE10 in Document Mode 'quirks'.

On investigation it boils down to using sticky table headers - use them fail, turn them off fine!  I found that code in misc/tableheader.js lines 12-14 (below) 'helps' IE10 create the problem.

So, I have a crude workaround, but would prefer to do something more elegant. Anyone encountered this problem and have a workaround (short of not using IE10?).

$('table.sticky-enabled', context).once('tableheader', function () {
  $(this).data("drupal-tableheader", new Drupal.tableHeader(this));
});

Update - I guess it is naïve of me to expect someone to identify the error either in Drupal core, the theme, Views or my code which causes this problem. Certainly not without providing more information.  I was hoping it might 'ring a bell' and thus satisfy my curiosity.

Can I ask for more specific advice?  I found elsewhere the code below to include in template.php as a more elegant way of disabling sticky headers than no-oping the function in drupal tableheaders.js.  Can anyone please suggest how I can restrict this to print requests only? Thanks Ron

function marinelli_js_alter(&$js) {
  unset($js['misc/tableheader.js']);
}


texts:
How can I allow an end-user (site visitor) to choose a view sorting method themselves?

Or more specifically have the visitor choose Ascending or Descending based on an integer?


texts: How can we create a custom element type in Drupal 8 webform, similarly to implementing hook_webform_component_info() in Drupal 7?


texts: I'm using CiviContribute and need CAPTCHA

texts:
I'm new to Drupal and CiviCRM. I work mostly with Blackbaud/NetCommunity. I'm operating a website that using CiviContribute for donations. Our Payment Processor is Paypal Payments Pro.

I'm trying to add in a CAPTCHA or verification method to our donation part. I can't find how to add a CAPTCHA or any verification to the donation form. I don't see any customizable options on the payment page.

Is it possible to add a CAPTCHA on a CiviContribute donation form?


texts: How can the height of CKEditor text areas be controlled?

texts:
In Drupal 8.2, this worked:

function MYMODULE_editor_js_settings_alter(array &$settings) {
  if (isset($settings['editor']['formats']['simple_formatted_text'])) {
    $settings['editor']['formats']['simple_formatted_text']['editorSettings']['height'] = 80;
  }
}

This stopped affecting the height in Drupal 8.3.

CKEditor 4 documentation mentions using config.width and config.height. It seems like I just need to find the right part of the $settings array to add a height property. Inside editorSettings there is a customConfig item which is a string. I've tried some things in there but haven't landed on something that works yet.


texts: Add all related content from entity reference with views

texts:
I really hope someone can help me, because it's the last thing I have to do in this site, and I thought it would be more or less easy, but I can't get this to work.
Not even sure if this is the wright question, and sorry for some English.

My situation it's this one:
I have two content types: Books and Authors.
Books as a entity reference to authors.

In the node type Books, I want to display the book authors plus all their books.

As I use panels, I can do this simple or making a view.

But what I can't do, it's to display all the author's books in that node.

I can create a view with the authors and all their books, using views merge rows, to merge the books.

But if in the contextual filters I use the nid, all I get it's the same book from the node.

So I'm trying to create a attachment to display just the books titles from those authors, but honestly, I'm completely lost !

Perhaps someone could give me some examples how to achieve this.

Thanks


texts: Views 3 - Create an archive for a given type grouped by year, then split in to months

texts:
I am trying to create an archive in Views 3 (Drupal 7) to use a filter for a given type to sort in to a list of nodes grouped in to Months, but then they are grouped in to Year:

Node Type
  |-Year
    |-September (node count)
    |-August (node count)
      ...
    |-February (node count)
    |-January (node count)
  |-Year
    |-December (node count)
    |-November (node count)
    |-October (node count)

I have looked at the default Archive view template, but that just groups by month (i.e. September 2012 (node count))

If anyone can help that would be great.

Thanks!


texts: Ajax submission not working for same webform rendered multiple times on same page

texts:
I have a content type called "FAQ" with teaser type display views page(Around 30 contents). I have created an ajax webform and rendering the form under each teaser content to collect user's feedback for the FAQ. When I submit the first webform it works fine. But when I try to submit other forms on the same page it just scrolls to the top of the page and shows the confirmation message on the first form.
I guess it is not working due to the same ajax wrapper ID being loaded for all the forms. Can someone please suggest the best option to render the same form multiple times?


texts: When do I need a contextual filter vs. a relationship?

texts:
Can someone explain the functional difference between contextual filters and relationships?

I understand that a relationship is a table join, and a contextual filter is passing parameters to the view. Both adjust view data. How would you describe when each should be used?

I have been building complex views for a few months now, but sometimes I still don't have an intuition for what I need - I generally have to find a tutorial on exactly what I am trying to do, and I think it stems from not really understanding these two capabilities.

Edit:

Thanks for all the answers helping to describe the SQL building. On that topic, I found this advice very helpful.


texts:
Auto-complete field not working. I am getting the result in the dropdown box but unable to select any dropdown option.
This is the code:-

function _questionnaire_autocomplete($string = '') {
  $matches = array();
  $result = db_select('questionnaire', 'q')
    ->fields('q', array('title'))
    ->condition('title', '%' . db_like($string) . '%', 'LIKE')
    ->execute();

  // save the query to matches
  foreach ($result as $row) {
    $matches[$row->questionnaire_add] = check_plain($row->title);
  }

  //echo "<pre>";print_r($result);exit;
  // Return the result to the form in json
  drupal_json_output($matches);
}

help needed.


texts: Entity Reference get nodes based on tags

texts:
Let me try my best to make myself understood.

I have a node type Exhibition where I want to display related nodes of type Article, and these related nodes are tagged with taxonomy tags. On the Exhibition node I want a field where I can write one or more words, and related Articles tagged with these words should be displayed.

I want to use the Entity Reference module since this is already in use elsewhere, and I want to limit the number of modules in use. (I know of the Similar By Terms module).

Does anyone know if this is possible?


texts: Override locale_block_view in custom module

texts:
In the locale.module file there is:

function locale_block_view($type) {
  if (drupal_multilingual()) {
    $path = drupal_is_front_page() ? '<front>' : $_GET['q'];
    $links = language_negotiation_get_switch_links($type, $path);

    if (isset($links->links)) {
      drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
      $class = "language-switcher-{$links->provider}";
      $variables = array('links' => $links->links, 'attributes' => array('class' => array($class)));
      $block['content'] = theme('links__locale_block', $variables);
      $block['subject'] = t('Languages');
      return $block;
    }
  }
}

I would like to alter this function in my custom module. I've created a custom module named custom (module is enabled). I've tried to alter the function with this function : hook_block_view.

But when I do that it doesn't work:

function other_block_view($delta = '')
{
    die;
}

Nothing happens ... . The module works because hook_block_view_alter works. But I need to change the $links variable in that other function .. .


texts: Commerce add to cart not adding product to cart

texts:
I have an e-commerce site. In that, I have created product listing page using views. I have added add to cart field in the view, so the every product in the view will have add to cart button. I have enabled views caching.

When I click on add to cart button for first time it adds the product to cart. After that product is not added to cart it just reloads the page and doesn't throw any error.

After searching I found the solution https://stackoverflow.com/questions/34732300/caching-product-display-with-display-cache-and-still-be-able-to-add-products but it is not working. Kindly help me.


texts:
According to a comment on Drupal's AJAX framework it should be possible to define a link as a render array which Drupal then would turn into an ajaxified link. As far as I understand it, the essential part of this is :

$link = array(
  '#type' => 'link',
  '#title' => t('something'),
  '#href' => 'some/path',
  '#ajax' => array(
    'callback' => 'some_callback_function',
    'wrapper' => 'ajax-response-goes-here',
    'method' => 'replace',
    'effect' => 'fade',
  ),

However, I'm not quite certain which url the client would use to actually invoke the AJAX request? I know forms use 'system/ajax' to access callback methods from there, but what about this case?

If anyone would have the chance to shed a little light on how to properly ajaxify links, I'd be very greatful!


texts: Change background for authenticated user

texts:
I'm pleased with my body background for my site; it looks great when not logged in.  But when a user is logged in I need a different one.  I need to specify a slightly different background because of the fact that my Marinelli-based D7 site's custom body background (2 horizontal bands of green and black) stays in position but all content moves down almost 100px due to the administrative menu at the top.

An authenticated user would not be able to see the navbar due to this color change  (green words on a now green background).

Can I specify an alternate background for authenticated users vs. visitors?  Or perhaps better:  Is there a way to specify that the body background should move down when the user logs in and all the admin menus show up at the top?

Here's my present CSS for body:

body.marinelli{
    background: #fff url(../img/backgrounds/body-background.jpg);
    background-repeat:repeat-x;
}


texts:
I am a heavy EMACS user. On the Mac I get EMACS keybindings in most text fields, and on most websites. However, if I am on a drupal website editing an HTML field, control-b toggles bold. Command-B should toggle bold; control-b should move me back a character.

Is it possible to fix this, on either my client or on the Drupal server?


texts: I am using drupal core aggregator to show images from instagram on my website. i get the rss using https://web.stagram.com/rss/n/page_name. The images are dispalyed as media:thumbnail in the rss, and they are rendered correctly in aggregator/sources in the aggregator/source/1 path. But only the title and link are displayed in the aggregator block.


texts: How to limit term reference autocomplete to a certain branch in hierarchical vocabulary (D7)?

texts:
I would like to add a term reference field in my user registration form, where the users should enter or select the organization they are from.

Tags vocabulary:

  - Organizations
   -- Orga1
   -- Orga2
    -- Orga3
    -- etc.
  - other parent term
  - other parent term

I think i remember, that in D6 i found a way to limit the term search to a certain branch of my vocabulary, so in this case, i was able to select "Organizations" and only the children terms where handled through the autocomplete.

I played around with various modules, but still there is no way to configure a parent term, but only set a hole vocabulary for the reference while creating the field.

Of course, i could set up a single vocabulary for the organizations only, but i fear that i will end up with a mess of single-use vocabs, while i would prefere to keep those things in one hierarchical vocabulary.

Did i miss something? Was there a change in the vocabulary-use-philosophy?
Any hints appreciated.


texts: Classes to differentiate between different status messages?

texts:
After enabling my custom theme, I noticed that while Drupal adds special classes for different status messages being put out by the drupal_set_message() function, e.g. messages and messages--status. However, when I use drupal_set_message() in my module, the messages get displayed but no classes are added to the container that is displaying these messages, thus it makes them hardly stylable.

I've been looking for a solution but no site I've been able to find mentiones this. Is this a bug or am I doing something incorrectly?

Thanks a lot in advance.


texts: How to implement a Subscribe block functionality?

texts:
I wonder how to implement a block similar to the block shown below, to integrate with the Subscriptions or Notification module.

Basically it sends emails to user everytime a new article is added.

Any suggestions?


texts: Content API - parameter to find link url of a Link field

texts:
I have a custom content type called Link, which has a Link field. I'm using services and Content API to query the list of Links, and I want to show the data for a Link node where the Link is equal to a parameter passed into the URL.

Eg, I would like to do something like the following:

[Drupal root]/api/content?field_link=http://www.google.com


texts: How to have a popup calendar in a date view exposed filter?

texts:
I am setting up a view, with the Authored on filter exposed. When selecting the box, there isn't any popup calendar.

Doesn't Drupal 8 come with a calendar popup in core? How can I turn this on for exposed filters with date?


texts: Multiple Forms Messing up Threaded Comments?

texts:
I am trying to set up a Display page which shows a Node and all the comments on it. Because I don't really like Node Displays / Views and prefer to have absolute control over what I'm outputting, I am trying to use the drupal_get_form('comment_node_post_form', $c) to place forms for Comments on my page.

I also want to support threading, to a certain degree. I have placed multiple Comment Forms on my page. Some of the forms have the comment's PID set, so that threading will be supported.

For some reason, though, the Parent ID never stays after submission.

Is this because I have multiple forms on the same page? How can I get around this?


texts:
I am a kind of noobie so excuse me for that.

I am trying to implement this into my website.

It is a fancy looking bookshelf gallery. I am using drupal 6.x. I have already set up a view to list out the items I would like to appear in the gallery. In other posts, I saw that if I set up the view output as "fields" I can wrap individual fields into custom divs. That is kind of what I want to achieve. The code I need to alter is the following:

What I need to know is how to make the view output my field data (node url, img, nodetitle) in specific parts of the HTML (data-url ,img ,title); plus, based on taxonomy terms, form different categories. So my books will be under books, and my DVDs will be under dvd.


texts: When/how are text format filters executed/applied?

texts:
I was experimenting in D8 with filters on text-formats to understand why i was not seeing CSS i had placed in a block.

Turning on and off Limit allowed HTML tags and correct faulty HTML and Correct faulty and chopped off HTML i saw that the limit filter was not only applied to the output, but the results were also saved to the block. That's in contrast to the description on the text-format config page:

  A text format contains filters that change the display of user input

Then when i saw that without any filters on, a &lt:style> tag was turned into &lt:style type="text/css"> it became clear that CKEditor was doing his thing too...
Sure enough, after disabling the editor, the limit filter only altered the output.

Now, my questions:

Is this described behaviour all as intended? If so, what's the logic?
And, shouldn't the fact be described in the UI that enabling an
Editor changes the filter's behaviour?

Or is this a bug?


texts:
I have multi level taxonomy with 2 levels, but when I run REST export on it, "parent":[], always stays blank - no matter how many levels there is.

How can I expose relations within taxonomy via restful?


texts: How to get body field within THEME_page_alter

texts:
Possible Duplicate:
  How do I access node body from template.php?

I've actually asked this previously, but I received an unsatisfactory answer, and thus my question was forgotten, as it was marked 'answered'.

My aim is to have a meta description on my front page, and a meta description for each of my blog entries, I'm using THEME_page_alter to achieve this. Both the metatag and metatags_quick modules don't seem to work properly despite several hours of changing settings.

Here is the code located in my template.php:

function vertaxe_page_alter($page) {
    $description = 'My default desc';
    if (!empty($page['content']['system_main']['nodes']) && is_array($page['content']['system_main']['nodes'])) {
        foreach ($page['content']['system_main']['nodes'] as $nid => &$content) {
            if ($content['#node']->type == 'blog') {
                $description = '';
            }

        }
    }

    $meta_description = array(
        '#type' => 'html_tag',
        '#tag' => 'meta',
        '#attributes' => array(
            'name' => 'description',
            'content' =>  $description
        )
    );

    drupal_add_html_head( $meta_description, 'meta_description' );

}

How do I get the node's body field for use in my description?


texts:
I'm interested to aggregate posts on my Drupal site with the built-in feed aggregator.
The feed aggregator can make different feeds based on categories which is nice; my problem is that, when users create a post, they cannot assign a category at the same time. They have to later on find the post manually via the feed aggregator and set the category.

Is there a way to allow users to assign categories while creating a post?


texts:
I want to add .gitignore file to my local repo. My local repo is a clone from my Drupal 8 distro from Acquia Cloud.

What are best practices for my .gitignore file for Acquia Cloud hosted sites? I followed this tutorial.

For example: do i have to ignore settings.php and not settings*.php? Regarding this quote from the tutorial:

  Drupal 8 You can modify .gitignore so that it ignores settings.php
  (not settings*.php). Then, you can update the standard settings.php
  with the Drupal 8 local settings file checker:

Where is settings.local.php for, mentioned in the Quote above from the article?

Currently my .gitignore file looks like this:

# This file contains default .gitignore rules. To use it, copy it to .gitignore,
# and it will cause files like your settings.php and user-uploaded files to be
# excluded from Git version control. This is a common strategy to avoid
# accidentally including private information in public repositories and patch
# files.
#
# Because .gitignore can be specific to your site, this file has a different
# name; updating Drupal core will not override your custom .gitignore file.

# Ignore core and vendor when managing dependencies with Composer.
# core
# vendor

# Ignore configuration files that may contain sensitive information.
sites/*/settings*.php
sites/*/services*.yml

# Ignore paths that contain user-generated content.
sites/*/files
sites/*/private
sites/*/files-private

cache/
files/

# Ignore SimpleTest multi-site environment.
sites/simpletest

# If you prefer to store your .gitignore file in the sites/ folder, comment
# or delete the previous settings and uncomment the following ones, instead.

# Ignore configuration files that may contain sensitive information.
# */settings*.php

# Ignore paths that contain user-generated content.
# */files
# */private

# Ignore SimpleTest multi-site environment.
# simpletest

# Ignore default text files
/CHANGELOG.txt
/COPYRIGHT.txt
/INSTALL*.txt
/LICENSE.txt
/MAINTAINERS.txt
/UPGRADE.txt
/README.txt
sites/all/README.txt
sites/all/modules/README.txt
sites/all/themes/README.txt

# ------------------------------------------------------------------------------
# SublimeText files
# ------------------------------------------------------------------------------

# Workspace settings.
*.sublime-workspace

# Project settings.
*.sublime-project

# ------------------------------------------------------------------------------
# OSX
# ------------------------------------------------------------------------------

# Common OSX files.
.AppleDouble
.DS_Store
.LSOverride

# Thumbnails.
._*

# Files that might appear in the root of a volume.
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share.
.apdisk
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items

# ------------------------------------------------------------------------------
# Windows
# ------------------------------------------------------------------------------

# Windows image file caches.
ehthumbs.db
Thumbs.db

# Folder config file.
Desktop.ini

# Recycle Bin used on file shares.
$RECYCLE.BIN/

# Windows Installer files.
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts.
*.lnk

# ------------------------------------------------------------------------------
# Linux
# ------------------------------------------------------------------------------

# Tilde files.
*~

# KDE directory preferences.
.directory

# Linux trash folder which might appear on any partition or disk.
.Trash-*

What do i have to change to make it perfect?


texts:
I am struggling to find a way for a custom block type of mine to reference a view. Basically I want a field of the block to show some of the newest articles.

Using the entity reference field and an entity reference view I must select the articles to show manually.

Is there a simple way to use the entity reference field to render the contents of a view or a view block? Or do I need to code it myself?
Thanks in advance.


texts: No results because of relationships, unless "Bypass content access control" is selected

texts:
I have a view that lists faculty members in a table. Everything was working fine until I decided to go into incognito mode to view the table. It wasn't rendering anything at all. So I went back and tried a few things:

Since it was a view/display issue, I thought it was caused from the permissions. So I changed all the permissions to access: none (and a bunch of other combinations). This didn't seem to be the issue.
Selecting Bypass content access control worked fine, but I don't want to use this because of the security implications.
Getting rid of the relationships works, but I need the relationships.

Note that this view works if I am logged in as administrator user; it doesn't work when I am in incognito mode (logged out/anonymous user). So I suspect it is a permission issue (given that "Bypass content access control" worked), but I am not really sure.

I have 6 different pages in this view.


texts: Update Webform and not Add if there is an existing value in one of the fields

texts:
In Drupal 7, I have a field which stores Usernames of the user. If a submission is made by a user, it stores its username.

All I want is that if there's an existing submissions made by a user, and that user makes an entry in the form, the webform should update the previous entry rather than create a new one.

Any idea how it can be achieved?

Thanks.


texts:
I am using the Migrate module, and I need to upload a CSV file before every migration run.  I've created a module that allows me to upload a file.

My first step was to make sure I had the logic correct for overwriting a file, so I have the following code:

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

if ($form_id == 'migrate_ui_dashboard_form') {
  $form['fldset'] = array(
   "#type"        => "fieldset",
   "#title"       => "CSV to Import",
   "#collapsible" => "TRUE",
   "#collapsed"   => "FALSE",
   "#weight"      => "-98",
 );
$form['fldset']['csv_file'] = array(
   "#type"   => 'managed_file',
   "#title"  => t('Choose a file'),
   "#upload_location" => 'private://user_migration',
   "#upload_validators" => array(
      "file_validate_extensions" => array('csv'),
   ),

 );

$form['fldset']['actions'] = array(
   "#type"    => 'submit',
   "#value"   => t('Uploady'),

 );

}

return $form;

}

That creates the file upload widget etc.

The following is what I do upon form submission:

 function migrate_htmlfiles_form_submit($form, &$form_state) {

  $file = file_load($form_state['values']['csv_file']);
  //TODO: rename file to user_migrate.csv
  $file->status = FILE_STATUS_PERMANENT;
  $file->replace = FILE_EXISTS_REPLACE;
  file_save($file);
}

The file uploads fine, and then when I refresh the form, and do another upload, that works but the file is not overwritten, but is incremented.


texts:
I am trying out the Migrate module, to move my site from Drupal 6 to Drupal 7, but I dont see comments being moved; just the content is migrated.

How do I migrate comments too?


texts: How to change active link css class (is-active)

texts:
What the best way to change css class for an active link from 'is-active' to (in my case) 'active'?

Also, need I really to replace it or to append my class? I know the 'is-active' class is hard-coded (here and in several php classes) and it is so strange for me since drupal is overloaded with many abstraction layers and tons of settings. What is it: "legacy of the past" or really well-founded idea?

I need 'active' class just for my current css-framework, but may be 'is-active' used in core or so?

Thank you!


texts: How to get the id of a group when using the Group module?

texts:
I'm using the Group module.

How can I get the id of a group whose a user is a member (I have the user id)?


texts: How to read drupal reports programmatically?

texts:
Background: I have installed Maillog and need to read its mails for my behat tests. But I can not find any functions that give me an 'easy' access to this mails via php.

Question: Is it possible to read Drupals reports programmatically without read data direct from database?


texts: How to add custom sort order to a taxonomy field list?

texts:
I am trying to sort the list of content according to the weight order given to taxonomy term.

Terminology used:

content type    : contact-person-details

taxonomy        : company vocabulary which has list of company names like company A, company B, ...

session company : every user has a company which is stored in session, users have similar company names too.

how it works now: Imagine I am from "company A" stored in my session. Based on my company, content in a view is getting shown (company A is the taxonomy term used for filtering).
Views are used to filter the content type contact-person-details. Varies from company to company which was tagged to content, based on user session company.

What I am trying to achieve? Image below helps in understanding the visual concept. Imagine list (Test one, Test sort, ...) shown are the company vocabulary lists, just like (company A, company B, ...) I want an additional field or textbox just to the side of each term showing to add weight. This weight should be available in the view so that I'm able to making sorting based on the weight allocated for each content.

I would like to know is there a existing possibility to weight the taxonomy list in field.

If it is still complex to understand I will try to edit my explanation.


texts: How to create a view to display only child nodes of a parent term?

texts:
Is it possible to create a view which displays only the child nodes of selected taxonomy term?

I have something like this

-Fruit
--Apple
---Green
---Red

and when I click on fruit (taxonomy/tem/1), I want to display only nodes with term apple, green, red. Now It is displaying nodes from fruit, too, but I dont want it. I have some nodes with term fruit but I dont want to display it when I click on fruit.. only nodes from fruit children terms.

Is it possible to do this?


texts: The best way to debug a custom token module development

texts:
I'm building a custom module to build some tokens. I have added hook_token_info() and it works great. I haved added hook_tokens(), but I'm not able to debug with var_dump() or with dpm().

function mymoduletoken_token_info() {
  $info['tokens']['node']['seccion'] = array(
    'name' => t('Seccion'),
    'description' => t('Custon token to add to the G.A. script more optoins in seccion'),
  );

  $info['tokens']['node']['subseccion'] = array(
    'name' => t('Subseccion'),
    'description' => t('Custon token to add to the G.A. script more options into subseccion'),
  );
  return $info;
}

function mymoduletoken_tokens($type, $tokens, array $data = array(), array $options = array()) {
  dpm($type);
  dpm($token);
  dpm($data);
  dpm($options);
}

I would like to debug the different options to build the token with the information I need.


texts: Remove duplicate values in a column after join in drupal 7

texts:
I am using this db_select query.

$query = db_select('taxonomy_index', 't1');
    $query->distinct();
    $query->join('node', 't2', 't1.nid = t2.nid');
    $query->join('taxonomy_term_data', 't3', 't3.tid = t1.tid');
    $query->fields('t1', array('tid'));
    $query->fields('t3', array('name'));
    $query->fields('t1', array('nid'));
    $query->groupBy('t1.nid');
    $query->condition('t2.type', 'article', '=');
    $query->condition('t3.vid', '2', '=');
    $query->orderBy('t2.created', 'DESC');
    $query->range(0, 20);
    $result = $query->execute()->fetchAll();
    print_r($result);

After running this query
my output is

tid  name   nid
1    apple   200
5    orange  165
9    grapes  130
5    orange  106

My expecting output is

 tid  name   nid
    1    apple   200
    5    orange  165
    9    grapes  130

No need to repeat duplicate rows like  5 orange 106 again. How this can be possible?


texts: Drupal 7 - can't uninstall Features module

texts:
i just started to mess up with Drupal 7 (and Drupal in general sense) - and i can't uninstall module named Features it gives error

PDOException: SQLSTATE[HY000]: General error: 1 no such table: menu_custom: DELETE FROM {menu_custom} WHERE (menu_name = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => features ) in features_uninstall() (line 29 of /Users/umren/projects/LAMP/sites/all/modules/features/features.install).

p.s. i'm using sqlite if it matters


texts: How to get drupal to check for a twig template in the active theme folder before checking the module folder?

texts:
I'm developing a contrib module for Drupal 8 that sends email notifications to group members when new content has been posted in groups they have subscribed to. The module defines some new view modes for nodes and comments. It then uses these new view modes to render the contents of the emails it sends out. The module defines a theme hook suggestion for each view mode and supplies a twig template for each view mode.

It works fine as is. The twig templates from within the module are utilized without a problem. What I'm not understanding is why copies of these templates placed within the active theme are not utilized. I'm familiar with the process of copying an existing twig template into a theme to be modified. But no matter what I do the template from the module is always used in this case. It was my understanding Drupal searches for suitable twig templates in the theme first and then works backward but perhaps my module is missing something.

Here are code samples for more details.

Define the view mode for comments - in modules/contrib/group_subscription/config/install/core.entity_view_mode.comment.group_subscription_immediate

langcode: en
status: true
dependencies:
  module:
    - comment
id: comment.group_subscription_immediate
label: 'Group Subscription Immediate (comment)'
targetEntityType: comment
cache: true

Define the theme hook suggestion - in modules/contrib/group_subscription/group_subscription.module

/**
 * Implements hook_theme()
 */
function group_subscription_theme($existing, $type, $theme, $path) {
  return [
    'comment__group_subscription_immediate' => [
      'base hook' => 'comment',
    ]
  ];
}

/**
 * Implements hook_theme_suggestions_comment_alter()
 */
function group_subscription_theme_suggestions_comment_alter(array &$suggestions, array $variables) {
  if ($variables['elements']['#view_mode'] == 'group_subscription_immediate') {
    $suggestions[] = 'comment__group_subscription_immediate';
  }
}

Please let me know if there is anything else I can provide to help me figure this out. I've been working with Drupal for years but am still relatively new to D8 and this is my first attempt at creating a module to give back. Thanks in advance!


texts: How to list similar products using views in Commerce Kickstart?

texts:
I am trying to list other products in the same category using the Views module when browsing a product.

For example, I am browsing drinks/drupal-commerce-wake-you; I want to list all other products in the "drinks" category, to build similar, or related products.

How can I achieve this?


texts:
I'd like to change the orderby clause in the Drupal built-in search. I have implemented the feature in a module using hook_query_alter, but it doesn't seem to work. Any advice on making it work?

/**
* Implements hook_query_alter().
*/
function pa_search_sort_query_alter(QueryAlterableInterface $query) {

  $is_search = FALSE;

  foreach ($query->getTables() as $table) {
     if ($table['table'] == 'search_index') {
      $is_search = TRUE;
     }
   }

  if (get_class($query) !== 'PagerDefault') {
    if($is_search){
      $fields =& $query->getOrderBy();
      unset($fields['calculated_score']);
      $query->orderBy('calculated_score', 'DESC');
      }
  }
}


texts: infinit redirection loop with lightbox2 module

texts:
I have a redirection with drupal_goto() function like that :

drupal_goto($url, array('fragment' =>  'lightbox='.  $lb_path, 'alias' => TRUE));

this link, after redirection, automatically open a lightbox, but the lightbox itselef still open another lightbox and so on ... (infinit redirection and opened lighboxes)

the lightbox is a content of node, and the idea is to redirect users from google search if it index a content of a lightbox. here my code in hook_node_view :

function MYMODULE_node_view($node, $view_mode, $langcode){
    if(strpos(request_uri(), "/lb/") !== FALSE && strpos(request_uri(), "lightbox") === FALSE){
         // the "/lb/" in path is only for lightbox content
         // my code here to get the right $url of the node containing the lightbox link.
         drupal_goto($url, array('fragment' =>  'lightbox='.  $lb_path, 'alias' => TRUE));
     }
}

But unfortunately I get an infinit loop !
Maybe the if statement was my fault...
Is there other alternative ? check for example if a lightbox is already open. But I don't think that would be possible in that php function!
Any other help will be appreciated :)

Thanks in advance.


texts: Views - List of content that user (ID from URL) voted on

texts:
I want to make a list on every profile page of content that the user voted on.

I've yet only managed to show the current logged in user's votes, not the user from the profile page.

In other words, I need to pass the User ID from Contextual filters to the Filter criteria with VotingAPI.

I tried with the filter Votes: User, but I wasn't able to set Is one of: % as the username, which would've solved my problem.