texts:
in my store, I want to set the products price without decimals,
e.g. "$500.00" ==> "$500"
I put following codes in the template.php:

function roomify_travel_commerce_currency_info_alter(&$currencies){
  $currencies['TWD']['format_callback'] = 'roomify_travel_commerce_currency_format';
}

function roomify_travel_commerce_currency_format($amount, $currency, $object = NULL, $convert = TRUE) {
  $price = number_format(commerce_currency_round(abs($amount), $currency), 0, $currency['decimal_separator'], $currency['thousands_separator']);

  $replacements = array(
    '@code_before' => $currency['code_placement'] == 'before' ? $currency['code'] : '',
    '@symbol_before' => $currency['symbol_placement'] == 'before' ? $currency['symbol'] : '',
    '@price' => $price,
    '@symbol_after' => $currency['symbol_placement'] == 'after' ? $currency['symbol'] : '',
    '@code_after' => $currency['code_placement'] == 'after' ? $currency['code'] : '',
    '@negative' => $amount < 0 ? '-' : '',
    '@symbol_spacer' => $currency['symbol_spacer'],
    '@code_spacer' => $currency['code_spacer'],
  );

    return trim(t('@code_before@code_spacer@negative@symbol_before@price@symbol_spacer@symbol_after@code_spacer@code_after', $replacements));
}

then the price became correct, but my admin page was broke!
and apache error log showed:

[Thu Feb 09 07:20:41.168665 2017] [proxy_fcgi:error] [pid 25564:tid 139845024192256] [client **.**.**.**:40368] AH01071: Got error 'PHP message: PHP Fatal error:  Call to undefined function mytheme_currency_format() in /opt/bitnami/apps/drupal/htdocs/profiles/roomify/modules/contrib/commerce/commerce.module on line 641\n', referer: http://**.**.**.**/drupal/?q=admin

please tell me where I went wrong! thank you!!


texts: Panels: Targeting content to panel-2 from submenu placed in panel-1

texts:
On my site in Main Menu among other links I have a link called Photos that leads to photos.

In Taxonomy I've created vocabulary Photocategory to categorize my Photos.

I want to create Page (for photos) that have two regions:
(1) In first region I would like to have a list of Photocategories linked to each photocategory plus some custom links.
(2) Second region would be the place where items from chosen photocategories (listed in first region) will be displayed.

For first region I am using "My Menu" with dynamically generated Photocategories links (by Menu Views Module). This solution gives me ability to add pages like photos-home-page and photos-info-page to "My Menu"

Second region would be a "landing region" for links from "My Menu"

I have started by crating Custom Page with panelized regions, one region for "My Menu" and second region for as "landing region". But from this point I don't know how to tell Drupal to:
(a) relate/connect links from My Menu to "landing region"and how to:
(b) choose position from "My Menu" to be displayed as default/home for this "panelized Custom Page structure"


texts: Recommendation for modules/workflow to build a premium link directory

texts:
I'm just about to start building a link directory and I'm at odds over the best way to go about it.

The directory will accept both standard (free) and premium subscriptions. Premium subscribers will have extra fields available to them to fill out and display on their 'profile' page (standard link directory model I guess).

The front-end directory itself will be based on taxonomy/views so that's not an issue, but I'm struggling with the best way to handle the subscriptions. Conceptually I guess I would be selling access to a user role for a limited period of time, and showing/hiding various fields on the profile form based on the role's permissions.

I'd prefer to use Commerce and I'm struggling to find a stable module (or example using rules) that would help me plan out this subscription system.

Has anyone built a similar system before? If not can anyone think of a good collection of modules/workflow to accomplish this? I'm happy to write as much custom code as is needed but I'd rather not reinvent the wheel where possible, and it seems like Drupal is made for this kind of thing.

EDIT

Following Patrick Kenny's comment I should add that I don't need these subscriptions to recur automatically, just for the access to the role to expire after a certain amount of time.

If this will be difficult to do with Commerce I'd love to hear any other ideas (Ubercart, etc).


texts: Escape of Upscaling image in Scale and Crop option

texts: I am using Image Style with Scale and Crop option with the dimension 110 * 110. If the style applies on small image it upscales the size to 110 * 110. I don't want to upscale it. How to do that?


texts: Content From Another Page Displaying on Current Page

texts:
I created a piece of content called training that is supposed to display all training content offered. Instead of displaying only training content it is displaying articles, news content within the page.

Could someone steer me in the right direction in order to solve this issue? I'm a bit new to Drupal so I am still learning my way around. Thank You.


texts: Drupal 7.27: 408 Request time out in Chrome browser

texts:
We are getting 408 request time out errors in Chrome browser only since the beginning of May. We have not been able to replicate the problem with any other browser. With one website we had a SSL protocol and the error only occured in Chrom on http://
After implmenting a redirect from http:// to https:// via .htaccess the error seemed to have gone.
On a second site there is no SSL certificate and the error only occurs occasionally but it does. We have set the request_time_out to 10080 in the php.ini to no avail. Another thing we tried: We redirected that site to be accessed only with "www".

Has anyone experienced something similiar? Any suggestions would be very welcome.


texts: How can I view the IP addresses of visitors who view the home page of my site?

texts:
I need to gather the IP addresses of visitors who view the home page of the site. There are bots that bounce off of the home page thousands of times a day. The Statistics module makes the site too slow. I also tried the Visitors module which worked pretty well, but there was no way to reduce the results only for the home page. Is there an another way to exclusively view IP addresses that visit the home page?

Edit: A way that doesn't slow the site down with a lot of database writing.


texts: How to make progress_message more accurate?

texts:
In the submitForm of MembershipSettings, I run a batch:
      $operations = [];

      << some query on an custom entity >>
      $results = $query->execute();
      foreach ($results as $key => $result) {
        $operations[] = ['\Drupal\association\Form\MembershipSettings::updateMember', [$result]];
        $iNumber++;
      }

      $operations[] = ['\Drupal\association\Form\MembershipSettings::updateUsers', []];

      $batch = [
        'operations' => $operations,
        'title'      => t('Renew membership: Period Closure'),
        'init_message' => t('Process is starting...'),
        'progress_message' => t('Processed @current out of @total. Estimated remaining time: @estimate.'),
        'finished'   => '\Drupal\association\Form\MembershipSettings::endofPeriodClosure',
      ];
      batch_set($batch);

  public static function updateMember($result, &$context)
  {
    << run some code on each Member >>
  }

  public static function updateUsers(&$context)
  {
    $id = $user->uid->value;
    if (empty($context['sandbox'])) {
      $uids = Drupal::entityQuery('user')
       ->condition('roles', 'member')
       ->execute();
      $context['sandbox']['progress'] = 0;
      $context['sandbox']['max'] = count($uids);
      $context['sandbox']['$uids'] = array_values($uids);
    }
    $uid = $context['sandbox']['$uids'][$context['sandbox']['progress']];
    $user = User::load($uid);
    if ($user) {
      $user->removeRole('member');
      $user->save();
      $context['results']['user'][] = $uid;
      $context['sandbox']['progress']++;
      $context['message'] = t('Updated user @num of @max.', ['@num' => $context['sandbox']['progress'], '@max' => $context['sandbox']['max']]);
    }
    if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
      $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
    }
  }

In updateMember(), I load the content entity to update it.
In updateUsers(), I first retrieve all the relevant users, then in the successive calls, I remove a specific role from the user.
Lets say that in updateMember() I have 20 iterations and in updateUsers() I have 200 users.
progress_message is not reflecting the reality: it says that @total is 21 which is (and I get it) the total number of operations.
What can I do at the beginning of the execution of updateUsers() to have @total reset to 200?


texts: Exposed grouped filters - inputs on a date field don't render

texts:
I am having the same issue as listed here:https://www.drupal.org/node/2128683

I am using:

Latest version of Drupal core
Views 7.x-3.10
jQuery 1.7
Use AJAX is enabled on the view

If I do not group the the filter the "select a date" and "enter a relative date" display their respective input fields.
Once I select Grouped filters neither "select a date" or "enter a relative date" display the input field.

Any help would be appreciated.


texts: Providing translations for custom modules

texts:
I'ld like to provide module specific translations for my custom modules.
I followed the instructions in https://api.drupal.org/api/drupal/core!modules!locale!locale.api.php/group/interface_translation_properties/8.

But if I install the module no translations get imported.
I've searched a lot for examples on the net, but it seems as no one else used it until now.

Here's my module "custom_module"

custom_module.info.yml:

name: 'Custom module'
version: '8.x-1.0'
core: 8.x
project: 'custom_module'
datestamp: 1434014760
interface translation project: custom_module
interface translation server pattern: modules/custom/custom_module/custom_module-%version-%language.po

and a "custom_module-8.x-1.0.de.po"-file with some messages in the module folder.


texts:
I have been going over posts and examples for hours but finally need specific help on where my code is broken. I'm trying to create link in navigation that opens a form to create a new node. However no link anywhere is being made and I'm not sure what is missing. While its supposed to also upload a image I'm not worried right now since it doesn't work anyway. As a beginner my module looks correct but experienced eyes can hopefully give me some advice on where I went wrong! Thanks for any support and let me know of anything else I can add to solve this problem.

<?php

function ImageLoader_menu() {
$items = array();
$items['ImageLoader'] = array(
   'title' => 'Image Uploader',
   'description' => t('Upload a image.'),
   'page callback' => 'ImageLoader_upload_form_submit',
   'page arguments' => array('ImageLoader_upload_form'),
   'access arguments' => array('access content'),
    );
  return $items;
}

function ImageLoader_upload_form() {
$form = array();

$form['name'] = array(
    '#type' => 'textfield',
    '#title' => 'Name'
);

$form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Create Node!'
);
return $form;
}

function ImageLoader_upload_form_submit($form, $form_state){
$node = new stdClass();
$node -> type = 'Nature';
$node -> title = $form_state['values']['name'];
$node -> language = LANGUAGE_NONE;
$node->path = array('alias' => '/');
node_object_prepare($node); // Set some default values.
$node->uid = 200;

$node = node_submit($node);
node_save($node);

drupal_set_message(t('Node Created'));
}


texts: In Ubercart auction final bid amount adds sell price instead of highest bid amount in the cart?

texts:
In uber-cart after auction has been won, the buyer will get add-to-cart button to add and buy the product. After clicking on add-to-cart button, it adds sell price value in the cart page instead of highest bid amount.

How to make it add highest bid amount in cart page instead of sell-price.

Any suggestions? Thanks in advance.


texts: How to show a list of users subscribed to the current node's taxonomy terms

texts:
I've been boggling my brain on this for a while now and although I seem to be getting close, so far there is now awesomness kicking in.

Here's what I want:

I have a number of articles (nodes), each with their own list of taxonomy terms
I have a number of users, each with a list of interests defined in taxonomy terms
I want to generate a list of users subscribed to taxonomy terms of the -current- node

I've tried many different approaches and often had the feeling I got close but, so far, no dice.

The closest I've gotten so far is:
view of 'user'
relationship: 'User: content authored' (yes,I know, this limits the output to author only but it DOES expose the  "(nodes)Content: taxonomy terms on node" relationship, which exposes
'(term) Taxonomy term: name of the tax-list' etc..

SO:
If someone could point out the general outline of the approach (what view type, what relationships to use) that would get me where I need to be, that would be splendid!

REWARD:
A whole lotta love will go to the one who sets me on the right track!


texts: Printing current node workflow state name as the page body classes

texts:
I have a workflow system in my site using workflow module, and I need to print the node current state name as body class.

I did the same with user current role in template.php with this snippet:

function sattari_preprocess_html(&$vars) {
  foreach($vars['user']->roles as $role){
    $vars['classes_array'][] = 'role-' . drupal_html_class($role);
  }
}

I'd really appreciate your help.


texts: Trouble enabling view modes for content types

texts:
I have a custom view mode and need to enable it for a node type.  I need to enable it through my module, and it seemed like hook_entity_info_alter() is the way to go, but it's not working.  Am I missing something?

My code:

function mymod_entity_info_alter(&$entity_info) {
    $entity_info['node']['view modes']['vm_mid_box'] = array(
        'custom settings' => TRUE,
        'label' => 'Mid Box'
    );
}

EDIT: I create the displays in Display Suite, and am using the export data dumped into DS hooks.


texts: Blog posts not trimmed evenly in list - and sometimes at first period

texts:
The list of blog posts on my D7 site should display posts trimmed to 300 letters, but some posts simply stop at the first period "." Without an eclipse or anything. If I remove the period - and put ANYTHING else - it works fine. Is there a setting somewhere to cut a post at a period within the trim limit or something?
Thanks in advance.


texts: Translatable strings and Drupal primary language

texts:
I use a lot of modules and templates, in which I have to print a lot of display markups.

My website has primary language FR, but whatever I do, each time I use a translatable string, it's always EN that is set for that t('whatever').

I'd like to be able to write all my custome code in French, and then translate strings into english in the interface.

Is it any way to achieve that?


texts: How to publish and unpublish content depending on the type of user?

texts:
I have a site with content for two different user types: primary and secondary. I want to publish and unpublish some content depending on whether the current user is anonymous user, user primary or secondary user.

If the current user is an anonymous user:

to publish primaria/docentes
to publish secundaria/docentes
to unpublish primaria/docentes/kit
to unpublish secundaria/docentes/kit

If the current user is a primary user:

to unpublish primaria/docentes
to publish primaria/docentes/kit

If the current user is a secondary user:

to unpublish secundaria/docentes
to publish secundaria/docentes/kit

I try to do this with the the Rules module. The result of my configuration is this:
 - In the computer 1, I login as a primary user. Everything works fine.
 - In the computer 2, I login as a secondary user. Everything works fine.
 - If I return to the computer 1, the things are not good. I see that everything works as if logged in as a secondary user.

My settings do not respect the rules for the user already logged on. Every time someone logs on to any part of the world, that user settings apply to all other users in the world.

Please help me. I attached screenshots of my settings. :(

All my rules:

Log in as an anonymous user.

When primary user logs.

When primary user logs off.


texts:
New user here so this could be a dumb question, but I've searched the web and can't find the answer.

In my Status Report I have this error mentioned:

Video.js    Unsupported Video.js version 3.2.0
The installed version of the Video.js library is not supported. This version of the Video.js module only supports Video.js version 4. Download Video.js version 4 and extract it into the sites/all/libraries/video-js directory or download Video.js module version 7.x-2.x to use Video.js 3.

So I did what it said, downloaded Video.js 4.9.1 and replaced the files in sites/all/libraries/video-js. But it doesn't make any difference, the same error message remains. Any ideas why?


texts: Block won't appear on specific language pages

texts:
I have a view with a filter to show entries based on chosen language (Configure filter criterion: Content: Translation language = Interface text language selected for page). The view is placed into a block, and that block is set to show for all languages. The block's placement is restricted to the page node and all its translations, for example /node/1234, /company, /empresa, and /enterprise.

Then when I go to some of the pages, it doesn't show. It's only appearing for Global default language and ES-US, randomly. French and US English it doesn't appear for, even though the alias is exactly what I've got: /company and /enterprise.

I cannot, for the life of me see any reason this should be happening. Every setting I know of is set, and the exact same thing is working for every other block I've set up like this.


texts:
I'm using Webform to set up a number of enquiry forms on a company's extranet and they require submissions to be confidential. Since access to anything on the extranet requires user login, the forms can't be submitted anonymously and some user info is associated with each submission.

I can get around this issue in outgoing emails by removing the user-specific info from the email template, but submissions stored in the database still retain user info.

I suppose my question is this: how can I disable Webform submissions from being recorded in the backend, OR, how can I modify recorded submissions to remove user info (basically to store nothing but the date/timestamp and message)?


texts: Drupal 6 - Build Menu "...not available at this time." Issue

texts:
I was just recently given administrative rights to the Drupal account to our firm to do some front-end work. I need to revamp a lot of the structure and content, however I do not see the 'Menus' option under 'Site building', more so I cannot access it via URL with I type "http://mysite.com/admin/build/menu". I get the following 404 Message "This content is not available at this time." My DBA says that it used to be accessible for he gave me an account. My question is what did he or I do wrong? I edited some of the Input Type Profiles and used the Rebuild Permissions option several times but have had no luck. I have not be able to find much mention of this through research. Is this a common scenario?

Full HTML prefs:

WYSIWYG Configs:

Type Settings Per User:

Filters for Filtered HTML:


texts:
Drupal 8 supports multiple file upload, however the native interface requires three steps:

Select one or more files
Click Upload
Click Save

Ideally this could be simplified to a single step i.e. select one of more files, once done it uploads them. The user can delete a file later if they wish, but no point showing them the list of which they just select, just to make them change their mind.

How should one click upload for multiple files be implement in Drupal?

In pure PHP this can be done easily as follows (but Drupal 8 adds too many constraints for this to work):

<?php

$upload_dir = '/tmp/upload_test';
if ( ! is_dir( $upload_dir ) )
{
    mkdir( $upload_dir, 0777, true );
}

/** Rearrange the "parallel" _FILES array into consolidated file items. */
function rearrange( $arr )
{
    foreach( $arr as $key => $all )
    {
        foreach( $all as $i => $val )
        {
            $new[$i][$key] = $val;
        }
    }
    return $new;
}

if ( ! empty( $_FILES['data_fs_uploads'] ) )
{
    $files = rearrange( $_FILES['data_fs_uploads'] );
    print '
Copying uploaded files...
';
    foreach ( $files as &$file )
    {
        // File has 'name', mime 'type', 'tmp_name' path, 'error', and 'size'.
        $file['ext'] = pathinfo( $file['name'], PATHINFO_EXTENSION );
        $target_file = $upload_dir . '/' . $file['name'];
        if ( move_uploaded_file( $file["tmp_name"], $target_file ) )
        {
            print '
Copied ' . $file['name'] . '
';
        }
        else
        {
            print '
FAILED to copy ' . $file['name'] . '
';
        }
    }
}
?>

<form action="upload.php" method="post" enctype="multipart/form-data">
    <input id="data_fs_uploads" type="file" name="data_fs_uploads[]" multiple="multiple" onchange="javascript:this.form.submit();" />
</form>

<?php
foreach ( glob("$upload_dir/*") as $file )
{
    print '
' . $file . '
';
}
?>


texts:
I have a problem with a views form. It should only be submitted when I hit the submit button. Currently it is submitting when I change a value in any textfield. When I select "Using AJAX: no" it doesn't change anything. :/

Can somebody help me out here?

Thanks!


texts: what permissions are needed to give a role ability to access: admin/content list page

texts:
what permission do i need to give a role to give them access to the list page of content. path: admin/content

This is for drupal 7.


texts: how to remove duplicate in view search API?

texts:
I get some duplicate article for the site. How can i remove the duplicate? There is no distinct setting.
Here is the setting of view


texts:
SearchAPI in Drupal7 with Apache Solr on Jetty was working ok in Windows, however when I moved the installation to Linux, I'm getting this exception in Drupal log:

SearchApiException while retrieving config files of Solr server solr_server server: "0" Status: Request failed: Permission denied in SearchApiSolrConnection->checkResponse() (line 536 of .../search_api_solr/includes/solr_connection.inc).

I can see that Apache Solr is accessible in Linux by the link:
http://localhost:8983/solr/#/~cores/drupal7

But not accessible by Drupal Search API for the Solar service URI:
http://localhost:8983/solr/drupal7

With the same links everything worked well in Windows. I'm not sure what permission is missing in Linux and would appreciate any insight on this.


texts: D7 serving node content to related subdomain

texts:
I am using Drupal 7 with single installation. Requirement here is to serve node content which belongs to sub-domain

Example:

if user try abc.mysite.com then system will internally serve content from

mysite.com/node/abc but user will not see any change in URL

What i have tried so far but failed:

htaccess modification
Subdomain module
Drupal hook "hook_url_inbound_alter"

Here "abc" subdomain is dynamic as this is related to node content.

Please Help!!!


texts: Execute pending queues using batch? Possible?

texts:
I have implemented the Queue API inside hook_cron, to do certain update operations on a site:

function HOOK_cron() {
  $interval = variable_get('variable_val', 60 * 60 * 24);
  if (time() >= variable_get('cron_next_execution', 0)) {
    variable_set('cron_next_execution', time() + $interval);
    $queue = 'MODULE_queue';
    $queue = DrupalQueue::get($queue);
    $query = db_query('SELECT nid FROM {node} WHERE type=:type', array(':type' => 'profile'))->fetchAll();
    foreach ($query as $node_obj) {
      $node = node_load($node_obj->nid);
      $queue->createItem($node);
    }
  }
}

where MODULE_queue is name of the queue, who's worker callback does some task on the nodes.

At any moment of time I would like the administrators to be able to run the updates manually using batch.
I would like something like this

Check if there is anything pending in a queue at the moment Admin chooses to manually update, and execute them in batch.
If not just run a manual batch update.

So, I'm stuck at the part where I need to run the queue inside batch. I am not sure if this even is possible. Any pointers would be highly appreciated.


texts: How to count nodes per content type in views D7

texts:
Possible Duplicate:
  Count of nodes by type

I'm building a views block for the current/logged in user. In this block, I'd like to have a view that shows counts nodes related with content types. Here's an example:

(Submitted) blogs: 5
 articles: 3
 polls: 2


texts: How can I theme the outgoing contact mail?

texts: I want to theme the outgoing mail from the contact module, because the standard output looks horrible. Where can I do this? It's the one starting with admin (http://example.com/user/1) sent a message using the contact form at http://example.com/contact.


texts:
I want to show a custom link for each role on my site. To do so, I will put PHP code in my page.tpl.php. I want to add an if statement that checks if the current user's role is equal to something, then print the link.

How can I get the current user role?


texts: Region for the footer not working, but the header is working

texts:
I have the following regions set up in my *.info.yml file:

name: Test
type: theme
description: 'Theme'
base theme: stable
core: 8.x
regions:
  header: 'Header'
  content: 'Content'
  footer: 'Footer'
libraries-override:
  system/base: false

In page--front.html.twig, I placed {{ page.header }} where I wanted the header to be, and noticed via Twig Debugging that Drupal was expecting a file named region--header.html.twig.  Great!

So, similarly, I did this for the footer.

{{ page.footer }} and region--footer.html.twig ... but it does not work!  Twig Debug's comments do not reveal any hook for the footer at all.

What am I doing wrong?


texts: White Screen of Death on Cron, fixed with update.php

texts:
One installation of Drupal has been fine for a long time, but has started developing a WSOD on most (maybe all) cron invocations.

Looking through Drupal's log messages, I see a few normal cron messages, and then this:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in theme_get_registry() (line 277 of theme.inc).
Warning: array_keys() expects parameter 1 to be array, null given in ThemeRegistry->initializeRegistry() (line 413 of theme.inc).
Warning: array_fill_keys() expects parameter 1 to be array, null given in ThemeRegistry->initializeRegistry() (line 413 of theme.inc)
Warning: PHP Shutdown: Argument #1 is not an array in ThemeRegistry->set() (line 457 of theme.inc).

I then see the following repeated many hundreds of times, once for each theme hook, it seems:

Theme <hook name> not found. Warning: array_key_exists() expects
parameter 2 to be array, null given in ThemeRegistry->offsetExists()
(line 421 of theme.inc).

So that is repeated a few hundred times, where <hook name> is every theme hook in the entire Drupal installation.

It has been running a custom theme, but that theme has behaved fine for ages. In fact, I have not made many recent site changes. I've only updated Drupal to 7.52.

Any ideas how to proceed?


texts: Combine recent and popular items in Views

texts:
I need to show 2 popular and then 2 most recent items, and again next 2 popular and next 2 recent items in Views.

Any idea how to do this?


texts: Force Language Path Prefix For Default Language

texts:
I have a multilingual site configured to use path prefix for URL language detection.

When no prefix is used in the URL, the default language is assumed. How can I change this behavior?

I want the site to return content only when a language prefix is set in the URL, otherwise return a "page not found" error.

Reasoning behind this functionality:

Preventing duplicate content in search engines
Keeping everything well organized (under language prefixes)
Avoiding users to be able to view content without a language prefix and thus potentially link to it (loosing link juice)

Edit: added reasoning.


texts: Can Pathauto fallback to another pattern if the first pattern yields an empty path?

texts:
I want pages to have an auto generated path if they are in a menu and another one if they are not in the menu; not an empty path like Pathauto currently generates if the page is not in a menu.

How can I do that?

Details: I'm using this pattern for my pages content type which works perfectly when a page is in a menu.

[node:menu-link:parents:join-path]/[node:menu-link]

The problem is, when a page is not in a menu, it gets an empty path. I want to give it another path based on the "title" of the page, for example.


texts: LogicException: The database connection is not serializable - when I try to open any "gear" on checkout flow page?

texts:
So I'm on Commerce -> Configuration -> Orders -> Checkout flows. I'm editing a flow (it's the same with any of them), so i.e. I'm at page:
/admin/commerce/config/checkout-flows/manage/shipping

and for some items (i.e. "Login or continue as guest", "Contact information"...) with the option I also have gear icon on right for opening some settings block.
Until recently that worked well, but now, when I click gear icon spinner appears for short time and nothing happens.
In error log I see message:

LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect
reference to the database connection. Adjust your code so that is not
necessary. Alternatively, look at DependencySerializationTrait as a
temporary solution. in Drupal\Core\Database\Connection->__sleep()
(line 1573 of
/var/www/html/drupal/web/core/lib/Drupal/Core/Database/Connection.php).

From browser network tab I can see that url:
http://sitename.test/admin/commerce/config/checkout-flows/manage/shipping?destination=/admin/commerce/config/checkout-flows&ajax_form=1&_wrapper_format=drupal_ajax
is called and response was:
500 Service unavailable (with message)
Any idea what could cause this error and how to solve it?


texts:
I have two modules. The first module is for custom login form and the other is for custom user pages.
I want to store a session variable from the first module and later to call on the second module.
Let's say my field from the first module is:

<?php
function custom_login_form($form, &$form_state) {

    $form['custom_field'] = array(
       '#type' => 'textfield',
       '#title' => 'Custom field',
    );

   return $form
}

and this is the callback from my second module:

    <?php
    function custom_user_pages() {
       $The_session_stored_field = 'some_value';

    }

How can I store the custom_field with session and how to call it on the second module?

EDIT: My custom modules are connecting with web service and all the information I'm passing with XML. With simplexml_load_string() I'm getting all the data. Now I've used $_SESSION, but I have some error:

  "Exception:Serialization of "SimpleXMLElement" is not allowed in
  session_write_close()...

EDIT2:In my first module I've set SESSION like this:

$_SESSION['custom_field'] = $custom_field;

On the other module I've set $custom_field = $_SESSION['custom_field'];

Is this a right approach?

Yes, I've got an error that's not related with session, because simplexmlelement cannot be serialized like that. Maybe I should open a new thread for that.


texts: "Allow multiple selection" not available in exposed filters

texts:
I'm having trouble making some options appear as checkboxes in an exposed view form.
The problem is that the "Allow multiple selection" option is not available in the filter.

How can i make it visible. "Allow multiple selection" option.


texts: I am wondering about how to set up hierarchical taxonomies.  For example say I have a vocabulary called Vehicle Make which consists of terms Audi and Honda, then I have a further vocabulary called Vehicle Model which consists of A4, Civic and Accord.  So now say I wanted to create a vehicle registration content type with term reference fields corresponding to the two vocabularies listed above.  Is there a way to define an is-a relationship between these vocabularies, I.E. an Accord is a Honda and an A4 is an Audi and therefore the selection in the Vehicle Model term reference would be dependent upon the selection in the Vehicle Make term reference.  So if I select honda for the make I should be able to select Accord or Civic for the model and if I select Audi I should be able to only select A4.  Is this something that can be done with Drupal taxonomy system?


texts:
On every page on my site, there are always these tabs on display:

  News, Events, Grant.

I have been able to hide them on specific pages using CSS Injector however I want to disable these tabs from appearing.

How can I do this?

I have added a screenshot for reference:


texts: How to insert other language's numbers in an integer text field?

texts:
I have an Integer Text Field which I want to fill with numbers in Persian (as long as the whole content fields should be filled with Persian characters), but when I write numbers when my keyboard is in Persian mode, Drupal doesn't detect the numbers and replies "Only numbers are allowed in Pages". And of course I prefer not to change keyboard mode every time to fill this field.

what should I do to solve this problem?
I'm using Drupal 7 on my local machine.
Thanks.


texts: I have product images that I want to appear in a view. Easy enough.  At the same time I have 6 different product types.  So what I'm trying to do is create a view that is 6 columns across.  Each column is a different product type.  Then each product will fall into 1 of 6 categories.  Some columns will have 4 items, some 7. I cannot seem to do this with the "Grid" layout.  Which seems the best way to do this.  Any suggestions?


texts: how to prevent user from clicking button twice on server side in jqx

texts:
$('#save').on('click',function(){
  $('#form').jqxValidator('validate');
});

How can I prevent user from click button twice on server side?


texts: Display a view block with a list of content excluding the one currently displayed on the page

texts:
I sometimes use contextual filters to display fields matching the content ID from url

In that case , i would like to display a list of content as a view block , except the one that is displayed

It would require to :

negate the condition " Content ID from URL contextual filters "

or

being able to choose the 'content id from url' as value of a view filter

I don't know how to do the first option.
That token conditions module would do for the second option but is not stable
https://www.drupal.org/project/token_conditions

How can i possibly do that then except JS?


texts: Search results showing nodes which are already under NODE_ACCESS_DENY

texts:
In Drupal 7, I have some nodes that are restricted access for anonymous user. I implemented this using hook_node_access where if the user_is_anonymous and if the operation is View, I am giving NODE_ACCESS_DENY.

Now, how can I restrict these pages from showing in search results page for anonymous user?


texts:
In my drupal 6 website, we have used feed importers to import feed, but from few days We are not getting new feeds and then I have gone to 'status report' in admin panel and checked status report & I found that cron is not running.As I have seen that there is problem in cron I imported feed manually and it worked for me.

When I tried to run feed import cron manually from status report page I got error "cron run failed"

As I am new to Drupal, I dont know that from where I should start cron failed troubleshooting.

Can anyone suggest me the way.


texts: Using form_set_error in the submit handler

texts:
I have a multistep form and on each submit I send completed fields off to an external API which returns data about the next step of the form.

The problem is, if I use form_set_error in the submit handler, the form_storage is cleared and so the form resets to the first page.

Here's a arbitrary example;

function example_form($form, &$form_state) {
  if(!isset($form_state['step'])){
    $form_state['step'] = 1;
  }
  $form['test'] = array('#markup' => '
Step: ' . $form_state['step'] . '
');

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'go'
  );
  return $form;
}

function example_form_submit($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
  if($form_state['step'] > 5){
    form_set_error('test', 'error');
    return;
  }
  $form_state['step']++;
}

So this create a form with just a text block displaying the step number and a submit button that takes you to the next step. Until you go past the 5th step at which point it should start to error.

For some reason in my testing this breaks the step count, and on error takes you back to step 2.

moving the form_set_error into the form callback, or into a validate callback fixes the issue, but it would be cleaner if I could call it in the submit handler.


texts: With several user profile pages built in Views as tabs, how do I build a menu linking to those pages?

texts:
I can't just use the menu UI to create menu links because the links need to be dynamic. The best solution I have found so far is in OpenAtrium. Are there any others?

   $block['content'] .= "<h3>". t('My account') ."</h3>". theme('links',
atrium_account_links());

and

/**
 * Generates an array of account links suitable for use in theme_links().
 */
function atrium_account_links() {
  global $user;
  $links = array();

  // @TODO: If menu.inc had a real API function for this we would use it, but
  // as of now we'd have a copy hand paste hack job of menu_local_tasks()...
  $paths = array(
    "user/{$user->uid}" => t('Profile'),
    "user/{$user->uid}/dashboard" => '',
    "user/{$user->uid}/edit" => '',
    "user/{$user->uid}/notifications" => '',
    'logout' => '',
  );
  foreach ($paths as $path => $title) {
    $item = menu_get_item($path);
    if ($item && $item['access']) {
      $links[] = array(
        'title' => !empty($title) ? $title : $item['title'],
        'href' => $item['href'],
      );
    }
  }
  drupal_alter('atrium_account_links', $links);
  return $links;
}


texts:
I'm using a rule to send out emails when a node is created. Under Action and Message body, I insert [node:field_calendar_date]. The token is replaced with (for example) "2012-12-14T08:00:00" in the email message, but I would like it to be replaced with "Friday, December 14, 8:00am" (same date, but a different format).

I tried to follow format_date(), but it doesn't work.

How can I get the format I want?


texts: How come there are different UUIDs for multiple environments?

texts:
We have D8 site where we use Configuration Management to export and deploy to multiple environments. We recently created a new content type, Blogs where we added a few fields (field_url, field_country). When we export this in our local development environment it all exports to yml files.

When we push these configurations to our Dev and Test environment we are seeing that they are out of sync even after running drush @env cim. Doing further analysis we found that the UUID is different and causing the issue.

However even if we were to export the configuration from Dev environment into our local ones, we still see that the UUID is different.

The settings.php already contains $config_directories['sync'] = 'path/to/config-folder';

How can we get the UUIDs to be in sync? We don't have this issue with other content types nor fields.


texts:
I have just introduced my custom template suggestions in MYTHEME_preprocess_node, based on a certain field's value. Won't work somehow.

The content type is project. In my template folder I have already a file named node--project.tpl.php, and my suggestions append additional two: node--project--pcgame.tpl.php and node--project--movie.tpl.php. They are visible when I dpm() the variables, but are not found/applied to the node, even when I remove node--project.tpl.php.

Cache cleared.

Any clue as per what could be the cause?

The code I'm using:

function MYTHEME_preprocess_node($variables){
  if(isset($variables['node'])){
    $node = $variables['node'];
    if($node->type == 'project'){
      // Determine project type based on a term field.
      $project_type = (int) $node->field_genre['und'][0]['tid'];

      switch($project_type){
        case 4:
          $variables['theme_hook_suggestions'][] = 'node__project__pcgame';
          break;
        default:
          $variables['theme_hook_suggestions'][] = 'node__project__movie';
      }
      dpm($variables['theme_hook_suggestions']);
      }
   }
}


texts: Session is not getting maintain in settings.php drupal 7

texts:
I have Created one php file on root of drupal7 and access it using URL.I have one form in that file which has dropdown values and submit button. Now in settings.php i am getting those value in POST. Based on That post value i want to select DB for drupal. But it Throws error because session is not getting maintain.
This is my code in settings.php

session_start();
$_SESSION['data'] = $_POST['year'];
if(!empty($_SESSION['data'])) {
  $databases = array (
    'default' =>
       array (
        'default' =>
          array (
            'database' => 'mydbname'.$_SESSION['data'],
            'username' => 'root',
            'password' => '',
            'host' => 'localhost',
            'port' => '',
            'driver' => 'mysql',
            'prefix' => '',
          ),
      ),
  );
}
else {
  header("Location: welcome.php");
}


texts: HTML mail - how to properly format message

texts:
I am trying to implement html mail notifications using htmlmail module. I am not certain if message should be formatted as array in $message["body][] before the template or passed as a string in $message['body'].

The reason I am asking is that I first expected the email to be sent in as a string but then saw the HTMLMAILSystem::format function that flattens the body array:

  public function format(array $message) {
    $eol = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
    // @todo Remove this when issue #209672 gets resolved.
    $default_from = variable_get('site_mail', ini_get('sendmail_from'));
    if ( !empty($message['headers']['From'])
      && $message['headers']['From'] == $default_from
      && valid_email_address($default_from)
    ) {
      $message['headers']['From'] = '"'
      . str_replace('"', '', variable_get('site_name', 'Drupal'))
      . '" <' . $default_from . '>';
    }
    // Collapse the message body array.
    if (module_exists('mailmime')) {
      $body = $this->formatMailMIME($message);
      $plain = $message['MailMIME']->getTXTBody();
    }
    else {
      if (is_array($message['body'])) {
        $message['body'] = implode("
$eol
$eol", $message['body']);
      }
      $body = theme('htmlmail', $message);
      if ($message['body'] && !$body) {
        watchdog(
          'htmlmail',
          'The %theme function did not return any text.  Please check your template file for errors.',
          array('%theme' => "theme('htmlmail', \$message)"),
          WATCHDOG_WARNING
        );
        $body = $message['body'];
      }

So if I understood correctly, message must be preformatted with correct html in $message["body"][] , but I am not 100% sure there are lots of code-bits involved for email sendouts. I also need to validate if this will allow me to send mail as plaintext?


texts: Drupal 7 Commerce Stock - Setup stock rules on purchase success for all line items?

texts:
Currently im trying to setup the stock rules for drupal 7 commerce, but I'm not sure how to go about setting up the rules to deduct stock on purchase success. I have the following: http://prntscr.com/24d0b5

As for the following action: Decrease the product stock level, given a line item

I have this: http://prntscr.com/24d0u8

Currently it only applies to line-item:0 , But how do I make it apply to all line items? Can someone take a snapshot of how their configuration is for this stock rules setup?

thanks


texts: Google Analytics module is not tracking site search

texts:
I have a site that is using the Google Analytics (GA) module. It's happily tracking data to GA. However, I can't seem to get Site Search working.

The site uses Apache Solr. A search results page for the query "test" is:
/sitesearch/test

I've enabled "Track internal search" in the Google Analytics module config page
I've enabled "Site search Tracking" in GA
I've set the query parameter to "sitesearch" in GA
I've unchecked "Strip query parameters out of URL" in GA
I've confirmed that if I manually hit this URL, it pings a track in GA:
/sitesearch/test?sitesearch=test
(Any URL on the site with ?sitesearch=test works.)

I'm out of ideas. What could be causing this to fail?


texts: How to change the user registration form markup

texts:
I want to change the markup on the user registration form that reads

  Spaces are allowed; punctuation is not allowed except for periods,
  hyphens, apostrophes, and underscores.

and

  A valid e-mail address. All e-mails from the system will be sent to
  this address. The e-mail address is not made public and will only be
  used if you wish to receive a new password or wish to receive certain
  news or notifications by e-mail.

to something more friendly.

I don't think String Overrides works with the registration form so I guess I need a custom module - hook_form_alter perhaps?


texts:
I am trying to print an image using an image style that I've created in my drupal 8 theme.

I'm implementing a field template for the field collection. I have an image in my field collection, So i need a way to get the URL for a different image style of the same image.

Any effort will be appreciated.


texts: Update entity ref field in parent form with new node created in ctools modal

texts:
I have a node_add form for Foo node-type with an entity reference field to Bar node-type. I'm trying to allow users to create Bar nodes inline from the Foo create form.

So far I've been able to get the ctools modal to popup, create and process the new Bar node and dpm the new Bar-type nid. but I'm stuck on how to push that to the parent Foo form and add this new Bar node into the entity reference field.

Here's what I tried using ajax_command_append in my callback for the ctools modal, but it doesn't append the new Bar node to the entity reference field values in the parent form:

function mymodule_add_bar_callback($js = FALSE) {

ctools_include('node.pages', 'node', '');
ctools_include('modal');
ctools_include('ajax');

$node_type = 'Bar';
$node = (object)array(
    'uid' => $user->uid,
    'name' => (isset($user->name) ? $user->name : ''),
    'type' => $node_type,
    'language' => LANGUAGE_NONE,
);

$form_state = array(
    'title' => t('ADD A NEW BAR'),
    'ajax' => TRUE,
);

$form_state['build_info']['args'] = array($node);
$commands = ctools_modal_form_wrapper($node_type . '_node_form', $form_state);

// if the form was submitted, reload parent Event-Add form
if (!empty($form_state['executed'])) {
    $commands = array();
    $commands[] = ctools_modal_command_dismiss();
    $commands[] = ajax_command_append('#edit-field-bar-und-0-target-id', '<input type="text" id="edit-field-bar-und-1-target-id" name="field_bar[und][1][target_id]" value="" size="100" maxlength="1024" value="' .  $form_state['node']->title . ' (' .  $form_state['node']->nid . ')" class="form-text required form-autocomplete" autocomplete="OFF" aria-autocomplete="list">');

    $output = $commands;
}


texts: What module should I use to save a module settings in a feature?

texts: I am needing some additional power for my Features.  I have several modules that have their own settings (like css injector... yeah, I know) which do not appear in teh list of items that can be saved within a feature.  I have been told that Strongarm offers a good way to include additional configuration within a feature (above and beyond what Features can normally store.)  I have also heard talk of another module that is (commonly?) used with Features which improves its ability to store and transfer configurations.  I can not remember the name of this other module.  Could someone point me in the right direction?


texts: Drupal 7 with front-end in Spanish/English; Back-end in English only

texts:
I installed Drupal in English and also installed the i18n and Locale modules for translation. I then enabled Spanish as a language and set it as default. My aim is to have the site default to Spanish (www.mysite.com/spanish-page), and to allow users to choose English if they wish (www.mysite.com/en/english-page).

My site is still defaulting to English... for example, in "admin/config/system/site-information", my Default front page setting is defaulting the the "en" (English) url prefix. I cannot delete that prefix on that page; it is listed in the non-editable text just in front of that field. Likewise, when I click the "Home" button on my admin menu, it takes me to "www.mysite.com/en" (the English home page) instead of "www.mysite.com" (which would be the Spanish home page). I'm sure it must be a default setting somewhere, but I cannot find it. Can anyone provide guidance on how to properly set up this type of language scenario?

Thanks!


texts: I am running a local Drupal 8 site via Aquia DevDesktop. I enabled the Migrate modules: Migrate, Migrate Drupal, Migrate Drupal IU, Migrate Plus and Migrate Tools. When I run a migrate command in drush, such as migrate-status, I get an error, "unknown database".  Settings.php is correct and the site if working fine. I am running drush 8.1.17 and other drush commands work ok. Any suggestions?


texts:
Is it possible to show the current total userpoints a user have next to menu item?

example menu: Home | Downloads | My Points (24) | Logout

if it's possible, how would one do this (beginner)


texts:
UPDATE:

The node.js server is now running correctly at Openshift. The node.js server and the socket.io script can now be accessed publicly.

Running cron in Drupal, I see that it can also access the node.js server. However, my problem now is this, from the Chrome console:

  GET https://nodejstapchat-breathalert.rhcloud.com:8080/socket.io/?EIO=3&transport=polling&t=LM-NWXx net::ERR_CONNECTION_TIMED_OUT    socket.io.js:3511

I think it has to do with that redundant port in the url. Can anyone confirm?

ORIGINAL QUESTION:

Having problems while setting up the drupal nodejs module to use with Chatroom. This is working for me on localhost, so I suspect it has something to do with HTTPS.

The Drupal site is served only via HTTPS, and I just got the nodejs server, running on Modulus.io with HTTPS.

The drupal nodejs module (v7.x-1.13) and nodejs server (v1.0.9) are of compatible versions (based on the doc). Also confirmed the matching config on the Drupal site as well.

Checking the HTML source on one of the chat pages using nodejs, came across this:

<script src="https://tapcreativechat-64706.onmodulus.net:8088/socket.io/socket.io.js"></script>

But it appears it does not return the socket.io script (also tried port 8080).

Second related problem is the messages in Drupal dblog:

  Error reaching the Node.js server at "nodejs/health/check": [-110] Connection timed out.

I am out of ideas why Drupal can't connect to the nodejs server.

My Node.js server config file:

//Node.js server
settings = {
scheme: 'https',
port: process.env.PORT || 443,
host: 'localhost',
resource: '/socket.io',
serviceKey: 'key',
//Drupal site
backend: {
    port: 80,
    host: 'tapcreative.services',
    scheme: 'https',
    basePath: '/',
    messagePath: '/nodejs/message'
},
debug: true,
sslKeyPath: '_privatekey.key',
sslCertPath: 'tapcreative_services.crt',
sslCAPath: 'all_certs.crt',
baseAuthPath: '/nodejs/',
extensions: [],
clientsCanWriteToChannels: false,
clientsCanWriteToClients: false,
transports: ['websocket', 'polling'],
jsMinification: true,
jsEtag: true,
logLevel: 1
};

Advice is appreciated.


texts: active menu background for all the nodes of a particular content type

texts: I have created a view to list the nodes of a particular content type.I have given a path and linked it to a menu item.I am changing the background of the menu item when it is active or visited.Also i want to change the menu background when the node in the view is viewed so that it should look like active menu.Thanks in advance.


texts: What's the latest in the page lifecycle a module can send an HTTP header?

texts:
For CDN purposes I am collecting the modified times of various pieces on the page and want to set the Last-Modified header to them. What's the latest during a request a Drupal 7 module can call drupal_add_http_header?

I know the answer but I think this is a very interesting question and I somehow doubt most people would know the answer, so I will leave this open for a few days and then post the answer.

Note

To avoid insane answers like using runkit or doing your own request cycle, I will say the answer is userland PHP only, and less than 10 line of code.


texts: Centered layout with div borders on left and right (with bg images)

texts:
I have begun a new theme on drupal using the Boilerplate theme.
I am trying to achieve a centered(responsive width) layout with borders on both left and right sides. I have attached a diagram. DIAGRAM HERE

I have the left side borders  working fine, they are within the #PAGE div which is the one and only WRAPPER of all content. (there is no other div above it)

As i have shown in the diagram, i am having trouble with the RIGHT side borders. With the same CSS syntax as the left borders, you can see they are positioned all the way to the right, even though they are inside the #PAGE div. Why is this? why is the #PAGE div not pulling it together?

Thanks for the help!

EDIT
codejsFiddle demo/mockup

PS- these 'borders' need to hold images as backgrounds so i can not simply use the 'border' property. And the 'border-image' is not well supported. DIV's is what i need.


texts: Redirect Module doesn't redirect from node/{nid} to alias

texts:
I installed the redirect Module in Drupal 8 but sorrily can't get it to work properly. I enabled all checkboxes in the settings, also the "Enforce clean and canonical URLs" option.

In my page source, the canonical is printed in a meta tag. But if I browse my page and enter a system URL like www.domain/node/5, no redirect to the autopath alias / canonical happens.

Does anyone have any suggestions? I also reinstalled it twice already. Nothing helped.


texts: Calendar legend on taxonomy via relationship?

texts:
I'm working on a calendar view to show employees' vacation. For that I setup 2 content types:
-Employee: Name and Department (Term reference to 'Department' vocabulary)
-Vacation: Date field with start and end dates and Employee (Node reference to Employee content type)

I got views to show the calendar with vacation time for the employees, but I want to colorcode them based on the department their in. So I setup the relationship to the Employee content type and added the Department field using that relationship.

Views recognised the term reference field and allows me to set colors for each vocabulary term. Everything looks ok, except the actual calendar view which doesn't show any color at all. There is no "stripe" keyword in the html source.

To test I added a dummy term reference field to my Vacation content type itself to test the behaviour without a relationship and everything works as expected.

So it seems the colorcoding doesn't work on term reference fields via relationships. I could add the department reference field to my Vacation content type, but that would mean have the same reference in both the Employee and Vacation content types, which isn't something I'd like to have.

Has anyone come across this problem or better yet, solved it?
Thanks in advance.

I'm running:
Drupal 7.14
Calendar 7.x-3.4+0-dev
Date 7.x-2.5+15-dev
Views 7.x-3.3+175-dev
Chaos tools 7.x-1.0+32-dev


texts: Changing default file permissions for group?

texts:
I'm not super familiar with the permissions structure in Drupal 7 so I'm not sure if this is actually an Apache question or a Drupal question.

I have a style.css file in /sites/all/themes/mytheme/css/ that I need to edit via FTP. That css folder also contains files that are edited via the Omega Tools UI. It appears that each time I use the UI to change style information, Drupal changes the owner of the css folder from ftpuser to www and gives it permissions 754 (group cannot write).

I am okay with the owner changing to www but I need to be able to edit my style.css file via FTP, so I need permissions to be 774. Is there a way I can set a default permissions structure on a folder or on Drupal in general that sets permissions to 774 instead of 754 whenever the system changes the owner of a folder?


texts: Drupal Mailchimp module for multilanguage sites

texts:
I setup a D7 multi-language site. People can subscribe with my MailChimp newsletter list when they register at user/register.

It works fine with german, the default language, but when somebody switches to english, registers at /user/register with the Subscribe to our Newsletter set, the double opt-in email the user receives from MailChimp is still german, not english.

How can I create MailChimp signup form that sticks with the current selected language?


texts:
I enabled devel to Display query log

UPDATE: this problem only happens for logged users

I found that the Frontpage generate 900 queries.

**67** of them generated by the **Locale** module

and

**480** of them are of the type: **DrupalDatabaseCache::set**

How can I track this problem?

I read that I should disable the i18 module, but I can't do this since it is a multilingual site and I there are other modules that need the i18 module.

This only happens in the Frontpage in other pages the queries downs to 300.


texts: How to load add comment form in light box or any other pop up

texts: Want to load add comment form in light box or any other java script pop please help me how should i approach this


texts: Lock Workbench content until moderation state change

texts:
I'm managing content workflow using the Workbench module. Content is moved through various states until it's made live by the publisher.

I've managed to lock content whilst it's being edited, using the Content locking module, which seems to do the job well. However, I now have another requirement to lock the content to the user until the user is finished editing it, which is to be indicated by changing the state to the next level, such as 'Ready for review'.

Can anybody suggest a method of doing this?


texts:
I've created a view with a number of exposed filters, but it is pretty ugly looking.

I'd like to improve the theming, including wrapping the whole thing in a fieldset as well as grouping some of the other elements (like pairing the published and updated inputs), but not sure how to go about this.

I tried to var_dump the form, but it seems to go on forever and my browser locks up, so I can't easily learn anything about the form that way.

I also tried putting the form as a fieldset child in another form, but getting all the form ID information and so on proved problematic (although, I did get the fieldset styling).

Anyone got any pointers?

Update:

I copied over the template from the module to my site's theme directory, and made a start.

<fieldset>
    <legend>Filters</legend>

            <?php foreach($widgets as $id => $widget): ?>

                    <?php if (!empty($widget->label)): ?>
                        <label for="<?php print $widget->id; ?>">
                            <?php print $widget->label; ?>

                    <?php endif; ?>
                    <?php if (!empty($widget->operator)): ?>

                            <?php print $widget->operator; ?>

                    <?php endif; ?>

                        <?php print $widget->widget; ?>

            <?php endforeach; ?>

                <?php print $button ?>

</fieldset>

I can't seem to figure out how to pair up the date fields - I need to somehow modify the widget properties so I can wrap them in HTML (using hook_form_alter doesn't work because the #prefix and #suffix are added to $widget->widget so they break the output)


texts: Why is there a number being inserted into this view?

texts:
I've set up a view to show the first image in my gallery, but for some reason it is inserting the number 1 after each image it shows. I can't find anything in my settings that seems obvious, so what is going on here?

Picture of the problem (there should not be anything but the picture in this cell):

I've also changed it to show 2 items and the "1" still persists.


texts: No page style appearing on Permissions page.

texts: The permissions page on my site has no styling/theme. It is the only administration page that has this problem. The page displays as if I have turned off styles. I am using Drupal 7. What could be causing this issue?


texts: How do I make the nodes referenced by organic group content also be OG content?

texts:
I have an organic group called 'newsletter'.
I have two content types - 'issue' and 'article' - in 'issue' (which is set to be a group content type), there is a node reference field to articles, and many articles in a single issue, using an inline entity reference form.

I want to put an issue inside an organic group, for access control. I also want the articles that the issue references inherit that group content relationship without having to explicitly set the group for every single piece of content.

The group is public, but the content is private. I don't want anyone to access group content until they go though a process and purchase access via the commerce_licence_og module.

The article (content referenced in entity reference field) isn't added to the group content, though the issue itself is. I felt that a group reference for every article is redundant, and I would rather the article inherit the issue's access and status as group content rather than have a bunch of redundant fields and is automatic, not requiring additional admin steps.

Is there an easy way to do this?
Do I HAVE TO make the articles group content in the UI?


texts:
I have PathAuto providing /term/[term:name] for terms of a specific vocabulary.
If I hover over the link for any of the terms, the path given is the alias.
When a term page is requested, e.g. /taxonomy/term/2, why isn't the page URL replaced with the alias?


texts: block to display nodes using entityQuery with pager

texts:
I am trying to figure out how to create a block that displays recent content using a pager that can fetch the next set of nodes
here is what I have so far
/modules/example_module/example_module.info.yml

name: Example Module block with pager
description: 'Example Module block with pager'
core: 8.x
type: module
dependencies:
- node
- block
type: module

/modules/example_module/src/Plugin/Block/ExampleModuleBlock.php

<?php
namespace Drupal\example_module\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
 * Display all instances for 'ExampleModuleBlock' block plugin.
 *
 * @Block(
 *   id = "example_module_block",
 *   admin_label = @Translation("Example Module"),
 *   category = @Translation("Example Module"),
 * )
 */
class ExampleModuleBlock extends BlockBase {
  public function build() {
    $output = example_module_get_content();
    $out = [
      '#markup' => $output,
      ],
    ];
    return $out;
  }
}

and /modules/example_module/example_module.module

<?php

function example_module_get_content(){
  $out = "";
  $nids = example_module_query();
  foreach($nids as $nid){
    $node = \Drupal\node\Entity\Node::load($nid);
    $out .= "<div>" . $node->getTitle() . "</div>";
  }
  return $out;
}

function example_module_query() {
  $query = \Drupal::entityQuery('node')
    ->condition('status', 1)
    ->sort('created', 'DESC')
    ->pager(10);
  $nids = $query->execute();
  return $nids;
}

which creates a block that can be placed on a theme and displays the latest/recent 10 nodes on the drupal site.

Well I can probably devise a way to query the database and figure out a way to create a custom pager and probably use $current_path = \Drupal::service('path.current')->getPath(); to get the pager PAGE but I was wondering if there is an obvious way that could greatly help and I don't have to reinvent the wheel

what is the deal with pagers are they of any help here ?


texts:
It mightbe a lame question but I want to be able to display a custom page let say: "/news".

So, I created a template named: page--news.tpl.php with my content, some rendered views etc.
Now when I got to this address, I can see my requested content however there are two problems:
- title of the page is "Page not found"
- the search form does not work.

Could anyone explain what is going on? I am on Drupal 7.

BTW. My template contain some html and this section to embed another view:

News

                        <?php echo views_embed_view('news_view_block_more', $display_id = 'block'); ?>

Thank you


texts: Pop up message and a button to cancel it

texts: My site contains two pages. The front and an article. I want to add a pop up message whenever someone visit the front page. This pop up will have a link that will trasfer the user in the article.The article will contain a button that when is clicked it means that the user no longer want this pop up message so it must be stopped for this user only. Any idea how can i do this? should i write html & javascript? php?and where can i find the pages in order to edit them?


texts: showing an image field from solr index on custom solr search page

texts:
I use the Apache Solr Views module to create a View that displays only items from a specific content type.

I would like to include an image as well on the view. I managed to get the images on my site indexed in solr using a custom module (field is called ss_field_image_uri). They show up in the solr index and I can add the image field in my custom solr view. So far so good.

The problem is that the field outputs as "public://folder/imagename.jpg". My question is how how I could I get the view to output not the link but the image itself?

Should I somehow rewrite the output of the image field in the view? Or use a custom php field and add some code? I cannot figure out how to do it. I am not a programmer but any pointers as to how to proceed would be very much appreciated.

Best,
Gerben


texts: How to programmatically create new revision and publish it?

texts:
(I am using Revisioning.) I call node_load(nid, vid) (with the latest version id), give new values to some fields, and then save the node. Setting $node->is_current = TRUE before saving will ensure that this version of the node is now published. However, it does not create a new revision. So I try setting $node->revision = TRUE also, but this creates a new unpublished revision which is not what I would expect.

How can I edit a node, and save it as a new revision and also as the current published revision? Not sure if it is a bug in the module.

// Node has some new revisions since the version that is currently published.
$vid = revisioning_get_latest_revision_id($nid);
$node = node_load($nid, $vid);
$node->revision = TRUE;
$node->is_current = TRUE;
$node->status = 1;
node_save($node);
// New revision created, but not published.


texts: How to add a class for forgot password link?

texts:
I need to add a class for the forgot password link. How can I do using Drupal?

This is the actual link:

Have you forgotten your password?

My expected link is this one:

Have you forgotten your password?

How can I achieve this, without using jQuery?


texts: How to tell if node has been updated via UI form as oppose to programmatically?

texts:
I am importing/updating nodes from a web service using node_save.  One feature that I want to achieve is when the imported node is changed locally, it should not receive any further updates from the web service.

So, what I want to achieve is:

Detect when a node has been updated
If the update was carried out by a user submitting a form (as oppose to programmatically)
Then flag that this node should receive no further updates form the web service (I don't need any assistance with this part)

I wanted to use hook_node_update but I'm not sure how to tell whether the update was carried out by a user submitting a form.

Any suggestions?


texts: views_get_view_result() how to retrieve a specific pager (pagination) page?

texts:
views_get_view_result() returns the results of the first pagination page (views pager). Is there a way to retrieve a specific page pagination results?

I have tried views_get_view_result('MYVIEW', 'MYDISPLAY', array('page' => 3)); but no juice.

If this function specifically does not do this trick, is there any that does?


texts: How to insert value to user entity custom field while creating new account?

texts:
I am trying to insert a value into a custom field(field_custom_referral) which is created in the backend.When a user creating a account in our application, this particular custom field should be updated with custom value. Can anyone help me out here.

I tried below code in .module file but not working out:

function module_user_insert(Drupal\Core\Entity\EntityTypeInterface $entity) {
  $entity->set('field_custom_referral', '3');
  $entity->save();
}

Any suggestion will be appreciated.


texts: How to create a textfield with autocomplete function for the view?

texts:
My Drupal 8 website is multilingual, and on one of the views I present a list of nodes (titles). On top of the page I need to implement a textfield with autocomplete function, where the user can start typing in the language, and then by choosing one the content on the page will be presented in chosen language.

I have started by creating a custom block:

public function build(){

$block = array(
  '#type' => 'textfield',
  '#title' => t('Choose language'),
  '#autocomplete_path' => '?????',
  '#cache' => array(
    'max-age' => 0,
  ),
);
return $block;

}

What should I write in '#autocomplete_path' => '?????' as the list of languages is not taxonomies. It is coming from Languages module. Could you please help me?


texts:
I am trying to create a view that has a image that is linked to another node, which I can do. However, I want to take the title (of content) and place it over top of the image like this.

I tried with CSS. Am I missing something?


texts: How to create Media entity and attach to user field

texts:
I'm trying to import user profile pictures from Drupal 7 to Drupal 8. So far I've managed to upload the picture from the url and save it to the file system, create Media entity and use the user id as author. However, the picture doesn't show to the user profile (Manage Form Display), neither to the Edit Media Content Type page.
Here is the code I have so far:
$values = array(
      'name' => $user["name"],
      'pass' => [
         'value' => $user["pass"],
         'pre_hashed' => TRUE,
      ],
      'status' => $user["status"],
      'mail' => $user["mail"],
      'field_first_name' => $user["field_first_name"],
      'field_last_name' => $user["field_last_name"],
);

$userStorage = \Drupal::entityTypeManager()->getStorage('user');
$userEntity = $userStorage->create($values);

    $replaced = str_replace("\\", "", $user["picture"]);
    $imageData = file_get_contents($replaced);
    $fileName = basename($replaced);
    $file = file_save_data(
        $imageData,
        "public://". $fileName,
        FileSystemInterface::EXISTS_RENAME
    );

    $media = Media::create([
        'bundle' => 'image',
        'uid' => $userEntity->id(),
        'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(),
        'field_media_file' => [
             'target_id' => $file->id(),
             'alt' => $file->getFilename(),
        ],
        'thumbnail' => [
             'target_id' => $file->id(),
             'alt' => $file->getFilename(),
        ],
    ]);

    $media->setName($fileName)->setPublished(TRUE)->save();

    $userEntity->field_user_picture->appendItem($media);

Is the something missing in the code?
UPDATE
I noticed (as also pointed out in the comments) $userEntity->save(); is missing after $userEntity->field_user_picture->appendItem($media);.
However, after I added that line, I get the following error:
Error: Call to undefined method Drupal\media\Entity\Media::getFileUri() in Drupal\image\Plugin\Field\FieldType\ImageItem->preSave() (line 321 of /var/www/html/web/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php) #0 /var/www/html/web/core/lib/Drupal/Core/Field/FieldItemList.php(233): Drupal\image\Plugin\Field\FieldType\ImageItem->preSave()

Is it related to file_save_data() function?


texts: How to load a form/page into a div via AJAX?

texts:
I want to open the create user form (/admin/people/create) into a specific div via AJAX. I can currently open such forms into a modal window using the following link format:
<a href="/admin/people/create" class="use-ajax" data-dialog-type="modal">
    Add user
</a>

Is there any way to load this form/page into a div instead of into a modal window?


texts:
I need to create dependent dropdown lists (like hierarchical select) from several referenced entity types (term_reference, node_reference, user_reference).

To be more clear:

- BMW
- - X1
- - - E84
- - X3
- - - E83
- - - F25
- - X5
- - - And so on...

1 level - taxonomy term from vocabulary 1;
2 level - taxonomy term from vocabulary 2, referenced to term from vocabulary 1;
3 level - node, referenced to vocabulary 2.

As the result I should get node:nid element.

Or another example:

- brand 1
- - model 1
- - model 2
- brand 2
- - model 3
- - model 4
- - and so on..

1 level - is a node;
2 level - node referenced to first-level node.

As the result I should get node:nid of second level node.

I guess I should create field widget that can be used in node create form.

Is it any solution without hardcoding using fapi?


texts: Why is user_role_change_permissions() throwing an error?

texts:
I want to change the permission of anonymous user to view content hits only for a blog section. I came across user_role_change_permissions(), but it is throwing an error when I use the following code.

 if ($user->uid == "0") {
   $custom_role = user_role_load_by_name('anonymous user');
   $custom_rid = $custom_role->rid;
   $custom_permissions = array(
     'view content hits' => TRUE,
   );
  user_role_change_permissions($custom_rid, $custom_permissions);
 }

The error I get is the following:

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'module' cannot be null: INSERT INTO {role_permission} (rid, permission, module) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => view content hits [:db_insert_placeholder_2] => ) in user_role_grant_permissions() (line 3154 of C:\xampp\htdocs\capacad\modules\user\user.module).

  Notice: Undefined index: view content hits in user_role_grant_permissions() (line 3152 of C:\xampp\htdocs\capacad\modules\user\user.module).

I tried also with user_role_grant_permissions(), but it doesn't work too.

How do I set a new permission for a role?


texts: Receiving two subscriptions emails when run cron using rules

texts:
I need to send subscriptions immediately to users upon updating content. It is sending one subscriptions email when I run cron manually. But, when I run cron using rules, it send two subscriptions emails.

I have checked and found that I get one email only when I use rule to send test email.

Subscriptions setting: Users are not subscribed to content type...they are subscribed to taxonomy terms only.

Using modules for mail setup:
1. Mail system.
2. Mimemail.
3. Subscriptions.
4. Mail templates.

How can I send one subscriptions email only to each users upon updating content?


texts: How to add large self hosted videos to Drual 7?

texts: The Video module for Drupal 6 has an option to use videos uploaded through FTP. The Drupal 7 version does not have that option. How can I embed large self hosted Video files?


texts: Recommendation for hosting Git VCS from my drupal installation

texts: Our community does a lot of coding work (lua, c#, php, etc) and we are looking to move away from the usual repo hosts (BitBucket/GitHub/Jenkins) and make our website more of an all-in-one experience. I've been trying to find guides for hosting a git repo and browser from a drupal installation, but all I can seem to find is installing/updating drupal with git. Are there any modules for hosting a personal git repo?


texts: Make either of 2 fields required but not both?

texts: Ive added a file field to comments so users can upload a file in a comment as well as post text. How can I make it so one of the 2 fields is required to be filled in to create a comment (so you cant submit blank comments), but without making both fileds required?


texts: How create Menu items by permissions for a view page?

texts:
My client wants a menu with a link for each content type.

Each item will displayed if the user have permission to create that
content type.
Each item will show a list of content only for that content type.

To accomplish this, I create a view page that have a filter for bundle. In that way I can use same view page for all content types. I tried too, to use same view page like /admin/content but I need to pass the content type to filter for that machine name.

What I trying to do, is create a menu item for each content type, and set permission for each item(link) using the permission that have each content type.

E.g.: My menu have a Item Article. You should see this item only If you have right to create an Article. When you click here you will see all the content Articles(like /admin/content).

It suppose that a user or role, that have permission to create a content type.. should see the item.

How can I create menu items with permission to a view?

There is my issue, because it use the permission in the view page, and not in the route.

.links.menu.yml

content_types.admin_1:
 title: 'Articles'
 parent: content_types.admin_menu
 route_name: content_types.admin_1
 route_parameters:
  type: article
 description: 'Content articles'

content_types.admin_2:
 title: 'News'
 parent: content_types.admin_menu
 route_name: content_types.admin_2
 route_parameters:
  type: nouvelle
 description: 'Content news'

.routing.yml

content_types.admin_1:
  path: '/admin/view-test'
  defaults:
    _controller: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage'
    _title: 'Articles'
  requirements:
    _permission: 'create article content'

content_types.admin_2:
  path: '/admin/view-test'
  defaults:
    _controller: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage'
    _title: 'News'
  requirements:
    _permission: 'create nouvelle content'

As you see I added _permission: 'create article content' but it didn't do anything.

admin/structure/views/view/view_test?destination=/en/admin/structure/views

The role for the user that I'm using doesn't have permission to create article or news.

UPDATED:

I created a .permissions.yml and used _permission: 'access menu item 1' but it display the item even if this permission is not ticket for that role.

.permissions.yml

'access menu item 1':
  title: Access Menu MTL 1
  description: Allow users to access menu MTL

Any suggestion?

UPDATED: January, 2019

The issue is try to use same view page(/admin/content) for each Content type with different permissions. You dont set permissions to each link, instead you set permission to the view (or item) that you are trying to access.


texts: Creating QuickTabs programmatically not working

texts:
I'm trying to create some QuickTabs programmatically like it's documented on the website, but for some reason, my code bellow doesn't generate QuickTabs at all!
What do I do wrong or am I looking at the wrong documentation here?

function quicktabsmenu_block_info() {
  $blocks['quicktabsmenu'] = array(
    'info' => t('Dynamic QuickTabs menu'),
    'cache' => DRUPAL_NO_CACHE,
  );
  return $blocks;
}

function quicktabsmenu_block_view($delta = '') {
  $block = array();

  switch ($delta) {
    case 'quicktabsmenu':
       //set tab content
        $block['subject'] = t('Syndicate');
        $block['content'] = _create_quicktabs();
        return $block;
      break;
  }
  return $block;
}

function _create_quicktabs() {
  $tabs['tabcontent'] = array(
    'title' => t('Tab 1'),
    'type' => 'freetext',
    'text' => t('Free text'),
  );
  $quicktabs['qtid'] = 'my_new_quicktabs';
  $quicktabs['tabs'] = $tabs;
  $quicktabs['style'] = 'Zen';
  $quicktabs['ajax'] = FALSE;;
  $var = theme('quicktabs', $quicktabs);
  return $var;
}


texts: Field with content entries from a content type

texts:
I want to add a field (List text) to a content type, using as values the entries of another content type.

Should I use the References module?


texts:
I would like to update a payment method settings. As I understand, the settings are inside a RulesReactionRule.

Is it possible to modify the configuration of a RulesReactionRule using a hook_update ?

Thanks.


texts: How to see override functions and template files in use for any part of the drupal site?

texts:
I remember there is a module for displaying which core or theme functions or template files are used in order to create any part of a drupal site. Has anyone know what is the name of this module?

I need this module in site building.
Thanks in advance.

gokhan


texts: Join a select form with the number of the database to check

texts:
I have this select form:

$options = array(
      'twenty' => '20',
      'hundred' => '100',
      'five_hundred' => '500',
      'thousand' => '1.000',
      'five_thousand' => '5.000',
      'ten_thousand' => '10.000',
      'hudred_thousand' => '100.000',
      'million' => '1.000.000',
      'two-million' => '2.000.000',
  );

  $form['number_select'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#description' => t('Select the number of values that you want to check.'),
  );

I want according to what number the user has selected to limit the same number how i can solve this problem?

my DB code is this:

function something_cron()

  $number = variable_get(number_select)
  $query = db_select('watchdog', 'wa')
    ->orderBy('wid')
    ->fields('wa', array('variables', 'type', 'severity', 'message', 'wid',
    'timestamp'))
    ->condition('wid', $last_id, '>')
    ->range(0,$number);
  $result = $query->execute();

  // Loop through each item and add to $row.
  foreach ($result as $row) {
    someother();
  }


texts: Some field values are erased on new node creation (D7)

texts:
It is a strange problem.

I noticed that some field values were mysteriously resetted to the default value.

Using Devel I tracked down the problem : the field values of some nodes are erased and replaced with default value when new nodes of the same content type are created.

In this case, the nodes are created programmatically through AJAX with a custom module. It often happens that the jquery event fires multiple times on a single click, which causes 2 to 5 nodes to be created almost instantly. Could it be that the extra nodes created would replace existing ones?

Thanks for any ideas


texts: Find out if you're viewing a taxonomy page

texts:
Clicking on a Taxonomy term generally takes you to a page showing several nodes which use that term. Is there a way to find out if you're viewing a specific vocabulary and save it to a variable? That way you can change the layout at will:

<?php if( $is_vocabulary_fruits ) : ?>
    Load this layout
<?php if( $is_vocabulary_cars ) : ?>
    Another layout different from the first
<?php else : ?>
    Nope, use this layout instead
<?php endif; ?>

I'm looking to place this in page.tpl.php. This means that the markup outside of the node.tpl.php is changed when viewing a taxonomy and not the node itself. How is this done in my template.php file?


texts:
As shown in the picture, I have the teaser view of a taxonomy term (Virtual Tour) which shows the node title, the node summary, the submission date, and an image added in an image field.
What I would like to achieve is to let the image float to the left of the summary. Is there a way to achieve it?


texts:
I am trying to migrate some data with the migrate api in a custom entity called Seller.

Each seller has an email address with a constraint "UniqueField" which checks, that the email address is just entered once. If i try to import a seller with an existing email address, the seller will be created although the email already exists.

So my question is: Doesn't the migration api consider the entity validation or how can I do this?

One solution for the problem would be to write a custom process plugin for the email address, but it would be nice, if the entity validation would check this automatically.


texts:
Why do all of these menu items return "Access Denied" pages no matter how many times I drush cc all and clear cache from admin/config/performance?

/**
 * Implements hook_menu()
 */
function caplogin_menu() {
  $items = array();
  $items['join'] = array(
    'title' => 'Foo settings',
    'access arguments' => array('access content'),
    'type' => MENU_NORMAL_ITEM,
  );
  $items['join/signup'] = array(
    'page callback' => 'caplogin_unified_registration',
    'access arguments' => array('access content'),
    'title' => 'Request Member Online Credentials',
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
  $items['join/login'] = array(
    'page callback' => 'caplogin_unified_login',
    'access arguments' => array('access content'),
    'title' => 'Members Login',
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}


texts: How do I pass parameters from a form redirect to a controller?

texts:
I feel like it should be easier to find this stuff out. I'm trying to pass some data from a form submission to a controller, and do something based on that data. What is the most Drupal way to do this (i.e. without accessing the request object directly)?

The form in a custom module that extends FormBase has this method.

public function submitForm(array &$form, FormStateInterface $form_state) {
    $var_to_send = $form_state->getValue('val_to_get');
    $form_state->setRedirect('my.route', [ 'sent_var' => $var_to_send ]);
}

In this case, my.route is configured like this.

my.route:
  ...
  defaults:
    _controller: '\Drupal\custom_module\Controller\MyController::index'
    ...

I have the following method in \Drupal\custom_module\Controller\MyController.php.

public function index() {
    $params = \Drupal::request()->query->all();
    $this->myfunc($params['sent_var']);
}

This page says that what I'm doing is highly discouraged. So how should I access URL parameters in a controller?


texts: Correct way to build a validator that depends on previously submitted nodes?

texts:
I'm developing a booking system using the Forms API and a node type to store a booking in.

hook_form_validate is used to make sure that no overlapping bookings are created - this  means if existing booking A is from 9:00 to 12:00, and a new booking is submitted for 11:00 to 13:00, validation fails because the range 11:00 to 12:00 overlaps. My validator looks like:

function custom_booking_form_validate($form, &$form_state) {
  $thing_to_book = $form_state['values']['field_thing_to_book'];
  $time = $form_state['values']['field_time'];

  if(overlapping_booking_exists($booking, $thing_to_book)) {
    form_set_error('Looks like this time is already taken.');
  }
}

This works as expected when two different users pick the same time in the form, customer A clicks submit and then customer B clicks submit. User B will get the form error.

However, if customer A clicks submit twice("submit spam"), the validation of the second submissions will incorrectly pass because Drupal seems to execute the validate/submit functions in this order:

(pseudocode)
validate_form_submission(first submission);
validate_form_submission(second submission);
handle_form_submission(first submission);
handle_form_submission(second submission);

While for my logic to work properly, it needs to be:

(pseudocode)
validate_form_submission(first submission);
handle_form_submission(first submission);
validate_form_submission(second submission);
handle_form_submission(second submission);

I have found two workarounds that are both unsuitable:

Hide the submit button with JS after clicking it to prevent a second click. This is not suitable because this is a live site, and therefore mischief such as
Put redundant validation logic in the hook_form_submit function. This is not really an option because the clients' requirements are quite complicated and change regularly,

How do we solve this "the drupal way"?


texts:
I am trying to pass variables to a custom block in a module. I can see that the custom block is used in the code, however I cannot get the variables to show up.

Any help much appreciated:

I am themeing the block in the module file

function etypeservices_theme($existing, $type, $theme, $path) {
   return [
    'block__etypeservices' => [
      'variables' => [
        'facebook' => '',
     ],
   ],
];
}

I am building the render array

class SocialBlock extends BlockBase implements BlockPluginInterface {
/**
 * {@inheritdoc}
 */
public function build() {
    $config = \Drupal::config('etypeservices.settings');
    $facebook = $config->get('facebook');
    return [
      '#theme' => 'block__etypeservices',
      '#facebook' => $facebook,
   ];
 }

}

and here is the template

{%
    set classes = [
   'block',
   'block-social-icons',
   ]
%}

    {% if facebook %}

Facebook

    {% endif %}

Can anybody see why this is not working?


texts: How can I change the front-page title when front page is not /node?

texts:
I changed the site's front page from /node to another page. However, now the title of the front page is page name | site name. To clear up any confusion, by "title," I mean the phrase entered between the HTML <title> tags.
I tried this SO answer, but it had no effect. How can I declaratively change the name of the site's main page?


texts: Make page accessible to logged in users only

texts:
I need to make a basic page available to logged in users only and also need to retrieve information based on their login. I installed the Content Access module but it is not granular enough for me. Where would I modify the page that non-logged in users see?

Also, is there a way to store additional information in the user account such as an ID to our third-party database that we use to store user information? I will be retrieving this information to show in my first sentence above.


texts: Composite block from multiple other blocks + layout

texts:
I would like to create a block consisting of multiple other blocks, combined with a layout or some other kind of wrapper html.

A typical example would be a footer with 4 columns containing a menu, some custom text, etc.

The entire thing should be configurable in the UI and then exportable to the CMI system.

Known solutions

I know that this is possible in Drupal 7 using renderkit + cfrblock. However this has not been ported to Drupal 8 (yet). I will get there eventually, but atm I would like to find out if another solution might already exist.

EDIT:
On D8 there is blockgroup, but it does not really work for me.

Related issues

How to group multiple blocks into one big block I think this is for D7.

Thanks!


texts: image_style_create_derivative not resizing the image

texts:
I am using image_style_create_derivative to create image styles on fly. Before that I am using image_style_path which creates style path.

$derivative_uri = image_style_path([style_name], [source]);
image_style_create_derivative([style_name], [source], $derivative_uri)

It generates image. Which is fine. But it is generating image with original size. Not with the size of style_name.

For example if style name is thumbnail, the generated image style size should be 160x100.

How can I achieve it?


texts: Call javascript right after the form elements are rendered

texts:
I have a content-type "Document". I have a multiple select dropdown box in my form.

$form['priorities']['selectoffid'] = array(
    '#type' => 'select',
    '#title' => 'Select Signatories',
    '#id' => 'select-chosen',
    '#attributes' => array('multiple' => 'multiple', 'style' => 'width:100%'),
);

Each option of the dropdown corresponds to a textfield. Selected option's corresponding text field are shown and unselected option's corresponding text field are hidden.

Now everytime I hit the Save button  and some other required form elements are not filled, it reloads and display the form errors. After reloading some text fields that are supposed to be visible is now hidden.

The value of the multiple select dropdown still consist of 3 values, according to the $form_state variable , but some of it's corresponding text fields are not visible anymore. How will I make it visible again? I tried using after_build form.

$form['#after_build'][] = 'document_monitoring_form_after_build';

function document_monitoring_form_after_build($form, &$form_state){

    drupal_add_js(drupal_get_path('module','document_monitoring') . '/myscript.js');

    return $form;
}

In my myscript.js :

alert('Javascript is called');
document.getElmentById('priority-6').style.display = 'block';
document.getElmentById('priority-22').style.display = 'block';
document.getElmentById('priority-5').style.display = 'block';
alert('Javascript is called');

The javascript is called before the multiple select dropdown is rendered. How will I make the javascript be called right after the form elements is rendered?


texts:
I want to empty the cart before a product in the code. I tried

$this->cartProvider->emptyCart($cart);

But this did not work and gave an error. I am doing this in Drupal 8. I am adding products in the controller code.

This is how I am fetching the cart.

$destination = \Drupal::service('path.current')->getPath();
   $productObj = Product::load($productId);

   $product_variation_id = $productObj->get('variations')
     ->getValue()[0]['target_id'];
   $storeId = $productObj->get('stores')->getValue()[0]['target_id'];
   $variationobj = \Drupal::entityTypeManager()
     ->getStorage('commerce_product_variation')
     ->load($product_variation_id);
   $store = \Drupal::entityTypeManager()
     ->getStorage('commerce_store')
     ->load($storeId);

     $cart = $this->cartProvider->getCart('default', $store);

     $this->cartManager->emptyCart($cart);

   if (!$cart) {
    $cart = $this->cartProvider->createCart('default', $store);

   }

   $line_item_type_storage = \Drupal::entityTypeManager()
     ->getStorage('commerce_order_item_type');
// Process to place order programatically.
   $cart_manager = \Drupal::service('commerce_cart.cart_manager');
   $line_item = $cart_manager->addEntity($cart, $variationobj);

    $response = new RedirectResponse(Url::fromRoute('commerce_cart.page')->toString());
    return $response;


texts: Hide already purchased products (or allow purchasing the product only once)

texts:
I have a view with a list of product displays, and I would like to hide all the products that are already purchased by the current user. This would allow purchasing products only once per user.

I've tried to modify the view and add a relationship with the order, but I can't find the relationship "Order".
As explained in the similar issue http://drupal.org/node/1221372 , I also tried to create a view of "Commerce Order". I think this would work for displaying a list of purchased products, but not for displaying a list of non-purchased products, because a view of 'Commerce Order' displays results with orders, not results without orders.

Can anyone help me? :)


texts: Views, adding I like, Retweet - best approach

texts:
I have several views.

Now I need to add FB I like and retweet button to those views.

I search for modules, but all I get doesn't goes with Views well.

I would like to pass nid of node as excluded field and use Views Custom Field to create those links, but is this possible to get data from another field in custom field?


texts: How to change Webform field value after a webform has been submitted

texts: I have a webform with a hidden field having a default value of No.  How do I change this value to Yes after a webform has been submitted using Rule? I'm using Drupal 7.x.  Thank you.


texts: After Update to 8.5.6, "Add" Links Missing From Page but still are in router

texts:
I recently manually updated Drupal to the 8.5.6 version.  I did this by moveing over the files (using command line) according to Drupal.org instructions and running update.php.

I have two issues that I'm guessing are related:

My themes no longer toggle from the front end and I can't force them to change by clearing cache, running cron, rebuilding menu or anything else that I can think of.
All "add" links are missing ** - "Node/add" is present in the routing file and still works.  However, it is missing from the content page. It also seems that ALL "add" links are missing from the site. To get there, I need to manually type in the path.

I am running out of obvious ideas on how to fix.  Can anyone point me in the right direction?

I followed the instructions below:

Drupal Page on Running Installation Manually

Below, you can see the commands Drupal tells you to follow:

cd /path/to/your/drupal/directory
rm -rf core vendor
rm -f *.* .[a-z]*
wget https://www.drupal.org/files/projects/drupal-x.y.z.tar.gz
tar -zxvf drupal-x.y.z.tar.gz
cd drupal-x.y.z
cp -R core vendor /path/to/your/drupal/directory
cp *.* .[a-z]* /path/to/your/drupal/directory


texts:
I am using book navigation block which contains links to content of BOOK.I would like add ajax functionality to this links.

I tried adding use-ajax class to this links.But i was unsuccessful.

Please let me know how to ajaxify links of book navigation block

Thanks a lot for the help.