A quick google search gives me the impression  that there is no such module available just yet.

Feel free to provide it to the community if you want ;-)

You can take a look here if you want:

http://emicalculator.net/emi-calculator-widget

That might  give you a good starting point.


Create custom form button that does not submit webform

Something like this may work.

#name and #submit are required.

The name makes sure the button does not get confused with other submit buttons.

The #submit value calls a custom function you have to create.

#limit_validation_errors prevents form validation, which may or may not be useful.

  $form['generate_pdf'] = [
    '#type' => 'submit',
    '#value' => $this->t('Generate PDF'),
    '#name' => 'generatepdf',
    '#submit' => ['::generatepdf'],
    '#limit_validation_errors' => array(),
  ];


Output same content type in different format

The easiest would be to use Views Datasource which allows you to output any data in XML, JSON, XHTML with different schemas. You can the set your own URLs and can have fine control over the output.

Another, rather primitive way is to use the RSS feed with full content on, but I take it that may not be what you are looking for, yet when all else fails — it is better than nothing.


Ubercart : How to display product information ( of certain brand ) as XML?

Find the steps to create XML for certain product:

Enable the catalog module
add Brand as a term
Create products and assign it to certain brand
uc_catalog view is available for to show the listed product in certain brands
make that view as RSS feed using View RSS module


setting checkbox Checked in user_registration_form

Please Try this

$form['account']['notify']['#default_value'] = TRUE;

Thank You.


What are Hooks in Drupal and can I learn and use them if I've yet to learn PHP?

Hooks can be thought of as internal Drupal events. They are also called callbacks, but because they are
  constructed by function-naming conventions and not by registering with a listener, they are not truly
  being called back. Hooks allow modules to “hook into” what is happening in the rest of Drupal.

Suppose a user logs into your Drupal web site. At the time the user logs in, Drupal fires hook_user_login.

That means that any function named according to the convention module name plus hook name will be called. For example, comment_user_login() in the comment module,
locale_user_login() in the locale module, node_user_login() in the node module, and any other
similarly named functions will be called.

If you were to write a custom module called spammy.module and
include a function called spammy_user_login() that sent an e-mail to the user, your function would be
called too, and the hapless user would receive an unsolicited e-mail at every login.

  The most common way to tap into Drupal’s core functionality is through the implementation of
  hooks in modules.

You have to use coding to implement hooks and you need to know PHP.

  For more details about the hooks Drupal supports, see the online documentation at
  http://api.drupal.org/api/7, and look under Components of Drupal, then “Module system (Drupal hooks).”


Php Access User Data from external script

You can following file authorize.php to do it like this:

<?php
use Drupal\Core\DrupalKernel;
use Drupal\Core\Site\Settings;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

$autoloader = require_once 'autoload.php';

function authorize_access_allowed(Request $request) {
  $account = \Drupal::service('authentication')->authenticate($request);
  if ($account) {
    \Drupal::currentUser()->setAccount($account);
  }
  return Settings::get('allow_authorize_operations', TRUE) && \Drupal::currentUser()->hasPermission('administer software updates');
}

try {
  $request = Request::createFromGlobals();
  $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
  $kernel->prepareLegacyRequest($request);
}
catch (HttpExceptionInterface $e) {
  $response = new Response('', $e->getStatusCode());
  $response->prepare($request)->send();
  exit;
}

authorize_access_allowed($request);
$user = Drupal::currentUser();

if ($user->id()) {
    print "Logged in";
} else {
   print "Logged out";
}


How to create a view to display poll results formatted as a chart?

About this phrase in the question:

  display poll results using 3rd party charting app

To create charts in Drupal, consider the comparison of charting modules as a possible place to start from, to find the module that best fits your needs. That comparison includes the following: "Poll Chart Block displays poll's results in a block, with a selectable chart type, and using the Chart module." So it looks like what you're trying to achieve already exists as a contributed module, no?

Be aware: I'm a new (co-) maintainer of Chart, and the author of the comparison of charting modules.


Found the solution. Just for future references for others and me as well :-)

There is an issue in Services module Wrong username and password, just after a creation of a user where someone faced the same problem. User login just registration. So as it stated,

  If you are anonymous user and register a user your register form does not have password field at all. It has only username and email fields. All instructions are sent by email (with token to log in and set the password). So register call actually does not set the password.

This is actually true. If I go to the admin and change the password again then it's working. So the solution is to alter two variables,

variable_set('user_email_verification', FALSE);
variable_set('user_register', TRUE);

This will now allow the users to register by themselves.


Create a block with articles from the current edition

I presume you categorize your content using taxonomy terms, or?
So, as an example, you create an article for issue number '122' and you 'could' use this in the url of your article, such as www.example.com/articles/issue_number/node_id

In this example, if the node id was 12345, the full url would look like this:

www.example.com/articles/122/12345

Now you could use views and arguments - in Views 3 'Arguments' was renamed to 'Contextual filters'.
So,

Create a view -> create block -> unformatted list -> titles (linked)
add a Contextual filter
Content -> Has taxonomy term ID
When the filter value is NOT in the URL: -> Provide default value ->
Type: Taxonomy Term ID from URL -> Load default filter from node page, that's good for related taxonomy blocks.
Check the boxes of the taxonomies you want involved here
skip to point 11

------------ old way -------

Provide default argument -> php code

$node = node_load(arg(1));
if($node) {
//Be sure to rename ->field_taxonomy_name to your field name
foreach($node->field_taxonomy_name[LANGUAGE_NONE] as $term) { $terms[] = $term['tid']; }
 return implode('+',$terms);
} else { return; }

Allow multiple terms per argument -> yes
Reduce duplicates -> yes

^^----------- old way ---------^^

Create a second argument to remove the currently displayed node from related content block
so, add a 2nd Contextual filter
Select Node: Nid
Action to take if argument is not present -> Provide default argument
Default argument type -> Node ID from URL
Exclude the argument -> yes
Save
Add block to node pages, only display in articles/*


The code you are showing is wrong because DrupalDateTime::__construct() is expecting a string, while you are passing an integer, which is what Node::getCreatedTime() returns.

Instead of DrupalDateTime::__construct(), you should use DrupalDateTime::createFromTimestamp().

$date = DrupalDateTime::createFromTimestamp($variables['node']->getCreatedTime(), 'UTC');

Since the static method also accept a \DateTimeZone object as second parameter, your code could be similar to the following one.

if (isset($variables['node'])) {
  $date = DrupalDateTime::createFromTimestamp($variables['node']->getCreatedTime(), new \DateTimeZone('Asia/Tehran'));
  $variables['date'] = $date->format('Y/m/d');
}

Since you seem interested to get strings in a specific language, you should also set the language code.

if (isset($variables['node'])) {
  $date = DrupalDateTime::createFromTimestamp($variables['node']->getCreatedTime(), new \DateTimeZone('Asia/Tehran'), ['langcode' => 'the language code for the language you need']);
  $variables['date'] = $date->format('Y/m/d');
}


Why is Drupal CSS/JS Aggregation files stored in sites/default/files?

Because the file is served and needs to be accessible via the web server. sites/default/files is typically the default location for uploaded content, or content that is generated dynamically, which these CSS/JS files are.

Your situation happens to be because css (Central Safety Services) happens to be the same directory that Drupal uses to store these files. The recommended solution is to update the path name in the database for their files to something else.

Drupal has the ability to configure the directory where the files are stored, under File System in the admin, but ultimately it has to store them somewhere below Drupal root directory.

Drupal 6: http://drupalsitename/admin/settings/file-system
Drupal 7: http://drupalsitename/admin/config/media/file-system


Not able to navigate through different sections of administrator page of fresh installed drupal 7.14

During drupal installation you should be careful of following things;

Download and unzip drupal properly.
copy and paste that into your var/www (for linux) and xampp/htdocs (windows).
Rename the drupal folder to ur project name. Don't make any subfolder.
Make sure there is no spaces during renaming the drupal folder.
After creating database. Doing changes in settings.php run install.php in ur browser.
 If u r using linux give all permissions.


Subdomain with shared database for users: subdomain not accessing primary database

I would advise to look into the answers of this question. One solution is indeed a specific setup in settings.php, however all your sites need to make use of the same database when using that option. E.g.:

$databases['default']['default'] = array(
  'driver' => '[Your database engine]',
  'database' => '[Your database name]',
  'username' => '[Your username for the access to the database engine]',
  'password' => '[The password for the access to the database]',
  'host' => 'localhost',
  'prefix' => array(
    'default'   => 'main_',
    'users'     => 'shared_',
    'sessions'  => 'shared_',
    'role'      => 'shared_',
    'authmap'   => 'shared_',
  ),
  'collation' => 'utf8_general_ci',
);

The solution above uses the same database for all sites, but different table prefixes. So in the example above most tables will be prefixed with "main_", but the users, sessions, role and authmap tables will be prefixed with "shared_". For your additional sites, you will use a different prefix for 'default' (maybe 'site2_', 'site_3', etc.) but the same 'shared_' prefix.

(all credits to zdecibel & Dalin for the example & explanation above)

Another option is using the Domain Access module, which is developed for this kind of purposes.


Add a custom submission handler to a form

If you use hook_form_node_form_alter() maybe use example code:
function MYMODULE_form_node_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  foreach (array_keys($form['actions']) as $action) {
    if ($action != 'preview' && isset($form['actions'][$action]['#type']) && $form['actions'][$action]['#type'] === 'submit') {
      $form['actions'][$action]['#submit'][] = 'mymodule_form_submit';
    }
  }
}

and for the submit function use:
function MYMODULE_form_submit(array $form, \Drupal\Core\Form\FormStateInterface $form_state){
  //die("I'm not getting run, why :(");
  \Drupal::service('messenger')->addMessage("Why won't this message show?");
}


A rule like this should do it:

#logo {
  display: block;
  width: 100px; // width of the image
  margin: 0 auto;
}


Drupal shortcuts - link with question mark included

The shortcut module is more strict about valid URLs it can use compared to what the menu module will allow (e.g. no external URLs, no query param).

One way to circumvent this is to use hook_menu in a custom module to define a valid path that redirects where you want it to go and add that path to your shortcut set.

function MYMODULE_menu() {
  $items['MYMODULE/work'] = array(
    'access arguments' => array('access content'),
    'page callback' => 'drupal_goto',
    'page arguments' => array('admin/work', array('query' => array('date_filter' => 'XXX'))),
    'type' => MENU_CALLBACK
  );
  return $items;
}

This makes MYMODULE/work a valid path for your shortcut set.


How to override limit of only 10 items showing in Create an Order page in Drupal Commerce?

This should be the screen you are referring to yes?

The field here is an auto complete field that is widely used in Drupal Commerce.  And yes the hints are limited because if they were not limited then the AJAX call could take a very long time to run.  You have to keep typing to narrow down your options in the provided guesses.

Short answer: No you cannot change this without hacking Commerce.

Long answer: To change this would require a lot of work because the create order form (/admin/commerce/orders/add) is built by attaching fields from the entity. Specifically here is the code that creates the form in the image above. So in order to change this you would have to alter the field types of the order entity. Specifically the Product SKU field would have to be altered and it's call back replaced with one that would load more than 10 items.  Doing so would of course alter Commerce and any upgrade you did to Commerce would erase your alterations.

// Add the field related form elements.
$form_state['commerce_order'] = $order;
field_attach_form('commerce_order', $order, $form, $form_state);

This uses field_attach_form to attach elements to the existing form based off the entity, in this case the entity 'commerce_order'.


Remove trimmed version form preview screen?

Ah, the linked template.php override method (code below) does work but you need a sub theme for it to do so.

/**
 * Override node preview to remove trimmed teaser version.
 */
function theme_node_preview($variables) {
  $node = $variables['node'];

  $output = '
';

  $preview_trimmed_version = FALSE;

  $elements = node_view(clone $node, 'teaser');
  $trimmed = drupal_render($elements);
  $elements = node_view($node, 'full');
  $full = drupal_render($elements);

  // Do we need to preview trimmed version of post as well as full version?
  if ($trimmed != $full) {
   // drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication. You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.'));
    //$output .= '
' . t('Preview trimmed version') . '
';
    //$output .= $trimmed;
    //$output .= '
' . t('Preview full version') . '
';
    $output .= $full;
  }
  else {
    $output .= $full;
  }
  $output .= "
\n";

  return $output;
}

UPDATE this has stopped working for me. It seems the code doenst work properly with my zen template.

UPDATE This code worked for me:

            /**
             * Returns HTML for a node preview for display during node creation and editing.
             *
             * @param $variables
             *   An associative array containing:
             *   - node: The node object which is being previewed.
             *
             * @ingroup themeable
             */
            function THEMENAME_node_preview($variables) {
              $node = $variables['node'];

              $output = '
';

              $preview_trimmed_version = FALSE;

              $elements = node_view(clone $node, 'teaser');
              $trimmed = drupal_render($elements);
              $elements = node_view($node, 'full');
              $full = drupal_render($elements);

              // Do we need to preview trimmed version of post as well as full version?
              if ($trimmed != $full) {
               // drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication. You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.'));
               // $output .= '
' . t('Preview trimmed version') . '
';
               // $output .= $trimmed;
               // $output .= '
' . t('Preview full version') . '
';
                $output .= $full;
              }
              else {
                $output .= $full;
              }
              $output .= "
\n";

              return $output;
            }


With the following code I managed to create the flag link to embed in the email body:

global $base_url;
$flag_url = $base_url . base_path() . 'flag/confirm/flag/my_flag/' . $nid;


Commerce cart line item to show original price, not the one with discounts subtracted

Maybe this could help you out. https://www.drupal.org/project/commerce_price_savings_formatter


How to export data from drupal to Excel?

You are in luck! There is a module for that. (I love saying that!)

Views Excel Export
Views

This is an extension for Views module, which pretty much can list any data from Drupal's DB; users, content, comments and any other entities. You will have to install the Views module and then install the Views Excel Export module which will export the list generated by Views to an Excel file. Without any code! Brilliant isn't it?

If you need instructions on how to install a module in Drupal, you can follow Installing modules (Drupal 7) on Drupal documentation.


Content Type - turn in to Form on front end to be used

Under /admin/people/permissions you can grant a role access to create/edit/delete content of a specific type.

Look for the sub-heading Node and pick your content type from any listed. I've highlighted Poll in my example.

Click here for full size image

Here is the guide for roles and permissions from Drupal:
https://drupal.org/node/120614


Displaying a text field for the user to embed media, and then enabling rating (fivestar) for that content; listing all of them as separate writings

Why don't you just let your users create a node with this field and a fivestar widget and then you use node_view() to display these nodes in your page.

Updated:
To embed the node form in a page, have a look at Embedding CCK content type create form in your page, then create a block and put this code in it (select the php format - you have to activate the php filter module first):

if(!function_exists("node_object_prepare")) {
  include_once(drupal_get_path('module', 'node') . '/node.pages.inc');
}
print node_add('store_review');  //put the content type machine name here.

Then on another page you create a view to retrieve the listing of your videos.

You can also have a look at the Blockify module it may be useful to embed the node form (I'm not sure it'll do the job but can be easy if you're not comfortable with embedding PHP code in a block).


Do I still need to add verifications if the site has been verified through Google Analytics?

It's up to you, of course. from the module's page:

  This module is useful for the following search engine verifications:

  Google Webmaster Tools
  Google Apps
  Bing Webmaster Central (formerly Live Search)
  Yahoo! Site Explorer
  Yandex.ru
  Any search engine or web service that uses META tags or file upload to verify that you are the owner of a site.

You are the one to know if you will need or want assistance with verification against above tools.


Is media-7.x-1.x vulnerable to SA-CONTRIB-2018-020

According to Joseph Olstad 1.x is not vulnerable to the problem found in the 2.x branch. Source:
https://www.drupal.org/project/media/issues/2966112#comment-12592407

There is a previously unreleased fix for another security issue though. This was integrated in version 1.7 of this module.


How do I detect spam from among published comments?

I use a view, that shows me 200 comments at once with their body. So by quickly looking at the list of the comments, I can see which are span and checkmark them to delete.

You can copy this view from the gist here: https://gist.github.com/timonweb/5990901

Make sure you have Views Bulk Operations (https://drupal.org/project/views_bulk_operations) module installed, then import the view from the gist and go to: http://yoursite.com/admin/content/comment/moderate.


How can I add something after the day/hour/time in a date select list?

You can't use hook_form_alter() or hook_field_widget_form_alter() in this case. Try with hook_element_info_alter()

function MY_MODULE_element_info_alter(array &$types) {
  if (isset($types['datelist'])) {
     $types['datelist']['#process'][] = '_mymodule_add_suffix_value';
  }
}

function _mymodule_add_suffix_value(&$element) {
  // process logic option $element['day']
  // process $element['month']
  // process $element['hour']
  return $element;
}


Media module and wysiwyg inserts image link rather than rendered image

You can fix this in the web admin GUI:

Configuration > Media > File Types > Image > Manage File Display > Check the "Image" box.


I had the same question a while ago here.

hook_node_access is not recognized by views or menus. It should only be used as the last line of defense.

A better way to control node access is through hook_node_access_records and hook_node_grants as described here and here  .


You can use orConditionGroup, but the IN operator is a shorthand for OR conditions on the same field:

->condition('roles', ['role1', 'role2'], 'IN')


Bootstrap simple carousel: how to display it on front-end?

If you look at https://git.drupalcode.org/project/bootstrap_simple_carousel/blob/8.x-1.x/src/Plugin/Block/CarouselBlock.php

/**
 * Provides a 'Bootstrap simple carousel' Block.
 *
 * @Block(
 *   id = "bootstrap_simple_carousel_block",
 *   admin_label = @Translation("Bootstrap simple carousel block")
 * )
 */

There is a block for it, called, "Bootstrap simple carousel block". You just have to place it in a region over at /admin/structure/block


Can I use my own template for a view mode?

The standard way to do this is to create a template in your theme, you can use node--nodetype--viewmode.html.twig . (two dashes between each part).

To use it in your custom module, you'd have to use hook_theme_registry_alter to change the path that it looks in for that theme hook.

function mymodule_theme_registry_alter(&$theme_registry) {
  $theme_registry['node__nodetype__viewmode']['path'] = drupal_get_path('module', 'mymodule') . '/templates/';
}

I don't really see the value of moving it into a custom module though.  It's a standard to keep custom templates in the theme.


An AJAX HTTP request terminated abnormally

I have setup a cron job that sending mail to 500 users in every half hour.


How do I get at the raw file name of a File entity in a Twig field override?

to get the filename you can use this:

{{ item.content['#file'].filename.value }}


The webserver must not have the correct permissions to access those CSS and JS files. You need to set the correct permissions on the /sites/default/files/css and /sites/default/files/js directories. Allow read access at the very least.


How to add module libraries to the page through an admin page?

Your module is referencing the library names wrong. It should be “mymodule/library_name” instead of just the library name.

As long as you get that right, it wouldn’t be hard to loop node field values or a config object and add them like that.


Your field only stores the file ID, so it makes sense that theme_get_settings only returns a number. If I'm not mistaken, this should work:

use Drupal\file\Entity\File;
function casper_preprocess_page(&$variables){
  // Get the value of the first element in the array.
  $fid = reset(theme_get_setting('frontpage_background_image', 'casper'));
  // Load the file.
  $file = File::load($fid);
  // Generate the URL.
  $variables['frontpage_background_image'] = $file->url();
}


How to translate field collection which has unlimited values?

I think that I found a workaround for this problem. Check my post at drupal.org.


"jquery_file_upload.id is part of the primary key but is not specified to be 'not null'"

The error message is about the schema currently used by the module, which defines the primary key using the following code.

function jquery_file_upload_schema() {
  $schema['jquery_file_upload'] = array(
      'description' => t('Stores files sizes for each user.'),
      'fields' => array(
          'id' => array(
              'description' => t('auto increment'),
              'type' => 'serial',
              'size' => 'normal',
          ),
          'uid' => array(
              'description' => t('registered user'),
              'type' => 'int',
              'unsigned' => TRUE,
              'not null' => TRUE,
              'default' => 0,
          ),
          'file_name' => array(
              'description' => t('File Name.'),
              'type' => 'varchar',
              'length' => '255',
              'not null' => TRUE,
          ),
          'file_size' => array(
              'description' => t('File Size.'),
              'type' => 'float',
              'size' => 'big',
              'default' => 0,
          ),
      ),
      'primary key' => array('id'),
  );
  return $schema;
}

The correct definition would be the following one, as the fields that are part of the primary key should be declarated as "NOT NULL."

function jquery_file_upload_schema() {
  $schema['jquery_file_upload'] = array(
      'description' => t('Stores files sizes for each user.'),
      'fields' => array(
          'id' => array(
              'description' => t('auto increment'),
              'type' => 'serial',
              'size' => 'normal',
              'not null' => TRUE,
          ),
          'uid' => array(
              'description' => t('registered user'),
              'type' => 'int',
              'unsigned' => TRUE,
              'not null' => TRUE,
              'default' => 0,
          ),
          'file_name' => array(
              'description' => t('File Name.'),
              'type' => 'varchar',
              'length' => '255',
              'not null' => TRUE,
          ),
          'file_size' => array(
              'description' => t('File Size.'),
              'type' => 'float',
              'size' => 'big',
              'default' => 0,
          ),
      ),
      'primary key' => array('id'),
  );
  return $schema;
}

There is nothing you can do, if not opening an issue report for the module, in its issue queue. Be sure there isn't already a report about that.


In your code where you are setting the value move the last line above variable_set() function

Change this code:

 $staff_action = $_GET['staff_action'];
$first_name = $_GET['first_name'];
variable_set('first_name', $first_name);
$last_name = $_GET['last_name'];
variable_set('last_name', $last_name);
$email = $_GET['email'];
variable_set('email', $email);
drupal_set_message($email . " in first function");

To this:

 $staff_action = $_GET['staff_action'];
$first_name = $_GET['first_name'];
variable_set('first_name', $first_name);
$last_name = $_GET['last_name'];
variable_set('last_name', $last_name);
$email = $_GET['email'];
drupal_set_message($email . " in first function");
variable_set('email', $email);

Then it should work.


The correct code is similar to the following one.

I will add some notes about the code as I wrote it:

If you use "form-test/%node" (instead "form-test/%"), the node will be loaded from Drupal, and if there are some problems with loading it, it will report an error (404, page not found) to the user; in this way, you don't need to call node_load() as that is already done by Drupal.
There is a callback that returns the title Drupal should use.
I am not sure I translated correctly the strings you were using (I guess it was Swedish, but I am not positive, as I don't know Swedish); I had to translate the strings, as t()'s argument is a string in English, which will be translated in the language set for the site.

function formtest_menu() {
  $items['form-test/%node'] = array(
    'title' => 'Export',
    'title callback' => 'formtest_title',
    'title arguments' => array(1),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(formtest_simple_form, 1),
    'access arguments' => array('access administration pages'),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

function formtest_title($node) {
  return t('Export Klicket from @title', array('@title' => $node->title));
}

function formtest_simple_form($form, &$form_state, $node) {
  $form['#node'] = $node;

  $items = array(
    t("Title: @title", array('@title' => $node->title)),
    t("Where is my beef?")
  );

  $form['item_list'] = array(
    '#theme' => 'item_list',
    '#items' => $items,
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Export as Klicket')
  );

  return $form;
}

function formtest_simple_form_submit($form, &$form_state) {
   // Write the email.
   // If you need the node object, it is in $form['#node'].
}


How to change File field icons (without changing core)?

You can override theme_file_icon in your theme, and specify different icon images. See file_icon_path for reference regarding how core determines which icons to use.

You can also set the "file_icon_directory" variable to the path to your icons, as the file_icon_path function looks for the path in that variable.


Drupal 7 block api, is this custom module correct?

Very nearly, but not quite.

You're missing the function arguments in your hook implementation, so there's nothing there to actually alter.
The blocks array is keyed by module, then block delta, so you would need to access the block using those instead of the title as you currently are.
You're trying to overwrite the system main block in it's entirety rather than changing a property on it.
You've spelt function wrong ;)

Try:

function MYMODULE_block_info_alter(&$blocks, $theme, $code_blocks) {
  $blocks['system']['main']['weight'] = -9999;
}


Yup. You can use hook_FORM_ID_alter() to change any field into text area into a WYSIWYG field:

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

  //Set the type to text format
  $form['parameter']['message']['settings']['message']['#type'] = 'text_format';

  //Replace 'full_html' with 'filtered_html' or any other input format that has a WYSIWYG profile
  $form['parameter']['message']['settings']['message']['#format'] = 'full_html';
}


Use theme_item_list function for it, see the below code

$title = 'Title';
$type = 'ol';
$items = array(
  'one',
  'two',
  'three',
  'four',
  'five',
);
$items[] = array(
  'data' => 'something',
  'class' => array('dummy'=>'category'),
  'children' => array('1.1','1.2',array('data'=>'1.3','class' => array('dummy'=>'category'),'children'=>array('1.3.1','1.3.2')))
);
$attributes = array('class' => array('test-class', 'demo-class'));

print theme_item_list(array(
  'items' => $items,
  'title' => $title,
  'type' => $type,
  'attributes' => $attributes
));

This will give you following HTML output:

Title

one

two

three

four

five

something

1.1

1.2

1.3

1.3.1

1.3.2


Making text fields autocomplete in views exposed filters

Views change elements after form generation, so you should add own after build function:

function nk_form_alter(&$form, &$form_state, $form_id) {
    if (($form_id == 'views_exposed_form') &&  ($form['#id'] == 'views-exposed-form-my-page')) {
      $form['#after_build'][] = 'nk_views_mypage_exposed_after_build';
    }
}

function nk_views_mypage_exposed_after_build($form, &$form_state) {
  $form['title']['#autocomplete_path'] = 'nk/autocomplete';
  $form['title']['#default_value'] = 'abcd'; // this one also doesn't work
//  print_r($form); // I recommend to use dsm function of devel module, instead of print_r.
  return $form;
}


how do I control order of promoted pages?

There is a tutorial at Custom re-ordered front page teasers. It uses the pre-packaged view Front page that comes with Views, as well as the Nodequeue module to re-order the teasers.

  The Nodequeue module allows users to collect nodes in an arbitrarily
  ordered list. The order in the list can be used for a any purpose


How can i display tokens with html tags?

Try this one -

$replacements[$original] = \Drupal\Core\Render\Markup::create("<b>Hello</b>");

Helpful links:

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21Markup.php/class/Markup/8.2.x

http://www.drupaldump.com/drupal-8-how-have-custom-tokens-html-them-properly-replaced


No there's no such hook I'm afraid (see the list of hooks for Drupal 7).

If you want caching that goes beyond the normal static page cache provided by node_load() then you might want to look at the Entity Cache module, which "puts core entities into Drupal's cache API.". Even if you don't end up using that module you can inspect the code to get some ideas for implementing your own caching system.


Generally, the correct way is to throw new AccessDeniedHttpException() over setting a 403 or a redirect response, which bypasses the exception handling, so that it's no longer possible to configure a different handling of 403's in contrib or custom code. Unless you want to bypass this intentionally, for example if you want to produce a faster 403.

However, in most cases it is preferable to control the access as route requirement. The main effect is the same, the routing system throws an exception as well. But it does other things, like controlling the visibility of menu links, which you don't get when you throw the exception in custom code.


What is the correct ways to add themes to a profile within an Aegir install

I figured out a work around, actually it is quite simple. First ssh in as root. Then switch users su - aegir. Now drush will work. then simply use the drush command with the @sitename, so for instance drush @sitename.com dl themename. now this downloads to sites/all/modules, if you want you can move it to sites/sitname/modules. Either way it's a pretty fast workflow.


Use Display Suite to manage your display and show/hide fields for Taxonomy terms. You can actually display nothing. Then add the blocks in there.

Second option is alter taxonomy term page.tpl.php - a function that you need to add in template.php within your theme directory.

This is a function for templating pages for content types or terms. Second part defines page--taxonomy--term.tpl.php suggestion. It worked for me.

<?php
/**
* Add / modify variables before the page renders.
*/
function YOURTHEMENAME_preprocess_page(&$vars) {
// custom content type page template
  // Renders a new page template to the list of templates used if it exists
  if (isset($vars['node']->type)) {
// This code looks for any page--custom_content_type.tpl.php page
    $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
  }
    if(arg(0) == 'taxonomy' && arg(1) == 'term') {
        $tid = (int)arg(2);
        $term = taxonomy_term_load($tid);
        if(is_object($term)) {
           $vars['theme_hook_suggestions'][] = 'page__taxonomy__'.$term->vocabulary_machine_name;
        }
  }
}
?>

I hope it helps. A while ago, I've been looking for this solution for days!


Render a content type bundle in a custom module template

I'm not sure what you're exactly asking, but there are various modules that allow you to display entity forms in a block, for example Entityform block (Disclaimer, maintained by me).

Either use that, you can use form modes and/or form alters to then customize the form, or just look at the code to see how to do it.

One thing that this module doesn't support yet is editing existing entities, I'd love to add support for that using the plugin context system.


You need to disable the module on http://example.com/admin/modules first. That should take care of your error messages.

If your administration interface is not accessible - caused by the error message - you could access the database directly and disable the module in the system table - as suggested by Mołot and outlined in https://drupal.org/node/157632.

Additionally to disabling the module, you should also uninstall it - which will remove any configuration and data associated with this module from the database: http://example.com/admin/modules/uninstall (at least it should, if it is properly written).

Now, you can safely remove the module from the modules directory, if you want to. Since the module is disabled and uninstalled, it will not interfere with your Drupal installation, however, it is advisable to clean up the modules directory, and move the module to a location outside the webroot - to avoid issues if the module has security holes and the web-server is (mis)configured to allow direct execution of modules.

Before you do all this, I would save a backup of the database and the custom module, in case the functionality and data might be needed after all.

You can of course do all of this also on the command line using drush - since you asked about ftp, I assume you do not have ssh access.


What's wrong in my code for setting up entity title in a Computed Field?

You can't do it all in the first box.

Use the Computed Code box to create a value for the field in $entity_field[0]['value'].

Then use the Display code box to do something with this value.


Compare form input with user password in drupal 7

If I copy the user from the other database and save it to the main database user_check_password() does work. While I don't like this it does work…

If you have a better answer please submit it.


Unable to update content or enable / disable module via Drupal Admin once migrate to live server

problem was server firewall called mod_security. It's purpose is to stop hackers from inserting mysql_query type commands into your website. So, I solved this problem by disabling the mod_security service.


Unknown drupal_view() function although Twig Tweak is installed

If a module defines new twig filters or functions, they need to be manually excluded from the blt linter. Per a comment in the BLT issue queue, you can make these exclusions in blt.yml like:
validate:
  twig:
    functions:
      - drupal_block
      - drupal_field
      - drupal_view
      - drupal_block
      - drupal_region
      - drupal_entity
      - drupal_field
      - drupal_menu
      - drupal_form
      - drupal_image
      - drupal_token
      - drupal_config
      - drupal_title
      - drupal_url
      - drupal_link
      - drupal_messages
      - drupal_breadcrumb

This is also documented in the Overriding variables at runtime section of the blt docs (it's near the bottom of the section, under the tests: list item).


Invoking Drupal core tests from within a custom module .test script

So... I found a solution that's working, at least for my case.

It has to do with the fact that test cases are actually PHP classes that can be extended. So I tried to leverage inheritance, with a caveat...

I want to run a test on the pager, Drupal 7, after I have enabled a module that replaces the core pager.

The core pager test class is defined as

class PagerFunctionalWebTestCase extends DrupalWebTestCase {

now, my problem was that the core test would not be caring about my module to be loaded before running the tests.

I created my module test class as an extension of the core one, like

class MyPagerTest extends PagerFunctionalWebTestCase {

This is OK, but the point is that if I call parent::setUp() at this stage, the core setup will be run and I will still miss my module from loading before the actual test.

So the caveat is that instead of calling parent::setUp, I will call directly the 'ancestor' DrupalWebtestCase::setUp function, with my setup, and skip the call to parent.

Like this:

...

public function setUp() {
  // Enable required modules.
  $modules = array(
    'dblog',
    'mypager',
  );
  DrupalWebTestCase::setUp($modules);

  // Insert 300 log messages.
  for ($i = 0; $i < 300; $i++) {
    watchdog('pager_test', $this->randomString(), NULL, WATCHDOG_DEBUG);
  }

  $this->admin_user = $this->drupalCreateUser(array(
    'access site reports',
  ));
  $this->drupalLogin($this->admin_user);

}

....

That's all - class inheritance will do the magic and bring the rest of the test functions in.

Anybody sees other options?


Creating config schema file for mutable data

Mutable or Immutable has nothing to do with config schema, that's something else.

getEditableConfigNames() only works if you actually implement \Drupal\Core\Form\ConfigFormBase and $this->config().

Otherwise you need to explicitly get the config.factory service or \Drupal::configFactory() and then call getEditable() on that, instead of get().


Code comments in TPL file that wont be rendered in HTML?

You can use PHP comments, those will be ignored by the template engine and not rendered to HTML:

<div class="something">
  <?php /* This won't be visible in the source. */ ?>
</div>


Trying to create a custom menu link in a menu

Got it from here:

http://zufelt.ca/blog/embedding-view-menu-hook-drupal

Changed my hook instance to this:

/**
 * Implements hook_menu().
 */
function MYMODULE_menu() {
  global $user;
  $items = array();
  $items['user/' . $user->uid . '/messages'] = array(
    'access callback' => 'user_is_logged_in',
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'main-menu',
    'title' => t('Messages'),
    'page callback' => 'views_embed_view',
    'page arguments' => array('message_private', 'page_1'),
    'file path' => drupal_get_path('module', 'views'),
    'file' => 'views.module',
  );
  return $items;
}

This will embed the view into the hook_menu() instance.


I've spent some time trying to achieve the same goal.
I didn't find a lot of documentation on MimeMail module, I inspected the code and found a solution :
  $message = drupal_mail('my_module', 'my_module_key', 'email@mail.com', $language,
    $params = array(
      'subject' => $subject,
      'plain' => TRUE,
      'plaintext' => $mailBody,
    ));

You just need to use 'plain' => TRUE and put your mail content in 'plaintext' => $mailBody


Using composer - basics with localhost Mamp

Posting as an answer instead of a comment.

You run Composer from the project directory, which is where your composer.json and .lock file (which will get generated for you) lives.

I can work on any project at any time in the CLI by cd ing to the project I want to work on. Composer understands that this is the working directory in that execution.

So, no matter where you are in your server, Composer will execute in the directory you are currently in.


Is it a good idea to split a Drupal site into multi-site one for editors/admins and another for front end users?

Is this a good idea or is it just adding an extra level of unnecessary complexity?

There is no functional advantage of creating a multi-site for the purposes of separating content administration, as that will add an unnecessary level of complexity.

Some of the issues include determining what tables to share (which you've identified). Another common scenario is that content will be rendered differently depending on the site, leading to troubleshooting nightmares. An unscrupulous developer can have multiple versions of the same module in the site code, which creates head-scratching differences.

A single site is significantly easier to manage and ensure that administrative roles and permissions are logically set given your needs.

It can be helpful to have a distinct administration theme to visually enforce the difference between a normal and administrative roles. It's possible to specify a role per theme - https://drupal.org/project/role_theme_switcher for example.


Use contextual filter value in a view's header "rendered entity"

It looks like this isn't currently possible. There's a feature request on d.o to make this work. You can achieve it with Views PHP as you mentioned by using the following code:

<?php
$entity_type = 'taxonomy_term';
$id_arg = 1;
$view_mode = 'full';

if ($entity_id = $view->args[$id_arg - 1]) {
  $entity = entity_metadata_wrapper($entity_type, $entity_id);

  // Rendering without title ($page = TRUE).
  $render = $entity->view($view_mode, NULL, TRUE);

  // You may need to unset the title, even when rendering without it.
  $render[$entity_type][$entity_id]['#term']->name = NULL;
  print drupal_render($render);
}
?>

Note: this code requires the entity module. Shouldn't be hard to port it to native Drupal code, but entity is rather widespread.


All added links open as target, how to prevent it?

In CKeditor  when adding a link it will ask

click -> hyperlink button ->in Target set it as  will resolve your issue.

or if you have installed external  module means disable it.


Is there a way to add a Tour on all the pages/routes?

Since you're using the Tour UI module, add the routes to the list
All node pages have the same route, entity.node.canonical
For view pages, they are unique. You can use Devel's Webprofiler module to see the route names, ex:

They are basically structured as view.[view_name].[display_id]
Note: display_id is also known as the machine name value.

Is there a possibility to have wildcards in the routes? Chances are
thin

There isn't. You would have to tinker with the Tour UI module's code.

Also, is there a way to enable tour for a specific node?

There isn't. You'll prob have to use one of the hooks shown in tour_test.module to unset if the entity/node id is not the one you want.

Because of the routing limitation, seems to me like the core tour module was built towards showing how to edit or configure pages for administrators and not catered towards anonymous users. For your use case, you're better off using
D8: Bootstrap Tour module which is using the bootstrap tour library

No need to be familiar with Drupal routing names to be able to assign
a tip to a page, this modules works purely on jQuery selectors so you
may add the page body class plus some jQuery selectors to target a
specific page instead of routing name.


You need to first add a path field to your view, and then exclude from display:

Add the field "Content:path" to your view as the first field in the list
Exclude "Content:path" from display
Under "Rewrite results", enable "Use absolute link (begins with "http://")"
For Nick name, choose "Output this field as a link"
For "Link path", use the [path] token

Repeat #4 and #5 for age if you like

It's important that the path field be listed first (or at least before Nick Name and age) or it won't be available as a token.

Also note that you must use an absolute link for Content:path under Rewrite Results. It's a little counter-intuitive, since the field is being excluded from display, but the setting is still used in the [path] token.


in your theme's template.php:

function mytemplate_preprocess_html(&$vars) {
  $node = menu_get_object();
  if ($node && isset($node->nid)) {
    if ($node->status) {
      $vars['classes_array'][] = 'published';
    } else {
      $vars['classes_array'][] = 'unpublished';
    }
  }
}


how do I add a table and where clause to query object using hook_views_query_alter()?

I don't know enough about your problem to say whether using  hook_views_query_alter is the best approach.

In regards to the error you're getting, the answer is in the error message: the query object you have is an instance of SelectQuery. If you look at the documentation for SelectQuery you will see that it doesn't have an add_table method.

Instead you should use SelectQuery::addJoin (or one of the more specific methods, such as SelectQuery::innerJoin, SelectQuery::leftJoin, etc.)


How to check if a referenced entity is being used in other places?

Is there a quick way to check if a paragraph (or any entity) is being
  used and in which places (preferably one that shows paths) so that I
  can remove the reference before deleting this paragraph reference
  option from my paragraph component?

A paragraph can only be used in one place. So I'm first answering the part "or any entity", which also reflects the question title, and address the paragraphs specifics later.

I would do this in two steps. First find all entity reference fields which are configured to target this entity type, then run an entity query for each field.

As example how to find all entities where term #1 is used:

use Drupal\field\Entity\FieldStorageConfig;

$target_id = '1';
$target_type = 'taxonomy_term';

$map = \Drupal::service('entity_field.manager')->getFieldMapByFieldType('entity_reference');
$results = [];
foreach ($map as $entity_type => $fields) {
  foreach ($fields as $field_name => $field) {
    // we are only interested in configured fields, not base fields
    $config = FieldStorageConfig::loadByName($entity_type, $field_name);
    if ($config && $config->getSetting('target_type') == $target_type) {
      $ids = \Drupal::entityQuery($entity_type)
        ->condition($field_name, $target_id)
        ->execute();
      $results[$entity_type][$field_name] = $ids;
    }
  }
}

If the field is configured in a paragraph type, the IDs you find are of paragraph entities. Load the paragraph and get the parent entity with $paragraph->getParentEntity(). For nested paragraphs do this multiple times, until you find a non paragraph entity, for example a node.


Drush not connecting to site's settings.php

Changing the ownership of the some of the files in the sites directory seems to have fixed the issue.


According to the description of  the   References Tabs module

  This module allows to render nodes referenced via a node reference
  field in tabs, with node titles as tab titles and rendered nodes as
  tab content.

it is only support Nod referenced not entity reference ,you can see here  that it is not support entity reference , you can change your field from entity reference to node reference type.


I fixed the problem with the following steps:

Uncheck "Use token", change the "path" to normal path without using menu token.
Save the change.
Edit the menu, check "Use token", change the "path" to [current-user:edit-url]
Save.


Leaflet Map disappears when selecting term in views exposed filter

You must use global area views from other block with generic map, should not have results always show you the map.


Disable all user accounts apart from admin.
Disable new users from registering new accounts.
Edit permissions as necessary.

Now only admin can login, and anonymous users won't have permission to edit anything.


how to access webform submission data from a custom content type

One way to accomplish that would be to use the https://www.drupal.org/project/webform_entity_handler module. It is not very widely used module yet but I've used it, it was simple to use and worked well. What that module does it allows you to create arbitrary entity from a webform submission (like the results node). So you could store the input, submission id and whatever else you need to this entity at this time.
Then feeds can update this same entity with the results if you know unique identifier like the submission id.


How to restrict permissions for administering Taxonomy?

For D7 there is a taxonomy access fix module. It makes it possible to manage access permissions to individual vocabularies.


Connecting to a database from another application

Since you asked, the "correct" way would be to implement a simple web-service in Drupal in order to perform these tasks remotely from your application.  You could build a simple RESTful API to handle all your CRUD needs, for example.

The Services module is an excellent starting-point.

The reasoning for this is that you should really avoid modifying your Drupal database directly (unless you really know what youy are doing) and even if you must, connecting to it directly from another application is not only bad practice but a security risk too!

Please reconsider and use a webservice-approach, think of the kittens! :)


How to show a list of students: pairing entity references?

EVA: Entity Views Attachment can help you doing this task.

  "Eva" is short for "Entity Views Attachment;" it provides a Views
  display plugin that allows the output of a View to be attached to the
  content of any Drupal entity. The body of a node or comment, the
  profile of a user account, or the listing page for a Taxonomy term are
  all examples of entity content.

See this tutorial: https://www.torontowebsitedeveloper.com/drupal-video-tutorials/drupal-7-node-reference-tutorial

"Entity Views Attach: Use Views Almost Anywhere" contains a great tutorial about it.


feedback for duplicate registration attempt

It sounds like your theme is missing  from the page template, which will usually show a description of the error at the top of the page.

I know you said no modules but I would recommend looking at Username originality AJAX check which is very small and does an ajax lookup before the form is submitted.


Display delete confirmations in a modal window

You can use https://drupal.org/project/ctools_automodal and then use menu_alter to use following code and see if it helps.

function modulename_menu_alter(&$items) {
    $items['entityform/%entityform/delete']['modal'] = TRUE;
}

Be sure to clear cache.


How do I override a function from a module?

It's Drupal...there's always a way, but the amount of time it will take to do might make you think twice :)

If you look a bit further up the food chain so-to-speak you'll see that this function is exclusively used by commerce_price_table_field_formatter_view(), which declares a field formatter that is used for the commerce_price_table field type.

With that in mind, you can quite easily implement your own field formatter, assign it to the commerce_price_table field type, and use as much custom code as you want, all the time keeping in line with best practices.

Basically you need to implement hook_field_formatter_info():

function MYMODULE_field_formatter_info() {
  return array(
    'MYMODULE_commerce_multiprice_default' => array(
      'label' => t('MyModule Price chart'),
      'field types' => array('commerce_price_table'),
      'settings' => array(
        'calculation' => FALSE,
        'price_label' => t('Price'),
        'quantity_label' => t('Quantity'),
        'table_orientation' => t('Orientation'),
      ),
    ),
  );
}

And then implement hook_field_formatter_view(), field_formatter_settings_form() and (optionally) hook_field_formatter_summary().

For each of these functions just take the code from the same function in the contrib module, and make the changes where you need to.


A way to have an unchecked "end date" input field?

We can do this easily using hook_form_alter hook, by setting #checked value of checkbox to FALSE. Since the date module doesn't add both fields at initial form load, we've to add #after_build to form where we can modify #checked value of checkbox (i.e. show_todate field) in form.

Below is the sample code for hiding the end date in date field. For this we've to add a Date Type field (field name as field_date) with ability to add end date in article Content Type. After which we've to implement hook_form_alter and checked if current form is add new article form to make sure we don't override node edit field value. And then added #after_build to add article form. Which then set the #checked value to FALSE.

/**
 * Implements hook_form_alter().
 */
function [MODULE_NAME]_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'article_node_form':
      if (empty($form['nid']['#value'])) {
        $form['#after_build'][] = '_modify_end_date_form';
      }
      break;
  }
}

/**
 * Proxy function to call _modify_end_date_form_after_build().
 * @param type $form
 * @param type $form_state
 * @return void
 */
function _modify_end_date_form($form, &$form_state) {
  return _modify_end_date_form_after_build($form, $form_state);
}

/**
 * After_build callback for Article Content Type.
 * @param type $form
 * @param type $form_state
 * @return void
 */
function _modify_end_date_form_after_build($form, &$form_state) {
  $form['field_date'][LANGUAGE_NONE][0]['show_todate']['#checked'] = FALSE;
  // $form['field_date'][LANGUAGE_NONE][0]['show_todate']['#value'] = FALSE;
  return $form;
}


Show create content menu item to ananymous users but call URL for login/register popup on click

I had the same problem, and solved it without coding.

Manually set the menu path with absolute URL, ie. http://yourdomain.com/node/add/node-type
Install and enable the module r4032login
Done!


The easiest (and less expensive) way I see to do this is as follows (did not try this, but should work):

Copy node.tpl.php from the core node module (/modules/node) to your theme's folder (/sites/all/themes/).
Modify the code to display the desired title. By default the code to display the title is:

<h2<?php print $title_attributes; ?>>
  <a href="<?php print $node_url; ?>"><?php print $title; ?>

can be changed to:

<h2<?php print $title_attributes; ?>>
  <?php if($unique_card == 1) { ?>
    <a href="<?php print $node_url; ?>"><?php print "*" . $title; ?>
  <?php } else { ?>
    <a href="<?php print $node_url; ?>"><?php print $title; ?>
  <?php } ?>

Note: I used the variable $unique_card because the comments from node.tpl.php mentions:

  Field variables: for each field instance attached to the node a corresponding
  variable is defined; for example, $node->body becomes $body. When needing to access a field's raw values, developers/themers are strongly encouraged to
  use these variables. Otherwise they will have to explicitly specify the
  desired field language; for example, $node->body['en'], thus overriding any
  language negotiation rule that was previously applied.


The template most likely does not print content directly only specific fields, you need to add {{ content.field_name }} to the template, where you want to have it displayed.


Which version of Drupal are you using? If 8.3 you may wanna update to DS 8.x-3.0-beta3 which no longer requires the layout plugin module, instead uses "Layout Discovery" in core.

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


What exactly is a "friendship"? You most likely want to use cache tags for invalidation.

One way to do that would be to add the cache tag for the user, then you just have to make sure that you are invalidating that user cache tag. So you add 'tags' => $user->getCacheTags(), and when the friendships of a user change, you use Cache::invalidateTags($user->getCacheTags()). The downside is that this will invalidate too much: It will invalidate all content where the user is displayed, e.g. if he's the author of an article.

You could define your own cache tag; they're really just strings and invalidate just that, e.g. 'tags' => ['friendships:' . $user->uid] and then invalidate that.

Cache contexts are for variations of the same cache entry; it's exactly those things you see in the cache key. Having $user->id() in the cache keys and the user context is practically the same thing. You can do either or the other; you don't need both. (Cache context user and keys just 'friendships' would be the same as what you have now.)


drupal link not working on live server after moving from localhost

This sounds like missing .htaccess file. Check if this file exists or not. If not, upload a standard drupal htaccess file.

You can use this one maybe. https://github.com/drupal/drupal/blob/7.x/.htaccess


A taxonomy-provider module: enable/disable vs install/uninstall

There is at least one core module that creates a vocabulary that we can use as a guide: Forum.

It creates the vocabulary "Forums" in hook_enable() (see form_enable() function).

It does not remove the vocabulary in hook_disable() or hook_uninstall(). (see forum_uninstall() function - Forum does not have a hook_disable() function.

So, to answer your question, create the vocabulary in hook_enable() and don't delete it.

One other note gleaned from the forum.install file that is probably relevant to your module is that you need to make sure your module is loaded after the Taxonomy module. You can do so by settings the module's weight to 1.


OpenLayers Locator proximity search(content) and map display within tab

Anyway I Find Out Solution.
Create a two pages like Page 1 and Page 2.

Setting Menu Tab to both pages

1. Menu Tab: List in PAGE SETTINGS
2. Menu Tab: Map in PAGE SETTINGS

Change CSS setting in view-filter.


Possible cause of the one time login link sent via e-mail to be broken?

There must be something, Drupal does not create broken links by default. Sadly, we can't debug your site for you. literally are not able to. See here - URL is accessible as [user:one-time-login-url] token, so if nothing overrides default support for this token, it must be OK.
Inspect http://example.com/admin/config/people/account, Password recovery tab. By default it should look like this:

[user:name],
A request to reset the password for your account has been made at [site:name].
You may now log in by clicking this link or copying and pasting it to your browser:
[user:one-time-login-url]
This link can only be used once to log in and will lead you to a page where you can set your password. It expires after one day and nothing will happen if it's not used.
--  [site:name] team

If this token is alone in it's line, just like above, then you know something interferes with tokens. If it's not, then maybe some automatic HTML syntax correction kicked in, and messed up your layout? It is impossible to tell without actually debugging your site.


You can use the PHP function menu_get_item('path/in/question') to determine more about what module is responding to the url.

If the path is an alias, you may need to use drupal_get_normal_path($alias).

So if you use drush, you might run

drush ev "print_r(menu_get_item(drupal_get_normal_path('path/in/question'))"

That should return an array, which will likely have a 'page callback' element which will tell you the function (and hence, the module) that is handling that url.


How to make panels with a node reference argument

I implemented a similar feature on my site: when a user registers, several nodes of different content types are created specifically for that user.  I also use Panels.

To (somewhat) easily link the content with the user, I used the Relation module, which integrates with Rules.  After I created the content upon account registration, I created relations between the user and the content (all using Rules-- if you do this, you'll need to make a rule set and create the content in one rule before creating the relations in a following rule; otherwise, you'll get some weird errors).

Then, without using Panels contexts, I simply created content panes in Views that pull in the content by adding relations (from the Relation module) as relationships (in the Views UI).

The challenge of this approach is that setting up rules to fetch the relations and loop through them is pretty complex.  It might be easier to use the Entity Reference module, which has Rules integration, but when I was building my site a year ago it was broken so I used the more complex Relation module instead.


Here is an idea about running this in a more efficient way:

<?php
  $loaded_user = user_load($uid);
  $user->changed' = time();

  field_attach_update('user', $user);
?>

I am not 100% sure if this is gonna work for your setup the way you want to, i.e. if the hook you implement in your module is going to be called (not enough information there).

Let me know and I can give you an updated answer.

Cheers


You can use Panels like Patrick suggests, but Panels requires a lot of resources and it's a bit of a waste to only use it for this simple case.

There are different approaches to this, one could be to react to the full view of the node:

/**
 * Implements hook_node_view().
 */
function hook_node_view($node, $view_mode, $langcode) {
  if ($node->type == 'type' && $view_mode == 'full' && arg(0) == 'node') {
    drupal_goto('url/' . $node->nid);
  }
}

The if statement if true if the node is of the correct type, is being view in full view and the url is node/..., which should limit to node being view the standard way.

Another way of doing this, would be to use the redirect module or something similar to setup redirects for all nodes of the type to the view. A weakness to this approach could be path alias. But that way you would make a permanent redirect which is more SEO friendly.


Custom Content Entity type - allow fields to be managed

Alright, after lots of research I've come up with three different solutions to the issue.

Solution 1 (not so great):

On the text formats and editors configuration page (/admin/config/content/formats), the top format in the list that the user has permission to will be set as the text format automatically when saving the field (entity). If you only have a text format or two, this will work, but it is easily breakable, so it's not a great solution.

Pros - easy.

Cons - easy to break if/when someone adds a text format or re-orders them. Hard to configure. Not stable at all.

Solution 2:

In your form defintion for the entity (or a _form_alter hook for the form), you can set the format as follows. Note that in this case, my field is keyed as 'message:

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);

  foreach(\Drupal\Core\Render\Element::children($form['message']['widget']) as $element_index) {
    $form['message']['widget'][$element_index]['#format'] = TEXT_FORMAT;
  }

  return $form;
}

Note: Replace TEXT_FORMAT with the key of the text format you want to use.

Pros - can be overridden as part of the form by other developers

Cons - can be overridden as part of the form by other developers (if you want to ensure that the text format is always the same and cannot be changed)

Solution 3:

In your entity definition, first add this function (again, my field is keyed as 'message'):

public function setMessageFormat($format) {
  $this->get('message')->format = $format;

  return $this;
}

Then you can add a preSave() method to the entity definition to set the format:

public function preSave(EntityStorageInterface $storage_controller) {
  parent::preSave($storage_controller);

  $this->setMessageFormat(TEXT_FORMAT);
}

Note: Replace TEXT_FORMAT with the key of the text format you want to use.

Pros - Ensures your text format is always what you want it to be for that field on the entity

Cons - cannot be changed by anyone else if you want this to be configurable.


How do I display the "recently created node" block using Views?

You need to check the views output settings. Notice there is a preview option. You wrongly select either fields either the filter doesn't match. You need to filter by Content Date Field and order it desc.


custom block menu path returns json Ok, but a 404 status header

First of all, for JSON output use drupal_json_output as a delivery callback in your menu. It will make thinks much easier:

function tripchi_menu() {
    return array(
        'tripchi/getme' => array(
            'title' => 'My Profile',
            'description' => 'mobile test for user status and object',
            'access callback' => 'user_access',
            'access arguments' => array('access content'),
            'page callback' => 'tripchi_getme',
            'delivery callback' => 'drupal_json_output'
         ),
    );
}

Then in your menu callback just return array. You don't need any other fancy stuff. I also faced 404 issue, but with this solution AND explicitly set response code 200 everything worked fine.

function tripchi_getme(){
    global $user;
    $json = array();
    // ... a bunch of stuff to construct a special array;

    // Only this was needed to make the stuff work.
    http_response_code(200);

    return $json;
}

I couldn't tell if the cause of my trouble was drupal or apache or both, but this certainly helped. Note that Access-Control-Allow-Origin was not needed to make this work (and I didn't plan to use cross domain calls either).


Setting date_popup year range to more than the 3 years default in Drupal 7

Use the following option in the array:

    '#date_year_range' => '-8:+8'

That goes up to 8 years or more. Generally you don't use minDate as that only goes back up to 3 years only.


How on node forms do I set multiple vertical tabs to be always open?

You can do this with the hook_form_node_form_alter. Add the following to a custom module.

/**
 * Implements hook_form_FORM_ID_alter().
 */
function YourCustomModuleNAme_form_node_form_alter(&$form, FormStateInterface $form_state){
  //- MENU SETTINGS
  $form["menu"]['#open']                 = TRUE;
  //- COMMENT SETTINGS
  $form["comment"]["widget"][0]['#open'] = TRUE;
}

Change the value of #open to true to show the menu as openend.

In some cases it is necessary to move this hook implementation to the end of the list. Because the menu group added by menu_ui Module can overwrite your settings to #open false again. For this you can use the following:

/**
 * Implements hook_module_implements_alter().
 */
function YourCustomModuleNAme_module_implements_alter(&$implementations, $hook){
  switch ($hook) {
    // Move our hook_form_FORM_ID_alter() implementation to the end of the list.
    case 'form_alter':
      $group = $implementations['YourCustomModuleNAme'];
      unset($implementations['YourCustomModuleNAme']);
      $implementations['YourCustomModuleNAme'] = $group;
      break;
  }
}


Why are my custom error pages returning HTTP status 200 headers?

I believe you still have to return the proper status code from your custom error page. For instance, for a custom 404 page, you need:

<?php header("HTTP/1.0 404 Not Found"); ?>


Getting my paths/breadcrumb right with views

Does the node title in the url include spaces? IF so, know that the spaces in the name which do not work well in urls.  You should set the title to have dashes to be a machine readable title. To do so change the configuration settings in pathauto to use a '-' separator.


Remove and uninstall module in a single patch

You can use ModuleInstaller::uninstall():

\Drupal::service('module_installer')->uninstall(['social_stats_views']);

In D8 there is a lot of housekeeping to do. You can see this in the code of uninstall():

https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Extension!ModuleInstaller.php/function/ModuleInstaller%3A%3Auninstall/8.2.x


How to display tabbed menu, created via hook_menu?

Alright, I found the problem: my tabs definitions were lacking the extra line

'access callback' => TRUE,

With this line in each tab definition, the tabs show up as extected.
Here is my final code for dummy_module.module:

<?php

/**
 * Implements hook_menu().
 */
function dummy_module_menu() {
  $items = array();
  $items['dummy_module'] = array(
    'title' => 'dummy_module',
    'page callback' => 'temp_output',
    'access callback' => TRUE,
    'weight' => 30
  );
  $items['dummy_module/new_tab1'] = array(
    'title' => 'Current 1',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'page callback' => 'temp_output1',
    'access callback' => TRUE,
    'weight' => 1
  );
  $items['dummy_module/new_tab2'] = array(
    'title' => 'Current 2',
    'type' => MENU_LOCAL_TASK,
    'page callback' => 'temp_output2',
    'access callback' => TRUE,
    'weight' => 2
  );

  return $items;
}

function temp_output() {
  return 'Hello world!';
}

function temp_output1() {
  return 'Hello world 1!';
}

function temp_output2() {
  return 'Hello world 2!';
}


What is the difference between hook_preprocess_page and hook_preprocess_html?

hook_preprocess_page is the preprocess hook invoked when the page.tpl.php template file is used, and hook_preprocess_html is the preprocess hook invoked when the html.tpl.php template file is used.

Both the preprocess hooks are invoked when a page is rendered with theme('page'), since the page element defined from system_element_info() defines html as theme wrapper.

  $types['page'] = array(
    '#show_messages' => TRUE,
    '#theme' => 'page',
    '#theme_wrappers' => array('html'),
  );

system_theme() then defines html as follows.

'html' => array(
  'render element' => 'page',
  'template' => 'html',
),

As for when to implement hook_preprocess_html(), you implement it to alter the variables used in the html.tpl.php file, which by default has the following content.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"<?php print $rdf_namespaces; ?>>

<head profile="<?php print $grddl_profile; ?>">
  <?php print $head; ?>
  <title><?php print $head_title; ?></title>
  <?php print $styles; ?>
  <?php print $scripts; ?>

<body class="<?php print $classes; ?>" <?php print $attributes;?>>

    <?php print t('Skip to main content'); ?>

  <?php print $page_top; ?>
  <?php print $page; ?>
  <?php print $page_bottom; ?>

As you can see, it contains just the HTML tags that wrap a page content, available in $page. With that, you can change the content of the  tag, the page title (the one that goes in the <title> tag in the  tag), the CSS styles and the JavaScript files added to a page, the classes and the attributes for the  tag.
With the page.tpl.php template file, you can change more of the page being rendered, including the site name, the site slogan, the page title, and the feeds associated with the page. For most of them, there is a specific Drupal function/hook you should instead use.

hook_preprocess_HOOK is the generic hook name used for all the preprocess hooks, in the same way hook_form_FORM_ID_alter() is the hook name used for a class of alteration hooks.


Can Rules create a node reference that is empty except for a title?

The solution is to use the URL Node Reference widget.


How can I check in Twig if an advanced theme setting option is unchecked?

The following answer is credited to @leymannx.
{% if not remove_searchbar %}
  do something
{% endif %}

After some research I found twig syntax. You also can find the "if statement" syntax and samples on Twig Symfony website.


In a nutshell....

Create a view, with a filter of the node type that contains this field_type and if it's published etc.

Add all the fields you want to display, including the field_type.

In Advanced Settings, turn grouping on.

In Style Settings, click on the Unformatted Settings (the round dodad next to Unformatted :) and in there you will now see a grouping field...so select field_type.

Save and preview.  It should do what you want data wise, so just add whatever CSS is needed to make it look pretty.


Should the maintenance template be used when the database API raises an exception?

This looks to be the case of where the documentation is out-of-date. That comment has been around verbatim since D7. D8 doesn't produce a themed maintenance page like D7.

When looking at _drupal_log_error(), you can see that unless Drupal is going through the install process, a fatal error will output a bare error message with a 500 status then exit:

if ($fatal) {
  // We fallback to a maintenance page at this point, because the page generation
  // itself can generate errors.
  // Should not translate the string to avoid errors producing more errors.
  $message = 'The website encountered an unexpected error. Please try again later.' . '<br />' . $message;

  if ($is_installer) {
    // install_display_output() prints the output and ends script execution.
    $output = array(
      '#title' => 'Error',
      '#markup' => $message,
    );
    install_display_output($output, $GLOBALS['install_state'], $response->headers->all());
    exit;
  }

  $response->setContent($message);
  $response->setStatusCode(500, '500 Service unavailable (with message)');

  $response->send();
  // An exception must halt script execution.
  exit;
}

Whereas in D7, _drupal_log_error() passes through a themed maintenance page:

if ($fatal) {
  drupal_set_title(t('Error'));
  // We fallback to a maintenance page at this point, because the page generation
  // itself can generate errors.
  print theme('maintenance_page', array('content' => t('The website encountered an unexpected error. Please try again later.')));
  exit;
}


I want to make node views "Edit link" field as a menu

I'm a bit confused, because your question sounds like a basic Drupal feature that has been around for years: tabs with "local tasks" as they are called. Here is a screenshot from a Drupal 7 site, without any extra modules:

If I understand correctly, the 'Edit' tab is what you are looking for... Or isn't that what you need?


When uploading images into Drupal, those are uploaded as it is and not compressed. To compress them you can check Image Optimize (or ImageAPI Optimize) Module.

Another solution is to add custom code in your custom module, which will compress image before a record is inserted into file_managed table, check code below:

/**
 * Implements hook_file_presave().
 */
function [MODULE_NAME]_file_presave($file) {
  if (!empty($file->filemime) && (strpos('image', $file->filemime) >= 0)) {
    $compressed = _[MODULE_NAME]_compress_image($file->uri, $file->uri, 75);
  }
}

/**
 * Helper function to compress images while uploading.
 *
 * @param string $source_url
 *   Source image URL.
 *
 * @param string $destination_url
 *   Destination image URL.
 *
 * @param string $quality
 *   Percentage of Image quality to compress.
 */
function _[MODULE_NAME]_compress_image($source_url, $destination_url, $quality) {
  $source_url = drupal_realpath($source_url);
  $destination_url = drupal_realpath($destination_url);

  $info = getimagesize($source_url);

  if ($info['mime'] == 'image/jpeg') {
    $image = imagecreatefromjpeg($source_url);
  }
  elseif ($info['mime'] == 'image/gif') {
    $image = imagecreatefromgif($source_url);
  }
  elseif ($info['mime'] == 'image/png') {
    $image = imagecreatefrompng($source_url);
  }
  else {
    return FALSE;
  }

  //save file
  imagejpeg($image, $destination_url, $quality);

  //return destination file
  return $destination_url;
}

NOTE: Change [MODULE_NAME] with your module name.


Using the Drupal 7's Block "description" field as a CSS class field

If I understood your question correctly, you have two options:

A) Use a _preprocess_block() function:

function THEME_preprocess_block(&$vars) {
  // Make sure that this is a custom block, and not a block that is provided by
  // a module.
  if ($vars['block']->module == 'block') {
    // Load the block information.
    $info = block_custom_block_get($vars['block']->delta);
    // Add block description to the list of classes.
    $vars['classes_array'][] = $info['info'];
  }
}

B) Use the Skinr module. Probably will require more work, but it's much more flexible and editors / non-tech staff will be able to define styles of blocks. From the project page:

  Skinr's main purpose is to allow the theme to define a set of reusable and modular CSS styles, and to make those styles available in Drupal's UI.


How to access label of List (text) via node_load()

You can get the list of values as a keyed array using list_allowed_values, and use it to show the "key" with whatever logic you want.

An example from the API comments section is as follows:

<?php
/*
assuming there's a field named machine name is 'field_my_field_name' whose
type is a list (float, integer or text), and you want to get the values that
were entered into the "Allowed values list" textarea on the edit screen for the field
*/
$all_fields_on_my_website = field_info_fields();
$allowed_values =       list_allowed_values($all_fields_on_my_website["field_my_field_name"]);
/*
$allowed_values is now an array of $key=>value pairs that
can be dropped into the '#options' value for a form field array, for instance
*/
//example:
$form = array();
$form['my_form_element'] = array(
  '#type' => 'select',
  '#title' => t('Choose something, sucka!'),
  '#description' => t('Descriptive text under form elements rather than above them is a great UX choice, really.'),
  '#options' => $allowed_values,
);
return $form;

Being a "field" in drupal the List field instance attached to a bundle has configuration and settings such as the custom list of items, the default value, whether its mandatory, etc.


Yes, THEMENAME_preprocess_page() is fine for this, but one could argue that it's better to implement hook_user when $op == 'view'. That way you would make the change available for all themes (who knows you will be adding a mobile theme a couple of months from now?).
I wouldn't use THEMENAME_menu_local_tasks() for this, but instead do $variables['tabs'] = ''; in THEMENAME_preprocess_page(). Of course, only do this for the user page, otherwise you will lose the tabs on all pages.
Yes, use user-profile.tpl.php to print out variables. If you need additional variables, fetch them in THEMENAME_preprocess_page() and add them to the $variables array to make them available in your template. Depending on what you need to do, see also user-profile-category.tpl.php, user-profile-item.tpl.php and their respective preprocess functions.
Yes, that's an option. You can also create a block display of that view and enable the block on the user page.

I recommend not to use multiple page templates (like page-user.tpl.php) if you can. When you do, a simple change to page.tpl.php will often need to be applied to all other page templates as well, which is a bore.


In the documentation is not present, but on $options array we can simply set "set_active_class" to TRUE (FALSE by default) and then drupal add a "is-active" class to the link:

Url::fromUri('internal:/progetti/selezionati', array('set_active_class' => TRUE)),

I think that this behaviour should be TRUE by default..


Creating followups to Commerce Orders for each Line Item

I wanted to share how I solved this problem: I created a rule which is dependent on an Order's Status being "Completed". This rule runs a custom PHP script which loads the Completed order Entity, retrieves each Line item and checks for its field called "Follow-up", which gives a time value in weeks


With module: Title you can convert title to field and then you can change the field length

For title-tab goto: admin/structure/types/manage choose your content type and then manage fields edit your field


Embed some user profile fields in a block form

This should give you a start. Probably it is not the most elegant solution, but after 5 minutes of hacking, this is what I got. It works, and updates the profile fields (alone).

  function custom_block_info() {
     $blocks['user_profile'] = array(
       'info' => t('User profile edit'),
       'cache' => DRUPAL_NO_CACHE,
     );

     return $blocks;
    }

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

      switch($delta) {
        case 'user_profile':
          $block['subject'] = t('Fill your profile');
          $block['content'] = drupal_get_form('custom_profile_form');
          break;
      }

      return $block;
    }

    function custom_profile_form($form, &$form_state) {
      global $user;

      $form_state['user'] = $user;
      $form['#user'] = $user;
      $form['#user_category'] = 'account';
      $form['actions']['submit'] = array(
        '#type' => 'submit',
        '#weight' => 100,
        '#value' => t('Save'),
      );

      $form['#action'] = url('user/' . $user->uid . '/edit');
      // $form['#validate'][] = 'user_profile_form_validate';
      $form['#submit'][] = 'user_profile_form_submit';
      field_attach_form('user',$user,$form,$form_state);

      return $form;
    }


Node is flagged, flag has node reference field, how to show list of referenced nodes to author

I would have an entity reference field for the user where their CV node is referenced. (Using rules on node creation). Helps in many ways.

In views, the contextual filter would be getting those CV nodes using the entity reference filter.

Then in the relationships, you would pick the appropriate flag and it should display the relevant job postings.

I'll test this tomorrow as its very similar to something i did before. I might be off on the contextual filter but i think you should definitely use entity reference from the beginning.

Edit: I'm actually quite certain you should be able to do this without entity reference or rules. Filter the view using Job content type. Then two relationships, one for node authored and flag.


Passing 'db-store' as first argument of _locale_import_read_po() will cause the content of the translation file to be imported in the database. To import it in memory, it's necessary to use the following code.

(As usual, replace mymodule with the machine name of the module that contains this function.)

function mymodule_import_translations_in_memory($directory, $pattern) {
  $po_files = file_scan_directory($directory, $pattern);
  if (count($po_files)) {
    require_once DRUPAL_ROOT . '/includes/locale.inc';

    // Allow execution to continue even if the request gets canceled.
    @ignore_user_abort(TRUE);

    // Try to allocate enough time to import all the file.
    drupal_set_time_limit(240);

    foreach ($po_files as $po_file) {
      _locale_import_read_po('mem-store', $po_file);
    }

    @ignore_user_abort(FALSE);
  }

  return _locale_import_one_string('mem-report');
}

Passing 'mem-report' to _local_import_one_string() will cause the function to return all the imported strings, while passing 'mem-store' to _locale_import_read_po() will import the translation in a static variable.

The code I shown works, but if another module called _locale_import_read_po() passing 'mem-store' as first argument, mymodule_import_translations_in_memory() would return the content of the files imported from the other module and the content of the files mymodule_import_translations_in_memory() imported. A more generic code would be the following one.

function mymodule_import_translations_in_memory($directory, $pattern) {
  $po_files = file_scan_directory($directory, $pattern);
  if (count($po_files)) {
    require_once DRUPAL_ROOT . '/includes/locale.inc';

    // Allow execution to continue even if the request gets canceled.
    @ignore_user_abort(TRUE);

    // Try to allocate enough time to import all the file.
    drupal_set_time_limit(240);

    $strings =& drupal_static('_locale_import_one_string:strings', array());

    // Store the old string list to restore it at the end.
    $old_strings = $strings;

    // Reset the string array to an empty array.
    $strings = array();

    foreach ($po_files as $po_file) {
      _locale_import_read_po('mem-store', $po_file);
    }

    @ignore_user_abort(FALSE);

    // Store the value to return.
    $string_list = $strings;

    // Restore the value set before this function was called.
    $strings = $old_strings;
  }

  return $string_list;
}

The code is directly accessing a static variable set by another function, but since there isn't any function to reset its value, that is the only possibility.

In the case of importing a big translation file, keep in mind that loading it all in memory is probably going to cause memory problems. Before doing it, PHP should be set to use more memory than Drupal would normally use.


How to get a notification when user is blocked following flood

Yes, Flood is part of core (it lives in includes/common.inc, and because Rules is a contrib module, there is no set way to integrate cleanly in Drupal 7.

The one thing you might be able to do is to do a form_alter() on functions like user_login_final_validate($form, &$form_state), since if a flood event has been triggered they will include a form value such as $form_state['flood_control_triggered'] which, when it is not empty, will indicate that a login attempt has been blocked. Then of course your custom form_alter implementation can call any Rules events it likes.

This is totally untested so I can't verify that it would work, but for now there doesn't seem to be an easy or clean way to do this in D7.


switching display suite view modes based on context or user location, show/hide fields based on user location

I was able to do this using Display Suite Extras, I found this tutorial very useful.

Display Suite Extras has a switch view mode by URL option, if you add ?v=view_name to the end of the url it will render that view. So I created the needed view types and used views to rewrite the URL of the titles to include the url parameter.


How to stop using Hindi number in Arabic translation of products

Subscribe to the NumberFormatDefinitionEvent ("commerce_price.number_format") and change $definition['numbering_system'] to 'latn' for your locale.


Get all the machine names of the date formats

Date formats are entities so you can use the Entity Type Manager service:

$formats = \Drupal::entityTypeManager()
  ->getStorage('date_format')
  ->loadMultiple();

$ids = array_keys($formats);


Language switcher block hides for authenticated user

Things you can try one of the following:

Uninstall Big Pipe module
Try switching to another theme. It might be that the active theme has a JS error which breaks the execution of the Big Pipe
Enable JS aggregation if disabled, or disable it if enabled
Check for console erros in the developer tools


The connection was reset when creating a new node

There are in fact two issues in your question.

To solve The connection was reset issue, have you tried to run rebuild_registry ?

drush dl registry_rebuild-7.x
drush en registry_rebuild-7.x -y
drush cc drush
drush rr

Some people also reported that with Coder Module but not only, they had to edit httpd.conf, increasing the Apache stack size to 8MB

<IfModule mpm_winnt_module>
   ThreadStackSize 8388608
</IfModule>

For the 2nd issue The following module has moved within the file system, this appeared since Drupal 7.50 release. A straight way to correct these errors is to use Module Missing Message Fixer. You'll find alternatives and full explanations in this DO post.


Need to add media with embed code and NOT URL - how to do it?

Create a new field on your content type called "Embed code", and create a new text format called "code" where HTML is allowed, and no WYSIWYG modules are enabled.

Use css to change the width and height of the iframe of the soundcloud widget. it will adapt automatically.

More control Using Views:

Hide that field from display on the "manage display" tab of your content type.
Create a view block display.
In that view, bring in the embed code field.
Add a contextual filter to the view. Use the nid and provide a default value "content ID from URL".
Place the block on your page.


How to restrict group node access to a user/member of an group?

It seems to me that, for what you're trying to achieve, you do not need the "Page access" module. Instead only using the Group module it should be possible to get it to work.

Some basics about the Group module to be aware of:

Make sure you enable gnode, a submodule of the Group module.
For each group type you need to define the appropriate permissions (view, edit, delete, etc) for the various Content Types.
Every group can have users, roles and permissions attached to it (refer to "What are the various roles supported by the Group module?" for more details about that).

It seems that you would want to grant access to what, in Group, is called "Members". But you woudn't allow access to "Anonymous" (site visitors that are not logged it). However, you also need to think about which access you want to give to "Outsiders" (=  logged in users who are not a member of a group).

With the above in place, it's just a matter of assigning a node to a Group. So if the gnode submodule is enabled, you should be able to do so via a group-related field that will be shown on the node edit form, via which you can then select the appropriate group

More info

Refer to "How to create collections of content that can be accessed by users with various access levels?" for more  info about all this.


you can use one of this function

file_create_url($uri);

or

image_style_url($style_name, $path)


Password confirmation before submitting a form

You might want to use hook_form_FORM_ID_alter(). Then you can create a valitate function, that checks if the password is correct.

function mymodule_form_article_node_form_alter(&$form, &$form_state, $form_id) {
  // There will already be some validate handlers added so you need to add to the
  // array rather than overwrite it.
  $form['#validate'][] = 'mymodule_article_form_validate';
}

function mymodule_article_form_validate($form, &$form_state) {
  //This is just a dummy example that will not 100% work, so you need the get the correct information.
  $password = 'TesT128#';
  if ($form_state['values']['password'] != $password) {
    form_set_error('password', t('You have entered the wrong password'));
  }
}


Show multiple term references as ID in one row

Change field Formatter

If you're showing the actual Content field you can change the Formatter. Instead of using Label use Entity ID under Formatter.

This will output Term IDs instead of term names, and all the Multi-valued settings will apply the same way as for the names output.

Rewrite results with TID replacement token

Another way or changing the field output in D8 views (if the Formatter option isn't available for example) is to use the Rewrite results > Override the output of this field with custom text and enter the token for the TID in there. You can look up the correct token pattern under Replacement patterns below the Text area.

That is also how you would get the TID to display instead of the name if you use the field Content: All taxonomy terms.


Exactly what it says. You seem to be deleting the Catalog vocabulary. You need to delete all terms in it first.


How to use node title or path alias instead of node id in node reference contextual filter in views?

I had a very similar problem and I not just found the solution to it, but also learned new things about how view works. Let me share what I learned and the solution to your problem too.

When you are creating a view with one or more contextual filters, the view must receive values of those filters from somewhere. This can be done by -

Picking the context filter value(s) from the URL

Typically you would have a page view for such purposes one that has URL of the form foo/%/bar or foo/bar/% for single contextual filter OR of the form foo/%/bar/% or foo/bar/%/% for multiple filters
In case you have multiple filters, the url value that appears first is mapped to the first filter, next to the second filter and so on.

Views allows you to tell what to do if the filter values are not available in the URL. This is typically used for block views.

You can choose from different actions and then configure the choice too.

asdfj kajsdf

Another thing views allows you is to tell what to do with the filter values if they are found in the URL as described in #1 above. Typical use cases are - Making dynamic titles based on filter values, Validating filter values etc.

When validating filter values, you can change the values too! (That is where our solution lies btw). This is very akin to the way we can change $form values in the drupal form validation callbacks.

Solution to your specific problem lies in using a very similar code in the sections pointed to by the arrows in the above image.

This link  proved out to be great help to me. Here is an excerpt from it:

$np = explode('/', drupal_get_normal_path($argument));
if (!empty($np[1])) {
  $handler->argument = $np[1];
  return TRUE;
} else {
  return FALSE;
}


How can I make a view that shows users all the who have flagged a single user?

Add a relationship, Flags: User's flaggings for your flag.  Uncheck Include only users who have flagged content.
Add a contextual filter, Flags: Content ID and set Provide default value to User ID from logged in user.

This was not intuitive, but it appears to do the trick.


How to implement a cancel button with required elements

You can make something like this in your function validate :

function FORM_validate(&$form, &$form_state) {
if ($form_state['values']['op'] == 'cancel')
{
 ///  Do something
/// drupal_goto() for example
}
}


Display nested relationships on a single view

Okay, so I've largely solved this one as follows:

The View is set to a table showing content of type Batch
I've added two relationships. The first is to items referenced by the content which are of type = Item (and which does not use any relationship). The second is to items having a reference to the content, are of type Order, and use the first relationship
I've then added fields from all three content types (using the appropriate relationships) to create the flat table I'm looking for.