I would suggest that you clone the view and amend it to display only the filter criteria that you require.  You can then display the cloned view in a block and the original in a page, or wherever you require it to be.


How to solve “This version is not compatible with Drupal 7.x and should be replaced” error?

Your custom theme is surely not a part of Core package,  so remove that line first. Second, you mentioned that the theme is built based on Stark but you didn't define it in the info file, so add this line :

base theme = stark

Third, usage of version is discouraged in Drupal 7, so delete this line as well.


Is it possible to use stringoverride on ONLY one page?

I'm betting you're looking for hook_form_alter() ... I'm pretty sure its just a form buttom on the page and you can change its #valueproperty as-needed with that hook. Its up to you to figure out how to target just that form, on just that page ... I don't think you need stringoverride for this.

You would want to test this out of course :)


Mini pager work with ajax but not full pager?

This sounds like a theme issue, try switching to Bartik and seeing if the issue is resolved. For example Omega provides its own theme() function for full and mini pagers.

The class pager is required on the UL element for pager AJAX to work properly. Review your theme and make sure it is properly theming the full pager, or open an issue on the Drupal.org project page.


How to add country phone number prefix in webform?

Webform allows you to load options in bulk. Just google for this list and load it into a spreadsheet. Use a bit of find/replace to get it into the format needed by a webform select element, which is:

65|Singapore (65)
44|United Kingdom (44)
58|Venezuela (58)

Then create a webform select field and paste it in.

To get the fields to line up side-by-side (with country code right before phone number and not on a separate line) use the webform_layout module.


AJAX Views with filter as path component

There are many ways to solve this, you can take different approaches to the filtering part, the URL part, and the contextual part, and how they play together to get you to your goal. Here's one of the possibilities, probably the easiest route:

This is solved by adding a Relationship for the category field, and then adding a Term "Name" Contextual filter (it will automatically use that Relationship). Be mindful how you configure the spaces/dashes options. This will give you the term name in the URL instead of the term ID.
To get the Exposed filter to match the Contextual you need to use the Views Filter Harmonizer module. There's no workable D8 version yet, you can try and help there, there is an issue open for it.
If you've set up the Exposed filter properly, and turned Ajax on, it should work without a page reload. The "harmonizer" module also claims to play well with that.
I might be missing something here, I wouldn't expect that the Addressbar updating without a page reload is easy, but again the "harnomizer" module claims to do just that, so it seems you're covered if you can get that module to D8.

Another module that might be relevant in another approach: (also no D8 yet) Query Parameters To URL , but similar outcome can be done through your server configuration.


Update form attributes with javascript and get them on submit

As Clive said in the comment, you can't fix it. To do such things in the background of a form, use a hidden element:

https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#hidden


Popup with the content of the exposed date field

How about writing a custom jquery code with the help of http://docs.jquery.com/UI/Datepicker. I am not sure whether you are proficient with jquery , but still i would prefer to have a go at this.


Apache Solr integration on shared hosting with cpanel

No, in this case, you cannot do put Apache Solr on your server.  I just had a client who had the same problem. You have 2 options:

Setup a second server that has shell access, and will index you site for you
Use someone else's preconfigured Apache Solr already, such as Acquia Search (not free)


"No Drupal site found" -- Windows and SQL Server

You should perform the following checks:

For SQL Server, review README file of SQL Server driver for Drupal 7 to confirm the right requirements and installation steps. See also: Can I use MS SQL with Drupal.
Make sure that your database client (such as sqlcmd) command exists globally (from the command-line). Otherwise make sure its path is added into your PATH system variable. See: Sqlsqlsrv.php.
Clear Drush internal caches and try again:

drush cc drush

If you're using a multisite environment, make sure to specify the right Drupal site to use, e.g.

drush --uri=http://site1.example.com status

or:

drush -l http://site2.example.com status

Note: By default Drush uses sites/default unless you will run the command in specific sites/ folder.

Note: To define URI of the Drupal site, set $base_url in your settings file per given site (or drushrc.php).
Run drush status (add -d for debugging output) to check whether Drupal root, Database name and Database driver has been detected correctly. If not, run the command again, but in the same folder where is your settings.php file and verify that Drupal Settings File has been recognized. Verify it has the right read permissions
Check the output of drush sql-connect command whether it returns the right command and there are no errors.

If there is no matching SQL Class, this suggests drush can't detect the db driver from your settings file. So confirm the following command returns the current site path (folder containing settings.php):

drush ev "echo drush_site_path();"

If it's empty, make sure you're running drush command in the right folder and your settings.php exists.
Check whether Drupal bootstrap object is properly loaded by:

drush ev "print_r(drush_get_bootstrap_object());"

If so, check whether your settings file is readable:

drush ev 'echo file_get_contents(drush_get_bootstrap_object()->conf_path()."/settings.php");

Otherwise if your bootstrap object is EmptyBoot, please review how Drush defines Drupal root as valid (candidates are: DrupalBoot6, DrupalBoot7, DrupalBoot8), for Drupal 7 the logic is as below:

function valid_root($path) {
  if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
    // Drupal 7 root.
    // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
    $candidate = 'includes/common.inc';
    if (file_exists($path . '/' . $candidate) && file_exists($path . '/misc/drupal.js') && file_exists($path . '/modules/field/field.module')) {
      return $candidate;
    }
  }
}

So make sure that you've the following files present: includes/common.inc, misc/drupal.js and modules/field/field.module in your Drupal root (where $path is your Drupal root, but it can be specified manually by --root=path/to/drupal). Also make sure the files are readable by the user (in case of symlinks, they're pointing to the right files; right permissions in case of network share or Linux file system). Otherwise edit Drupal boot class file (e.g. DrupalBoot7.php, part of Drush) and try to debug the above valid_root() method by checking which condition exactly fails and why.

Example Drush command to verify whether index.php exists:

drush ev '$path = drush_get_context("DRUSH_SELECTED_DRUPAL_ROOT"); var_dump(file_exists($path . "/index.php"));'

Finally check whether SQL class can be loaded by:

drush ev 'var_dump(drush_sql_get_class());'

You may consider re-testing in different PHP versions, e.g.

Debugging

Assuming drush status doesn't return the right details, here are the suggested steps to debug drush (shell commands).

Install and enable PHP xdebug extension. Verify by php71 -i | grep xdebug.

Consider these xdebug ini settings: xdebug.ini for better visibility.
On empty folder, install clean Drupal, e.g.

drush -y qd --no-server --core=drupal-8
cd quick-drupal-*/drupal*

Verify Drupal root, Settings File and Database are present in drush status.
Generate trace file for the working bootstrap process:

drush ev "xdebug_start_trace(); print_r(_core_site_status_table()); echo xdebug_get_tracefile_name(); xdebug_stop_trace();"

If xdebug is enabled for different PHP version, specify with DRUSH_PHP=/path/to/php.

If successful, trace output file should be printed at the end, so take a note of it.
Generate another trace file for the same command above, but in the location which doesn't work.
Now compare these two trace files (working with non-working) using some diff tool (Meld, DiffMerge, opendiff, etc.) and check the differences. For better format, remove first 40 columns from these files (e.g. ex +'%norm 40dl' -scwq file.xt).

If you believe you found a Drush bug, please report it with details at GitHub issue page.


I think that you will find the answer here:

Responsive column resets

  With the four tiers of grids available you're bound to run into issues
  where, at certain breakpoints, your columns don't clear quite right as
  one is taller than the other. To fix that, use a combination of a
  .clearfix and our responsive utility classes.

If it is too difficult to add above mentioned classed divs in the layout (can be done via templating Views) you should add your own styling wherein you use the n-th group of CSS selectors to clear at the different media queries.

The problem arises from the fact that your views rows do not have equal height and therefore do not flow as you want it to.

Also look at this post Bootstrap 3.0:responsive column resets section of the documentation

And for a module to assist you can try this: gido's sandbox: Views Bootstrap Responsive Grid

  Views Bootstrap Responsive Grid module enable you to take advantage of
  the Bootstrap 3 Grid System columns reset. With this module you can
  define the number of items per row for each breakpoints. All of this
  within the great configuration settings of the View module.


How can I keep the files uploaded by filefield module even though users delete them on node edit form?

I used a module called Filefield Sources together with IMCE. And on the file field's configuration page, I enabled the "IMCE Browser" option for additional sources.

I did a few tests and any files attached to a node using the "IMCE Browser" method doesn't get deleted when the file is removed from a node on node edit screen. But files added through the normal "Upload" method do get deleted, so I think you should upload files using the IMCE Browser too as it has a file uploader as well.

I'm not sure how to remove or hide the actual default "Upload" method on the file field though.


How do you return an entity property of 'type' => 'struct'

Based on entity_metadata_node_entity_property_info_alter() and entity_property_text_formatted_info(), I suppose the getter callback should be the most generic callback the entity API offers: entity_property_verbatim_get.

This should allow you to access the properties as: $custom_entity->structure_property->sub_field1


You can find the database information in your settings.php file.

A simple export of that database should allow you to capture the site as it exists currently, then when you get the server reconfigured you can simply import the exported database.


Creating custom panel page gives page not found error

The most common and likely reason is that you have not assigned a context to your %term argument. This causes Page manager to reject the term argument, failing to find the path, and finally returning a 404. There's a similar issue here.

I could tell more specifically if you provided an export of the Panel.


MariaDB is a drop-in replacement for MySQL. No changes are required.

You'll obviously need to update your connection/credential details to match the new server, but as far as configuring Drupal to use MariaDB, there's nothing to do.


Edit Unit Price line item After Adding product to the cart

this rule update unit price Unit Price of all Commerce Line Items to $200 when "Add a Product to Cart" Event is fired.

{ "rules_set_unit_price" : {
"LABEL" : "Set Unit Price",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_cart" ],
"ON" : { "commerce_cart_product_add" : [] },
"DO" : [
  { "data_set" : {
      "data" : [ "commerce-line-item:commerce-unit-price" ],
      "value" : { "value" : { "amount" : 20000, "currency_code" : "USD" } }
    }
   }
  ]
 }
}


Use another field value as condition in Entity Query

The entity query is a powerful and convenient tool to query for content and config entities that have certain properties/field values/field references.

Yet, it has its limitations. Comparing two fields is not possible using the generic entity query and its condition method.

For such a task, you may need to use the more low level dynamic (select) queries and its where method. An example for your use case:

$connection = \Drupal::database();
// Query node base field table.
$query = $connection->select('node_field_data', 'n');
// Join with the `field_days` field table.
$query->leftjoin('node__field_days', 'd', 'd.entity_id = n.nid');
// Query for the node ID.
$query->fields('n', ['nid']);
// Your condition (a day has 86400 seconds; we multiply them with
// the value of the field_days field, add them to the changed
// timestamp of the node and compare it against the current time).
$query->where('n.changed + (d.field_days_value * 86400) <= :now', [
  ':now' => \Drupal::time()->getCurrentTime(),
]);
// Optional sorting.
$query->orderBy('n.changed', 'DESC');
// Fetch results.
$result = $query->execute()->fetchAllKeyed(0, 0);

Above example assumes:

that you used a numeric field type for field_days, so its database stored value can be multiplied with seconds without any casting,
that the field_days field allows one value only, so we can safely ignore field deltas when joining,
that field_days is present on all nodes/bundles and has a valid value,
that you use one language only in your site/the field_days value is not translatable, so we can also ignore langcodes.

You may have to alter the query accordingly, if any of these assumptions is not true.


How to import the webform without changing the node id ?

There are no module allow you to do it, but if you want to transfer webform I suggest you to use Webform share module.

Also, if you just want to determinate webform by any unique id, you should use UUID module.


YouTube thumbnails - options for adjusting interface widgets and behaviour when clicked?

I recommend the Video Embed Field module, it's pretty new but under active development. It will just show the thumbnail and when you click it load the video player page.

However, they are working on a lightbox integration (video plays in a popup modal) and you might want to suggest the "Facebook player functionality" as a new feature to them.


Token replacement pattern is not working

I dont know what the reason was, but Its working fine, when i disabled the auto_nodetitle and enabled a new module "auto_entitylabel".


It depends from what exactly the code needs to achieve.
hook_form_alter() and hook_form_FORM_ID_alter() are still used from Drupal 9, and they can be used to hook into account registration before users can enter values for the account to create. They should not be used to add an entity field, or add a validation handler for an entity, for which hook_entity_base_field_info() and hook_entity_bundle_field_info() (to add entity fields to an entity) or hook_entity_type_alter() (to add constrains to validate an entity) are preferable.
If you are instead looking for the Drupal 9 equivalent of Drupal 7 hook_user_insert(), hook_user_update(), and hook_user_presave(), which are invoked after the users entered the account data (and they should not be used to invalidate the entered data), they are still used, but they are documented under hook_ENTITY_TYPE_insert(), hook_ENTITY_TYPE_update(), and hook_ENTITY_TYPE_presave(). When you implement those hooks, you replace ENTITY_TYPE with user, for the User entity. This means that the name of the function implementing those hooks for the User entity doesn't change respect of the function name used in Drupal 7; it's just a matter of documentation.
Note also that the generic hooks, invoked for every entity implemented in Drupal, for example hook_entity_insert() are still used in Drupal 9. (See hook_entity_insert().) The documentation page for that hook for Drupal 9 contains a reference to the equivalent hook invoked for a single entity type (See also hook_ENTITY_TYPE_insert(), written on two lines).
Further reading

Drupal Entity Validation API: Create Custom Entity Constraints
Documentation for entity hooks has been consolidated


How can I replace the "Add to cart" button with an "Ask about product" button, based on product property?

I figured out answer, and it's not that bad as I though. I decided to write a tutorial for it as it looks like very useful feature. So here it is:

Tutorial

Install everything, I mean, Commerce and Webforms,
Create example webform - let's name it "Contact",
Create Product Display, create some product with few attributes, and one boolean field (not attribute) "Contact required",
Configure webform, specifically, create there a field that will have default value, fetched from GET query string (how to do this: http://drupal.org/node/296453#webform-url-default ), we will pass to our Contact form a SKU of our product by using GET method.

Now create your own module, I will not elaborate on that, as there is a lot of info out there. The hooks that we will need are:

  HOOK_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state)

  HOOK_commerce_cart_attributes_refresh_alter(&$commands, $form, $form_state)

The first one will allow us to manipulate our form initially (if default product will have "Contact required = true"), the latter will allow us to adjust our form to AJAX calls.

Yes, that means that, our "Add to cart" button will be dynamically changing based on current product "Contact required" field. Looks promising doesn't it? :)

We will also use two helper functions that are not hooks:

  MODULE_ask_for_product($product)

  MODULE_contact_required_validate($form, &$form_state)

The first one will return HTML of our new button "Ask for product" (I encapsulated it in function, because we will need that data in both above hooks),
and the second one will validate our form, so if "Contact require" field on product, will be set to 1, the form will not validate, and product will not be added to cart. The submit button for regular user will be removed, but this is only against smart guys that would like to annoy you by sending this form even if you hide submit button.

Those are the functions:

    function HOOK_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state) {
    // Adding new class to our button, that will allow us, to target it by jQuery
    $form['submit']['#attributes']['class'][] = 'add-to-cart-button';
    // Adding new validator, that will make sure that our products with required contact, will not be added to cart
    $form['#validate'][] = 'MODULE_is_contact_required_validate';

    // Getting value of field_is_contact_required of default product
    $product = $form_state['default_product'];
    $field = field_get_items('commerce_product', $product, 'field_is_contact_required');

    // If value is 1, then replace our button with markup.
    if($field[0]['value'] == 1) {
        unset($form['submit']);
        $form['ask_for_product'] = array(
            '#markup' => MODULE_ask_for_product($product),
            '#weight' => 50,
        );
    }
    }

Now we need to do something with AJAX:

    function HOOK_commerce_cart_attributes_refresh_alter(&$commands, $form, $form_state) {

    if (!empty($form_state['context'])) {
        // Getting value of field_is_contact_required of new chosen product
        $product = $form_state['default_product'];
        $field = field_get_items('commerce_product', $product, 'field_is_contact_required');

        // If field_is_contact_required is set to 1, then replace a container that have class ".add-to-cart-button" (we just added that class), with our markup
        if($field[0]['value'] == 1) {
            $replacement = '.add-to-cart-button';
            $commands[] = ajax_command_replace($replacement, MODULE_ask_for_product($product));
        }

    }

    }

And our helpers:

// Return markup of our new button. 'node/7' is node of our contact form, 'subject' is a key of our query string
function MODULE_ask_for_product($product) {
    return '
' . l(t('Ask about product.'), drupal_get_path_alias('node/7'), array('query' => array('subject' => 'Ask about product with SKU: ' . $product->sku))) . '
';
}

// Prevent some products from be added to cart.
function MODULE_contact_required_validate($form, &$form_state) {

    $product = $form_state['default_product'];
    $field = field_get_items('commerce_product', $product, 'field_is_contact_required');

    if($field[0]['value'] == 1) {
        form_set_error('', t('Don\'t try to be annoying! :P'));
    }

}

That's all, you can customize it, or by extending the idea, do much more with it (maybe by using webform api).


Inserting Fields from A Custom Content Type into Custom Form

There isn't an API for attaching a single field from an entity to a form, there is one to attach all fields. field_attach_form. I wouldn't suggest you doing that do, since it can quickly become unmaintainable.

Instead I would suggest that you simply get the field options, or allowed values as they are called. That is pretty simple as well.

$info = field_info_field('field_machine_name');
$options = $info['settings']['allowed_values'];


If you add the "NID" field to your view's fields, (as the first entry, for reasons I won't get in to here),  you can then use the "rewrite output" function to attach a unique CSS ID using the NID to your image.


Drupal 8 & Solr 8.1: No search results, error: "The datasource with ID '' could not be retrieved for index..."

Possible problem: "Search API Solr" module 8.x-2.7 does not support Solr 8.

Solution:

Remove "Search API Solr" module 8.x-2.7 using 'composer remove drupal/search_api_solr'
Install "Search API Solr" module 8.x-3.1 using 'composer require drupal/search_api_solr'
Find Solr modules in Drupal BO ("Extend" > "List") and click "Install" button
Add Solr Server in Drupal BO. I used solr path "/".
Download the configs zip folder from Drupal BO, copy files from the folder to the conf directory of the Solr core. (See details in INSTALL.md file in the module directory).
Restart solr server.
In Drupal BO in my Index configs select the name of my Solr server.
Go to the Index in Drupal BO. Click to run the index of content.
Go to my previously confiured view. See search results and search!


Best way to translate parts of an existing site and retain page aliases

I have found the solution and it's quite easy actually. Here are the steps necessary:

Go to languages settings: admin/config/regional/language
Edit the default language (the one that shouldn't have language prefix).
Remove the code from "Path prefix language code" field.
Go to detection options (admin/config/regional/language/configure) and select "URL" method.

That's it, it should work as I have described in the question.


How to pre-populate paragraphs when creating a page

Actually I found a solution using a module. It was not the first time to find the solution after asking it here so it was not in vain - even if I found it myself...

To help possible otrhers, here is my solution from my module's .module file

function acme_pre_populate_node_create(\Drupal\node\NodeInterface $node) {
  $i=0;
  if ($node->getType() == 'acme_basic_page') {
    $paragraph = \Drupal::entityTypeManager()->getStorage('paragraph')->create([
        'title' => 'Paragraph ' . $i,
        'type' => 'hero_image',
      ]);
      $node->field_paragraph_list[] = $paragraph;
      $i++;
      $paragraph = \Drupal::entityTypeManager()->getStorage('paragraph')->create([
          'title' => 'Paragraph ' . $i,
          'type' => 'one_column_text',
          'field_one_column_text' => "
Change title here

And contents here
",
    ]);
        $node->field_paragraph_list[] = $paragraph;
       $i++;
  }
}


How to change drupal commerce views like checkout,payment?

Have you learned Views?
you can try change default views shoppingcart,checkout page,billing page,review page etc.
Eg: to modify shopping cart block you can go to
http://your.site/admin/structure/views/view/commerce_cart_block/edit


How do I enable language without importing translations?

drush cset locale.settings translation.import_enabled 0

Or any other method of disabling that flag should do the trick.


If you have access to ssh, use drush to disable and uninstall the module. If you do not have access, disable your module, set the status to 0 for the module name that you want to disable.

UPDATE system SET status='0' WHERE name='module_name';

And then you can manually delete the table "history_rec_user_map".

It however has two variables ('history_rec_uid_watermark' and 'history_rec_last_aid') in the variables table. Use variable_del to delete them

To remove modules, you have to remove them from your server's modules directory (usually sites/all/modules/).

UPDATE:

To delete the modules blocks use delete from block where module = 'MODULE'


Importing Published status from xml using Xpath parser

I suggest installing feeds tamper (https://www.drupal.org/project/feeds_tamper) with this module you can easily convert the yes to a 1 and no to a 0 before saving to the database. This should solve your issue.


A quick look through the imagecache module suggests that the only time the module itself enforces the "view imagecache [preset]" permission is when it is serving private files.  This makes sense in that once the image derivative is created in the public files structure, it is never called; once a file "really exists" drupal is never bootstrapped up, it is only booted up to create the derivative the first time it's not found.

So, then, what are these permissions useful for?  Well I'd imagine so you could do something like this...

$presets=array('small', 'medium', 'large');

foreach($presets as $preset) {
  if (user_access('view imagecache ' . $preset)) {
    // do whatever your module wants with that preset, create a link, show the image, whatever
  }
}

...in your own module.

As for lightbox2, a quick look there shows it just presents a list of possible Display Field options using all of the imagecache presets.  As to why it doesn't check these permissions when building these links is a question for that module's maintainer on its issue queue on drupal.org.


How to attach files to node instead of uploading?

Try the Attachment Links module

The Attachment Links module provides permanent links to files attached to a node. A single, easy-to-remember URL can be used to retrieve the preferred (canonical) or newest version of a file regardless of how many versions of that file have been attached to a node.
Typically, users will want to create a "File" content type and enable the Attachment Links module for that content type. Each "File" node should refer to a single file: "Handbook," "Company logo," "Team roster," etc. Though each node could contain multiple versions of the file, Attachment Link provides permanent link to access the preferred or newest versions.

It seems you can also use the IMCE for FileField module to get the uploaded files from other content type. check this answer  posted by me.


Selecting nodes by content type and value of a custom field

In Views, you could do this:

Create a view, filter on node TYPE and node PUBLISHED
Create an argument/contextual filter using your CUSTOM FIELD
In Fields, select NID (and/or TITLE or whatever you want to work with in the node(s))

Preview the view, putting FILTERONTHIS in the arguments/contextual filter area.

Look at the SQL it generated in the Preview and cut/paste it into whatever you need, substituting FILTERONTHIS for a variable of your chosing. Or, save the view and then use views_get_view_result() to access the result.


No delete button for a content reference

To delete a value from your "Content Reference" field, simply leave the textfield of the desired row-to-delete blank (the multi-field widget for autocomplete fields doesn't have a delete button, it infers which rows should be maintained/deleted based on the presence of a value).

You've marked that field as required (notice the red asterisk at the top), so it must contain at least one value for the form to pass validation. If that's undesirable, just visit the manage fields page, edit the field, and remove the required constraint.


You need to do field level theming.

Create a template file having name like: views-view-fields--your-view-name.tpl.php
drupal_set_message('<pre>' . print_r(array_keys($fields), TRUE) . '</pre>');

see Calling a field in views-view-fields--view-name.tpl.php ---- Error


How to create a checkbox to turn-off/on email notifications each time when a node is published or updated?

Unless you want to re-invent the wheel, you should have a look at the Message Stack, which does exactly what you are asking for (and much more ...). The Message Stack consists of these modules (quotes are from the module's project page):

Message:

The Message module is the core of the message stack. It enables logging and displaying system events in a number of different use cases. Events that are recorded over time are sometimes call activity streams. Exportable messages subtypes can be created for different use cases with custom fields and display (view) modes.

Message Notify.

This module provides a method for sending a message via a notifier plugin. Message Notify comes with plugins for email and SMS and may be extended to other transport mechanisms as required.

Message Subscribe.

With this module, users who subscribe to content will be notified when events occur that involve that content. The module leverages the Flag module, which provides a subscribe functionality to users.

These are the basic components and dependencies of the message stack:

Quite a few popular Drupal distributions already adopted to this Message Stack, such as such as Commerce Kickstart, Drupal Commons, ERPAL and Open Atrium.
If you want to have a closer look at the Message Stack and see it at work in your own environment, then experiment a bit with the Answers module (disclosure: I'm a co-maintainer), together with the Answers Notification sub-module, which allows logged in users to subscribe to selected questions (= nodes of content type "Question"), and so that they receive notifications (using the Message Stack) when Questions receive Answers (= nodes of content type "Answer").


How to turned off the translation on the node reference with entity translation?

I got my answer.

There is an option for "Select nodes by language" in "admin/config/regional/i18n/select".

I just unchecked it. my issue has been solved.


How to prevent a field with thousands of files from loading on Edit operation?

Would it be enough to deny editing rights to that field using Content Permissions?


Get User ID (not current) in a overridden views.tpl.php

You should have a $views variable available with an array similar to $rows called $view->result[] that contains the unrendered/raw view results and just as long as you have a field in your output that has the uid in it, you will be able to access it directly here.  (It can be a hidden field if you don't want it rendered later on) Put a drupal_set_message('<pre>' . print_r($view->result, true) . '</pre>'); or its equivalent in your template to take a look at it, but basically you should be able to use something like $view->result[$id]->FIELDNAME to access it or any other raw data.


Combine multiple Fivestar rating fields into an average

Would Computed Field be of use to you here? You might need to duplicate the three ratings fields with a different output (and hide them) but then you should be able to do some calcs on the result.


How do I know which products have seen other customers when they took a look at the product that I am currently looking?

Yes the feature you are asking after is this module.
Commerce Recommender

:: Updated, Here is a tutorial on how you can achieve what you are looking for

Drupal Commerce recommender tutorial


Include custom Product Fields in an email

The solution here (Drupal Commerce - Add Product Fields to Cart Form through Line Items) for adding Product Fields to the Cart View answered my question.

I edited the "Line Item" View to include my custom Product Field.  This is the View that drives the [commerce-order:commerce_line_items] token but per the answer linked above:

For that you'll need to add I believe the "Commerce Line Item: Referenced Products" relationship in the view.

You also need to give anonymous users the Permission "View own orders of any type" (I also gave them "View own Order Orders" but probably not needed) or the email says "No Line Items Found" for anonymous checkouts.


You could use:

views-view-fields--[view-name]--[machine-name].html.twig

Use the machine name if you only want to affect a specific view Display. (IE: when you click + Add button, that other view/display does not get affected). If you wan't all displays to be affected, then don't include the machine name.

views-view-fields--[view-name].html.twig

{% if fields.field_photo.content|striptags == 'some value' %}
    ...
{% elseif fields.field_something_else.content|striptags == 'some value' %}

        {{ fields.field_something_else.content }}

{% endif %}

If you just want to add a div class regardless of the value of the field and not depending on some condition, then simply

{{ fields.field_machine_name.content }}

OR you can do this through the Views UI:

Now, if you need something more global, IE: You want to affect all Views that contain your field and future views that will contain your field, then you need to use:

views-view-field--[field-name].html.twig

{{ output -}}


How to use field variables in un-formatted view template?

Ok so I've managed to get it working with:

<?php print $view->style_plugin->row_tokens[$id]['[view_node]']; ?>

I tried to use:

<?php print $view->style_plugin->row_tokens[$rows['id']]['[view_node]']; ?>

But it kept throwing undefined index errors, even though it was valid path from DPM.

rows (array)
  id (value)

id (the variable I used in the top working solution) didn't show in my DPM. Is that because I was calling it for the views unformatted tpl and id is a global variable?


Sending email notifications to webform submissions

To make this work, you should process the results of a VBO enabled view via Rules, whereas your rule performs 2 Rules Actions:

load the VBO list of webform submissions that you want to be processed.
add a loop to perform a Rules Action, for each webform submissions contained in your Views results.

Since you want this Rules Action to be "... sending to the email addresses ...", you need to make sure that these email addresses are contained in the Views result (if needed enhance you view to have them included).

For more details, have a look at the tutorial "How to process the results of a VBO enabled view via Rules?".


How to get taxonomy translated when creating a new node in a different language than the interfaces?

Language Selecting

There are number of ways Drupal distinguishes which language the current user is in (yourself for example).

The admin page at '/admin/settings/language/configure' lists 4 methods.

None.
Path prefix only.
Path prefix with language fallback.
Domain name only.

As you can see, to determine the language, Drupal either uses a 'path prefix', 'language fallback' and 'domain'.

The path prefix is simply something like '/de/about-us-page'. Drupal sets the language to German. When I say set, I actually mean it sets it for that particular page request. Then visiting '/about-us-page' would NOT display the language in German but your default language (maybe English).

For Language Fallback, Drupal check if the currently logged in user has a language set in their $user account. If not, it will look for a language from the headers sent from the browser. If in any case the language cannot be determined, the default language is used; again may be English.

The Domain method is simply inspecting the domain and checking if it has been mapped to a language. e.g. German to domain.de.

Conclusion

From this, you can see that Drupal is simply reverting back to the default language. You setting the 'language' within the node edit form, is simply mapping this node to that language.
Usually when adding content for other languages, I switch into the native language. This ensure my taxonomy terms are mapped correctly.

Essentially, this is not a problem but the way this system works.

Possible Fix

If all the terms you are using are common to all languages, you can modify the Taxonomy translation mode to 'Localize' instead of 'Translate'. This should allow all the terms to be saved correctly even if you use the edit page without prefix 'node/add/page'.
Just ensure you translate the terms using the String translation module.

Hope this help.
Amarjit


After Drupal 8.6.x

In your THEME.info.yml add a line like logo: logo.png. You need to clear cache for Drupal to detect this change.

Before Drupal 8.6.x

Default logo file has now become logo.svg in Drupal 8. However, to use logo.png or something else, you need to add custom settings definition in your theme. To do this, add the following lines to config/install/THEME.settings.yml file in your theme folder (replace THEME with your theme's machine name).

logo:
  path: 'themes/THEME/logo.png'
  use_default: false

After doing this, you must reinstall your theme if already installed. The file asks Drupal to install the given settings when the theme is installed. Hence, when you install the theme, the logo path parameter gets saved to the database and the default logo is disabled by the use_default parameter.


using DrupalWebTestCase - any trick to prevent it from running from scratch each time?

No, there isn't. Simpletest doesn't know if your last test run was successful, or maybe broke something within the test environment, or if you changed it. That alone would be problematic, beside technical reasons. Also, the really slow part isn't your custom setUp() code but setting up a complete Drupal installation every time.

There are some tricks to improve the speed, however.

Use the testing profile by adding a protected $profile = 'testing'; to your test class. Maybe you need to define a few additional dependencies though, because that only installs the absolutely required modules. This improves test speed ~50%.
Have a single public test*() method, which calls a number of functions. Then you only need a single set-up for the whole test class. However, you need to be aware that your test methods aren't run in a separate environment anymore.
"Hacking" core by changing the default engine from InnoDB to MyISAM. That makes create TABLE statements much faster.
Improve your MySQL configuration, here's my configuration as an example: http://techblog.md-systems.ch/blog/improve-mysql-performance
When actively working on a single test method and the class has multiple ones, disable the others by replacing function test... with function dtest... Don't forget to revert that before committing.

A single test method takes ~10 seconds on my laptop. That's not too bad.


How to manage editing and publication of content

I think you're looking for the Workbench Moderation module.  From the project page:

  Workbench Moderation adds arbitrary moderation states to Drupal core's "unpublished" and "published" node states, and affects the behavior of node revisions when nodes are published. Moderation states are tracked per-revision; rather than moderating nodes, Workbench Moderation moderates revisions.


Column multiplication and keep the result in separate column

Have you looked at the Matrix field module? It provides a table with fields in each cell, it's possible to define calculations in some of the field.

I'm the co-maintainer of the module if you have any problems.


Redirecting after submitting content - why this code doesn't work?

If you put a die in your MYMODULE_node_submit does it stop there after the form has been submitted? If it doesn't then your submit handler is not being called and you need to debug why that isn't happening.

I just tried your code on one Drupal site I have with a good 40 or 50 modules and I could not get my additional submit handler to fire. Could not work out why.

I then put the same code on a testbed Drupal site I have with only the core modules installed and it worked straight away.

Once you've made sure that you additional submit handler is being called the you just need to put:

$form_state['redirect'] = '';

to redirect to the front page.


Render an entity reference in a twig template

first you should select show Rendered Entity in your content type field Manage Display section in admin/structure/types/manage/teacher/display (I supposed your content type is teacher based on your question), then in your node template  try to render the content field with something like

{{ content.field_classrooms }}


Show Link to Subscribe/Unsubscribe to Nodes in a View

For a single View of non-subscribed nodes:

Using a contextual filter for NIDs, select provide default value by using PHP code.
Then in the PHP code use an EntityFieldQuery to get a listing of all nodes that are subscribable. Save this array of IDs to a variable.
Then use a 2nd EntityFieldQuery to get an array of all subscribed nodes for the active user.
Then subtract the 2 arrays, these are all nodes able to be subscribed to by the user.
use return $subscribable_nodes; to return the nodes as an array to the View.

Your view would contain a node title, and you could rewrite the node title as a link to the subscription url if you want.


As all the modules, it goes in site/all/modules, or in $config/modules, where $config is the directory containing the settings.php file currently used for the site. (See drupal_system_listing() to understand where Drupal looks for modules.)

sites/all/libraries is the directory where the third-party library files should go. (Although, that is not the only directory where the Libraries module looks for them.)


You may need to attach some additional custom JavaScript to do this. Take a look at the "correct" answer to a similar question.

EDIT:
I've put together a working version of this page - which contains a working modification of the tableheader.js to solve the problem of sticky headers not working when scrolling horizontally.

I've created a module with a new theming function that can be used as an alternative to Drupal's table_theme to allow for scrolling sticky headers.I also created an example module. It's working great, but may need some tweaking for your case. The modules are not documented (I'll do that later) but you can look at the example. It's self explanatory. It's on GitHub, here.

I hope this is useful.


How do I save the user submitted values of a multi-step node editing form in the database after last step submission?

After you have constructed your custom node object by stepping through your multi-form, use the node_save() function. That will write your node to the database.

To see how Drupal creates and saves it nodes you can take a look at node_add(). Hope that helps a little.


Use sass variable and mixins from base theme in sub theme

There's no special process because it's Drupal or sub/parent theme relationships, just import what you need. E.g.

@import '../../../../base/sass/core/abstractions/_linear-gradient.scss';


Where and how are escape quotes stripped when saving a taxonomy terms which include comas or quotes?

Oh! I just found it:

The function taxonomy_node_save(&$node, $terms) calls drupal_explode_tags()

https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_explode_tags/6

which has:

// If a user has escaped a term (to demonstrate that it is a group,
// or includes a comma or quote character), we remove the escape
// formatting so to save the term into the database as the user intends.
$tag = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $tag)));


Administrator settings vanished for sheetnode content type nodes

I got the answer myself. I had my CKEditor module disabled while the "Sheetnode CKEditor" module was enabled. So there was some conflict which led to the disappearance of links.


Programmatically (via php code) create content of a specified type

Thanks Ivan Jaros and Kevin ... Once I placed the machine name of the content type (rather than it's human readable title) as the type value the content created successful and was of the required type e.g.

$node = Node::create([
    'type'        => 'the machine name associated with the content type',
    'title'       => 'My title',
   ]);
 $node->save();


Search all content fields with "find content" module instead of title

Your best option is to use the Administration views module and edit the view to suit your needs. Edit the view with an exposed search filter.

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.
  *Note: If you are upgrading from an older version of Administration views and the default views have been overridden (saved in the
  database) you could encounter issues or not see any new changes unless
  you revert these views, so the default in-code views are used. This
  can be done in the views UI listing or using drush (drush cter
  views_view --module=admin_views)


having problem with db_or() and LIKE clause in drupal 7

You can use dpq() to inspect your query.
Your query looks good, but I suspect that there's a small error in your condition. You put donaiton, shouldn't it be donation ?


Search results: order & group by custom field

Found an answer... hook_preprocess_search_results is exactly what I need.

function mymodule_preprocess_search_results(&$variables) {
    $variables['search_results'] = '';
    $output_results = '';
    $output = '';

    // loop through results, group by department
    $departments = array();
    foreach ($variables['results'] as $result) {
            $departments[$result['node']->field_department[$result['node']->language][0]['value']][] = $result;
    }
    ksort($departments);

    foreach ($departments as $department => $departmentResults) {
        $value = "";
        foreach ($departmentResults as $key => $result) {
            $value .= theme('search_result', array('result' => $result, 'module' => $variables['module']));
        }

        $output_results .=  '

' . $department . '
';
        $output_results .=  $value;
        $output_results .=  '
';
    }

    $output .= '
';
    $output .= $output_results;
    $output .= '
';

    $variables['search_results'] = $output;
}


Anyone having a problem with Drush 7 and Drupal 8 alpha-11

I found the same issue. Upgrading Drupal 8 to the latest change (8.x branch instead of the alpha11 version) Drush works properly.


Help with finding field reference to node title within webform select options view? field reference issue

OK, you're just accessing the wrong (non-existent) properties.  You need

foreach($view->result as $item) {
   $options[$item->product_id] = '<a' . $attributes . '>' .
       render($item->field_field_img[0]['rendered']) .
       ' (' . $item->commerce_product_title . ')' . '</a>';
 }

I removed $item->field_title because I don't see it's equivalent in your $items. And without knowing what the field_field_img is it's impossible to tell if that will work for it as well.


Custom pager "Showing X - Y of Z results"

In views you can use the below php function and place it in header with php filter

<?php
global $pager_page_array, $pager_total_items, $pager_total;
$my_view = views_get_current_view();
$items_per_page = $my_view->pager['items_per_page'];
if ($pager_total[0] == 1) {
  echo t('Showing !pager_total_items results',
    array('!pager_total_items' => $pager_total_items[0])
  );
} else {
  $start = 1 + ($pager_page_array[0] * $items_per_page);
  $end = (1 + $pager_page_array[0]) * $items_per_page;
  if ($end > $pager_total_items[0]) $end = $pager_total_items[0];
  echo t('Showing !start-!end of !pager_total_items results',
    array('!start' => $start, '!end' => $end, '!pager_total_items' => $pager_total_items[0])
  );
}
?>

See the below is result


Twig dump not working (PHP Warning: Leaked 2 hashtable iterators )

Probably because there are some recursive data structures in there. Try installing kint from the devel project, I'm not sure right now if it replaces dump() or if it provides an alternative kint() but one of those should give you much better output.


Remove confirmation page in Drupal Installation Profile

I've never tried it but the docs for hook_install_tasks_alter() suggest it's possible since install_finished() it one of those tasks

Alter the full list of installation tasks.
Parameters
$tasks: An array of all available installation tasks, including those provided by Drupal core. You can modify this array to change or replace any part of the Drupal installation process that occurs after the installation profile is selected.

So in theory you should be able to replace the function for that entry with one that performs a redirect instead
function MYPROFILE_install_tasks_alter(&$tasks, $install_state) {
  $tasks['install_finished']['function'] = 'MYPROFILE_install_finished';
}

function MYPROFILE_install_finished(&$install_state) {
  // install_finished() still needs to run but we can discard the output.
  install_finished($install_state);
  drupal_goto('<front>');
}


How to add additional class to an imagecache preset?

Add it as an array,

$class = array('imagecache', 'beautytips', 'class3');


Just to eliminate a possible cause of your problem: if you have enabled CSS aggregation then you must clear the cache before changes to CSS files become active.


Can you access the command line? If so, try to use Drush (the drupal shell command-line interface) to export the view settings.

If you use Drupal 6, this is possible once you install the Drush Views module so it won't help you since you can't access the site.

But if you use Drupal 7, you can use this patch.


how to wrap drupals taxonomy term node list in a div

One option you have is to override page.tpl.php and wrap the "content" render:

      <div class="row">
        <?php print render($page['content']); ?>
      </div>

This will encapsulate your whole taxonomy-term.tpl.php, where your node list is.


Ajax behavior is attached to form elements when there is a record in Drupal.settings.ajax for the HTML-id of the form element. Therefore in order to disable Ajax for a given form-element, you need to remove the appropriate ajax settings record. You can achieve that by implementing hook_js_alter:

function hook_js_alter(&$javascript) {
  foreach ($javascript['settings']['data'] as $index => $item) {
    foreach ($item as $key => $settings) {
      if ($key == 'ajax') {
        // The prefix id for a field_collection with the name fc:
        $field_id_prefix = 'edit-field-fc-und';

        // Remove ajax settings for the "Add another item" button
        unset($javascript['settings']['data'][$index][$key][$field_id_prefix . '-add-more']);

        // If you also need to de-ajaxify the "Delete" buttons:
        foreach (array_keys($settings) as $element_id) {
          if (preg_match('/' . $field_id_prefix . '-[0-9]+' . '-remove-button/', $element_id)) {
            unset($javascript['settings']['data'][$index][$key][$element_id]);
          }
        }
      }
    }
  }
}


extract list of user id's from views to tag a content automatic

Perhaps you could use Views Bulk Operations to list the advert nodes and assign the relevant field information though 'Modify entity values' action

It will allow you to filter and select the adverts to update then batch update them.


How to control from a module the block visibility of a block implemented by another module?

You can call the aggregator's (or an other module's) block routines by doing something like this in your module...

$foo=module_invoke('aggregator', 'block', 'view', 'BLOCK_DELTA');
$content.=$foo['content'];

...with the resulting $content containing the html of the block in question.

So, it would be fairly trivial to include something like the above in your custom module's block view hook instead of copying all of the aggregator module's code into your module.

More information on module_invoke() here.

Just an FYI:  Using the visibility key set to PHP in hook_block() actually requires the <?php ... ?> brackets with the whole shabang being passed through eval() so IMHO I don't think it is all that much safer than using the Block UI's PHP option.


Roughly speaking, the procedure is to

copy all files to your webserver
create a database on the webserver
export the local database
import the db export in the webserver db
edit settings.php and set the new db name, user and pass
enjoy

The recommended webserver specs can be found at http://drupal.org/requirements. Since you have been developing on Linux, Apache and MySQL, use the same on your webserver (unless there is an important reason to change it). Also pay attention to your PHP version. Recent Ubuntu versions come with PHP 5.3, so it's best to use that on your server as well.

To prevent problems while importing your database (especially if you're using a tool like phpMyAdmin), it can help to empty (truncate) all cache_ tables before exporting it.


adding meta info to contents and filter them

Have you looked at the Internationalization module?

  This is a collection of modules to extend Drupal core multilingual
  capabilities and be able to build real life multilingual sites. Some
  features:

  Taxonomy translation (both, per language terms and translatable terms)
  Multilingual variables Multilingual blocks (control visibility per
  language and translate title and content)
  Language selection (when you switch the site language you'll see only the content for that
  language)
  Requires Variable module 2.x (Drupal 7)
  Read a complete
  feature overview in the Internationalization handbook: Building
  multilingual sites .

If you dont want a full i18n site you can always just use a custom field or Taxonomy term and Views to build page lists of content tagged with that language.


Content entities are different from most other things in that they often do not have methods and proper interfaces, at least not for configurable fields.

In case of content entities and fields, public methods is not really what you actually want to know, what you want is to know about fields and properties. And only when you get to an entity again through a reference then the methods matter.

For an overview, I always refer to the great Entity API Cheat Sheet.

Content entities have a fixed structure, Entity > Field (FieldItemList) > FieldItem -> Property. A property is either scalar or a reference to something else, e.g. another entity, a language object, a date object, ...

For a few specified examples, some useful snippets:

// List of fields that an entity has, the field definitions also have a lot of information like the type.
array_keys($entity->getFieldDefinitions())

// Use get() instead of the magic __get() on the entity level then you at least get some type hints.
$entity->get('field_name').

// Get the list of properties a certain field has, use array_keys() again for just the names, but the definitions also have the type and if it's computed or not.
$entity->getFieldDefinition('field_name')->getFieldStorageDefinition()->getPropertyDefinitions()

// Most field types have value property, but e.g. entity references have target_id and the computed entity. as you found. File and Image fields have additional properties like title/alt/description.
$entity->get('field_name')->value
$entity->get('field_name')->target_id
$entity->get('field_name')->entity

// Note that get('value') is not the same as ->value on the field item level, get() returns a typed data object, get('value')->getValue() is the same as ->value.

// When not specified, the delta 0 is assumed (all fields are a list internally, even something like the node id), you can use array access or the delta to access another delta, make sure it exists.
$entity->get('field_name')[1]->value
$entity->get('field_name')->get(1)->value

// When you have an entity reference, you can get the entity type and class like this:
$entity->get('field_name')->entity->getEntityTypeId()
$entity->get('field_name')->entity->getEntityType()->getClass()
// or
get_class($entity->get('field_name')->entity)

// From there you can look up the interface and type hint against that, to a) make sure you have a valid, loadable reference and get type hints in an IDE:
$file = $entity->get('field_name')->entity;
if ($file instanceof \Drupal\file\FileInterface) {
  $file->getFileUri();
}


How do I programmatically add a product reference to a commerce product node?

Your issue isn't that there wasn't a field available in the data model to edit but that you used the wrong array structure for the product reference. Instead of the "value" key you should've been using "product_id".

I highly recommend against directly inserting field data like your answer proposes. The Entity / Field APIs should be allowed to perform their full jobs on this data when it's entered. For example, in your case you didn't put the necessary data into the field data revision table at the same time.


This code should work for you

$link = l($title, $url);
$my_body_content = t('!frequency new comment(s) sent to !link', array('!frequency ' => $frequency , '!link' => $link));
$ewrapper->field_body->set(array(
    'value' => $my_body_content
) );


mediafront module showing thumbnails instead of original image

Here is the installation guide.

Step 4 shows how to set up your fields, now just make sure you go to the "Manage Fields" for the content type you created, click edit next to the image field. Check the page for a dropdown for "image style", set it to none and define the dimensions of the image.


"Trying to get property of non-object" for image_get_info

Always, always read the documentation first:

  Return Value

  FALSE, if the file could not be found or is not an image. Otherwise, a keyed array containing information about the image:

Emphasis mine.


Hide authoring information programmatically in a content type

I assume you need to hide the Authored by part basing on some conditions you check at run-time. If you need to hide that only for a content type, for example for the Article content type, then you can change settings in admin/structure/types/manage/article.

If you want to hide that information basing on the user ID of the user who created the node, then you could use the following code.

function mymodule_preprocess_node(&$vars) {
  $node = $vars['node'];

  // Remove that information if the node has been created from the user #1.
  if ($node->uid == 1) {
    $vars['display_submitted'] = FALSE;
    $vars['submitted'] = '';
    $vars['user_picture'] = '';
  }
}

Notice I am setting the same variables set by template_preprocess_node(), which uses the following code.

  // Display post information only on certain node types.
  if (variable_get('node_submitted_' . $node->type, TRUE)) {
    $variables['display_submitted'] = TRUE;
    $variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date']));
    $variables['user_picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', array('account' => $node)) : '';
  }
  else {
    $variables['display_submitted'] = FALSE;
    $variables['submitted'] = '';
    $variables['user_picture'] = '';
  }

The template files used by Drupal core check $display_submitted before rendering $submitted and $user_picture. Probably Drupal core sets also $variables['submitted'] and $variables['user_picture'] for those template files that render them without checking first $display_submitted.


How to put drop down list of content type page in to another content type pages

YOU should use the entity reference module for the above purpose.

  Provides a field type that can reference arbitrary entities:

  A generic entity reference field Four widgets: Two implemented on top
  of the Options module (Select and Radios/Checkboxes), Two autocomplete
  widgets (one with one text field per entry, one tag-style with
  comma-separated entries in the same text field) Two formatters: A
  "Label" formatter, with optional link that displays the label of the
  referenced entity (the node title, the user name, etc.) A "Rendered
  entity" formatter, that renders the references entity using a
  configurable view mode Integration with Views (for both forward and
  backward references) Integration with Entity Metadata (and as a
  consequence with Search API and the like) Integration with Devel
  generate Integration with Feeds and Migrate (>= 2.3) for painless data
  import This modules depends on Entity API and CTools.

  Modules extending Entity reference functionality:

Earlier answer deleted following comments :
If you want to use the existing field then just go to manage fields tab under Home » Administration » Structure » Content types » A and use existing field option where you will get the existing field of other content type
Check the image below for existing field option :

Or else you can do it in the following way :

You can get your dropdown list for content type in $form_state['values']['your_field_name_for_dropdown'] and

and Save that value in $_SESSION['module_name']['your_field_name_for_dropdown']
After saving that value you can use that value to insert into another content type in the hook_form_alter function or your custom_form itself.


Are ids strictly sequential i.e. does later added content always have higher id?

User IDs and Node IDs are automatically incrementing (mysql, postgresql, sqlite) fields. Once an id has been used, it should not be used again (in the case of deleted content).

The higher the number, the later it was inserted into the database.

You could always end up with imported content that is older, but now has a higher Node/User ID because it was inserted at a later time.

You may want to look to the Relation module, or even Drupal's own menu system to define hierarchies.  This depends completely on your use case of course.


I found the answer to this question here: https://www.drupal.org/project/group/issues/2959912

Create a .yml file, for example: my_module.group.permissions.yml

It should contain:

access group menu edit:
  title: 'Edit group menu'
  description: 'Allow users to edit the group menu'

First line is the permission itself.  I did this. Flushed cache, and my permissions now appear in Group module permissions screen under "My Module".


Creating first module, and How to alter text field on new content creation in Drupal 7?

A couple of pointers:

Use only lower case for module names.
$node is not available in hook_field_presave(). $entity should contain necessary info.
hook_nodeapi() is not available in Drupal 7.
It's possible you can make these alterations in your theme's template.php file as well.

You can use the devel module to help with debugging, e.g. dpm($entity, '$entity contains').

Also see Module developer's guide and Drupal 7 API reference for more info.


Attach different CSS classes to first and second link

I figured how to loop through an entity reference field. Because I am looping from inside a paragraph twig through another paragraph (entity reference) I have to loop the children:

{% for item in content.field_name|children %}

So the children did the trick! Then you can do something like:

{% set link_class = loop.index == 1 ? 'primary' : 'secondary' %}


I think (if i did understand you correctly) you need to add a new image style first and then you apply it to your image in the manage display area.

you can add a new style by going to admin/config/media/image-styles and then click on "Add Style"


Field Collection : Query to get the node id by sending a value of a field collection field value

You could try Field Collection Values

As it says, try

  To get the values of the individual field items call the entity_load
  function:

<?php
  $node25 = node_load(25);
  $track_1 = entity_load('field_collection_item', array($node25->field_track[LANGUAGE_NONE][0]['value']));
  $track_2 = entity_load('field_collection_item', array($node25->field_track[LANGUAGE_NONE][1]['value']));
?>


How can I stop ckeditor from adding   in front of pasted word content?

Upgrading to ckeditor 4 solved this issue for me. I am using wysiwyg 7.x-2.2 and CKEditor 4.0.0.769.


jQuery Draggable plugin integration with Views 3

I know this isn't exactly what you asked for, but have you considered using the draggable views module? It does what you aim to do without you having to code anything.


Override the body field with another field in hook_node_view

Just hide your body field, if there's a value in your field_coming_soon_body:

    if ($coming_soon) {
      $node->content['body']['#access'] = 0;
    }


How to insert the title of the group in a message?

For this, you need to know that a node can be in multiple groups and there is also a midlevel entity between a node an a Group called a GroupContent entity.

To retrieve the Groups for a given node you can use this code:

 $plugin_id = 'group_node:' . $node->bundle();

 // Only act if there are group content types for this node type.
 $group_content_types = GroupContentType::loadByContentPluginId($plugin_id);

  // Load all the group content for this node.
  $group_contents = \Drupal::entityTypeManager()
        ->getStorage('group_content')
        ->loadByProperties([
        'type' => array_keys($group_content_types),
        'entity_id' => $node->id(),
  ]);

  /** @var \Drupal\group\Entity\GroupInterface[] $groups */
  $groups = [];
  foreach ($group_contents as $group_content) {
    /** @var \Drupal\group\Entity\GroupContentInterface $group_content */
    $group = $group_content->getGroup();
    $groups[$group->id()] = $group;
  }

You can see this code in action in gnode_node_access() which works out access permissions for a node by checking the Groups it is attached to.

Now you have a list of groups, you can load the first one from the list and use its title.

  $group = reset($groups);
  $title = empty($group) ? '' : $group->label();


On the "Manage Display" page for your content type (under admin/structure/types), you can adjust the format to use to display the date.

To adjust the formats, you can configure the date and time settings (admin/config/regional/date-time).


Checking whether or not an unpublished comment exists on node for current user

You can achieve this in either of the following way,

1) If you are writing custom function as described in question,
   a) Write your function in a block by selecting text format as PHP code, and display the   block in desired region.
   b) Otherwise define the function in your module and call it in your node template file node--type.tpl.php

2) Through view: Create a view to show un published comments of a node as follows,

View

Create a view:
Settings:
  Show: Comments
  Create block: select
  Click save & continue

Filter criteria
 Comment: Approved (No)
Advanced->Add
 Contextual filters

Content: Nid

Under When the filter value is NOT available

Provide default value : Content ID from URL
Comment: Author uid
  Provide default value ->choose user id from logged in user

Now assign your block to a region on the node display page, you will get unpublished comments of the particular user for that node,


How can I loop through entity reference values?

According to the entityreference_field_schema() function, the column name for an entity reference field is target_id (not value). That said, to extract the node ids you should probably use something like this:

$nids = array();
foreach ($node->field_exporter_countries[$node->language] as $index => $item) {
  $nids[] = $item['target_id'];
}

$nodes = entity_load('node', $nids);

// etc...


In general, as Clive said it is difficult to give answer to a question that broad in scope. But in general there are two broad directions:

Use Modules like Panels and Display Suite - These allows customizations in node pages by allowing you to chnage layout, add different contents etc.
Follow custom theaming path. this involves writing modifying the preprocess function and modifying the node.tpl.php

Any more specific info will require you to give out more details in terms of what you want exact in terms of layout and "clean up"


List of template suggestion used for a node

I'd go and get the Theme developer module.  Simply get the element you want to theme and click on it - then you'll get a list of any template files and/or theme functions that were called in the processing of the element you clicked.

  Firebug for Drupal themeing. See the screenshot and screencast. Note
  that this module injects markers into the DOM to do its magic. This
  may cause some themes to behave erratically and less capable browsers
  may make it worse (especially IE)/. Enable it when needed, and disable
  it afterwards.


You could run an EntityFieldQuery on hook_node_insert to count all of the nodes of type event and then see if that count plus one (because the new node isn't saved to the DB yet) is divisible by five. Something like this:

function mymodule_node_insert() {
  $query = new EntityFieldQuery();
  $result = $query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'event')
    ->execute();
  $count = (count($result['node']) + 1);
  if (!($count % 5)) {
    // Generate/Send your email
  }
}

Note that the code above is totally untested.


Hope this will help you,

In Drupal 7, you can achieve it using template_page_alter

    function THEME_NAME_page_alter($page) {
        global $language;
        $lang_name = $language->language;
        $meta_language = array(
          '#type' => 'html_tag',
          '#tag' => 'meta',
          '#attributes' => array(
            'http-equiv' => 'content-language',
            'content' => $lang_name
          )
        );
        $meta_content_language = array(
          '#type' => 'html_tag',
          '#tag' => 'meta',
          '#attributes' => array(
            'http-equiv' => 'language',
            'content' => $lang_name
          )
        );
        drupal_add_html_head($meta_language, 'content-language');
        drupal_add_html_head($meta_content_language, 'language');
    }

Folder listing of active theme folder

template_page_alter inside template.php file

Source


How to use hook_views_data_alter to display select list on user reference field?

You could checkout Editable Views which let's you create Views where the fields are editable directly. It works with Field API fields which it looks like your field is.


How to add a local task tab to node view?

Your code looks good but Remember to clear your Drupal caches at admin/config/development/performance after every change to your hook_menu above.

The alternative that comes to mind,would be to use hook_menu_local_tasks_alter, because the menu item we want to use may be already exists.

You can also try this i hope it will help you:

/**
* Implements hook_menu().
*/
function add_performance_menu() {
  $items = array();
  $items['node/%node/performance'] = array(
    'title' => 'Add a performance',
    'access callback' => 'your_module_access_check',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}
function your_module_access_check($node) {
  if ($node->type == 'page') {
    return TRUE;
  }
  return FALSE;
}

Thanks


You could use hook_theme to register your theme function, but it sounds like you're wanting output an item list which can be done with theme_item_list:

  $names = array('one','two','three');
  $block['content'] = theme('item_list', array(
    'items' => $names,
    'title' => t('My Names'),
  ));

This will fill in your block's content with this:

My Names

one

two

three


If you update a routes file in Drupal 8 how do you clear the cache?

You can use

drush ev '\Drupal::service("router.builder")->rebuild();'

to rebuild the routing information without clearing all the caches.


Clean GET parameters after submitting a 'GET' form

FormState::cleanValues does exactly that:

  Removes internal Form API elements and buttons from submitted form values.

  This function can be used when a module wants to store all submitted form values, for example, by serializing them into a single database column. In such cases, all internal Form API values and all form button elements should not be contained, and this function allows their removal before the module proceeds to storage. Next to button elements, the following internal values are removed by default.

  form_id
  form_token
  form_build_id
  op

But as you're not POSTing the form you can't really use it. Two options spring to mind:

Implement your own cleaning method. This might be tricky as you don't have the form fields to work with so unless you have a list of known good fields available, there's always the possibility you'll include something you don't mean to
Change your form's flow to Post/Redirect/Get (PRG). The steps are roughly:

Change the form method to POST
In the submit handler:

Use FormState::cleanValues to clean the input
Build a new Url with the desired redirect path, and query options made up of the clean form state values
Use $form_state->setRedirect($url); to redirect the user to the new URL

From the user's point of view, nothing really changes. They still end up at the same URL, just without the undesired query args.


Dynamically remove library based on user role, cache context not working

hook_library_info_alter() is not the right approach. You get the role of the user who installs a module or clears the cache, not of the user who requests the page. Info alter hooks in general are about changing information provided by other extensions and usually are only recalculated if an extension is added or removed and for a better dev experience on a cache clear.

And indeed, hook_page_attachments_alter() lists only libraries added by other hook_page_attachments(_alter) hooks. See invokePageAttachmentHooks(), which starts with an empty attachments array:

  public function invokePageAttachmentHooks(array &$page) {
    // Modules can add attachments.
    $attachments = [];
    ...

So we can rule out both hooks you've mentioned. Attached libraries are collected from many different places (YAML, render arrays, hooks) and they are merged (bubbled up) through the entire page building and rendering process. So it might be a good idea to attach the override in form of a custom library the same  way and let Drupal calculate the assets when rendering the page. See https://www.drupal.org/node/2216195#override-extend


Hide the option of Payment method "No Payment Required" based on user role

In Drupal Commerce each payment method is essentially a rule. So just like with any rule, you'll need to add your required condition to that payment method rule.

Find Payment Method Configuration page - admin/commerce/config/payment-methods.

You'll see payment method "No Payment Required (Payment)" in the list of "Enabled payment method rules" (if it is enabled). If not enabled - enable that payment method.

Then click Edit next to that rule, and add condition "User has roles". Select the role "Customer", save, test and you're done.


Running update.php is only required if there are new implementations of hook_update_N() done from a module, which the hook used when:

The schema for a database table is changed
A database table is created, deleted, or renamed
The content of a database table is altered
A persistent variable is added, removed, changed, or renamed

If the release notes for the version you installed say it is necessary to run update.php, or you check the content of every .install file and notice there are new implementations of hook_update_N(), then you need to run update.php.
If you don't do it, modules will start not to work, and you could get database error messages (for example, about a database table not existing, or a table field not being present).

If the release notes for the release you installed say it is not necessary to run update.php, or you check the content of every .install file and notice there aren't new implementations of hook_update_N(), then you don't need to run update.php.
If you don't run update.php, there isn't any issue, for this update, but it's not said you can continue avoiding to run update.php for future updates. For each update, you would need to check what the release notes say about or the code in .install files.

What I said holds true also for third-party modules, not just for Drupal core.

If you want to avoid reading the release notes for every installed modules, which could also not report if running update.php is necessary or not, or check the code in .install files, which would also require you to notice if there are new hook_update_N() implementations, you just run update.php after updating core or any third-party module.

I normally run update.php every time I update core or modules. If there are update hooks that need to run, they will run. If there isn't any update hook that needs to run, update.php will end faster and show me a page with a link to the front page and the administrative pages.


Is There A Way To Remove Kickstart Demo Product Types Without Emptying Database?

hmm my understanding was that Kickstarter kit was a "hey see what it can do once fully configured!" example of Commerce. Understanding the setup -- you could then go back and install/configure Commerce by hands to your needs.
That being said Commerce content I think is just Entities and Nodes, If you want an non-SQL way to reset a site (i've written ~34 sql Delete statements to nuke content from sites in an sql script for drupal -- it's not that hard you just look at node and field_* tables mostly when clearing content from a drupal site) I'd recommend looking at the Delete All module and the documentation found in drush help delete-all as a GUI means of selecting out types of content to nuke from a drupal site.
EDIT: DrupalCamp Montreal 2014 steps to setting up Commerce ala Commerce Kickstart but Not Depending on the Kickstarter kit
Original source (broken):  http://renaudjoubert.com/en/article/step-step-guide-to-installing-commerce-scratch

Step by step guide to installing Commerce from scratch

The following guide was used in a presentation at DrupalCamp Montreal 2014.
The presentation focused on how to install Drupal Commerce from scratch
(i.e. we won't use the Commerce Kickstart distribution).
This is an elevator guide. So get in now because we're going up!

FIRST FLOOR
https://www.drupal.org/project/commerce
Install required modules
drush dl ctools views entity rules addressfield commerce
drush en ctools views entity rules addressfield commerce -y
Installation instructions
https://www.drupal.org/node/1007434
use the provided drush commands
drush en commerce commerce_ui -y
drush en commerce_customer commerce_customer_ui -y
drush en commerce_price -y
drush en commerce_line_item commerce_line_item_ui -y
drush en commerce_order commerce_order_ui -y
drush en commerce_checkout commerce_payment commerce_product -y
drush en commerce_cart commerce_product_pricing -y
drush en commerce_product_ui -y
drush en commerce_tax_ui -y
Add a few more useful modules
drush dl admin_menu module_filter zurb-foundation-7.x-4.x-dev jquery_update -y
drush pm-disable toolbar
drush en admin_menu_toolbar module_filter jquery_update -y
Create a responsive Zurb subtheme
drush fst Your Subtheme Name your_subtheme_name 'A subtheme of ZURB Foundation.'
Set jQuery update to 1.7+ (admin/config/development/jquery_update)
Enable your new responsive subtheme (admin/appearance)

SECOND FLOOR
Quick tour of what we've got soo far
1 Product type named 'Product'
2 tax types
LOTS of hidden functionnalities
NO visible products
and NO, you don't get a store out-of-the-box
Commerce Kickstart gives you that but you won't know how to get there if you don't try from scratch
Create a new product type 'Download'
add file & image fields
Revisit 'Product', the product type installed by Commerce
add an image field
Let's create products
a physical product (Product)
a virtual product (Download)
Now what? where's the store?
Gotcha!

THIRD FLOOR
Out-of-the-box Store is for wimps! ; )
Commerce products only exist in the backstore
products are like brown boxes in a warehouse: they're only accessible to the store's employees
in order to make products accessible to customers, you need to put them on display in a nice and attractive way
how do we do that in Drupal?
we use content types, of course
Create a content type for displaying products
how does Commerce differentiate & recognize product displays from regular content types?
a product reference field!
create product displays and configure them
Alright, let's shop!
wait a minute, nothing happens when i click Add to cart!
Gotcha!

FOURTH FLOOR
In case you didn't read the fine print: some assembly is required, like Ikea, but without the KISS diagrams
Introducing Rules... doh! where's the UI ?
drush en rules_admin -y
go to admin/config/workflow/rules and add a rule that redirects to the cart
Welcome to the cart
Time to checkout wouldn't you say ?
doh!... something isn't right
where are the taxes?
Like I said, Out-of-the-box taxes are for wimps! ; )
Commerce's taxe model is simple
there are tax types; like there are product types and content types
and then there are tax rates which you create using one of the available tax types
Create GST & PST tax rates (note - these taxes are specific to the Province of Quebec in Canada where the camp was held)
Revisit the checkout
Darn, the taxes are not displayed in the expected order! (i.e. GST on this first row, PST on the second row)
How do we change the order in which taxes are displayed ?
the hard way: by overriding theme_commerce_price_formatted_components() in the theme's template.php (see https://drupal.org/node/1095576#comment-8721217)
the easy way: by creating separate tax types for GST and PST and playing with their respective weight (note that at the time of this writing, the behaviour for tax weights does not follow the convention where lighter weights float to the top; see this issue)
Are we in business yet? Not quite.

FITH FLOOR
Setting up a payment method
for simple tests, use the 'Example payment' module (provided by Commerce)
For serious tests and real sales, you can use Stripe or Paypal or whatever works for you. For the purpose of this presentation,I used Stripe.
www.stripe.com
setup an account
get the API keys (secret and publishable)
Install & configure Stripe
drush dl commerce_stripe
drush en commerce_stripe -y
add both keys to the Stripe payment method rule (admin/commerce/config/payment-methods/manage/commerce_payment_commerce_stripe)
Time for some tests
for this, we use the dummy credit cards provided by Stripe
https://stripe.com/docs/testing
When you're happy that all works like it should you can replace de test API keys by the live API keys.
Done!


Drupal 7 Form API, Checkboxes with key -> value from database

To populate your options array with data from table my_table, with value keys from column value and text from column atext, you can use:

$options = array();
$result = db_select('my_table', 'mt')
            ->fields('mt', array('value', 'atext'))
            ->execute();
foreach ($result as $row) {
  $options[$row->value] = $row->atext;
}

To get taxonomy terms, you could use the code above to query tid and name from the taxonomy_term_data table (plus add a condition() for the vocabulary id), but for this specific usage you'd better to use the right API:

$options = array();
// Get term tree for vocabulary which id is in $vid.
$terms = taxonomy_get_tree($vid);
foreach ($terms as $term) {
  $options[$term->tid] = $term->name;
}

Just do not forget that vocabularies are tree structures. See the documentation for the taxonomy_get_tree() API to know how to limit the terms you want to get from a vocabulary wrt starting term and tree depth.


How do I export and import content types (including fields) between environments?

You're on the right track with the configuration export but I am guessing you did the single export option for the content type. Each field on your content type has several configuration items that should be exported too.
An alternative is using the Features module. This will allow you to select your content type. It will also automatically gather up all the required configuration items for exporting them.


The requested page "/user/password" could not be found. need to reset my password

You could try the following drush command:

drush uli


You can implement complex field access conditions fairly easily with:

hook_field_access


how to show breadcrumbs only on subpage?

If you are using Drupal 7, then you can use:

Path Breadcrumbs
Context path breadcrumb

  Path breadcrumbs module helps you to create breadcrumbs for any page with any selection rules and load any entity from the URL!

  This is a plugin module for the context module. It takes the request URI part of the URL of the current page (for example /our-company/our-team/steve) and uses this path to build the breadcrumbs.


drupal_render() returns "Array" instead to render the content

First try Render instead of drupal_render

$arr = drupal_get_form('product_search_by_pin_form');
print render($arr);

From Clive answer on what is the difference between render() and drupal_render()?

  The docs for render() explain it pretty well:

  This function renders an element using drupal_render(). The top level
  element is shown with show() before rendering, so it will always be
  rendered even if hide() had been previously used on it. render() is
  basically just a wrapper for drupal_render(), except that it makes
  sure the element passed in is set to be shown when passed through to
  drupal_render().

  It also makes sure the element passed in is an array (which is all
  drupal_render() can accept). If it isn't, the element is return back
  as-is. So it provides a bit of a safety net if you like.

  If for any reason you have a variable you need to render, and you
  don't know if it's a string or a render array, you can pass it
  straight through render() without having to test the variable type
  yourself.

and another solution is, use drupal_get_form as you call back function and pass your form to it as an argument. ( take a look at https://www.drupal.org/docs/7/howtos/how-to-make-a-simple-module-with-a-form-and-menu-link )

function YOURMODULE-NAME_menu() {
  $items = array();

  $items['examples/form-example'] = array( //this creates a URL that will call this form at "examples/form-example"
    'title' => 'Example Form', //page title
    'description' => 'A form to mess around with.',
    'page callback' => 'drupal_get_form', //this is the function that will be called when the page is accessed.  for a form, use drupal_get_form
    'page arguments' => array('product_search_by_pin_form'), //put the name of the form here
    'access callback' => TRUE
  );

  return $items;
}

function product_search_by_pin_form($form, &$form_state) {
         // Provide a text field.
       $form['pin'] = array(
       '#method'=> 'POST',
       '#action' => '$come_back',
       '#title' => t('Input your PIN'),
       '#type' => 'textfield',
       '#attributes' => array('size' => '20', 'maxlength' => '20'),
       '#placeholder' => 'Type your PIN',
       '#required' => TRUE,);

       // Provide a submit button.
       $form['submit'] = array(
       '#type' => 'image_button',
       '#required' => TRUE,
       '#src' => "/images/upload/search.png",
       '#attributes' => array('id' => 'submit'),
       '#value' => 'Search',);

  return $form;
}

and third is another way of implementation second solution

function product_search_by_pin_form($form, &$form_state) {
       // Provide a text field.
       $form['pin'] = array(
       '#method'=> 'POST',
       '#action' => '$come_back',
       '#title' => t('Input your PIN'),
       '#type' => 'textfield',
       '#attributes' => array('size' => '20', 'maxlength' => '20'),
       '#placeholder' => 'Type your PIN',
       '#required' => TRUE,);

       // Provide a submit button.
       $form['submit'] = array(
       '#type' => 'image_button',
       '#required' => TRUE,
       '#src' => "/images/upload/search.png",
       '#attributes' => array('id' => 'submit'),
       '#value' => 'Search',);

       return drupal_get_form($form);
} // END of Function


Changing the confirm delete message for comments

You can do this with hook_form_alter(). https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_alter/7

Just add an if statement to check if the $form_id is 'comment_confirm_delete', then you can alter anything in the $form object, including the text.


How can I resolve my CGI error during installation of Drupal 7 on WinXp?

As in my comment above, you should try using WAMP server or Acquia Dev Desktop, which uses Apache (more suitable for PHP development).

To install Drupal on Windows, you could install it with Microsoft web platform installer by following this procedure.


Your controller must return an array or a Response object.

If you want to return the content as-is (no "drupal" around it):

return new Response($content)

If you want to return a normal, full page, then just return the render array.


How can I fix a migration input format mess?

One option is in the migration template, to add the input format value.

I found the default_value plugin worked well there e.g, to set default full_html:

field_subheading:
  plugin: sub_process
  source: field_subheading
  process:
    value: value
    format:
      plugin: default_value
      default_value: full_html

Another option, could be to run an SQL query to update the field data and revision data tables

update node__field_subheading set field_subheading_format = 'full_html' where field_subheading_format = 'other_format';
update node_revision__field_subheading set field_subheading_format = 'full_html' where field_subheading_format = 'other_format';

then clear cache.

However fixing as part of the migration template mapping is recommended.


How to alter languageswitcher to display as select element

Yes, you could override the links__language_block template (links--language-block.html.twig) and print out a select there by hand. You would also need JS to make selecting something the same as clicking a link as an option element alone won't be able to trigger like a form.


Use a relationship with the group Id and set the default value of your contextual filter to group Id from content


Create a permanent list of a content type

Views Save module can help you. The module page says

  This projects allows admins to add a "Save" button to their views (on
  a per-view basis). This button allows logged-in visitors to save their
  current exposed filter settings on the site, so they can later return
  to the same page. The saved views are stored per user, and can be
  listed with Views themselves, to provide users with an overview of all
  their saved views. Saved views can also be overwritten with new
  settings.

  Anonymous users are offered a way to log in or register when trying to
  save a view – if they do, the view is saved to their (possibly new)
  account, otherwise it is purged after a while.


Those pages are, by default, blocked in the Drupal generated robots.txt file meaning that it's very unlikely a "regular user" will stumble on them.

Someone would have to know you were using Drupal, and then type in that URL.  You're right though:  many people will know how to do that.

However, it's not a big deal.  Your admin account password should be strong enough that it cannot be guessed at.  Drupal is quite secure.  You have nothing to fear about leaving that login form where it is unless your passwords are really, really bad.

The amount of effort to re-create the login pages elsewhere does not make any sense in this case.


View published content - but only if you posted it

Node view Permissions fits perfectly for your needs and it is lightweight too. Its a drupal 7 module.

  Node view permissions module enables permissions "View own content"
  and "View any content" for each content type on permissions page as it
  was on Drupal 6. It's as simple as that.

  It's implemented in a non-conflict way, so you can use it with any
  other permissions related module.


$nid = arg(1);
$node = node_load($nid);
$image = field_get_items('node', $node, 'field_item_request');
$output = field_view_value('node', $node, 'field_item_request', $image[0]);
print render($output);


How to update the version of AngularJS using module configuration

As @Jimmy Ko suggested I have fixed the issue as follows:

I have added the following code in the function angularjs_version_files() of file sites\all\modules\angularjs\angularjs.module. Then selected the AngularJS version 1.5.8 in admin/config/development/angularjs.

$files['1.5.8'] = array(
    'angular-animate',
    'angular-aria',
    'angular-cookies',
    'angular-loader',
    'angular-messages',
    'angular-mocks',
    'angular-resource',
    'angular-route',
    'angular-sanitize',
    'angular-scenario',
    'angular-touch'
  );

Now, in the view source I can see the latest AngularJS file is included in my project.


How to save multi date and time in node programmatically?

If converting the two is your problem following may help you

foreach ($form_state['values']['field_event_date']['und'] as $key=> $value) {
  $node->field_event_date['und'][$key]['value'] = strtotime($form_state['values']['field_event_date']['und'][$key]['value']['date'] . ' ' . $form_state['values']['field_event_date']['und'][$key]['value']['time'])
}

strtotime() should be good enough.

I am assuming you are doing node_save() some where.


Not saving data after upgrading from 7.26 to 7.35

This worked for me:

Apply the patch from here:
https://www.drupal.org/node/1313912

cd sites/all/modules/contrib/taxonomy_access

wget https://www.drupal.org/files/1313912-5.patch

cat 1313912-5.patch | patch -p1
go here and rebuild permissions.
/admin/reports/status/rebuild
Clear the cache


Change page.tpl.php in a shared theme based on domain

You could do aomething like this:

function MYTHEME_preprocess_page(&$vars)
{
    $domain = domain_get_domain();

    $vars["theme_hook_suggestions"][] = "page__" . $domain["domain_id"];
}

Feel free to explore what other values are in the $domain array and use it accordingly to make your theme suggestions as complicated as required. The above example is just to demonstrate injecting domain information.

There are developer notes on the Domain Access module as well which you may find useful


Overriding Panels' default category structure

"Whaddayamean you can override functions starting with 'template' like you can functions starting with 'hook'?" I ask...

I've finished my organizer and will post it as a sandbox module if my boss lets me. I ultimately just copied the source of template_preprocess_panels_add_content_modal() from panels/includes/add-content.inc and changed what was passed on -- $vars['categories'], $vars['categories_array'] and $vars['root_content'] were particularly important.

Surprised nobody answered this -- would've been an easy 10 points to just say "Yeah, template_preprocess functions work a bit like hooks in that you can insert your own version higher up the chain just by naming it a certain way..."


Date format on user profile form shown incorrectly - how to change

Date entry format is configurable, what you did was changing the way the date will display on content but not on create content form. To change it go to your field configuration page on content type then find more settings and values collapsed fieldset and inside it look for date entry options and change to whatever.

https://docs.google.com/a/srijan.in/file/d/0B9FG53CLjf-YdEFfdzVEV1hmcWc/edit?usp=drivesdk


How to get language code of a field in a node

You can use getLangcode
Try with:

$node->{$field_name}->getLangcode()


Voting a post several times by same user

Here's something you could try.

Create a content type, Vote.  Add an Entity Reference field (to link the vote to the relevant node).

Then, allow users to vote with flags.  When a user flags the content, use a Rule that goes something like this:

Event: Node is flagged
Action 1: Create an entity, a node of type vote (Author: logged-in user, also make sure to set the entity reference field value to the current node)
Action 2: Unflag the node

This way, the user will be able to flag the node multiple times and each time a vote node will be created that will include the date and time of each vote.


Programatically render block with contextual links (in php)

You can use the Twig Tweak module to insert the 'local tasks' menu in your template file:

{{ drupal_entity('block', 'THEME_local_tasks', check_access=true) }}


Making sure edits work as intended before publishing

The more or less standard solution is to maintain a so-called staging site (i.e. a mirror of your production site, but in a protected environment), and make all changes to the staging site before committing them to the production site.

The use of a staging site is not only limited to edits, but is also very useful when making more substantial changes, such as updating a module or adding a new module.  The staging site let you run detailed tests to make sure that changes does not "break" anything before committing to the main site.

You can use drush to simplify syncing content and configuration between the staging and production site.

Edit: By "protected environment", I mean some computer that is not available to outsiders on the Internet. It is typically only available for use by yourself (and your team if you're not working alone, but manage a team of developers). The standard way of protecting it is to use a firewall and only allow connections from the IP-addresses belonging to you (and your team members)