How do I install on Ubuntu 20.04 (LAMP)?

This might be an issue with the new ways MySQL 8 does authentication.

Read more about that in this answer: What is mysql_native_password?

From the docs: MySQL Secure Deployment Guide  /  Enabling Authentication

You need to adjust the authentication method for the MySQl user you're using with Drupal (seems to be root from your screenshot). You can't do that through Drupal, you have to login MySQL through terminal or go through some other way of configuring your installed database server.

If switching to the new way of authentication isn't an option then you can change the user to use the old way of authenticating with  mysql_native_password:

alter user 'root'@'localhost' identified with mysql_native_password by 'whateveryourpasswordis';
flush privileges;

After that Drupal should be able to connect with the chosen database.

This is probably unrelated to your problem, but I've had problems in the past with some special characters in the password (not the database name), I couldn't use & nor # IIRC.


Drupal & AJAXified links: hook into requests before they are sent?

You can use the following code,

Drupal.ajax[element].default_beforeSend = Drupal.ajax[element].beforeSend;
Drupal.ajax[element].beforeSend = function(xmlhttprequest, options) {
  if (1) {
    xmlhttprequest.abort();
  }
  else {
    Drupal.ajax[element].default_beforeSend(xmlhttprequest, options);
  }
}


How to display the currently logged in user's details

Create a custom module and add following function.

function login_user_fn(){
   global $user;
   //print_r($user);
   $fid = $user->picture;
   $file = file_load($fid);
    if($file !=''){

    $user_pic  = theme('user_picture', array('account' => $user , 'path' => $file->uri,));

    return ('Hello '.$user->name.'<br/>'.$user_pic);
  }
}

And than call custom function " login_user_fn()" in our drupal custom block body.


How do I add 2 blocks side-by-side in Bootstrap theme's "Content" region?

You can extend the page twig like this.

Make a copy of page.html.twig in your theme template folder and put a twig block around the content:

page.html.twig

...
{% block content %}

  {{ page.content }}

{% endblock %}
...

Then create a new file, and name it so that it will target the specific page, for example the view "myview":

page--view--myview.html.twig

{% extends "page.html.twig" %}

{% block content %}

  {{ page.content }}

    {{ page.subleft }}

    {{ page.subright }}

{% endblock %}

This new file extends the page twig and contains only a new version of the the twig block "content". You can define multiple twig blocks in one file and replace them.


Ok here is high level overview of the file uploading. I took most of this from the Drupal 6 Developer modules but made some changes that should get you started on how to achieve your final goal here. I left all the original comments and denoted any new comments with // ** Comment Text so you should be able to skim through this and get the general idea.

<?php

//////////////// Tutorial Example 11 //////////////////////

// ** Will denote any changes or anything that I am pointing out below.

/**
 * Example 11: A form with a file upload field.
 *
 * This example allows the user to upload a file to Drupal which is stored
 * physically and with a reference in the database. In this example, only
 * png, gif, jpg, and jpeg files are allowed.
 *
 * @see form_example_tutorial_11_validate()
 * @see form_example_tutorial_11_submit()
 * @ingroup form_example
 *
 */
function form_example_tutorial_11($form_state) {
  // This is required to upload files.
  // enctype="multipart/form-data" required by browsers to handle files.
  $form = array(
    '#attributes' => array('enctype' => "multipart/form-data"),
  );

  $form['file'] = array(
    '#type' => 'file',
    '#title' => t('Image'),
    '#description' => t('Upload a file, allowed extensions: jpg, jpeg, png, gif'),
  );

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

  return $form;
}

/**
 * Validate handler for form_example_tutorial_11().
 * Verify the valid extensions, and verify content is an image also.
 */
function form_example_tutorial_11_validate($form, &$form_state) {

  // ** I just left this as image but you can change the ext array if needed.
  $file = file_save_upload('file', array(
    'file_validate_extensions' => array('png gif jpg jpeg'),
    'file_validate_is_image' => array(),
  ));

  // If the file passed validation: ** File is in /tmp folder now
  if (isset($file->filename)) {
    // Move the file, into the Drupal file system
    // ** Notice the 'jira-upload/', this would be where your file is placed,
    // ** It will be in your /files folder, but you need to make this directory,
    // ** You can do it in code but for simplicity I just left it as is for now.
    if (file_move($file, 'jira-upload/' . $file->filename)) {
      // Update the new file location in the database.
      // ** Change from /tmp/filename.ext to,
      // ** /sites/default/files/jira-upload/filename.ext in database.
      // ** This will be important for Drupal later.
      drupal_write_record('files', $file, 'fid');
      // Save the file for use in the submit handler.
      $form_state['storage']['file'] = $file;
    }
    else {
      form_set_error('file', t('Failed to write the uploaded file the site\'s file folder.'));
    }
  }
  else {
    form_set_error('file', t('Invalid file, only images with the extension png, gif, jpg, jpeg are allowed'));
  }
}

/**
 * Submit handler for form_example_tutorial_11().
 */
function form_example_tutorial_11_submit($form, &$form_state) {
  $file = $form_state['storage']['file'];
  // We are done with the file, remove it from storage.
  unset($form_state['storage']['file']);
  // Make the storage of the file permanent/temp
  // ** This will actually make it where you don't have to delete,
  // ** You can let Drupal clean it up later on cron runs after a certain,
  // ** Amount of time. This will be done automatically.
  file_set_status($file, FILE_STATUS_TEMPORARY);
  // ** This is what you wanted, was the public file that can be navigated to,
  // ** This should work pretty well, but there are other ways.
  // ** Since validation is already passed I would run the API call here as,
  // ** Well. You could pass the $file object to another function or your pref.
  $fileurl = file_create_url($file->filepath);
  // Set a response to the user.
  // ** I added the $fileurl so you could see it on the frontend,
  // ** Without having to know if devel is there.
  drupal_set_message(t('The form has been submitted and the image has been saved, fileurl: @fileurl. filename: @filename.', array('@filename' => $file->filename, '@fileurl' => $fileurl)));
}

?>

Note: For this to work with the way you are wanting to curl the image and send it you will need to set your file system to public. I'm placing a screenshot of that page with configuration.

Additional Hook:

If your file system is private you will have to run an additional hook in order to allow access to the file through Drupal without having it attached to a node or anything. I tested this with making my file-system private and clearing out all previous images, then along with the code that I edited from the Drupal 6 Examples module I placed the code below in the main module file (just incase anyone needs to know how to test this out without knowing all the code). This should give you the functionality that you need without having to change the file-system.

<?php

/**
 * Implements hook_file_download().
 */
function form_example_file_download($file) {
  //dpm($file);
  // Used jira- as indicator but it needs to match your folder where you are storing your files.
  if (strpos($file, 'jira-') === 0) {
    $info = image_get_info(file_create_path($file));
    return array('Content-type: ' . $info['mime_type']);
  }
}

?>


Lightbox doesn't show images loaded by entity_metadata_wrapper

In the lightbox configuration settings it allows you to define a certain class, so it popups whenever an image has that certain class. So all you have to do is to find a way to add a class to your image.

Perhaps you could use the Image URL Formater module. Set your image field format to url. (So when it prints, it will print the image url instead of the actual picture)

then concatenate a string to add html to your code.

print '<img src="' . $image . '" class="lightbox">';


You can achieve your requirement by following below steps.

Create view of Ranking content type.
Add fields you want to show to your listing.
Now add sort criteria of field rank this content with selecting Ascending operation.


You need to use Path auto module .. Alias taxonomy term paths...

  The Pathauto module automatically generates URL/path aliases for
  various kinds of content (nodes, taxonomy terms, users) without
  requiring the user to manually specify the path alias. This allows you
  to have URL aliases like /category/my-node-title instead of /node/123.
  The aliases are based upon a "pattern" system that uses tokens which
  the administrator can change.


Well you could always assign custom CSS classes to each field and target them for styling. Template.php file should be used more for a data manipulation purpose anyway, rather than styling.


What mapping solution do people use that has a proximity filter?

As of writing this, jpstrikesback's sandbox: Proximity is really solid. I have it running on a few production sites without issues. Once he feels it's 100% it is either going to be released as the D7 version of OpenLayers Proximity or use the new namespace "Proximity" (as it really does not require OpenLayers to function).

I recently wrote up a walkthrough of how to get this up and running for another question on stack exchange. See Need a simple Google Maps solution; lost in the labyrinth of modules.

As you mentioned GMap was ok in D6, but using OpenLayers is much more robust and flexible. It's worth spending the extra time to get it set up. Good luck


I managed to create what I was after by using the Plugin Api
I created module with the file structure

mymodule
   -src
      -Plugin
          -Block
           Block.php

In block PHP I used the following

<?php

/**
 * @file
 * Contains \Drupal\mymodule\Plugin\Block\Basic.
 */

namespace Drupal\mymodule\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;

/**
 *
 * @Block(
 *   id = "basic_text",
 *   admin_label = @Translation("Basic MyModule Block (basic_text)")
 * )
 */

class Basic extends BlockBase {

    /**
     * {@inheritdoc}
     */
    public function defaultConfiguration() {
        return array(
            'mymodule_string' => $this->t('Enter text here'),
            );
    }

    /**
     * {@inheritdoc}
     */
    public function blockForm($form, FormStateInterface $form_state){
        $form['mymodule_string_text'] = array(
          '#type' => 'textarea',
          '#title' => $this->t('Block contents'),
          '#description' => $this->t('This text will appear in the block.'),
          '#default_value' => $this->configuration['mymodule_string'],
        );
        $form['mymodule_style_selected'] = array(
            '#type' => 'select',
            '#title' => t('Style'),
            '#options' => array(
                0 => t('default'),
                1 => t('black'),
                2 => t('white'),
            ),
            '#default_value' => $this->configuration['mymodule_style'],
        );
        return $form;
    }
    /**
     * {@inheritdoc}
     */
    public function blockSubmit($form, FormStateInterface $form_state) {
        $this->configuration['mymodule_string']
         = $form_state->getValue('mymodule_string_text');
    }
    /**
     * {@inheritdoc}
     */
    public function build(){
        return array(
            '#type' => 'markup',
            '#markup' => $this->configuration['mymodule_string'],
        );
    }
}

I haven't implemented the logic handling the style options but I can now place a pane using the IPE and configure the style pane by pane.


How to use the right menu_tree and menu_link depending on region

To theme only specific regions within your drupal page simply filter your css by prefixing your class with the class or id of the region in question. You can find the region by inspecting HTML output. I use chromes inspector which is accessed via inspect element within contextual menu.

#region-sidebar-first .menu_tree menu_link_my_class { css }

and if you want a different style for the right hand sidebar

#region-sidebar-second .menu_tree menu_link_my_class { css }


First AJAX request is working very well, next takes too much time

I found a solution that's working for me.
I just changed that:

$('#content-region-inner').load(url, 'ajax=1', function () {
      Drupal.attachBehaviors('#content-region-inner');

into that:

var result = $('#content-region-inner:not(.my_ajax-processed)', context)
    .load(url,'ajax=1',function() {
               Drupal.attachBehaviors(result);

When using that, Drupal only fires up Drupal.attachBehaviors() once a time, no matter how much requests you do.

I hope this is working for you, too


Look at your PHP error log. It should give you the file and line number it's having an issue with.

If you can, copy and paste the last few lines of the error log on here for us to look at.


Group views exposed taxonomy filter terms based on parent

You have to use an additional module to influence how the Exposed filter is displayed: Views Reference Filter.

This module adds special new Filters to Views that rely on (existing) Entity reference Views Displays to filter the View. Basically, it's filtering one View Display with another View Display.

In your case, you first have to:

create an Entity reference Views Display that shows all the Countries, grouped by their Continents. It will be the Term type of View, not Content.

You're designing here what your Exposed Filter will later look like.
List Countries as Fields,
then use Parent item Relationship to show Continent for each Country,
Group the results by Continent (Parent) field in the Entity Reference list settings

You will now see a list of Countries grouped by Continents.
Save the View

With this ready you can:

edit your "Note" Content view,
add a new Filter Has taxonomy term that has (reference filter) in its name, expose it, and choose the Entity reference Display you created in previous steps above.
Use Better exposed filters module to display the choices as Checkboxes

You will now have a working Exposed filter by Countries that will be grouped by Continents.


How to use the same EntityListBuilder for entity A and an extended version B

Your questions cover quite a few unrelated concepts, but here's an attempt at answering nonetheless.

Create a 'Person' base class and extend that into 'Contact' and 'Artist' classes. This approach will isolate your Artist entity type form changes you need to make to the Contact class and vice versa. Adding a company-field would, as an example, probably not apply to your artists.
I would use a content-view with a filter, only showing contacts and artists types. Re-using common fields on the 2 entities will make creating such a view a no-brainer.
Afaik the parent list-builder class does not support multiple entity types. The constructor for the list-builder class, accepts $entity_type as one of its arguments, so unless you write your own list-builder, you are limited to 1 type per list.
The getViewsData() method exposes properties from your entity type to the views api. Extending the EntityViewsData class, like you did, auto-generates the view-data through the inherited methods. Core provides some usage examples; e.g. UserViewsData. Use your IDE to search for "extends getViewsData()" for more examples.


Showing different page layouts based on form data

You can set a "theme callback" in a menu declaration, but that would only work if you had some way to distinguish which page/step the user is on.

The only other way I can think of would be to have some if/then statements in your form that check for what step the user is on, and alter the form how you need.


How should I render the tpl of module at theme

You don't need a customized page template file because you are using a template file for your theme. What you need to do is to fix your code, which should be as the following one.

function mymodule_menu() {
  $items['mymodule/list'] = array(
    'type' => MENU_CALLBACK,
    'page callback' => 'mymodule_list_view',
    'access arguments' => array('access content'),
  );

  return $items;
}

function mymodule_list_view() {
  return theme('list_view');
}

function mymodule_theme() {
  return array(
    'list_view' => array(
      'template' => 'list-view',
    ),
  );
}

Notice that:

For the menu callback, you should define the access callback, and the access arguments, or the menu will not be visible to the users (except the user #1). By default, Drupal uses user_access() as access callback; in this case, you need to provide the permission string as access arguments.
The template filename must be equal to the theme name; the only acceptable difference is the underscores replaced by hyphens.
Your page callback needs to return its output, or print it. In the first case, the rendered page will contain all the output returned from Drupal, such as blocks; in the second case, the rendered page will just contain what your page callback prints.


Saving a value from Javascript on Drupal form submit

Is this map that you created already in place? Were/are you utilizing it on the user's edit info page or somewhere else on the site?

You may want to consider instead using something like Geofield: https://www.drupal.org/project/geofield

This would allow user map input (on an OpenLayers map) via a new field that you can attach to the User entity (or any fieldable entity) and would collect the data into a "Drupal" way, freeing you up to focus on how to display the information, as opposed to doing a custom POST action using JS to your Drupal site, which could be time-consuming.

If you are looking to do this in JavaScript, you may want to consider the Services module, which would allow you to access your site's CRUD actions, therefore editing the information on a User's profile, but this means that you'd have to have to include a field to collect this information on the User entity anyways, at which point having a Geofield may be useful to you.


Updated the documentation page.

In step 2, we need to move in to nodejs module folder inside your drupal's sites directory. Install the dependencies using package manager(npm). Most probably the nodejs module is installed at sites/all/modules/nodejs.

Also don't get confused by these notation (path/to/your/nodejs/module/directory). It used to say that it exist in some directory.

server.js holds the code related to your express application from configuring your app to starting your app. Express will be installed in your node_modules folder when you install the dependencies. node_modules will be created in you nodejs module(drupal site).

node server.js starts the express application from the location where server.js file is present.

Also you can follow the tutorial links provided by No Sssweat.


Is there a way to send password to the user through 'Welcome (awaiting approval)' email?

Dig into these modules and you'll find something worth (quotes included are from their project pages):

Subscriptions:

  ...enables users to subscribe to be notified of changes to nodes or taxonomies, such as new comments in specific forums, or additions to some category of blog. Once enabled, all nodes will have an additional link that allows the user to change their subscriptions. Users have tab on their user screen to manage their own subscriptions. Users can also set an auto-subscribe function which notifies the user if anyone comments on posts they have made. Admins can turn this on by default.

Notifications:

  ... This is a complete Subscriptions/Notifications Framework aiming at extendability and scalability. It allows any number of plug-ins defining new event types or subscription types or a different user interface.


PHP filter is an unrecommended module and you should not use it. It not a secure option and the site maintenance is too difficult.

My recommendation is avoid this module and implements a dummy module with this functionality.

If you decide to use in any case, as you told correctly this pages should not been cached but it depends of your cache config and the place where the php-text is located. I mean, you can use the php filter text in a view or in a block (for example) and the cache behavior will be different.


Does turning off features modules affect what the features modules does?

FWIW I've successfully uninstalled modules required by a feature before, but I had to remove the dependency from the feature's info file first and then disabled and removed the module. I've seen several Features where the creator unwittingly auto-added all sorts of modules and dependencies to the feature, so just because a module is listed as a dependency doesn't necessarily mean that it is really needed. As this tutorial points out, we should "Build natural dependencies, prevent arbitrary dependencies." and it's so true because as these arbitrary dependencies creep in, a site's features become more difficult to manage.


Populate a drop down select list with the results from a view with entity reference relationships

Reference field option limit

  This module allows reference fields of several types to have their
  widgets' available options limited by the values of other fields in
  the current entity.

I think this link might already be enough.
If not, then I am happy to expand the answer with more specifics.


How do I add the "error" class when a form validation fails?

First try removing your if test and see if you can get the form_set_error to trigger. That way you can make sure your test is correct. You should be able to call form_set_error in a validation function and it will work.

If that isn't the problem then make sure the name of your field is correct.

To answer the question about simply adding a class in form validation you can use the following:
$form_state['complete form']['aux']['#attributes']['class'][] = 'error';

It won't add to the input itself but to the field wrapper and you can style it from there. But I think figuring out why form_set_error isn't behaving how you want is your best bet. That should really be adding the error class.


Views filter based on value in referenced entity

So assuming there's a content type with machine name new for News, owner for Owner, horse for horse.

The news content type has a field named field_horses referencing horses

The owner content type has an instance of the same field field_horses and a
reference field to User, field_user

Create a view listing Content of type News

Add a relationship

Entity Reference: Referenced Entity
A bridge to the Content entity that is referenced via field_horses

require this relationship

add a second relationship

Entity Reference: Referencing entity
A bridge to the Content entity that is referencing Content via field_horses

have this second one use the first relationship "Content Entity referenced from field_horses"

require this relationship

add a third relationship

Entity Reference: Referenced Entity
A bridge to the User entity that is referenced via field_user

have this third relationship use the second relationship "Content referencing content from field_horses"

require this relationship

For filters you need two content type filters
One for Content type = News, using no relationships
another for Content Type = Owner using the "Content referencing content from field_horses" relationship

One user filter, Current User (yes), using the "User entity referenced from field_user

$view = new view();
$view->name = 'news';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'News';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'News';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: Entity Reference: Referenced Entity */
$handler->display->display_options['relationships']['field_horses_target_id']['id'] = 'field_horses_target_id';
$handler->display->display_options['relationships']['field_horses_target_id']['table'] = 'field_data_field_horses';
$handler->display->display_options['relationships']['field_horses_target_id']['field'] = 'field_horses_target_id';
$handler->display->display_options['relationships']['field_horses_target_id']['required'] = TRUE;
/* Relationship: Entity Reference: Referencing entity */
$handler->display->display_options['relationships']['reverse_field_horses_node']['id'] = 'reverse_field_horses_node';
$handler->display->display_options['relationships']['reverse_field_horses_node']['table'] = 'node';
$handler->display->display_options['relationships']['reverse_field_horses_node']['field'] = 'reverse_field_horses_node';
$handler->display->display_options['relationships']['reverse_field_horses_node']['relationship'] = 'field_horses_target_id';
$handler->display->display_options['relationships']['reverse_field_horses_node']['required'] = TRUE;
/* Relationship: Entity Reference: Referenced Entity */
$handler->display->display_options['relationships']['field_user_target_id']['id'] = 'field_user_target_id';
$handler->display->display_options['relationships']['field_user_target_id']['table'] = 'field_data_field_user';
$handler->display->display_options['relationships']['field_user_target_id']['field'] = 'field_user_target_id';
$handler->display->display_options['relationships']['field_user_target_id']['relationship'] = 'reverse_field_horses_node';
$handler->display->display_options['relationships']['field_user_target_id']['required'] = TRUE;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'news' => 'news',
);
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type_1']['id'] = 'type_1';
$handler->display->display_options['filters']['type_1']['table'] = 'node';
$handler->display->display_options['filters']['type_1']['field'] = 'type';
$handler->display->display_options['filters']['type_1']['relationship'] = 'reverse_field_horses_node';
$handler->display->display_options['filters']['type_1']['value'] = array(
  'owner' => 'owner',
);
/* Filter criterion: User: Current */
$handler->display->display_options['filters']['uid_current']['id'] = 'uid_current';
$handler->display->display_options['filters']['uid_current']['table'] = 'users';
$handler->display->display_options['filters']['uid_current']['field'] = 'uid_current';
$handler->display->display_options['filters']['uid_current']['relationship'] = 'field_user_target_id';
$handler->display->display_options['filters']['uid_current']['value'] = '1';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'horse-news';


Display value not key of list after loading of node

If your field allows only 1 value, you can do it in both ways, i.e Controller or Twig :

Controller

$node->field_contest_things->getFieldDefinition()->getSetting('allowed_values')[$node>field_contest_things->value];

Twig

{{ node.field_contest_things.fieldDefinition.settings['allowed_values'][node.field_contest_things.value] }}

Update

You can now skip the usage of fieldDefinition on the latests Drupal 8 updates:

{{ node.field_contest_things.setting('allowed_values')[node.field_contest_things.value] }}

By experience, I suggest you to move for a taxonomy if you need to query your node by this field value on the future. It's more maintainable & scalable.

Hope it helps you !


Automatically add users to the same group as their group admin

In Drupal 7, you can achieve it using hook_user_insert and OG function og_group.

hook_user_insert : Called when a user account is created
og_group : Set an association (e.g. subscribe) an entity to a group

 /**
     * Implemention hook_user_insert
     * @global type $user
     * @param type $edit
     * @param type $account
     * @param type $category
     */
    function HOOK_user_insert(&$edit, $account, $category) {
        global $user;
        $usr_grps = og_get_entity_groups(); //get all user groups
        if (count($usr_grps) > 0) {//if any groups
            $grp_mgr_grps = array();
            foreach ($usr_grps['node'] as $key => $gid) {
                $group_type = 'node';
                $group = entity_load_single($group_type, $gid);
                if (is_object($group)) {
                    if (!empty($group->uid) && ($group->uid == $user->uid)) {//subscribe only the groups where the user is group manager
                        $grp_mgr_grps[] = $gid;
                    }
                }
            }
            if (count($grp_mgr_grps) > 0 && is_object($account)) {
                HOOK_subscribe_grpmgr_groups($grp_mgr_grps, $account); //subscribe the group
            }
        }
    }

    /**
     *
     * @param type $grp_mgr_grps : array of group ids
     * @param type $account : Object of the user we want to add to the group
     */
    function HOOK_subscribe_grpmgr_groups($grp_mgr_grps, $account) {
        foreach ($grp_mgr_grps as $key => $gid) {
            $group_type = 'node'; //All groups are of type node
            $values = array(
                    'entity_type' => 'user',
                    'entity' => $account->uid,
                    'field_name' => FALSE,
                    'state' => 1,
            );
            og_group($group_type, $gid, $values);
        }
    }


How to customize the 'node content links' block?

I was looking for this myself and come across this link:
http://makandracards.com/jan0sch/11463-drupal-organic-groups-extras-add-content-links

If you're using Drupal 7 and Organic Groups (2.x) you probably have the OG extras module enabled.

The documentation to enable the "create content" links for your organic group nodes is sparse. Therefore a short howto:

Enable all needed modules Enable the module entityreference
prepopulate!
Go to "Structure" -> "Content types" and select your
group content type, not your group type.
Click on "manage fields" and edit the field "og_group_ref".
Enable the checkbox labeled "Enable Entity reference prepopulate".
Enable the block named "Node content links".
Now you should be done. Steps 4-5 are needed for every group
content type in case you have multiple content types that can be
posted to groups.


Put this in a custom module:

/**
 * Implements hook_block_view_alter().
 */
function MYMODULE_block_view_alter(array &$build, Drupal\Core\Block\BlockPluginInterface $block) {
  if (!empty($build['#id']) && $build['#id'] == 'stocktickerblock') {
    $build['#cache']['max-age'] = 0;
  }
}

but if the your 'stocktickerblock' block is from a custom plugin you can set the build cache directly in that plugin render array.


Templates must be put in the theme's directory, not in the Mime Mail module directory or in your own custom module directory. The Mime Mail documentation explains the proper template naming and location. See https://www.drupal.org/docs/7/modules/mime-mail/theming-html-mail-sent-through-mime-mail
The most specific template name should have three parts, separated by "--". These parts are:

"mimemail-message" This is the same for all templates.
"modulename" This is the machine name of the module that provides the hook_mail() implementation used to send the mail. This is also the module name that appears as the first argument to your drupal_mail() call.
"key" This is an identifier used to differentiate multiple emails sent by the same module. This appears as the second argument to your drupal_mail() call.

Any underscores appearing in the "modulename" or the "key" should be replaced by dashes.
For example, if my module has a machine name of "example_module" and the mail key is "example_key" then the specific template name, used just for email with that key sent by that module, should be:
  mimemail-message--example-module--example-key.tpl.php

The documentation for drupal_mail() explains a number of these things. See https://api.drupal.org/api/drupal/includes%21mail.inc/function/drupal_mail/7.x


You can load the vocabulary object using taxonomy_vocabulary_load() and get the name that way:

$vid = 1; // Vocabulary ID
$vocab = taxonomy_vocabulary_load($vid);
$vocab_name = $vocab->name;


WSOD on node edit/view pages only after migration - subdomain multisite

You have to also turn on display_errors (see the examples section of http://php.net/manual/en/function.ini-set.php ).

Usually when display_errors is off php is configured to log errors to some file. You might want to find that file and look at it.

My guess would be that some php-module is missing on that server and some drupal-module that is active on node-edit forms tries to use a function from that php-module.


How can I link a group of galleries through a single image using Views?

You can just do the following on the View:

Add your custom "path" field and set it to be hidden (Exclude from Display).
Add The image field. Under "Rewrite results" set it to "Output this field as a link" and use the token for the previously hidden field.

This will allow you to define what will each image do when clicked.


services userpoints with xmlrpc server can't be linked by external device?

I didn't test xmlrpc($server_url, 'userpoints.points', $key, $uid, $points, $tid, $event, $description) is worked or not.

Instead, I use POSTMAN extension from chrome store to post data to the userpoints service api endpoints path.

The userpoints alias must be filled, the data here is "pointss".
url:http:userdomain/userpoints_api/pointss method:POST
header: Content-type | application/xml
raw/xml

<?xml version="1.0"?>
<methodCall>
   <methodName>pointss.add</methodName>
   <params>
     <param>
           <name>uid</name>
           <value><int>1</int></value>
           <name>points</name>
           <value><int>170</int></value>
           <name>tid</name>
           <value><int>18</int></value>
           <name>operation</name>
           <value><string>test for operation</string></value>
           <name>description</name>
           <value><string>test for description</string></value>
           <name>entity_type</name>
           <value><string>node</string></value>
           <name>entity_id</name>
           <value><int>1</int></value>
     </param>
   </params>
</methodCall>

Done.


If you have enabled SSL, it may happen that some browsers may block the resources that are not using https:// in their URLs. While Chrome and Firefox manage to work fine in some cases, Internet Explorer has a strange behaviour.

I would suggest you to check if external scripts, images, or CSS styles  you are using in you website use http:// in their URLs, and change them if they don't use https://.


Redirect all www addresses to non-www web addresses

Uncomment lines 93 and 94 in the .htaccess file that comes with Drupal in the web root.

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewiteRule ^ http://%1%{REQUEST_URI} [L,R=301]

EDIT: If the certificate requires https, edit the second line to read:

RewiteRule ^ https://%1%{REQUEST_URI} [L,R=301]


How to limit the maximum length of the title of a node?

Try Maxlength module to do this.

  Maxlength allows you to set maximum length of any field on any form
  making use of the form API. This includes fields created using the UI.
  (Example: any text field on a node) In D6 Maxlength allows you to set
  maximum lengths to the body, title and CCK textfields of any content
  type (node).

  When the maximum length is enforced for a field, while editing content
  of that type some Java Script will countdown how many characters are
  left, also if the Javascript is turned off, it falls back to form API
  validation.

Automatic Nodetitles : I haven't try this. Try once, hope this module solve your issue.

  "auto_nodetitle" is a small and efficient module that allows hiding of
  the content title field in the form. To prevent empty content title
  fields one can configure it to generate the title by a given pattern.


image share issue for single variant product

Use the 0 instead of 1 in node image token

1) Go to : Site setting -> configuration -> Metatag

2) Edit the “Node”

3) Click On Open Graph field set

4) Add “[node:field-product:0:field_images]” in Image

Hope this will solve your issue


Which of the wysiwyg modules will get in to the core of Drupal 8?

Dries answered this in From Aloha to Ckeditor on Jan 02, 2013:

  Therefore, we are going to switch from Aloha to CKEditor for Drupal 8
  core. By making this switch, we will not only have a more mature
  WYSIWYG editor, but we also free up resources to work on other parts
  of Drupal's authoring experience. The CKEditor team has committed to
  fix the 8 functional gaps that we've identified in their two next
  upcoming releases.


The Recipient in the Privatemsg rules integration does not provide a user object, because the recipient could be a user or a role.  (There is a Privatemsg function for sending messages to roles, not just individual users.)

So, this is a limitation of the Privatemsg rules integration.  If you want to do this, you will have to add that functionality to the module yourself.


How to tag content from external databases?

by tagging you mean reference taxonomy terms ?

you could import those rows with the migrate module as nodes, with taxonomy reference (a normal taxonomy field), into your drupal DB.


You can override existing paths with the Page Manager Existing Pages Module.

I have not used it with a login page but it works well for other cases. You can use it to override an existing page's path and then add the original content for that path as a panels pane alongside your custom additions.


Set default country for the Address type element (Webform)

Under the 'Address' element's 'Advanced' tab, you can set the 'Default value' via the UI.


View's path prevents 404 page from showing

This is not a problem with the Views module; it's how Drupal behaves.

If you look at menu_get_item(), you will notice the following code.

$original_map = arg(NULL, $path);

$parts = array_slice($original_map, 0, MENU_MAX_PARTS);
$ancestors = menu_get_ancestors($parts);
$router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' => $ancestors))->fetchAssoc();

I tried the following code, in a test site.

$original_map = arg(NULL, 'people/bob');

$parts = array_slice($original_map, 0, MENU_MAX_PARTS);
$ancestors = menu_get_ancestors($parts);

What I got is an array containing the following items:

people/bob
people/%
people

In your case, as there isn't a menu callback for people/bob, and people/%, the query executed from menu_get_item() will find the menu callback for people, the view you have defined.

To avoid people/bob returns the view page, I would create a custom module with the following code.

function mymodule_menu() {
  $items['people/%'] = array(
    'page callback' => 'mymodule_people_view',
    'page arguments' => array(1),
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
  );
}

function mymodule_people_view($username) {
  $alias = "people/$username";
  $path = drupal_get_normal_path($alias);

  if ($alias == $path) {
    // $alias is not a defined alias; in this case, drupal_get_normal_path()
    // returns the string it gets as argument.
    drupal_not_found();
  }
  else {
    drupal_goto($path);
  }
}

There is a module to resolve this issue (Views 404), which has now a version for Drupal 7.

  Are your views returning a 200 when it should return a 404? Views404 is the answer! This is very helpful for any caching layer and it will help SEO.
  [...]
  Standard Drupal behavior is to pass all arguments through, whether or not they requested. Sometimes this behavior is desired. The views 404 module assumes that by default you do not want arguments passed through. 404s for views can also be accomplished by setting the Global: Null under Arguments.


Views Slideshow Using Absolute Path to Images

Implement hook_preprocess_views_view_field() or hook_preprocess_views_view_fields(). In those you should be able to alter anything related to that image field. If the image field happens to be represented as a render array in the hook (assuming you are using Drupal 7), you can also change the theming function to use for that image. Within your own image theming function, you can get the path to the image using file_create_url(), which supports https.

If you need a good example of an image theming function, you can look at core's theme_image(). For a complete list of Views preprocessors, you can look at the views/theme/theme.inc source code.


Embed media in Ckeditor field for drupal 7

The standalone version of ckeditor module comes with a plugin called media embed. Ensure you have:

Enabled the media embed plugin for Ckeditor
Added the media embed input filter to a text format that your uses have access to (and is not filtered or tag limited in anyway)
Added the media embed button to the toolbar for the above text format

And that is it. In order to embed a youtube video (or anything for that matter), you get the <iframe> embed code from youtube, and paste it into the media embed dialog popup.


How to add delete button to file field upload widget that actually deletes the file (not just association with content)?

The file should be deleted, if it isn't there is something going on. When a submit button fires, file_managed_file_submit($form, &$form_state) is triggered:

// No action is needed here for the upload button, because all file uploads on
  // the form are processed by file_managed_file_value() regardless of which
  // button was clicked. Action is needed here for the remove button, because we
  // only remove a file in response to its remove button being clicked.
  if ($button_key == 'remove_button') {
    // If it's a temporary file we can safely remove it immediately, otherwise
    // it's up to the implementing module to clean up files that are in use.
    if ($element ['#file'] && $element ['#file']->status == 0) {
      file_delete($element ['#file']);
    }
    // Update both $form_state['values'] and $form_state['input'] to reflect
    // that the file has been removed, so that the form is rebuilt correctly.
    // $form_state['values'] must be updated in case additional submit handlers
    // run, and for form building functions that run during the rebuild, such as
    // when the managed_file element is part of a field widget.
    // $form_state['input'] must be updated so that file_managed_file_value()
    // has correct information during the rebuild.
    $values_element = $element ['#extended'] ? $element ['fid'] : $element;
    form_set_value($values_element, NULL, $form_state);
    drupal_array_set_nested_value($form_state ['input'], $values_element ['#parents'], NULL);
  }


Use Display Suite token field in custom block type template

My teammate figured this out:

{{ content['dynamic_token_field:block_content-link_card_edit_block'] }}


It turns out, in my case, I'm asking the wrong question.  All that I need is the parent config entity (@bojanz pointed this out in slack), so I was over-complicating the issue:

$gateway = \Drupal::entityTypeManager()
  ->getStorage('commerce_payment_gateway')->loadByProperties([
    'plugin' => 'paypal_express_checkout',
]);

This will return an array of gateways, get a specific one:

// Get the first one
$plugin = reset($gateway);
$plugin = $plugin->getPlugin();

Now you have the $plugin to be used elsewhere.


Wrong Javascript order: Undefined variable: jQuery

Modules, via drupal_add_js() can define the 'scope' and 'weight'. The 'scope' defaults to header, so unless you change this via drupal_add_js() in your template.php file, you can't move print $scripts from your header, or you'll have this problem with, likely, most contrib modules.

To change this, you could do something like this in yourtheme_preprocess_page($vars):

$js = drupal_add_js();
$newJs = array()
foreach ($js as $s) {
  $s['scope'] = 'footer';
  $newJs = $s;
}

drupal_add_js($newJs);


How to add google maps js without breaking jquery?

So, in this case the answer comes from one of the comments. I wasn't properly using the drupal_add_js call, which shouldn't be called globally. So I moved it into the function in my little module to side step this, but the better way to approach this is using the render arrays and the #attached property of the block's content array. This approach let's you more granularly choose which js is placed and called.


Fatal error: Cannot use object of type stdClass Error help!

You say :

  note: line 99 is $uri = $value['url'];

So:

$value isn't an array and you can't write $value['url'];.

In fact $value is an object and you have to use this syntax $value->url;


Creating several users in one request using Services/REST/Json

Out of the box no.

But you could write a module that supplies you're own resource that takes multiple user objects.


Entity Reference auto complete term creation on the fly?

Instead you can give a try to this Autocomplete Deluxe module to achieve your goal. It have the option to create new term in auto-complete field.

  Features

Combo/Select box like selecting.
Select without entering something.
Widget for taxaonomy
Chosen like multiple selecting.

  If you want to deny adding new terms, then checkout Chosen. It
  converts select boxes to autocomplete fields.


Preprocess hooks work in themes and modules. It doesn't matter where you put it, the only difference is, that modules have higher priority.

What you have to do is to work on caching. Because of the variables you put in,  you need a cache context on url.path,

$variables['#cache']['contexts'][] = 'url.path';

That doesn't make a difference for the first run after clearing the cache, but makes sure that the hook is run for every new path.


You are headed into right direction: almost all websites I work on, have one main module that contains general customizations and provides the base for additional custom modules.
I find that this is absolutely necessary if you want to keep the sanity in the long run, especially if the project can potentially grow.

Small fixes are often faster and easier to maintain this way, rather than just adding more modules and making the configuration more complex.

I created a boilerplate module that we use as "Main" module for almost every Drupal installation.
You can see it here.

Most of the generic implementations / integrations (views, rules, webform, drush, helper functions, etc.) are there already, and it's much easier to just remove what you don't need.

On a related note, the same can be said for new Drupal installations. After creating a lot of Drupal websites for real projects and testing, you will realize that there are certain sets of modules and settings you want to have as a starting point. This is solved the best through installation profiles.

Here is a default installation profile that we use in almost every website, as well as for testing.

Hope this helps.


How to access private page (views page) with authentification in the URL?

Try reading about these projects:

Auto Login URL
Auto Login URL Tokens
Token authentication
Login one time
One-time login
urllogin

They're not all usable but you can get inspired by their different features and how they implement them so you can solve it for your own problem.


Get a module version for a list of modules

Mr. H does not want to actually download or install the relevant modules, he only wants to get a list with the latest recommended D7.x version.

Well, at the very least, you can do:

drush @site.env up module_name --select for individual modules, you can also do:

drush @site.env pm-releases which has a load of options for output.

https://drushcommands.com/drush-8x/pm/pm-releases/

It has format options.


Overriding fields from one content type which inherit from another content type

I am not sure if you are using D7 or D8, so will take a high level approach.

I would suggest that you will need to use an entity reference field on Content Type 2 (Person) to reference the item of Content Type 1 (Profession template) that will provide the default values for fields that are not filled in. They might even be the same content type if all the fields are the same, and all can accept default values (though if so watch out for recursion in the next step).

Now using a custom module, on node load, you can check for empty fields and replace their values with those of the referenced node.


Solved out with following jQuery code:-

$('.bef-tree input:checkbox').click(function() {
            var $this = $(this);
            if ($this.is(':checked')) {
            // Check all child checkboxes
            $this.closest('li').find('input:checkbox').prop('checked', true).change();

            // If all siblings are checked, the also check the parent term
                if ($this.closest('li').siblings('li').find('input:checkbox[checked="true"]').length
                == $this.closest('li').siblings('li').find('input:checkbox').length
                ) {
                    $this.closest('li').parent().closest('li').find('input:checkbox').prop('checked', true).change();
                }
            }
            else {
            // Uncheck all child checkboxes
                $this.closest('li').find('input:checkbox').prop('checked', false).change();

            // Uncheck all parent checkboxes of this element
                $this.parentsUntil('ul.bef-tree').filter('li').each(function() {
            // NOTE: "this" is no longer the closure variable, but the filtered
            //       li elements we selected and are iterating through.
                $(this).find('input:checkbox:first').prop('checked', false).change();
                });
            }
        });


No page content displaying on front page

Try viewing the page source to see what is there. Does it match your front page layout file?

Have you modified the front page layout file?


How to import (stream) data in Drupal and save the visualization as nodes - similar to datamasher.org)?

Nodes arent the best for storing data as such. I would suggest the data module for storing the datasets. (support for import via feeds is underway)
To display some results and charts there is several ways - have a look at forena for example. You could then create a node type that would save the parameter values for forena reports and upon node node display show the report. Similar functionality can be achevied vith views (not so much fomratting though).


Views : custom table with relationship is not queried

Instead of adding the fields manually, you should populate the instance variable additional_fields. From the views documentation:

  additional fields: An array of fields that should be added to the query for some purpose. The array is in the form of: array('identifier' => array('table' => tablename, 'field' => fieldname);

Looking through some of the implementations out there indicates that your code should look something like this:

class MYCLASS extends views_handler_field {
  function construct() {
    parent::construct();

    $this->additional_fields['ALIAS1'] = array(
      'field' => 'COLUMN1',
      'table' => 'MYTABLE',
    );
    $this->additional_fields['ALIAS2'] = array(
      'field' => 'COLUMN2',
      'table' => 'MYTABLE',
    );
  }

  function query() {
    $this->ensure_my_table();
    $this->add_additional_fields();
  }

  function render($values) {
    $alias1 = $this->get_value($values, 'ALIAS1');
    $alias2 = $this->get_value($values, 'ALIAS2');
    ...
  }
}


In Drupal 7, how to prevent *.php files from being upload to the /files folder when its required to have 777 permissions?

Drupal file uploads (in core or modules) should use file_save_upload which itself also calls file_munge_filename. Together those two functions should ensure that even if a file contains php it is not named in a way that a typically configured webserver would execute them. They also have protection against pl|py|cgi|asp|js files which can often contain code.

Since you seem to have .php files in that directory you have to start considering other ways the files might have landed there.

A vulnerability in a module that is allowing arbitrary file uploads
A vulnerability in some other code running on the server (outside of Drupal)
An insecure configuration (allowing users to run php) was used to download these files directly, avoiding Drupal's API.
An attack that used a virus to read stored passwords (e.g. out of Filezilla) on your local computer - these are more common than you'd think, but they usually don't target the files directory.

I suggest doing a few things:

Check the permissions and ownership on the files, that will help you know which webserver user uploaded the files and from there you can hopefully narrow which code was used to upload them. Or if, you notice they are owned by a specific unix user other than the webserver then you should worry about that account.
Check when the files were created - go through backups to find when they appeared or check the file timestamps (though on most OS you can only the file last modified and not the file created timestamp)
Check the apache logs for all accesses to these files and see which IP is accessing them and when (especially the first date of access)
Check the apache logs for other accesses to your site from those IPs and on those dates

These investigation steps are meant to help narrow down how the files were uploaded. Ideally you'll find some specific event (e.g. a POST to some url on your site that you investigate and see is a way to execute php, something like the CKeditor/FCKeditor module issue, then you can know that's how your site was exploited.

If you do find out how the site was exploited, please report it as a security issue: http://drupal.org/node/101494


You can try views_get_page_view() function, Which return Views object and you can get current views name on  $views_page->name


How to fix Zen theme only showing correct breadcrumbs with theme developer module enabled?

So, apparently there is a conflict between the Path Breadcrumb module and zen's built in breadcrumbs. When the Path Breadcrumb module is enabled, the zen breadcrumb doesn't append the title to the path. I'm assuming that Path Breadcrumb hooks into and overrides the drupal_get_breadcrumb(), although I haven't been able to demonstrate this myself. When I disable Path Breadcrumb, the zen breadcrumbs behave normally. This leaves me with two viable options: 1) hack the current status of the theme breadcrumbs, 2) or code Path Breadcrumbs for the rest of my pages. Neither options seems particularly palatable.


Populating a node reference field using PHP in Rules

This should actually be pretty simple:

Create your rule for the event "A node has been flagged, under "NAME OF YOUR FLAG" and name your rule
Add an action of "Add new content" and click "Next"
Choose what you want the auto-created content's title to be (w/ or w/out tokens) and select what content type you want created and click "Save"
Add another action of "Populate a field", for the arguments configurations choose "new content type of CONTENT TYPE YOU CREATED" and for field, choose your node reference field and click "Continue"
Again on arguments change to "new content type of CONTENT TYPE YOU CREATED"
Open the fieldset titled: "Advanced: Specify the fields value with PHP code" and enter:

return array(0 => array('nid' => $node->field_NAMEOFYOURFIELD[0]['nid']));

Note: You can find the field names by going to admin/content/types and click "Manage Fields" on the content type you want OR you can do a print_r($node); on a node of that content type to see the node object structure

Now when you view your rule, you should see something like:

and whenever you use that flag, a new node will be created having the same reference as the node you flagged.


Field Formatter Class and limit number of characters

I believe you are using the module Field Formatter Class to have this option for your fields.

The module does not set a maximum value for this field. So I believe it is using a default of 128 chars in core.

128 is a fairly long limit for a class field. But if you want to alter this you can write an alter function in your module like they have done in their module and set the #maxlength property of the field_formatter_class element.

Having said that, the following is a quick hack to get this working for you.

You can open the file field_formatter_class/field_formatter_class.module

and add a line

'#maxlength' => 256,

in the element class array in the alter function in line 44. After modification this will be like the following (view original code)

function field_formatter_class_field_formatter_settings_form_alter(&$settings_form, $context) {
  $display = $context['instance']['display'][$context['view_mode']];
  $settings = $display['settings'];
  $settings_form['field_formatter_class'] = array(
    '#type' => 'textfield',
    '#title' => t('Field Formatter Class'),
    '#maxlength' => 256,
    '#default_value' => $settings['field_formatter_class'],
  );

Do note that this is modifying a contrib module and is generally not a recommended approach. You will have to maintain this patch in a patches folder.


Recover content from a deleted user and assign ownership to other user

Transferring ownership of nodes is a part of Drupal core's functionality. Outside of that, any other contrib module has to provide that functionality itself; Drupal core doesn't have a concept data ownership for contrib module data.

I've rarely seen a contrib module implement a data ownership transfer feature. For popular modules they might exist but it's not a given. For example, with userpoints there submodule called userpoints_donations in the User Points Contributed modules project. However, it covers the use case of one user giving to another, not transfership from an account set to expire.

You might be able to do this on a per module basis if you look at the data tables each module stores in its .install file. It would be pretty easy to look at each table for a uid column and perform a SQL UPDATE statement that changes any uid value from X to Y. If you know all the modules in question (with their respective data tables), it's quite feasible to build your own custom VBO operation that would automatically do the SQL queries for you.


The other answers are great, accurate, detailed, but I'm not sure they're the "simple words" explaining the bare bones of the concept that the asker was looking for.

I think of hooks as a point where the code pauses and shouts "Anyone else got anything to add here?". Any module can have a function that replies to this, and gets triggered with appropriate data passed to it at that point in the code.

A nice straightforward example is hook_node_delete(). Any module can use it to make things happen every time a node is deleted. The docs tell you this hook passes the module the object of that deleted node to work with, and outlines other useful information such as about the exact timing of when it's called (e.g. that it is before the node data is actually deleted from the database), and where in Drupal's code the hook is called (which can be more than one place).

You can explore what hooks exist and find out what data is passed to them by exploring things starting with "hook_" in the Drupal api.

Hooks work by a name conventions: using hook_node_delete as our example, when the node deletion process reaches the point where the hook is called, for every module with a function like this [modulename]_node_delete() where the word hook in the hook's name is replaced with the module's name (e.g. my_amazing_module_node_delete() ), those functions get called.

Why? So any module can do anything at these key points: for example you could look at the deleted node and do things if it meets a certain condition (say, email an administrator, or launch some long process).

Some hooks let you alter things that have been generated just before they're processed. For example, hook_menu_alter() passes you the current menu items that the system has generated. Any module can define a function some_modulename_menu_alter() and look at them, optionally change them (delete some, add some, sort them...), and pass the newly altered menu back in.

It's simple, really powerful and is at the heart of how Drupal works as a modular system. Implementations of hooks are at the heart of most Drupal modules.

When looking through the code of a Drupal module, you can spot which functions come from hooks (as opposed to functions that are simply called from within the module code itself), as the Drupal community enforce a convention whereby each implementation of a hook has a comment in front of it like this (note the "Implements hook_..." bit):

/**
 * Implements hook_some_hook().
 *
 * Some descriptive summary of what this does
 */
function my_amazing_module_some_hook() {

Some modules that act as APIs define their own hooks. For example, Views defines many hooks that allow you to add to, read and edit data at various points in the process of creating or displaying a view. You can find information about hooks created in custom modules from two places (assuming the module follows conventions etc):

The code and comments in the modulename.api.php file in the module folder
drupalcontrib.org - for example, here's their list of D7 modules they have info on, and here's their page of Views hooks

Bootstrapping is, as others explained, basically booting up - I won't duplicate the other good clear explanations.


I placed this code directly after my call to node_add_body_field('my_node_type').

  $field_instance = field_info_instance('node', 'body', 'my_node_type');
  $field_instance['settings']['display_summary'] = FALSE;
  field_update_instance($field_instance);

References

node_add_body_field()
field_info_instance()
field_update_instance()


Recreating a media_gallery using a view?

I haven't used Media Gallery, but have used a few others - they all do similar things though often in quite different ways.

First off, it's not really necessary to create a new node for each image - Image Field can contain multiple images, depending on its configuration.

I recently created a Gallery content type with two image fields - one for the gallery "cover" with a single image and one with unlimited images allowed, for the gallery contents. I then used Views to create a View with several Page displays (one to display a list of galleries, another to display each gallery's contents), along with the Colorbox module for image display in a lightbox, and the Plup module (and plupload jquery plugin) to do drag and drop all-at-once uploads into the gallery. Works like a champ and very easy for site maintainers to deal with - all they have to do is upload a "cover" image, drag the whole mess o' images into the plupload area, give it a title, and save it.

Doing it this way lets you leverage image styles in several places - the cover image, the gallery page images, and the colorbox display images - plus Colorbox makes it possible to set up the gallery slideshow as automatic or manual advance. Pretty cool, and no custom code to write. You can fiddle with the View's output options as needed and, should you need more styling action, you have the option of writing theme templates to get the output looking the way you need it.

You can see it at work at http://betheldrupal.m-so.com/galleries - not in production yet but working well so far...

Let me know if you want details - I can export the views and stuff if need be.


theme_key does not switch theme when URL user//edit is called

Here is the answer : http://drupal.org/node/1130158
To quote:

user/%/edit is an admin path. See function user_admin_paths for details.
So if you enabled an "Administration theme" at "/admin/appearance", this theme will be applied instead of any theme configured using ThemeKey.

Also: Don't forget to specify "system" in your settings for theme_key.


How do I disable tooltips for field help text in Bootstrap?

There is a setting for this.

admin/appearance/settings/bootstrap
Javascript -> Uncheck Enable Bootstrap Tooltips


How to show status messages in modal window?

The easiest would be by installing any from a few modules that do this out of the box

Two of the most used modules are nicemessages and better_messages


Cron error: LogicException : Render context is empty

$view = \Drupal::service('renderer')->renderPlain($view);

instead of

$view = \Drupal::service('renderer')->render($view);

was the solution!
Thanks to @Clive


Is accessing the current node from multiple block plugins on a single page costly from a performance perspective?

No performance issue concerning the node entity, which is loaded only once per request and then stored in memory.

For caching between requests there are also no performance issues, because the rendered twig template(s) of a block are cached by default. But you have to make sure you provide the correct cache data, which is possible via a plugin context in the annotations (preferred) or by adding the cache metadata to the render array. See Block cache depending on current node and its last modification time


Unresolved dependency error when updating

This is a bit of a guess...

If you're updating modules on a fairly out-of-date site, some of the new versions may now depend on other modules, whereas they didn't when you originally installed them. Either that, or the files have just become missing somehow.

Either way, it looks like you need to download

Libraries
Token
Views
Phone


Add a link on to /cart on /cart/checkout, using uc_cart_checkout_form. necessary or not?

The cancel button will take the user back to the cart page, which is why you are redirected there when you hit enter on the form.

You could indeed add the link by theming the checkout form.

The alternative would be by modifying the form itself, and adding a new markup type element:

$form['cart_link'] = array('#value' => l('Cart', 'cart'));

You can modify the form using hook_form_alter

But using the theme hook is fine too!


Does anonymous can access current node? How to check it in my module?

The check if the anonymous user has access to a given $node, you can use the node_access() like this: node_access('view', $node, user_load(0)).

As a side note, $node->status == 1 will check that the node is published. An unpublished node is usually not visible by anonymous user. Which users are allowed to view unpublished node depends on the granted permissions and node access module enabled on the site.


How to only display languages in language switcher block where a translation exists?

To adapt the solution you tried, you would just have to unset entries for languages where no translation exists, so no link will be printed for them in the theme_links() call. So:

function YOURTHEMENAME_links__locale_block($variables) {

  foreach($variables['links'] as $key => $lang) {
    if (isset($lang['attributes']['class'])) {
        if (in_array('locale-untranslated', $lang['attributes']['class'])) {
            unset($variables['links'][$key]);
        }
    }
  }
  return theme_links($variables);
}

You would put this code into the template.php file of your theme, adapting the YOURTHEMENAME part of the function name above according to how all the other functions in your theme start. Means, you always start the function name of all your theme functions with the so-called "machine name" of your theme.


Can I disable Toolbar in specific theme?

You'll have to use hook_page_alter from within a module to unset $page['page_top']['toolbar'] — you can't do it from within a theme.

There is a module for that: Toolbar Visibility.


How to ignore specific Drupal release in update notifications?

Note: this is definitely not recommended. Hiding security updates is bad for all the obvious reasons (it's clear you know that, but for the sake of others who see this...).

As a technical exercise, I can't see why something like this wouldn't work (un-tested):

function MYMODULE_update_projects_alter(&$projects) {
  $projects['system']['info']['version'] = '7.29';
}

That should basically trick Drupal into thinking core is already at 7.29, so you shouldn't get any warnings. Plus you should also receive update notices for 7.30.


Is there a way to alter output/markup for a field in node edit view?

You can use hook_form_alter or hook_form_FORM_ID_alter

You'll need the ID to target specific forms; otherwise, you will endup altering every single form. See How can I find the form ID of a form?

Example of hook_form_FORM_ID_alter:

function mymodule_form_node_form_alter(&$form, &$form_state, $form_id) {
  /* @var Drupal\Core\Entity\FieldableEntityInterface $node */
  $node = $form_state->getFormObject()->getEntity();

  if ($node->getType() == 'article') {
    // Alter the 'article' form here.
  }
}


Are "files[]" from custom_module.info not included on form submits?

Files listed in .info files are not automatically included when the module is loaded; they are loaded when a module tries to create an object for a class that PHP doesn't find. In that case, a callback registered with spl_autoload_register() will check the content of the Drupal registry to find which file needs to be loaded to allow the creation of the object.

The only way to load a file containing a function is to use module_load_include().
In the specific case, where the function to load is a form validation handler (or a form submission handler) that is added to a form altered with hook_form_alter() (or hook_form_FORM_ID_alter()), I would rather keep the form handlers in the same file containing the hook implementation. Technically, the file is loaded by hook_form_alter() when it is not necessary, as the form handlers are used after the form has been submitted; so far the code worked, but it is not said that it would not work in future versions of Drupal.

Drupal 7 allows modules to implement hook_hook_info(), which is used from Drupal to know in which files the hook implementations are defined. The System module define its own implementation, which contains the following code:

function system_hook_info() {
  $hooks['token_info'] = array(
    'group' => 'tokens',
  );
  $hooks['token_info_alter'] = array(
    'group' => 'tokens',
  );
  $hooks['tokens'] = array(
    'group' => 'tokens',
  );
  $hooks['tokens_alter'] = array(
    'group' => 'tokens',
  );

  return $hooks;
}

With this implementation of the hook, when Drupal is looking for the file containing the implementation of hook_tokens() for the module custom.module, it will look for the file custom.tokens.inc contained in the directory where the module custom.module is installed.
Third-party modules are allowed to implement their own hook_hook_info(), but it should be remembered they are modifying where Drupal looks for the hook implemented by other modules too, which means that changing the group for hook_token_alter() changes the files where Drupal looks for any implementation of hook_token_alter().

It is possible to use hook_hook_info() to keep some hooks in a file that is different from the module file, using an implementation similar to the following:

function custom_hook_info() {
  return array(
    'form_alter' => array(
      'group' => 'form',
    ),
  );
}

What I reported before is still valid; future versions of Drupal could stop working because they would not find where the form handlers are, even though they know where to find the implementation of hook_form_alter().
This is the reason I keep to put the implementation of hook_form_alter() (or hook_form_FORM_ID_alter()) and every related form handler in the module file.


Yes, entity_load can be used, but you have to retrieve entity ids yourself:

$terms = array();

$v = taxonomy_vocabulary_machine_name_load('sites');
$query = new EntityFieldQuery();
$result = $query
  ->entityCondition('entity_type', 'taxonomy_term')
  ->propertyCondition('vid', $v->vid)
  ->fieldCondition('field_status', 'value', 1) // If your field name is 'field_status'
  ->execute();

if (!empty($result['taxonomy_term'])) {
  $terms = entity_load('taxonomy_term', array_keys($result['taxonomy_term']));
}

// dpm($terms);


but what does $variables contain?

A couple of render arrays and some values that be used by twig template. Your best option is check de documentation for each preprocess function to see what are included in $variables. Docs link template_preprocess(&$var) better explanation about preprocess functions and default list of template preprocess functions

  but how do I apply this to views or content types?

For me the best option is your twig template file by including this line.

{{ attach_library('my_theme/my-library') }}

No matter how many times this will be 'attached' only one will be downloaded (or aggregate). And only will added if this particular template will be rendered.

More info about Twig debug is here


Using the following code to print comment helped me to solve this issue:

module_load_include('inc', 'comment', 'comment.pages');
$comment_form = drupal_get_form('comment_node_<content_type>_form', (object) array('nid' => $nid));
print drupal_render($comment_form);


With Bootstrap you can have two regions side by side wrapping them with a row and adding a col-size-number class to them, like this:

    ...

    ...

You have to do that in the page.html.twig file.


Configuration Management module  does not support exporting blocks. See https://www.drupal.org/node/2125089 for more info.

There are several other modules than can help you with this:

Features and Features Extra
Blockexport


Try replacing 'primary_key' with 'primary key'


I ran into this fairly recently on Pantheon, and hopefully this helps if you haven't already solved it.

cors.config:
    enabled: true
    # Specify allowed headers, like 'x-allowed-header'.
    allowedHeaders: ['x-csrf-token','authorization','content-type','accept','origin','x-requested-with', 'access-control-allow-origin','x-allowed-header','*']
    # Specify allowed request methods, specify ['*'] to allow all possible ones.
    allowedMethods: ['*']
    # Configure requests allowed from specific origins.
    allowedOrigins: ['http://localhost/','http://localhost:3000','http://localhost:3001','http://localhost:3002','*']
    # Sets the Access-Control-Expose-Headers header.
    exposedHeaders: false
    # Sets the Access-Control-Max-Age header.
    maxAge: false
    # Sets the Access-Control-Allow-Credentials header.
    supportsCredentials: true

A few things to note...

Regarding the location of the file on Pantheon, please make sure your service.yml file is in /sites/default vs just /sites. I was wrongly under the impression it would work from both places. It will only work if in the /sites/default directory.

Notice the comma separated list of allowedHeaders each in their own set of quotes. I originally had a single string like you do in your example above, and it failed countless times before I caught the subtle difference. I'm fairly certain allowedMethods works the same way if you specifically want to list out your methods.

Please also note that while my code snippet will work well for development against a Pantheon sandbox you will likely want to lock things down a bit more prior to going into production. With Pantheon offering HTTPS you will also want to make sure to use it if you are going to be passing information around through headers. Hope this helps either you if you are still having issues or someone else that stumbled upon it down the road.


I'm pretty sure that using Services Entity API  will provide what you are looking for.  An endpoint shows up for me after enabling the module.

This module provides support for all Entity API entity types to Services. All entity types get a standard resource, similar to what Services provides for code entity types such as nodes.
This module allows to get entities by properties or fields and also paging and related entities that are defined properly.


best practice for email validation in form alter drupal 7

The function valid_email_address($mail) in D7 validates any email passed into it. If you need to validate a new email field from a form altered form, you can add a validation handler to your newly add email field to ensure that it is valid. Just append to the $form['#validate'] array the function you want called for validation.

function MYMODULE_form_uc_order_settings_form_alter(&$form, &$form_state, $form_id)
  //@TODO: Other form modifications
  $form['#validate'][] = 'MYMODULE_form_uc_order_settings_form_validate';
}

Then in your form validation function, check the value of the submitted field with valid_email_address($mail).

function MYMODULE_form_uc_order_settings_form_validate($form, &$form_state) {
  if (!valid_email_address($form_state['values']['MYMODULE_uc_order_template_email'])) {
    form_set_error('MYMODULE_uc_order_template_email', 'Not a valid email address');
  }
}


Drupal Content Updates Not Visible to Public Without Login Attempt

The Drupal site seems to treat an unauthenticated log in attempt to be an Anonymous User

Correct; an anonymous user is unauthenticated.

  What is the "role" of the viewer of the site before a login attempt is made?

"anonymous user"

  Where is the site content being pulled from to display in browser when the site URL is first loaded?

Either the database or your cache store.

  Where is the site content being pulled from after a login attempt?

Ditto - database or cache, depending on your setup, whether caches have been primed for the particular cache id, etc.

It sounds like you simply have page caching enabled for anonymous users. Clear Drupal's caches and see if the problem persists.


How can I eliminate duplicate Drupal nodes in a View when one CT references the other?

My guess would be to use fields instead of teasers, first. Then, use filter to undisplay Articles that are nodereferenced by pages - you then would only have pages and unreferenced articles showing up.

You might be able to do that with the relationship entityreference - reverse, or with views PhP if it doesn't work.


Functional test not displaying context aware block

As discussed in IRC, pretty sure your problem is $this->drupalPlaceBlock('my_context_aware_block'); which doesn't configure the necessary context mapping. That's not visible in the UI if you only have a single context, but it's still there and then stored in the settings.

See \Drupal\block\Tests\BlockUiTest::testContextAwareBlocks(), go to a URL like admin/structure/block/add/test_context_aware/classy, and save the block.
,


What's the syntax to apply hook_schema() in .install file?

The only place you use 'unsigned' is in this block:

'web_link' => array(
  'description' => 'TODO: please describe this field!',
  'type' => 'text',
  'unsigned' => TRUE,
  'not null' => TRUE,
),

'unsigned' does not apply to text columns. Try removing that line from the web_link column definition. https://api.drupal.org/api/drupal/includes!database!schema.inc/group/schemaapi/7.x has useful reference on this.

(The docs state that unsigned is ignored for other types, but it seems the error is in that chunk, so I'd certainly try removing it in case your database engine is not ignoring it.)


Create imagefield and set min width and height programmatically

Problem solved. If you use Media browser, like me you could use:
'min_resolution' => '750x500'.


Creating new users with Commerce & Rules: ERROR

During anonymous checkout, an email address is collected from the 'Account information' pane to create a new user (or append the order to an existing user).

You should be able to hook into the form on the 'Account information' pane and add your required fields. You will probably have to modify the rule (Create a new account for an anonymous order) to send along the extra fields for creating a new user with the required fields - when marked required, custom fields added to the user are added to the Create Entity action for user as well.

You can populate these fields using existing variables, or fields added to the Commerce Order or Commerce Billing Profile, or create your own variables (eg via hook_token_info_alter() to make variables available through the commerce_order).


How do I delete the Edit Delete buttons suddenly showing above pictures?

you need to increase the memory limit size in php.ini

That indicates that Drupal needed more memory than PHP was allowed to give it.

Drupal 7

Memory increase to 128M:
(This has worked every-time; and used to always work for D6 as well)

Create a new file php.ini, and add the code...
php_value memory_limit = "128M"
and put that file in your Drupal 7 (or D6) root folder.
    For step-by-step details, see comment below...
    Drupal 7 "Fatal error: Allowed memory size of ...".
If you need more than 128M:

Add the line
ini_set('memory_limit', '512M');
to your [Drupal 7 root]/sites/default/settings.php file.

I have yet to need this much memory, but I did achieve
a memory increase to 512M using this slightly more complicated
process that involved temporarily changing the permission level
for that file.
    For step-by-step details see the comment below Drupal 7 memory increase to more than 128M.

refer this link

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


how to set date field not to display past date

You can use the Field validation module to create validation for the date field.

You can follow below step to achieve this.

Go to  Administration -> Structure -> Content types and it will
display the list of content type.
Click on 'Manage Fields' links for your content type and it will display the list of fields for your content type.
Edit your 'Date field' from the list of fields.
Select '0 years from now' from the drop down 'Starting year' under 'More settings and values'. It will not display the previous year date in the popup.
You can set the default values for the date field under 'default values' section.
Save the settings.
Edit again your fields.
Click on 'Validation' tab in top of page.
Click on 'Date range2' link in the page.
Select 'value' from the drop down 'column'
Select 'Cycle of date' as global and set '-0 day' for the 'Minimum
date' textfield. Now, it will generate the error if date is less than today's date.


If $db_prefix is "assumed to be a string", then does Drupal automatically sort what is a sharable table in the DB?

$db_prefix can either be a string or an array, have a look at the documentation: Share a single database across multiple sites, the db_prefix_tables function take care of this job.


Commerce cart allowing quantity than In stock

commerce stock module check the quantity and prevent add max than stock,also if the stock be 0 it change add to cart button to out of stock.

Also if you want to implement it by yourself you can do it with rules


Would enabling 'Use Ajax' for view content harm our SEO?

It will only have an effect if there is content that you want to be visible to the search engine crawlers that is only accessible after having run any JavaScript (aka an ajax call).

For example maybe you want to be optimising for the key word carrot, and there is lots of content about carrots that only appears on page 2 of your view. To get to page two you have to do an ajax request so crawlers will never get there and it will in this instance negatively impact your SEO.

This is quite specific though, and could easily be mitigated against by ensuring your important content on carrots appears on the first page of the view.

So I guess it could have an impact, but it's unlikely that it will be a very big one. But certainly something to consider.

Google has a tool that allows you to fetch a page of your website and preview how it looks to the crawler.
This could be useful for testing exactly what impact enabling ajax on your view will have.


Drupal 7 : How to break title of content into multiple lines

As I understand you want have your nodes titled using pattern <English name><Arabic name>, and split your title on 'language border' to different lines. As was mentioned node title is used in both places content title, and page title.

So you can use changed pattern <English name>|<Arabic name> and override your template file in your theme. You can use str_replace before displaying title for your node. Also your page title will look ok, without changing theme more; and this solution support titles without | delimiter, or with more then 1.


How can I have the language-specific 'enabled' Boolean of menu items being respected?

For what you are trying to achieve I found out you can use the Menu Manipulator module. This module initially aimed to fix [Issue] Untranslated menu items are displayed in menus.

  Notes

  This module initially aims to fix this core issue with unstranslated menu items.

Having this module installed only menu items that are available in the current language will be displayed. If there's a menu item you don't need in a certain language, remove it or remove its translation.

To make this work properly, ensure that your menu, the menu title and "Show language selector on create and edit pages" is enabled for your menu under https://example.com/admin/config/regional/content-language.

Having a menu item you want only to be shown on the French site, select French as its language, and don't translate it.
Having a menu item to be shown only on the English site, select English as its language, and don't translate it.
Having a menu item to be shown on both sites, add it in one language and simply translate it.


How can I make a usable backup of the site on CD?

The Backup and Upgrade module can be used to schedule automated database backups. One of those backups, combined with the codebase, gives you a full backup of the site. If this is to be burned to a disc every 6 months, I wouldn't bother automating anything - the time investment won't be worth the future time savings.


Under "Header" select "Add" and choose "Text area" or "Unfiltered text". Then fill in your text in the text area and click "Apply".

You will need to provide content editors access to your view in order to alter it.

Another option would be to create a custom block and to place it above the Main page content block. Then again, you will need to provide access to the content editors to administer blocks.


How to show a Select list (dropdown) for state and dependent cities of India?

If you have City and State list in CSV, you can import to taxonomy using Taxonomy CSV import/export module.

  This module allows you to import or export taxonomy from or to a CSV
  (comma-separated values) file or with a copy-and-paste text.

you can use Hierarchical Select Module to list it in content type

you can find Indian states and city list in xlsx format here


It looks as though you have invalid serialized data for that authorize_filetransfer_connection_settings_ftp variable.

If saving to the db manually, make sure you have serialized the data prior to db storage.

Some ways to set the variable include

variable_set('authorize_filetransfer_connection_settings_ftp', $value);

and

drush vset authorize_filetransfer_connection_settings_ftp 'value'

The former is a bit easier if setting an array value, otherwise you can do something like this with Drush:

drush php-eval 'variable_set("authorize_filetransfer_connection_settings_ftp",array("key1" => "value1", "key2" => "value2"));'


Because it needs lots of coding and building a new module I only give you the tips and the algorithm, you need to know how to build a module.

build a module and create a variable (called IP) using drupal_get_variable, in this way a variable will be created in the `variable`` table.
for any user who visits your website, replace its IP address with the existing one (drupal_set_variable) in the IP variable (so far it is easy to implement).
you need output this variable in your view, so use the hook_views_prebuild ($view) hook function, get the IP and embed it in the view.


Array Flip Error Message on All Node Pages

Something is calling entity load with an incorrect $ids parameter.

This could be from something like node_load() or equivalent or node_load_multiple() or equivalent. If you pass in the wrong type of value into any of these you could end up with the error you mention.

If you want, add just above line 178 the line

print_r($ids);

Then reload the problem page and you will get a bunch of text print out.
Post the text back here (if you can upload files and there is a lot of output you could paste it in a txt file and post it).


You can use

$name = location_country_name($iso_code);

For reference http://www.drupalcontrib.org/api/drupal/contributions%21location%21location.inc/function/location_country_name/7


You cannot change your $form in your ajax callback. Instead try to add a validate function with hook_form_alter on your form (or if in custom form just there) where your add a variable to your $form_state and don't forget $form_state['rebuild'] = TRUE. This will cause your form to rebuild (so form build function is called anew) In your form build function you can check this variable in $form_state and malipulate the form. In your ajax callback you need to replace the form element (ajax_command_replace)

So workflow will be: form build function - ajax trigger - form build function - form validation (set variable & rebuild) - form build function - ajax callback


Limit access to a view based on profile field

I do this on my site using Rules.  I use the Data comparison condition on profile save and then add or remove the role as necessary.  If you do decide to use the Rules module, make sure to add a NOT Data comparison as well to make sure the Rule doesn't get called multiple times (I had problems with this).

Example:

Event: After updating an existing user account
Condition: NOT Data Comparison: account-unchanged:field_mycheckbox is Yes
Condition: Data Comparison: account:field_mycheckbox is Yes
Action: Add a role


One method would be to create a central function that you can use to store the object you create, and return it from a static cache when required. That way you only need to create the object once, and other methods in the same page build can pick it up when they need it.

The function might look like this:

function MYMODULE_new_ticket_cache($new_object = NULL) {
  // Register the static cache with the system
  $object = &drupal_static(__FUNCTION__, NULL);

  // If we've been passed a new object, update the static cache to store that object
  if ($new_object) {
    $object = $new_object;
  }

  // In all cases, return the stored object (if it's NULL, that will indicate the object hasn't been stored yet)
  return $object;
}

When you create your object you would pass it to your caching function like so:

$ticket = function_to_create_new_ticket();
MYMODULE_new_ticket_cache($ticket);

Then in your hook_block_view() implementation you can inspect your cache to see if the object has been set, and use it:

$cached_ticket = MYMODULE_new_ticket_cache();

if ($cached_ticket) {
  // Build up your block content
}


How to edit image field output from template

You need to install the Image URL Formatter module

Then in your view, click on your image field and select url as the formatter, so it prints the url rather than the image.

Option A) In the rewrite results field, use the token for your image field.

Example:

Option B) if you want to use the .tpl.php file, put this inside it.

<img src='<?php print $fields["field_image"]->content; ?>' class='yay-we-did-it'>


Drupal 7 ckeditor relative path setup issue

Pathologic will solve your problem, in the configuration of the filter put both http://localhost/myapp & http://localhost/myapp2 and the filter should work everything out


How to Retrieve FID from UUID on Feature Enable

I guess i didn't know exactly how the export/import works...perhaps, i still do not, but here is my theory so far. When importing custom fields containing file, we have to save the file in the table file_managed by ourselves. The feature module will only do the work of importing files for the default field types(file, text,etc) and not for custom fields which is our case.

Here is quick write up
http://margotskapacs.com/2014/03/make-custom-field-with-file-exportable-in-drupal-features/


Add module-generated pages to Drupal 7's search index

Implement hook_search_info() to describe your new search type.
Implement hook_update_index(), build up the content you wanted to be indexed, and throw it over to search_index() (see the example in hook_update_index()).
Profit.

Be sure to follow all the advice in the comments in the linked functions, and check out the core node and user modules' implementations of these hooks for examples of exactly what you need to do. The comments for hook_search_execute() should also prove pretty helpful.


Add description and title field to each image

You can add the title field and alt field, but not sure about the description field.

Go to admin/structure/types and then click manage fields for the particular content type and then click edit under operations for image field you want and then check the title field as shown in the below image.


Accessing values entered in custom fields added to install_configure_form

Altering the site configuration form is not different from altering other forms, as done from a module.

If myprofile.profile is used in your profile, its content should be similar to the following one.

  function myprofile_form_install_configure_form_alter(&$form, $form_state) {
    $form['site_information']['site_name']['#default_value'] = st('Organization name');
    $form['site_information']['org_short_name'] = array(
      '#type' => 'textfield',
        '#title' => st('Short name'),
        '#description' => st('This will be used as a casual reference to the association throughout the site. If left blank, the Site name will be used.'),
      '#attributes' => ['placeholder' => 'e.g. FBI'],
        '#size' => 60,
        '#maxlength' => 60,
    );
    // Move the email to the bottom
    $form['site_information']['site_mail']['#weight'] = 1;

    $form['actions']['submit']['#submit'][] = 'myprofile_install_configure_form_submit';
  }

  // Notice which argument is passed by reference.
  function myprofile_install_configure_form_submit($form, &$form_state) {
    $name = !empty($form_state['values']['org_short_name']) ? $form_state['values']['org_short_name'] : $form_state['values']['site_name'];

    variable_set('short_name', $name);
  }

As for variable_set() working in this case, it works, since install_configure_form_submit() (the default submission handler for the site configuration form) uses it.

  variable_set('site_name', $form_state['values']['site_name']);
  variable_set('site_mail', $form_state['values']['site_mail']);
  variable_set('date_default_timezone', $form_state['values']['date_default_timezone']);


How can I add relative path to a pdf file link in drupal menu

The thing with the menu system is that what you are typing is not a relative path, but an internal Drupal URL.

Since what you are after is not a Drupal path, but instead a static file server outside of Drupal by your webserver your options are limited.

You can write the full url like you tried yourself
You can create a module/theme where you can make this possible, either by adding the extra link or creating a drupal path that redirects to the static file.

Of these, I personally think that a an absolute path is the lessor of evils, unless you need to do this a lot of times.