How do I restrict GraphQL access with Basic Auth?

I got it!
I needed to add
$route->setRequirements(['_user_is_logged_in' => 'TRUE']);

...And then do the curl request with the username and password.


Printing a function on a content type page?

The error message itself is clear I think. You are trying to print an object as a string.
otherwise, your query seems correct.

function innovista_get_page_children() {

 $result = db_query("SELECT link_path FROM {menu_links}");
 return $result;

}

<?php
$results = innovista_get_page_children();
print '
';
foreach($results as $result){
    print_r($result);
}
print '
';
?>

Now you will see a formatted variable information of each $result.
it will look like

stdClass Object (
  [link_path] => admin/structure/views
)

So when you print the results, it will be like,

<?php
    $results = innovista_get_page_children();
    foreach($results as $result){
      print $result->link_path;
      print '
';
    }
?>

However, keep in mind that it's never OK to print link paths or database queries like this. It will cause huge performance problems and will arise security problems.
Try to use url() and/or l() functions for links (suggested it because you seem to make a link).
Also, in most cases, there is a function for core/contrib modules to retrive data.


while translaing page, there is an option at bottom 'provide a menu link'. check this field with title...


You need to create a custom module and override default area handler using hook_views_data_alter().

The default implementation of order total handler placed here.


Why the meta-tag module add "|" after the site name?

So by default, the module sets up all pages to use "[current-page:title] | [site:name]" and then for the front page it uses "[site:name] | [site:slogan]".

Now I am assuming you do not have a slogan set for your site, which is why it appears like "Sitename | ".

If you navigate to admin>configuration>site information, you will probably see the site slogan box is empty.

So you have a few options..

Add a slogan to your site
change the tokens for the front page.

to change the tokens for the front page, go the the Metatag config page and expand the "Global: Front page" field. You may need to click override to configure it to something other than default.

Click edit to edit the Global Front Page settings. Then remove the token you dont need and the seperator "|".

Hope that helps.


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

It looks like you copied the Bartik theme and put inside your "mytheme".
Do you create new theme or just create theme base on the Bartik theme?
If you want to create the subtheme base on Bartik theme. Please add the default regions in your new mytheme.info like from link : Problems creating Bartik sub-theme

You may also check the tutorial from How to Customize Bartik. It's the nice tutorial for creating subtheme base on Bartik theme.


What is the appropriate way to store arrays of information with configuration API?

You define a schema type sequence:

Example: /core/modules/options/config/schema/options.schema.yml

# Schema for the configuration files of the Options module.

field.storage_settings.list_integer:
  type: mapping
  label: 'List (integer) settings'
  mapping:
    allowed_values:
      type: sequence
      label: 'Allowed values list'
      sequence:
        type: mapping
        label: 'Allowed value with label'
        mapping:
          value:
            type: integer
            label: 'Value'
          label:
            type: label
            label: 'Label'

You'll find the form for this example in /core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php

More info https://www.drupal.org/docs/8/api/configuration-api/configuration-schemametadata


How to change fields permission using some action in the Rules module?

To my knowledge, there is no way you can "add the field edit permission to the Action component of the Rules module" (as in your question), which is somehow confirmed in the Post installation Support forum via the issue about "Field Edit Permissions Based on Rule?" also.
However, in one of the comments of that link, there is an interesting work around that might work in your case also:

Create a user role that has editing permissions for the field, then assign that user role to a user with Rules when the conditions you require are met.
You'd then possibly need to remove that role after updating the content depending on your workflow.

PS: I'm assuming this question is about D7.


display submitted variable - where does it originate

For completeness, I have added a patch to File Admin's issue queue. Patch adds the vertical tab to file entity's GUI edit page and sets the variable: 'file_submitted_' . $file_type, which is read by template_preprocess_file_entity in file_entity.module.


Strange disappearing  problem with Drupal 7

Ah, I found it. In /admin/config/content/formats/filtered_html, I needed to add <p> to the list of allowed HTML tags way at the bottom of the page. I'm not sure how/why this problem didn't show up previously...but this solved it.


How to interpret the code: module_invoke_all('user', 'logout', NULL, $user);?

No, they don't log the user out. That is done by the call to session_destroy() in user_logout().

That line only invokes the hook to tell other modules that the user was just logged out so they can react based on that.

The passed arguments are simply those that match the executed hook. Note that the Drupal 7 version is different from what you posted above, which is the Drupal 6 version.


Add autoupload property after page load using plupload

Drupal's plupload module does not support '#autoupload'. Or at least that's what I experienced. I wrote my own behavior for this:

(function($) {

Drupal.plupload = Drupal.plupload || {};

/**
 * Attaches the Plupload behavior to each Plupload form element.
 */
Drupal.behaviors.mymodule_plupload = {
  attach: function (context, settings) {
    $(".plupload-element", context).once('mymodule-plupload-init', function () {
      var uploader = $(this).pluploadQueue();
      if(uploader !== undefined) {
        uploader.bind('FilesAdded', function(up, files) {
          $('.form-submit').prop( "disabled", true );
          uploader.start();
        });
        uploader.bind('UploadComplete', function() {
          if (uploader.files.length == (uploader.total.uploaded + uploader.total.failed)) {
            // If nothing is being uploaded right now:
            $('.form-submit').prop( "disabled", false );
          }
        });
      }
    });
  }
};

})(jQuery);

I based it on codes and hints from the Internet, but I can't recall exact sources. I'll be happy to fix that and add reference links if someone recognizes parts of this.


If I install the same module in sites/all/modules vs sites/example.com/modules, which is used?

The sites/site.com/modules will be used over anything in sites/all/modules.

There's a really good description of how it works on Acquia:

  Site-specific modules and themes

  Each site in a multi-site install contains at least a settings.php and
  a /files directory. But each multi-site directory can contain modules
  and themes too - and any modules or themes in those directories will
  only be available to that site.

  For example, imagine I have two sites, example.com and example2.com:

  /sites/all/modules/contrib contains all of the community contributed modules that I want both sites to share. For example, Views might live there.

  /sites/all/modules/custom contains all of my custom modules, written specifically for my Drupal installation.

  /sites/example2.com/themes contains any themes you want to only be available on example2.com.

  /sites/example2.com/modules contains any modules you want to only be available on example2.com.

  When Drupal looks for available themes and modules, it searches in the
  following order:

  /modules/

  /profiles/

  /sites/all/

  /sites/[sitename]/

  So, when I write my custom theme for example2.com, I can put it into
  the example2.com multi-site directory:

  /sites/example2.com/themes/chicken

  And the "Chicken" theme will only be available to users of
  example2.com. Users of example2.com will still have access to all of
  the themes in /sites/all and /themes, but example.com won't be able to
  see the "Chicken" theme at all.


how to make config fields stick at admin/structure/types/manage/?

You can add a custom submit handler for your custom group of options and controls. For example on the base form you add an additional #submit value and check your own custom fields:

$form['#submit'][] = array('mymodule_form_followbtn_custom_submit');

if needed you can validate is form element independantley:

$form['followbtn']['followbtn_default_mode']['#element_validate'] = 'mymodule_followbtn_element_validate_default_mode';

or ...

$form['followbtn']['comment'] = 'mymodule_followbtn)element_validate_comment';

Then your submit function just does your processing (after elements validate on submission:

function mymodule_form_followbtn_custom_submit($form, &$form_state) {
  // save your stuff ...
}


How to query all fields of the node that is tagged with taxonomy term from a specific vocabulary

I think, you should check the field_config table where type = 'taxonomy_term_reference'.
The vocabulary name where the field is referencing to is stored in the data column as BLOB. you can use the unserialize php function to extract the data stored in the BLOB. That's because you can't reach it with a single select query.

Try using loops and ifs :)


Technically, the config override API that config translation uses allows any kind of override of configuration.
The core config translation however only does translation, meaning it only allows to change things that are classified as user-facing texts and not technical strings.
What you want is usually referred to as localization, changing things based the language that isn't actually a "translation". There is a core issue to better support this, https://www.drupal.org/node/2275865, but it hasn't been updated in quite some time.
There are a few possible workarounds, though:

Since you mention nodes, in Drupal 8, translations of nodes have the same ID/URL. That means you could have your different front pages as translations of the same node. That would be problematic if you use Paragraphs for example, as that doesn't currently support translatable fields, so you'd be forced into the same structure.

You could use Page Manager to have different front pages (there is a per-language constraint necessary, which has a patch but has not yet been committed) or even just a view that selects a node based on a certain condition (like filtered by language of a certain type).

A custom callback that displays a certain node based on a bit of code.

Update:
4 years later, I had this use case too and still no activity on the core issue. As a workaround, I altered the config schema and made the front_page a label type to be able to translate it. Not fully tested yet, so beware of dragons:
function custom_config_schema_info_alter(&$definitions) {
  // Change the front page type to label so that it can be translated.
  $definitions['system.site']['mapping']['page']['mapping']['front']['type'] = 'label';
}


As reported in drupal_set_title() and drupal_get_title() were removed that function is deprecated in Drupal 8.
For a dynamic title set from a controller, the code the change record suggests is the following one.
mymodule.test:
  path: '/mymodule/test'
  defaults:
    _controller: '\Drupal\mymodule\Controller\Test::getContent'
    _title_callback: '\Drupal\mymodule\Controller\Test::getTitle'

The controller code is the following one.
class Test {

  /**
   * Returns a page title.
   */
  public function getTitle() {
    return  'Foo: ' . \Drupal::config()->get('system.site')->get('name');
  }

  /**
   * Returns a page render array.
   */
  public function getContent() {
    $build = array();
    $build['#markup'] = 'Hello Drupal';
    return $build;
  }

}

Alternatively, as the same change record suggests, you could use the #title property in a render array. This should be generally avoided, since the title for the page when fully rendered could be different from the title in other contexts (like in the breadcrumbs).
class Test {

  /**
   * Renders a page with a title.
   *
   * @return array
   *   A render array as expected by drupal_render()
   */
   public function getContentWithTitle() {
     $build = array();
     $build['#markup'] = 'Hello Drupal';
     $build['#title'] = 'Foo: ' . Drupal::config()->get('system.site')->get('name');
     return $build;
   }

}


Can I use hook_uc_add_to_cart to ask for a yes/no confirmation before adding to cart?

I was able to solve this issue using the first answer on this stackoverflow question : https://stackoverflow.com/questions/10490253/how-to-save-a-session-variable-in-drupal-7

In general: Drupal's static $_SESSION array variable allows to store key=>value pairs between different node pages, in my case the same page.

My code snippet inside uc_product_minmax_uc_add_to_cart hook :

    if (!empty($disclaimer)) {

        $confirmed = lists_session("s_key");

        if(! $confirmed) {

            $message[] = t($disclaimer, array('@qty' => $minmax->pmin_multiple, '!item' => $node->title));
            $result[] = array(
                'success' => FALSE,
                'message' => theme_item_list(array('items' => $message, 'title' => t('Read this note from medical department before confirming your reservation :'),
                'type' => 'ul', 'attributes' => array())),
                'silent'  => FALSE,
            );
            lists_session("s_key", TRUE);
        }
    }


Drupal integration with external binary program to convert an image?

Not anything near a working proof of concept, but a hint in the right direction:

You could use FileEntities for the upload of the Files, for example via a FileField on a node.

In hook_node_insert() and or hook_node_update() you can get the path to the file in the filesystem via:

$file = $node->field_source->entity;
$path = FileSystem::realpath($file->getFileUri());

You could than trigger the execution of your external program. By using hook_cron() you could regularly check for results. You could than attach the resulting file to the node like this

// Create FileEntity from a local file.
$uri  = file_unmanaged_move($path, 'public://'.$result_filename, FILE_EXISTS_RENAME);
$file = File::Create([
    'uri' => $uri,
]);
$file->save();
// Load node and attach the file.
$node = Node::load($nid);
$node->field_result->setValue([
    'target_id' => $file->id(),
]);
$node->save();


How to send an eMail on specific dates indicated in 3 different date fields?

You can perfectly use the Rules module for this. Here are the main steps to do so:

You need "a" field related to the "date" your want to do something with (you're fine with that, you already have 3, so repeat what is below for each of the 3 fields).
Create a rules Component  for sending an eMail (specific to the reminder-eMail you want to send).
Create a Rule to trigger the Rules component from Step 2, which typically involves some date offset (like "how long ahead should the eMail be eMailed?").

For a sample of step 2 and step 3 above (in Rules export format), refer to my answer to the question about "Rule to store user's last post date and scheduled rule based 30 day reminder".

Note: If you're not familiar (enough/yet) with Rules, checkout the 32 (!!!) great, and free, video tutorials Learn the Rules framework.


Why and what wrapper should I use for my module's JavaScript file?

There are a couple of different things at play here.

This:

(function (Drupal, drupalSettings, d3) {

})(Drupal, drupalSettings, d3));

is an Immediately Invoked Function Expression (IIFE). Quoting gion_13 from the canonical SO post on the subject:

  This pattern is often used when trying to avoid polluting the global namespace, because all the variables used inside the IIFE (like in any other normal function) are not visible outside its scope.

That's why you'll see it so often in Drupal's (and pretty much any other framework or library's) JS code; it's generally considered good practice.

Ben Alman's blog post is a must read if you're not familiar with this pattern. Yes, it's a good idea to use it in your own code.

This:

Drupal.behaviors.mymoduleTest = {
    attach: function() {

    }
};

is a Drupal "behavior". Quoting the docs:

  Any object defined as a property of Drupal.behaviors will get its attach() method called when the DOM has loaded both initially and after any AJAX calls.

This allows your code to re-run on elements that may have been replaced as a result of an AJAX or other JS event, so you don't need to keep track of that.

Say you had a d3 chart bound to an element in the content area, and an AJAX operation on the page replaces the content area with new HTML; the d3 bindings will be lost, and the chart will no longer show. Assuming the AJAX op was invoked by Drupal's API in some way, your attach method will be invoked automatically, and the chart will be re-bound to the new element in the content area.

It's a good idea to conform to this pattern when writing JS code for a Drupal site, it has the potential to save time and headaches later on.

As always it'll pay to use common sense with stuff like this; if you find yourself using these patterns, then immediately trying to get around them for a couple of specific requirements, those situations may be exceptions where it's best not to use them.


Installation keeps complaining that Unicode library (mbstring) should be disabled, even though it seems it already is

http://php.net/manual/en/mbstring.configuration.php#ini.mbstring.http-input

Drupal's code is checking it in core/lib/Drupal/Component/Utility/Unicode.php, but it won't even check if unless PHP version is < 5.6.0.  If you are using PHP 5.5.x here's the check:

  if (ini_get('mbstring.http_output') != 'pass') {
    static::$status = static::STATUS_ERROR;
    return 'mbstring.http_output';
  }

So I would double check the phpinfo via the Drupal interface at /admin/reports/status/php to make sure you are changing the config file that's used by PHP for Drupal.


How to modify HTML of specific node in Drupal 7?

Short answer: Place a customized template named node--[nid].tpl.php or page--node--[nid].tpl.php in your themes template folder. ([nid] = id of specific node).

Long answer: If you didn't done yet, you should first create a Bootstrap subtheme for your modifications. Then copy either node.tpl.php or page.tpl.php from the Bootstarp theme inside your subtheme folder. Rename the file to either node--[nid].tpl.php or page--node--[nid].tpl.php (Replace [nid] with the node id of the specific node) and customize the file to your liking. Lastly clear the cache at /admin/config/development/performance

For more/other template examples have a look at Drupal 7 Template (Theme Hook) Suggestions

EDIT: To control specific blocks for a specific page, I'd create a dedicated region inside your subtheme's .info-file and in your page.tpl.php / page--node--[nid].tpl.php. And place the blocks inside those regions.


Is drupal able to handle technical data sheets?

According to me you have half answered your question, yes node is what your data holder for the datasheets.
consider nodes as container for your data so to change the way you to present them you can use views module.views module will allow you to present your nodes the way you like also you have option to export your views in different formats.

Here are some modules which can be helpful for exporting your views in different formats

Views PDF
Views data export
Views Excel Export

Update:

For content locking for concurrent content edit
 you can  check Content locking (anti-concurrent editing) contributed module.

Update:

About having different types of datasheets,

If you are looking are categorizing your nodes/sheets, core shipped taxonomy is there.
If you need to have separate types of sheets in structure, permissions to create/edit/view them, having separate content types will be the solution.


How do I programmatically generate a menu based on field values?

This could be achieved by using taxonomy to define your terms and the Taxonomy Menu module to create the menu from these terms. Taxonomy is the preferred method for categorising content.


How to import the node class into a title field of a view?

As far as I understand, you want to add a class name to the title field of your nodes listed in a view. (1) Views provide this functionality by default:

Adds the class to the selected html element, <span> is by default.
It can be used as a field wrapper.

(2) In case this is not suitable for you, you may very well use view's "rewrite results" :

It can be used to wrap the field's text.

(3) Lastly there is always the preprocess_views_view_fields solution where you can edit your field's attributes:

if($view->name == 'view-name') {
  $vars['fields']['title']->wrapper_prefix = '<div class="views-field views-field-title my-class">';
}

It can be used as a field wrapper.


How can I create a "show full article" button that bypasses smart paging?

I have never used smart paging, but from looking at the docs and the code I would say this is currently not possible. My suggestion in this case would be to create a feature request in the modules issue queue.


is there a module for status updates in drupal 7

Somthing along the lines of statuses?  It doesn't have a stable release yet, so is DEFINITELY not ready for production.  I've not used Heartbeat, so I can't help any more than that I'm afraid :(


How to display Commerce Order Owner role in Views fields?

No clue why it's not showing. The Views module defines a "User: Roles" field, and I see that just fine in my own development environment for a View joining to Users via the "Commerce Order: Owner" relationship.


'hook_entity_operation_alter', but for users

mymodule.module also needs:

use Drupal\Core\Entity\EntityInterface;

Credits to drupality, who first mentioned this in a comment below my question


They have 2 Varnish servers, 10 web servers and 4 database nodes (2 master, 2 slave)

Their workflow is Trunk -> Stage -> Live, from bzr.

They are fully Drupal for a month or so, now.

See The Economist: An Informal Technical Case Study session video from DrupalCon London for more information on their processes.


Implement Menu block hook function hook_menu_block_tree_alter() to add/change/remove classes

Other than the regular clear cache I am not sure why that would not be called. I do not have much experience with that hook. However I am fairly certain theme_menu_link would work here as well. Take a look at the answer here. A test for $vars['element']['#below'] should allow you to accomplish what you want.

Note: If you have a small menu you can always add classes to menu items through the UI.

EDIT: To answer part 1 try something like this (taken from bootstrap_menu_link):

if ($element['#below']) {
  if ((!empty($element['#original_link']['depth'])) && ($element['#original_link']['depth'] == 1)) {
    // Add our own wrapper.
    unset($element['#below']['#theme_wrappers']);
    $sub_menu = '
' . drupal_render($element['#below']) . '
';
    // Generate as standard dropdown.
    $element['#title'] .= ' ';
    $element['#attributes']['class'][] = 'dropdown';
    $element['#localized_options']['html'] = TRUE;

    // Set dropdown trigger element to # to prevent inadvertant page loading
    // when a submenu link is clicked.
    $element['#localized_options']['attributes']['data-target'] = '#';
    $element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
    $element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
  }
}


How to have View output is same as node output

but when I go like /poem/1 I am not seeing the block that list the poems. The node/1 view has bold header of the title but that's missing in my /poem/1 too.

In the Blocks Admin UI at admin/structure/blocks be sure the Block for your block view for a poem listing is enabled for the url path = poem/*.

You can also assign blocks to regions easily with the Context module.


Term order when saving a new taxonomy term

while I am not aware of a solution that will get you this exactly behavior without spending a bunch of time on a unique setup, there maybe a simple workaround for you to quickly identify the new term and move it to whereever it belongs to.

but first of, the definition or new terms being sorted alphabetically is not entirely true. by default, newly added taxonomy terms have a Weight of '0'.
this Weight value serves as the first sort criteria: terms with a higher Weight value will be further down, as will terms with a lower Weight value (can be negative too) appear further up in the list.
only when multiple terms share the same Weight value, they further get sorted alphabetically.

you can see the exact Weight value for every term by clicking Show row weights just above the top right-hand corner of the table.

so if you have a taxonomy vocabulary where all terms have a Weight of -1 and below, newly added terms will be found at the very bottom of the list.

while this will put new terms to the very end of a list, setting up a list this way may be rather tedious, as you might run out of negative numbers or simply because managing 200+ entries this way can  be a pain in the butt. instead, there is another approach I find myself using most of the time:

there are two View Modes managing Weights: one enables you to manually define a Weight value via a select list (the 'show row weights' mode mentioned above), and the other one lets you sort individual terms via dragging and dropping by clicking on the cross/drag cursor on the very left of each term. when you manually define a term order by dragging and dropping (dont forget to hit Save!), every term will be given a unite Weight value starting by 0.
 this means only the very first term will have a Weight of 0. the second term will have a Weight of 1, the third gets a Weight of 2 and so forth.
when you now add a new term, it will be assigned the weight of 0 as well, placing it as either the very first or second term in the list. this will enable you to find it immediately and place it wherever you need it to be.
if you find yourself wanting to place that new term at the very bottom, dragging it all the way down can be tedious as well, so a quicker way now would be to enable Show row weights again, just pick the lowest value and hit Save.

again, maybe this is not exactly what you are looking for, depending on whether you actually care about the order they are listed, or just want to identify the newest entry.


How to use cron to delete nodes of a content type that does not allow deletion by anonymous users

Not sure if you want to consider using it, but the Rules switch user module might be an acceptable compromise. Some details about it (from its project page):

This module adds two new Rules actions:

Switch to another user
Switch back from another user

These actions could be useful when you have an operation that you want an unprivileged user to use but it fails because the user doesn't have sufficient permissions.

Refer to the image on its project page to get the big picture. So if you'd add these 2 Rules Actions at the start / end of your list of existing Rules Actions, and you'd use some user id that does have the right permission, it should work.
As an alternative you could just reuse the relevant code (it's only 76 lines ...) to create your own custom Rules Actions. Similar to what you wrote in your question (= "**...code in a custom module...").  If you make any useful improvements, please consider contributing your changes back to the module's issue queue.
Be aware, however, that this module only has a DEV version for D7 (= not covered by Drupal’s security advisory policy!). This doesn't mean that the module/code is dangerous to use/reference, but it does mean that the code has not been vetted by the Drupal security team.


ER fields store only the ID of the referenced entity.
Pulling in other information about the referenced entity usually involves adding Relationships, but some details can also be shown through the Formatter Field setting.
Set Formatter to Entity ID and Rewrite
Without adding the Relationship edit the ER field, set the Formatter to Entity ID, then under Rewrite results turn on Override the output of this field with custom text and enter something like this into the Text field:
{{ field_myImagefield }}
Check the correct tokens under Replacement patterns a bit lower under the Text field.
You can also achieve similar result with Output this field as a custom link which has more options for the link if you need them. In this case the Text field will only hold the image token and this option will contrast the anchor HTML.
This approach is helpful when you have a multivalue field it will be possible to show all values in the same row, while using a Relationships usually splits them into separate rows and it requires more steps to aggregate them.
Use the ER Relationship
If you add the ER Relation ship you will be able to add the Link to content field and make it use that Relationship to show the link to the Referenced entity instead of link to the original row entity.
You may want to use the Output the URL as text option to make the token output more predictable.
Now you have the referenced entity link in your Views you can use it to Rewrite other fields.


export views data to text file in the background

Well, I think you can set a cron job on server. You just need to add a drush command in crontab file. Drush command :

drush views-data-export [view-name] [display-id] [output-file]

Views data export provides this drush command.

Edit :

If you don't have drush installed on your server then you can take the idea from code of views_data_export.drush.inc.

Or :

In simple way you can run the code following in hook_cron :

$output = views_embed_view('ViewName', 'views_data_export_1');
file_unmanaged_save_data($Output , 'private://output.xls', FILE_EXISTS_REPLACE);

As per https://www.drupal.org/node/1875456#comment-7524421.


Custom Display Modes on a custom entity type

As always, I found the answer just after posting the question.

For others looking for the same thing, you need to create an install .yml file in your custom module.
I found this by looking at the Media module in core.

In your module create config/install/core.entity_view_mode.ENTITY_TYPE_ID.NAME_OF_VIEW_MODE_TO_CREATE.yml that implements the following:

langcode: en # Or your default site language
status: false
dependencies:
  module:
    - my_module
id: entity_type_id.name_of_view_mode_to_create
label: 'My new View Mode'
targetEntityType: entity_type_id
cache: true

I hope this helps someone else too :D


What are the required fields to create user through social media login?

For Social Media Login Password field is not required. Only Username, Email-ID is required. After register with with social media login, Your account is pending for approval by the site administrator. You will receive an email once your account has been approved and you can then login with your Google account.


This is how I'm doing it for dropdown operations(Font Awesome icons).

/**
 * Implements hook_preprocess_links().
 */
function HOOK_preprocess_links(array &$variables) {
  if (stripos($variables['theme_hook_original'], 'links__dropbutton__operations') === 0) {
    $variables['attributes']['class'][] = 'menu';
    $links = &$variables['links'];
    foreach ($links AS $key => &$link) {
      switch (Html::getClass($key)) {
        case 'view';
        case 'canonical':
          $icon = 'eye';
          break;

        case 'edit':
          $icon = 'pencil';
          break;

        case 'delete':
          $icon = 'trash';
          break;

        case 'clone':
          $icon = 'clone';
          break;

        case 'add':
        case 'create':
        $icon = 'plus';
          break;

        case 'manage-fields':
          $icon = 'list';
          break;

        case 'manage-form-display':
          $icon = 'server';
          break;

        case 'manage-display':
          $icon = 'th';
          break;

        case 'devel':
          $icon = 'code';
          break;

        case 'pay':
          $icon = 'money';
          break;

        case 'enable':
          $icon = 'toggle-off';
          break;

        case 'disable':
          $icon = 'toggle-on';
          break;

        default:
          $icon = 'question';
          break;
      }

      $link['link']['#title'] = [
        '#type' => 'inline_template',
        '#template' => '{{ title }}',
        '#context' => [
          'title' => $link['link']['#title'],
          'icon' => $icon
        ]
      ];
    }
  }
}


Conditionally load JS based on whether or not a field has data?

If a field within a specific content type has some content, load some javascript, if there's nothing in the field, do nothing.

function THEME_NAME_preprocess_page(&$variables) {
  if(isset($variables['node']) && $variables['node']->type == "CONTENT_TYPE") {
    if(!empty($variables['node']->FIELD_NAME)) {
      drupal_add_js(drupal_get_path('theme', 'THEME_NAME') . 'PATH-TO-JS.js', array('type' => 'file', 'scope' => 'footer'));

    }
  }
}


Theming main menu with block--menu.tpl.php not working

main-menu comes from system module, so it should be block--system--main-menu.tpl.php

Cheers


The path changes, as in Drupal 7 the same page you would before see at admin/settings/error-reporting is now at admin/config/development/logging.


Customize content page in backend with more filters

There's a module for it! :)
You should take a look at Administration Views. This module gives you all you need. Just create views for nodes or users or use the default ones that come with the module. It has a dependency to Views Bulk Operations as it can perform customizable tasks, like mass deleting or changing values.


Override page.html.twig with custom module template

drupal_get_path('module',$module_name)  function will return the path to your custom module so:
function promo_accc_theme_suggestions_page_alter(array &$suggestions, array $variables) {
    $suggestions[] = drupal_get_path('module','promo_accc').'/templates/page__promo__accc';
}

for more info about the drupal_get_path() function: https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/function/drupal_get_path/8.7.x


On large sites with many users and many simultaneous connections keeping sessions in database will cause a problems. So there are some tricks that may help you:

Don't keep unneeded sessions for anonymous users. To do this, choose one of the following, from what I advise most, to what's easiest:

Upgrade to Drupal 7
Migrate to Pressflow
Use No Anonymous Sessions module

Move your sessions where they will do less damage:

Memcache API and Integration module allows sessions in memcached bin
Memcache Storage (possibly with Cache Backport) offers the same functionality
Create your own session module looking at code of the above, for example to keep sessions in shared memory or in files on a ramdisc.

Flush sessions every midnight (or other hour with no visitors)


Drupal is a dynamic application, having an index.html file wouldn't make much sense.

There is an index.php file at the root of the install (the one you've already found). All requests are sent to that script, and the Drupal bootstrap takes over and routes them to the PHP function responsible for serving the appropriate content.

If you want to change the content on the front page, the simplest way would be to create a new node (of whatever type you feel is appropriate), visit /admin/config/system/site-information, and set the "Default front page" to the page of that new node.


What you're experiencing is a bug. It happens quite often with contributed code, since it usually moves faster than it is tested. But don't worry, being contributed also means there are lots of people using, and probably someone else will bump into the same issue as you are experiencing.

When you face an issue that looks like a bug, you should ask yourself whether you've configured everything properly. Check first, but if there's nothing obviously wrong, give the issue queue a visit. Every module, theme or profile has an issue queue where people report bugs, suggest features and ask for support.

Search the issue queue and you may find a patch to your issue. If there is no report of your bug, file a new issue and provide a step-by-step guide to reproduce the error. That means you will have to try installing and configuring the module again on a fresh Drupal install. When the module mantainer sees the bug report, the steps to reproduce will make it a lot easier to debug and provide you with a fresh patch.

Mantaining modules/themes are usually voluntary work, and if you don't provide the steps to reproduce nor reply to mantainer questions, your issue will probably be postponed. Get involved with the community, it pays off.


$form_state->setErrorByName() for a form in a block doesn't work properly

This is a known bug. You can see the same problem with the core user login block upon submitting bad credentials. The comments in that issue note that it's a side effect of another issue which has a fix committed to the 8.2.x branch.


permisssions set to 755 - image upload is not possible - in drupal-commons 6x 24.

You have to set files directory permissions to 777 to make it writable by "others". As I understand you set it to 755 and expect to be writable? 755 means all for the owner, read and exec by group and read and exec by others.

EDIT: As MPD said, if the owner of the files is same user as the one apache runs as than files directory doesn't have to be 777. 755 is enough and it is also recommended.


Form API Select List will not show empty option

It looks like you're not running your form through drupal_get_form()...that would account for the additional form processing functions not running, but you'll still get a rendered HTML element out at the other end so it could be difficult to tell the difference.

Just change the page callback for your router item, and add the form as arguments:

function stack_test_menu(){
  $items['stacktest'] = array(
    'title' => 'Stack Test',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('stack_test_form'),
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'main-menu',
  );
  return $items;
}

Clear the caches and give your test page another try.

The same goes for your original problem - A form is essentially just a render array, and when you return that directly from a page callback it's run through drupal_render(). That function will do what it can to render the form element, and it knows how to do it to a certain degree, but the form processing functions add a lot of extra stuff in there, which drupal_render() won't do.

Moral of the story - always use drupal_get_form() to build the output for a form :)


Does anybody know how to add the remove button in a custom module (field type) with unlimited number of values?

The custom field type has to implement a method which tells whether the field is empty (if the inherited default method is not able to do this).

For example for a numeric field:

NumericItemBase::isEmpty()

  public function isEmpty() {
    if (empty($this->value) && (string) $this->value !== '0') {
      return TRUE;
    }
    return FALSE;
  }


I have the book, but page 404 does not include the quote in mine (the beginning paragraph is "The switch statement does...", so I cannot interpret the exact context of the quote.  In general, every page is assigned a path and drupal determines the display from its 'menu' of path options.  Think of the displayed menus as a subset of the available options in drupal's list.

Drupal stores information about each site in the database and callback functions are associated with the each master menu option.  When  a URL is requested, it queries the database, finds the associated function and executes it.

I found parts of 'The Definitive Guide...' confusing to begin with too, but it is actually pretty good overview and quite useful.  The problem is that Drupal is very large and a complex system to get your head around at first. The learning curve seems enormous at first (I know), but soon parts begin to fall into place and you begin to "GET IT".

This site is a great place to expand your understanding and begin to put it together.  Your question was well written (clear) and there are plenty of people here to answer (although traffic is slow this week with the holidays).


Install the module Admin Views
An overview from the module page:

Replaces administrative overview/listing pages with actual views for superior usability.
Features

Filter all administrative views via AJAX.
Perform any kind of bulk/mass operations on items in administrative views.
Filter content by title, node type, author, published status, and/or vocabulary.
Filter comments by title, author, node title, or published status.
Filter users by name, ban/blocked status, or user roles.

Once installed this module will replace the main admin content page, and the admin user page with pre-made views. You can then customise these to suit your needs (adding or removing fields / filters).


Count results in Views using aggregation

Yes, it is possible in Views 3 out of the box.
The idea is the same as in SQL aggregations. Lets see an example:

Edit your view and enable Views aggregations:

Remove default sort criteria.
Add fields “Content: Type” and “Content: Nid”:

Select COUNT function for Content: Nid:

To see what happens just turn on checkbox “Show the SQL query” at global Views settings page.

SELECT node.type AS node_type, COUNT(node.nid) AS nid
FROM
{node} node
WHERE (( (node.status = '1') ))
GROUP BY node_type
LIMIT 10 OFFSET 0

So, we are grouping nodes by node_type and calculating count for this groups.


How to manage multiple drupal 7/8 sites with multiple drush versions

I assume the command above is run locally and it connects to the dev server? On the dev server you have the phar-installed global Drush 8 and the site-local Drush 9. From the debug backtrace you see that it starts with launching the global Drush 8 and then at the end it uses some functions from the site-local Drush since those are included when Drupal 8 bootstraps. Not strange that it doesn't work. And to make it even worse the: The phar-installed global Drush is too old - Drush 8.14 is clearly needed.

It might work to upgrade the phar-installed Drush 8 to 8.15, but why not use Drush Launcher (which is recommended) and install in globally instead of Drush. It even supports a fallback to a globally installed Drush of your liking.


What permission is required to access node reference data?

After I add a dummy CCK field in claim_category, the list show up properly.


How to display a field in a content type template?

As per my knowledge you can not use $content array in field.tpl.php.
You need to use $items.

  Available variables:

$items: An array of field values. Use render() to output them.
$label: The item label.
$label_hidden: Whether the label display is set to 'hidden'.
$classes: String of classes that can be used to style contextually through CSS.

  from preprocess functions. The default values can be one or more of
  the following:

field: The current template type, i.e., "theming hook".
field-name-[field_name]: The current field name.
field-type-[field_type]: The current field type.
field-label-[label_display]: The current label position.
$element['#object']: The entity to which the field is attached.
$element['#view_mode']: View mode, e.g. 'full', 'teaser'...
$element['#field_name']: The field name.
$element['#field_type']: The field type.
$element['#field_language']: The field language.
$element['#field_translatable']: Whether the field is translatable or not.
$element['#label_display']: Position of label display, inline, above, or hidden.
$field_name_css: The css-compatible field name.
$field_type_css: The css-compatible field type.
$classes_array: Array of html class attribute values


Ubercart does have an API (see http://www.ubercart.org/docs/api and http://api.ubercart.me/ ), but I don't see general REST or SOAP support related to fulfillment.

Some options may include miniRESTapi or as noted UCServices and Bee Colony for Drupal 6. There are some vendor-specific SOAP implementations for CyberSource, but I do not know how well-supported they are.


How to delete a value from a multi-value entity reference field with EntityMetadataWrapper

This seems to work:

$wrapper->field_entityrefs[3]->set();

Also, to test if the field is there in the first place:

$wrapper->__isset('field_entityrefs');

I'm now finding myself calling __isset() on all wrapper fields.


Why do the database functions return all fields as strings?

The DatabaseStatementBase::fetchObject() method is inherited from PHP's PDOStatement::fetchObject() which returns the object columns as strings. Given that not all RDBMS's have the same set of types & PHP isn't a strongly typed language, it was probably decided to return everything as strings since it's a base datatype that can be relied on.


field update on field with no permission

I would use a Computed Field for this purpose, then you can define in PHP how to populate it.
Or you can populate it with a hook_nodeapi submit.


Is there any way to know if it is the first visit of a Anonymous User?

Why not set a cookie when folks visit, then you can check for whether they have the cookie. No cookie = first time visitor.


How do I re-attach AJAX behaviours to a managed_file field?

The main problem is that you're not loading the form in Drupal way in the AJAX requests. When you use the normal jQuery ajax to load the form, then the necessary actions(Generating new scripts and re-attaching the behaviors) won't happen.

So you should follow the below process to achieve it.

Create a page with ajax Link/button - clicking on it should load the form(This
may change based on your need)
Create form generation callback
Create a ajax callback which will returns the form

Below is the complete example module which loads the form with the managed file field using ajax.

<?php

/**
 * @file
 * Provides File module pages for testing purposes.
 */

/**
 * Implements hook_menu().
 */
function test_menu() {
  $items = array();

  $items['file/test'] = array(
    'title' => 'Managed file test',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('test_form'),
    'access arguments' => array('access content'),
  );
  $items['ajax/test'] = array(
    'title' => 'Managed file test',
    'page callback' => 'file_ajax_page',
    'access arguments' => array('access content'),
  );
  $items['ajax/form'] = array(
    'title' => 'Managed file test',
    'page callback' => 'file_ajax_form',
    'access arguments' => array('access content'),
  );

  return $items;
}

/**
 * Generates the Test page.
 */
function file_ajax_page() {
    // Make sure Drupal Ajax framework javascript is around.
  drupal_add_library('system', 'drupal.ajax');
  $output = '';
  // Generate a Ajax Link to load the form.
  $output .= l(t('Delete'), 'ajax/form', array('attributes' => array('class' => 'use-ajax')));
  // Specify the container for the form.
  $output .= '

';
    return $output;
}

/**
 * Returns the processed file form.
 */
function file_ajax_form() {
    $commands = array();

    // Treat them in Drupal way to load the form in AJAX, so that all the necessary scripts will be loaded.
  $commands[] = ajax_command_html('.form-container', drupal_render(drupal_get_form('test_form')));
  ajax_deliver( array(
    '#type' => 'ajax',
    '#commands' => $commands,
  ));
}

/**
 * Form constructor for testing a 'managed_file' element.
 *
 * @see file_module_test_form_submit()
 * @ingroup forms
 */
function test_form($form, &$form_state, $tree = TRUE, $extended = FALSE, $default_fid = NULL) {
  $form['#tree'] = (bool) $tree;

  $form['nested']['file'] = array(
    '#type' => 'managed_file',
    '#title' => t('Managed file'),
    '#upload_location' => 'public://test',
    '#progress_message' => t('Please wait...'),
    '#extended' => (bool) $extended,
    '#size' => 13,
  );
  if ($default_fid) {
    $form['nested']['file']['#default_value'] = $extended ? array('fid' => $default_fid) : $default_fid;
  }

  $form['textfield'] = array(
    '#type' => 'textfield',
    '#title' => t('Type a value and ensure it stays'),
  );

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

  return $form;
}

/**
 * Form submission handler for file_module_test_form().
 */
function test_form_submit($form, &$form_state) {
  if ($form['#tree']) {
    $fid = $form['nested']['file']['#extended'] ? $form_state['values']['nested']['file']['fid'] : $form_state['values']['nested']['file'];
  }
  else {
    $fid = $form['nested']['file']['#extended'] ? $form_state['values']['file']['fid'] : $form_state['values']['file'];
  }
  drupal_set_message(t('The file id is %fid.', array('%fid' => $fid)));
}

This way Drupal will do all the works for you if you specify what/how do you want:)

I took File Test module in the core as the base for this example.


Three level menu: How to show only the children of the current page?

You can do that with Menu Block module.

  It provides configurable blocks of menu trees starting with any level of any menu. And more!

You can then first create a menu block in the block configuration page.  Then configure the menu block to start with the 2nd or 3rd level according to which level of the menu you want to have and set the depth to 1 so that it only lists that level and not its children.

If you want to have sub-menu items follow the current menu item, i.e. it always shows the children of the current page, you should set under the menu block configuration, Advanced Options, and check Make the starting level follow the active menu item.


Add background to a div based on a Node's Image Field

You could try BackgroundField:

  BackgroundField started as an extension of the CCK ImageField that
  allows a CSS selector and background attributes to be set for a
  content-type. This is particularly helpful for allowing your node
  authors to add images to a node that are integrated into the theme of
  the site. With the inclusion of the Image field in Drupal 7,
  BackgroundField was rewritten to extend that core functionality.


Contextual filter only working on one URL

OK, found my error.

On the artist block configuration I'd copy pasted urls except for the label, it said:

`label/artists shop/artists/ management/artists/ wholesale/artists/ publicity/artists/`

Removing the trailing slashes did the trick.


Need help modifying the OG "add user" form to replace the user search box with first and last name searches

I ended up using a custom callback to populate a new field called "full_name", and then used JQuery to populate the username field on blur of my new field, and also hid the username field to make the interface a little more intuitive. It worked well enough, but it would be nice to completely override the submit function and use a custom one to ensure everything worked as expected. If a user enters in an invalid name and clicks enter, the default validation fires off, and nothing I've created works without a page reload. Kind of stinks, but at least it's working for the time being.


I'm pretty certain you want to be saying 'template' in your  hook_theme():

template: If specified, this theme implementation is a template, and this is the template file without an extension. Do not put .tpl.php on this file; that extension will be added automatically by the default rendering engine (which is PHPTemplate). If 'path', above, is specified, the template should also be in this path.

instead of 'file', as...

file: The file the implementation resides in. This file will be included prior to the theme being rendered, to make sure that the function or preprocess function (as needed) is actually loaded; this makes it possible to split theme functions out into separate files quite easily.

...which would suggest the reason why all of this html is being spit out on top of each page because it is being included every time instead of being buffered with Drupal's theme engine as a template and then output later on.


How to fetch content data based on Node reference field into a view

I think you can either construct your news and article views as attachments and attach them to your view, or you can bring the content for news and articles in field by field in the main view.

Using attachments might help you to end up with less repetition without having to use query aggregation.


You are retrieving the absolute url of the file correctly, but your quotes in style attribute are a little mixed up.

Try this:

<?php
print '

';
?>


How to assign 2 taxonomy vocabularies in a single field for a node?

Usually is is not good to rely on modules what are not widely used (like Combined Termref), because of worse community support and maitainance.

Consider using Entity Reference module what can connect any type of entities together. You can use it almost the same way like Term reference field.

There propably will be some differences in configuration, but nothing critical (blocking use-cases), just less straightforward. Internally it will works the same - is saves entity ID of term into "term reference field".


How to see the individual fivestar ratings in a view?

I believe you can create a relationship to Votes, and then you can show the users who voted and their vote values.


Custom Submit Handler issue in getting file

You need to use following code to get it

$target_id =$form_state->getValue('field_name');//get the target_id from it
    $file = \Drupal\file\Entity\File::load($target_id); //load the file and its attribute.
            $file_image= '<img src = "' . \Drupal\image\Entity\ImageStyle::load('large')->buildUrl($file->getFileUri()) . '" />';//load the large image


Let users create content by using the default (non-admin) theme

I might misunderstand you, or you did not yet try this. There is a permission View the administration theme, which normal users should not have.

This means that if you login as a less privileged user that has permission to [Content type]: Create new content, the add content page will look like any other front-end page already:


How do you include a user's default image in a Drupal 7 view that lists people?

I have just found the answer to this question via Drupal.org. You have to use a URI like this:

public://user_pictures/default.png

in your account settings.

Here, public:// stands for your public files location (often sites/default/files/). What comes after that, is the location of your image within public files. If you do this, the default image is treated like normal user images.


Using Webform as an Application for membership/user roles

Based on some other questions you've asked on this site I wonder if you are using CiviCRM for tracking the memberships? If so I might suggest this workflow:

Setup a webform with CiviCRM integration. Add your membership and other custom fields to the form.
Set the membership status to be "Approval Needed" (you can create that status in CiviCRM if it isn't there already).
Have it send an email to your staff whenever that form is filled out.
You can optionally restrict access to that form so that only non-members can use it.  This would require you to enable the module 'CiviMember Roles Sync' which is bundled with CiviCRM and enabled syncing between Drupal roles and Civi memberships.


How to process the data which type is BLOB?

Pass it to unserialize(). That is the string obtained from serialize(), when the argument is the following array.

$array = array(
  'attributes' => array('title' => ''),
  'langcode' => 'zh-hans',
);

serialize() is the function used from Drupal when the data to save in the database is an array.


Using "Model Entities" Module to Create Custom Entities

I know this question is a little old, but just in case you (or others) still need assistance...
Make sure the hook_views_default_views() was renamed properly.
If your module name is "client" then it should be client_views_default_views().

I was recently working with the Model Entities module and ran into the same issue. Turns out I missed renaming that function.

If it's named correctly, then I suggest comparing your file to the model.views.inc file to find the difference.


Blog with subscription option to send emails on new blog entry

Another way is to use the MailChimp module but requires the extra step of registering on MailChimp.com.

  This module provides integration with the MailChimp email delivery
  service. While tools for sending email from your own server, like
  SimpleNews, are great, they lack the sophistication and ease of use of
  dedicated email providers like MailChimp. Other players in this field
  are Constant Contact and Campaign Monitor.


what is the importance of delimter in a feeds module

The delimiter in csv (comma separated values) files is a comma, usually. It may be changed. The delimiter expected by Feeds must match the delimiter used in the csv files, or feeds cannot detect where one value ends and the next begins.


Drupal doesn't send email to reset password

Taking a quick peek at your code (at http://cie.austin.utexas.edu/uex-cm/user/password) it looks like something is overriding the default HTML output for your forms. You're missing the <form> tags and the associated action and method attributes.

If you're looking for a quick fix (just to login one time) you can use Chrome Inspector or Firebug or similar to add the form tags around your form elements:

<form action="/uex-cm/user/login" method="post" id="user-login" accept-charset="UTF-8">
  // Your existing form elements
</form>

But ultimately, you'll need to figure out what is stripping the <form> tags from your HTML.


How to import a CSV with list field labels using Feeds?

It seems that this is a known issue. There is a patch at https://www.drupal.org/node/2006810


How to retrieve files from url when they have whitespace into filename?

I managed to solve the issue by adding this command:

$image= str_replace(' ', '%20', $image);

I juste replaced all whitespaces with html whitespace characters..


Exporting custom configurations from Drupal

You can features module. So you can create a feature of several configuration and can use in other installation.

Sorry I missed the features part in question, which you already know.

I think features is the best solution for exporting configurations. other than features nothing is there for exporting all configurations without telling what to export.


Create a rule based on specific URL being visited

Publish content

  Exposes publish/unpublish links to your views, making it easy to
  streamline workflows for reviewers, editors and publishers.


LESS like SASS has to be compiled to real CSS-files.

Find out where the compiler put the CSS-files eg. by disabling css-aggregation and check the source-output of your site.
Add the paths of the css-files to your CKEditor-settings.


This is more of a hint since I don't have "comment" privileges yet.
You could create 4 field sets to accommodate the rows. Then create the collected funds and donor fields and when you add fields in each field set, use the respective field rather than create new ones.

So you are then left with html that you can very easily manipulate into having the appearance of being a table.

You would need to position the fieldset label to the left rather than on top and then hide the field labels for all but the first field set (giving it an absolute position and setting the first field to have enough left margin should accommodate this.

Then position the fields by either setting max widths and floating left to keep it responsive or setting the width of the field and the fieldset so that it's not responsive.


How to display custom content when viewing node?

I resolved it by using hook_node_view() to append to the $node->content object.


When can I use a custom field type instead of a custom entity?

Custom entities and custom fields are not mutually exclusive, you can use them together.

You can build a custom field type with more than one property. See for example the Password field which defines three properties:

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21Plugin%21Field%21FieldType%21PasswordItem.php/function/PasswordItem%3A%3ApropertyDefinitions/8.2.x

You can also extend the entity references field. See for example the File field:

https://api.drupal.org/api/drupal/core%21modules%21file%21src%21Plugin%21Field%21FieldType%21FileItem.php/function/FileItem%3A%3ApropertyDefinitions/8.2.x

The File field adds two properties to the reference field. In your case you would add the properties chemical name and concentration to a reference field which points at the analysis entity.


system.admin_config is the top-level page at /admin/config. Normally you would not put your configuration link there - you would instead put it into one of the blocks that appear on that page. For example, the "People" block would be user.admin_link, so if you want your config under "People" use user.admin_link as your parent. Or if you want to put your configuration link under the "Development" block use system.admin_config_development as your parent.

If you want to create your own top-level block then you need to do things a little differently - see the core user module and how it defines user.admin_link in user.links.menu.yml and user.routing.yml - this shows how a new block is created on the config page. You can then put your configuration link in that new block.


Why is my taxonomy term name no longer outputting?

Go to Structure > Content types > Article > Manage display, for Article for example. If your field is in Hidden section (bottom of the page) then change Format of this field to other than Hidden.


Using the FAPI in a hook_form_alter() function:

$form['buttons']['delete']['#attributes']['class'] = 'my-class';


Can I search for parent nodes from deep child nodes using Views?

You can probably do it with the Corresponding Node References module. Otherwise you can't do reverse references at all. You'll use relationships, of course, to go both ways.


How to avoid that a module encodes json puts out "\u0026" instead of "&"?

Explanation:

Content as Json module simply returns the content by running it through drupal_json_output(), which in turn call drupal_json_encode().
Inside drupal_json_encode drupal ensures to have unicode conversion to special characters including '<','>','&'.

function drupal_json_encode($var) {
  // The PHP version cannot change within a request.
  static $php530;

  if (!isset($php530)) {
    $php530 = version_compare(PHP_VERSION, '5.3.0', '>=');
  }

  if ($php530) {
    // Encode <, >, ', &, and " using the json_encode() options parameter.
    return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
  }

  // json_encode() escapes <, >, ', &, and " using its options parameter, but
  // does not support this parameter prior to PHP 5.3.0.  Use a helper instead.
  include_once DRUPAL_ROOT . '/includes/json-encode.inc';
  return drupal_json_encode_helper($var);
}

If you see if your php version is greater than 5.3 than json_encode() it self takes the argument to make sure all are unicode converted, it php is less than or euqall to 5.3, than drupal imcludes a helper json-encode.inc file which do the same.

Solution:

Way 1: The best would be to handle it on the client consuming the json data, have quivalent parser on the consumer side as well.

Way 2: Hook into contentasjson module to return json the way you want.Alter menu callback to register your own page callback

function mymodule_menu_alter(&$itmes) {
  $item['contentasjson/%/%']['page callback'] = '_my_custom_json_as_content';
}

//Copy the code as it from contentasjson module `contentasjson_get_data()` callback with a small change the json_encode function.
function _my_custom_json_as_content($type, $id) {
  switch ($type) {
    case "node" :
      $data = _contentasjson_get_node( $id );
      break;

    case "comment" :
      $data = _contentasjson_get_comment( $id );
      break;

    case "menu" :
      $data = _contentasjson_get_menu( $id );
      break;

    case "taxonomy_term" :
      $data = _contentasjson_get_taxonomy_term( $id );
      break;

    case "taxonomy_vocabulary" :
      $data = _contentasjson_get_taxonomy_vocabulary( $id );
      break;

    case "custom_data" :
      $data = _contentasjson_get_custom_data();
      break;

    default :
      $data = _contentasjson_get_error_message_type( $type );
      break;
  }

  // If false (no data object returned), generate return message
  $data = ($data == FALSE ? _contentasjson_get_error_message_id( $id ) : $data);
  // Here is the small change we are doing.
  json_encode( $data );
}


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

You can expose information from other modules/"orphan" database tables from your own module by using hook_views_data in case nobody is exposing that table to views then you would "claim" it with all the consequences. If the table is already exposed to views but you want ton enhance the integration, you can use then hook_views_data_alter for adding fields, altering filters, etc.

You can find an example of how to implement a hook_views_data in the views documentation.


Using taxonomy exposed filter in a view ends in MySQL can only use 61 tables in a join

UPDATE

As discussed here, this issue was caused by some missconfiguration at view level and normally should not occur. Read the full post to get the full picture on how you can step on this error.

ORIGINAL ANSWER

I'm adding my findings as answer since comments have limitations both on styles and length, but by all means THIS IS NOT an actual answer to the question.

I've tried to reproduce the describe behavior using an exisitng Drupal site that I'm working on:

I've a content A with a er field targeting vocabulary B
I've generated over 300 terms with hierarchy
Added 2 nodes tagged with 2 of the generated terms
Created a view as described in the question, but with a slight change: I've one display using "Has term" filter an another display "Has term (with depth)" filter; I explain below why I did this.

The reason using two displays with these two filters is because I saw that "Has taxonomy term" filter (plugin id taxonomy_index_tid) is implemented by \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid which extends from \Drupal\views\Plugin\views\filter\ManyToOne. Reviewing the code I saw that neither the ManyToOne base filter or the TaxonomyIndexTid implement JOIN queries. On the other hand \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTidDepth extends from TaxonomyIndexTid and has this on it's ::query() method

public function query() {
  ...
  // Now build the subqueries.
  $subquery = Database::getConnection()->select('taxonomy_index', 'tn');
  $subquery->addField('tn', 'nid');
  $where = (new Condition('OR'))->condition('tn.tid', $this->value, $operator);
  $last = "tn";

  if ($this->options['depth'] > 0) {
    $subquery->leftJoin('taxonomy_term__parent', 'th', "th.entity_id = tn.tid");
    $last = "th";
    foreach (range(1, abs($this->options['depth'])) as $count) {
      $subquery->leftJoin('taxonomy_term__parent', "th$count", "$last.parent_target_id = th$count.entity_id");
      $where->condition("th$count.entity_id", $this->value, $operator);
      $last = "th$count";
    }
  }
  elseif ($this->options['depth'] < 0) {
    foreach (range(1, abs($this->options['depth'])) as $count) {
      $field = $count == 1 ? 'tid' : 'entity_id';
      $subquery->leftJoin('taxonomy_term__parent', "th$count", "$last.$field = th$count.parent_target_id");
      $where->condition("th$count.entity_id", $this->value, $operator);
      $last = "th$count";
    }
  }

  $subquery->condition($where);
  $this->query->addWhere($this->options['group'], "$this->tableAlias.$this->realField", $subquery, 'IN');
}

As shown it does LEFT JOINS to work with the selected depth and hierachy. All though after selecting all 300 terms in both displays I was unable to reproduce the described error (see screenshots below).

Has taxonmy term

Has taxonomy term (with depth)

Also as commented @mpdonadio the filter is using WHERE IN to filter the terms and delegates to LEFT JOIN when dealing with hierarchy.

Maybe these can shed some light on your error.


How to change the url pattern of user revisions?

This path is defined by revisions module hook_menu(), so if you want to alter it, use hook_menu_alter() in your module.

function mymodule_menu_alter(&$items) {
  // Copy element to new path:
  $items['users/%/archive/%/view'] = $items['users/%/revisions/%/view'];

  // Optionally remove original - this may break some links!
  unset($items['users/%/revisions/%/view']);
}

And of course remember to clear the caches!


How do I get the correct URL of an image field?

You want to use the drupal_realpath() function to convert the URI into the actual filesystem path.

echo drupal_realpath($field_company_logo['und'][0]['uri']);

You could also use file_create_url() to get the actual URL to the image, as opposed to a local filepath.

And the correct way to render an image is to run it through theme_image():

echo theme('image', array(
  'path' => file_create_url($field_company_logo['und'][0]['uri']),
  'alt' => check_plain($company[0]['#markup']),
));

Also, accessing field data the way you're doing it isn't the preferred method. Have a look at field_get_items() and the detailed example in the Rendering Drupal Fields (the right way) blog entry.


There are a few things wrong with your approach, don't use $_POST, the values are there in &$form_state and you will break Drupal form handling using $_POST. If you have devel running use dpm() to explore that array.

In the theme function call drupal_get_form with the right name: forexCompare_form, i.e.
drupal_get_form('forexCompare_form'). Or was the theme function just an example.


header and menu is missing from Login module page--user--login.tpl.php

Your page--user--login.tpl.php is overriding the page.tpl.php. Print your header & menus regions/variables  in the file 'page--user--login.tpl.php'.


As far as I know, path templates are built-in Drupal 7, so just do this:

page--node--add--blog.tpl.php (for blog)
page--node--add--story.tpl.php (for story)
etc.
etc.

Clear cache!


What module are you using to get the list of IPs ? You need a Reverse DNS lookup to integrate with your module, I wasn't able to find such module on drupal.org but there's a lot of sites that provides such service like Domain tools: lookup for 203.153.44.130 .


The simpler approach is with the help of entity_metadata_wrapper().

$e = entity_create($entityType, array('type' => $bundleName));
$ew = entity_metadata_wrapper($entityType, $e);
$ew->field_name->set('value');
$ew->save();


Field sharing between translations of a node?

How about storing the 7 fields in a 1st content type and the 3 remaining fields in a 2nd content type. And then use the References module to connect them to each other? That way you'd only have to "translate" the content type with the 3 fields.

A variation of this could be using entities, whereas you'd then use the Entity Reference module instead. And probably also the Entity Translation module, for which quite some Community Documentation is available to get you started.

Drupal 7's new multilingual systems compilation contains an interesting set of posts about multilanguage websites ...

PS: You may also want to look at Node translation vs. Entity (field) translation for a lot of extra info/details about both variations of translations.


Unable to generate html using theme_table in block view

Assuming Drupal 7, and assuming $table_rows and $table_headers contain valid data, this is what you need:

$block['content'] = [
  '#theme' => 'table',
  '#rows' => $table_rows,
  '#header' => $table_headers,
  '#empty' => 'Nothing to see here...',
];


This is to do with render arrays in general, it's not just specific to AJAX or the form API (although the form API uses render arrays exclusively for building up it's content).

Put simply, array keys in a render array without a # in front of the name are seen as children of the render array, and are subsequently rendered themselves (recursively).

Those with a # in front of them are seen as meta data/variables for the render array to use as necessary, and are not themselves rendered.

The render array docs (linked to above) actually put this nice and succinctly:

  A render array is a classic Drupal structured array that provides data (probably nested) along with hints as to how it should be rendered (properties, like #type).

The # keys are the 'hints' that the above paragraph is talking about, the non-# keys are the nested data.

I'd thoroughly recommend giving that page a read, it does a good job of de-mystifying the whole render array thing, and provides code examples.

There's also another small explanation/code example on the Theming the page docs which might be useful.

Render arrays are used all over the place in Drupal (forms, themes, general markup, etc.) so knowing a good bit about them will help a lot with future Drupal development.


Resizing the Height of 2 blocks to always be the same depending on block with most content

There's plenty of equal height jquery plugins out there.

jquery-match-height and jQuery.equalHeights are two plugins that you can use, but there's others just google it up and you'll see for yourself.

Beyond that it's just a matter of integrating the plugin to your theme.


As a clue,  you should alter the theme_pager_link function. copy this function in the template.php, if the years are started from 2001, you need to alter the pager so that every link of the pager be summed with 2000, it is the function

function THEME_pager_link($variables) {
  $text = $variables['text'];
  $page_new = $variables['page_new'];
  $element = $variables['element'];
  $parameters = $variables['parameters'];
  $attributes = $variables['attributes'];

  $page = isset($_GET['page']) ? $_GET['page'] : '';
  if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
    $parameters['page'] = $new_page;
  }

  $query = array();
  if (count($parameters)) {
    $query = drupal_get_query_parameters($parameters, array());
  }
  if ($query_pager = pager_get_query_parameters()) {
    $query = array_merge($query, $query_pager);
  }

  // Set each pager link title
  if (!isset($attributes['title'])) {
    static $titles = NULL;
    if (!isset($titles)) {
      $titles = array(
        t('« first') => t('Go to first page'),
        t('‹ previous') => t('Go to previous page'),
        t('next ›') => t('Go to next page'),
        t('last »') => t('Go to last page'),
      );
    }
    if (isset($titles[$text])) {
      $attributes['title'] = $titles[$text];
    }
    elseif (is_numeric($text)) {
      $text = $text + 2000;  ------>>>>> in this line every number is added with 2000
      $attributes['title'] = t('Go to page @number', array('@number' => $text));
    }
  }

  // @todo l() cannot be used here, since it adds an 'active' class based on the
  //   path only (which is always the current path for pager links). Apparently,
  //   none of the pager links is active at any time - but it should still be
  //   possible to use l() here.
  // @see http://drupal.org/node/1410574
  $attributes['href'] = url($_GET['q'], array('query' => $query));
  return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
}

the indicated line with  ------>>>>> add every number with 2000, the only shortage of this solution is that the current number won't be summed with 2000. A few modification to this code will solve this problem as well. you can also add any css class to $attributes variable.


Next/previous links in a view based on contextual filter in the url

Not sure what your strengths are, but you could easily accomplish this with a custom php block.  If you did something along the lines of

<?php
$previous = arg(2) - 1;
$next = arg(2) + 1;
?>
<a href="/events/<?php print $previous . '/' . arg(3)?>/">Previous
<a href="/events/<?php print $next . '/' . arg(3)?>/">Next

I would clean up that code and use the l() function to create a link, but that is the general concept.


Add the phone number as an argument to numberSubmit_form and include it in your form array:

$unvalRows[] = array(
    array('data' => '0'.substr($a[0], 2)),
    array('data' => drupal_render(drupal_get_form('numberSubmit_form', $phone_number))),
);

Then in the form constructor:

function numberSubmit_form ($form, &$from_submit, $phone_number){
    $form['phone_number'] = array(
        '#type' => 'hidden',
        '#value' => $phone_number,
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
    );
    return $form;
}

It will then be available to you in the submit handler:

function numberSubmit_form_submit(&$form, &$form_state) {
    // do something with $form_state['values']['phone_number']
}


Crumbs provides a "Breadcrumb (Crumbs)" block that you should be able to use.


Organic Groups module  messes up node editing

Just figured out that the problem was not caused by the references module, but by the "Organic Groups" (og) module. It seems to be a known bug in the organic groups module that basically hides/disables all fields for custom content types that are not marked as group or something like that. There's a report about this in http://drupal.org/node/1029230.

Disabling the organic module make the fields come back again, and even relationships seems to be editable again. I can live without organic groups for now, and considering the severity of the bug I will definitively not try to use that module again until it has been fixed.


Intermittent "Cron already running error"

You have a long running, stalled or erroneous cron hook.

To determine where the error is, try the module

cron_debug

or the temporary core patch listed here:

https://drupal.org/node/1143706


Drupal 7 default core search functionality

display suite offers counts and highlighting,
plus you can edit the search-result-display via UI.
to get the contenttype there, you'll need to add a custom field,
or install search api and use views.


How to limit the quantity of a product to 1?

For me, simply skipping to checkout does not address my desired workflow. I still want users to be able to shop around and use a cart.

But some of my products are subscriptions, for which it doesn't make any sense to have multiple. For this purpose, I'm using https://www.drupal.org/project/commerce_xquantity module.


views_get_view became Views::getView, and several others are now static methods on the Views class in the views module.

I don't think views_include is necessary anymore.


Reject e-mail address from specific domain in simplenews newsletters e-mails

How are users registering their email addresses? For example, we use simplemail on http://goniseko.com in the footer. It's a signup block that anyone can use.

Is this where your spammers are signing up from?

In my opinion, this is super easy to fix, if you aren't afraid of creating a quick and dirty module that uses hook_form_alter.

In the module you would simply create a validation rule that if the form value submitted contained 'baddomainame.com' it would prevent the form from sending.

function mymodule_hook_form_alter(&$form, &$form_state, $form_id){
    if($form_id == 'my_simple_news_form_id'){
        $form[#validate][] = 'check_domain_callback_validate';
    }
}

function check_domain_callback_validate(&$form, &$form_state){
    if(&$form_state['values']['simple-news-email-value'] == 'baddomainame.com'){
        form_set_error('', 'BAD DOMAINNAME, BAD! YOU NO SIGN UP');
    }
}

of course all of that is pseudo code, but the structure should get you started.  Here is a link to the forms API tutorial that will help if you are not very familiar with FAPI.

http://drupal.org/node/262422


How to do a date range entityQuery with a Date only field in Drupal 8?

I'm doing lots of conditions like that in entity queries, I haven't encountered a problem yet.

The main thing you have to be aware of is the timezone the data is stored, which is UTC. You need to convert it to the storage timezone (there's a constant for that), or your query will be off by a few hours.

Here's an example based on something I'm doing, if you only store days, then there is a constant for formatting that too.

$date = new DrupalDateTime('21 days ago');
$date->setTimezone(new \DateTimezone(DATETIME_STORAGE_TIMEZONE));
$formatted = $date->format(DATETIME_DATETIME_STORAGE_FORMAT);

$nids = \Drupal::entityQuery('node')
  ->condition('your_date_field.value', $formatted, '<=')
  ->range(0, 50)
  ->execute();


It is impossible to tell you exactly what is wrong with the information that is given.  I run several multi-sites using separate databases, and they work as advertised when I set them up following the standard instructions.

The White Screen of Death is usually caused by some error in the PHP.  To see the error message, you need to turn on PHP error reporting.  To do this, add the following to the settings.php, just below the initial <?php:

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

This will usually show an error message that tells you where you've left out a semicolon or some other trivial PHP-error.

See also: https://drupal.org/node/1056468 and https://drupal.org/node/158043


Page manager selection rules for a variant for the front page

If fron page point to "node" (in Site information administering page), just change it to show some selected node (blank node for example), then edit this node in panels as you want, if you want list nodes, enable there views...


Some MyISAM tables not converted to InnoDB during 6 to 7 upgrade

It does make sense to convert all tables to InnoDB. The core 6 -> 7 update does not change the engine type; so the reason they weren't converted is that it was not programed to do so.

Use READ COMMITTED for MySQL transactions https://drupal.org/node/1650930#comment-8437127
Use 7.25 Core or higher https://drupal.org/node/937284

By doing both of these you will significantly reduce the number of deadlocks that occur on your database.

Using a non database cache backend like memcache is a good idea, as explained in this presentation: http://www.percona.com/resources/mysql-webinars/drupal-and-mysql-performance


You can configure which fields are displayed in the view mode compact:

admin/config/people/accounts/display/compact

Then you can in twig display all fields with

{{ content }}

or single fields with

{{ content.field_example }}

To put a user in a page template you can use Twig Tweak:

{{ drupal_entity('user', 1, 'compact')

The third parameter is the view mode and you can use theme hook suggestions to catch this with your custom user twig to make adjustments of the user fields.


What about doing it the other way around? Use a date field and triggering the rule according to it?


Will a Fields form with many submissions make an overload of nodes?

Generally, the bigger the database the potentially slower it can get. If you get 200 nodes submitted every day that's 73,000 nodes a year. A lot of news sites or forums or w/e that run on Drupal easily surpass numbers like that.

You can use the Form API to capture content in a custom table of your creation, there's absolutely nothing wrong with that. If you need everything that comes along with nodes, fields, contrib modules that plug into nodes, etc., than you may want to just use nodes. Then there's the ability in D7 to just create a custom fieldable entity (not a node but "like" a node in that it's a piece of content that Views and other things can hook into) and save overhead by keeping things lean.


How to add a new condition to access callback function in hook_menu_alter?

You can call default access callback function in your custom access callback and if default access callback return TRUE, then you can check your own conditions and return TRUE/FALSE. Check example below:

function mymodule_custom_callback() {
  // If node access return TRUE.
  if (_node_add_access()) {
    // Do your processing here.
    if (condition) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
  return FALSE;
}

  And is it possibly to do it not knowing the name of default access
  callback function ? For example, default access callback function for
  path node/add is _node_add_access().

In such cases, you can either find it by debugging (print $items['node/add']; exit;) or you can append that as an access argument and call it from your custom callback. Something like below:

function mymodule_menu_alter(&$items){
  $items['node/add']['access arguments'][] = $items['node/add']['access callback'];
  $items['node/add']['access callback'] = 'mymodule_custom_callback';
}

function mymodule_custom_callback($function) {
  // If node access return TRUE.
  if (function_exists($function) && $function()) {
    // Do your processing here.
    if (condition) {
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
  return FALSE;
}


Bulk upload via Form API, or, Please Warn Me

I don't think there is any particular difficulties in bulk creation of a nodes from a set of uploaded files. What would be difficult and probably explain why there is not such feature implemented in Drupal 7 is that it would be difficult to make it generic and re-usable. Mapping files to node is not a straightforward process. Variability is probably to high to allow a meaningful re-usable implementation.

If you plan to do write custom code, don't start with Webform. Webform is great for forms that are content to be edited by end users of the site/CMS. They are not designed to be a developer tool to create complex forms with custom backend behaviors. Using Webform will force you to deal with two form APIs in code. While one of them is designed to serve UI users, not developer.

You, or your user, would probably love to have a single widget to upload multiples files (as opposed to multiple file form element). But I suggest you first get a working solution that rely on the Form API and the available file widget. Drupal's API are build to work with standard and old-style browser to server interactions. Introducing new interactions model early into the mix will likely make thing unnecessary difficult by forcing you to learn and understand Drupal's API and inner working only to find workaround for its limitations. Once you get a working solution, search solutions to build a better UI/UX using progressive browser side enhancement. OR at least, refactoring a working solution build on sane and understood bases.

Since processing multiple files and creating multiple nodes is likely a long running operation, you should use the Batch operations API.


Take the $form = array(); line out of the foreach loop. This is clearing the $form array every time it loops around. You don't want it to do that.

foreach ($line_items as $line_item_id => $line_item) {

   $option_first = array(1 => '1', 2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9');

   $form['line_items'][$line_item_id]['quantity'] = array(
     '#title' => 'Qty',
     '#type' => 'select',
     '#options' => $option_first,
     '#default_value' =>  $line_item->quantity,
   );
}

Also, if $order_id is a argument, you should not need to call arg(1). Consider passing the commerce order object as an argument instead, using %commerce_order as a URL parameter. Drupal will load it and pass it for you (if this function is a menu item callback).


Android submission: I get a "CSRF validation failed" error while using a cookie

CSRF token error comes when user is allready login to drupal site just logout then send the request you wont give this error again..hope this will help.


the --destination flag surely works to say where. I'm not quite sure if the outcome would be a mix of the former and the latter system though. Probably the writing does not delete the old files. It would be safer to delete them manually prior to archive recover.


There are two different "block things". Actually, three.

First, there are block plugins. That's code, that's what you have. It's the thing you select on the block layout page. It's not something that you can list with views (Well, theoretically, it would be possible, but you would have to write a views query plugin that queries plugins.)
Then, there block config entities. That's a plugin + configuration, a block placement.
Last, there are custom blocks or content blocks. Those are content entities, similar to nodes with different types, fields and so on. Those are the user-created data. Each of them is exposed on the block layout page as a plugin derivate. There's one plugin class for them and then there are derivates for each content entity. Those are the things you can list with views. Only those.

Everything is connected, you can create custom/content blocks, which are exposes as a block plugin, which is then placed and becomes a block config entity. But they're all different things.


How are user.tokens.inc and other similar files included?

They do it by way of hook_hook_info():

Defines one or more hooks that are exposed by a module.
Normally hooks do not need to be explicitly defined. However, by declaring a hook explicitly, a module may define a "group" for it. Modules that implement a hook may then place their implementation in either $module.module or in $module.$group.inc. If the hook is located in $module.$group.inc, then that file will be automatically loaded when needed. In general, hooks that are rarely invoked and/or are very large should be placed in a separate include file, while hooks that are very short or very frequently called should be left in the main module file so that they are always available.

As luck would have it, the example from the docs shows exactly how the Token module does it:
function hook_hook_info() {
  $hooks['token_info'] = array(
    'group' => 'tokens',
  );
  $hooks['tokens'] = array(
    'group' => 'tokens',
  );
  return $hooks;
}

Should I be doing the same with my own module?

Totally up to you - it certainly can't hurt, other modules that need to implement your hook will just have an extra option for storing the hooks. But if you don't, they can still implement your hooks in the .module file anyway.


How can I redirect the users after confirmation basing on the roles they have?

yes, with Rules!

create a new rule.
select event: user has logged in (or if you use LoginTobogan module you can use the event "When the user account is validated".)
select condition: User has role(s), and assign the role (I recommend create a new Role and assign this role to a test user)
selet the action: Page redirect, and add the url to the destination
(I have selected 'Immediately issue the page redirect' to see the redirection (if is not select this, I can not see working the redirection, but test if you does not need this. Please review the warning about the setting)
enable your rule and test.


Using CDN for jQuery and jQuery-ui with Drupal 6

Those files look to be available https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js

update

As to why it didn't work:

Jquery that ships with drupal 6 is 1.2.3
The Jquery update module can push this to 1.3.2

You are trying to use a much more recent version of jquery than Drupal 6 can handle. Drupal uses a lot of jQuery in it's workings, so it is not straightforward to put a new version on top. Sorry I didn't spot that earlier.


Proper way of Link generation from string

You do not need internal:/ you just need to have some help text that says an internal path should begin with a slash.

After that, when you create the links, you can do:

use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Component\Utility\UrlHelper;

....
....
....

function or method.... {
  $path = // get config value
  $label = // get config value

  if (UrlHelper::isExternal($path)) {
    $url = Url::fromUri($path);
  } else {
    $url = Url::fromUserInput($path);
  }

  return Link::fromTextAndUrl($label, $url);
}

Of course I am assuming there is always a value... you'd have to add your own checks so you don't get errors calling Url:: for null or empty input, etc.

The return will be an renderable array to use. I am using a similar method to allow input for third party settings on a config entity. This way the value can be internal or external.


The htaccess file was overriding everything. I installed https://www.drupal.org/project/htaccess and added "Header always unset X-Frame-Options"

That fixed it.


The Date module will store date time in this format: "2012-05-25 hh:mm:ss" . Using PHP's date_parse function you can extract all those values. What easier thing do you need?


Mark only Event's start date on calendar?

Try setting the end date the same as the start date


Override node template depending on menu settings

I believe it is possible to achieve this in hook_preprocess_node by calling menu_get_item, checking whether it is the item you are looking for (checking the parent etc.) and then assigning the appropriate template like this: $vars['template_file'] = 'your_template_file';


How to make the subscriptions module produce notifications on a screen?

Same thing I wanted to do for some kind of notification.
Finally, this was the implementation:

Added one function which returns the count and notification with HTML.
Then added Ajax request to fetch the result and place it on the notification element which is already placed in page.tpl.php
Added JS code to custom.js which works on every page of site.
See below:

But remember don't make it heavy ajax request, it may slow down your site. And remember to add JS code at bottom of page.
Also you can do one thing, put ajax request on click of the element, look what StackExchage do:

on click of notification they send request and fetch the data...


Sharing Global Menu Links Menu to subsites

So I think I've gone a long way to achieving this.

In the setting.php file of each site I declare a Data Connection called globalmenu that point's to the database belong to the menu's management site.

I make the menu and get the machine name for it; in my case menu-global-menu.

In my page.tpl.php of my theme I have included this

  <?php
  if ($global_menu){
  print($global_menu);
  }
  ?>

My module

function global_header_preprocess_page(&$variables, $hook) {

 $query_options['target'] = 'globalmenu';

 $query = db_select('menu_links', 'p', $query_options)
    ->fields('p')
    ->condition('menu_name', 'menu-global-menu', '=')
    ->execute();

 if($query->rowCount() ==   0) {
    print '
No Global Header Configured!

Check the Global Header Module Help for details

';
}

 $links = array();
 $markup = "

";

 foreach ($query as $item) {
    $markup = $markup ."
link_path."' class='global-link'>".$item->link_title."
";
 }

 $markup = $markup ."

";
 $variables['global_menu'] = $markup;
}

There's probably a much better way of doing the markup but I'm a noob so I guess someone will correct me.


Redirect after a new node is added but not edited

function mymodule_form_alter(&$form, $form_state, $form_id) {
    $form['actions']['submit']['#submit'][] = 'custom_node_submit';
}

function custom_node_submit($form, &$form_state) {
    if (arg(2) != "edit") {
      $form_state['redirect'] = 'request-sent';
    }
}


Unable to create a view of type solr search

Steps:

Install the modules that you have mentioned
Install and configure Apache Solr in your server
Configure Apache Solr server in the apachesolr module settings
Add a view. Select Apache Solr localhost server (or the name that you have given to your Apache Solr server configuration in apachesolr settings) in the Show dropdown menu when creating the view.

Steps for installing and configuring Solr:

Download the .zip file from http://lucene.apache.org/solr/ (you might want to try with version 3, although it has worked for me with 4
Unzip in a folder in your machine
Copy all the contents from sites/all/modules/apachesolr/solr-config/solr-3.x/ to apache-solr/example/solr/conf/ in the folder you created in step 2
Start the server with running java -jar start.jar

Check in the admin section of your Drupal site if the server is found and working.


How to migrate from test environment to production environment?

This is a non-trivial problem that almost everyone has a different answer for: there isn't a canonical Drupal way to handle staging to production pushes. Dries Buytaert, the guy who runs the Drupal show, made it one of the key initiatives of Drupal 8. Of course, Drupal 7 was just released, so it'll be a while before that bears any fruit.

The problem can be broken out into two separate issues:

Staging configuration (variables, content types, fields, views, etc.)
Staging content (nodes, users, etc.)

The former can be mostly handled by the Features module, which will take your site configuration and turn it into a module you can add to your Drupal installation: this way, you can add it to your version control system and not having to worry about it being blown away when you migrate your content.

The latter is really tricky, because on an active site, it's likely the content will change on production even after you've made the initial sync to your development environment. This prevents wholesale replacement of content during staging like you can do with configuration.

Additionally, Drupal doesn't use universally unique identifiers (UUIDs) for content: every time a node or a user is added, the ID increases by one. So what might be node 45 on your development site might be node 90 on your production site.

Unfortunately, I don't have a great solution for this: staging content is a real weakness of Drupal. What I personally do is add content on the production site only. If a client wants to see how the content looks prior to it going live, I'll set up a clone of the production site that's only accessible to the client. Then, once approved, the same changes are then made directly to production.

There's another alternative that gets tossed around: the Deploy module. It's supposed to leverage Services to make staging content relatively painless. But I can't vouch for its effectiveness and it doesn't have a Drupal 7 version.