texts: Clean way to programmatically add attributes to a view field entity label link

texts:
I have a View that lists entities. One of the fields is the entity label field, which is set to output a link to the entity itself. I would like to add attributes to the <a> tag to grab later with a jQuery plugin.

I can use template_preprocess_views_view_field() and hook_views_pre_render() to get the rendered markup and alter it there, but it's very dirty and not something I'll consider. I could also create a specific theme suggestion and field template and do it that way, but I don't want to rely on something that's potentially editable or changeable. It needs to be as generic as possible.

Is there a clean solution for this?


texts: What's the difference between adding a template and overriding a template, from a custom module?

texts:
I found a paragraph in the documentation about using template files in a custom module. This way can be even used to override a template like I did here.

However, I am wondering if this is the correct way since I have read this answer.

After some research I noticed that we can see sometimes, depending on the case, the use of:

hook_theme alone
hook_theme with hook_theme_suggestions_HOOK_alter
hook_theme_registry_alter

What are the subtleties between these different ways to create or override a template?

The documentation for hook_theme, which is not clear for me, states:

  The keys on the outer array are known as "theme hooks". For theme
  suggestions, instead of the array key being the base theme hook, the
  key is a theme suggestion name with the format
  'base_hook_name__sub_hook_name'. For render elements, the key is the
  machine name of the render element. The array values are themselves
  arrays containing information about the theme hook and its
  implementation.

Does this mean: "theme suggestions" for template overriding, and "render elements" for template creation?

To summarise, is there a difference between adding a template and overriding a template, from a custom module?
If so, what’s the correct way to add a template and the correct way to override a template?


texts: Remove the resizing of images that are bigger then the max resolution. (reject instead)

texts:
I'm using a very specific theme on the site where an image need to be exactly 1110x540.
I've set up the min and max resolutions and everything works perfectly, except when I upload an image that's bigger then 540px. Then the image rescales.

Is there a setting that rejects these images instead of resizing them ?
I'm using Drupal 7 btw.


texts: A view I wrote has bugged handlers so I want to alter the query manually. How do I get the current view display?

texts:
The view handler for locations is broken when the locations are in field collections.

I need to rewrite the view query, replacing 3 joins with 2 other joins, for the query to work.

I don't want to mess with other displays of the view - how do I get the currently used display with hook_views_query_alter()?


texts: Filter User in Views based on taxonomy contextual filter?

texts:
I have some users with taxonomy term reference fields.
Lets say users can be associated with regions.

When i view  the user page i want to see all other users from the same region as the user i am looking at.

I created a views block on users with a contextual filter based on that taxonomy, but i cant get it to work ? Do i need some relationship ??

My Settings for the contextual filter:

filter on User: Region (field_region) / that is the taxonomy term reference field in the user
provide default value -> user
ID from URL
specify validatiion criteria -> taxonomy term -> vocabularies "Region" , filter value type -> term name converted to term id


texts: Inserting in user's field on creating the user?

texts:
I need to add subscription key field to user as a hash of his email and time created so I did this in a custom module

function custom_newsletter_mail_entity_presave($entity, $type) {

    if($type == 'user') {
        if(empty($entity->get('field_subscription_key')->getValue()[0]['value'])) {
            $hash_input = $entity->getEmail() . $entity->getCreatedTime();
            $key = hash ('sha256' , $hash_input , FALSE);
            $entity->set('field_subscription_key',$key);
            // $entity->save();
        }
    }
}

This is not working for some reason, note that I tried this outside of module on all users array and it worked. for some reason, the subscription key field is still empty, the second if condition is there to prevent the field from being overwritten.


texts: Drupal 7 ability to use other databases in the web form module

texts:
We used webform-7.x-3.20 module in our web site.
But we want to connect and use a database different than drupal's default database.

Below you can find example DB setting.

$databases['default']['default'] = array (

  'database' => 'example_1',

  'username' => 'example_1',

  'password' => 'example_1',

  'host' => 'localhost',

  'port' => '',

  'driver' => 'mysql',

  'prefix' => 'example_',

);

$databases['default2']['default'] = array (

  'database' => 'example_2',

  'username' => 'example_2',

  'password' => 'example_2',

  'host' => 'localhost',

  'port' => '',

  'driver' => 'mysql',

  'prefix' => 'example_',

);

As a conlusion we want to use the second DB in webform modules. The rest will used the first DB that is default.

We could not be succesful in realizing this.
Any help would be appreciated


texts: I have a form with an image field, I want to remove the upload button and submit the image while the form is submitted. I not able to find out how to proceed further with this. Any help is greatly appreciated.


texts:
This must be something simple but I cannot figure out how it should be done.

I have a page created by Page manager (and Panels) on the url [page-path]. I have added a custom content with an url in it: Add a term.

The problem is that on the rendered page the url is transformed to contain also the path of the page itself: [page-path]/admin/structure/taxonomy/[vocabulary]/add.

I suppose this is how the Page manager (or Panels) works, but I can't find out how to handle this.

Thank you in advance!


texts:
I used Pathauto to create URLs for my nodes like gallery/[node:title].

I created a view with an argument, and the path is gallery/% (% is the node title), but when I point my browser to that URL, I get the standard node, not the view.

How can I override the paths to get my view on that path?
How can I increase the weight of views.module?


texts:
How to use tables that are claimed by other modules in drupal?

I have a table in my database named "dictionary" used by a module for translation .
now i want to use that table in views to show all data of that table.
Is there any method by which i can use that table?


texts: Solr server URL needs to include a scheme?

texts:
Recently I am facing a issue with all my D7 websites which I have migrated to a new server. The case is as follows

-> All Sites have been setup with Apache Solr and working fine on my old server

  After I migrated the sites to new server I am getting this error

URL Format Used :

  http://USERNAME:PASSWORD@XXX.XXX.XXX.XXX:8983/solr/CORE_NAME

Note: I migrated to new server with latest version of LAMP. Also I use remote Solr server.

OLD Server : Ubuntu 12.04, PHP 5.3.10, Nginx 1.8.0, MySql 5.5.X

New Server : Ubuntu 16.04, PHP 7.0.28, Nginx 1.10.3, MySql 5.7.X


texts: I have a client who needs to allow customers to put products in a cart so that they can be custom quoted, instead of purchased online. Is Drupal Commerce aptly suited for this? If so, what are some strategies to hide pricing throughout the process?


texts: Cannot Add Registration to cart: SQL Error with Registration and Drupal Commerce

texts:
I have drupal site running core 7.42 and Commerce 7x-1.11 with Commerce Registration and Entity Registration. The modules all seem to be working fine as I can create registration products and product displays and add registrations to pages and such.

The problem is when a user tries to add the registration to cart it produces 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
        '))  LIMIT 1 OFFSET 0' at line 1: SELECT registration.registration_id
        AS entity_id, registration.type AS bundle, :entity_type AS  entity_type,
NULL AS revision_id FROM {registration} registration WHERE (registration.entity_id
         = :db_condition_placeholder_0) AND (registration.user_uid = :db_condition_placeholder_1)
     AND (registration.state IN ()) LIMIT 1 OFFSET 0; Array ( [:db_condition_placeholder_0] => 5
        [:db_condition_placeholder_1] => 1522 [:entity_type] => registration ) in EntityFieldQuery->execute()
    (line 1192 of /home/phislub9/public_html/includes/entity.inc).

I'm not sure what is causing the error, or how to debug it. It looks like a bad query is getting passed to the a drupal_alter function to modify query's in entity.inc.


texts: List all users whose "member for" and "last access" are the same

texts:
I have around 40,000 users on my site but around 20,000 of them are automated registrations (by comment spammers presumably) and I'd like to delete those.

It's very easy to spot them as their registration date/time is exactly the same as their last access date/time.

How do I filter the user list in Views so that I only get users whose "member for"=="Last access"?


texts: How to allow a route to a user as long as he has the good role?

texts:
Maybe this is a noob question but here goes:

I have a menu a menu that contains four links. However, I need one of the items to be accessible only if the current user has "beneficiary" as role.

Since the user's 'roles' is an array containing all kind of roles, how can I set my route in a way that as long as the user has the correct role ?

IE, let's say that a random user has the following:

$user['roles'] = ['authenticated', 'beneficiary', 'elected'];

and would pass, but another random user having the following:

$user['roles'] = ['authenticated', 'elected'];

wouldn't.

I'm pretty sure there is a way but I can't find explicitely what I'm looking for in Drupal's documentation

Thank you in advance


texts:
I have a problem with a pretty complex custom views relationship.

The scenario:

I have nodes that have a field field_revision. This field has the same value for nodes that belong to the same revision. I have another field field_element. This field stores information for some container the node is assigned to.

What I want now is a views relationship that gives me the possibility to get all nodes of the same revision assigned to a specific container. My idea is to use the SQL joins as follows:

node.nid > field_data_field_revision.entity_id
field_data_field_revision.field_revision_value > field_data_field_revision.field_revision_value
field_data_field_revision.entity_id > node.nid
node.nid > field_data_field_element.entity_id with extra field_data_field_element.field_element_value = 123 (defined by a filter)

The joins look like this:

$join2 = new views_join;
$join2->construct('field_data_field_revision', $join1_name, 'field_revision_value', 'field_revision_value', NULL, 'INNER');

I managed to implement that using the views API and its working fine with..

..one problem:

Whenever I use the relationship I lose all the table rows of the view with nodes from revisions that do not have other nodes in the container I want to join to. I tried to use left joins but I did not get the expected result.

Did anyone of you ever try something like this and has another approach or an idea what I may change to not lose rows when there are no results?

Thanks, j


texts:
On my site I've views and custom hook_menu.

Also if I don't use page arguments (or contextual filters on views), the system returns pages also when I try to add element on path.
Example:

hook_menu define a "my-great-page" and if I try to go to "my-great-page/test", Drupal returns me the content on my-great-page

This occurs also with views and with many other paths.

Is there way to avoid this behaviour?


texts: Change node content after logging in under the same URL alias (showing other content for authenticated users)

texts:
I would like to change node content under some specific URL aliases after the user logs in, to show some other contents for authenticated users.
With a really simple example, there's a node which can be reached under the URL alias http://<mysite>/something, and this content contains the string "You have to be logged in, because this would be good to you", but after logging in, the same URL alias would show "OK, now you're logged in".

Another user wrote here that

  "in views we can setup same url for different views that is one for
  anonymous and another for registered."

Is this the right solution?
If yes, how should I do this in practice?
If no, what else can you suggest?

Thank you in advance!


texts: How to set HTML value for taxonomy description field using entity_metadata_wrapper

texts:
I've set my taxonomy description field to taking a filtered text value. Using the UI, I can edit a taxonomy term, write some HTML, save, and when I view it I see the HTML rendered by my browser.

However when doing this:

$wrapper = entity_metadata_wrapper('taxonomy_term', 123);
$wrapper->description->set('
My html
');
$wrapper->save();

And viewing the term's page, the description comes out with the html converted to entities, i.e. I see
My html
 instead of a paragraph with My html as its content.

I notice that

$wrapper->description->value(); //
&lt;p&gtp;My html&lt;p&gt;

Whereas if I load a term that I have edited with the UI, saving HTML to the description field,

$wrapper->description->value(); //
Some html

I've looked at $wrapper->description and $wrapper->value()->description and there's no difference between a term with/without the correct/desired behaviour.

Also, I note that with normal fields, when you set a formatted text field you pass/get an array [ 'format' => 'filtered', 'value' => '
the html
' ] whereas here I only ever get a string.

Is this something peculiar to taxonomy terms (and is there a workaround or extra code I need)? Have I misunderstood something?

Thanks.


texts:
I want ajax dependent fields in one of my node's form so I am altering the form.

here is the code

    function mymodule_form_alter(&$form, &$form_state, $form_id) {
      $selected_first = isset($form_state['values']['field_first'][LANGUAGE_NONE][0]['nid']) ? $form_state['values']['field_first'][LANGUAGE_NONE][0]['nid']: '0';
    $form['field_first'][LANGUAGE_NONE]['#ajax'] = array(
      'callback' => '_first_callback',
      'wrapper' => 'second-field-wrapper',
    );
    $form['field_first'][LANGUAGE_NONE]['#default_value'] = $selected_first;

    $form['field_second'][LANGUAGE_NONE]['#prefix'] = '
';
    $form['field_second'][LANGUAGE_NONE]['#suffix'] = '
';
    $form['field_second'][LANGUAGE_NONE]['#options'] = _get_second_options($selected_first);
}
/**
 *
*/
function _first_callback($form, $form_state) {
  return $form['field_second'];
}
/**
 * Ajax callback for second field
 */
function _get_second_options($occ_id) {
  //array which contains some int values
  return $second_options;
}

Some more information: field_first is select list of type node reference and field_second is checkboxes.

  Issue: This works fine while creating the node. But when I edit the
  same node, the second field doesn't show and also values selected for
  this field while creating the node are also not checked by default.


texts: Using twig|without for a commerce product

texts:
I have a twig template for my commerce product, commerc-product--contenttype.html.twig:

      {{ product.field_price_original }}
      {{ product.variation_price }}

      {{ product.field_discount_percentage }}

  {{ product|without('variation_attributes', 'product.field_price_original', 'product.variation_price', 'product.field_discount_percentage') }}

I want to print three fields separately first and then print the rest of the content except for the first three fields (which have already been printed).

However, even though this note implies that without can take multiple values, everything is being printed; the without is ignored.

If I try a single value like this:

  {{ product|without('product.field_price_original') }}

The without is still ignored.  What might be the cause of this?

Drupal 8.4 and Commerce 2.1


texts: Theme import not changing the color scheme

texts:
I created a new theme in d8 and modified some color schemes.

Then I ported that theme to another site and placed in /var/www-
drupal/themes and enabled it.

The theme is ported. But the changes made to
the color scheme is not ported. Any idea how to import the color scheme?

Its still in the default color scheme.


texts: How do I see if it's improving my response time?

texts:
I installed memcached for a Drupal 6 site. The status report shows it's properly installed.

How do I check if it's working as expected, and speeding up my site?


texts: Error by sending Email in Drupal 7, but ok by Rules?

texts:
System messages (Restore Password, Registration) not sending to email and in Logs shows error. But email sending by Rules (Ubercart) very good. What's the problem?

  Message   Error sending e-mail (from user@example.com to
  user@example.com).
  Severity  error


texts: Authenticated REST requests becoming anonymous user

texts:
I'm new to the services and rest_server modules (and RESTful APIs altogether.) As I understand it though, the steps are basically this:

Send a post request to /api/user/login with the username and password set in data
Store the token you get in the response
On subsequent post requests, add the token to the header with the key X-CSRF-TOKEN

When I use the Postman Chrome extension to do that, it works great. When I do it in code, it does api/user/login fine, I get the token, but when I try to access /api/other/endpoint, I get 403 Access denied for user anonymous error.

The first request (/user/login) looks like this:

POST /api/user/login HTTP/1.0
Content-Type: application/json
Accept: application/json
User-Agent: Drupal (+http://drupal.org/)
Host: mysiteurl.com
Content-Length: 41

{"username":"NAME","password":"PASSWORD"}

And the second request (/other/endpoint) looks like this:

POST /api/other/endpoint HTTP/1.0
Content-Type: application/json
Accept: application/json
X-CSRF-TOKEN: vGJm5GNDGumf-SoHnLsBU6d46EkrOZkvUY0CSa08GA0
User-Agent: Drupal (+http://drupal.org/)
Host: mysiteurl.com
Content-Length: 0

If I make requests to /user/token after authenticating, I get new tokens each time. If I try to logout immediately after logging in (and send along that token), I get a "406  Not Acceptable : User is not logged in." error. it tells me user is not logged in.

If I check the site though, it shows the user as successfully having logged in, and still being logged in after the fact.

Do I have to save/send anything regarding the session name/id or cookie? Everything I've been looking at suggests only the session token is necessary.


texts: Image styles with $settings['file_public_base_url']?

texts:
I deep dive in the settings.php file of Drupal 8.1 and try to configure $settings['file_public_base_url']and $settings['file_public_path'].

All media links are correctly rewritten, that works with static files, but styles fails with 404 errors as there is no php support and rewriting rules are not implemented.

How can you get styles to work with $settings['file_public_base_url'] ? Is it related with Image cache external ?


texts:
Im trying the following to bring up a view that only has 6 product nodes, and I get a WSOD with a Memory Exhausted warning, ive set it to 256MB, it shouldnt be flaking out on such a small request!

$view = views_get_view('products');
$view->set_display('Master');
$view->get_title();
$response = $view->preview('block');
dpm($response);

Am i doing something wrong?


texts: Is there a way to see all the available variables inside content?

texts:
I am using Drupal 9 with twig files
I have a page where in one section I need to show thumbnails of the latest posts. So I created a new view as a block, and placed this block under Content in admin/structure/block/list/
When I inspect with debug on I get these file suggestions -
 FILE NAME SUGGESTIONS:
   * block--views-block--latest-news-block-1.html.twig
   * block--views-block--latest-news-block-1.html.twig
   * block--views-block.html.twig
   * block--views.html.twig
   x block.html.twig

So I created a file name block--views-block--latest-news-block-1.html.twig with the code from block.html.twig.
Inside that file I have -
    {% block content %}
      {{ content }}
    {% endblock %}

Which shows all the content in the block. I need to customize the content in the block though, some things need to be removed, I need to truncate the article text, need to add buttons.
I think I'd be able to do what I want if I could target specific parts of the content. I want to do something like this -

{{ content.title }}

{{ content.body }}

Is there a way to target specific parts of the content like that?


texts: Make block render right after enabling the module

texts:
I'm working on a module which renders a small block in a footer region. My goal is to make it work out of the box with default settings. User just needs to enable it with drush, no configuration required.

In Drupal 6 version I stumbled upon a strange problem. Looks like after enabling module it's hook_block isn't called, so block isn't rendered. It can be fixed either by doing drush cc all or going to blocks admin page. All caching is disabled on the test site.

I tried to incorporate drupal_flush_all_caches and drupal_cache_clear into hook_install without success.

Can someone give a hint?


texts: How to insert a block inside the content?

texts:
I need to insert a block inside in a specific place of my Drupal posts of only one type.

I understand that would be done through page.tpl.php file but can somebody explain how do I actually create that block in the first place and ascribe the right name to it? I tried searching in documentation and I'm a bit confused... Thank you!

                <?php print render($title_prefix); ?>
                    <?php if ($title): ?>

<?php print $title;  ?>

                    <?php endif; ?>
                <?php print render($title_suffix); ?>

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


texts: Can fields validation errors be displayed below the fields?

texts: Can field validation errors be displayed below the fields instead of as a list at the top of the form?


texts: CKeditor + Media: insert image tag rather than link to image

texts:
I want to insert an image into node body content using Ckeditor and Media. Everything seems to work except all I get is a link to the image file but I would like it to insert an image tag. When I click Ckeditor's Add Media button and choose an image I get an option Current format is and I can choose from Default, Preview and Teaser. While the first two return nothing, Teaser at least inserts a link to the image file.

How can I get it to insert an image tag instead of a link?

I am using Drupal 7.22 with Media 7.x-2.0-unstable7, Wysiwyg 7.x-2.2 and the latest Ckeditor.


texts: Porting a multi-site setup to local (MAMP) server

texts:
There seems to be plenty of tutorials about setting up a local multi-site installation, however, I cannot seem to find any information about porting a live multi-site to a local environment.

Specifically I want to work on just one of the sites from the live setup. I am using Drupal 6. Here are the steps I have taken:

I have setup a database on my local MAMP server with the same name as one of the live sites that I want to work on.
I have imported the mysql dump of just the database I want (removing the others multisite sites from the dump).
All site files transfered to a folder in my MAMP>htdocs>new-folder-name
In new-folder-name>sites>desired-site-folder>settings.php I've set the db_url variable to mysql://root:root@localhost/dbname

What further steps do I need to take? When I navigate to the local site I get the  'It works!' message. I presume I maybe need to set up a htaccess file to redirect, but if so, how should it be formed?


texts:
Can any one help me with this? I'm not sure what's causing my feeds importer to fail on import.

I have debugged the saving function of the feed item found out it's trying to insert the node twice but not sure how to get around it or fix it so i don't run into the issue.

Throwed exception:

PDOException: SQLSTATE[23000]:
  Integrity constraint violation:
    1062 Duplicate entry 'node-284' for key 'PRIMARY':
      INSERT INTO
        {feeds_item} (entity_type, entity_id, id, feed_nid, imported, url, guid, hash)
      VALUES (
        :db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2,
        :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5,
        :db_insert_placeholder_6, :db_insert_placeholder_7
      );
Array (
  [:db_insert_placeholder_0] => node
  [:db_insert_placeholder_1] => 284
  [:db_insert_placeholder_2] => feedback_importer
  [:db_insert_placeholder_3] => 55
  [:db_insert_placeholder_4] => 1363973130
  [:db_insert_placeholder_5] =>
  [:db_insert_placeholder_6] =>
  [:db_insert_placeholder_7] => 725208b7e0c7068d723d1488df2ffc31
 )
 in drupal_write_record() (line 7106 of (...)\includes\common.inc).

See also http://drupal.org/node/1950422.


texts: I have a third-party PHP script that I want to integrate and use in my site. The script is quite small and comes with its own functions and array indexes. How would I be able to call the functions and have them displayed in Views or CCK nodes?


texts: Taxonomy term with especial characters and Views Contextual Filter

texts: I try to use especial characters in Taxonomy. The comma, for example. I want that I can name a term as "Alpha, Beta, Gamma" and I would like that the contextual filter Url may be something like "alpha-beta-gamma". I have tried with alias url and filter by id but it does not work and if I try with an url containing the comma, it works but I don't want those characters to shkw in the Url for SEO purposes. Any idea?


texts: rewrite cck option values list using php

texts:
I use finder module for Drupal 6. There is a possibility to rewrite cck select options list using php. In a cck field I have following options with values and names:

1|a
2|b
3|c

It doe's not matter what names I choose because finder module's default output is allways values. I need to rewrite the list, so names are outputted instead of values like this for example:

1|yes
2|no
3|dont know

Finder module made available following variables

$value - The themed display value of this option.
$key - The themed key value of this option.
$option - Object containing data that finder has about this option.
$finder_element - Object containing data about this finder element.

Can anybody help me with code, I hava absolutely no idea where to start. Thank you


texts: How to display a field when a media is uploaded to the media library field?

texts:
I have block settings form where I have a media library field.
 public function blockForm($form, FormStateInterface $form_state) {
    $form = parent::blockForm($form, $form_state);
    $user_input = $form_state->getUserInput();
    $my_field = $user_input['settings']['my_field'] ?? $this->configuration['my_field'] ?? NULL;

    $form['my_field'] = [
      '#type' => 'media_library',
      '#allowed_bundles' => ['my_bundle'],
      '#title' => $this->t('Upload'),
      '#default_value' => $this->configuration['my_field'] ?? '',
      '#required' => TRUE,
      '#ajax' => [
        'callback' => [$this, 'ajaxCallback'],
        'event' => 'updateMediaLibrarySelection'
        'wrapper' => 'test-field',
      ],
    ];

    $form['test'] = [
      '#type' => 'textfield',
      '#title' => 'test',
      '#prefix' => '
',
      '#suffix' => '
',
    ];

    if (empty($my_field)) {
      $form['test']['#wrapper_attributes']['class'][] = 'visually-hidden';
    }

    return $form;
  }

public function ajaxCallback(array &$form, FormStateInterface $form_state): array {
    return $form['settings']['test'];
  }

but my ajaxCallback method never called and the test field is always hidden.


texts: Using hook_user_format_name_alter(), how to change username on user paths?

texts:
I am using hook_user_format_name_alter() to change the way usernames are displayed through my site.

However, on the user paths:

user/UID
user/UID/edit

The page title is set to the username, not the result of hook_user_format_name_alter().

Is there an easy way to override the username here (and preferably anywhere else) and replace it with hook_user_format_name_alter()?

My goto solution would be the Real Name module, but I ran into a bug so I'm trying to do this programatically myself.


texts: How to reset my password if I forgot it?

texts:
I forgot the admin user pass for my site. Then I followed the process to recover my password. I get an email with a link (available for 24hs) which allows me to login in my site. I go to 'user/1/edit' to create a new password, but the old one is a REQUIRED field. This is wrong, I forgot my password, then I can't fill this field.

Am I missing something here??


texts: Programatically change user field (entity reference) in drupalgap with user_save()?

texts:
We are using DrupalGap to make an app. We have nodes (content type chargingstations) which we want our users to be able to "check" into by pressing a button. Until now I have created a button on the nodes page in DrupalGap which executes a function on an onClick event.

This function takes in a NID which is the node I want the user to check into. I then have a field on the user called "checked_in_chargingstation" which is an entity reference field.

In the DrupalGap documentation there is not much information on user_update. It just says "...". But it seems like you can update a node by passing the NID. So I figured I could do the same for user? But it doesen't seem to work. I get a success alert, but I can't see any changes to the users.

My check in code. Drupal.user.uid gets the current users uid.

function check_in($nid){
  var $field_checked_in_chargingstation = {};
  $field_checked_in_chargingstation["und"] = {
    target_id: $nid,
  };

  var user = {
    uid: Drupal.user.uid,
    field_checked_in_chargingstation: $field_checked_in_chargingstation,
  }

  user_save(user, {
    success:function(result){
      console.log(result);
    }
  });
}

In the console I get:

Looking at the json I can see:

"field_checked_in_chargingstation": {
 "und": [
  {
   "target_id": "29088"
  }
 ]
},

But this is the wrong id. This is an old node which I have assigned before from Drupal and "edit" user. So it doesen't seem updated. Trying to drush cc all doesen't seem to work either.

If I try to edit the user from the app I only see null values for the entity reference field. One suggestion in the Drupalgap documentation is to make an entity reference view http://docs.drupalgap.org/7/Entities/Entity_Reference which I also did.

Sorry if this is a bit long. And I'm not sure if I should post it here on Stack Exchange or as an issue on DrupalGap.


texts: Checkbox value incorrect in custom validation

texts:
I have a custom form like this :

public function buildForm(array $form, FormStateInterface $form_state){

      $form['first_name'] = [
        '#type' => 'textfield',
        '#title' => t('First name'),
      ];

      $form['t_and_c_accepted'] =[
         '#type' => 'checkbox',
         '#title'=> t('I accept the terms and conditions'),
         '#return_value' => 1,
         '#default_value' => 0,
      ];
 }

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

          $values = $form_state->getValues();
          if(empty($values['first_name'])){
             $form_state->setErrorByName('[first_name]', t('Fill in a first name'));
          }

          if($values['t_and_c_accepted'] !== 1){
             $form_state->setErrorByName('[t_and_c_accepted]', t('Accept the t&c's);
          }
    }

If I uncheck the checkbox and submit the form, it gives me an error about the unchecked checkbox, as expected.
If I check the checkbox, leave the first_name empty and submit the form, it gives me an error that my fist_name is empty, as expected.
But if I then fill in first_name, UNcheck the checkbox an submit. The validation passes! So not as expected.
If I then go back to the form (back from my landing page), I can reiterate this sequence

I have monitored the $form_state->getValue('t_and_c_accepted') value throughout my tests and it gives me indeed value=1 during the unexpected behavior. So it is consistent with what I see, but I have absolutely no idea what's going on.

So any help would be appreciated

Update:
When looking into the http headers I see that the browser does the POST request with form data t_and_c_accepted:1 while the checkbox is unchecked.

So Drupal's form api seems to handle the request correct, but why does the browser doesn't post the correct checkbox status value ?


texts: How to set different languages for different domains, and display the language switcher accordingly?

texts:
I have a website with different domains and I'd like to have some domains to have different languages.

I have a main site which is example.com, it's the main "group" site, it has multiple languages, in this case french, english, russian and spanish.

Then i have several other "sub" sites assigned to other domains and each have one or many assigned languages.
For example:
es.example.com is in spanish
ru.example.com is in russian

The problem is for a sub site that have more than one language.
for example:
ca.example.com would be in french and english.

How do you configure drupal to be able to achieve this, and how do you make the language switcher display only the languages available on the domain ?

I have domain access and i18n installed obviously.

Thanks in advance for your help.


texts: VBO custom action and submit functions from my module don't get called

texts:
I am trying to make my custom action for View Bulk Operations. My action works up to the point where I submit the form specified in assign_to_action_form. The watchdog statement in that function get's logged, but the ones in assign_to_action_submit and assign_to_action don't get logged. So somehow the rest of the action never gets executed.
Any clues?

The code is below. Just to explain what the action will be doing:
It is a bulk operation that assigns a User entity value to entityreference fields for all selected nodes in the view. It contains an action configuration for VBO specifying which field to fill when the action is executed (function assign_to_action_views_bulk_operations_form), and an action parameter (specified at each execution) specifying the actual User entity to set to the field (function assign_to_action_form).

function various_vbo_actions_action_info() {
    return array(
      'assign_to_action' => array(
        'type' => 'node',
        'label' => t('Assign to user'),
        'behavior' => array('changes_property'),
        'configurable' => FALSE,
        'vbo_configurable' => TRUE,
        'aggregate' => FALSE,
        'triggers' => array('any'),
      ),
    );
}

function assign_to_action_views_bulk_operations_form($options){
    /**
    VBO action configuration form (per view/field)
    */
    $options = array();
    $fields = field_read_fields(array('type'=>'entityreference'));
    foreach($fields as $field){
        if($field['settings']['target_type'] == 'user'){
            $options[$field['field_name']] = $field['field_name'];
        }
    }
    $form = array();
    $form['fieldname'] = array(
        '#type' => 'select',
        '#title' => t('Choose which field to fill.'),
        '#options' => $options,
        '#required' => TRUE,
        '#default_value' => !empty($options['fieldname']) ? $options['fieldname'] : '',
    );
    return $form;
}

function assign_to_action_form($settings,&$form_state){
    watchdog('views','Show form',array(),WATCHDOG_DEBUG);
    /**
        per action (click) configuration
    */
    #$form = array();
    $options = array();
    foreach(entity_load('user') as $user){
        $options[$user->uid] = $user->name;
    }
    $form['uid'] = array(
        '#type' => 'select',
        '#title' => t('Choose which user to assign it to.'),
        '#options' => $options,
        '#required' => TRUE,
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
    );
    return $form;
}

function assign_to_action_submit($form,$form_state){
    watchdog('views','Submit action',array(),WATCHDOG_DEBUG);
    $return = array();
    $return['uid'] = $form_state['values']['uid'];
    return $return;
}

function assign_to_action(&$node,$context){
    watchdog('views','Execute action',array(),WATCHDOG_DEBUG);
    #get settings fieldname
    $field = $context['settings']['fieldname'];
    #get user from context
    $user = user_load($context['settings']['uid']);
    #field_set_value($node,$field,$user);
    drupal_set_message("Got field ".$field." and user ".$user);
}


texts: How do I place super-fish or nice menus in Zen theme main menu?

texts: I have successfully downloaded the super fish module and jQuery and placed the jQuery in the libraries folder. I have also activated the module but am having problems placing the super fish blocks in the main menu of my zen theme. Under blocks, there main menu does not appear so am not sure where to place the blocks so that they appear in the main menu.


texts:
I changed my Drupal 6 website tag structure and got a new URL however old URLs are indexed in Google and are generating 404 errors.

My old URLs are

www.mydomain.com/topics/12345/widget
www.mydomain.com/topics/5783/widget2

numeral - 12345 in this URL was tag no in the database

new URL structure is

www.mydomain.com/topics/widget
www.mydomain.com/topics/widget2

Now I wish to create a redirect so that

mydomain.com/topics/12345/widget

goes to

www.mydomain.com/topics/widget

and remove the random numeral nos in URL.. How to do it?


texts: How do I avoid the HTML I enter is altered?

texts:
I use drupal 8.4.3 with ckeditor 4.7.2 (apparently)

When I press the "source" button, I want to be able to write whatever source I want, in just one line if I want to, I don't want the ckeditor to touch my source code AT ALL.

How is that possible? I think I have used 3 hours googling, without making it work completely.

I want to be able to write "

" without it turning by code into:

 (-- LINE BREAK)

I don't want it to touch it!!! it should just be

 (without the closing /)

when I write into the source, ckeditor shouldn't touch it! How is that possible?


texts: I want to remove the option of request new password from admin section. I have Drupal 8.


texts: How to debug and fix error [fcgid:warn] (OS 109)The pipe has been ended , get overlap result error, [core:error] End of script output before headers

texts:
I’m using :

Drupal 8 on Acquia DevDesktop version 2 with php 7.0.15.
php_mode is set to FAST CGI (mod_fcgid).
Info from the phpinfo() Apache/2.4.18 (Win32) OpenSSL/1.0.2j mod_fcgid/2.3.9

The problem is I’m getting 500 internal errors very frequently.

In the apache log this is displayed for each 500 error log as follows

[Thu Nov 09 09:24:36.140248 2017] [fcgid:warn] [pid 17112:tid 1268] (OS 109)The pipe has been ended.  : [client 127.0.0.1:56192] mod_fcgid: get overlap result error, referer: http://inzicht5.dd:8083/

[Thu Nov 09 09:24:36.140750 2017] [core:error] [pid 17112:tid 1268] [client 127.0.0.1:56192] End of script output before headers: index.php, referer: http://inzicht5.dd:8083/

Therefore I added into php.ini

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

And I added in php.ini

error_log = C:\php_errors.log

Activated error.log in php.ini. Checked by  phpinfo(). But still no php error is shown up. Yes, I restarted the server

I already installed MS distribution C++ 2015 version 14.024215

But still I do not get more information. Also I googled a lot of sites for this error but none of them are giving me directions.

How to get more debug information about this error?
How to solve it?


texts: Can I use multiple if statement in with with same validation?

texts:
Multiple if statement with similar validation will crash(WSOD) my website and I'm not sure if this an expected behavior, meaning what I'm doing is wrong. Or this is a bug, which I should fill into Drupal.org as bug.

Here is my code.

  {%  if page.footer_second and page.footer_third %}
       {% set col_class = 'six' %}

   {# If we have 3 columns#}
   {%  if page.footer_first and page.footer_second and page.footer_third %}
       {% set col_class = 'four' %}

   {# If we have 2 columns#}
   {%  elseif page.footer_first or page.footer_first or footer_third %}
        {% set col_class = 'eight' %}
   {% else %}
        {% set col_class = 'ten' %}
   {% endif %}

     {{ page.footer_first }}

     {{ page.footer_second }}

         {{ page.footer_third }}

    {% endif %}

If I remove one of my if statement my website will not crash (WSOD).

What I'm doing wrong ?


texts: How to only display Second level of menus in Superfish?

texts:
I am using Superfish to display the menus in the left sidebar. I am using the Main Menu navigation structure which only displays the top/first level. In the sidebar, I would like to display only the second level menus. But I cannot figure out how to do this.

At the moment, the complete menu is being displayed...

PS. the reason I am using superfish is because I need the sidebar menu to be able to slide out/drop down menu items.

I have extracted https://github.com/mehrpadin/Superfish-for-Drupal/archive/1.x.zip to sites/all/libraries/superfish I have extracted http://ftp.drupal.org/files/projects/superfish-7.x-1.9.zip to sites/all/modules/superfish I have extracted ftp.drupal.org/files/projects/libraries-7.x-2.1.zip to sites/all/modules/libraries

My superfish menu parent is set to Main menu, Menu depth is set to 2 and Path levels is set to 1.

However, the superfish menu in the sidebar is always the same, regardles of what level of the menu I am in :(


texts: How do I create a Twig override for server 500 error?

texts:
How do I override the template used for a 500 error?
Is there any way to achieve this from a module?


texts:
I have the following code in my custom theme that works well and allows me to test against the multisite_id in my twig files:

function mytheme_preprocess_page(&$variables) {

 $site_path = \Drupal::service('site.path');
 $site_path = explode('/', $site_path);
 $site_name = $site_path[1];
 $variables['multisite_id'] = $site_name;

}

I need the same functionality inside a module.  I can't seem to access the multisite_id var from the module.

I'm new to module development.  I can't seem to get the same preprocess hook to work from my .module file.  Is there a different approach when using a module?


texts: Need help on a callback function with login form

texts:
When a user tries to log into my drupal website, I want to check an external database to see if he is registered there. If he is registered in the external db, an account will be created on Drupal when he logs into Drupal for the first time. This is what I currently have to modify the login form to check the second database and create a drupal account for the user if necessary

function converge_form_alter(&$form, &$form_state, $form_id)  {
  if ($form_id == 'user_login_block' || $form_id == 'user_login') {
    $form['#submit'][] = 'converge_convergeAuthenticate';
  }
}

However, this callback function only gets called on a successful login in Drupal. How can I get the system to run the callback function even if the users password and username are incorrect (and create local account if the incorrect password matches external database)?

I also tried the following code to get the custom function called first but it's not working.

 if ($form_id == 'user_login_block' || $form_id == 'user_login') {
    array_unshift($form['#submit'], 'converge_convergeAuthenticate');
  }


texts:
I'm trying the alter the menu_edit_item (Edit menu link in a menu element) with a module. So far I tried

   function module_name_form_menu_edit_item_alter(&$form, &$form_state, $form_id) {
    $form['additional_desc'] = array(
        '#type' => 'textfield',
        '#title' => t('Additional Description'),
        '#maxlength' => 180,
        '#required' => TRUE,
        '#description' => 'Name of the Additional Description'
      );
   }

But it doesn't work. I'm new to Drupal. Thanks!


texts:
I'm trying to place an image using a local resource in theme. Using the site url like

drupal.localhost/themes/customtheme/images/image.png

does give me access denied error. I understand that Drupal should generate a public url for the image, but how to ask Drupal to do so from the theme while still using relative URLs in src tag of img ?

edit: Changed question, made more clear


texts: How do I pre-configure a block's settings in my module in Drupal 7?

texts:
I'm building up a custom module which contains a few blocks. These blocks will always only appear either on the front page or on every other page, mutually exclusive.

I'd like to be able to pre-configure these blocks on install, but I'm not sure how to go about it.  The documentation for hook_block_configure mentions an '#options' key, but has no details on the format of that info.

Can anyone get me pointed in the right direction here?


texts: How to add a confirmation form upon submission of user profile form

texts:
I have previously added a confirmation dialog to my own forms using a technique like http://blog.purdy.info/2014/04/how-to-work-with-confirmform-in-drupal-7.html.  However this assumes that you have control of the form builder and submit functions.  I now want to add a confirmation to the user profile form which is of course defined in the user module.

Any suggestions ?

Thx


texts: Views: How to list "files" view for their own files?

texts:
I'm working on Workbench module on Drupal 7. There is a "File List" tab and showing all images and files from the site. I would like to change this to be showing their uploaded files only.

PS: the "File List" Tab is from the "workbench_files" Views


texts: Is there a way to get the controller class from a Request object or any other service class?

texts:
My controller class holds some not-so-easy logic to receive some data from a route parameter I need in a block plugin. As this block will only be rendered on this specific route, I would like to simply get the route controller route with this block which would receive its data from the controller.
Is there any way to get the controller class from any of the services like current_route_match?
I can get the route object or the route name, but I didn't find a way to get the controller class.


texts: search and facet api tables dropped during module updates

texts:
We recently added search-api and facet-api functionality to work with a new Drupal 7 view, and now whenever certain module updates are performed using Drush, one or more of the following tables are found to be corrupt or missing:

  search_api_db_00_facet,
  search_api_db_00_facet_field_facetname,
  search_api_db_00_facet_text,
  search_api_db_00_search,
  search_api_db_00_search_text,
  search_api_db_00_facet,
  search_api_db_00_facet_field_facetname,
  search_api_db_00_facet_text,
  search_api_db_00_facet_text_1,
  search_api_db_00_search,
  search_api_index.sql,
  search_api_server.sql

After these tables are restored from backup all is well again. We are using MyISAM table format in the database. No error message displays in the Drupal log until after this has occured. Search module is being used for whole site, while search-api is used for one application. Website is medium sized. The application created by content type and view contains 44,000 nodes. Is this a MySQL problem, such as a need to convert to INNODB, a search-api issue, or a facet-api issue? This doesn't seem to be a common occurrence.


texts:
I'm looking to write a module that automatically uploads the submissions of a webform to an ftp server every week or so.

I'm looking for the recommended way to use the CSV export plugin that comes with the WebForm module to render a csv file to a string. I would want to set the following options:

separator (default is , but should be ; because Europe)
start date and end date of submissions (weekly export)

I see there are a lot of classes and configuration options available, but I'm not sure about the best way to string them together to achieve what I need.


texts: How to perform a redirect after completing a Quiz?

texts: I am using Quiz module. How can we redirect user to thankyou/someother page after clicking Finish button?


texts: Module to turn on/off the whole block region

texts:
My client wants to turn on/off the whole region for block from the drupal menu. Is there some module that can do that?

Right now he must move the all six blocks from that region to disabled area and then he needs to find them and rearange when he want them back and it is not very efficient.


texts:
I would like to enable javascript to be added inside CKEditor. The editor filters all my javascript and I would like to make a transtision from an image to a youtube iframe, here is the code that I am using:

But when I click nothing happens, it filters the "onclick" event and adds a paragraph tag:

I am using CKEditor with the module Wysiwyg.

Thanks in advance.


texts: Create a taxonomy view that links to different photos

texts:
I'm creating a website for a business who sells and installs rail fencing for their clients.

For the fence, there are three different categories of interest:

fence type (2 rail, 3 rail, etc)
fence application (barrier, dog fence, horse fence, etc)
fence material (pressure treated, pine, etc)

I'm trying to create a method of giving the site visitor to choose how they want to look at the pictures.

Each time a fence is installed and photos are taken, I want the business to be able to sign in, create a node called "Photos," Add a title, cover image, body, group of images, and then tag the node using the 3 categories above (on three separate taxonomy lines).

From there, the site would automatically arrange the added photos into the pre-configured view based on its categories.

http://fence.ckasdf.net is the site.

The menu item marked "Photos" shows a view that separates each slideshow by "job" or node called Photos.  This works as expected.

The menu item marked "View: Fence Application" is a view of taxonomy and shows the various applications.  Clicking on each link shows the various nodes (jobs) that have been tagged with that particular application, and clicking on a node shows the picture slideshow.

Instead, after a taxonomy term is clicked, I want it to load a page showing a slideshow that includes all the photos relevant to that taxonomy term.


texts: "Add content" button on related content node?

texts:
Let's say I have 2 content types "Shopping center" and "Shop".

"Shopping center" is a OG group.
"Shop" has node reference field "Shopping center".

I would like to allow moderators to add shops to shopping centers on the shopping center node screen.

How to add "add shop" button on "Shopping center" node view ?


texts: Why is my custom webform submit handler not submitting?

texts:
I've looked at a number of posts, but none of them have quite the same issue as I am. I've added two custom submit buttons to a webform (in addition to the default one created by the admin page.) My custom validate function and submit function are being called, but the default submit function is not - i.e. the error logging I've put in my custom function gets printed, but the form is NOT actually submitted. Any ideas?

function create_vector_user_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
  case 'webform_client_form_24': // free trial webform
    $form['submit']['64_bit_btn'] = array(
      '#name' => 'op',
      //'#button_type' => 'submit',
      '#type'   => 'submit',
      '#value' => t('DOWNLOAD 64-BIT TRIAL'),
      '#executes_submit_callback' => TRUE,
    );

    $form['#validate'][] = 'create_vector_user_free_trial_form_validate';
    $form['#submit'][] = 'create_vector_user_free_trial_form_submit';
    $form['actions']['submit']['#submit'][] = 'create_vector_user_free_trial_form_submit';
    break;
  }
}

function create_vector_user_free_trial_form_validate($form, &$form_state) {
// this function runs correctly

}

    function create_vector_user_free_trial_form_submit($form_id, &$form_state) {
    error_log("submit!");
    if (strtoupper($form_state['clicked_button']['#value']) == 'DOWNLOAD 64-BIT TRIAL') {
        error_log("submitted 64");
    }
    else if(strtoupper($form_state['clicked_button']['#value']) == 'EMAIL ME A LINK') {
        error_log("submitted email");
      $to = $form_state['values']['submitted']['email'];
      $params = array();
      $params['version'] = $form_state['values']['submitted']['download_type'];
      $key = 'homepage';

      drupal_mail('create_vector_user', $key, $to, language_default(), $params);
    }

    else {
        error_log("submitted default 32");
    }

  error_log("test end");

}

ETA: I've also tried this in my form_alter function based on this article about custom validation:

$form['#validate'][] = 'create_vector_user_free_trial_form_validate';
// $form['#submit'][] = 'create_vector_user_free_trial_form_submit';
$first = array_shift($form['#submit']);
array_unshift($form['#submit'], $first,'create_vector_user_free_trial_form_submit');

//$form['actions']['submit']['#submit'][] = 'create_vector_user_free_trial_form_submit';


texts: I'm on drush version 6 & can't do a drush status on my drupal8 site, whats the story?

texts:
drush status says I'm on drush version 6  How can I get drush to work with Drupal8 ?  Do I have to grab a later version of drush directly from github?  Any directions for this?  Thanks.

This is the error message I'm getting when trying to run drush against my drupal8 install:

Drush 6.0 does not support Drupal . See http://drupal.org/project/drush for more     [error]
information.


texts: When I manage fields in content type edition I can put them in order. How could I retrieve this information to use it in a custom module. In Database there is no any column which saves weight order information of fields as they appears in "Manage fields" tab in content type edition.


texts: Create different URL alias based on CCK field

texts:
So I have a typical blog entry content type and I've added a CCK checkbox for some extra functionality. I'm using the pathauto module to automatically set the URL alias for the blog entry content type.

What I would like to do is alter the URL alias created depending on the value of the CCK checkbox. If the box is checked, I'd like to change the URL alias. If not, let pathauto do it.

Possible? Can this be done in the template.php file of my theme?


texts: SearchApiQuery - possible to remove a filter?

texts:
The query parameter that is passed to search_api_query_alter has SearchApiQueryFilter member. It contains a protected array of filter elements. I can add to this by calling the createFilter() and filter() methods, but it does not appear that there is a way to remove a filter through the API.
Can this be done?


texts: Removal of all markup and overall customization

texts:
So, hey everyone, I've picked Drupal for my newest project, and after checking out the code and a couple of case studies. I think that it's a perfect fit, but I have some concerns about the markup and customization.

I like to write my own markup, and hardcode things like menu items, remove unnecessary clutter, most JS, and really just give the website a life of its own.

What I'm really asking is if any of you had done (or attempted to do) a similar thing and if it's possible to remove absolutely all of the markup and JS (I don't really need any JS) Drupal adds to the frontend without breaking things to hell?

I'd appreciate any kind of help or guidance.


texts: Where does the style guide get generated?

texts:
I just enabled the Zen theme, created a new sub theme and ran gulp successfully. On the Zen documentation, it says a gulp task should generate a styleguide for me, but I am not sure what the url is or how to find the generated styleguide.

  Zen now includes a KSS-based living style guide. KSS reads comments in your Sass files and automatically generates a Style Guide that shows how your actual CSS works on your Drupal site.


texts: How to programmatically set a value to a node attribute

texts:
I have a node named let's say "group" to which I added a field called "foo".

How would I programmatically give a value to this "foo" attribute?

I would like to do this when a user is joining a group. This joining process does not involve a saving of the current node, it just add data to a custom table i made. So Hooks don't apply here.

I am guessing i would have to:

1-load the node
2- add data to my attribute
3- resave the node

I am still trying to figure out how to do that, so if anyone has experience to share that'd be much appreciated..

Thanks


texts: Unable to sort view based on search index by taxonomy weight

texts:
I have a search index created using search api and I have a view created based on the search index. I have a taxonomy term field called subscription which is indexed. I need to sort my view based on the subscription field and it should be based on the taxonomy term weight and not by the term name. I am able to add the subscription field in my sort criteria but it doesn't seem to be working the way it is expected.

I referred to multiple links but those seem to work only for views based on content and not based on search index.

How do I sort the view(based on Search index) by taxonomy term weight?


texts:
I want to be able to add arbitrary attributes to rendered view fields.  So for example, I may want to add the attribute itemprop="url" to the rendered A tag for a url field.

I don't want to do this in the actual theming layer - I want to keep it in the view definition.

Is there a way of altering the option forms of any field handlers, so that I can add a new form element that does this.  I would then need to alter the render function to ensure the field is outputted correctly with the new attributes.

So essentially I would want to change the options_form, render functions etc. in the views handler class (e.g. views_handler_field_url.inc).

Any help would be much appreciated.


texts: how do I programmatically save nodes with multiple photo uploads?

texts:
I have a very straight forward content type created in Drupal - Title, Body, Taxonomy term (drop down select, 1 value only), and Photos (multiple permitted, up to 8, alt and title tags are enabled).  I also have the meta

I have a set of CSV files with data for those fields with corresponding photos. I need to iterate over these programatically and use node_save() to get these in the database as well as upload the related photos.

I followed the direction here, and while it was a good start, I am still confused as to how to handle multiple uploads.

Bulk saving nodes with a file field

Can any suggest a tutorial or provide some sample code that can better illustrate how to do this?

EDIT:
Based on the direction below, this is the code I have come up with

$images = array();
foreach ($file_data_array as $csv_data) {
    foreach($image_array as $file_data) {
  $file = new stdClass();
  $file->filename = basename($file_data['filepath']);
  $file->filepath = $file_data['filepath'];
  $file->filemime = $file_data['mime'];
  $file->filesize = filesize($file_data['filepath']);
  $file->uid = $uid;
  $file->status = FILE_STATUS_PERMANENT;
  file_save($file);
  $images[] = array(
    'fid' => $file->fid,
    'alt' => $file_data['alt'],
    'title' => $file_data['title']
  );
}
$node = new stdClass;
$node->type = 'baby_clothes';
$node->body = 'body';
$node->title = 'title';
$node->uid = 1;
$node->status = 1;
$node->active = 1;

//the name of my actual field is 'product images'
$node->field_product_images[LANGUAGE_NONE] = $images;

//this is my actual taxonomy field
$node->field_baby_clothes_category[LANGUAGE_NONE][0]['tid'] = 2; //actual ID of the taxonomy for this node

node_save($node);
}

Thoughts?


texts:
1) Place this module directory in your modules folder (this will usually be
   "sites/all/modules/").

2) Enable the module within your Drupal site at Administer -> Site Building ->
   Modules (admin/build/modules).

I have installed jcarousel module as shown in the above steps.
After that I have create a new views (block) and then added format jcarousel
On the settings I have added auto scroll after 2 seconds
But it does not scroll at all
Also previous and next button when clicked does work

What am I missing?


texts:
I am developing a multilingual site, where the front page outputs the poll block with the following code.

    $block = module_invoke('poll', 'block_view');
    print render($block['content']);

The output does not change when the language changes. How do I translate that output with the i18n module?


texts: Heartbeat module comments collapsed by default

texts:
I set my user's profiles with Heartbeat. At first moment they just look fine but when I open the web to the private beta I realized that when users started to comment nodes, the heartbeat logs of their profiles began to show too much information, they started to look overcrowded. So I have been asking to implement an option to the module core to show the log comments collapsed by default but none has replied.

There is another thread (Display a comment link instead of all the textareas.) on Drupal forums referring to something similar but I don't know how to use that information because I'm a rookie in Drupal hooking & custom modules writing.

Hint: maybe using this code (default option when clicking on Heartbeat comment count)

javascript:Drupal.heartbeat.comments.toggleComments(this, COMMENT_NUMBER); return false;


texts:
Drush version 9.7.0 Drush Launch version 0.6.0 Drupal ver 8.7.3 Open social dist 5.5.

The error I get at the command line when running drush topic or drush cr or any Drush command:

  [warning] Drush command terminated abnormally. Check for an exit() in
  your Drupal site.

I have tried reinstalling Drush, removing and reinstalling, clearing cache via the GUI, but nothing seems to help.

I don't know where to check for an "exit() in your Drupal site".


texts: Cannot alter output of a view under any circumstances

texts:
I am running into a repeat issue with views and the lack of ability to apply or stick additional classes to a field. We have a "view all content" page that renders fields pertaining to a certain content type and its views through a "Custom Text" field and a variety of excluded fields (so we can render them inside our Custom Text field, to better resemble what the front-end team expects). One of these rendered fields is a hyperlink, and the design team would like to see a class added to it so they can limit a broad set of CSS rules for it.

Okay, simple right? Just go into the field, style settings, and customize its HTML. Done, added classes. But they aren't showing up for this hyperlink. I even tried a more untenable approach of applying a class through a tpl.php rewrite and a Regex. But as long as this field is being displayed through a "Custom Text" field, it does not assign any classes.

The design team has informed me there is no other approach for this given the use of Global Text here. Is there any way to alter what the tokens used by other fields in Drupal output in terms of raw HTML markup, including the addition of other attributes such as classes when taking this design approach?


texts: How to add "browse" button in image in CKE Editor?

texts:
I wanted to put "browse" button in image button iframe(pop up).

But I am unable to put it.

How can I change the default behaviour and customize pop up screen in cke editor buttons ?

Thank you...


texts: Adding a validation handler to the registration form

texts:
I have altered the registration form to change the thank you message and add the validation of some fields.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_register_form') {
    $form['actions']['submit']['#validate'][]  = 'checkout_nationality_form_validate';
    $form['#submit'][] = 'thank_on_submit';
  }

All code is working fine; my problem is the registration doesn't take the default Drupal validation. Why does this happen?


texts: What is difference between #value and #markup?

texts:
I had gone through drupal link which contains something as shown below
https://drupal.org/node/224333

Use '#markup' not '#value' for markup

(Issue) The new default type for items in forms or other structured array data (e.g. node content) passed to drupal_render() is '#type' => 'markup'. In Drupal 6 and earlier, the HTML content was added to the array using the #value attribute. In Drupal 7, this needs to be changed to #markup. This change also applies to those form elements of '#type' => 'item'. This change reduces the confusion between form values and markup and allows the code in drupal_render() to be simplified.

Example 1, from system.admin.inc
In Drupal 6:

<?php
  $screenshot = $screenshot ? theme('image', $screenshot, t('Screenshot for %theme theme', array('%theme' => $theme->info['name'])), '', array('class' => 'screenshot'), FALSE) : t('no screenshot');

  $form[$theme->name]['screenshot'] = array('#value' => $screenshot);
?>

In Drupal 7:

<?php
  $screenshot = $screenshot ? theme('image', array('path' => $screenshot, 'alt' => t('Screenshot for %theme theme', array('%theme' => $theme->info['name'])), 'attributes' => array('class' => 'screenshot'))) : t('no screenshot');

  $form[$theme->name]['screenshot'] = array('#markup' => $screenshot);
?>

I have a code in drupal 6 which is as shown below :

$form['in_title'] = array(
  '#type' => 'button',
  '#value' => t('ort'),
  '#executes_submit_callback' => false,
  '#attributes' => array('class' => 'hide-submit-exclude'),
);

I want to convert this code to D7 .
So When and where should I use #markup and #value ?
I just want to know the difference between #markup and #value


texts: suggestions needed to define a class for field per entity/node

texts:
Im not sure the best way to go about this, and not so much a big programmer...

I would like to let the node creator decide whether the image in the image field should be top, left, or right. So i simply want to add class to the image div somehow.

So there should be a way to grab that info, maybe a "list" field?

Now, how to get that info over the image field?

Im thinking something like a field template for the image field (using media module)... or maybe something i heard about preprocessing in template.php?

pointer and tips appreciated!


texts:
I am using the filedepot module. With this module I am able to upload files. I want to allocate space for "uploading files" to individual registered users basing on user roles.

Is it possible? How do I do it?


texts:
I am using twig tweak to embed a view in node.tpl.twig

{{ drupal_view('testview', 'block_1', '12') }}

how can I pass current nid {{ node.id() }} as argument instead of static '12' in this case?


texts: How to track user node views and quiz results

texts:
I am searching for the easiest way to track wether particular user has read particular group of nodes (training material) and did the quizes that are related to those nodes. In success case I would like to grant user some points and a badge and for the site administrator to have a list of all the training material with "read"/"not read" results per user. I know that there could be various ways to do this, but I am not sure, which one would be the easiest one.

using Goals + Rules (but I can't find how exactly can I track wether user has visited particular node).
using Activity module?
using Heartbeat module?

None of these looks like it is possible to do such thing without coding, or I am missing something?

thanks!


texts: Registering User Programatically with only Email Address

texts:
My Drupal 7 site utilizes the email_registration and logintobbagan modules. It works fine to register users with just their e-mail address. However, on a separate page I am using a newsletter subscribe form called 'news_subscribe' which is of the following form:

function news_subscribe_form($form, &$form_state) {
    $user = $GLOBALS['user']->mail;
    $email = "";
    if(!empty($user))
    {
        $email = $user;
    }
    $form['email'] = array(
        '#type' => 'textfield',
        '#title' => t('E-mail'),
        '#required' => TRUE,
        '#default_value' => $email,
        '#size' => 20,
        '#maxlength' => 20,
        '#element_validate' => array('news_subscribe_email_element_validate'),
    );
    $form['id'] = $id;
    $form['submit_button'] = array(
        '#type' => 'submit',
        '#value' => t('Subscribe!'),
    );
  return $form;
}

By default this then submits the data to the drupal databases and saves the values for the given user if they are already registered in our system via hook_form_submit().

function news_subscriptions_form_submit($form, &$form_state) {
    //Get the values
    $email = $form_state['values']['email'];
    $id = $form_state['build_info']['args'][0];
    $uid = $GLOBALS['user']->uid;

    //Get the database information
    $collection = variable_get('mongo_user_preferences_collection',DEFAULT_USER_PREFERENCES_COLLECTION);
    $savedarrayname = variable_get('mongo_saved_data_array',DEFAULT_SAVED_DATA_ARRAY);

    //Generate the conditions and queries
    $where = array("uid"=>intval($uid));
    $query = array($savedarrayname=>$id);

    //Insert the data into the datbase
    upsertData($where,$query,$collection,$database=NULL);
}

If the user is not currently registered in the system I need to first automatically register them and then retrieve their user id. I know that normally I can use a function such as

$new_user = array(
  'name' => 'JohnDoe',
  'mail' => 'john.doe@email.com',
  'pass' => 'password123',
  'status' => 1,
  'field_custom_first_name' => array(LANGUAGE_NONE => array(array('value' => 'John'))),
  'access' => REQUEST_TIME,
  'roles' => array(), // No other roles than Authenticated
);
user_save(NULL, $new_user);

However, I want to integrate it with the current setup which requires just an email address, auto generates a password and then sends a mail to the user with a temporary login link where they can change the password. This is the current setup on the user registration form. I have been looking for a hook into the email_registration module but cannot find one. Can anyone provide some insight?

Basically I am trying to register a user from a non-registration form (if they are not already registered). I then need to retrieve their assigned uid which is used in subsequent post-processing.


texts: Replace data from command line: site name

texts:
I run in mysql:

update variable set value = replace(value,'SiteName','NewName');

and then clearing cache:

drush cache-clear

But I dont know why the site name become blank instead of NewName

I've tried this after replace in variable table, but not works:

update cache set data = replace(data,'SiteName','NewName');

I hope I can change any data from command line.


texts: Show taxonomy term for administrators only in node creation form

texts:
I have a content type Topic. The topic has the taxonomy terms -health -fitness and -news. I only want certain roles like administrators to be able to see and use the taxonomy term - news when creating topics. I need all other users to only see and use the other two.

How do I go about this? Would hook form alter be the right direction?


texts: How do I solve the "table '.cache' doesn't exist" error?

texts:
My friend's site shows the following error message:

  user warning: Table '.cache' doesn't exist

I am working with zero documentation pertaining to the previous person's work on the site; I'm not sure what has been mucked around with.

How can I fix this?


texts:
I created one custom module for rest server, i created own resources and i want to be able to cache index request, for return a 304 with using http request if - headers.

I cannot find information on how to do it.


texts: URL alias with multi-lingual site access doesnt work

texts:
i have two systems, one live system and a local one, which are almost the same configured.

i have a node which is in english (/testEN) and basic translated in german(/testDE). if i call on my local system localhost/testEN the page changes its language to english and it goes to the node. if i call localhost/testDE the page changes to german and redirects to the german node.

on the live system i need to write before the URL the siteaccess e.g. www.examplepage.de/en/testEN or www.examplepage.de/de/testDE.

if i just call www.examplepage.de/testDE the site gives a 404 PAGE NOT FOUND.

From where comes this diffrence? why doesnt drupal recognize the URL alias with the node translation like in my local system?
is there any setting i didnt see?

any solution would be nice.


texts: How do I migrate the file attachments field from a content type?

texts:
My Drupal 6 site has different content types, and there is a File Attachments field added to the content types. While migrating to Drupal 8.1, this field is not getting migrated, but the attached file is present in the files directory. While doing the migration, it is displayed that the "upload" module in Drupal 6 has migration path, yet it is not migrated.

How can I migrate the file attachment field to Drupal 8?


texts:
I am building a site selling engineering components. There are many Variations of some of the products but each variant looks almost identical.

Would I be better placed having an image field for each variant or just one image field in the product type?
If I go down the 'image field in the variant' option, then each variant would have the exact same image; yet, this doesn't strike me as sensible.


texts: Drupal 7 theme('pager') -> PDOException: SQLSTATE[42S02]: Base table or view not found

texts:
first time i have asked for help on a forum for a very long time. Normally find what i need by viewing other posts... Well i'm really confused so need help.

I am trying to use theme('pager') in Drupal 7 to have pagination for my table results i get from a db_select query.

The below query produces an error when i include the line:

$output .= theme('pager');

If i leave this line out i get the expected limited 5 results from my table.

My code:

// Set external databse
db_set_active('nondrupal');

// build query to get desired results
$query = db_select('diary', 'n')
->fields('n', array('photo_id', 'photo'))
->orderBy('photo_id', 'DESC');

//Create a new object from extend. The reason for this is that extend() creates a
new object which wraps the current object (Decorator pattern).
$query = $query->extend('PagerDefault')->limit(5);

// Execute query and add to array
$result = $query->execute();

// empty output var
$output = NULL;

// Loop through results and output each row for chosen columns
foreach($result as $row) {
$output .= $row->photo_id.': '.$row->photo.'<br />';
}

// Show pagination in output
$output .= theme('pager');

// echo output to screen
echo $output;

// Set db connection back to default (drupal)
db_set_active();

The page renders fine without the theme('pager') line.

With it i get an error:

Additional uncaught exception thrown while handling exception.
Original

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table
&#039;dbMYDATABASENAME.semaphore&#039; doesn&#039;t exist: SELECT expire,
value FROM {semaphore} WHERE name = :name; Array ( [:name] =&gt;
theme_registry:runtime:garland:cache ) in lock_may_be_available() (line 167
of /homepages/28/d228752694/htdocs/drupal7/includes/lock.inc).

Base table or view not found seems to be the key but i cannot see why including the    theme function causes this error. I have a basic Drupal 7 install.

Your help is appreciated!

Madmilner


texts: how to override module's theme function in a custom module?

texts:
I'm a Drupal8 newbie. I installed a third party module simplelogin, and I attempted to change the {{site_name}} value in page--simplelogin.html.twig but can not find a right way.

I noticed that the variable is defined in simplelogin.module:

function simplelogin_preprocess_simplelogin(&$variables) {
  $path = \Drupal::service('path.current')->getPath();
  $module_path = drupal_get_path('module', 'simplelogin');

  $variables['#attached']['library'][] = 'simplelogin/simplelogin-library';

  // Able to use custom variables
  $variables['path'] = $path;
  $variables['base_path'] = base_path();
  $variables['logo'] = file_url_transform_relative(file_create_url(theme_get_setting('logo.url')));
  $variables['background_class'] = simple_login_settings('active');
  $variables['background_opacity'] = simple_login_settings('opacity');
  $variables['wrapper_width'] = simple_login_settings('width');
  $variables['site_name'] = \Drupal::config('system.site')->get('name');
  $variables['site_register'] = \Drupal::config('user.settings')->get('register');
}

I guess the second "simplelogin" presented in the hook function is a form element in the theme (I'm not quite clear although), as I found $form['simplelogin'] appears in the buildForm function of form controller.

  public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {

    $form_state->disableCache();

    $simplelogin_config = $this->config('simplelogin.settings');

    $imageid = $simplelogin_config->get('background_image');
    if ($imageid) {
      $file = \Drupal\file\Entity\File::load($imageid[0]);  // File Load
      $fileUrl = $file->getFileUri();

      // check if image is valid.
      $image = \Drupal::service('image.factory')->get($fileUrl);
      if ($image->isValid()) {
        $image_render = array(
          '#theme' => 'image_style',
          '#width' => $image->getWidth(),
          '#height' => $image->getHeight(),
          '#style_name' => 'medium',
          '#uri' => $fileUrl,
        );
      }
    }
    //$renderer = \Drupal::service('renderer');
    //$renderer->addCacheableDependency($image_render, $file);

    $form['simplelogin'] = array(
      '#type'            => 'details',
      '#title'           => $this->t('Configuration'),
      '#open'            => TRUE,

      'background_active' => array(

WHAT I HAVE DONE:
                                                                                1. created a custom module named "mylogin", this is the info.yml:

name: myLogin
description: my login module
type: module

version: '8.x-1.0'
package: 8.x
core: '8.x'
project: 'mylogin'

dependencies:
  - simplelogin

2. override hook_preprocess_page in mylogin.module:

use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\file\Entity\File;
use Drupal\Core\Controller\ControllerBase;
use Drupal\simplelogin\Controller;

function mylogin_preprocess_page(&$variables) {
  if (\Drupal::routeMatch()->getRouteName() == 'user.login') {
    $variables['site_name']= 'test';
  }
}

But it cannot work, and I believe the preprocess is not triggered. Is there a simple way to override the needed variable while keep the others in the module's preprocess function? Any help will be very appreciated.


texts: Drupal 7 - Multi Step Registration with save on end

texts:
I have been looking through some tutorials, but couldn't find what i wanted to accomplish.

The thing i can't find in any tutorial/resource is the ability to save users registration data on the last step.

What i want to accomplish is to display a registration page for users, and the user goes through 3 steps.

Step 1 - Registration info
Step 2 - Payment Info
Step 3 - Save and show custom message

Can some one post some good resource, where it shows how to do this.. Preferably with explanation so i can learn from it.

The tutorials i followed so far were saving after the first submit.

Thanks in advance


texts: Can I create a form with a route like this /rooms/{node.alias}/booking?

texts:
I'm working on a booking project and I have to create a form for reservations.

I have created the accommodation content type and the url_alias for this is: /rooms/[node:title]

Example:

/node/1 = /rooms/1-accommodation-example
/node/2 = /rooms/2-accommodation-example

I need to know if I can do this:

booking.booking_form:
  path: 'booking/{url_alias}'
  defaults:
    _form: '\Drupal\booking\Form\BookingForm'
    _title: 'Accommodation booking'
  requirements:
    _access: 'TRUE'

Is this possible? path: 'booking/{url_alias}' or path: '{url_alias}/booking'

What happen next, if you try yo go to this route:

/booking/any-text-asdasdas = the form page is loaded.
/booking/rooms = the form page is loaded.
/booking/rooms/1-accommodation-example = page not found.

I tried but I don't know how to find information about this way of routing.

I don't know if I have explained what I need well, any information will be very helpful.

Thanks,STF


texts: What is the difference between KPR() and DSM()

texts: I am learning advanced theming for which I am using Devel Module kpr() and dsm() functions to print the arrays on the page for finding variables. So I want to know, What is the main difference between kpr() and dsm() functions? And which one is the best for which condition.


texts: Can you create a script to programatically run update.php on multiple drupal sites

texts:
We have a multi-site install that uses the same core files but different databases.  As of right now, we have over 40 sites. When I do module and core upgrades, I have to login to each site and manually run update.php.

Is there a way to automate this process so that I do not have to spend so much time logging into every multisite, run update.php and clear the cache?  If so, what is the exact command to run update.php? I've tried wget and that doesn't seem to work.


texts: Add taxonomy terms to search autocomplete

texts:
I have a Drupal 8 website with default search bar in my homepage. I have installed the Search Autocomplete extension to extend its functionality. Everything works great, except it does not suggest taxonomy terms. Can you give me an idea to add taxonomy terms to its suggestions?

Update:

I'm sorry that this is not the question I suppose to ask, as I have mistaken the issue. The default search block, does not search taxonomies, but search for the content which belongs to that taxonomy. Let me show you an example:

Here the Vancouver is a taxonomy term, and the things that listed(ZHR DEL, Gas Town, etc.) are content which belongs to this term. If you type the same thing in autocomplete, it does not suggest above content nor taxonomy term.

What I want is to suggest the taxonomy in autocomplete, and show the taxonomy term in the search result. Any help is truly appreciated.


texts: Simplest way to translate just date and time

texts:
I have a website running on Drupal 8, it a single language website, content is not English but i build on default Drupal, that mean everything is English, except content i write.

In some views, i'm using date and times formats to provide the time my content event will happen. But time&date provide by Drupal is English, like : Wednesday, December 28, 2016

So i need to translate it to my language. It is only thing i need to translate.

I try to follow official way, creat my language in Regional and language setting, enable Interface Translation, upload my language .po file from localize.drupal.org, change default language to my language, booom, date now show in my language very nice, but, everything messed up.

URL broken, title, desciption, tag, meta tag .... everthing become a mess. That mean i need to reset everything, what content not set language will need set, URL need to be update, .....

I mean why i need to do a ton of job and change a lot of thing in my site to do a just simple job : Change 'December' to 'Tháng Mười Hai'

So i wonder, there is someway easier to do that job? Keep my site simple, English by default.

I thinking about translate it by javascipt but it not good for SEO and it is a dirty way. Please help me.


texts: Exposed view filter is not rendered properly

texts:
I have a view with a filter "Has taxonomy term", this filter is an exposed filter and is set to be a "Dropdown" and "Show Hierarchy"

The vocabulary has parents and children term (hierarchical).

The filter works fine but the html tags of the select dropdown are incorrect. The parent terms should be wrapped in  instead of  (see image 2)

Can I override this?

I trying to do it with hook_form_alter() but I see that the construction of the select itself is done by drupal_map_assoc() function. Then I see no way to do it? Can I put the value for '#options' in other way?

<?php
  $form['undergraduate']['school_country'] = array(
    '#type' => 'select',
    '#options' => drupal_map_assoc(array(t('UK'), t('Other'))),
    '#title' => t('In what country is your college or university located?'),
  );
?>


texts: in product title on new product type drupal commerce kickstart

texts: I created a custom product variation called Switch Plate and on the product displays it is showing Product Name on the title I installed from the 2.0 version of Commerce Kickstart it only shows on my product not on the 2 generated products.


texts:
I've created a views block that loads all nodes of a certain content
type.
I've added the Content: Has taxonomy term ID contextual filter

This works great. In the preview area if I change the value in the "preview with contextual filters" input field it changes the nodes that load below according to which taxonomy term ID I input.

How can I have this same functionality on a normal Drupal page?

I will have a list of links on the page with an href value of the taxonomy term ID. When I click a link, I need it to load all nodes that have been associated with that particular taxonomy term into an empty div using AJAX.

I've read somewhere on here that if the nodes just contain some basic text then using a pure AJAX solution might not be the best but rather accomplish the same thing using views.


texts: Field group horizontal tabs are displayed as accordions in small screens

texts:
On Drupal 8 site using the default Bartik theme, I have setup the article content type to be displayed in horizontal tabs based on the "field group" module.

On normal/large screens, the article display page is rendered in horizontal tabs style (Good!):

However, in small screens, the article display page is rendered in accordion style (Not good!):

I have found an answer here Horizontal Tabs rendered as rendering collapsible fields which is for Drupal 7 and I didn't know how to convert it to work for Drupal 8.

Does anyone have an ideas how to keep the article display rendered as horizontal tabs for whatever screen sizes?


texts: Link pages from a child term to it's parent

texts:
I have really two questions in one. I have pathauto make a page for all my terms. I have something like this:

USA
-NY
-NJ
-LA
UK
-London
-Hogwarts
-Manchester
France
-Paris
...

Anyway pathauto made pages for all the terms, so I have site/USA , site/USA/NY etc. I want to make it so that site/USA/NY has a link to it's parent which is site/USA. Is there any way to do this?

Another question, I'm also using the hierarchical select plugin to make a user select the deepest child possible (in this case just one level in). When a user tags content with NY, I also want that content to be tagged with USA, is that possible?


texts: How to resend same newsletter from Simplenews?

texts:
I'm using simplenews module in Drupal 7. Also I have working mailing system as well as Cron system. I want to resend the newsletter that has been sent previously. I don't want to edit the database every time for resending. I want to send newsletter using user interface itself.

I tried editing simplenews.module and simplenews.admin.inc files.

I edited simplenews.module

/**
* NEWSLETTER SENT STATUS
*/
define('SIMPLENEWS_STATUS_SEND_NOT', 0);
define('SIMPLENEWS_STATUS_SEND_PENDING', 1);
define('SIMPLENEWS_STATUS_SEND_READY', 0);
define('SIMPLENEWS_STATUS_SEND_PUBLISH', 3);

But as I edited for SIMPLENEWS_STATUS_SEND_READY, it started giving me notice in the admin panel stating:

  Notice: Undefined offset: 2 theme_simplenews_status() (/home/#####/public_html/#######/sites/all/modules/simplenews/includes/simplenews.admin.inc file row number　1776 ).

But I couldn't edit simplenews.admin.inc file. And in the newsletter sending option it shows following message but don't send message when I run Cron:

  This newsletter is pending

Please help if someone has faced the same issue.


texts:
The main menu at my Drupal 7.2 site is represented as tabs. I wonder please, how could I add an image to one of the tabs - for example a letter-icon for the last /contact tab?

When I look at the HTML code I see that tab as a class="menu-276 last" list item:

Основные ссылки

Преферанс

Как играть

Рейтинг

Форум

Этюды

Письмо админу

How would you be adding an image there, through editing the core Menu module or maybe there is a nicer way? (a CSS-solution would be ok too...)

Thank you!
Alex


texts: How do I intercept a press on "Save" and get the nid?

texts:
I want to get hold of the nid of the newly created node whenever a new node or comment is created by a user by pressing "Save" (and only when the user press "Save" - not when the node is created or saved by other means).

I've tried to create a custom submit handler to intercept the save by means of a custom submit handler:

$form['#submit'][] = 'mymodule_node_submit';

This handler intercepts the press on the "Save" button, but it is invoked too early. The nid of the node it is not yet available inside the submit handler.

What is the correct way of getting the nid whenever a new node is created by an interactive user?

I know there is a similar question here: Get node id of saved node - but the accepted solution (use hook_node_update()) is not correct.  hook_node_update() will also intercept calls when nodes are created programatically (for instance by the Feeds module), when there is no real user involved.


texts: I've turned on the setting that allows "alt"'s for many images in Drupal 7. But the alt field doesn't show up for a lot of images, like the ones displayed. Is there any way to display alt field's for them?


texts: 7 Ubercart - Notify Customer Shipping when Product Ships

texts:
For our site, we process payments by performing a Capture on the PayPal site. Soon after, we pack and ship the order.

Does Ubercart provide a means for notifying the customer (via a button click somewhere in the admin site), via a pre-defined email, that the product has been shipped?


texts: Update existing field collections with Migrate module

texts:
How can I update existing field collection entities using Migrate module? I wasn't able to find any examples at the official documentation page, nor anywhere else.

When I'm migrating nodes, I can do something like:

$this->addFieldMapping('nid', 'nid');
$this->systemOfRecord = Migration::DESTINATION;

What's the alternative in this case?


texts: Why is my Ajax callback not returning anything?

texts:
I'm implementing an ajax callback function whats the issue with my code not returning anything.  I'm new to backend

  <?php
use Drupal\node\Entity\Node;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\Query\QueryFactory;

use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;

/**
 * Implements hook_form_alter().
 */
function hook_form_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'webform_submission_go_to_csv_import_add_form') {
    // Choose for "Featured Type" field "N/A" value by default.
    $form['elements']['name']= [
      '#type' => textfield,
      '#title' => 'sammy',
      '#ajax' => [
                'callback' => '::some_ajax_sample',
                'wrapper' => 'edit-name',
                'event' => 'keyup',
                'progress' => [
                  'type' => 'throbber',
                  'message' => 'loading.....',
                ]
              ],
            ];

  }
}

function some_ajax_sample(array &$form, FormStateInterface $form_state) {

  $response = new Response($form['elements']['name']['#title'] = 'Test');
    return $response;
   }


texts: How to create a pie chart using the chart module in Drupal 7?

texts:
I'm trying to create a pie chart using the chart module. I was able to create a pie chart that looks similar to the pie chart shown on https://developers.google.com/chart/ . But I am not getting any percentages.

My Question: What is needed to also show those percentages, or what might I be doing wrong)?

Note: I cannot do those interactive additions, but I can live without them.


texts: How to define custom date format in page.tpl.php?

texts:
I would like to add a custom copyright footer to my site e.g. MONTH YEAR. I have set up a »short« date format for English, French and German in admin/config/regional/date-time/locale. Using <?php print format_date(time(), 'custom', t('F Y')); ?> in page.tpl.php is working great.

However I would love to go one step further. How do I print the short date format to page.tpl.php instead of adding them to *.tpl files separately?


texts:
Is there any kind of cache applied to the Modules?

I am developing a module but I am not able to see the last changes I made (Adding a new Role programmatically), even after cleaning all caches.

install code (update):

function nutrition_install()
{

    //Create New Role
    $role = new stdClass();
    $role->name = 'nutricionist';
    $role->weight = 1;
    user_role_save($role);

  node_types_rebuild();
  $types = node_type_get_types();

 // add the body field to the node type
  node_add_body_field($types['meal']);

  // Load the instance definition for our content type's body
  $body_instance = field_info_instance('node', 'body', 'meal');

  // Configure the body field
  $body_instance['type'] = 'text_summary_or_trimmed';

  // Save our changes to the body field instance.
  field_update_instance($body_instance);

  // Create all the fields we are adding to our content type.
  foreach (_meal_installed_fields() as $field) {
    field_create_field($field);
  }
  // Create all the instances for our fields.
    foreach (_meal_installed_instances() as $instance) {
        $instance['entity_type'] = 'node';
        $instance['bundle'] = 'meal';
        field_create_instance($instance);
    }
}


texts: Is it necessary to use cache in hook_init?

texts:
I wonder, since hook_init doesn't run on cached pages, is it useful to use cache_set in a hook_init() ?

I am going to retrieve an array of strings from the database on each page request (not on cached pages obviously), so I am wondering how to do it properly. For this purpose, should I use cache_set, a persistent variable or maybe no cache at all in hook_init ?


texts:
I am using the Gratis theme, but there is a little problem.

Here is the screen shot of the block region demonstration:

Yellow are the regions. I want to make the 1,2,3 marked area into one top nav where I have logo, main menu and other links. How to do that?

The main menu (third party system) is a different area. Say 4th area. Not concerned with that.

Here is the page.tpl code for these top 3 areas

`

  <?php if ($page['top_links']): ?>

      <div class="l-top-wrapper l-setwidth" <?php if (!empty($set_width)) : print 'style="max-width:' . $set_width . ';"' ; endif; ?>>

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

  <?php endif; ?>

    <header class="l-header l-setwidth" <?php if (!empty($set_width)) : print 'style="max-width:' . $set_width . ';"' ; endif; ?>>

      <?php if ($logo): ?>

          <a href="<?php print $front_page; ?>" title="<?php print $site_name; ?> » <?php print $site_slogan; ?>">
            <img id="logo-img" src="<?php print $logo; ?>" alt="<?php print $site_name; ?> » <?php print $site_slogan; ?>"/>

        <?php endif; ?>

      <?php if ($site_slogan || $site_name) : ?>

            <?php if ($site_name) : ?>

                <a href="<?php print $front_page; ?>">
                  <?php print $site_name; ?>

          <?php endif; ?>

              <?php if ($site_slogan) : ?>

<?php print $site_slogan; ?>

            <?php endif; ?>

        <?php endif; ?>

    <div class="l-setwidth" <?php if (!empty($set_width)) : print 'style="max-width:' . $set_width . ';"' ; endif; ?>>

      <?php if ($main_menu): ?>
        <?php print t('Show Navigation'); ?>

          <?php print t('Hide Navigation'); ?>

            <?php print render($primary_nav); ?>

      <?php endif; ?>`


texts:
Say one needs to alter a form with a dynamic id, for example nodequeue_arrange_subqueue_form_12, where 12 is the dynamic element of the $form_id, is there a way to target this type of form_id? Some sort of wildcard?

I have resolved to using the following:

if (strpos($form_id, 'nodequeue_arrange_subqueue_form') !== false) {
  $form['add']['nid']['#size'] = 90;
}

Seems there must be a cleaner more "drupalish" way of doing this.

Is there a way to use hook_form_FORM_ID_alter() form of form_alter?

UPDATE:

Nevermind, hook_form_BASE_FORM_ID_alter() works fine even without the dynamic placeholder.
Left the post in case anyone stumbles here with the same question.


texts: Rewriting Views results with tokens on multi field

texts:
I need to write a paragraph laced with field values from a result from a view.  For example, "Our camera case works with model ABC, 123, and XYZ", where ABC, 123, and XYZ are 3 out of multiple results values for that field.

Can I use tokens to achieve this?