texts: Trying to fix errores with the admin_menu module

texts:
I have a Drupal 8 installation that went bad after installing admin_menu module.
and now the website is down with this error.

  stderr: PHP Fatal error:  Call to undefined function user_access() in /var/www/clients/client1/web7/web/modules/admin_menu/admin_menu.module on line 149

I've tried to delete the admin_menu module with Drush, given website is completely out of order and it gives me this error.

  PHP Fatal error:  Call to undefined function variable_del() in /var/www/clients/client1/web7/web/modules/admin_menu/admin_menu.install on line 22
  Drush command terminated abnormally due to an unrecoverable error.
  Error: Call to undefined function variable_del() in /var/www/clients/client1/web7/web/modules/admin_menu/admin_menu.install, line 22

So I've looked into admin_menu.install and I have commented out its code.

function admin_menu_uninstall() {
  // Delete variables.
/*  variable_del('admin_menu_components');
  variable_del('admin_menu_margin_top');
  variable_del('admin_menu_position_fixed');
  variable_del('admin_menu_tweak_modules');
  variable_del('admin_menu_tweak_tabs');
  variable_del('admin_menu_show_all');
  variable_del('admin_menu_display');
  variable_del('admin_menu_cache_server');
  variable_del('admin_menu_cache_client');
  // Unused variables still should be deleted.
  variable_del('admin_menu_devel_modules');
  variable_del('admin_menu_devel_modules_enabled');
  variable_del('admin_menu_devel_modules_skip');
*/
}

It appears it was also done in a patch here.

Since it worked, I put the module back on and tried to overcome the issue and deleted content of admin_menu_page_bottom() function at line 150 in admin_menu.module and this brought the website back online.

Is it okay to remove this function content? and why is this module still not functional? have anyone else managed to get this working on Drupal?
Is it okay to do this in Drupal 8 to unsintall admin_menu removal with above procedure and is there anything that I am missing?


texts: How can I make Apache Solr Autocomplete work in search Views?

texts:
I'm trying to work with Apache Solr search in my view and make this autocomplete.

Apache solr is configured correctly and I've added a solr view. I can search on fields, that's no problem. But how can I make the autocomplete work?


texts: How are the templates in the js_example module retrieved?

texts:
I installed js_example, one of the sample modules in the Examples for Developers module.

In this module I found the following configuration:

css
 - jsweights.js
js
 - black.js
 - blue.js
 - brown.js
 - green.js
 - js_example_accordion.js
 - purple.js
 - red.js
src
 Controller
  - JsExampleController
templates
 - accordion.html.twig
 - description.html.twig
js_example.info.yml
js_example.libraries.yml
js_example.links.menu.yml
js_example.module
js_example.routing.yml

I do not understand how the template description.html.twig and accordion.html.twig are retrieved.

I miss this piece to understand the example completely.

In which file do I find the configuration I am looking for?


texts: Is it possible to show Poll results as a table in Views?

texts:
I want to show the results of a Poll (core module) in Views.

However, the only way to show any Polls in Views is just as a full node (as they appear to a normal user).

I want to be able to display it as a table so that I can make it easily exportable to Excel (using the Views Export XLS module).

Any ideas?


texts: Commerce Allows User to Edit Cart After Completion of Checkout

texts:
I recently found a problem where a customer can edit their cart and re-checkout after checkout has been completed and payment has been made. This results in a single order record (the latter one) and two payments.

Re-creation of this issue:
1. Start a cart
2. Open the cart in a second window (You should have two windows/tabs open with the same cart)
3. Checkout on the first screen
4. Once checkout is completed and payment has been made, remove or update an item in your cart using the second screen

This places the cart back in a Shopping Cart status (per Drupal Commerce rules) and you have the same order/cart number since they share a table (which is another problem for another day). You can now checkout again and you will have two order confirmation emails with the same order number. Drupal Commerce will show only one order (the second order) but two payments. There is no way to recover the first order.

This only happens when the customer leaves the shopping cart open in multiple window(s) and tries to edit it after checkout.

Is there a fix to dis-allow editing of a cart after it changes over to an order? I would like it to throw an error and force a refresh of the page causing it to create a new shopping cart.


texts:
Problem

I'm trying to create multiple nodes at once using a CSV file for the data. However my script only creates the first 25 before it throws the following error. Any ideas what might be happening?

  PDOException: in drupal_write_record() (line 7166 of C:\XAMPP\htdocs\drupalie\includes\common.inc).

Set-Up

I have a custom form which creates the nodes on submit. The form just has a submit button.

This is the submit handler. I only have one column in my CSV sheet so I don't actually use the delimiter. First I generate an array with each node name.

  if (($handle = fopen("sites/all/modules/custom/generatenodes/nodes_database_import.csv", "r")) !== FALSE) {
    //open the CSV file
    $length = 1000;
    $delimiter = "|";
    //set the length and delimiter.
    while (!feof($handle)) {
      //$line is an array of the csv elements
      $node_name_array[] = fgetcsv($handle, $length, $delimiter);
    }

    fclose($handle);
  }

The array looks like this:

I then create the nodes:

global $user;
foreach ($node_name_array as $nodename) {
  if($nodename == FALSE) {
    return;
  }

    $values = array(
      'type' => 'school',
      'uid' => $user->uid,
      'status' => 1,
      'comment' => 0,
      'promote' => 0,
    );
    $entity = entity_create('node', $values);

    $ewrapper = entity_metadata_wrapper('node', $entity);

    $ewrapper->title->set($nodename['0']);
    $ewrapper->field_country->set($schoolname['0']);
     $ewrapper->save(true);
    entity_save('node', $entity);
}

But it breaks after the first 25 or so. What have I missed?

EDIT--

So I found the cause. It's to do with the values in my CSV file. Sometimes it likes them othertimes it doesn't. If I replace these values then it works up to the next broken value.

The first problem was a value with an accented e inside. Removing the accent fixed it.

Unfortunately the next two which broke it are not so obvious:

Putian Cambridge English
Zhangzhou Bilingual Middle School

Yet the following values work:

Quanzhou Foreign Language Middle School
International College of Xiamen University

I've only pasted in clean values, but something is breaking it. Any ideas?

Trying to navigate to the content page after causes MySQL to break. Here's the error log:

https://www.dropbox.com/s/jji3cw559filq03/mysqlcrash_log.txt


texts: Why is my image with URL that links to external site in a custom block not showing?

texts:
I made a custom block in header that houses the following html along with 4 more of the same html for different social media sites:

a href="https://socialmediasite.com" target="_blank"
img src="/images/socialmedialink1_icon_32x32.png" alt="Social Media link" style="width: 32px; height: 32px; border:0"
/a

The problems aren't the links because they do work. The problem is the images aren't showing up and only showing up as broken links so there's a problem with the img src link. I made a folder under root directory named images using my website hosting companies file manager and the images have been uploaded to that folder so I don't know what I'm missing. Am I missing something in the img src or something else before the a href or can it just not be done using only a custom block?


texts: Can't insert data to database on form submit

texts:
I am trying to insert some datas into database table on form submit like this:

function form_example_submit($form, &$form_state) {

    if ($form_state['values']['select']=='1') $gender = 'male';
    else $gender = 'female';

    db_insert('form_example_table')->fields(array(
      'name'    => $form_state['values']['name'],
      'gender'  => $gender,
      'message' => $form_state['values']['message'],

    ))->execute();

    drupal_set_message("Message is successfully saved");

    return $form;

}

My schema in .install file looks like this:

function form_example_schema() {

    $schema['form_example_table'] = array(
        'description' => 'Table for form_pokus module',
        'fields' => array(
            'id'        => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
            'name'      => array('type' => 'varchar','length' => 30,     'not null' => TRUE, 'default' => ''),
            'gender'    => array('type' => 'varchar','length' => 30,     'not null' => TRUE, 'default' => ''),
            'message'   => array('type' => 'text', 'not null' => TRUE,   'default'  => ''),
            'status'    => array('type' => 'text', 'not null' => FALSE ),
            'created'   => array('type' => 'int',  'not null' => TRUE,   'default'  => 0),
        ),

        'primary key' => array('id'),

    );

    return $schema;
}

But nothing happens on form submit, only page is reloaded. What I am mising?


texts:
I have created a variable to use in my twig template. The variable consists of a nested array. If I dump the variable I get the following result:

dump(gallery_images)
array (size=2)
  'img' =>
    array (size=15)
      0 => 'path-to-file.jpeg'
      1 => 'path-to-file.jpeg'
      .....
   'alt' =>
    array (size=15)
      0 => 'img 1 alt text'
      1 => 'img 2 alt text'

I want to loop through gallery_images and map the alt text to the image. My loop was working fine before I added the nested array / alt text. This is how I expected it to work:

{% for gallery_image in gallery_images %}

{% endfor %}

That did not work, then I tried to call the src and alt with

{{ gallery_image.0 }}
{{ gallery_image.1 }}

Then I only got 1 file and 1 alt text. What is the correct way to loop through the nested array? Also bear in mind I may want to add title text next.


texts: How do I attach some entity fields (or widgets?) to a form?

texts:
I am providing a form to a user to create a product.  I want to provide a few fields from a product type, along with some normal Form API input.  Example, I only want them to specify the price and SKU.  I want the submit handler to take care of creating the title name and any other fields.  In this case, a product lives as product entities and as product display nodes.  I want to present my user a single form to create and manage products.

I looks like I should be able to do this with the Field API, but I just see how to attached all fields from an entity.  I just want to attach a few.

Am I able to do this with the Field API?

EDIT TO ADD MORE INFO:

For example, when a user creates a new product, they will enter a 6 digit SKU.  Each product will have that SKU, with another 3 digits appended, specifying a category.  I want the user to simply enter the base SKU, like ABCDEF, select category Y and Z, and the submit handler creates the products with the correct SKUs, like ABCDEF-0001, ABCDEF-0002, and creates the node display.  There are also specific fields of the product type, so I need the user to populate the fields for these products, using the WYSIWYG filter they would otherwise use on the product create form.


texts:
I'm trying to create a subsite within our current drupal site. The v1 pass is all static HTML, but very soon, like as soon as I get v1 up I'm going to have to add in a few blocks for dynamic content.

I was wondering what the best way to structure this would be. We currently have a "chromeless-html-page" content type which i'm working with. But I wasn't sure if was the most efficient way as I would have to create a chromeless-page object for each page and then link them together. I was wondering would it make more sense to create a subsite-content-type that would be a view and then display all of those subsite-pages?

not sure if that makes sense or if i'm even on the right track with my question. I'm truly lost any help would be wonderful.


texts: Varnish/Drupal caching for logged in users

texts:
Problem

Varnish is caching pages when I go onto my website anonymously.

I have "Cache Pages for anonymous users" turned on so this is expected.

But when I login it continues to load the cached page for the pages I visited when I was logged out, so the user specific menu never shows and the login button continues to show even though I'm logged in.

I though Varnish didn't work for logged in users and I'm using the default drupal caching system which I thought didn't work for logged in users? How can I prevent this?

Server Set-Up

LEMP Stack - Ubuntu Server 12.04

APC + Memcached

Varnish

Drupal Caching Settings:

Cache pages for anonymous users -> enabled

Minimum cache lifetime -> 0

Expiration of cached pages -> 6 hours

Varnish Module Settings:

Varnish cache clearing: Drupal default

I installed Varnish using this guide and this Varnish config file: http://andrewdunkle.com/how-install-varnish-drupal-7

Browser Caching

I disabled browser caching in Firefox and I still get Varnish cache hits on my homepage however now the menu loads correctly. What does this imply?


texts: Importing Custom (Trumba ) RSS Feeds into Node

texts:
I'm working on a Drupal 7 college project that involve in importing the college calendar feeds into a calendar content type in Drupal. The RSS feed is coming Trumba - 25livepub-collegenet-com in the following format.

    <item>
        <title>Worship</title>
        <description>Christ Chapel &lt;br/&gt;Sunday, Januar</description>
        <link>http://www.gettysburg.edu/events/inde.....</link>
        <x-trumba:ealink>http://25livepub......</x-trumba:ealink>
        <category>2015/01/25 (Sun)</category>
        <pubDate>25 Jan 2015 16:00:00 GMT</pubDate>
        <guid isPermaLink="false">http://uid....8</guid>
    </item>
</channel>

I went to Feed Importers under Admin/Structure/Feeds and set up the Node processor as well as the Mapping for the Node processor using the following:

Source --------> Target

Title - - > Title
Published date - - > Published date
Categories     ---    ---> Event Category
Item GUID - - - -  > Item GUID
Item URL (link) - - > URL
Description - - - > Description

The nodes are imported into the calendar content type. The problem is everything except the Title is imported into the description field - making it difficult to differentiate them especially when the description is combine with the publish date, category etc etc. Can somebody please point me in right direction how to go about this. Thanks alot.


texts: How to connect different node bundles in one page

texts:
I am building a web site about football teams in Drupal 8 and I have the following content types Team, Player, Manager, Game etc. I would like to connect nodes from Player, Manager content types in the page of a Team.
So when viewing the Team page, below the Team nody/body I would like to have tabs with Manager node/body and Player node/body.
So, how is possible to connect nodes from different content types?


texts: How to transfer Userpoints between users?

texts:
I installed the User Points module (v7.x-1.0) and after going through all of the configuration I cannot seem to find the option for transferring Points between users.

Can someone point out how I find/activate this feature?


texts: Loading js file for all browsers except IE

texts:
I have a requirement to add a js file only for IE (6, 7, 8) browsers. The following script works fine and sometime it doesn't. I cleared the cache several times but has no difference.I don't know where I am going wrong . Is there anything to do with drupal_add_js for IE?

function mymodule_init() {
  if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
    $theme_path = drupal_get_path('theme', 'mythemename');
    $js_path = $theme_path . '/script/modernizr.js';
    drupal_add_js($js_path, 'external');
  }
}

// The code modified to true for all browsers it works for all browsers but not in IE
function mymodule_init() {
  if(1)) {
    $theme_path = drupal_get_path('theme', 'mythemename');
    $js_path = $theme_path . '/script/modernizr.js';
    drupal_add_js($js_path, 'external'); // loading in all browsers except IE
  }
}


texts: Where to find structure of objects that I can access in PHP snippets added to different parts of UI?

texts: In views I can add PHP snippets for custom validation or when I want to provide default value for contextual filter. It is telling me that I can use $view or $argument - but where is documentation of these objects? Where can I read what are my possibilities in these areas (or how check this, by using debugger for example)?


texts:
I'm using Drupal commons and I want to add new item next to View link, so I used hook_menu to create this.

function manage_child_menu() {
  $items['node/%node/demo'] = array (
    'title' => 'Demo',
    'page callback' => 'node_page_view',
    'page arguments' => array(1),
    'access callback' => 'manage_child_auction_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}

Well, it didn't work at all. Please help


texts: How to add existing product variations to a new product?

texts:
I have products with the same variation.
From product edit form I can only add new variation.
In variations field form setting i haven't "Allow users to add existing products."

how can i have this option or How can add existing variations?


texts: How can I aggregate information from about 30 Drupal sites in one place?

texts: I have about 30 websites on Drupal. I'm looking for module or service where i can aggregate information from all websites in one place. I need information about number of nodes, comments, users, Drupal core and modules versions. Something like acquia insight but for more sites and cheaper :)


texts: How to Add values to 'config' table and 'key_value' table when creating a new field in an existing table

texts:
I need to write a module that need to handle user related details.

I'm able to create the module and add the necessary database changes in 'users_field_data' table. By using db_add_field in hook_install()

db_add_field('users_field_data', 'user_office', array(
            'type' => 'varchar',
            'length' => 255,
            'not null' => FALSE,
        ));

But one thing I noticed when installing some other standard module from drupal, when a new field is added to the database it saves some values to 'config' table and 'key_value'table. But when I install the module it only insert the fields to 'users_field_data' table.

Is there a way that I add the values to 'config' table and 'key_value' table when creating a new field in an existing table.


texts: During updating translation: Fatal error: Maximum execution time of 240 seconds exceeded

texts:
I've tried to install a second language to my Drupal7 site. It can be done either by automatically or manually translation. I tried both but I got into the following issue at halftime:

  Maximum execution time of 240 seconds exceeded.

I tried to set higher values in php.ini:

default_socket_timeout = 240 (it was 60)
max_input_time = 360;
max_execution_time = 360;

I using local WAMP and Drupal7 installation. Port 8888.

I need help with configuration or another way to install it.


texts:
I'm creating a heavily customised website in Drupal. I want to use Views as a data source for a page with several options, where each option corresponds to a different display in a View. The reason I want to use Views is that they are easily configurable through a UI, so they are easy to tweak/change later if the need arises.

Unfortunately though, it seems like I can't create a display of a view that doesn't have some form of side effect (ie, a page display will create a new page). Does anyone have any bright ideas?


texts:
my Drupal 6 installation is on a MySql server, while my own custom database is on Oracle.
I have made a custom module that can read and write data into my external database, but i would like to use Views module to handle the data to show. I know that I can programmatically build views, but i don't know if I can build one for Oracle DB while Drupal is on Mysql.


texts:
I used profile2 module and create some profile types,in one of them I have a custom field require custom validation .
I did use drupal validation with custom validation function .
Lets suppose  I have a field with name  'nationalcode' if it was form element just need this in my custom module hook_form_alter(&$form,&$form_state)

$form['field_nationalcode']['#validation'][] = 'my_custom_validation_function';

And determine my_custom_validation_function function with my custom validation

function my_custom_validation_function(&$form,&$form_state) {
  if(!mycustomvalidation)
     form_set_error('field_nationalcode','my custom message');
        // I am not sure mayebe this one
     form_set_error('nationalcode','my custom message');
 }

But really what I should do in profile type cusotm validation?

I  set #validation  but How can i set form_set_error with profile type? .I means what i should  use in first parameter in form_set_error ?


texts: How do I integrate a custom filter inside a view

texts:
I am using entity browser to view my uploaded images. And now I want to integrate a new filter to the view. My objective is to filter the images from the URI path. Currently view has a field in Filter Criteria section in the view with a textfield to enter a part of a URI and filter. But I need to  filter the images with a custom dropdown which has only specific values in the URI.

Lets say my URIs looks as below.

s3://2019-01/image-set-one/image.jpg
s3://2019-01/image-set-two/image.jpg

I need to integrate a dropdown to the filter criteria of the view with elements image-set-one and image-set-two which will filter the images accordingly. I am using entity browser, so I need to add that field inside the view instead of getting the results and filter after.

This is a screen shot of the view that I am using.

Below is a preview of my entity browser that I am using with the above view.


texts: Check if Workbench Content Has Published Revision

texts:
We are using Rules for advanced Workbench notifications. However, we have a notification that needs to change depending on whether content actually has a previously published version or is entirely new content.

Does anyone know of a way, using  Rules, to check for whether Workbench content has a published revision? (Note: Not whether the current revision is published.)


texts: How to remove author name from blog post url?

texts:
When a user publishes a blog post the user's name is included as part of
the blog link or url:

  www.example.com/blogs/author/post-name

What I want is that:

  www.example.com/blogs/post-name

How can I remove that author name from the url?


texts:
Is it possible to create the functionality where, on creating a node, the user can tag friends to associate their friend with the node. Such as in Facebook's tag a friend in a post.

This would require a friends lookup field, which would imply that the users have already approved each other as friends (maybe using User Relationships).

So, the key thing is to provide a lookup field which searches the user's friend list, and also exposes itself to Views.

Ideally, the field would allow you to enter an email address if their friend isn't already on the site (probably asking too much, and could possibly make do with using the Invite module here).


texts: How to count the number of unique views of a node?

texts:
Is there any possible way to find the number of views of a node.

For example:

I have created a node called "Sample".

If i viewed it once then the count should be increased as 1 view and when i view the same node again it should not get increased.

Is there any module to do that..

Else what's the best way to do it ?


texts: How do I translate British English strings into US English?

texts:
I have created my own custom module. All of my outputted strings are wrapped in t functions. I have enabled Locale in core. I need to alter some of my module's strings and some field labels too, slightly, just a word here and there, form British English into US English.

What I'm trying to acheive is: if my site is being viewed in the US I want that to be automatically detected, and the adjusted strings/field labels displayed.

Thanks.

Solution: Install ip2country module. This provides a function called ip2country_get_country which returns an ISO 3166 two-character country code based on the user's IP address. Create a helper function that returns a boolean TRUE/FALSE is the country code is 'US'. Then just use if-else constructs to translate the required text.


texts: Reload only the content area of a website while the sidebars remain static

texts: Is it possible to reload only the content area of my website while the rest of the sidebars remain static? I notice that twitter does this, i am wondering if it is achievable in drupal. Thanks


texts: Import xml with Feeds from a folder outside site directory

texts:
I need to import data from multiple xml files. my site is in /var/www/sites/automationstats and the folder with the data is in subfolders of /var/lib/jenkins

If I use as directory in the import /var/lib, I get this error message: Directory needs to be a valid URI.

By the way, that folder (/var/lib) has owner and group jenkins. My first idea was to set that folder in the file system settings as private and then use private:// as URI but it says the folder is not writable.

So, is it possible to read from outside my site file structure or I have to get the files inside?


texts: Modify the date popup to only accept special days

texts:
I may need your help please. I have installed the "Date" module and using it with the date popup (datepicker). I need to have the popup just accepting Wednesdays and Fridays as dates.

Can anybody give me some help on this issue?

Thanks alot!


texts:
I have a site setup with Search API and Solr, everything is working as expected except for what I am trying to do with facets.

Each content type has tags using the tags vocabulary, I have created the facets for each content type, which works.  But what I am trying to have is a tag facet that isn't split into its content type.

What I want is so that users can narrow their search down seeing all content types with the tags they select, rather than having a facet tag list for each content type.

Does anyone know of a way to create this type of facet?


texts: How to access and edit files from admin panel?

texts: How i can acces my files without going to host control panel or by ftp. I mean if any module is for that to access and edit files from Admin panel.


texts: Drupal 7 Webform - Find input regardless of fieldset

texts:
I have created a webform hook (using hook_form_alter) which searches for a particularly named input and appends an ID for JS code to make changes on the front end.

It works fine however I have come across an issue where if that input is made part of a fieldset, it can no longer find it. This is to do with how the $form array is rearranged to include children inputs in the fieldset array.

My question is: how do I find an element by name regardless of whether it is part of a fieldset or not?

This is the code I'm using, which works fine for parent level inputs but not when it is part of a fieldset. How do I get this to work where I don't need to know what the fieldset is called (because I won't always know).

function MODULE_form_alter(&$form, &$form_state, $form_id){
  $form['submitted']["certain_name"]['#default_value'] = '';
  $form['submitted']["certain_name"]['#attributes']['id'] = 'new-id';
  $form['submitted']["certain_name"]['#ajax'] = array(
    'event'    => 'change',
    'callback' => 'module_js_lookup(this.value)'
  );
}


texts:
I would like to store meta data about users.

At first this I tried by adding fields to the user, but this is not exactly what I want, because the user himself should not be able to manipulate or view the data.

The data I want to store is based on actions a users takes in the application. Its is similar to a status which I want to write and read programmatically. E.g. has the users phone number been validated by the system?

What is the best way to store such data?


texts: Twitter module Oauth 'TwitterException' with message 'Unauthorized'

texts:
When trying to authenticate a Twitter account using the Twitter and OAuth modules, I get the following error

  Could not obtain a valid token from the Twitter API. Please review the configuration.

I have since found that The following error is recorded in Watchdog

  exception 'TwitterException' with message 'Unauthorized' in /var/www/html/sitex/public/sites/all/modules/twitter/twitter.lib.php:151 Stack trace: #0 /var/www/html/sitex/public/sites/all/modules/twitter/twitter.lib.php(114): Twitter->request('https://api.twi...') #1 /var/www/html/sitex/public/sites/all/modules/twitter/twitter.lib.php(51): Twitter->auth_request('https://api.twi...', Array) #2 /var/www/html/sitex/public/sites/all/modules/twitter/twitter.pages.inc(343): Twitter->get_request_token()

  [Abridged]

Having checked out the URL which is generated and sent off by drupal_http_request I get the following error message

  Failed to validate oauth signature and token

I have checked the following

Followed https://drupal.org/node/1346824
Reinstalled both the Twitter and OAuth modules
Ensured my OAuth Consumer key is correct
Ensured my OAuth Consumer secret is correct
Ensured I have Read & Write permissions
Ensured my server time is within 5 minutes of Twitter's as per this thread
Ensured my server is running extension=php_openssl.dll
Ensured my callback URL is correct - http://mywebsite.com/twitter/oauth

Note that I am not on localhost, nor is my host behind .htaccess

Visiting my callback URL results in the following error at /admin/config/services/twitter

  The connection to Twitter failed. Please try again.

I am not on localhost, but have tried the suggested 127.0.0.1 callback URL regardless.
I do a version compatible/containing "Patch 5" as mentioned here
I'm using the following versions of the modules

Twitter 7.x-6.0-alpha2+1-dev (But have tried 7.x-5.8 too)
OAuth 7.x-3.1
Core 7.22

I haven't enabled the following- Do I need to?

OAuth Provider UI
Twitter actions
Twitter Post
Twitter Signin

I'd appreciate it if anyoneis able to provide insight!

Thanks


texts: How to display node in popup using modal_forms module

texts:
Using Modal Forms module I want to popup node content without header and footer.

I am getting many links explaining using  Lightbox2 but not with modal_forms.


texts: How to force cron to use config saved during a SimpleTest?

texts:
I write a test using Drupal\simpletest\WebTestBase for a custom module, which implements hook_cron(). The test saves a configuration object, which should be used by the cron, and then runs the cron:

function testCron()
{
    $config = \Drupal::service('config.factory')->getEditable('mymodule.settings');
    $config
      ->set('some_setting', 'some value')
      ->set('another_setting', 'another value');
    \Drupal::service('cron')->run();
}

The settings are saved and can be used during the test. But when I want to use them in the cron (in mymodule.module):

/**
 * Implements hook_cron().
 */
function mymodule_cron()
{
    $config = \Drupal::config('mymodule.settings');
    ...
}

then instead of the saved values, the default settings from config/import/mymodule.settings.yml are used.

How can I force the cron to use the settings saved in the test?


texts: Help with content structure of a typical art gallery website

texts:
As a way of learning a bit more about how Drupal 7 works, I'm trying to replicate the features of a local art gallery website. I'm having a few problems setting up the content types so I was hoping someone could point me in the right direction. I want to get all the content correctly configured and stored so I can then play around with Views and different ways of presenting that content. Here's what I've come up with having broken down the different types of data:

ARTIST will have one name, a bio and a website
ARTWORK will be associated with one artist only, will have a title, may or may not belong to a SERIES, will also have dimensions, an image, a year of creation, and will have the material used to create the artwork (term reference to a taxonomy vocabulary with terms such as "oil on canvas", "photograph", "mixed media" etc)
SERIES will be associated with one artist only.

So I've set up my content types. Well, the Artist and Artwork ones anyway, but how do I link them? I think I'm supposed to set up Artist as a taxonomy vocabulary, and list the Artist names as terms, and then when creating the content type Artwork have a term reference to it. This is OK but I don't want to have to manually add the term to the vocabulary each time a new content type Artist is created. So I guess what I'm asking is two questions:

Is my approach completely wrong? If so, please guide me in the correct direction!
If it's not wrong, is there some way to automatically generate the terms of the vocabulary Artist based on the Artist name? So when new Artist content is created, the term is automatically added?


texts:
I am having trouble creating/registering custom templates in a module and overriding them in a theme. For example, I have this in my_module_theme():

$theme['contact-page'] = array(
    'render element' => 'content',
    'template' => 'contact-page',
    'path' => drupal_get_path('module', 'my_module') . '/templates',
    'variables' => array('form' => NULL),
);

This will correctly pick up the template (contact-page.tpl.php) located in modules/my_module/templates as expected. However, if I try to override this template in themes/my_theme/templates it will not be detected.

Furthermore, the advice from some similar questions I have found researching this topic says to use underscores when invoking hook_theme, as such:

$theme['contact_page'] = array(
    'render element' => 'content',
    'template' => 'contact-page',
    'path' => drupal_get_path('module', 'my_module') . '/templates',
    'variables' => array('form' => NULL),
);

When I do this the template (contact-page.tpl.php) is not read at all from either location (modules/my_module/templates or themes/my_theme/templates). In reports->recent log messages I see that Drupal is looking in the right place but cannot find the template for some reason.

Note: I am also rebuilding the theme registry on each page load.


texts:
I upgraded my drupal site from drupal 6 to drupal 7, and imported the image cache presets to image style.

When I checked in the styles folder of drupal files, no images where created with the effects of image style module.

I change the cck image field of a content type under "Manage Display", and have set the option to of Image style to "tiny" which is Image style I have defined (scale:100px).

Yet when I try to access the node, Images with big sizes gets loaded along with the content.

I am still struggling to find a way to display cck image field to show images having the respective Image Style to it.

Also I am running the site in windows xampp.


texts: Cannot call function leftJoin on a SelectQuery object?

texts:
$query = db_select('drupal5users', 'udf');
$query->leftJoin('drupal5users_roles', 'ur');
$query->fields('udf', array('uid','name','pass','mail','created','access','login','status','language','init'));
$query->fields('ur', array('rid'));

The above gives me the following error:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') subquery' at line 1.

If I comment out $query->leftJoin and the second $query->fields line, it works, so the problem lies with leftJoin. What am I doing wrong here?


texts:
I want cached a controller that returns a json..
I try this:

$build = array(
  '#cache' => array(
    'contexts' => ['ip'],
  ),
);
return (new CacheableJsonResponse(['test'], 200))->addCacheableDependency(CacheableMetadata::createFromRenderArray($build));

But i get an exception:

LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\Core\Cache\CacheableJsonResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (line 154 of /Applications/MAMP/htdocs/finder-cms/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).


texts: How to put two form elements in a row using Drupal Form API?

texts:
I am creating a form in Drupal 6 using form API.

I need to put a textfield and a select next to each other. they are for entering something like 'www.domainname.com' . www. is fixed. domainname section is given from user in a textfield and .com section is chosen from select element by user.

So they should be in a line. but as I see I can put these two form elements in a line, they are in their div container.

Would you help me? Thank you.


texts:
I have a View (let's call it A) that gets the 4 more recent nodes of type News. The News node has a boolean field called IsImportantNews. Since I render the most recent important News (IsImportanNews = true) in another View (B), I'd like to filter out from View A the most recent important News that I already shown in View B.

Eg:

News1 -> date: 02 Mar 2013, IsImportant = false
News2 -> date: 01 Mar 2013, IsImportant = false
News3 -> date: 25 Feb 2013, IsImportant = true
News4 -> date: 21 Feb 2013, IsImportant = false
News5 -> date: 19 Feb 2013, IsImportant = true
News6 -> date: 11 Feb 2013, IsImportant = true

I'd like to show the News3 in the View B (and I can do that easily).
I'd like to show News1/2/4/5 in the View A, somewhat filtering out the News3.

Is there a way to do that? I thought about taking the 5 more recent News and than apply some php code to filter out the unwanted News but I can't seem to find a place to put that code without writing a new module. Is there another way to do that?


texts:
I have a hook_menu in my module.

Artwork is a content type.

$items['galleryguide/artwork/new'] = array(
  'title' => t('Add new Artwork'),
  'page callback' => 'galleryguide_admin_artwork_new',
  'access arguments' => array('access content'),
  'type' => MENU_CALLBACK,
  'file' => 'galleryguide_admin.artwork.inc'
);

And I have hook_theme

function galleryguide_admin_theme($existing, $type, $theme, $path) {
  return array(
    'artwork_form' => array(
      'template' => 'artwork_form',
      'arguments' => array('form' => NULL),
      'render element' => 'form',
    ),
  );
}

In .inc I do:

function galleryguide_admin_artwork_new() {
  return drupal_get_form('galleryguide_admin_artwork_form_new');
}

function galleryguide_admin_artwork_form_new() {
  module_load_include('inc', 'node', 'node.pages');
  $form = node_add('artwork');
  $form['#theme'] = array('artwork_form');
  return $form;
}

Then in my template, artwork_form.tpl.php, I put

print drupal_render_children($form);

Everything renders fine, but I have an image upload file field and it does not work. It selects an image and then after I press upload it does not show any prevew and does not upload image
If I try to add node reference field I see system/ajax 500 error and nothing on frontend.

Same with all cck with widgets

Also file upload adds ajax-new-content span with empty inner html

Using same theme, and admin.

Can anyone tell me what can be the reason of that?


texts: How do I set a value based upon other values?

texts:
I have a content type of product, and want to set the postage cost for the item which is dependent upon length,width,height, weight but also product kind - e.g. hazardous items needing special courier etc. I have a series of prices for the various weights and size limits, so I'm wondering how can I utilise these prices for the postage field automatically.

At the moment, the prices aren't inserted in Drupal, would these prices be better as a separate content-type or as fields inside a courier content-type? If the latter would they be as easy to reference?

This is not for a commerce site, merely somewhere to manage all my stock from all the various suppliers - a product information manager.


texts:
I m using field collection items in my content type for particular upload function.

I want to use import excel feature to bulk upload with field collection item fields.

when i click on import excel upload button the field collection fields filled with excel data.

Can anyone help me, how to achieve this feature.

Thanks in advance.


texts: After save empty cache of referenced node

texts:
I have two content types. For clearer question I will work with the content types event and location.

From my location content type I can reference to and event.

Then on the event page I show the location that is connected to this event. I do this by creating a Views Block. This views block is showing content of the type location with a contextual filter to only show content with the Content ID from url.

This works fine. But there are events that don't have a location. On these events page I have a button saying add location. I do this with the following Twig Tweak:

{% if drupal_view_result('view-name', 'location-block') is empty %}
    Add location
{% else %}
    {{ drupal_view('view-name', 'location-block') }}
{% endif %}

This also works. But when I am on a event page and click the add location button I can add the location. When I go back to the same event page I was before I still see the add location button. Because the page is cached.

Is there a way to empty the cache of this event page after saving the location that is refering to the event? Or is there a other way to deal with this?

I tried if the problem was in the views cache but it wasn't turning it off for the block or removing only the views cache didn't work.

Thanks in advance


texts: Can you force users to put all new content in at least one Organic Group?

texts:
In Drupal 6, I would like to make sure users always add their Group content nodes to at least one Organic Group. I have a module that enforces a maximum number of groups, but I don't think it does a minimum.

The site is entirely groups-based and I don't really want people posting outside of a group.

I could certainly write a module for this if one does not exist, or it might be as simple as a form_alter() function.


texts: Dates display incorrectly on node display after programmatic creation

texts:
Problem

I have a form where users can create a node by filling in a number of fields. It creates a node using the Entity Metadata Wrapper as shown here.

I have two date fields on this form, however whatever value is selected for the date on the form, today's date will be shown on viewing the newly created node.

If you then edit the node, the correct date appears and on saving the node the correct date re-appears. (Opening the node isn't enough, you have to save it.)

Has anyone solved this? Any idea what might have caused it?

Example Code

I checked through every step of the Start date part of the entity wrapper (using dpm).

The correct date ends up in $entity, but for some reason it's still displayed incorrectly if you don't open the node. (It reminds me of this other problem I had with the wrapper.)

function createanode_form($form, &$form_state){

  $form['field_start_date'] = array(
    '#type' => 'date_popup',
    '#title' => t('Start Date'),
    '#date_format' => 'd/m/Y',
    '#default_value' => NULL,
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#weight' => 70,
  );

function createanode_form_submit($form, &$form_state) {

  $values = array(
    'type' => 'job_advert',
    'uid' => $user->uid,
    'status' => 1,
    'comment' => 1,
    'promote' => 0,
  );
  $entity = entity_create('node', $values);

  $ewrapper = entity_metadata_wrapper('node', $entity);

  $ewrapper->title->set($form_state['values']['title']);
  $ewrapper->body->set(array('value' => $my_body_content));
  $ewrapper->body->summary->set('Things that interest me');

  if ($form_state['values']['field_start_date'] != NULL) {
    $job_date = new DateTime($form_state['values']['field_start_date']);
      $entity->field_start_date[LANGUAGE_NONE][0] = array(
         'value' => date_format($job_date, 'Y-m-d'),
         'timezone' => 'UTC',
         'timezone_db' => 'UTC',
      );
  }

  entity_save('node', $entity);
}


texts: Creating new bulk views operations (VBO) actions for custom entity types

texts:
I have the following code and created a view for my custom entity type. I just want to create a new action button to be able to change a field's text to something else. I'm not sure why this custom action isn't showing up. Under which window am I suppose to see it? Execute arbitary php or modify multiple entity values?

Where is a good example code of getting a custom action working? Is there a pre-built VBO action example I can just download to see how it's made?

/**
 * Implements hook_action_info().
 */
function rubik_custom_action_info() {
  return array(
    'hideit' => array(
      'type' => 'entity',
      'label' => t('Custom Action'),
      'configurable' => FALSE,
      'triggers' => array('any'),
      'behavior' => array('changes_property'),
      'vbo_configurable' => FALSE,
      'pass rows' => TRUE,
    ),
  );
}

/**
 * Action function for MY_ACTION_NAME.
 */
function hideit(&$entity, $context = array()) {
  drupal_set_message('ok it works');
}


texts:
I've installed a contrib module in Drupal 7 and would like to hook into it.  However, the documentation for the contrib module is sparse and doesn't list the available hooks, though it implies that there are some.

Is there a standard "Drupal way" of seeing what hooks a contrib module exposes?

(I've deliberately not mentioned which module this is as I'd like a generic answer if one exists.)


texts: Why does email attachment fail on rescheduled rule?

texts:
I have an action set component that takes a "date" param and does the following:

"Add Variable" saves a path string based on the date.
"Execute custom PHP code" saves some data to the path created above.
"Send HTML mail to all users of a role" sends an email with the above file attached.
"Schedule component evaluation" repeats the component at time +2 minutes and sends date parameter +2 minutes.

If I execute the component, the file is created and the email is sent with the attachment as intended. But when the rescheduled component executes again, the correct file is created on the server and the email is sent, but the attachment is not there.


texts: webform: redirect to modified result page

texts:
After somebody submits a webform, he should be redirected to the "webform
result" (which is standard generated, but only accessible by clicking the
"webform results" tab as an admin).
My module needs to hook into the "webform results", and add some simple custom PHP
calculations on top of that "webform result" (for example: if two
radio-elements have a certain value, a warning is displayed on top of that
result page)

Any ideas ?

cheers


texts: How to use this Message Module with Services Module?

texts:
Can anyone tell me how to use Message and Services module to create REST API? Is there any other module I need to install to make it work?

I am not sure but may be Services Entity API module will work for me?


texts: Write anything as an author name on an article

texts:
I need to make it so the author field when making an article doesn't reference actual users. Is this possible without clunky workarounds? The problem is I often have articles posted that aren't posted by an actual user, but their names still need to be credited.

How do I do this in Drupal 7?


texts: Look up nodes that reference a given node

texts:
I'm using the references module (not grounded to it, but it seems to work well enough) however I don't know how in a custom PHP block/etc I would be able to do a query that can look up all the nodes of a given type that reference the current node.

What sort of query would accomplish this?

For just looking up by type I've used this previously:

<?php
    foreach(node_load_multiple(array(), array('type' => 'homepage_image')) as $node){
    //code
    }
 ?>


texts: How can I set a reminder for a specific user to be triggered on a specific date?

texts:
How can I set a reminder for a specific user to be triggered on a specific date (in a Drupal 7 site)?

Example: I want to remind the user regarding particular event such as hepB vaccination day.

Any suggestions?


texts:
I want to create field with name img for content type announcement

From the documentation, I can type drush field-create announcement. After that typing the field name img, after that type 2, lastly type 1.

Is there any ways achieving this through one line command?


texts: How to hide child field collection using jquery

texts:
I have 3 field collection 1st is parent in that having other 2 is child field collections.

parent FC: Student Info
child FC 1: English Info
child FC 1: Maths Info

Set field setting "unlimited" to parent field collection(i.e Student Info).

Now I want hide 2 child field collection (i.e English Info and Maths Info) on click of "Add another item"
I have hide child FC using jquery

For exmaple:

jQuery('.child1').hide();

jQuery('.child2').hide();

Child field collection hide initially, but if I click "Add another item" button then jquery removed and child FC shows. I have tried to bind click event in jquery but it's not working.


texts: Is there a module or technique to display blocks or panels based on device width?

texts:
We have our ads set up as blocks or panels and we would like to prevent wide ads from rendering on narrow (mobile) devices. Additionally, we would like to render other ads only on wide (desktop) devices.

I'm new to drupal and new to the website in question, and I'm having trouble finding where the actual ad calls are made, so I figured the best solution would be to handle this at the block/panel level.

To be clear, I am trying to prevent the ads from even rendering, not just trying to hide them from view once rendered.


texts: DB queries fast, Apache response slow, high PHP CPU

texts:
Working with D6, trying to get a page running more efficiently. I made a lot of progress by installing the Cache Backport module and configuring Redis, so devel shows my DB queries are a fraction of what they were before. Load testing shows that the site can handle a much heavier load than ever. Making progress.

The problem now is that the initial connection to the site is slow, usually 2-3 seconds but often as high as 5 or 6. It's not the database doing it, Devel shows queries are very fast, less than 500 ms on average. It seems to be pretty random. I'm working off a test server right now, I'm the only one on it, but I know it's not just me because any tests with external services show the same thing. My log files are clean, both Apache and syslog. The only other symptom I've seen is that prior to the page's load, PHP will spawn 6 processes and CPU will be high.

I've tried using XDebug to trace PHP's behavior but nothing is jumping out at me. It's definitely loading a few different files, including the Domain module, but I can't really tell what's happening.

I'm using fcgi, Debian 7, Apache is using mpm-worker, if that matters at all.


texts:
trying to create a groupon-deal style 'time left to buy' field, a dynamic countdown field.

Any modules can do this?


texts: How do I automatically do an SQL insert when creating a new node?

texts:
When creating a new node of a certain type, I want an SQL insert to be made at the same time.
The insert operation needs to use the node ID from the node just created, such as INSERT INTO my_own_db (nid) VALUES ('last inserted node id').


texts: Unknown column errors because of table alias

texts:
Because of truncated identifiers with more than 63 chars, causing Views to break

It causes errors like

  SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'taxonomy_term_data_node__draggableviews_structure_weight_coalesce' in
  'order clause'

Goal: I want to change the table alias from _draggableviews_structure_ to _dv_

If I change

    $data['draggableviews_structure']['weight'] = array(
      'title' => t('Weight'),
      'group' => t('Draggableviews'),
      'field' => array(
        'help' => t('Display the weight value.'),
        'handler' => 'views_handler_field_numeric',
        'click sortable' => TRUE,
      ),
      'sort' => array(
        'help' => t('Sort entities by the draggableviews weight table field.'),
        'handler' => 'draggableviews_handler_sort',
      ),
    );

    $data['draggableviews_structure']['parent'] = array(
      'title' => t('Parent'),
      'help' => t('The parent entity id.'),
      'group' => t('Draggableviews'),
      'field' => array(
        'handler' => 'views_handler_field_numeric',
      ),
    );

  // Explain to every entity how to join with draggableviews structure table.
    $data['draggableviews_structure']['table']['join'][$info['base table']] = array(
      'handler' => 'draggableviews_join_handler',
      'left_table' => $info['base table'], // Because this is a direct link it could be left out.
      'left_field' => $info['entity keys']['id'],
      'field' => 'entity_id',
    );

to

   $data['dv']['weight'] = array(
     'title' => t('Weight'),
     'group' => t('Draggableviews'),
     'field' => array(
       'help' => t('Display the weight value.'),
       'handler' => 'views_handler_field_numeric',
       'click sortable' => TRUE,
     ),
     'sort' => array(
       'help' => t('Sort entities by the draggableviews weight table field.'),
       'handler' => 'draggableviews_handler_sort',
     ),
   );

   $data['dv']['parent'] = array(
     'title' => t('Parent'),
     'help' => t('The parent entity id.'),
     'group' => t('Draggableviews'),
     'field' => array(
       'handler' => 'views_handler_field_numeric',
     ),
   );

   // Explain to every entity how to join with draggableviews structure table.
   $data['dv']['table']['join'][$info['base table']] = array(
     'handler' => 'draggableviews_join_handler',
     'table' => 'draggableviews_structure',
     'left_table' => $info['base table'], // Because this is a direct link it could be left out.
     'left_field' => $info['entity keys']['id'],
     'field' => 'entity_id',
   );

This works. However, all of the views with draggableviews fields/sort components have disappeared. In the admin view, views complains able missing relationship, and it trying to fix them for you. If you read the fields, the view works again.

Is there a way to fix this, without manually changing everything? Is there a better way to solve it?


texts: Any particular vacuum policy to increase performance using Drupal with PostgreSQL?

texts: I'm running Drupal 7 with PostgreSQL as a Q&A (with a lot of nodes inserts/updates and several contrib modules). Do you recommand any particular pgsql vacuum policy on particular tables ?


texts: What is the recommended way to load a dev version of a library locally and production version on production on Drupal 8

texts:
For example with Vue.js on dev (local development) I would like to load the dev version like this:

vue:
  version: VERSION
  js:
    /libraries/vue/dist/vue.js: {}
  dependencies:
   - core/jquery

But on production, I would like to have it load like this (minified production version):

vue:
  version: VERSION
  js:
    /libraries/vue/dist/vue.min.js: {}
  dependencies:
   - core/jquery

What is the best way to handle this?


texts: Where do I make a feature request to drupal.org?

texts:
What is the best place to make a feature request about the drupal.org website?

I probably spent an hour searching.  There is/was the redesign project, there is the drupal.org issue queue but I was refused access.

FYI - I'd simply like to suggest that project owners have a tab for "roadmap" or "project Future".  Sure, the summary page can include that but often it is crammed with things and maintainers forget to talk about what plans they have, what they need, etc.


texts: How to use replacment patterns in "no results behaviour"

texts:
I would like to define "no results behaviour" for an image field in a view. For this, I need to obtain the dimensions of the image that would be placed there if it existed.

Below the "no results text", it says:

  You may enter data from this view as per the "Replacement patterns" in the "Rewrite Results" section below.

In the "Replacement patterns", there is the entry:

  [field_news_images-width] == Raw width

However if I for instance set the "no results text" to Width: [field_news_images-width], the output is just Width: instead of the expected Width: 70.

Is there anything else which has to be enabled such that the replacement patterns work here?


texts: Drupal gives error to admin, anonymous users can browse pages

texts: Anonymous users can browse various pages, when logged in, it gives "The website encountered an unexpected error. Please try again later". I am using drupal 7 commerce. Before this error I installed drupal example modules and drupal commerce example modules.  THe image is attached which shows the errors.


texts: What does the outbound path processor do?

texts:
In some PathProcessor classes there is a processOutbound method which is from the OutboundPathProcessorInterface. The API for that method simply says:

  Processes the outbound path.

What is the outbound path? What is it for? What does it do?


texts: How to let public access to the sitemap page?

texts:
I am using the Site map module that creates a page called sitemap. However, I cannot access it if I am not logged in, as the access is denied for that page for the anonymous users.

How can I let public access to the sitemap page?


texts: How to NOT share content between multi sites?

texts:
Try as I might cannot stop all changes in one sub site copying to other. They have two separate databases and settings files and conf files but because of necessary symlink to share core code base , everything else is being shared right along with it.

How can I stop this sharing everything between subsites when drupal core is in first subsite and symlinked to second?

Why is it even happening when have two sep db set up and two sep settings.php?

I don't want changes to be made to subsite2 when I make changes to subsite1 and vice versa as is happening now.

mysite.com (static html) in /var/www/html

sub1.mysite.com  (drupal install) pointing to mysite.com/sub1

/var/www/html/sub1/sites/sub2

sub2.mysite.com (symlink to sub1 in html folder) pointing to mysite.com/sub2(symlink vs)

No necessity to add sites.php or even change httpd or conf file with symlink.

My theory is you must have drupal core files in html folder not a subdir linked to subdomain below it. I will test tomorrow.

No I think I need to just know what to put as base url in conf file? Do I direct it to html/mysub.site.com  or to html/sub1/sites/mysub.site.com ?


texts: What are the URLs for devel generated images in CCK fields?

texts: I generated a few nodes with Devel. When I do a krumo($node), the CCK field consisting of an image, does not have a filename. $field_name['und'][0][filename] is a string of 0 characters. I only get this: $field_name['und'][0]['uri'] = public:///garbledImageName.tmp.png. How do I use this? What function does Drupal use, to convert this public:/// URI into a complete image path? And in the future, can I count on custom created modules to also have the 'uri' value?


texts: How do I programmatically set the default value of an exposed filter?

texts:
I seen many answers for Drupal 7, but I can't find any information for Drupal 9.
In hook_form_alter(), $form['field_assigned_location_target_id']['#default_value'] = '553'; doesn't alter the default value for an exposed filter, which uses the value in the settings.
$form['field_assigned_location_target_id']['#value'] = '553'; changes
the value initially displayed on the filter, but it's the value submitted from the exposed filter form, independently from the value the users want to submit.


texts: How to condition output based on a URL query string

texts:
In my node preprocess function I check the value of a query param...

$variables['exclude_urls'] = \Drupal::request()->get('exclude_urls');

And in my template, I have...

{% if not exclude_urls %}

{{ url }}

{% endif %}

However, this approach doesn't work because the node preprocess function does not fire if nothing in the URL changes besides the value for the 'exclude_urls' param.

I have tried various methods to disable caching for the page.  Adding this to the route doesn't work...

  options:
    no_cache: 'TRUE'

I also tried using the page_cache_kill_switch in my controller, but it doesn't work...

\Drupal::service("page_cache_kill_switch")->trigger();

Neither does adding the query parameter to cache contexts...

$element['#cache']['contexts'][] = 'url.query_args:exclude_urls';

Instead of using hook_preprocess_node, is there some other way I should be checking the value of $_GET['exclude_urls'] and passing that to the template?  Do I add code to the twig template itself to check the value of 'exclude_urls'?  Is there any sure way to force hook_preprocess_node to fire every time?  What is the usual approach to conditioning display of content based on a URL query param so that caching won't interfere?

Update:  To be clear, I have also tried the above approaches in combination, with no success.  For example, the end of my page function in my controller looks like this...

\Drupal::service("page_cache_kill_switch")->trigger();
$element['#cache']['contexts'][] = 'url.query_args:exclude_urls';
return $element;

Update 2: In my local dev site, I do not experience this problem, and I've found that this line in my local settings makes it so hook_preprocess_node fires every time...

$settings['cache']['bins']['render'] = 'cache.backend.null';

However, I'm not sure how to take advantage of this in my production site, since I don't want to disable the render cache generally.  I can do something like this in settings.php, but it's a hack:

$parts = explode('?', $_SERVER['REQUEST_URI'], 2);
if ('/disable/cache/at/this/path' == $parts[0]) {
  $settings['cache']['bins']['render'] = 'cache.backend.null';
}


texts: Version of Drupal is no longer supported [Using the latest 7.42 release]. After automatic update

texts:
I use Drupal with Commerce Kickstarter profile installed. After automatic update from Installatron in my Direct Panel i get an error of unsupported Drupal Core version:

There's no way to make update using Drush or Installatron from that state.

The only way to make it work, that I have found, is to revert to the backup before update. Can anyone help me to understand what's happening, and why  Installatron updates to the 7.42 version (7.41 -> 7.42) while Drupal Report state of 7.41 v. states that it is up-to-date?


texts: Deny full node access for anonymous users

texts:
I know it's possible to deny access for the whole node, but I need it only for the full view, so anonymous users can see the teaser; when they access the node, they will get a 403 error. Is it possible?

I've tried premium content modules, but this is not what I want.


texts: Getting the node object in hook_form_FORM_ID_alter

texts:
Follow up to this question  but I don't have enough reputation to ask clarification in a comment.

I am porting a contributed module to Drupal 8.
The sugested code on the above mentioned CR and post is not working:

$node = $form_state->getFormObject()->getEntity();

Nothing is loaded into the $node variable.

My PHPStorm IDE gives a warning for getEntity():
Method 'getEntity' not found in class Drupal\Core\Form\FormInterface less...
Referenced method is not found in subject class.

It is also not presenting this method for code completion.

In the use cause I am referencing:

use Drupal\Core\Entity;
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\Entity\Node;
use Drupal\Core\Render\Element;


texts: Issues with manual update from 7.77 to 7.78 on cPanel with PHP 7.4

texts:
I have been manually been doing Drupal 7 and 8 updates on cPanel for many years. I carefully read what files need to be updated and what files need to stay.
Recently, there was an update to PHP 7.4. I cannot anymore manually update using Filezilla. I only get a generic server error, which doesn't say exactly what happened.
Has something changed in Drupal to cause this to happen? I really do not think it is a cPanel's issue.


texts: How to make a text field box appear after clicking select option by using ajax?

texts:
I have created a content type and with a field which is a select type and the options is:

Text
Text area
File

Now, when I select text area option, then a text area box have to appear below the select field and same for text option also. And if a select file option, then a button should appear after the select field for file functionality. I heard this can be done by ajax, but don't know where to start and how to do it.


texts: Importing Nodes to D7 with all custom fields

texts:
I've got a Drupal site with an obscene about of content that has been given to me in CSV format. I'm toying with the idea of building a module to let me do this but if there's one already out there that I can use to just get this site out of the way that would be awesome.

My question is: Is there anything out there that allows you to import a CSV file into D7 that will populate the node table and all the custom fields tables as well?

Thanks.


texts:
I have a programmatical plugin block defined in theme region. I need to check access to this block in my module hook. The following code creates a new instance, but I need to load an existing plugin block from the theme with its custom visibility settings and find out if it is going to be displayed or not.

$block_manager = \Drupal::service('plugin.manager.block');
$config = [];
$plugin_block = $block_manager->createInstance('system_breadcrumb_block', $config);
$access_result = $plugin_block->access(\Drupal::currentUser());

Please advise.


texts: Notify user if they are about to delete a node that is referenced by another node

texts:
Is there a way to notify a user when they are about to delete a node that is linked to by another node?

I'm working on a site where many of the pages reference another and I would like to put some mechanism in place where the user is notified before taking action.


texts: I am trying to add multiple pages to my home page (about, contact), I assumed I do this in page--front.tpl. How to I call or pull in page nodes into my template?


texts: Drupal 8 styling part of form field title

texts:
i have form api element, in which i need to style only a part of it via a given tag

 $form['title'] = array(
  '#type' => 'textfield',
  '#title' => '
"'.t('how much   quantity').''.t('...please specify').'
',
  '#required' => TRUE,
);

the part in span tag, is differently styled.
But the problem is, when i run drupal validation on this, the whole title along with tags comes in the message.


texts:
in drupal 7 we could use kpr() from devel module or php print_r() and var_dump() functions to print $node object in node.tpl file or hook preprocess node in purpose of debugging and finding a field or ..

but in drupal 8 we can't use php functions in twig and I tried kint() and dump() to print node in twig but no success. ( I've already set debug: true in services.yml ) ( more detail: kint(node) in twig file makes an infinite loop and causes memory size exhausted in browser).

so the question is how to print node object in drupal 8 using twig or hook preprocess node?

more details:

I have custom twig template for article: node--article.html.twig and the content is like:

    {{ content.body|render }} {# this works #}

    {{ kint(node.field_custom.value) }} {# prints the custom field value without any problem #}
    {{ kint(node) }} {# this causes infinite loop and memory issue #}
    {{ content }} {# prints all content fields without any problem #}
    {{ kint(content) }} {# nothing happen or display with this! #}
    {{ kint(label) }} {# infinite like node #}


texts: Drupal 7: use Form API to make a button that doesn't submit the whole page

texts:
I want a button that runs a callback function using the AJAX method included in Form API.
The button I have still submits the whole node edit form. I don't want it to do that - just pass a couple variables to the callback function and display the results. How can I do that?

This is my FAPI code for that button:

    $form['rid_import']['rid_get'] = array(
                '#type' => 'button',
                '#value' => t('Import'),
                '#attributes' => array(
                    'id' => array('fetch_rid'),
                    'class' => array('col-sm-3', 'col-xs-4')
                ),
                '#parents' => array('rid_import'),
                '#limit_validation_errors' => array(),
                '#executes_submit_callback' => false,
                "#submit" => array('sql_no_submit'),
                '#ajax' => array(
                    "callback" => 'sql_fetch_restid',
                    "wrapper" => 'rid_sql_query',
                    "event" => 'click'
                )
          );

EDIT

You're right, I was being unclear. Basically what I wanted is something that works like your "Add More" or "Remove" buttons when you have multiple-value fields, but just to run my function without reloading the page – grab some data from the DB and show it there on the node edit form. I have a multivalue field collection that should be populated with those values and then saved together with the rest of the node. That's why I don't want it to go ahead and save the node. However, if it isn't possible I guess I will have to find another way to do what I need.

And tried to add a submit function, still reloads the whole page.


texts: How to disallow users with certain emails form posting?

texts:
On a Drupal 6 site, I struggle with some persistent spammer who uses different tricks to escape any regexp spam filters. Whenever I delete him, he always uses certain email provider (e.g. somerandomname@blablamail.com) to register again.

So I am wondering how can I disalow blablamail.com altogether so that either users can not register with this email provider, or better, they can not post anything after registration?


texts:
I need to import on node save information from a third party REST server and map that data to an entity that references the node saved. There will be a field in the node that the user can input an id that is passed in the url of the REST call. The REST call will return an XML object that needs to be mapped to a new entity that is referenced to the node.

How is this done? Are there an examples of Drupal 7 modules that do this?


texts: How to reuse the same custom template in Ajax callback

texts:
I am currently trying to display a list of nodes with a custom form containing taxonomy dropdowns (placed above node list) to filter out the contents. Now, on page load all content is displaying well by theming with custom template. Now my form is an Ajax form. After filtering I want to display the result with by using same template just passing the filter array of the node(s). Please find my ajax submit callback code.

Not working. render() works only if I pass nodes by loading node by viewMultiples. is there any way I can use similiar to theme() of drupal 7 like theme('my_content_build_page', $nodes)?

$nodes= Myclass::getNodesByEntityQuery($params);
$build = \Drupal::entityTypeManager()->getViewBuilder('node')->viewMultiple($nodes, 'full');
$response = new AjaxResponse();
$response->addCommand(
  new HtmlCommand(
    '.result_message', '
'.render($build).'
'
  )
);
return $response;

On page load I am theming

$page_params['content'] = MyClass::getNodesByEntityQuery($params);

$build = [
  '#theme' => 'my_content_build_page',
  '#page_params' => $page_params,
];

Can I reuse the same template in Ajax Callback?


texts: I have a view in which I have used Exposed filters and load the content using AJAX. The problem is whenever I apply any filter, first page is loaded properly but when there are more result and I go to next page using pager my filters are reset and wrong next page is loaded,because javascript is getting called after AJAX call. Any suggestions how to overcome this issue?


texts: How to add google_tag script to header with custom environment variables?

texts:
I'm trying to add Google Tag Manager to the <head> of my document.

Unfortunately, the way I'm doing it with an HTML tag render element, the ampersands (&) are being escaped.

function mymodule_page_attachments(array &$page) {
  $config = \Drupal::config('mymodule.config');
  $gtm_id = $config->get('google_tag_manager_id');
  $gtm_auth = $config->get('gtm_auth');
  $gtm_preview = $config->get('gtm_preview');

  /** @var \Drupal\mymodule\AnalyticsUtility $utility */
  $utility = \Drupal::service('mymodule.utility');

  if (!empty($gtm_id) && !empty($gtm_auth) && !empty($gtm_preview) && $utility->isAdminPage() === FALSE) {

    $script = "(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl+ '&gtm_auth={$gtm_auth}&gtm_preview={$gtm_preview}&gtm_cookies_win=x';f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{$gtm_id}');\n";

    $page['#attached']['html_head'][] = [
      ['#tag' => 'script', '#value' => $script],
      'google_tag_manager',
    ];
  }
}

This results in ampersands in the code.

<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&amp;l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl+ '&amp;gtm_auth=testrWktRcmjpViiQKW&amp;gtm_preview=env-6&amp;gtm_cookies_win=x';f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-K53TEST');</script>

There are two modules with Google Tag Manager and they both add the code using hook_page_attachments().

The recommendation for adding JavaScript is to use an external file; yet, the Google Tag Manager documentation recommends adding the script in <head>.

Is there a way to do this with Drupal settings and a javascript file in my custom module? Alternatively, is there a way not to convert the ampersands to HTML entities?


texts: How can I get node creation date and convert it to custom format in my theme, I tried to make some operations on node date in "MyTheme.theme" file and in preprocess_node section.


texts:
question 1: I am making a site for a client who wants the search to support synonyms and this is not something that is supported in the search api i believe. so that when a user searches for USA, nodes related to america will show up. Is this possible without the author of the content creating synonyms manually? Is there other options, like embedding google custom search that will support this in any language?

question 2: Is there any module that enables search results to show up in a map for drupal? i have been looking and havent come across any yet..

Thanks in advance:)


texts: How to get escaped file description from node?

texts:
I enabled file description for node and I want to display descriptions close to the download links.
I would like the description be secure. I tried

$items = field_get_items('node', $node, 'field_files');
foreach ($items as $item) {
  echo $item['description'];
}

but there is html code parsed.

I can use just check_plain() function on the description, but is there any way to do it better?


texts: override theme function in facetapi module

texts:
I am trying to change the markup of links created by the facetapi module.  The theme function is here

function theme_facetapi_link_inactive($variables) {
  $accessible_vars = array(
    'text' => $variables['text'],
    'active' => FALSE,
  );
  $accessible_markup = theme('facetapi_accessible_markup', $accessible_vars);
  $sanitize = empty($variables['options']['html']);
  $variables['text'] = ($sanitize) ? check_plain($variables['text']) : $variables['text'];
  if (isset($variables['count'])) {
    $variables['text'] .= ' ' . theme('facetapi_count', $variables);
  }
  $variables['text'] .= $accessible_markup;
  $variables['options']['html'] = TRUE;
  return theme_link($variables);
}

I am trying to override this function so I can change the markup without editing the module files.  I've tried MYTHEME_preprocess_facetapi_link_inactive and using a custom module but both times I can print the variables and they are correct but the links are still displayed wrong.

function MYTHEME_preprocess_facetapi_link_inactive($variables) {
  $accessible_vars = array(
    'text' => $variables['text'],
    'active' => FALSE,
  );
  $accessible_markup = theme('facetapi_accessible_markup', $accessible_vars);
  $sanitize = empty($variables['options']['html']);
  $variables['text'] = ($sanitize) ? check_plain($variables['text']) : $variables['text'];
  if (isset($variables['count'])) {
    $variables['text'] .= ' <strong>' . theme('facetapi_count', $variables) . '!!!</strong>';
  }
  $variables['text'] .= $accessible_markup;
  $variables['options']['html'] = TRUE;
  return theme_link($variables);
}

Am I going about this the wrong way?


texts: How to get the out of the box slideshow to display on a page other than /node? - Corporate Clean/Omega theme

texts:
I am using a domain access module and currently running two domains. Out of the box, my default domain was displaying a slideshow on the homepage. Using these instructions I created a new front page -

However, now the slideshow isn't displaying. How do I get it back up?

By the way, the reason I went ahead with the front page setup as per the instructions was to avoid the "No front page content has been created yet." message.


texts:
Website has several types of users and all can post images, videos, events etc.

One user type is hard to solve for me.

This user type is summer school that is happening every year and last for few weeks.

This user as all other can post images, videos, events etc. but i would like to separate all of these by the year.
So summer school happened in 2009, 2010, 2011 etc.

For other user types i have menu in sidebar:
Bio
Photos
Videos
Etc.

For summer school i have the same menu but somehow i would like to have a year above the menu with drop down if possible ? When year is picked website should remember it so the menu gives content based on year picked.

Also when user (summer school) creates content it should be able to pick which year it happened. I can use date field here i guess, but the bio should remain the same for any year chosen.

Hope i was clear enough.


texts: Error when uploading file through Drush on S3 volume

texts:
I am using Amazon S3 volume to store the node's attachment.
I keep having the following message:

file_put_contents(public:///.htaccess): failed to open stream: "DrupalPublicStreamWrapper::stream_open" call failed file.inc:494                                                                                [warning]
WD security: Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your public:// directory which contains the following lines: # Turn off all options we don't need.                                 [error]
Options None
Options +FollowSymLinks.....

I tried chmod 777 on private (sites/default/files/private) public (sites/default/files) folders without any success.

Is it because amazon S3 and AWS/SDK are installed. It works weel anyway : my files are created on S3 volumes. But the message is annoying.

Any ideas ?

Thanks


texts:
Before creating "form" custom module, everything was fine. After creating this module, I have got the following error message:

  Cannot use string offset as an array in includes\form.inc on line 3575

I deleted the entire custom module folder, and cleared the cache as well. Still, I am getting the same error when modules page.

How do I overcome this error?

coding inside the form.module page is

        function form_menu() {
      $items = array();
      $items['form/form'] = array(
        'title' => t('My form'),
        'page callback' => 'form_form',
        'access arguments' => array('access content'),
        'description' => t('My form'),
        'type' => MENU_CALLBACK,
      );
      return $items;
    }

    /**
    * This function gets called in the browser address bar for:
    * "http://yourhost/form/form" or
    * "http://yourhost/?q=form/form". It will generate
    * a page with this form on it.
    */
    function form_form() {

      // This form calls the form builder function via the
      // drupal_get_form() function which takes the name of this form builder
      // function as an argument. It returns the results to display the form.
      return drupal_get_form('form_my_form');

    }

    /**
    * This function is called the "form builder". It builds the form.
    * Notice, it takes one argument, the $form_state
    */
    function form_my_form($form_state) {

        // This is the first form element. It's a textfield with a label, "Name"
      $form['name'] = array(
        '#type' => 'textfield',
        '#title' => t('Name'),
      );
      return $form;
    }


texts: Should I enter data as English and then translate to my language?

texts: For data entry for taxonomy terms and field names should I enter data in English and then translate to my own language?Entering directly in my own language has no problem.I just want to know if there is any rule for this.


texts: How to add a description to the Goals used by the Goals module?

texts:
I'm using the Goals module in combination with Views. I'm now displaying all the Goals that were completed by a user on the profile pages in a table that contains the Goals' image and title.

Now, I'd like to explain a bit more what the user exactly achieved by adding an extra column with a description. Adding a direct description to the Goals would be a perfect solution, but as this isn't provided by the module's maintainers, I opened a feature request.

I know Drupal Answers isn't built to provide patches (although they're very welcome), so I'd like to ask whether there's perhaps another solution for my problem.


texts: How can I switch to an external db with Views API?

texts:
In Drupal 7 I have a module with a hook_form(). This form is saving data into an external postgresql database.

I want to create a views to display data recorded. So I used hook_views_data() to create a mapping between the view and my custom tables. I created a view with admin but in this view I have the following error :

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cars' doesn't exist

I have tried something like this but it doesn't run :

function carshop_views_pre_render(&$view) {
  if ($view->name == 'cars_overview') {
    db_set_active('carsdb');
  }
db_set_active();
}


texts: How do I use a token to set the default value of a date field to the current date?

texts:
When I go to the build tab of the webform and click edit on the date element, I can find the default value setting under the advanced tab in the element editor. The help text says I can use tokens, but I'm having trouble making a token work there. (I'm trying to use the [current-date:html_date] token).

If I click "set default value", another dialog opens with a text input and a button that says "update default value". But when I click that button after putting the token into the input, it goes back to the advanced tab and the default value input is empty. If I enter the token before clicking "set default value", the "update default value" dialog opens with an empty input. I've tried various combinations/orders and can't get the token to stay there. It doesn't matter if I type it in, copy/paste it, or fill it using the "browse available tokens" tool.


texts:
I am modifying the node content on hook_form_alter() as follows.

  $node = \Drupal\node\Entity\Node::load($nid);
  if ($node) {
    $node->field_p_frontip = $availableip[0];
    $node->save();
  }

I need to clone the node and save it in the  hook_form_alter() submission. How could I do this?

UPDATE

In D6 the node was cloned using the function clone_node_save which uses the node id to clone as clone_node_save($nid,false);, what is the corresponding function in D8 ??


texts:
There are hundreds of records in a database that are in windows-1256 charset, I want to read these data and convert them to utf8 then insert them in a new table, to read these data I need to change the MySQL unicode to latin1 and convert the data to utf8. from this link I successfully did this.
Now I need to insert these data into database and their charset must be utf8, the problem is $database variable in settings.php have this configuration

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'DB_NAME',
      'username' => 'PASSWORD',
      'password' => 'PASSWORD',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
      'collation' => 'latin1_general_ci',
      'pdo' => array(
            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES latin1",
      )
    ),
  ),
);

and in database/mysql/database.inc line 57 changed to this:

if (!empty($connection_options['collation'])) {
  $this->exec('SET NAMES latin1 COLLATE ' . $connection_options['collation']);
}

so because of this new database configuration, insertion the converted records (to utf8) doesn't provide the desire result (because MySQL is latin1 now), I need to reset the database configuration to its origin just before inserting the data. how do I can do this?

UPDATE:

the only solution I have found so far, is to create another database in utf8 and using external connection move the data into there !!!


texts: How to pass along current $form_state for an #upload_validators callback?

texts: I have a managed_file #upload_validators callback and when it is called the $form_state does not get passed along with it. My goal is to use another field in the form to rename the uploaded file. I just need access to that during the validation. Maybe I shouldn't be using a validator callback for renaming the file and displaying in the UI immediately but this but it is all I can think of at the moment.


texts: View table style sort options - custom alternative to Ascending or Descending

texts: I have a view that is displayed as a table. In Format > Settings I can set some fields (columns) to be sortable. The Default Order can then be set to Ascending or Descending. How can I define a custom sort method so that it shows up in that dropdown?


texts: how to save new value of autocomplete field with hook_form_submit?

texts:
creating a custom submit function for the form of mymodule

/**
 * Implements hook_form_submit()
 */
function mymodule_form_submit($form, &$form_state){

    $new_user = drupal_anonymous_user();
    // removed basic user fields here to make it more clear

    // save taxonomy checkbox field
    foreach ($form_state['values']['third']['field_functioncat'] as $key => $value) {
        if($value > 0){
            $new_user->field_functioncat[LANGUAGE_NONE][$key]['tid'] = $value;
        }
    }

    // save text field
    $new_user->field_firstname[LANGUAGE_NONE][0]['value'] = $form_state['values']['first']['field_firstname'];

    user_save($new_user);
}

Above code works but I'm having trouble saving the autocomplete field.

What I'm trying:

// get value of the form
$tid = taxonomy_get_term_by_name($form_state['values']['first']['field_city'], 'field_city');
// get the first array value and then the tid of the left over object:
$tid = reset($tid)->tid;
// save field to user profile
$new_user->field_city[LANGUAGE_NONE][$tid]['tid'] = $tid;

This works for existing terms, but when I put in a new term it can't get the id of the term because that term name is not created?

How do I create the term name and get the tid to submit it to the user creation?

note:
I've created the field_city as taxonomy term and linked it to the user profile so it's visible and editable in on the user edit profile page.


texts: field_info_field: how to define the content type name?

texts:
I defined several content type. In a module, I need to get the list of fields for this content type. I did the following:

 $fields = array();
  $content_type = 'indicatorsheet_page';
  $instances = field_info_instances('node', $content_type);

Variable $instances is empty. How should I defined $content_type? Isn't it a string set to the type machine name?


texts: How can I resize the original versions of all of the images that have already been uploaded?

texts:
I have a Drupal 7 site that uses a custom content type that allows users to upload images via the core image field.

Originally, I set the maximum resolution of images to 2048x2048 on the field configuration page.  However, I realized that I only need a resolution of 1024x1024.  I have modified the value of the setting, and new image files are resized appropriately, but the image files that have already been uploaded are still up to 2048 pixels in size.

What I want to do:  I would like to resize the image fields that have already been uploaded to a maximum of 1024x1024 as well.

What I tried: I made a view of all images and used Views Bulk Operations to re-save all content.  However, this had no effect on the image sizes.


texts:
Here is the code I currently have:

function mymodule_action_info() {
  return array(
  'mymodule_send_mail_admin_action' => array(
  'type' => 'node',
  'label' => t('Send a mail to administration warning insertion and deletion of nodes.'),
  'configurable' => FALSE,
  'triggers' => array('node_insert', 'node_delete'),
  ),
);
}

function mymodule_send_mail_admin_action($object, $context) {

if ($context['hook'] == 'node_insert') {}

//if ($context['hook'] == 'node_delete') {}
    }

What should I put inside the mymodule_send_mail_admin_action function? How should I complete it?

Note: I need to write a function for this (not use rules).


texts: Tracking Sessions and Calling a web service

texts:
I have a module that simply has a couple functions that retrieve cookie information, set cookie information and calls a web service using the web service client to help track the users information.  However, when i installed the module, it did not recognize the function that executes the loading of the service from the web service client.  It returned the following error:

Call to undefined function wsclient_service_load()

The code is simple and looks like this:

function set_session_tracking_data() {
$sessionGuid = com_create_guid();

//Time for Cookie Experation
$time = time()+3600;

if (isset($_COOKIE["Drupal_VisitorGUID"])) {
    $sessionId = $_COOKIE["Drupal_VisitorGUID"];
}
else {
    $sessionId = $sessionGuid;

    setcookie('Drupal_VisitorGUID', $sessionId, $time);

    $params = array('visitorGuid' => $sessionGuid);
    $service = wsclient_service_load('tracking');
    $result = $service->CreateVisitor($params);
}
}

The function set_session_tracking_data is being called from a module created solely for tracking purposes.  It has no hooks.  Simply has a function called set_tracking_params() and in that function we call set_session_tracking_data().  The code is below:

function set_tracking_params() {
//Sets Module Path
$modulePath = drupal_get_path('module', 'eddy_tracking');

//Time for Cookie Experation
$time = time()+3600;

if (!isset($_COOKIE["cid"]) && !empty($_GET['cid'])) {
    setcookie('cid', $_GET['cid'], $time);
    dsm($_COOKIE["tsource"]);
}

if (isset($_COOKIE["key"]) && empty($_GET['key'])) {
    setcookie('key', $_GET['key'], $time);
}

set_tracking_params()
}
set_eddy_tracking_params();

I made the wsclient a dependency but it still does not recognize the function. If i put this same code within a block module i created, the code executes without a hitch.  Can someone please help me with this issue?  Or perhaps someone can mention to me the best practice at setting sessions and tracking a users session.  Any help would be greatly aprreciated.  Thanks!


texts: How to reindex $form_state values' deltas when deleting or unsetting one of the options?

texts:
In a module, I provide a form to the user to select a value from a select. The form allows multiple values and the form updates itself via ajax to provide always one more select field than selected values. Thus it starts with just one field, and each time you select a value in the new select, another one is added.

Initial

After selecting two values

The Problem

Now when the user decides to remove one of the values selected by selecting the null value ---, this appears (first value set to ---):

But of course, I want to have the second value now in the first select field and the second one should show the null value.

How is it possible to alter the $form_state array in such a way?

I tried to go through the respective form_state value, get all the "true" selections and set $form_state to the temporary array like

$tables_real_num = 0;
if (isset($form_state['values']['tables']['table'])) {
  $tables_values = $form_state['values']['tables']['table'];
  $i = 0;
  $tables_real_values = array();
  foreach ($tables_values AS $t => $data) {

    if ($tables_values[$t] != '0') {
      $tables_real_num++;
      $tables_real_values[$i] = $form_state['values']['tables']['table'][$t];
      $i++;
    }
  }
  $form_state['values']['tables']['table'] = $tables_real_values;
}

But still with this code, the only value appears in the second select element. At some point, my thinking must take a wrong turn, can you help get back onto the right track?

I know, I could just use a single field with multiple select options in this case, as the available options are always the same, but the user needs to be able to select the same value multiple times.

For reference, the part in question is part of a multistep form. It's on page one of that form and thus in the first constructor function. The function retrieves the form values either from the current submit (when editing page one and if an error occurs) or from stored values (if going back from page two). The pastebin version is different in that these values are used internally to create the distinct select fields. In line 29, I try to set the real values to $form_statebut there must be something wrong with that way.


texts:
I am on Drupal 7. Hi, I have installed the Devel module and I am using it to help me theme the user-profile.tpl.php. I want to show the e-mail information only when the user looking into the user info page is the own user.

I am checking the currently logged in user with $user->uid.

Now I want to get the uid corresponding to the current user page to evaluate if they are the same so that I can print the e-mail. When I go to the Devel  interface, it shows me the information I need on the Load area, when expanding the stdClass information.

How can I use these attributes on the stdClass? I was expecting to do something more or less like $somethinghere->uid to grab the current page user uid, but my trial-and-error process isn't working, I have tried everything... Thanks.


texts: Drupal error after creating new theme ,Undefined variable: hide_site_name and other similar error

texts:
I am new to drupal theme . I have created a direcory mytheme and added mytheme.info to it and copied other files from drupal's default theme directory . Now after editing the page.tpl.php, drupal is showing the errors below .

Notice: Undefined variable: hide_site_name in include() (line 99 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined variable: hide_site_name in include() (line 109 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: featured in include() (line 168 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: highlighted in include() (line 187 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: sidebar_second in include() (line 212 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_first in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_middle in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: triptych_last in include() (line 220 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_firstcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_secondcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_thirdcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).
Notice: Undefined index: footer_fourthcolumn in include() (line 230 of C:\wamp\www\dtest\sites\all\themes\mytheme\bartik\templates\page.tpl.php).

After searching on google, I have found that clearing cache will solve the problem . But even after clearing my cache,it remains the same !


texts:
I want to display the default value of a variable when no value is set. I checked the Drupal 8 documentation pages, but I couldn't find any information about the default value.

In Drupal 7 if variable value is not set then default value is displayed.
variable_get('variable_name', 'hello');

If "variable_name" is not set at that time, hello will be returned.

Now for Drupal 8 I am trying the following way.
$config = $this->configFactory->get('module_name.settings');

$config->get('variable_name', 'hello'),

I am not getting hello.