Can I create a drush make file and installation profile from existing site?

Profiler and Profile Builder, while useful, are for building a new profile using tools and libraries.  If you would like to convert an existing site into an installation profile, please see:

http://drupal.org/node/1368242

This issue contains a Drush command to build a Drupal 7 installation profile from an existing site.  The issue is marked as "needs work" because the code templates for Drupal 6 are not in place yet, but if you're working on a D7 site, it should do the trick for you.


How do I enable pagination on a taxonomy term page

There is a default view for that. If you have installed Views module, you can just enable the view named 'Taxonomy Term', which is disabled by default.

Then you can adjust the pager settings in the view configuration interface.


Should I disallow drupal path or alias by robots.txt?

You should add both paths, as both of them are accessible.

However, I recommend installing Global Redirect plugin. It will permanently redirect your internal path to the alias (if any). This way you only have to add one path to your robots.txt.


Where can I get a list of all the Views handler properties when building my own Views handler?

When it says table, are they referencing to a table name in the database?

Often yes, but not always. A Search API index View declares a "table", for example, but if Solr etc. integration is enabled, it won't necessarily be talking to a database/table. A lot of the time though, yes, a "table" tells Views the base table to select data from; the FROM part of the SQL query.

  where can I find a list of other parameters for this as seen below in the screen shot?

The hook_views_data() API docs walk you through all the possibilities in comments and code.

  These fields show up when you click on the "add field" button in the View, but what dictates if it shows up in a content type or user type view?

The loop in the code you've shown, combined with the condition immediately after. All entity types are looped over, and if their known Views data has a base and/or revision database table, a new field is added to provide operations (because VBO knows it can process those "tables").


Fivestar being cached for anonymous users!

Rather than rendering the Voting widget with the rest of the page, I would add a delayed (ie. on page-load) AJAX request for every widget which would do a back-end call, render the widget (without pulling in a cached version) for the appropriate node/piece of content, and inject it back into the DOM.


How can I sort a view based on a date value in a multi-value paragraph reference field?

Sounds like you need to do a relationship to the paragraph reference field on your node. Which will then open up the fields on the paragraph into views. Then you might need to turn the field aggregation on in your view and add a sort on your date field selecting the MAX value


Core search, when only one result, open result

As I see the only way is use hook menu alter for this item

/**
 * Implements hook_menu().
 */
function search_menu() {
  $items['search'] = array(
    'title' => 'Search',
    'page callback' => 'search_view',
    'access callback' => 'search_is_active',
    'type' => MENU_SUGGESTED_ITEM,
    'file' => 'search.pages.inc',
  );

I propose to replace page callback "search_view" to your own and put there your logic.


Duplicate Results Using Views, loosing results using (File) File: Content using Thumbnail image

Why you don't get in the view the field that has the image and display it as thumb("image style").
That "Content using Thumbnail image" i guess it load every image with an "preview" from the respective node.


Which IPs/hosts does Drupal query for updates?

From update.module:

/**
 * URL to check for updates, if a given project doesn't define its own.
 */
define('UPDATE_DEFAULT_URL', 'http://updates.drupal.org/release-history');

Each module and theme is allowed to define it's own URL, it'll be in it's info file, but this one will cover most cases.

Note you need an access to all paths under this one, ie for Views updates Drupal will query http://updates.drupal.org/release-history/views/7.x


Installed Module crash my site. How do I bring my site back up by uninstalling a module

In Drupal 8, try to removing the module from your module folder and run http://YOURSITENAME/update.php

or

Removing module via Database - In Drupal 8 it is a bit hard to remove a module.

I think the best way is to use Drush.

drush pm-uninstall module-name (machine-name)


what is the difference between "Commerce Product Attributes" and "Commerce Customizable Products"

i'm bad in english, but still try to explain.

Product attributes are always set by the administrator, and customer can not change it. For example, if you set a colour as product attribute, you also have to define all possible variants of colors. There is no difference whether you are using conversion rates depending on the color value of the attribute or not.

Customizable products, however, allow the customer to select an attribute value depending on the preference. For example, if you sell T-shorts, you are able to allow customers choose an inscription on a T-shirt, without price changing. Customer may order T-short with any inscription that he wants to.

To be more precise, trying to explain the difference in terms of data structures. Product attributes add fields to commerce product entity, and customizable products add fields to line item entity. So there is the main difference with all the consequences.

Based on my experience:

I use a Customizable products to sell tea sold by weight. Customer allowed to enter any amount of tea in grams, and then i recalculate sell price using rules.


Where does field help text get filtered?

In function field_default_form in field.form.inc
line 107

'#description' => field_filter_xss($instance['description']),


What does this Omega theme warning / notice mean?

The $pattern needs to be filled with one of the values to the right of the question mark. To find which value to use, Drupal checks the global variable $GLOBALS['language']->dir if it contains the value 'rtl'. If this is true, the first value is assigned, otherwise the second. Basically this is a short notation of if-else.

The problem is, that $GLOBALS['language']->dir does not exist, so php throws an error.

The lines part should read $GLOBALS['language']->directory
There seems to be a fix here, which is from 2014, so there is a good chance this fix was already integrated into production.

You might be able to fix this issue by upgrading the Omega-Template to the latest stable or maybe development version (after creating backups!)


How do I include the main navigation block twice?

This functionality is present out of the box in Drupal 8. You can actually place the same block multiple times in different regions.

For adding a block multiple times:

Go to Admin -> Structure -> Block layout (/admin/structure/block).
Click on "Place block" button besides the region name.
Select any block you wish to add to that region.

Follow the same steps to add block to a different region.


Have you already checked the PlUPload module ?

It's still -dev, but should work ..

Another approach could be:
Using IMCE browser, that already allows multi-file uploads
in combination with filefield_sources, you should then be able to select the uploaded images for your gallery field and others.

  More sophisticated is the media(-entity)-suite, there's
  dropzoneJS in place.


How can I access XMLSitemap links from external PHP script?

You'll need to bootstrap the Drupal environment in your PHP script to do this. There are many ways to do this, probably the easiest is Drush's php-script command:

drush php-script my_custom_script.php

This will let you execute any arbitrary PHP script in a bootstrapped Drupal environment.

Once you have your script running your Drupal environment, you can utilize the XMLSitemap API functions for all your CRUD operations.


How can I view a list of pages to link to in the Navigation module?

Drupal has designed this a bit differently. Instead of creating content and then creating the menu, you can add a menu link when you create or edit content.


I am not familiar with mforms, but I see a few potential issues:

1)  your form doesn't have a standard signature ($form, &$form_state, ...).  I obviously can't see how you're calling it, but this is not a typical thing to do.

2)  when getting the path of the css, you should be using drupal_get_path
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#attached

3)  widget is not a property of #settings


How to bind to AJAX complete event in regard to styling the AJAX button submit throbber

You can use success function. You can refer this for its usage.

/**
 * Handler for the form redirection completion.
 */
Drupal.ajax.prototype.success = function (response, status) {
  ...
}


In the People config page you can set up who can register accounts. Put that option on Administrators only.
After that identify the bots users and delete them (make sure to delete them, not just disable).
Then, identify content created by bots and delete it.
Also, don't forget to check who can create content on the website (permissions page).


Drupal 7: Looking for suggestions on AJAX-base update to view

Wow this was not all that difficult after all.

The following forces the overlay to only be used for my desired node type and admin pages:

<?php
  function yourmodule_admin_paths_alter(&$paths) {
  $paths['node/add/user-update'] = TRUE;
  $paths['user'] = FALSE;
  $paths['user/*'] = FALSE;
  $paths['users/*'] = FALSE;
  $paths['node/*/edit'] = FALSE;
  // Add this for each content type you don't want the overlay to be used for.
  $paths['node/add/other-types'] = FALSE;
?>

Then I needed a rule to redirect to my view (home page in this case) after the content was added:

{ "rules_redirect" : {
"LABEL" : "Redirect to home page",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "node_insert" ],
"IF" : [
  { "node_is_of_type" : {
      "node" : [ "node" ],
      "type" : { "value" : { "user_update" : "user_update" } }
    }
  }
],
"DO" : [ { "redirect" : { "url" : "\/" } } ]
  }
}

The combination of the two makes it appear as if the user is adding a "quick update".


The is_new property is set by the node_save function, which is the same function that will invoke hook_node_presave - so your are safe in your assumption that this property will be present.

If you were not doing this in hook_node_presave, another way of testing if a node is new is by checking if the nid property is present and non-zero:

if (empty($node->nid)) {
  // ... this is a new node ...
}


what actions to take when someone uploaded php files in random drupal folders and sending out spam

Notice how most of these code snippets begin with "preg_replace('/(.*)/e'"? That's because it's an alternative to the eval() function for executing PHP. The rest of the string is hexadecimally encoded; you can decode it using this script. That string will decode to PHP that probably executes other scripts or performs other actions to hijack your site and make it part of a spam mailing net.

Check out this StackExchange post for more details and suggestions. There are a bunch of good articles out there too that can give you tips on securing your server.


How can I use HTML in a field of paragraphs module

Make it a body field, and then edit the source - put your HTML in there


Dynamic footer link based on current url

The default menu system won't let you do that...but if you install the Menu Token module you should be able to use a path similar to the following to get what you need:

http://m.example.com/[current-page:url]


Here is a zero coding solution.

Create a new view:

CONTEXTUAL FILTER add Node id (since workers is a content type), so we have the id of the worker.
RELATIONSHIP add Referecing Entity, checkmark require relationship.
Fields: Add Title

At top you will see a select box, select the relationship option.
Unchecked Link this field to the original piece of content
Click on NO RESULT BEHAVIOUR, put Green
Click on REWRITE RESULTS, checkmark Rewrite the output of this field, put Red

In FILTER CITERIA add type and select Workers.
In FILTER CRITERIA add the List Field (the one that contains Red or Green) and put is equal to Red and select relationship option at top.

for PAGER put 1 item.

Install and enable Views Field View

Now in your List of All Workers view:

In FIELDS add Node ID and checkmark hide field from view.

In FIELDS now Add the View Fields view field.

Select the previous view we created.
For argument, Click on replacement patterns, and use the Node ID token to pass as an argument.


Commerce order either stays as pending or grants double to customer

I seem to have fixed it by changing the weight of the second rule. I made the weight 10. I'm guessing that having the weight on default (0) was causing the double triggering.


What I see here is a typical Panels situation, with Taxonomy.

Create a vocabulary "groups",
Create two content types : slideshow item , nodes (with term relationship field to the vocabulary "groups", of course)
Three fields to the terms themselves (taxonomy terms have "cck-like fields" in core since Drupal7) : email adress, Facebook widget, etc.
Create views for each use: the slideshow, the nodes...
Enable the "taxonomy term page" panel, and insert in it your views showing your content associated to that term, and the fields of your term (Panels has the out-of-the-box interface for that) : contact form, FB block, and so on.

That's the simpliest I see :)


How can I set up an existing site from Pantheon on my computer?

Uploading your key is the first step towards cloning your repository because this gives you access. The next step is to grab the git repository address from your site's dashboard. This is located in the "Connection Info" dropdown menu on the upper righthand side, or in the "Connection Mode" bar above your commit log. The info button provides the git commands you'll need to get started. Please note that you'll need to be in the Git mode in order to push your local commits to the Pantheon repository.


Some pages are generated entirely through views, bypassing the code. You can set the menu link and path in the view's settings. The navigation to that page would then be completely independent of the code.

If the page was created when you installed someone else's module, I would guess that the view is embedded into the site through code, and the path can be set that way as well. In that case, the path would be set in an array with something like this:

$handler->display->display_options['path'] = 'user/%/wishlist';

Contained in a function utilizing hook_views_default_views.

You can tell where the view is generated on the admin/structure/views page, where under each view title it tells you either: "In database", "In code", or "Database overriding code."
I'm assuming that the wishlist page is a view. So, if your page doesn't appear on the views admin page, then it's a different problem.


Generally speaking, directly redirecting from a hook is something you should not do because it would not allow other hooks to be invoked, and it would stop what Drupal is doing.
In the specific, hook_node_insert() would also be invoked when a node is programmatically created from a module, for example in a hook_install() or hook_cron() implementation, or from a Drush plugin. In those cases, redirecting inside hook_node_insert() would just break Drupal core or third-party modules.

If you want to redirect users, the proper moment is after a form has been submitted. It is also preferable, because you can tell Drupal where you want to redirect users, and Drupal will do it after all the involved hooks are invoked.

You just need to add a form submission handler to the node edit form. Inside that, you redirect users with $form_state->setRedirect($route_name) or $form_state->setRedirectUrl($url) where $route_name is the name of the route (a string), and $url is a \Drupal\Core\Url object.


You can set the node title as a token on the link-field (in the content type field settings).

You can alternatively output the field in the view as url plain text and rewrite the title to display as a link with the given field link as URL.


You're asking a chicken and egg problem. Nodes just hold data and no information about the theme (usually). You're describing mixing the two in the Body field of a node, in essence hard-coding the look (layout) of your "node" in the database.

Drupal in many respects fights this as the page content is 1 item and drupal7 cares nothing about whats around it. In D8 their is a UX initiative to make a nicer page layout creation system.

In D7 you may be interested in context_layouts found in Context. See this youtube video on its usage.

I've done something similar (but not Grid aware) using Spaces, spaces_node and Dashboard (spaces dashboard) in Drupal6 per node (I also used node_block heavily). Every node/page could have their own unique layout using Spaces and its submodule of Dashboard; you can set any content to any block/region of the page as needed using a drag-and-drop overlay. Actually, the site I'm mentioning is UCSB SageCenter. Unless your logged in and editing a Space/Dashboard you dont really see anything in the source. I added a node field to pre-assign a known space for node pages on node creation. This site was hard.

Here's a video demo on spaces_node -- its not supported anymore really.


How to write options lists with drush vset?

You can use drush.

drush vget foo --pipe

The --pipe option will format the output as php code.

As far as using that with drush vset, I would recommend against that and instead set via an update hook, or directly in settings.php.


exclude contextual filters from breadcrumb

Click the "override breadcrumb" box in the settings pane for the contextual filter. You can override it with a custom value and you can use %1, %2. This won't exclude them but it will clean up the problem of the repeated words.


Did you read this and this posts? I thinks it's not so difficult to achieve this:

function MYTHEME_links__system_main_menu($variables) {
  $html = "
\n";
  $html .= "  \n";
  foreach ($variables['links'] as $link) {
    $html .= "
".l($link['title'], $link['path'], $link)."
";
  }
  $html .= "  \n";
  $html .= "
\n";
  return $html;
}


How to check whether content entered by a user in a custom form is valid HTML?

You can probably do that with PHPTidy (PHP Module) and tidy_get_error_count


How to make SASS/SCSS Module works with Drupal 7?

You didn't mention whether you installed the PHamlP library or not and from your question description, it sounds like that is the problem -- it needs this to actually render your .sass files. From the readme:

1. Create a folder inside the SASS module (sites/all/modules/sass) and name it phamlp
2. Download PHamlP_3.2.zip from http://code.google.com/p/phamlp/downloads/list
3. Extract its contents to the phamlp folder you just created
4. Once you have installed/enabled the module you can visit admin/settings/sass where you can
configure various settings surrounding the behavior of this module.


copying out Hierarchical Select terms into other textboxes

You can use Drupal JavaScript API for setting the values of fields, based on selection made by user in Hierarchical Dropdown field.

The below sample code is for fixed number (3) of fields, you can further extend this to dynamically set the values of n number of fields using jQuery $.each().

(function($){
  Drupal.behaviors.exampleModule = {
    attach : function(context, settings) {
      // On hierarchy change event.
      $(".hierarchical-select .selects select").change(function(event) {
        updateFieldsValue();
      });

      function updateFieldsValue() {
        var First = $.trim($(".hierarchical-select .selects select[name='field_hierarchical_dropdown[und][hierarchical_select][selects][0]'] option:selected").text());
        var Second = $.trim($(".hierarchical-select .selects select[name='field_hierarchical_dropdown[und][hierarchical_select][selects][1]'] option:selected").text());
        var Third = $.trim($(".hierarchical-select .selects select[name='field_hierarchical_dropdown[und][hierarchical_select][selects][2]'] option:selected").text());

        // set value of Fields.
        $("input[name='field_prop_1[und][0][value]']").val(First);
        $("input[name='field_prop_2[und][0][value]']").val(Second);
        $("input[name='field_prop_3[und][0][value]']").val(Third);
      }

    }
  };
})(jQuery);

You can find more details about Drupal Behaviors on 'Better understanding of Drupal behaviors' and 'Understanding JavaScript behaviors in Drupal'.


It would really help to knowing how your data is saved (e.g. providing a snippet from your BlockBase::blockSubmit() implementation that shows this value), or what exactly you tried adding to your yml files.

However, in theory a working example that assumes, you are saving the value like this:

PmInboxBlock.php

/**
 * @Block(
 *   id = "pminbox",
 *   admin_label = @Translation("PmInbox"),
 *   category = @Translation("PmInbox"),
 * )
 */
class PmInboxBlock extends BlockBase {

  // ... Your Form definition here ...

  /**
   * {@inheritdoc}
   */
  public function blockSubmit($form, FormStateInterface $form_state) {
    $this->configuration['thread_count'] = $form_state->getValue('thread_count');
  }

}

Then you provide the schema definition in a schema file named after your module:

mymodule.schema.yml

block.settings.pminbox:
  type: block_settings
  label: 'PmInbox Block'
  mapping:
    thread_count:
      type: string
      label: 'Thread count'


How to autocomplete taxo term (inside a paragraph) when using a filter in a view

Why not try to define a relationship towards the field_ingredient_quantity and then add the field_ingredient in the fields of the view(should be available after defining the paragraph relationship). Afterwards just add the exposed filter with the autocomplete functionality.


Test if Anonymous users can sign up for a new account

If you look at the implementation of the login block in the core user module:

$items = array();
if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
  $items[] = l(t('Create new account'), 'user/register', array('attributes' =>
    array('title' => t('Create a new user account.'))));
}

you'll see that it queries a variable name user_register. If you disable anonymous registration, this becomes 0, and the link to "Create a new account" doesn't show.

This logic should work, no matter how you theme your site.

If your theme breaks this logic in the core user module, then you need to rework your theme until it don't break the core user module.

(Btw - this also tells you how to "test if Anonymous users are able to sign up for a new account" - check the status of the user_register variable, and if it is non-zero they should be able to sign up.  But this does not belong in your theme.  It belongs where it already is: In the core user module. I will advice against putting it in the theme.)


Panels default content when creating a new page

You want to create a new page by cloning (AKA copying) the one you've already made with all your content/layout/settings chosen.

Under admin/structure/pages, navigate to the Edit form for the page you've already created and would like to replicate (See screenshot).

Then, click on the Clone button on the top, right-hand menu of the page's Edit form (See screenshot).

Then just follow the wizard's instructions for cloning the page. Once you've cloned the page, you'll have a brand new page with all the same content, layout, and settings as the previous one.


As also WordPress is now moving towards modular content (codename Gutenberg) I'd advise you to do the same in Drupal with Paragraphs.

Then you can provide different paragraph types (image, text, CTA etc.), one of them could be a simple block reference (I don't remember if core already offers block reference fields or
if you need Block field for that) with which you let editors choose blocks to be placed wherever they want. (Paragraphs also are resortable.)

So, you already have your form, cool. Next level is to let your custom module provide a block that outputs this form. Next, In your theme add a new region "Disabled" (that never gets printed anywhere) and place your block there. Now this block will be available to choose as block reference. (I guess it's desired behavior that only blocks that are assigned to a region can be referenced.)

Bonus would be a little bit of back-end JS to only display certain blocks in the block reference select list. But that's just bonus.


Performance and javascript issue in a drupal 7 website

You could try advagg, but shoving cloudflare at the problem is usually easier, let them deal with the js complexity by converting it to rocketscript for you for free!

Or you could mention which modules you have, how many scripts you are attempting to load, whether they are asynchronous/deferred etc, what version of jQuery, perhaps even a link to the site itself so we can have a look?


Drupal 7 contexual filter display block based on node reference

Create a simple content view of readers add fields and add a contextual filter of field_book or whatever is the name of reference field and choose option "When the filter value is NOT in the URL" -> "Provide default value" -> "Content ID from URL" and save.


You should use node to display the product since commerce doesnot provide a product display page.

Then by replacing the title for that content type allows you to translate the product title.

To create product node page while creating the product in commerce form you can make use of inline node form provided by using Inline entity form module


How do I pass a response from a Webform custom handler back to Drupal to display on the confirmation page

Your two options are…

OPTION 1: Add the SOAP API's response value  as a hidden element's value using something like

$webform_submission->setElementData('response_value', $response->value);
$webform_submission->resave();

OPTION 1: Store the response in $_SESSION and use

\Drupal\webform\Plugin\WebformHandlerInterface::confirmForm
\Drupal\webform\Plugin\WebformHandlerInterface::preprocessConfirmation

to alter the confirmation message or page.


User login using a token or ID (no password)

If security's not a concern (and make sure it really isn't!) then you might as well do it the simplest way possible.

This would involve a small custom module that provides a path to log in users by their ID.

function MYMODULE_menu() {
  $items['insecure-login/%MYMODULE_insecure_login'] = array(
    'title' => 'Insecure login',
    'access callback' => TRUE, // Might as well be, no point in authenticating
    'page callback' => 'MYMODULE_insecure_login',
    'page arguments' => array(1)
  );

  return $items;
}

function MYMODULE_insecure_login_load($uid) {
  // Don't let user 1 login with this method
  if ($uid == 1) {
    return FALSE;
  }

  // Just return the user ID
  return $uid;
}

function MYMODULE_insecure_login($uid) {
  if ($account = user_load($uid)) {
    global $user;
    $user->uid = $uid;
    $user->name = $account->name;
    $user->timezone = $account->timezone;
    user_login_finalize();
    drupal_goto('user');
  }
}

Users will be able to login by visiting http://example.com/insecure-login/USER_ID

I've tested this and it worked, but it felt very wrong. The above code is just a proof of concept if you like, I can't really recommend that you use it.

Please, please double check your thinking before using any method like this; you're obviously aware of the security implications but I can't sign off this post in good conscience without encouraging you to think about it a little more ;)


Views: Return the nodes either side of current node

You can use Previous/Next API to get the previous and next nodes of particular nodes.
It also provides Views plugin to display Previous/Next links in View.


I need to use hooks without using theme and module

Yes, hooks must be implemented in a module or theme.

The only other options would be:

Hack at the core functionality until it does what you want. This is bad for many reasons.
Use the PHP filter module, and hope that it's compatible with the place(s) you need to inject your custom code. This is even worse than the first method.

Moral of the story:

Drupal provides hooks in themes and/or modules to extend its functionality.

If you need to extend Drupal's functionalality, use hooks in themes and/or modules.


dynamically fill a field with the value of a field in another node referenced with an entity reference field

You don't state much about your setup, so I am gonna presume you are using drupal 7. In that case I highly recommend using entityreferences. It replaces the former nodereference and userreference modules IMO. You can reference any entity with it. Also your custom CTs (Client, Contact, Job.)

When you create a reference field you have to option to use a 'simple' selection which indeed gives you ALL content of a certain type. But you can also choose to use a custom made view for the selection.

Using a contextual filter (which you can pass along in the entityreference field settings) you can filter the view down to exactly what you want.
It's brilliant, try it!


It sounds like you might have another module also implementing that path.

To check, install the Devel module (if you haven't already), and go to /devel/php. Put in this code:

foreach (module_implements('menu') as $module) {
  $items = module_invoke($module, 'menu');
  if (isset($items['sitemap'])) {
    print $module;
  }
}

And submit the form. If another module is directly responsible for the /sitemap path (i.e. it's not a redirect or something else), its name will be printed to the screen.


Render/display Panel's page outside 'content'

I think you need to use mini panels, mini panels shiped with panel module and you can use it as block, any mini panels you create will be listed under blocks, just assign it to the region you want


HTML requests return headers, that tell what the response will be, and the body, that is the response. The headers are required by browsers to understand how to interpret the data that is in the body, therefore no output must be sent before the headers. This error is outputted when headers are sent after some body output has been sent. When working on a Drupal system, there are three common causes to this error that you can debug:

An echo statement in a module/theme (and not in a template). Sometimes developers will echo out a value for debugging purposes, and forget to remove that line.

Blank space before the opening <?php tag in a document on the system. This is usually in a custom module or theme, or can be in settings.php, or settings.local.php.

A closing `?>' tag, with whitespace after it. Drupal coding standards are to not use the closing php tag, so if you find this anywhere outside of a template, you can probably remove the closing tag. At the very least, you should ensure there is NO whitespace after the tag.


You have a typo in one of the permissions. It should be “administration”. Permissions itself is also spelled incorrectly.

Please refer to the official docs for creating routes and links. YouTube videos may be out of date.


Hope this will help you,

In Drupal 7, you can achieve this using form_load_include OR require_once

Try form_load_include() OR require_once() in your form alter.

function test_form_alter(&$form, &$form_state, $form_id) {
 switch ($form_id) {
    case 'simplenews_block_form_ID'://add your form_id
        require_once(DRUPAL_ROOT . "/modules/contrib/simplenews/includes/simplenews.subscription");
        //OR
        form_load_include($form_state, 'inc', 'simplenews', 'includes/simplenews.subscription');
    break;
   }
}

Reference


Unable to upload video files in drupal 7 with the video module

According to your error, you need to have CURL installed.

If you're running a mac:
http://www.davidonzo.com/lng/en/post/986/php-mac-os-x-how-to-install-the-curl-library/

If you're running linux:
type in the command line - "apt-get install curl"

If you're running WAMP on Windows:
click the WAMP icon in task tray, then go to PHP > PHP Extensions > php_curl. Then restart apache.


How to access past DrupalCon website that requires password?

The reason they're password-protected is due to a critical security vulnerability in the version of Webform run on those sites. There's an open issue about it, and only the DrupalCon sites updated to a secure version of Webform are allowed to remain up.

In order to gain access to the ones that are still in lockdown, I'd comment on that issue to see what you can do to help get them updated. Otherwise, you can use the Internet Wayback Machine to access Archive.org's cached copy.


Live content migration to a separate server for important content

With the Backup & Migrate module installed, navigate to: /admin/config/development/backup_migrate/schedule to create & manage database or site file backup schedules:

Note that there are options to backup the default Drupal database, all of the site files, or just specific Drupal file directories.

Under "Settings" there is an admin section to configure the destination address for the backups at: /admin/config/development/backup_migrate/settings/destination

Schedule a complete site backup daily with hourly database backups. The Backup & Migrate developers have the NodeSquirrel service available for offsite backups - but this service only works with the D7 module & is unavailable for D8 currently.

With cPanel, there are better options available now with cPanel Backups & Backup Tool:

If you need a more professional backup service, look into Veeam.


Use twig to style a specific block (unformated list)

Not sure to understand what you mean...

Do you want to customize the fields that appear in your block?? If so, Drupal normally provides you with available twig hooks you could use. Yours would probably be field.html.twig.

Exemple : you can customize a menu with menu.html.twig and then customize the links in that menu with links.html.twig


Create a CSV file dump/feed whenever item of Content Type A is created

Look at Views Data Export. It can create a CSV from Node content.

It sounds like you need this to somehow be recurring over time ... this is a tall order and so I wont be providing much code, but will outline a possible solution:

Implement hook_cron_queue_info(). This is a cron task that runs off of a custom Queue. You can insert a NID every time a node is created into a custom queue you've created named MyCSVQueue. Every time a node is created it gets added to this queue -- when you process the queue you create individual csv files.
Use either hook_node_insert or Rules to place the NID into the work queue.
In your queue worker function you pass the NID to a custom view that uses a contextual filter to load the NID. Or, you may be able to use node_export to create the CSV data as well. You then simply use the Drupal File API and file_save() to store the csv file somewhere in your public/private drupal filesystem.

If the default Cron options of drupal dont suite your needs look at Ultimate Cron

EDIT

A slightly easier alternative:

Use:

Use either hook_node_insert or Rules to run a snippet of custom PHP code. Simply create a file directory using the File API in public files as: %files/csv_node_exports/MM-DD-YYYY. Your snippet can create the directory if it doesnt exist today yet.
then just export the node data to a CSV file. You may or may not have a NID yet ... you could always update the filename after the fact to reflect the actual NID assigned to the node.


assuming that you are talking about the 'edit form', you can use css to control the visibility of these fields in this way:

/*---------------------------this rule is to hide the text"maximum file size"and "allowed extensions"*/
div#edit-field-cl-namefiled-upload-wrapper div#edit-field-namefiled-upload-wrapper div.description{
display:none;
}

/*---------------------------this rule is to move your descriptionnear to the field to upload.here you can add the "allowed extensions.." text*/
div#edit-field-namefiled-upload-wrapper > div.description{
margin-top:-70px;
position:absolute;
}


Exposed filter only allowing content types in list

OK, I figured it out.

I simply added a duplicate of my "Content type" filter, except this filter is not exposed. Same settings as above ("Is one of", Article/Post/Story, etc.), just an extra restriction on the results to always filter by all of the desired content types, with the exposed filter being an additional option to further narrow down the results.


How do I install a 3rd party PHP library in sites/all/libraries - can
  I just plonk it in there?

Answer:
- It would appear you can, in some cases at least. With the example given the question, the problem was not whether or not a 3rd party php library could be just placed in the libraries folder, but rather some other unrelated issues that appear now to be resolved (the s3fs module make, coredumperror was very responsive today in helping me and they have updated their documentation). https://www.drupal.org/node/2596683#comment-10467823

Update

The "unrelated issues that appear now to be resolved" are that one of the setup procedures for the s3fs, as described in the README.txt, now work. By 'now work', I mean that I can install the module and do the described setup and use the S3fsStreamWrapper class provided with the module to read a file from an Amazon S3 bucket, more detail here https://www.drupal.org/node/2596683#comment-10467823 I had tried other approaches to reading S3 in Drupal, e.g. using examples elsewhere but was unsuccessful with those. But with this s3fs module I am now successful. With the s3fs module I had originally ran into issues whereby I got the aforementioned "Unable to load the AWS SDK. Please ensure that the awssdk2 library is installed correctly." error as stated in my question. But one of the maintainers of s3fs, coredumperror replied and updated the documentation as they discovered it had errors. So thanks very much to coredumperror on that, most appreciated. They have described what they changed in the above link. With this setup documentation updated and corrected, I was then able to use the s3fs module and read from a S3 file using the S3fsStreamWrapper provided with the module.


Why don't external JS files load on mobile site built with jquerymobile/JQM?

The problem turned out to be that a call to the in_array() function in the jquerymobile module did not use the optional third parameter for strict type comparison, so array keys that were strings were getting cast to the integer zero when compared to another zero, and returning true.

The fix was to add the TRUE parameter to the call to in_array.

Here is a quick sample that proves the problem:

<?php

$haystack = array('foo', 'bar', 'baz', 'bat');

$needle = 0;

$test = in_array($needle, $haystack); // same as in_array($needle, $haystack, FALSE)

var_dump($test); // bool(true)

$test2 = in_array($needle, $haystack, TRUE);

var_dump($test2); // bool(false)

?>

Patch file is uploaded on the drupal.org issue.


How to organise content using public, private and semi-private groups?

The Group module allows for creating arbitrary collections of your content and users on your site, and grant access control permissions on those collections. It is available as of D7, and has a D8 version also. It is designed to be an alternative to Organic Groups. The Group module creates groups as entities, making them fully fieldable, extensible and exportable.

For this specific question, you'd enable the gnode submodule, and for each group type you would define the appropriate permissions (view, edit, delete, etc) for the various Content Types. That's it.

For more details about the various types of roles used by the Group module, refer to my answer to "What are the various roles supported by the Group module?".

Resources

Community documentation for the Group module.
Video tutorial "How to use the Group module in Drupal 8 to manage editorial access control to different areas of a web site".


How to replace a string in a URL field when outputting it in a template file

You probably want a preprocess function in your template.php for this. In your case, hook_preprocess_field() will be easiest to work with - for an example of how this is implemented, check out the API documentation for template_preprocess_field().

Remember, $variables is passed into preprocess hooks by reference. From within your hook_preprocess_field(), instead of modifying the field data directly (in case you need it elsewhere), you could do something like this after checking that you're operating on the right field:

/* devel's dpr() is handy for seeing where in the $variables array it lives if you
   don't have a debugger handy. If you see 'und', that's the value for the LANGUAGE_NONE
   constant. It's considered best practice to use the constant instead. */
$slave_link = $variables['field_url'][LANGUAGE_NONE][0]['value'];
$slave_link = str_replace("http://", '', $slave_link); // Trim http://
$slave_link = str_replace("master", "slave", $slave_link); // s/master/slave
$variables['slave_link'] = $slave_link;  /* You can now access this variable from your
                                            field--field_url.tpl.php as $slave_link */

You may also need to clear your cache after making these changes.


How to run alter query to modify mysql database using hook_schema?

Changes to the schema are typically handled with hook_update_N and you will normally locate this file in the module.install file.

For example with the update from Drupal 6.x-7.x the some of the base permissions were rename:

/**
 * Rename blog and forum permissions to be consistent with other content types.
 */
function system_update_7000() {
  $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
  foreach ($result as $role) {
    $renamed_permission = $role->perm;
    $renamed_permission = preg_replace('/(?<=^|,\ )create\ blog\ entries(?=,|$)/', 'create blog content', $renamed_permission);
    $renamed_permission = preg_replace('/(?<=^|,\ )edit\ own\ blog\ entries(?=,|$)/', 'edit own blog content', $renamed_permission);
    $renamed_permission = preg_replace('/(?<=^|,\ )edit\ any\ blog\ entry(?=,|$)/', 'edit any blog content', $renamed_permission);
    $renamed_permission = preg_replace('/(?<=^|,\ )delete\ own\ blog\ entries(?=,|$)/', 'delete own blog content', $renamed_permission);
    $renamed_permission = preg_replace('/(?<=^|,\ )delete\ any\ blog\ entry(?=,|$)/', 'delete any blog content', $renamed_permission);

    $renamed_permission = preg_replace('/(?<=^|,\ )create\ forum\ topics(?=,|$)/', 'create forum content', $renamed_permission);
    $renamed_permission = preg_replace('/(?<=^|,\ )delete\ any\ forum\ topic(?=,|$)/', 'delete any forum content', $renamed_permission);
    $renamed_permission = preg_replace('/(?<=^|,\ )delete\ own\ forum\ topics(?=,|$)/', 'delete own forum content', $renamed_permission);
    $renamed_permission = preg_replace('/(?<=^|,\ )edit\ any\ forum\ topic(?=,|$)/', 'edit any forum content', $renamed_permission);
    $renamed_permission = preg_replace('/(?<=^|,\ )edit\ own\ forum\ topics(?=,|$)/', 'edit own forum content', $renamed_permission);

    if ($renamed_permission != $role->perm) {
      db_update('permission')
        ->fields(array('perm' => $renamed_permission))
        ->condition('rid', $role->rid)
        ->execute();
    }
  }
}


Display a block only if another specified block isn't visible?

I was able to do this with panels, view blocks and a custom PHP visibility condition.  I think Panels is trivia.  You could do this with Drupal's built-in block administration.

I had a news block that would show up on the city page.  It would display all the news of the city.  If there was no news for that city, it would display [another] news block for that state.  If there was no news for that state, it would display [another] news block for the country.

Each of these block was a view.   In the PHP visibilty I would check for views results using the views_get_view_result($name, $dispay_id = NULL [, $args])

So the county block would check if the state and city block view returned any results,  if FALSE (no results) then it would get displayed.  State would check if city block view return any results, if FALSE (no results) then it would get display.

If you blocks are not views, then I don't know how to solve the problem easily (unless the last block is the only one that is not).


Splitting existing feature into several smaller. Safe?

Direct Answer
If you take the appropriate precautions, and test locally first, it should be safe to break up the feature.
Background
If you want to split the big feature up, you need to make ensure that disabling the features does not affect the configuration of your site. Then you can disable the feature and use features to carve up the config differently and export as smaller component features.
I understand your point that one big feature is not that useful, as the individual components are not then transferable via features to other sites (or from dev to production), which is one of the uses of features.
I agree with letharion that it makes much more sense to divide your features along the lines of functionality (eg blog, gallery) rather than along modular lines (eg views, fields) otherwise all of your features will be interconnected anyway, in that disabling one will break dependent functionailty on the site. For example if I export a content type in one feature, and a view using that content type in another, then I would have to declare that the views feature is dependent on the content type feature. Functional features are also easier to document sensibly in version control.
Method
I have taken solution from my own previous comment on d.o
You can use the Features Tools module to disable a module while leaving functionality in place. You can then re-export your config as smaller features.

First BACKUP YOUR DATABASE
backup your feature (files) if you would like to use it again.
Install Features Tools, go to the 'recreate' page for a feature, uncheck all of the features components
Now click on the 'Safe autocreate' button to recreate and replace the feature with an empty version.

You can now disable the module without affecting your site configuration.
These instructions are for D7, if you are using D6 there is an extra step.
See ftools project for more complete documentation.
http://drupal.org/project/ftools
PS - unchecking all the boxes in the features ui is much quicker if you install a browser plugin like check all first.


How to integrate content type to webform Drupal 7?

Tvphong, I think that the best way to go about doing this is by using a custom module so that you can then integrate that content type within the select list of preloaded options.

Perhaps this link can serve you well in this.

What I ended up doing is a slight tweak of this. So my custom module looks something like this (which is for location content types):

<?php

/**
 * Reference:  http://eureka.ykyuen.info/2012/04/11/drupal-7-dynamic-select-options-for-webform/
 * The following piece of code is based on the blog post above
 */
function webform_options_webform_select_options_info() {
 $items = array();

 if (function_exists('get_location_titles')) {
  $items['location_titles'] = array(
    'title' => t('Location titles'),
    'options callback' => '_get_location_titles',
    );
 }

 return $items;
}

function _get_location_titles() {
 $options = array();
 $type = "location";

 $result = db_query('SELECT nid, title FROM {node} n WHERE n.type = :tname', array(':tname' => $type));
 foreach ($result as $row) {
  $options[$row->nid] = $row->title;
 }
 return $options;
}


It's actually easier than you think :)

You can access a $form_state['triggering_element'] in your ajax callback function.

Something like this:

function my_ajax_callback($form, $form_state) {
  $ps = &$form_state['triggering_element']['#parents'];
  $k = $ps[2]; // field collection row number
  $collection = $form[$ps[0]][$ps[1]][$ps[2]];
  $element = $ps[3];
  ...

that was the snippet to access a changed textfield inside a field collection with multiple rows. Just adopt it for your particular form structure.


Render value of custom content type in html.html.twig

Load the node and get the field value in a preprocess hook:

function mytheme_preprocess_html(&$variables) {
  if ($variables['node_type'] == 'book' && ($node = \Drupal::routeMatch()->getParameter('node'))) {
    $variables['node_field1'] = $node->field_field1->value;
  }
}

This makes sense to check first for the correct content type, because then you know which fields are defined. Otherwise you would have to check if the field is present to prevent an error. But then you have already loaded the node for nothing.

Output the value in twig:

{{ node_field1 }}


How to give users with role Role2 the right to edit only user accounts with role Role1

You may want to try Administer Users by Role module.

  This module allows site builders to set up fine-grained permissions
  for allowing "sub-admin" users to edit and delete other users — more
  specific than Drupal Core's all-or-nothing 'administer users'
  permission. It also provides and enforces a 'create users' permission.

One of the extra permissions that this module provides is

Edit users with custom roles - Allows editing of any authenticated user with the specified role.


How to add a slideshow inside a node with Slick?

The problem comes from an incompatibility from the theme I use, Zircon, with Slick carousel.
The full explanation and the solution can be found here : https://www.drupal.org/node/2875173#comment-12075392

In brief, the solution is to comment the following lines in zircon.libraries.yml with the # sign :

# assets/includes/slick/slick/slick.js: {}
assets/includes/bootstrap/js/bootstrap.js: {}
assets/includes/flexslider/jquery.flexslider.js: {}
assets/includes/flexslider/jquery.flexslider-min.js: {}
assets/js/slideshow.js: {}
# assets/js/carousel.js: {}

This file is in /themes/zircon/ folder


Translate Entity Permission per Content Type

It won't be possible unless you write the code yourself or find someone willing to code it.

This feature request is now Closed (won't fix)


Media module browser iframe opens with wrong domain

This ended up being caused by a custom module we had on the site that performed url inbound and outbound alters to direct certain node types, paths etc. to certain domains. All we needed to do was add an exception to the handling for media paths.


You just need to copy this folder generated by Features into your /sites/all/modules/features directory. A feature is a module, you'll need to enable this feature on your new site to retrieve all the functionnalities.

You'll probably need to take a close look at the documentation for Drupal 7 https://www.drupal.org/docs/7/modules/features to achieve this correctly.


IMHO, I'd like to use Drupal AJAX API instead of jQuery AJAX because it supports many commands, events and content are manageable, error control and event binding for new content, those features are supported by Drupal.

But the disadvantage is it sends too much data, process is more complicated, using POST all the times. But of course, at javascript level, we can override the default behaviors and make it better :)

For example, If you have any ajax errors, like ajax request is running and you change document location, you will see an alert box with error message. That's a bit annoying so I always override it by re-write this function in my theme

Drupal.ajax.prototype.error

About your working process, I have some comments

1 & 2: It's ok for me, but why do you need to use another copy of ajax_deliver(), why don't you use it directly?
3: Are you going to write another thing like Drupal.ajax or just attach new function to Drupal.ajax? something like

Drupal.ajax.prototype.commands.log = function (ajax, response) {
    console.log(response);
};

Drupal.ajax.prototype.commands.open_popup = function (ajax, response) {
    var id      = typeof response.id      === 'string' ? response.id : 'gfc';
    var content = typeof response.content === 'string' ? response.content : '';
    var options = typeof response.options === 'object' ? response.options : {};

    Gfc.popup.open(id, content, options);
};

I'm ok if you do like that.
4: Yes of course
5: Errr, are you going to write something new instead if using Drupal.ajax?


Add option values to field that already has data

You should use taxonomy to create a vocabulary named Category and add terms to it. Then add a taxonomy term reference field to your content type.


How can I make special non-Drupal URLs without file extensions?

If the file exists serve it.

  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}\.html -s
  RewriteRule .* %{REQUEST_URI}\.html [L,T=text/html]

You'll need to put it above this inside your .htaccess file.

  # Pass all requests not referring directly to files in the filesystem to
  # index.php. Clean URLs are handled in drupal_environment_initialize().
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]

You can't pass the request back to apache once you've passed it to Drupal. The code above will hit the .html file first if it exists.

To do exactly what you want, you can set the 404 handler inside of drupal to a custom page; that page could then check to see if the file exists and use that. Config page for 404: admin/config/system/site-information. The handler would use something like this

<?php
$path = substr(request_uri(), strlen($GLOBALS['base_path'])) . '.html';
if (file_exists($path)) {
  echo file_get_contents($path);
  exit;
}
return MENU_NOT_FOUND;
// OR this, not sure.
return drupal_not_found();
?>


For those that might have a similar issue (having one node with 2 relationships and all other nodes in the view have 1 relationship to display) I found that by displaying the node teaser instead of just the field, I can get the information I need.


Is there a "best practice" for overriding a contributed module's controller in Drupal 8?

To avoid conflicts with other modules you could alter the controller content in a kernel VIEW event similar to a form alter hook:

src/EventSubscriber/ControllerAlterSubscriber.php:

namespace Drupal\mymodule\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
 * Class ControllerAlterSubscriber.
 */
class ControllerAlterSubscriber implements EventSubscriberInterface {

  /**
   * Alters the controller output.
   */
  public function onView(GetResponseForControllerResultEvent $event) {
    $request = $event->getRequest();
    $route = $request->attributes->get('_route');

    if ($route == 'entity.webform_submission.collection') {
      $build = $event->getControllerResult();
      if (is_array($build)) {
        // alter controller build array
        $build['added_content'] = ['#markup' => '
Added by ControllerAlterSubscriber.
'];

        $event->setControllerResult($build);
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {
    // priority > 0 so that it runs before the controller output
    // is rendered by \Drupal\Core\EventSubscriber\MainContentViewSubscriber
    $events[KernelEvents::VIEW][] = ['onView', 50];
    return $events;
  }

}

mymodule.services.yml:

services:
  mymodule.controller_alter:
    class: Drupal\mymodule\EventSubscriber\ControllerAlterSubscriber
    arguments: []
    tags:
      - { name: event_subscriber }


How can I programmatically remove the file from a managed_file form element?

hook_field_widget_form_alter(&$element, &$form_state, $context)

this may help you to validate your file and if validation criteria fails return empty form element.


How to preprocess group title render in views?

If you want to change the template for the title of the group, why don't you override the template file views-view-grouping.tpl.php for Drupal 7, or views-view-grouping.html.twig for Drupal 8.

By standard Drupal templates names, overrides are also working with this one.

views-view-grouping--MACHINEVIEWNAME.tpl.php for a specific view

views-view-grouping--MACHINEVIEWNAME--MACHINEDISPLAYNAME.tpl.php for a specific display of a specific view.

Hope this can help you.


Views filter referenced content when end date is over

I'm not so sure this is possible through the views interface. But, you can easily do this through your theme layer.

In your view admin area, under advanced there's the page: Theming information. Clicking on that will give you a list of available tpl.php names that can be used to create your own tpl.php files that can be added to your theme. Your probably gonna wanna use a row style output. The list of those files go from general to specific, so the last time will only be applied to your view. Clicking on the link of row style will give you the content of the default file.

All you would need to do is just print the fields as normal, with the exception of the fields you want to exclude. Just use a standard if to check to make sure they're still valid, if not, don't print them.


Views relationship working back from a content type

If I have understand your problem, you want display a list of "Curriculum" and inside each "Curriculum" show all observation of this item (like your second screen).

If you aren't blocked by add some module to your project, you can try "views_field_view".

In your View, you create a first display who list all your "Observations" filtred by "Curriculum" nid (like your second screen).

Then, you create a second display who list all your "Curriculum" with a View field who use the first display.


Different node / entity templates based on display type

I'll go with this solution after all:

function MYMODULE_preprocess_node(&$vars) {
  $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__' . $vars['view_mode'];
}


Route that renders a node has title of route rather than node title

As it is routing path, Drupal will always look for the title in routing.yml, if you want to set title for this you can do as follows,

$build['#attached']['html_head'][] = [
    [
      '#tag' => 'title',
      '#value' => "Node title"
    ],
    'title'
  ];

OR

$build['#title'] = 'Node Title';

Here you can replace "Node Title" with your dynamic node titles.


no description and image title in insert module

Solution
Enable the insert in content type.
admin/content/node-type/news/fields/field_image2


It is not clear what exactly you are asking.

@Cottser's answer is correct for disabling the render cache during development but that is not something you want to do on a production site as the render caching critical for performance. Also, when disabling the render cache locally, make sure to always test changes on the same configuration as production to catch problems with it.

If the markup you are outputting is dynamic on something, then you can add that context to the cache key, see my answer in https://drupal.stackexchange.com/a/140777/31.

If it is about clearing the cache after the user changes settings, you can clear the node_view cache tag with Drupal::entityManager()->getViewBuilder('node')->resetCache(). If you want to clear the cache of a specific tag, you can pass the node ID to that method or you can use \Drupal\Core\Cache\Cache::invalidateTags($node->getCacheTags()).

Each thing that is rendered has one or multiple cache tags (inspect the X-Drupal-Cache-Tags header of a page response, I'm sure there will be development tools to better understand them in the future), by invalidating them, you can automatically clear all caches that contain them.


How to access all images uri in node's field in custom module?

You can try this code:

$img_urls = array();
foreach ($node->field_image as $item) {
  if ($item->entity) {
    $img_urls[] = $item->entity->url();
  }
}

Then all field_image image urls available in $img_urls variable.


Different attribute selection widget in a view

Since the field definition isn't context sensitive (i.e. it can't have one value on a standalone page and another on a View for that setting), you're going to have to do this yourself via a form alter. Just be mindful that the options array for radio buttons / select lists are treated differently with respect to sanitization when formatted for display.


Image field - Cant set up number of values

If you're using the same image field on two content types then the cardinality (number of values) will be the same across both.

You'll notice you have 'instance' settings and 'field' settings on the field edit form. The 'instance' settings are unique to that instance, and can be different for each entity type/bundle the field is attached to.

The 'field' settings are global to that field, and the cardinality is one of these global field settings. If you change it for one content type, it will automatically change for the other content type. The caveat to this is that if you have data in the database for those fields already, you might not be able to change the cardinality at all (the select list will be greyed out).

This is by design, and how the field system works (there's no way around it). If you need to have two fields on two different content types with different cardinalities, you need to create two separate fields.


I had the same issue and finally I just manually did it in hook_uninstall(), I could find no other recourse.

function mymodule_uninstall() {
  $table_name = 'mytable';
  if (db_table_exists($table_name)) {
    db_drop_table($table_name);
  }
}

Hope this saves someone else some time.


The Interval Field module looks like it would do the trick.

Interval field gives you a simple field and widget to allow users to enter interval values eg

2 months
3 days
4 years


There is a work around using Page Manager Existing Pages (as suggested by Letharion) and hook_menu().

hook_menu() was required as Profile2 doesn't seem to register profile pages with the menu router. This was preventing Page Manager Existing Pages from being able to intercept the page.

function MYMODULE_menu() {
    $items['profile-example'] = array(
        'page callback' => '_profile2_form',
        'page arguments' => array(),
        'access callback' => TRUE,
        'type' => MENU_CALLBACK,
    );
    return $items;
}

function _profile2_form() {
    global $user;
    module_load_include('inc', 'profile2_page', 'profile2_page');
    $profile2 = profile2_by_uid_load($user->uid, 'profile2_profile_system_name_goes_here');
    $entity_form = entity_ui_get_form('profile2', $profile2, 'edit');
    return $entity_form;
}

This can now be intercepted by Page Manager Existing Pages and properly displayed by the Panels module.


How to do taxonomy based css styling using template.php?

The reason it is not called is because hook_preprocess_variables is for Drupal 5: you should use hook template_preprocess_page in Drupal 6.

So if your theme is called "mytheme", the function would be best named "mytheme_preprocess_page" in your template.php.

Also, Drupal and the Taxonomy modules already generate many body classes, so you should check out what classes already exist because it may be that you don't need to preprocess the page at all (if all you want is to add a body class depending on taxonomy).


select list - content outputs key instead of label

Go to the display settings for your content type, and look at the display formatter for the field. it should be set to Default. The other option is Key.


View published content to anonymous users front page only

As long as they don't have permission to view content, and as long as your template file(s) say print render($page['content']) then they should be denied access.

However, you could do something like this:

Make a custom template file called page--front.tpl.php inside your theme's folder
Copy the contents of page.tpl.php to that file
Alter the new page--front.tpl.php file so that it either doesn't render any content anywhere (including the sidebars), or make it so it only renders the content to logged in users.

Example:

<?php if (user_is_anonymous()): ?>
  <?php print t('Hello. This is where you would normally see content.'); ?>
<?php else: ?>
  <?php print render($page['content']); ?>
<?php endif; ?>


For a no-code solution try the page title module, which allows you to override page titles all over the site, with the use of tokens to improve flexibility.


What code should .htaccess of files directory hold in drupal 7.25?

The .htaccess you show is correct - it is actually the default .htaccess that Drupal versions above 7.24 (including the current 7.28) will generate for the files directory if the .htaccess file is missing.

In other words, the warning you get from Security Review is a false postive. There is no malicious alteration.

Your issue is a known bug with Security Review that has already been raised in the module's issue queue at Drupal.org. There is a also a patch that is supposed to fix this issue in the module's issue queue.

You may help the community by applying and reviewing this patch.


Create send user private message link in a node template content type

Assuming you want to create a link to the author, you should be able to create a simple link in the template
 - Field that links to a path/url defined with Tokens, is it possible?

It would follow something like: http://www.example.com/messages/new/[node:author]

You can see a list of tokens here: https://drupal.org/node/390482#token-node


Is there a way to get all values for a particular node?

You can use node_load() function.

eg:

 $node = node_load(nid); //you will get all fields values of particular node
 print_r($node);


Is there a way to partially rebuild the router or invalidate a route cache?

Instead of \Drupal::service('router.builder')->rebuild() you can invalidate route matches:
Cache::invalidateTags(['route_match']);

You don't need to rebuild the router table, because the static routes don't change. What you need to clear are route matches, which are calculated on the processed path and then stored for the unprocessed path. And this is the relation which changes in your case.
The router builder invalidates the route matches because after a route rebuild there might be routes missing which are still in route match collections.
To be more selective you can add a second cache tag for the frontpage in RouteProvider::getRouteCollectionForRequest and then only invalidate this tag.
Of course you also need to invalidate entries of the front page stored in page caches, but the front page has probably already a specific cache tag you can target.


In Drupal 8 configuration is also stored in files, so you can commit it to git and have a full log. As far as I know there is no mechanism to record all actions of users in any version of Drupal.

If you insist, you can implement hook_form_submit() for every form and add additional save function to record who, when and what, but it will be hard to use log created this way.

Other approach is to use Features - let them develop their parts on their copies and just send you packages with working pieces.


Exposed filters and contextual taxonomy description

You may use tokens (replacement patterns). If you add the term description in your fields and exclude it from display, you will have access to [description] token in a Global: Text area, for example, added in the view header. Then, if you check Use replacement tokens from the first row and set your exposed form style on Input required, when a category is selected, results will be filtered and the term description related to this category will be displayed in the header.

EDIT : for Drupal 8 (sorry, still more a "7 guy" ^^), the token follows Twig syntax : {{description_value}}


Is it possible to add custom stylesheets while using a core theme?

You can use context and context add assets to get the job done. If you are not familiar with context it's a way to set reaction blocks, theme HTML, theme pages, menus, etc based on conditions on menu items, paths, node types, taxonomy terms, etc. You can include a custom css file on your form with context add assets.


Custom submit handler on node form not picked up

Have a look on those form elements in the form array. They might have their own ['#submit'] in the array and you might need to add your custom handler on those too


How to get achievements notification popup for Ajax Callbacks?

Here is another try at this (various assumptions follow):

The whole thing should run through the Wall module's code, since this is the base for any other interaction happening.
By means of the Form API and AJAX callbacks, there is a possible entry point. This is to wrap the submit callback for the _drupal_wall_comment_post_form into another callback that will make sure the Achievements' related elements are updated.
The steps in this process would be:

Use hook_form_alter to modify _drupal_wall_comment_post_form
Modify _drupal_wall_comment_post_form by hijacking the ajax callback for the wall comment submissions:
$form['drupal_wall_submit']['#ajax']['callback'] =>_your_custom_wall_ajax_callback
Wrap the original callback in your ajax callback and extend it to trigger the Achievements popup functionality using the Ajax framework commands family:

function _your_custom_wall_ajax_callback($form, $form_state) {
  $wall_wrapper = $form['drupal_wall_submit']['#ajax']['wrapper'];
  $wall_content = _drupal_wall_comment_ajax_form_post($form, $form_state);
  $commands = array();
  $commands[] = ajax_command_replace($wall_wrapper, $wall_content);

  // This is where you can write ajax commands to trigger Achievements functionality
  $commands[] = ajax_command_*();

  return array('#type' => 'ajax', '#commands' => $commands);
}

Hope this brings you a step further!


How does an entity get printed into a page after going though the page callback function?

You should pass the array of fully-loaded entity objects to the entity_view function, not only the id.

For example:

...
$entity = entity_load('example_task', array($task);
return entity_view('example_task', $entity, 'full');


PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'fmotors_fms.block_node_type' doesn't exist:

If it was working last night, and now it doesn't and the table is missing, then the table has been deleted/renamed, or the database is partially corrupted. There isn't any other logical explanation.

As you rightly say that table is installed, unconditionally, by the node module upon installation of Drupal (see node_schema()).

If the table is really gone then your only option is to restore the DB from a backup; or if there was no data in that table, just manually create it (or copy from another Drupal install).


Drupal version control - professional development

If you've got a complex setup, you may want to look into the Aegir project, which is a Drupal-based tool for managing Drupal site installations.

If your needs aren't big enough to require Aegir, a lot of the tasks which it does can also be automated using Drush, which is a command-line tool for managing a Drupal site.

Even if you feel Aegir is overkill, you should definitely use Drush - it will make your life a lot easier when it comes to deployment between your development and live versions and management thereafter.

As for version control: If you're writing any of your own code, then yes, you should be using version control. If you're simply using Drupal plus third-party modules, then you probably don't need it, since you're not in charge of the code anyway. But you might find it useful nonetheless, because there's always a chance you might find yourself needing to tweak a third party module (or even the core) to get things to work the way you need to, and at that point you will need version control, and it will help if you already have it set up.

You can't very easily do version control on your site content, because it's all in the Drupal database. You can do a certain amount by moving your site structure from database to code using the Features module, at which point it becomes possible to version control it in the same way as other code, but your actual content remains in the database.

To do version control on content, the main option you have is the Diff module, which allows the database to store multiple versions of page content, which can then be administered.

Hope that helps.


Cloning nodes between multisite instances with separate databases

I wouldn't use the approach you used. Here is my recommendation.

First, define your database connection to each multisite on the default setting.php with different name, check the example below:

#Default site

$databases['default']['default'] = array (
  'database' => 'dbname',
  'username' => 'uname',
  'password' => 'password',
  'prefix' => '',
  'host' => 'host',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

#Site 1
$databases['site1']['default'] = array (
  'database' => 'dbname',
  'username' => 'uname',
  'password' => 'password',
  'prefix' => '',
  'host' => 'host',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

#Site 2
$databases['site2']['default'] = array (
  'database' => 'dbname',
  'username' => 'uname',
  'password' => 'password',
  'prefix' => '',
  'host' => 'host',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

Now, on hook_node_insert you can save the node object to multiple databases by changing the database each time, refer the code below as an example:

// Switch to site 1 database
\Drupal\Core\Database\Database::setActiveConnection('site1');
//$node will have all fields you need
$site1Node = Node::create([
    'type'        => $node->getType();,
    'title'       => $node->getTitle();,
    'body_text'   => $node->get('body')->value,
]);
$site1Node->save();
// Switch to site 2 database
\Drupal\Core\Database\Database::setActiveConnection('site2');

$site2Node = Node::create([
    'type'        => $node->getType();,
    'title'       => $node->getTitle();,
    'body_text'   => $node->get('body')->value,
]);
$site2Node->save();

// finnally make sure to swich back to default datyabase
\Drupal\Core\Database\Database::setActiveConnection();


Alternatives to Commerce Coupon / Discount

Both of those modules have caused me headaches, however I know of no alternative.

In order to fix the bug you need to ideally step through Commerce Coupon and Commerce Discount's implementation of commerce_cart_order_refresh and commerce_cart_line_item_refresh.

Line items kept getting deleted for me when they didn't have a properly formatted price.

By implementing my own commerce_cart_line_item_refresh I was able to fix any problems with line items before their code ran.

If I was to do a discount / coupon system again and the spec was not too complex I would be tempted to write something from scratch as both of those modules are suffering from a bit of bloat.


Download development releases of modules with Drush Make

I tried generating a Drush make file with http://drushmake.me/, and the generated file contained the following lines.

projects[jquery_ui][version] = 1.x-dev
projects[jquery_ui][type] = "module"
projects[libraries][version] = 2.1
projects[libraries][type] = "module"
projects[xmlsitemap][version] = 2.0-rc2
projects[xmlsitemap][type] = "module"

I think that in your case you should use the following lines.

projects[better_exposed_filters][version] = 3.x-dev
projects[better_exposed_filters][type] = "module"

That would select the development snapshot for 3.x; in the case you want to select the 7.x-3.0-beta3 version, then you should use the following lines.

projects[better_exposed_filters][version] = 3.0-beta3
projects[better_exposed_filters][type] = "module"

The make file needs to contain the following line, which select Drupal 7 as Drupal version to use. This alters the version used for the modules; for example, the following line used with the latter lines I shown, would pick-up version 7.3.0-beta3 of the Better Exposed Filters module.

projects[drupal][version] = 7


Generate automatic URL alias removing words

With just the Path module you can only edit each alias one by one manually.

If you want more control than the Path module allows you can use the Pathauto module. That module has a setting listing all words to exclude from the generated paths. Delete the of and a from that list if that is what you need. There are also options about how to deal with many special characters under Punctuation settings.

Be very careful with the # since it has meaning in URLs, it denotes an ID of an anchor on that page.


how to set up a user field that the only the administrator can access?

You can use the Field Permissions module:

  The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity.

Once installed you'll be able to set CRUD permissions on each field's settings form.


How to implement hook_field_widget_form() for multiple fields?

the name of the form in   myModule_field_widget_form must be the same column in your  .install file  make sure it matches the same  column


How to display the username instead of the UID?

You'll need to add a relationship to users in your view and then you should be able to access something like the username.


How do I hide the submission button basing on some conditions?

I just figured out that there is the 'Submit' element at the end of the webform elements under webform build tab and I can apply the conditions on that 'Submit' element.


In views edit > Relationships > add Flags: User's flagged content (also select Include only users who have flagged content.)


Adding rel=canonical meta tag in comment paginated node pages

It can be done using Nodewords module as described here:

  Nodewords project allows you to add meta tags to Drupal pages, both
  manually and automatically based on various settings. Paying attention
  to meta tags, such as keywords, description and canonical URL, may
  help obtain better search engine positioning.


How to get user data by providing user name or user profile field

If you want to get the user data by providing username, you can use pass name (username) as a parameter to the service URL like follows

http://example.com/<endpoint path>/user?parameters[name]=krishna

If you want to pass either username or other user profile fields you can achieve that using Services Views module. After installing this module make sure to enable it under service resources list.

Create a view with contextual filter(s)

Executing view via views resource

After enabling "views" resource in your services endpoint you can do GET request to:

http://example.com/<endpoint path>/views/<view name>

This will execute a view and pass results.

Possible arguments:
- display_id: views display

args: array of view arguments
filters: array of view filter values
offset: views offset
limit: limit views number of results
format_output: boolean whether we would like to get themed view or data


As Ryan Weaver mentions,

  The current version of Drupal - 8.4 - requires Symfony 3.2.8 or
  higher, but less than 4.0. In practice, this probably means that your
  Drupal 8.4 project is using the latest Symfony 3.2.* version. But, you
  could technically upgrade your Symfony dependencies to version 3.4.

  Source: Symfony 4 and Drupal

Thus, you can, but only for minor versions.

To quote Dries Buytaert,

  Our biggest dependency in Drupal 8 is Symfony 3, and according to
  Symfony's roadmap, Symfony 3 has an end-of-life date in November 2021.
  This means that after November 2021, security bugs in Symfony 3 will
  not get fixed. To keep your Drupal sites secure, Drupal must adopt
  Symfony 4 or Symfony 5 before Symfony 3 goes end-of-life. A major
  Symfony upgrade will require us to release Drupal 9 (we don't want to
  fork Symfony 3 and have to backport Symfony 4 or Symfony 5 bug fixes).
  This means we have to end-of-life Drupal 8 no later than November
  2021.

  Source: Drupal 7, 8 and 9

He says here that Drupal 8 will reach end of life of Nov 2021 because that's Symfonys 3's end of life. Thus, from this, one can conclude that you can't just upgrade D8 to Symfony 4 (another major Symfony version).


What module lets you delete a node after a specific time if its unpublished?

You could do this using the Rules module.  If you enable the built-in scheduler submodule, you could create a set of rules/components like this (rough code to give you an idea, not a step-by-step walkthrough):

Component to delete content (Action set)

Action: Delete content

Rule to schedule content deletion (Rule)

Event: Content is created
Action: Schedule the "Component to delete content" after the specified amount of time

Rule to clear deletion on publishing (Rule)

Event: Content is published
Action: Delete the scheduled event for that piece of content ("Component to delete content")


You should be aware that once there is data In the tables created for your fields, it's limited what changes you can make.

Anyways want you need to do, is to use hook_update_N in your module's install file. The number N should consist of 4 numbers

Major release of the module (the drupal version)
Minor release of your module.
Number
Number

3-4 is just a combined number that should increment for each time you need to use the hook.

The field module provides a host of functions to add, change and remove fields. You can use those to do what you need.


coder.drush.inc exists in module, so yes, it can. Only command available is coder-format. Module provides following examples:

  'drush coder-format sites/all/modules/coder/coder.module' => 'Re-format coder.module according to Drupal coding standards.',
  'drush coder-format --undo sites/all/modules/coder/coder.module' => 'Restore coder.module from coder.module.coder.orig backup file (if existent).',
  'drush coder-format sites/all/modules/coder' => 'Recursively re-format Coder module files according to Drupal coding standards.',
  'drush coder-format --undo sites/all/modules/coder' => 'Recursively restore Coder module files from *.coder.orig backup files (if existent).',


How can I Hide in Drupal 7 the bottom blocks in Add and Edit button for my content

Sorry I have found the answer myself

If I use another login than admin the blocks are not shown,

Sorry


Are those tabs menu entries? Check the menus you have listed in structure > menus. I'm not sure what menu it would be in because it may depend on the theme so click through them all.

Those could also be potentially generated by a View so check entries in structure > views as well.


Pagination in external api consume custom module

Is responsability of the external API paginate the results with the page parameter. If it was designed for such thing.

Then you only need to request the appropiate page.

If in another hand if you receive all the data, then, you only need to divide it.

Assuming in the referenced question that $data contains all rows, you need to divide the array (array_chunk() maybe).


Allow authenticated users to create taxonomy terms

Taxonomy Access Control provides finer control of taxonomy permissions, that sounds like what you need.


How can I use Migrate Extras to get custom media fields to migrate?

The following will allow you to use Migrate to import files as File Entities (used for Media 2.x) and populate the File Entity fields when importing Nodes (MigrateDestinationNode). No Migrate Extras needed.

Add the following to your custom migrate module's .info file:

files[] = includes/MigrateEntityFileUri.inc

Download/save the following code in an "includes" subfolder of your migrate module. (Strip the .php extension)
https://gist.github.com/dmsmidt/6f0f498a9dbaea8602fb

Then in your Migration class you can use 'MigrateEntityFileUri' as file_class.

Example code:

$this->addFieldMapping('field_media', 'your_file_uri_source_array');
$this->addFieldMapping('field_media:file_class')
  ->defaultValue('MigrateEntityFileUri');
$this->addFieldMapping('field_media:fields', 'fields_array')
  ->description(t('Populate the fields.'));
$this->addFieldMapping('field_media:destination_dir')
  ->defaultValue('public://your_file_sub_dir');
$this->addFieldMapping('field_media:file_replace')
  ->defaultValue(MigrateFileBase::FILE_EXISTS_REUSE);
$this->addFieldMapping('field_media:preserve_files')
  ->defaultValue(TRUE);

Note the sources: 'your_file_uri_source_array' and 'fields_array'.
You may need to do some processing in prepareRow() depending on your source to get your data organized like this (pseudocode):

public function prepareRow($row) {
    $row->fields_array = array(
      array(
        'field_one' => 'value_field_file_one',
        'field_two' => 'value_field_file_one'
      ),
      array(
        'field_one' => 'value_field_file_two',
        'field_two' => 'value_field_file_two'
      ),
    );
    $row->your_file_uri_source_array = array('file_one_uri', 'file_two_uri');
  }


To remove the rows that you annotated with "Duplicates", you could use the Views Distinct module. From its project page:

  Relationships or other joins in Views often create "duplicate" results. For example, a node with a field that has multiple values may show up in the View once per value in the multi-value field. It's frustrating, and the "DISTINCT" SQL query option in the Views UI does not actually solve the problem because the result row is technically distinct. This module aims to give a simple GUI method to remove or aggregate these "duplicate" rows.

Assuming that would indeed remove the duplicate rows, the "What I get" should match with "What I try to achieve". So with that the setup of your relationships like you already defined them should be OK also (I can't think of any other missing piece to complete your puzzle).


Enable fields in manage display programmatically D7

I couldn't find any concrete documentation either. However, I'm going out on a limb here and not 100% certain but, I think you just need to specify a correct formatter and the settings since it works that way in the UI.

$instance = array(
   'field_name'  => 'title',
   'label' => $t('Title'),
   'type' => 'text',
   'widget' => array(
     'type'    => 'text_textfield',
     'weight' => 1.0,
    ),
   'display' => array(
     'default' => array(
       'label' => $t('label'),
       'type' => 'text', // <-- invalid formatter
      ),
    ),
 );

text is not a valid formatter type. It should either be text_default or text_plain or text_trimmed or text_summary_or_trimmed or hidden (which hides the field from display).


Linking an individual term from a vocabulary with all terms from another vocabulary

To do a hierarchical taxonomy,  Use Taxonomy Manager and all you need to do is include the hyphen before the child terms, as shown in the answer above when you bulk add terms

You can also use the standard taxonomy manager, and use drag handles to inset children, like I have done below.


How can I allow users to edit CSS in a WYSIWYG editor

You might be interested in this module:

CSS Injector

  Allows administrators to inject CSS into the page output based on
  configurable rules. It's useful for adding simple CSS tweaks without
  modifying a site's official theme


Subscriptions template: test for imagefield

If you can use php in the template (?) I would just wrap the cell containing the image in an if statement, something like this:

Your subscriptions on [site:name] notify you of the following changes since the previous digest:

{{[subs:items:count]#

#1 of [subs:items:count] {{[subs:items:index:#0:subs:is-new]?(new):}}{{[subs:items:index:#0:subs:is-updated]?(updated):}}{{[subs:items:index:#0:subs:is-old]?(commented): [subs:items:index:#0:as-node:title]}}

        <?php if(**code to determine if image exists**): ?>

        <?php endif ?>

        [subs:items:index:#0:as-node:summary]

Read more: [subs:items:index:#0:as-node:url]

}}

That way if there's no image it just won't print the cell at all and the other cell will take the entire width of the table.

If you can't use php in the template then I'm not sure how you could deal with it except perhaps by merging the two cells like this:

  [subs:items:index:#0:as-node:summary]


Best practices for implementing custom caching?

I can't think of a good reason why dropping the entries manually would cause a problem. This assumes, of course, that you're using MySQL as the backend for your particular cache; although I think the same applies to any other type of cache backend, the method to clear just wouldn't necessarily be a database query.

If you take the core update module as an example, it bypasses the cache_* functions and clears its cache manually:

function _update_cache_clear($cid = NULL, $wildcard = FALSE) {
  if (empty($cid)) {
    db_delete('cache_update')
      // Clear everything except fetch task information because these are used
      // to ensure that the fetch task queue items are not added multiple times.
      ->condition('cid', 'fetch_task::%', 'NOT LIKE')
      ->execute();
  }
  else {
    $query = db_delete('cache_update');
    if ($wildcard) {
      $query->condition('cid', $cid . '%', 'LIKE');
    }
    else {
      $query->condition('cid', $cid);
    }
    $query->execute();
  }
}

I always think "if it's good enough for core, it's good enough for me" :)


The Video Filter module is still in alpha so it's very likely this is a bug. You should consult the issue queue to see if it exists, and create a bug report if it doesn't exist.

As for the ignore and deploy/pursue and fix question, it depends on how fault tolerant you are. Certainly the project maintainers (and community) would appreciate the bug fix. Deploying early release code is risky, but if the functionality is little used and has no chance of catastrophic results (e.g. complex DB manipulation that could result in corruption.) then deploy/ignore can be a fine strategy (regardless, you should always have warnings turned off on production).


Display vocabularies/terms inside content-type view

Create a new view block within your View definition and define it using contextual filters to display the appropriate content.  Then go to admin/structure/blocks and move the block to the regions you wish it to appear in.  One of the options for configuring the block will be to assign what pages it shows up on.  By entering taxonomy/terms/% or whatever other path alias you are using you can limit where these additional blocks will appear.


Is It Safe to Delete Content Types "Article" and "Basic Page"?

If you're not going to use them feel free to delete them.  There will be no impact if you remove them.


Add validation on views bulk operations form

Your omhm_mod_views_bulk_operations_form_alter($form, &$form_state, $form_id) takes $form by value, not by reference, so any changes made to $form are scoped to the function only. That's why $form['select']['submit']['#validate'][] changes nothing. It should be omhm_mod_views_bulk_operations_form_alter(&$form, &$form_state, $form_id)

When you fix mistake I pointed above, and it will not help, be sure to test if your hook is run at all, and if it is, then test if your validator is. It'll be needed for your next question, if you will need to ask it.


How to add custom css file to subtheme of omega kickstart theme?

I was missing one line in code. here is what you have to do. in your .info file under optional css code write the following code.

css[yourcustomcss.css][name] = Your custom products styles
css[yourcustomcss.css][description] = This file holds all the product page CSS of your theme.
css[yourcustomcss.css][options][weight] = 12
settings[alpha_css][yourcustomcss.css] = 'yourcustomcss.css'

Now go and enable your 'yourcustomcss.css' in Appearance/yourthemename/settings/toggle-styles


Dear friend I suggest you if you only want provide a visual manual for your customer install pdf printer ( software that print result is pdf like foxit,nitro etc) then in each page ctrl+P (print ) and enjoy ( admin pages are not very much and not need put yourself in complex ways,It seems you want fast and short way to achive it ) :)


Twig conditions for node/page/view in page-title.html

Try adding this to your MYTHEME.theme. This will provide the machine name value to your page.html.twig template files.

MYTHEME.theme:

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHEME_preprocess_page($variables) {
  $variables['machine_name'] = $variables['page']['#type'];
}

Then in page.html.twig:

{%
  set classes = [
    'title--h1',
    machine_name == 'about_me' ? 'ico ico--world',
  ]
%}

{{ machine_name }}

For node.html.twig templates, use bundle to get the machine name:

{%
  set classes = [
    node.bundle == 'content__type' ? 'one-class' : 'another-class'
  ]
%}

You cannot access the bundle type in MYTHEME_preprocess_page_title() directly.


Is it possible to add a wildcard in template.php to apply function to multiple items

This seems more like a general PHP question, but I'll answer it anyway with some Drupal context.

You usually loop through the array in these instances. You'll find looping as you code in Drupal more and more common.

Consider the following structure:

$form['submitted']['products']['product_1']['quantity']['#empty_option']

Assuming that you're editing the ['quantity']['#empty_option'] of each [product_x], you loop through your array like so:

foreach(element_children($form['submitted']['products']) as $key) {
  $form['submitted']['products'][$key]['quantity']['#empty_option'] = t('Qty');
}

element_children gives you the keys for the array which don't start with a hash #. Whether or not it's suitable for your particular array is a different matter. You can inspect your variable using var_dump($variable) or through Devel module's dpm($variable, 'label'); function.

You may find that you may need to run some if statements to test if $key starts with product_ if you have more than product_x keys under $form['submitted']['products']

foreach(element_children($form['submitted']['products']) as $key) {
  // Only proceed if array key starts with product_
  if (substr($key, 0, 8) == 'product_') {
    $form['submitted']['products'][$key]['quantity']['#empty_option'] = t('Qty');
  }
}


Triggering an action after user resets password?

/**
 * Implements hook_ENTITY_TYPE_update().
 */
function MODULE_user_update(Drupal\user\UserInterface $user) {
  if (!empty($user->original)) { // check previous value exists
    if($user->original->pass->value != $user->pass->value) { // check if pass changed
      $user->field_email_confirmed->value = 1; // set new value
    }
  }
}


Programmatic access to metatag module fields

If you have node object loaded, you can access the meta tags as below:

$metaTags = $node->get('field_meta_tags')->value;
if (!empty($metaTags)) {
      $metaTagsArr = unserialize($metaTags);
echo "<pre>";
print_r($metaTagsArr);
echo "</pre>";
}


How to use Rules to assign user badges to users with sufficient User points?

Which version of User Badges are you using?

According to the module page "The 7.x version is NOT suitable for production yet." so if you want to use it you will probably need to do some manual debugging at the very least.

This user had the same issue you are seeing and they said uninstalling and reinstalling the latest 2.x dev worked for them.


Yes, you can add as many menu items as you like in the menu administration section of the website.

Go to admin/structure/menu
Click the "add link" link for the menu you want to add an item to
Add the menu item to the path you are using for you view.


How do I add an ajax item on the submit button?

Try this:

$form['actions']['submit']['#ajax'] = array(
        'callback' => '\Drupal\mymodule\Controller\DefaultController::process_form_submission',
'event' => 'click',
      );


Some questions first. What's the data model?

"Time Entry" -> "User Node" or
"Time Entry" -> "User Node" -> "User Entity"

Are you using "User Reference" and "Node Reference" fields for the reference fields? If so, no need to use PHP to do it. You can use the Views UI for this functionality.

First, make sure the View's Row Style is "Fields" the format is Table and the view type is Node. Filter by "Time Entry" type.

Then, on the Advanced Tab, add a "New Relationship" and choose the reference field you use to reference the "User Node". By doing this, it'll enable you to access the "User Node", aside from the original "Time Entry" data.

If you have 3 entities related, you have to add another relation to access the 3rd entity's data. Follow the same procedure as above (adding a new relationship) and use the "User Node" reference field to access the "User Entity" data.

Then you can just add the fields you want, namely user name, last name and so on.

Hope this helps.