How to output view content as grid in custom template?

what if I want to use html and php

Ok, now that I remember there is another method.

Add the following code to the bottom of your template.php file (located in /sites/all/themes/yourtheme/ folder)

function themename_preprocess_views_view_fields($vars){

      if ($vars['view']->name == "view_name" && $vars['view']->current_display == "block_1"){
        $vars['fields']['title']->content = // do php or whatever you want to it here
      }
    }

replace themename with your theme name
replace view_name with your view name
replace block_1 with your machine name

To add html, Ex:

function themename_preprocess_views_view_fields($vars){

  if ($vars['view']->name == "view_name" && $vars['view']->current_display == "block_1"){
  $a = $vars['fields']['title']->content;
  $vars['fields']['title']->content = "
" . $a . "
";
  }
}

With this method your grid should remain intact.


Site map module assigns random frequencies to content

Is there a way I can assign uniform frequency to all my content pages? or edit individual page frequencies?

Not through the UI as far as I know, but it's possible in code using hook_xmlsitemap_link_alter():

function MYMODULE_xmlsitemap_link_alter(&$link) {
  if ($link['type'] == 'node' && $link['subtype'] == 'article') {
    $link['changefreq'] = 86400;
  }
}

$link also has a loc field which contains the router path for the node (e.g. "node/1"), although it's not ideal you can use that quite reliably to determine what specific node is being dealt with.

  What exactly is making the XML site map module assign two different sets of frequencies to the same content type?

It's intentional - the change frequency for each link is calculated dynamically by the module. I assume the idea is that giving Google an accurate change frequency is better than setting something static and then ultimately struggling or failing to live up to it in the mighty engine's eyes. Doesn't always work like that in practice, of course.


How to add Google adsense Adlinks at the middle of the post

2 Methods:

Create two body fields, display adsense between the output of the two.
Output the block for the adsense code (I assume it is in a block) via PHP in your body.

<?php
$block = module_invoke('block', 'block_view', 26);
print render($block);
?>


I was wondering if using hook_module_implements_alter() is a good practice in D8 also to alter the order of execution of hooks?

Yes it is - in fact it's the only way to alter the order of hook execution.

Events are something different. Their execution order is set in the implementation of each handler, and can't be affected by any hook.


How to change the entity view display configuration programmatically?

There are two configuration types. Simple configuration and configuration entities. In this case this is a configuration entity. The class name is in camelCase:

EntityViewDisplay.php

class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayInterface

If you have a config entity for the configuration, you can load the config entity,

$storage = \Drupal::entityTypeManager()->getStorage('entity_view_display');
$view_display = $storage->load('node.article.default');

modify it and save it:

$view_display->save();

Why you want to use config entities?

You can get the array of the configuration:

$config = $view_display->toArray();

This is not different from what you get in the yml file or config api.

The advantage is, that config entities usually have method for special configuration tasks. With displays this is for example to add or remove components:

$view_display->setComponent('body', [
     'type' => 'text_summary_or_trimmed',
     'settings' => ['trim_length' => '200'],
     'weight' => 1,
   ])
   ->removeComponent('field_image')
   ->save();

That is much easier than to do this in the configuration array.


This cannot be done the way you are trying. HTML embedded in XML is no different than regular text in XML. XPath has no way to look inside the HTML to query it.

There is some work being done, essentially adding another parsing step, https://drupal.org/node/1459870.


Add users from SSO server database to Drupal

IMHO, integration of different system through form POSting is at the hack level. To let external system inject data into Drupal, the Services module let you easily build HTTP REST API in Drupal. It comes out of the box with a user API that allow external system to easily create new Drupal users.

Off course, you can create your own page to receive POSTed data from a form build outside Drupal. You simply have to declare it through a hook_menu() implementation. For access control to the page, you can either use the 'access arguments' to restrict access with Drupal permission system. you can also use your own 'access callback' to implement your own access control logic (ie. for instance, using a secret token based access control).


What is the goal of template_preprocess_page(&$variables)?

It is an entry point in your theme or module that allows you to modify or add template variables before the page (or applicable item) is rendered. This hook affects any page*.tpl.php files.

Similarly, template_preprocess_node is the same, but for node templates.

Example:

I need to change existing variable foo:

function mytheme_preprocess_page(&$variables) {
  // $foo used to be 'Old Value'
  $variables['foo'] = 'New Value';
}

I need to add new variable:

function mytheme_preprocess_page(&$variables) {
  // $baz does not yet exist
  $variables['baz'] = 'Baz!';
}

These are injected into the template, then they can be rendered with render or printed:

page.tpl.php:

<?php print $foo; ?>
<?php print $baz; ?>

This is because $variables are passed by reference (note the & symbol) which allows you to modify the array.


View to show node titles only when a new comment has been posted?

You can add a relation in views "comments of the node" and add filter criteria by comment post date. As I know there is no status "new" in comments that's why you can limit them by date.

Or you can add custom field with status but you will need a logic how to add and remove that status.


Views Grouping field:Add Ordered class to Grouping row

Javascript?

$('.view-grouping').each(function(i){
  $(this).addClass('view-grouping-' + (i+1));
});


How to hide body field in a view only on certain content types

This can be done really easily with views_conditional module. Once you enable the module, having the content type and body fields already added and excluded from display, do the following steps:

add a views conditional field
set the if condition to the [type] == Indexed Content: Content Type
set is condition to contains
Set the value to the content type name for the body that you want to display
Then in Then output this... Use the [body] replacement pattern

Works like a charm!


Mobile_detect php redirecting to subdomain - Stuck in a redirect loop!

Presumably your hook_init runs on both domains.

You need to check you're not already on the redirected page prior to redirection.

e.g

/**
 * Implements hook_init
 */
function mobydetect_init() {
  if($_SERVER['HTTP_HOST'] != 'm.mysite.com'){
    include("PATH/TO/Mobile_Detect.php");
    $detect = new Mobile_Detect();
    if ($detect->isMobile()) {
      drupal_goto('http://m.mysite.com', array('absolute' => TRUE, 'external' => TRUE));
    }
  }
}

Note, hook_init doesn't run on cached pages so you may find mobile users aren't redirected on cached pages. You could try using hook_boot instead or else offload to the webserver conf.


How do I remove a module JavaScript file through a theme?

Implement hook_library_info_alter:

mytheme.theme:

/**
 * Implements hook_library_info_alter().
 */
function mytheme_library_info_alter(&$libraries, $extension) {
  if ($extension === 'some_module') {
    unset($libraries['some_module.library']['js']['js/foo.js']);
  }
}


How hierarchical taxonomy comparison works

try structure -> taxonomy -> (edit your vocabulary) and at the bottom there is a checkbox

"Select to rebuild the menu on submit."

Please note:

"Rebuild the menu on submit. Warning: This will delete then re-create all of the menu items. Only use this option if you are experiencing issues like missing menu items or other inconsistencies."

Hit save and it should help


How to insert multiple tables into their respective backup tables using insert sql?

You should use
Merge Queries

a Merge query is a combination of an Insert query and an Update query.
If a given condition is met, such as a row with a given primary key
already existing, then an Update query is run. If not, an Insert query
is run.

The above is for drupal
If you are using mysql then you can use UPDATE or ON DUPLICATE KEY UPDATE


I think that you have a typo in the field name, you should replace
$media->file_media_video_file
with
$media->field_media_video_file (2 times)


Hide formatting options from a CCK field in Drupal 6

Found that this can be handled in the theme's template.php file:-

function phptemplate_filter_tips_more_info() {
return '';
}
function phptemplate_filter_tips($tips, $long = FALSE, $extra = '') {
return '';
}

Which then overrides all filter tips from forms.


The only work-around solution that I can think of would be to:

Create a separate view for the tags.

Then there I will be able to uncheck display all values in same row.

Re-write field to <div class="{{ field_tags }}"> {{ field_tags }} </div>

Then use View Fields View to insert the Tags view as a field in my other view and pass the nid as contextual filter.

Probably not the best solution, so if anyone has a better one I'd love to hear it.


Enabling aggregate and compress CSS files resuls in vanishing theme

Do following steps:

Again place advagg module's folder in your module's directory. Usually (sites/all/modules)
Go to database and truncate all cache tables starting with "cache". Do with caution.
See if site works.
Otherwise if you are having drush installed, check command "drush status" if it works. And clear the cache throudh drush again by command "drush cc all".

Hope this will help you. If not reply in comment I'll assist you to make your site work again.


Panels should always respect the current users language, I've built several multilingual Panels sites, and never had to tell Panels which language to load.

In fact, the node "task handler", which is responsible for rendering nodes, doesn't even do a lot of work, but hands that responsibility over to Core, and as such, language to the Locale module.


Can I get integers from a dynamic query using fetchAllKeyed?

The issue here is that PDO returns strings, even for integer columns. Drupal handles this issue by providing the Typed Data API, which provides data typing used within Drupal, rather than PHP-level data typing.

In the Drupal 8 paradigm, database queries are generally made to query entity IDs, which are then used to load entities. Data is then retrieved from the entity. The Entity API on the back end will handle the setting/getting of the fields on the entity. The fields on the entity will all be of a Typed Data API data type, providing a consistent method of dealing with data types on the Drupal level.

The method of retrieving IDs, and loading entities is done for the sake of efficiency, as entities are cached, and may be loaded from backends such as Redis, therefore being much faster than retrieving the entity data from the database. And because fields are typed, it gives a consistent API for dealing with various data types, that can also be extended to provide additional data types through contributed modules.

So the question here becomes about what you are trying to do, and how you are trying to do it. If you are working with data that you've been saving to the database yourself, then you can switch to the Drupal way, and create a custom entity type then use the Entity API to set/get the field data. Or, if you are retrieving data from the DB that Drupal has saved there, it likely belongs to an entity that you should be retrieving, rather than directly retrieving the field data.


Workbench moderation state tab not displayed

Ah. Again, Fooled myself - it was a simple shoot into my own foot.
I had written custom PHP code in my costom theme in the function THEME_form_alter() to suppress the whole revisoning tab:

$form['revision_information']['#access'] = FALSE;

When I then installed and configured the workbench module I didn't realize that it needs exactly THIS tab.

Works as expected now. Sorry for using your time... But maybe someone else learns from my errors...
Thanks for  your thoughts.


How to attach block to page provided by logintoboggan

One option would be to redirect users to login when access is denied.

another may be to create your own Access Denied page, and then attach a login block to that URL.

To create your own Access Denied page, first create the page as you would with any other content,  then navigate to: /admin/config/system/site-information


FieldPluginBase: How to test based on views field raw value?

For the untranslated field value get first the untranslated entity:

if ($entity = $this->getEntity($values)) {
  $untranslated_entity = $entity->getUntranslated();
  $untranslated_value = $untranslated_entity->field_example->value;
}


Views, User type page view ignoring Omega content grid

Ok so I think I have found a workaround / solution when using view pages.  I think that the Context module may of had a hand in this, as another site I run, which doesn't have context installed works fine when rendering views pages.

So while poking around Context and its available blocks I noticed that there was a Main page content block.  I added that to the content region and now if I use a view as a page the content region HTML is rendered.


How to make a field required using JavaScript injector

Matt -

I would recommend looking into hook_node_validate(). This is a function hook provided by Drupal core that allows you to add custom validation into the form. While you cannot select "required" from the field UI, perhaps you can validate it here and then return an error if the form doesn't provide the correct information for that specific field.

Other things to investigate: hook_form_alter() and hook_validate - where you can add custom validation functions into the Drupal form array itself.

Helpful links:
https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_validate/7

https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_form_alter/7


SQL Error on Calendar View with Relationships

Have you recently deleted a field which name was field_school_term_deadline ? If so your view used it and is broken now, just remove it from the list of fields.


Forms : How to add elements on the client without a (ajax) round trip to the server

Short of building your form with a huge amount of fields, hiding them, and then showing them dependent on the user's action, no you can't.


With custom module.
See hook_menu()

As page_callback define your "send mail" function for restricted user roles


Using the Webform Rules module is indeed part of the puzzle to answer your question, as you can read also on its project page:

  This module adds rules integration on webforms.

  Did you ever want to react on webform submission using rules but couldn't find the proper event?

  Webform Rules makes it possible to catch webform submissions by rules and do whatever you'd like to do with it (meaning: do whatever rules let you do with it).

1. Get the user ID who submitted the webform

Have a look at this example rule (in Rules export format):

{ "rules_process_submitted_webform" : {
    "LABEL" : "Process submitted webform",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "webform_rules" ],
    "ON" : { "webform_rules_submit" : [] },
    "DO" : [
      { "mail" : {
          "to" : "[site:mail]",
          "subject" : "A new webform submission has occured",
          "message" : "A new webform submission has occured (with form-id \u0022[form-id:value]\u0022). It was submitted by the user with id = [user:id], name = [user:name] and eMail Id = [user:mail] ...",
          "language" : [ "" ]
        }
      }
    ]
  }
}

I intentionally did not include any Rules Conditions here, just to illustrate that by using the Rules Event you're already using, you do have access to a limited set of tokens related to the user who submitted the webform, such as [user:id], [user:name] and [user:mail]. In other words, you don't need a Rules Action like "fetch entity by ID" for these kinds of tokens to be available.

Of course, because of the nature of your question, you may want to add a Rules Condition to check that the user is not an anonymous user.

2. About the Webform data

The "Webform data"-part of your question seems like an example (variation?) of what's asked for in the feature request "Expose submission data to rules". Here is a summary of it:

  Right now, submission data is not exposed to rules except by way of token replacement or custom php actions. This patch exposes submission data in a "first-class" way.

Issue status is "Needs work" ... not an "easy" issue though.

The very same issue contains a comment with a workaround (it's genious I think, because it's so simple), here is a relevant quote from it:

  You can initialize a rules string variable with the tokens. If you need integers or booleans you can subsequently convert it to whatever and then use it to load nodes or whatever.

A picture is worth more then 1000 words: checkout the screenprint included in that comment.

So you could use a technique similar to what is described in my answer to "How to do a data comparison to submitted webform data when using the Rules module?". For short:

Add an extra Rules Action to Add a variable, with a value assigned to it equal to your Webform data you want to use (and with an appropriate data type). You'd need 1 such variable for each Webform component for which you want to access its Webform data.
In your subsequent Rules Actions you can refer to the value of these variables you just added (that's the clue!).

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


How do I make a block that pulls the current node content?

There are two completely different kinds of contexts.

Cache contexts, which have nothing to do with this. They're not used to invalidate something, but vary by something (e.g. cache differently for different user permisisons). Cache tags are for invalidation.

What you mean are plugin contexts. And yes, blocks are able to use them since a short while (They always could, but the block.module didn't support it properly). As @larowlan said, core uses them mostly for visibility conditions but it works the same for blocks.

One such example that you can look at is the NodeType condition. What you need to do is add the context annotation and then you can use it as $this->getContextValue('node'). The advantage of this is that your block is more flexible and doesn't need to know where the node is coming from exactly, that's up to the user configuring it.

Note that this is not visible in the UI currently unless there is actually more than one node to chose from.


The current way to do this, as per Commerce API is, instead of adding a validate handler to the complete checkout form you extend the checkout pane definition and specify your own validate handler.

If your custom validation passes, fallback to the default  pane validation handler.

In this example, to add a custom validation handler to the shipping pane:

/**
 * Implements hook_commerce_checkout_pane_info_alter
 */
function MODULE_commerce_checkout_pane_info_alter(&$checkout_panes) {
  if(isset($checkout_panes['commerce_shipping'])){
    $checkout_panes['commerce_shipping']['callbacks']['checkout_form_validate'] = 'MODULE_commerce_shipping_pane_validate';
  }
}

/**
 * Checkout pane validation override to ensure valid shipping method for address
 */
function MODULE_commerce_shipping_pane_validate(&$form, &$form_state, $checkout_pane, $order) {

  // Do some validation tests here... omitted for brevity.
  if (!$valid) {
    drupal_set_message(t('Some validation error message'), 'warning');
    return FALSE;
  }

  // Fallback to default validator.
  if (function_exists('commerce_shipping_pane_checkout_form_validate')) {
    return commerce_shipping_pane_checkout_form_validate($form, $form_state, $checkout_pane, $order);
  } else {
    // Passed validation.
    return TRUE;
  }

}

  checkout_form_validate($form, &$form_state, $checkout_pane, $order):
  validates data inputted via the pane’s elements on the checkout form
  and returns TRUE or FALSE indicating whether or not all the data
  validated

More info:

hook_commerce_checkout_pane_info
commerce_checkout_form_validate


Drupal Json Output strange characters when pulling from other language

just check HTTP response headers it should have utf-8 charset.


The settings form does not save entries to a file, but stores the value in the database. It can only be called from a custom module you will have to build.

Below you will find a link to Drupal's own module tutorial. Follow the steps and you will come across the usage of the settings page. (configuration form)

http://drupal.org/node/361112


Creating a view which lists all taxnomy terms and the number they appear in a content type?

Found the answer i was looking for, and that is to turn on Field Aggregation from the 3rd panel in the view.


What is the benefits of Panels for a themer?

One large advantage of Panels is that you can have wildly different layouts for pages, depending on your needs.  In this context, layouts can mean both content and styling.

On the content end, you can have your main node-being-viewed piece, and add in different things.  For example, you can add in views into sidebar areas that show/link to related content.  You can also add in blocks, and have a lot more flexibility than what come stock with Drupal (though D7 really improves things).

On the styling end, the biggest advantage is being able to choose different layout templates for each page and variant.  Other modules, like Context can do similar things, but I find it much easier to do with Panels.

With the sites we build, all pages are Panel pages (no exceptions).  From the client's perspective, having adequate training and inline help greatly helps with them being able to keep the site alive (and nearly all of our clients are non-technical).

A side effect of using Panels is that you get a lot of features that cTools provides, which can be a huge benefit when you need to retrofit a site.  In a lot of ways, we have found using Panels pages for everything really aids with future proofing a site.


How do I index all the content with the search_api module?

You must click the "Queue all items for reindexing" link that appears below the "Start Indexing Now" fieldset, and then once you run that process, you can return to the index UI (example.com/admin/config/search/search-api/index/my-example-index) and at that point the "Index Now" button is active.


What is the best way to add a confirmation tooltip to the remove button of a managed_file field?

Use this code to delay submit and display popup before submitting.

$("form").submit( function () {
   //display tooltip something
   return true;
 }

Something like this:

$('.form-item input.form-submit[value=Remove]').submit {
  if (window.confirm("Are You Sure?")) {
    myClick();
  } else {
    return false;
  }
}


I ran across this today and figured I would circle back and provide an answer that worked for me.

{% for item in items %}
    {% set conBody %}
        {{ item.content }}
    {% endset %}

{{ conBody|striptags }}

{% endfor %}


How to remove selected topics from aggregator feed?

Probably you must implement hook_aggregator_fetch for this job.


How do I 'programaticaly' create a new content type with hook_install in D7?

The reason I was not seeing my 'Apples' content type appear in the node_type table was because I did not realise that I had to uninstall my module then reinstall it every time I wanted to test my code changes. I was just disabling the 'Fruit' module and expecting my .INSTALL file to do its work when I re-enabled the module again. You have to disable and uninstall (not just disable) then re-enable. Apparently you can manually remove the module from the system table also, but I did not go there.

The code I pasted in above does work - although it may not be the 'correct' way of creating a content type. I'm not sure. My method mirrors how I would acheive the same with the Field UI: Add a new content type, set the content type options, add any new fields, then create the required instances of those new fields. This seems logical to me, but you may find the other solutions suggested here to be better.


Allow html tags in Form submit button in block plugin

Use a formattable markup:

use Drupal\Component\Render\FormattableMarkup;

  $value = new FormattableMarkup('<i class="fa fa-mail"></i>@text', [
    '@text' => $value,
  ]);

The formattable string will not be escaped. The variable in the placeholder @text will be escaped and that is important, because it contains user input.


Receiving two subscriptions emails when run cron using rules

I finally solved this. I noticed that it was rules who was getting trigger two times. This  link  help me.  I thetrigger me to disable another rule on same event condition.


$drupal_hash_salt is empty in my installations

The hash is used to salt things one-time links and forms tokens, it filed usually by the installer.

You can add your own salt here, basically any random string or even replace it with the content of a file (see the documentation in the default.settings.php).

If this variable is empty, a hash of the serialized database credentials will be used as a fallback salt (though you have to add it manually if you have a database cluster).

This is function used as a fall back if there is no salt drupal_hash_salt

function drupal_get_hash_salt() {
  global $drupal_hash_salt, $databases;
  // If the $drupal_hash_salt variable is empty, a hash of the serialized
  // database credentials is used as a fallback salt.
  return empty($drupal_hash_salt) ? hash('sha256', serialize($databases)) : $drupal_hash_salt;
}


Allowing third-party modules to alter the query executed by a module

Not really sure what your question exactly is now.

I'm not sure why hook_query_alter() even exists, it did not in the beginning. I don't think that hook makes much sense, I can't think of a use case where you want to alter every query.
If you expect that other modules want to extend your query, then use "->addTag('yourmodule_tag')" so that it is possible to alter it. As you already said, this only covers cases where the same existing query should be changed. It might be possible to do other checks and then add a condition that can never be true (like 1 = 0) on the query, but that sounds hacky to me.
You can also define your own hook if you think that there could be more complex checks that other modules want to do. You probably want to re-use the hook_node_access pattern with three possible return values (ignore, allow, deny), see node_access().

You can do either or both of these two things, hook calls are rather fast in D7 because the hook implementations are cached and don't need to re-checked every time the hook is invoked.


If you look at EntityAccessCheck::access() you'll see this:

$requirement = $route->getRequirement('_entity_access');
list($entity_type, $operation) = explode('.', $requirement);

The second line is causing the notice, and your access check to subsequently fail. Basically, the access method is expecting (requiring, in fact) your permission to contain an entity type and access operation, separated by a ..

If you take the node module's routing file as an example:

node.delete_confirm:
  path: '/node/{node}/delete'
  defaults:
    _entity_form: 'node.delete'
    _title: 'Delete'
  requirements:
    _entity_access: 'node.delete'
  options:
    _node_operation_route: TRUE

I would suggest you just need to change your route to match:

mymodule.myentity_delete:
  path: '/admin/config/search/mymodule/myentity/{myentity}/delete'
  defaults:
    _entity_form: 'mymodule_myentity.delete'
  requirements:
    _entity_access: 'mymodule_myentity.delete'


Why D7 Update Manager keeps sending emails?

Update Manager is a module that exists and works inside your installation. This means that Drupal installation exists. Maybe it is no longer connected to domain, but it is there, up and running. Delete it and you'll be all right. Or, if you want to keep it for backup / rollback purposes, ask your sysadmin to delete it's CRON rule. Without system's cron and visitors, nothing will trigger update checks and mail sending.


Batch API is setup in my module but it does not open batch window progress

your menu callback function is rhmtts_csvimport_page_default. This does not exist or currently does nothing.
Your form function rhmtts_csvimport_uploadform has this submit handler rhmtts_csvimport_uploadform_submit and it never calls or creates your batch function called rhmtts_batch_submit.

Your code is more or less all there I would:

use drupal_get_form as my hook_menu callback function and give it the name of my form function.
I would add my batch function onto the form submit handlers for my form as outlined here https://www.drupal.org/node/180528. Then it should all work.


Regarding question 1, there are several options to do that, for instance OpenID Selector.

Question 2: Yes. I don't know all of Discus' features so I cannot answer this for each and every one of them. However I do know that there are Drupal modules for comment notification, for instance Comment Notify.

Questions 3-5: those are quite specific, I think you'd better ask them in the issue queue of the Drupal Disqus module.


Can I use a universal no-results display for Views?

You can copy views-view.tpl.php template to your theme folder, then modify relevant part.

<?php if ($rows): ?>

    <?php print $rows; ?>

<?php elseif ($empty): ?>

    <?php print $empty; ?>

<?php endif; ?>

To:

<?php if ($rows): ?>

    <?php print $rows; ?>

<?php else: ?>

<?php endif; ?>

You can keep the <?php elseif ($empty): ?> part if you still want to be able to override your custom output.

Cheers,


View: Distinct list of all referenced entities

Create a view of events with relationship to the speakers and contextual filter to festival

For filtering duplicates you have to turn on aggregation as seen above and setup body aggregation settings: group column: format

The contexual settings for festival are

NOTE: To see preview for a festival put a festival node id in the contextual filter and press preview

Finally you can put the view block display on content region or any other region from  structure > block layout and the block with relevant event/speakers will be present when you visit a festival page


Why are there so many attempts by an anonymous user to access /wp-login.php?

As kiamlaluno said:

  It's just bots scanning for exploits. You don't need to do anything,
  except serving a faster 404 response for those pages, as described in
  drupal.stackexchange.com/a/152732/199.


Secure remote access to an RSS page via HTTP authentication using the Secure Site module.

  This module allows you to authenticate users with a browser-based password (HTTP Auth). You can restrict access to the site by role and choose to secure restricted pages or the entire site. This means the site will be inaccessible to search engines and other crawlers, but you can still allow access to certain users.


How to alter the result of my view using filters?

you should use hook_views_query_alter, because hook_views_pre_render is called after the query is done, so you cannot influence your database request anymore.

The views documentation has been added to the Drupal api docs recently, so for more info look at:
http://api.drupal.org/api/views/docs%21views.api.php/group/views_hooks/7

or

http://views.doc.logrus.com/


Views not showing date field in proper time zone

You can use Global PHP filed to convert the date in user's proper timezone using code. Your date field value will be the input here. If it works then use this field instead and set the original date field to 'exclude from display' in your view.


How to make menu items of restricted pages visible to all user roles?

Ah look, Always Visible already had an issue regarding D8: Drupal 8 port of Always Visible. Some nice person created a Gist you can easily build a custom module from to always display all menu items.

I've done that for you and put it on GitLab: Always Visible (D8). Simply download the Zip file, unpack it, rename the folder to always_visible and put it into your /modules/custom folder, enable the module, done.


Have I understood correctly? - Drupal Slider\carousel modules

There are a lot of options within Drupal. This is it's great strength, but comes with a steep learning curve for starters.

So there are a lot of modules to build a slider. Most sliders require a content type where you upload the image and views to make the list of images. This is not to make it hard, but to give you options on what to do with it.

If you want an 'instant' slider, check out https://www.drupal.org/project/content_glider. No views required.


The errors on the stats page are due to an unrelated issue with memcache reporting. I think the problem you have is with the conf setup. I believe it should be like this for a default set up where all tables are mapped to the same bin:

$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['memcache_servers'] = array(
    'memcache.domain.local:11211' => 'default'
);

$conf['memcache_key_prefix'] = 's-drupal';

If that doesn't do the trick you can explicitly code the mappings for each table:

$conf['memcache_bins'] = array(
  'cache' => 'default',
  'cache_filter' => 'default',
  'cache_menu' => 'default'
);

etc.


Disable Webform Componotent (field) after certain number of submissions

I would approach this by using

hook_webform_submission_insert (which is triggered after the submission is inserted into the database)

http://www.drupalcontrib.org/api/drupal/contributions%21webform%21webform.api.php/function/hook_webform_submission_insert/7

Once in that hook i would use webform_get_submission_count to get the number of submissions , if this was the last allowed submission i would then unpublish the node and create a redirect to a "this class is now closed page".

http://www.drupalcontrib.org/api/drupal/contributions%21webform%21includes%21webform.submissions.inc/function/webform_get_submission_count/7

You could also approach it by using hook_webform_submission_presave or a custom form validator to generate a form error.


You should be able to wrap form elements with #prefix and #suffix:

$form['submit'] = array(
  '#type' => 'submit',
  '#value' => t('Submit'),
  '#attributes' => array('style' => "padding: 0 10px;"),
  '#theme' => "submit",
  '#prefix' => "
",
  '#suffix' => "
",
);


How do I create dynamic routes where the changing part is at the beginning of the path?

In your edit, {con} is a route parameter? This is not possible in Drupal, you can't start with a route parameter and /{con}/ has to fill an entire route segment.
Before you can match a route for such a path you have to do some path processing. See Do new routes require a static first portion?


User registration password.
This is the first result when searching "drupal user registration password" on google.


How to configure the views slideshow from the CMS?

You can check a very helpful module in Drupal JCarousel. It has views integration and the settings which you want as well.

  This module allows developers and themers to make use of the jCarousel jQuery plugin. It includes a developer API that other modules can use, as well as Views integration in the 2.0 version so that you can turn any list of content or images into a carousel.


One view per taxonomy vocabulary without a contrib module?

Drupal 8 already uses the (now-builtin) Views for listing pages of content belonging to a certain taxonomy term.

That's a single view for all taxonomy terms:

You can edit the view and make necessary changes you need
http://example.com/admin/structure/views/view/taxonomy_term


How to define frontend theme (non-admin) for a given node tab route?

The _node_operation_route option respect the Use the administration theme when editing or creating content, if you want to explicitly disable admin theme for this node-related page don't use _node_operation_route

The _node_operation_route option overrides _admin_route https://api.drupal.org/api/drupal/core%21modules%21node%21src%21EventSubscriber%21NodeAdminRouteSubscriber.php/function/NodeAdminRouteSubscriber%3A%3AalterRoutes/8.8.x


How to flag term reference without flagging term?

You may use the Relation module.

Relation allows you the create relations between entities that are entitties too. So the scheme will be:

Create a relation between your users and the skills entities (they can still be taxonomy terms).
Because these relation instances between your users and the skills are entities you can create a flag for this relation entities. So, when a user adds a skill to the profile you will have to create one relation entity with the user (or profile2*) and the skill.
When anotheruser wants to aprove this user's skill she will flag that entity relation. No other user is affected.

I checked Relation time ago and I remember that creating relations was a little bit tricky. I don't remember how to make relations so I can't help you in this point, sorry. You may need some custom code to achieve what you want.

*: to decide between Profile 2 or user take into account how are you going to show this information. For example, think which options fits better with Views.


Prepopulate CCK ImageField with existing images

There are several ways to do this.

I'm supposing that you just want to display the images on the node page, not necessarily filling imagefields on the Apartment node (right ?).

The easiest way is to change the way your reference field is rendered. By default, it should render a title. If you go to Content Management > Content Types > Apartment > Display Fields, you can change the display for the node reference field from a "title" to "teaser" or even "full node". That way you can display the images in your apartment node.

Another way, if you really just want the images and not the rest, is to do some coding. For example, in your theme template.php file, you could add the following code (Drupal 6 - because you mention CCK, I guess you're using D6, right ?):

function YOURTHEME_preprocess_node(&$vars) {
  if ($vars['node']->type == 'apartment') {
    $building_nid = $vars['node']->field_YOUR_REF_FIELD_NAME[0]['nid'];

    $vars['images'] = array();

    // If your imagefield can have multiple values OR only one value BUT the same field is present on
    // another content type
    $result = db_query("SELECT f.* FROM {files}
                          LEFT JOIN {content_field_YOUR_REF_FIELD_NAME} cf ON cf.field_YOUR_REF_FIELD_NAME_fid = f.fid
                            LEFT JOIN {node} n ON n.vid = cf.vid
                        WHERE n.nid = %d", $building_nid);

    // If your imagefield can have only ONE value and is ONLY present on this content type
    $result = db_query("SELECT f.* FROM {files}
                          LEFT JOIN {content_type_building} cb ON cb.field_YOUR_REF_FIELD_NAME_fid = f.fid
                            LEFT JOIN {node} n ON n.vid = cb.vid
                        WHERE n.nid = %d", $building_nid);

    while ($image = db_fetch_array($result)) {
      $vars['images'][] = $image;
    }
  }
}


Using Views and adding ALT and TITLE to an image

Is the title-field before the Global text-field?
Can you provide a screenshot of your field-settings in the View? (the most left column)


You can try module_load_include

  Loads a module include file.

Parameters

$type: The include file's type (file extension).

$module: The module to which the include file belongs.

$name: (optional) The base file name (without the $type extension). If omitted, $module is used; i.e., resulting in "$module.$type" by default.

Examples:

  // Load node.admin.inc from the node module.
  module_load_include('inc', 'node', 'node.admin');
  // Load content_types.inc from the node module.
  module_load_include('inc', 'node', 'content_types');


Is it mandatory to apply every minor Core upgrade step by step?

You can go from 6.26 directly to 6.28.

The most critical part, is the database update, because tables and fields can get modified, added or removed. The upgrade process in Drupal takes care of executing every single database update step.


For ordinary users, you can just disable the "Edit any content" permission for the type in the Node section of Administration » People » Permission GUI:

However if you also need the to prevent user #1 (the default Administrator role) from editing, this will not work, since access controls are not enforced for that user.  Instead, you can implement hook_menu_alter() to override the access callback for the node edit page, and provide your own instead:

function MYMODULE_menu_alter(&$items) {
  $items['node/%node/edit']['access callback'] = 'MYMODULE_node_edit_form_access';
}

function MYMODULE_node_edit_form_access($node) {
  $type = is_string($node) ? $node : $node->type;
  if ($type == 'my_type') {
    return FALSE;
  }
  return node_access('update', $node);
}

(Please note that user #1 should normally be trusted to not do anything stupid, so you should not usually have to use access control tricks to restrain user #1.)

Alternatively, you prevent anyone (including user #1) from editing any field (e.g. the body field) by disabling access the field hook_form_alter.  You can do this with any field that makes up the content type.

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'my_form_id') {
    $form['body_field']['body']['#disabled'] = TRUE;
    $form['body_field']['body']['#value'] = $form['body_field']['body']['#default_value'];
  }
}


Adding conditional statements to custom text fields in views

Sure.

Edit both fields -- [field_title] and [field_subtitle] -- so that both are "exluded from display"
Edit [field_subtitle], and select Rewrite the output of this field

In the box for the rewritten value, enter : [field_subtitle]
Make sure Hide rewriting if empty is checked at the bottom

Create a third field whose type is Global: custom text

Unlike the first two existing fields, do not check the Exclude from display box -- leave this one visible
In the Text box for that field (the value), enter [field_title][field_subtitle] (no spaces in between)

Hope that helps... :)


The solution reported in the issue report is to replace every occurrence of unset($form[$id]) with $form[$id] = array('#language' => NULL) in all the module file; you just search for the first string, and you replace it with the second string. The module file is media_gallery.module.
Who suggests the fix doesn't report in which line you find unset($form[$id]) because you probably find more occurrences of that string, and the user doesn't want to make a list of all the lines containing that string. It is also useless to make such list, as an editor can easily make a search and replace for the strings listed in the issue report.


How to remove extra white spaces and line breaks from HTML in drupal 7

Agree with rooby, whitespace in html does not slow down the site performance.

You can use the Minify module to remove extra line breaks and whitespace before and after HTML tag.

Minify also minimize the JavaScript files. Minimized JavaScript files are smaller in size as compare to regular JavaScript files. Smaller size will helps you to load site faster.

To use Minify

Download and install minify module
Go to performace
Select minify HTML
To minify JavaScript files select Minify JavaScript files in upper right corner


Create a view based on node reference field

I think here is a simple solution just add that the node reference field (field_pers_gallery) to contextual filter then all nodes (Images) which have same value in that field can be displayed on a page.


How do I override ajax-progress-throbber in a theme?

There is a new way of doing this as per this change record
add the following into the respective files
THEMENAME.info.yml
libraries-extend:
  core/drupal.ajax:
    - THEMENAME/throbber

THEMENAME.libraries.yml
throbber:
  css:
    css/throbber.css: {}
  js:
    js/throbber.js: {}
  dependencies:
    - core/jquery
    - core/drupal

js/throbber.js
/**
 * @file
 * Replaced Drupal cores ajax throbber(s), see: https://www.drupal.org/node/2974681
 *
 */
(function ($, Drupal) {
  Drupal.theme.ajaxProgressThrobber = function () {
    return "
" + Drupal.t('Loading&nbsp;&hellip;', {}, {
      context: "Loading text for Drupal cores Ajax throbber (inline)"
    }) + "
";
  };

  Drupal.theme.ajaxProgressIndicatorFullscreen = function () {
    return "
" + Drupal.t('Loading&nbsp;&hellip;', {}, {
      context: "Loading text for Drupal cores Ajax throbber (fullscreen)"
    }) + "
";
  };
    // You can also customize only throbber message:
    // Drupal.theme.ajaxProgressMessage = message => '
' + message + '
';
})(jQuery, Drupal);

css/throbber.css
// optional code of your ajax-spinner classes

An alternative would be to use the ajax_loader module which lets you customize the throbber.


Search API display message when match not found

In Views, under the Advanced Tab, click on NO RESULTS BEHAVIOUR. There you can include a general statement (global text) when it returns nothing.


How to add filter 'fq' in drupal 8 search api solr?

I have reached out to drupalsupport IRC got an answer from there. By the time I have got the reply from them debugged the code founded a createFilterQuery function in SearchApiSolrBackend.php file

$solarium_query->createFilterQuery('your_indexed_filedname')->setQuery('your_indexed_filedname:"string_to_be_searched"');

Here your_indexed_filedname would be something like ss_5f_test_5f_1

Don't forget to put double quotes for string to be searched, otherwise it won't fetch you the result.


How can I create a GET form with the Form API?

I have looked at Views's exposed filters to copy the behaviour I want.
Views however manipulates the behaviour in several places. I created my own FormBuilder instead (which wraps around the core's FormBuilder) in order to get the behaviour I want.

<?php

namespace Drupal\my_module\Service;

use Drupal\Core\Form\FormBuilder as CoreFormBuilder;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormState;
use Drupal\my_module\Form\AbstractForm;

class FormBuilder {

  /**
   * @var CoreFormBuilder
   */
  private $formBuilder;

  public function __construct(CoreFormBuilder $formBuilder)
  {
    $this->formBuilder = $formBuilder;
  }

  /**
   * @param $form AbstractForm
   * @param $method string GET|POST
   */
  public function getForm(AbstractForm $form) {
    if ($form->getMethod() !== 'GET' && $form->getMethod() !== 'POST') {
      throw new \Exception('Method must be either GET or POST');
    }

    /**
     * Other than core's FormBuilder, we provide a way to set the form's method to GET
     * Note that the getMethod()-method is not a default FormInterface method.
     * It is part of our own AbstractForm which implements both Drupal\Core\Form\FormInterface,
     * plus our own needed interfaces.
     */
    $form_state = new FormState();
    $form_state->setMethod($form->getMethod());

    /**
     * Because we remove the form ID's from the GET request,
     * we must set the form to always process.
     * And as a result of that, we must also disable the redirect,
     * or the submit process will become an endless loop.
     */
    if ($form->getMethod() === 'GET') {
      $form_state
        ->setAlwaysProcess()
        ->disableRedirect();
    }

    // Default behaviour copied from core's FormBuilder
    $args = func_get_args();
    // Remove $form_arg from the arguments.
    unset($args[0], $args[1]);
    $form_state->addBuildInfo('args', array_values($args));
    $build_form = $this->formBuilder->buildForm($form, $form_state);

    // Make sure that the form identifiers do not end up in a GET request
    if ($form->getMethod() === 'GET') {
      $build_form['form_build_id']['#access'] = FALSE;
      $build_form['form_token']['#access'] = FALSE;
      $build_form['form_id']['#access'] = FALSE;
    }

    return $build_form;
  }

}

By using this FormBuilder, it will:

remove form_id, form_build_id and form_token from the rendered GET-form, so that these won't be send to the GET request when the form is being submitted;
and because those identifiers are not there, the form_state will be set to setAlwaysProcess(), so that the form will be processed.


Captcha session reuse attack detected error message in form with anonymous user

The problem comes from the fact that it is NOT necessary to add the form_id and Captcha method in the Captcha Configuration when you use a custom form.

If you do this, when the form is generated on the page, the Captcha module is called TWO TIMES instead of only one, and this causes some troubles in the database, because when you call the form page, and when you submit it, TWO lines are created in the captcha_sessions table instead of only ONE !!

So, you will have :

Line number | Token    | Code
------------------------------------------------
N           | AAAAA... | TT7Zi                   <=== FIRST CALL
N+1         | BBBBB... | dccedb00fa1234567890... <=== SECOND CALL (ABNORMAL)

Then, when you submit, a new line is created in the captcha_sessions :

Line number | Token    | Code
------------------------------------------------
N           | XxXxX    | Zjj7R    ( UPDATE of the whole former TT7Zi line )
N+1         | BBBBB... | dccedb00fa1234567890...
N+2         | CCCCC... | 542dda8e8d7fda2358b4b2f319ef198b <== SECOND CALL !!

That's why the generated WATCHDOG error line says :

  user answered "TT7Zi", but the solution was "542dda8e8d7fda2358b4b2f319ef198b".


Do I need to download migrate upgrade module if use drush command?

No. You don't. In Drupal 8.1.3 This module is part of the core.

To have the full list of drush upgrade commands you would need Migrate tools  module though.

See here for more details.


How do I show the size of an Image file in media2 after selecting the image?

I found the solution. Somehow undocumented is the fact that this uses the "Preview" view mode. Editing that and ensuring its the one selected in image view changed everything to working normally.

Thanks.


How can I programatically add the default AJAX throbber to a form submit?

It should be easily done like this:

$form['submit']['#ajax'] = [
  'callback' => 'MYMODULE_submit_throbber_callback',
  'progress' => [
    'type' => 'throbber',
    'message' => NULL,
  ],
];

And then return $form in the callback;


How do I add HTML to my module's custom admin page?

What you have tried is the right way to do. I have checked the same code snippet and its working for me in my D7 installation. Hopefully the issue will be with some other form element (probably custom block ) that has be assigned in this page, might have some syntax error.

Thanks


display data (taxonomy terms) after uploading it directly to the database

From what I can tell those are all the taxonomy tables, but none of them seem to contain the term (url) path; thus, they must be in the url_alias table. Also, don't forget to flush your cache to see the changes.

I think it's better/safer if you use feeds to import your taxonomy terms.

Feeds

  Import or aggregate data as nodes, users, taxonomy terms or simple
  database records.

  One-off imports and periodic aggregation of content
  Import or aggregate RSS/Atom feeds
  Import or aggregate CSV files
  Import or aggregate OPML files
  PubSubHubbub support
  Create nodes, users, taxonomy terms or simple database records from import
  Extensible to import any other kind of content
  Granular mapping of input elements to Drupal content elements
  Exportable configurations
  Batched import for large files

Video Tutorial


Try with the FileField Nginx Progress module.

  This module provides support for an upload progress bar for a backend/server implementing the RFC 1867 upload using multipart/form-data. Nginx does not yet support RFC 1867 uploads in
  its suite of official modules. You can use the Upload 3rd party module to do that or just rely on PHP FastCGI support for RFC 1867.


Alternative to the need for dozens of roles to access special materials

Have a look at the Group module (commonly perceived as an alternative for Organic Groups).

Group 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. The Group module creates groups as entities, making them fully fieldable, extensible and exportable. Which also makes it integrate very well (out of the box) with commonly used modules such as Rules, Views, etc.

Some more questions you may want to look at for more details:

What are the various roles supported by the Group module?, which explains the various types of roles that can be used.
How to bulk assign existing content to a group created with the Group module?, a typical issue when adding this module to an existing site.
What are the features of the Group module versus Organic Group module?

Sample configuration

Below is an example of a possible configuration, which may help to get you started with possible configurations (using the Group module):

Group type ID ! Group type ! Group role ID ! Role
--------------+------------+---------------+------------
 1            ! Class      ! 3             ! Instructor
 1            ! Class      ! 4             ! Student
 2            ! Customers  ! 5             ! Lead
 2            ! Customers  ! 6             ! Prospect
 2            ! Customers  ! 7             ! Licensed Customer
 2            ! Customers  ! 8             ! Sales
 2            ! Customers  ! 9             ! Support
 2            ! Customers  ! 10            ! Accounting
 2            ! Customers  ! 11            ! R&D
 3            ! Project    ! 12            ! Project Manager
 3            ! Project    ! 13            ! Developer
 3            ! Project    ! 14            ! Customer

Group Types

The above example consists of 3 group types:

Class.
Customers.
Project.

Group Roles

For each of the 3 group types, there are specific Roles defined, some more details about some of them:

for the Class group, these are the 2 roles that are configured:

Instructor.
Student.

for the Project group, these are the 3 roles that are configured:

Project Manager.
Developer.
Customer.

These are the Group Specific Roles: these roles can be configured per group type and will only be available on groups of that group type. As an example, for group type "Class", the defined roles are Instructor and Student (which are not available for the other group types.

On top of the group specific roles, there are also Special Global Roles: These are the special (hardcoded) roles named Outsider (= a signed in user that did not join a group) and Member  (= a signed in user that did join a group). These cannot be defined by the Drupal administrator, and they are always available for any group. These roles can have different permissions sets for each group type. Special case: the role Anonymous is related to a user that is not signed.

Groups

Each of the configured group types can have any number of Groups.

Examples of groups:

for the Class group type, there could be these Groups:

Getting started with Drupal.
Drupal for site builders.
Become an expert in using the Rules module.

for the Customers group type, there could be these Groups:

Service Requests.
Order Processing.
Sales Orders.
Relationship Management.

Permissions

For each of the configured group types, you can then also configure for each Content Type which Role has what kind of access (= none, view, create, edit, delete). Be aware: even though this looks similar to Drupal's permission configuration, these permissions are not the same permissions (they are specific to the Group module).

Rules integration

Since you seem to be using CiviCRM also, you should definitely also consider using the CiviCRM Entity module, especially because of its integration with the Rules module ... combined with automagically creating (or deleting) so called "Group memberships" (which you can do via Rules). For an example of how to use Rules to create or remove such group memberships, refer to my answer to "How to add and delete a user to another group using 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".

Note

About your concern (as in your additional comment), which includes:

  ... having a list of permissions associated with each role multiplied so many times, editing and saving them taking extra processing power and stability issues. As well as the amount of work to the system each time the organization wants to add content. It just seems messy.

You're right, using standard Drupal permissions (with a zillion of roles) it would indeed become messy. But after you realize/discover how the Group module's roles/permissions work, your concern should be addressed ...


Use Bootswatch.com themes with Drupal Twitter bootstrap

Use the theme bootstrap

Download Bootstrap place it in the bootstrap theme folder as mentioned in the theme page. Update jquery to 1.7 you might have to use the Jquery Update (Use the development version of JQuery Update and not the stable one as the development version has option to update it to 1.7. You can do that by going to admin -> jquery Update

By default the theme uses the bootstrap.css So you can simply replace that css file with the new one you download from bootswatch and you are good to go...


I don't think it's possible to write a single entity query to accomplish this. You could take your $entity_ids result, use loadMultiple to load all the line_item entities, and then iterate through them to get all the products. Something like this:

$line_items = $this->entity_type_manager->getStorage('line_item')->loadMultiple($entity_ids);

$products = [];
foreach ($line_items as $line_item) {
  $product = $line_item->getProduct();
  if ($product && !isset($products[$product->id()])) {
    $products[$product->id() = $product;
  }
}

Another possibility would be to use the database service to construct a select query with actual database table names and fields (\Drupal\Core\Database\Connection).

See:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%21Connection.php/function/Connection%3A%3Aselect/8.2.x

and for the list of methods you can use to construct the select:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%21Query%21SelectInterface.php/interface/SelectInterface/8.2.x


Views merge rows: merge uniques values and show the first one

Sure there is probably some way to do that with PHP or an advanced SQL query. I recommend looking at Views Aggregator Plus as it allows you to aggregrate over Views PHP values.

Views is a simple query builder. When you want to do something really really complex, it can be useful to try to do some business logic outside of the views admin ui.


Hiding the previous instance in a Multi value field collection embedded widget

I think the solution is within the theme layer. By extending the admin theme (i.e. creating a sub-theme) you could create the desired behaviour using CSS and JS.


How to call Ajax callback on form submit to display results

Basic working code example for validation or submit form with ajax.

 function afaf_custom_form($form, &$form_state) {
  $form['d_id'] = array(
    '#type' => 'textfield',
    '#title' => t('D id'),
    '#size' => 60,
    '#maxlength' => 60,
    '#required' => TRUE,

  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Search'),
    '#ajax' => array(
     'callback' => 'v_custom_ajax_handler',
     'wrapper' => 'display-dept-ajax',
   ),
  );

  $form['#prefix'] = '
';
  $form['#suffix'] = '
';
  if (isset($form_state['values'])) {
    $form['output'] = array('#markup' => 'thankyou message');
  }
  return $form;
}

function afaf_custom_form_submit($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
}

function v_custom_ajax_handler($form, $form_state) {
  $form_errors = form_get_errors();
  if ($form_errors) {
    return $form;
  }
  else {
    $thank_you_html = drupal_render($form['output']);
    $commands[] = ajax_command_insert(NULL, $thank_you_html);
    return array(
      '#type' => 'ajax',
      '#commands' => $commands,
    );
  }
}


Implementations suggestions for content on front page

I'd use Panels to handle the layout.  Panels will allow you to create a customized front page without using any templates from within the Panels interface.  I can't describe in detail how to use Panels here but Node One has an excellent series of screencasts on Page Manager and Panels.

Using Panels will allow you to easily give the front page a unique look which you can change at any time by simply logging in to the site (as an admin) and opening up the Panels interface.

For the slideshow, try the Views Slideshow module.  It is well-documented (links on the module page) so you shouldn't have too hard of a time setting it up, and it is widely used (more than 100,000 sites).


Front Page button to add new element in node

There are ways. Here is one:

You will have to programmatically add value to that entity reference field. Here is how you should do it Programmatically update an entity reference field (see the multiple values case)

To make your button work you will need to add a route with arguments (one argument of the content ID you are adding a current user into) see here https://www.drupal.org/docs/8/api/routing-system/using-parameters-in-routes

And in order to add a button you can just update/override a corresponding twig template to inject HTML code of a button there referring the path of the route above with the nid as a parameter.


I would use 2 entity reference field, one in each content type referencing the other. With some custom logic, you could add the desired behavior, eg remove reference Foo -> Bar when the user removes Bar -> Foo.

Regarding the migation, you can run the first migration twice with the --update flag the 2nd time:

Step 1. Migrate Foo. The migration_lookup plugin will not find any values for the entity reference so it will be empty.
Step 2. Migrate Bar. Foo already exists, you should have no problem with the entity reference.
Step 3. Migrate Foo again, with the --update flag. Bar already exists, so the entity reference field will filled.


Use of hyphen instead of slash in hook_menu

Although I would never do this just for the sake of SEO personally, I believe the workaround is to use both hook_url_inbound_alter() and hook_url_outbound_alter(). By using these hooks you can change any URL displayed by the site to replace slashes with the hyphen, and then back again when Drupal processes the page after the user has clicked the URL. That way you can still use slashes in your hook_menu(), but it would show as hyphens in your site.

I'm not sure there is any other way.

Oh dear, I just realised the question was for Drupal 6, my apologies.

I think for Drupal 6, using custom_url_rewrite_inbound() and custom_url_rewrite_outbound() could be used instead.


How to delete all Taxonomy terms of particular vocabulary using entity_delete_multiple?

Try to use vid instead of type. I haven't tried the code, but try the following

$result = \Drupal::entityQuery('taxonomy_term')
      ->condition('vid', 'tags')
      ->execute();
  entity_delete_multiple('taxonomy_term', $result);

Here is a good example for using entityQuery.

For deleting users, you can use entity_delete_multiple or user_delete_multiple

To delete user with uid 10

entity_delete_multiple('user', \Drupal::entityQuery('user')->condition('uid', '10', '=')->execute());

or pass an array of uids to user_delete_multiple

user_delete_multiple(array $uids);

I'm not aware of how to delete comments.


Sounds as if you need the Submenu Tree module.

This is an excerpt form the project page:

  Submenu Tree provides a method for structuring content hierarchically. For content which has a menu link, Submenu Tree display a list of content which is at the same level or below the content in the menu.

Is this what you were looking for?


Updating a module is usually two steps:

Replace the files with the new version you downloaded, for example via FTP.
Run update.php (it is not always needed, but run it to check if updates are needed).

When updating, it can be a good idea to try the update on a local development environment to check that nothing breaks, and do a backup before the live update. Some updates are minor and won't need this.

Views, which stores a lot of configuration in the database and has recently undergone major changes, is one of those modules where you usually want to test it out before upgrading.


You can create a simple module, implementing hook_form_alter, add additional form submit action which checks the submitted values on your form, looks up if there is node matching them and finally loads and updates the node accordingly.

Alternatively, you can add the Existing Club Name field to registration, implement hook_user_insert, and do the same logic as described above. This would save you unnecessary web form and improve the user experience greatly.

EDIT:
Now that I think of it, it might be possible to achieve this using Rules module (https://drupal.org/project/rules) without coding. You add the field to the registration, create a rule, on event when user is created. Then iterate over all nodes of the Club content type (this should be possible with rules) and do a string comparison on each, to find the corresponding club. If the string comparison matches, you can easily change the node author. Please note that this solution is rather slow (and definitely not "right"), users could experience slow registration times.

Alternatively, you could change the rule event from user registration to form submission (which you have already) and therefore this (possibly) slow processing would not affect all users.

Also, I havent tried it, it's just an idea, but you should definitely try it.


Instead of drupal_render(), you should use drupal_render_children().

print drupal_render_children($form["something"]["something"]);


If you have image file in each theme folder use option 1,otherwise it is place in particular theme folder use option 2.

Better use path_to_theme() function to get current theme path.ex: sites/all/themes/test Note: please use php as the input format for your block.
use drupal_get_path('theme','test') for image is placed only in this theme folder.


How can I add a currency field to a content type?

So to add a decimal field.

edit your content type.
manage fields
add new field
select Decimal from the Field Type dropdown.
Click the 'Save' button
Change 'Scale' to 2. These are the cents.
Click the 'Save field settings' button.
In the Prefix field add '$'.
Click the 'Save settings' button


How does drupalxray.com find out the modules present on a thirdparty website?

I enabled access log on my site and then let www.drupalxray.com to review my site.

The entries in the access log looked like below.

HEAD /sites/all/modules/token_custom/LICENSE.txt HTTP/1.1
HEAD /sites/all/modules/active_tags/active_tags.js HTTP/1.1

As you can infer, looks like they have an exhaustive list of static files in all the modules that they can ascertain through their service.

They are using HEAD requests to save the bandwidth.
If the HEAD requests return 404 response code, the module is not present in the code base if it gets a 200 response code then it can ascertain that the module is present.

However it would be good to know if they have a list of modules with static files or if they have automated that to find the static files all the module on drupal.org.

The suggestion to enable access log was made by Clive.

Note : Currently the services only looks at the sites/all/modules folder only. But I think they can easily tweak a little to make it more generic.


Yes, OpenID always works with an URL, which is your identifier.

I think what you are looking for is the Janrain Engage module: http://drupal.org/project/rpx. This provides a similar workflow and UI like the one you know from StackOverflow.


Drupal7 GMAP module, show and hide certain markers

I was able to show and hide specific markers on my full map under Administration » Structure » Views » Full Map View. I added a filter that showed markers based the Content: Author uid. Then I set the pages I wanted to show to have one author and the other locations that I didn't want to display to a different author. This article helped me figure it out: https://groups.drupal.org/node/19614

Hope that helps you.


Display a grid view without border columns

I would use the Views Slideshow Module to build your slider, it's been the easiest to install and configure in my experience.

As far as changing colors, you are likely going to need to change your theme's CSS, which is not a Drupal specific problem. This search should get you started.


Count total number votes a user has gained

I think it would be pretty expensive to do this without writing your own query, but here is one way you could do it:

Use EntityFieldQuery to build a list of nids created by the current author. Something like this:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'article');
  ->propertyCondition('uid', '1')
$nodes = $query->execute();

Then parse the nids returned into a seperate array and use that array as a criteria parameter in votingapi_select_votes(). Something like:

$votes = votingapi_select_votes('entity_id' => $nid_array);

I'm not 100% sure that votingapi_select_votes() accepts an array for the $criteria['entity_id'] param. You might need to loop through each nid if it doesn't.


Mimemail + SMTP + Mail System: inline images make body empty

Further investigations lost me into the SMTP Authentication Support module
It's complicated enough and I couldn't locate something to help me find what was the problem coming form my configuration.

After a quick search within issues of Mime mail, someone was linking to another module to handle SMTP connection: enter link description here

Basically it works the same way than SMTP Authentication support but its benefit is you don't have to create a bridge mail system class between it and Mime mail, it's natively integrating with Mime mail.

To make it work properly, I had to configure Mail system as such :

Site-wide default MailSystemInterface class: MimeMailSystem
Mime Mail module class: MimeMailSystem
PHPMailer module class: DrupalPHPMailer

and in Mime mail settings :
 - set Mail engine to PHPmailer


Why cannot edit views because "The requested page could not be found."

The update to your original question suggests that the problem wasn't with Views itself.

When you do a drush cc all, it essentially calls drupal_flush_all_caches(), which

clears the JS cached files
clears the CSS cached files
rebuild2 the list of themes
rebuilds the theme registry
rebuilds the menus
rebuilds the list of content types
deletes all temporary items from the cache bins, and all items that had TTLs set which have expired

What I suspect, is that something happened to the menu tables and the cached entries were not fully rebuilt (I have seen this before).  Typically, it happens when you do a cache clear from the Performance page, and the process barfs, normally from running out of memory or timeouts because of load (I have seen the later on some servers).

When you did this from the command line, the menu tables got fully rebuilt that time, and your pages are available.

You should keep an eye on the amount of memory your site is using for page requests from a stale cache, and compare with the PHP memory_limit on your site.  If the two are close, you may have periodic overages which will cause sporadic problems.  Also make sure your Apache and MySQL are well tuned, as poor tuning can cause process stacking during cache clears, which can avalanche into a mess.


Update existing 'paragraph' entity while changing the ID is not supported

You could load the paragraphs through their parent entity to get the active revisions:
$nids = \Drupal::entityQuery('node')
  // load only nodes where this paragraph reference field exists and has content
  ->exists('field_paragraph')
  ->execute();
$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);
foreach ($nodes as $node) {
  $paragraphs = $node->field_paragraph->referencedEntities();
  foreach ($paragraphs as $paragraph) {
    if ($paragraph->hasField('field_foo')) {
      $paragraph->field_foo->value = 'bar';
      $paragraph->save();
    }
  }
}


How to find in a node template file that node is loaded directly or from 'node_load' function?

Edit: I realise after writing the answer that I sound rather negative. Sorry about that, but I can't phrase this in a positive fashion.

Answer: First, and foremost, you are mixing logic, with output. The template should not have logic in it, and should absolutely not care about why it was called.

When a user visits node/1, core will call node_load(1). This is in no way different from calling node_load(1) anywhere else.

A node template does also not execute as a direct result of loading a node. Templates are used when the theme layer renders a node, which is the completely other end of the response.

You can, in theory, call debug_backtrace() to get the call stack, and from there figure out more information about from where node_load was called, but there is almost certainly exactly 0 valid use-cases for this. I guarantee that you do not want to go down that path, and even considering it means that something is seriously wrong.

I have built Drupal-sites professionaly for years now, and have done some really, really ugly hacks during that time. Neither of them would come anywhere near analysing the stacktrace, in the theme layer.


Migrate user passwords from drupal 6 to already existing drupal 8 site

If you only want to migrate users and their passwords then you can do the same by using drush commands.
Firstly you have to install certain modules:
1.Migrate Upgrade
2.Migrate Plus
3.Migrate Tools

Then you have to create a manifest.yml file at the root of your d8 site.
The manifest.yml must look like this:

# user
- d6_user
- d6_user_profile_field
- d6_user_profile_field_instance
- d6_user_profile_entity_display
- d6_user_profile_entity_form_display
- d6_profile_values:user
- d6_filter_format
- d6_user_role
- d6_user_picture_entity_display
- d6_user_picture_entity_form_display
- d6_user_picture_file
- d6_user_picture_field
- d6_user_picture_field_instance

Then run the following drush command:

drush migrate-manifest --legacy-db url=mysql://d6user:d6pass@localhost/drupal_6 manifest.yml

For further information follow the following page:https://www.drupal.org/docs/8/upgrade/upgrade-using-drush


Most people just use a stylesheet to exclude layout for printing. it does not rely on any particular module.

The idea is simple, you include a stylesheet in your theme which removes the layout from your site, typically by using style:display:none; etc. You also size the font and remove images where possible to save ink.

You can read a really good tutorial here: http://www.alistapart.com/articles/goingtoprint/


Drupal console "settings:set" not working or I am doing it wrong

The "drupal settings:set" command updates the Drupal console's own settings rather than the configuration of the running Drupal site.

If you want a one-liner to update configuration, then you can use Drush for this job, eg:

drush cset user.settings register admin_only -y


If your requirement is to format Field Collection in Table Format, then Field Collection Table Module will help.


Is it possible to declare a Javascript library dependency at Hook.info?

You can define library dependency using hook_requirements(). Then if the library is missing, drupal will automatically shows the error message in status report(admin/reports/status).

Also it will show the error message, when trying to install module without having required library.

You need to define hook_requirements() in your youmodule.install file like below:

/**
 * Implements hook_requirements().
 */
function yourmodule_requirements($phase) {
  $requirements = array();

  if ($phase == 'runtime') {
      $t = get_t();
      $library = libraries_detect('tinymce');
$error_message = isset($library['error message']) ? $library['error message'] : '';

if (empty($library['installed'])) {
  $requirements['tinymce'] = array(
    'title' => $t('TinyMCE Library'),
    'value' => $t('Not installed'),
    'severity' => REQUIREMENT_ERROR,
    'description' => $t('!error Please download !tinymce, and extract it into the %directory directory.', array(
        '!error' => $error_message,
        '!vimeo.ga.js' => l($t('TinyMCE'), $library['vendor url']),
        '%directory' => 'sites/all/libraries/tinymce',
      )
    ),
  );
}
else {
  $requirements['tinymce'] = array(
    'title' => $t('TinyMCE Library'),
    'severity' => REQUIREMENT_OK,
    'value' => $t('Installed'),
  );
}
  }

  return $requirements;
}


Pathauto module doesn't translate urls generated by l(), url() to aliases, should it?

Ok, found the reason. My admin area is dual-languaged and while I generate aliases in English, front-end runs in Dutch. Once I switched admin and front-end to the same language I got it working as expected.


How do I change '|' to '-' in HTML page title?

I would have used existing $head_title_array variable like this:

<title><?php print $head_title_array['name'] . ' - ' . $head_title_array['title']; ?></title>

Reference: html.tpl.php

You can also do this with the Metatag module.


this is how i did it ( simplified for demo purpose )

function my_module_node_access(NodeInterface $node, $op, AccountInterface $account) {

global $user;
$user = \Drupal\user\Entity\User::load($account->id());

  if ($node->bundle() == 'my_content_type') {
    if ($op == 'view') {
        $visibility=$node->field_visibilite->getString();
        $target=$node->field_target->getString();

        if ($visibility ==='all')
            return \Drupal\Core\Access\AccessResult::allowed();

        if ($visibility ==='restricted')
            if (($target === 'group1') && ($user->hasRole('group1')))
                return \Drupal\Core\Access\AccessResult::allowed();

}

 return \Drupal\Core\Access\AccessResult::forbidden();

}


As stated in your quote, 401 Unauthorized must be combined with HTTP authentication, which is not what Drupal is using, so this is not an option.

So 403 is IMHO a perfectly valid response because clients must not repeat their request but might eventually fill out a login form wich whill result in a different request.

Special cases like the shortlink function you posted aren't so clear. I guess the reason for using access denied there is that it is checking the token which is kinda an authentication. But it could just as well use 400 or 404. I guess the reason for using 403 instead of 400 is simply because there is no helper function for returning a 400.

There also has been a discussion regarding the Privatemsg module (that I'm maintaing) whether trying a private message as anonymous user should result in a 403 or a 404 (for privacy reasons). It used to be 404 but has been changed to 403 because users often click on direct links in mail notifications and a 403 page can easily be turned into a login form (as there is a module that does this out of the box). So this is related to the last two sentences of the 403 description.


Why is Drupal prepending 'node' to the link URL?

the issue (for the current scenario) turned out to be hardcoded link in the page.tpl.php file. the front page was working ok as it had its own custom template but other pages were using the page.tpl template for rendering the links.

seems that sometimes small issues goes undetected. :) . just leaving this answer so that someone else may also look into such a possibility in their case.


Building form and saving as a content type

What you need is the workflow module. You would create your content type with all of the same fields as your current webform but set it to default 'unpublished.'

Enable the workflow and create new workflow states for 'draft' and 'reviewed'. Set
your actions to mark it in draft when the node is created by the user and then allow your editors to approve and publish.


Changing the file of a file field (drupal 7)

File fields are referenced by their ID in the file_managed table; as well as updating the field in your presave hook, you'll probably need to update the file entity that relates to that id with the new filename/path.

This is just a basic example but it should give you a starting point:

// Get the file id from the field
$fid = $node->field_file[$node->language][0]['fid'];

// Load the file
$file = file_load($fid);

// Update the filename
$file->filename = basename($new_path);

// Update the uri (this must be in the format of a schema uri, e.g. public://folder/file.jpg
$file->uri = $new_path;

// Save the changes
file_save($file);

You might also want to update the filesize field; it's used in a few places in the system.


How are the templates in the js_example module retrieved?

Inside js_example.module there's a function which declares how a render array using a certain '#theme' is to be rendered as HTML and which variables might be available. This function is hook_theme. It also can define a template that Drupal will look for inside the module's template folder.

function js_example_theme() {

  return [
    'js_example_accordion' => [
      'template' => 'accordion',
      'variables' => [
        'title' => NULL,
      ],
    ],
  ];
}

Next there is the src/Controller/JsExampleController.php which has a function to output stuff and is told to use the 'js_example_accordion'-'#theme' for that.

  public function getJsAccordionImplementation() {

    $title = $this->t('Click sections to expand or collapse:');

    $build['myelement'] = [
      '#theme' => 'js_example_accordion',
      '#title' => $title,
    ];

    $build['myelement']['#attached']['library'][] = 'js_example/js_example.accordion';

    return $build;
  }

That's the basics.

The description.html.twig is used a little bit differently but maybe just skip that for now as its some kind of advanced exception you'll understand later.


Are there any acceptable uses for $_COOKIE['has_js'] outside of core?

I don't think so, for many separate reasons.

Given the comment made to 8.x change records Removed has_js cookie:

  Only Batch API used it as a workaround. A clean solution has been reached avoiding the need for the cookie.

I would extrapolate that any solution that uses it should be considered unclean.
There is no page for it on api.drupal.org so it appears it wasn't designed to be used outside and it's not guaranteed to stay unchanged. It's a common in IT to assume one uses undocumented features at his own risk.
It can be unset if JavaScript is on, but Cookies are off, so it cannot have a clear meaning.
It can be unset if some module will successfully try to make site EU Cookie Law compliant (and user didn't agreed yet)
If you read it from PHP, it will be unset if your page is first one loaded after "open in private window" or "clear cookies" click, no matter what are client's JS and Cookie settings.

Reasons in no particular order.


Form field with support for multiple values

Found the solution in AHAH

With AHAH you can dynamically add new fields to the form using JavaScript.
Be sure to read http://drupal.org/node/331941 with examples of implementations from e.g. the Poll module.


Access imagefield file object during node create/update

Even if the field hasn't been updated yet you should have access to the fid column (the file ID), which you can use in conjunction with the file_load() function to get the filename:

// Load a file object based on the fid column fo the field.
$file = file_load($node->field_foo_image[$node->language][0]['fid'];

// Get the filename.
$filename = $file->filename;


Group module with advanced permissions based on taxonomy (preferrably)

You should really give the Group module a try, which allows for creating arbitrary collections of your content and users on your site, and grant access control permissions on those collections.

It creates groups as entities, making them fully fieldable, extensible and exportable. Every group can have users, roles and permissions attached to it (refer to "What are the various roles supported by the Group module?" for more details about that).

Sample configuration

Below is an example of a possible configuration, which may help to get you started with possible configurations (using the Group module):

Group type ID ! Group type ! Group role ID ! Role
--------------+------------+---------------+------------
 1            ! Class      ! 3             ! Instructor
 1            ! Class      ! 4             ! Student
 1            ! Class      ! 5             ! Alumni
 2            ! Customers  ! 6             ! Lead
 2            ! Customers  ! 7             ! Prospect
 2            ! Customers  ! 8             ! Licensed Customer
 2            ! Customers  ! 9             ! Sales
 2            ! Customers  ! 10            ! Support
 2            ! Customers  ! 11            ! Accounting
 2            ! Customers  ! 12            ! R&D
 3            ! Project    ! 13            ! Project Manager
 3            ! Project    ! 14            ! Developer
 3            ! Project    ! 15            ! Customer

Group Types

The above example consists of 3 group types:

Class.
Customers.
Project.

Group Roles

For each of the 3 group types, there are specific Roles defined, some more details about some of them:

for the Class group, these are the 3 roles that are configured:

Instructor.
Student.
Alumni.

for the Project group, these are the 3 roles that are configured:

Project Manager.
Developer.
Customer.

These roles can be configured per Group type and will only be available on groups of that group type. As an example, for group type "Class", the defined roles are Instructor, Student and Alumni (which are not available for the other group types).

On top of the group specific roles, there are also Special Global Roles: These are the special (hardcoded) roles named Outsider (= a signed in user that did not join a group) and Member  (= a signed in user that did join a group). These cannot be defined by the Drupal administrator, and they are always available for any group. These roles can have different permissions sets for each group type. Special case: the role Anonymous is related to a user that is not signed.

Groups

Each of the configured group types can have any number of Groups.

Examples of groups:

for the Class group type, there could be these Groups:

Getting started with Drupal.
Drupal for site builders.
Become an expert in using the Rules module.

for the Customers group type, there could be these Groups:

Service Requests.
Order Processing.
Sales Orders.
Relationship Management.

Permissions

For each of the configured group types, you can then also configure for each Content Type which Role has what kind of access (= none, view, create, edit, delete). Be aware: even though this looks similar to Drupal's permission configuration, these permissions are not the same permissions (they are specific to the Group module).

Addressing your specific questions

Here is a possible recipe to get you going:

You'd only need 1 group type, say labeled "Departments".
Define whatever Group Roles you'd need for this Group Type and configure the desired Group permissions for each of those roles.
Creating Groups like Department A, Department B, Etc.
Make each user a member of the appropriate group (could be 1 or more, depends on your needs).
Assign each node to the appropriate group.

Further refinements using some other modules

Additional permissions per node

Providing additional view permissions for specific nodes to "Outsiders" (not member of a group) can be provided by the Permission by terms module.

This can by achieved by creating a Taxonomy Term reference field on nodes which points to a vocabulary "Additional Permissions" with terms "public" and "intranet users". Those terms get permissions assigned to them for respectively the "Anonymous Users" and "Authenticated Users" roles. When you set the field on a node to either of those values, users of the respective roles get view permissions, irrespective of the group view permissions. Nodes that don't have a value for the term reference field just get the group permissions by default. Edit permissions are not affected by this and are just defined by the group roles/permissions.

Changing the Group page layout

If you don't like the default way the group pages look like, you can modify them by using the page manager, together with panelizer and bootstrap_kit for instance. Together with views (using the "Group content" and "Content from group content" relationships optionally) gives you tremendous flexibility over how the group page is displayed.

Comparison with the Organic groups module

Have a look at my answer to "What are the features of the Group module versus Organic Group module?" for details about:

How both modules (Group versus Organic groups) compare to each other.
Integration with various modules that you might want to take advantage of also.

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". This video tutorial describes a scenario that is extremely close to your question here ...


Your question seems like a variation of this Master Summary with drill down: change "Schools" by "States" and "Domains" by "Cities" to understand what I mean.

To illustrate the "drilldown" feature of it, just click, for any of the states included, on either the corresponding column (in the chart) or link (the Total in the tabular report below the chart). If you do so (e.g. for state "IL"), you'll get the details (another tabular report) for the state you selected. If on the last tabular report you want to switch to the details for another state (e.g. for state "Florida"), use the pull-down selection list within "Parameters" (near the top of the report), and change the selected value to "Florida".

Even though the sample here doesn't allow you to do so, it would be straight forward to replace the "number of users" for each of these cities to yet another hyperlink to another report (eg to provide the details of each of the users).

To further enhance the user experience, you can optionally combine this with the (amazing) dataTables jQuery plugin. A working sample of it (that you can use to experiment with it) is shown in the Customized Simple Table of States.

The magic behind this kind of drill down reports is NOT Views, but instead it is the Forena Reports module. One way of using it, is as a  Views display format.

For more details about this module, refer to its Community Documentation. Or have a look at the module's documentation that comes with it, as in this demo site also.

Disclosure: I'm a co-maintainer of this module.


Is it possible to make summary mandatory?

Short Answer

Yes, you can require the summary field be populated before it can be sumbitted.

Details

Implement hook_form_FORM_ID_alter() in a custom module.

hook_form_FORM_ID_alter(&$form, &$form_state, $form_id) {
   $form['body'][LANGUAGE_NONE][0]['summary']['#required'] = TRUE;
}

This assumes that you are taking the standard "body" field and requiring that it's summary be entered before submission.


After eating dinner, washing the dishes, playing around with it and reading the comments in views-view-fields.html.twig located in core\modules\views\templates

/**
 * @file
 * Theme override to display all the fields in a row.
 *
 * Available variables:
 * - view: The view in use.
 * - fields: A list of fields, each one contains:
 *   - content: The output of the field.
 *   - raw: The raw data for the field, if it exists. This is NOT output safe.
 *   - class: The safe class ID to use.
 *   - handler: The Views field handler controlling this field.
 *   - inline: Whether or not the field should be inline.
 *   - wrapper_element: An HTML element for a wrapper.
 *   - wrapper_attributes: List of attributes for wrapper element.
 *   - separator: An optional separator that may appear before a field.
 *   - label: The field's label text.
 *   - label_element: An HTML element for a label wrapper.
 *   - label_attributes: List of attributes for label wrapper.
 *   - label_suffix: Colon after the label.
 *   - element_type: An HTML element for the field content.
 *   - element_attributes: List of attributes for HTML element for field content.
 *   - has_label_colon: A boolean indicating whether to display a colon after
 *     the label.
 *   - element_type: An HTML element for the field content.
 *   - element_attributes: List of attributes for HTML element for field content.
 * - row: The raw result from the query, with all data it fetched.
 *
 * @see template_preprocess_views_view_fields()
 */

{{ fields.title.content }} worked for me. In hindsight it's very similar to the D7 code, duh, lol.

For other fields:

{{ fields.machine_name.content }} What's the machine name? You can find them under the Machine Name column in the Manage Fields of your content type or block.


These are protected. You need to use any available getters to access them. Example, for nodes, the method is getType(). $node->getType(). Most generic entities should have a bundle() method that returns type.

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21Entity.php/function/Entity%3A%3Abundle/8.4.x

Examples:

$bundle = $myEntity->bundle();

$variables['bundle'] = $bundle;

Twig: {{ bundle }}


Display blocks on taxonomy and content type pages

I think Pathauto module could be your friend here. This module allows to define automatic url patterns for different entities, notably vocabularies, using tokens (Token module needed).
By default, you will have [term:vocabulary]/[term:name] for any taxonomy term page. Then you just have to configure your taxonomy menu block : Pages > Show block on specific pages : your-vocabulary/* (of course replace "your-vocabulary" by the name of the vocabulary you created).
The process is the same for any content type page.

Example:
Vocabulary : Fruits
Terms : Apple, Orange, Strawberry
The Apple page url would be : your-site/fruits/apple
You configure your block with : Show block on specific pages : fruits/*
And then your block will only appear on taxonomy term pages related to the vocabulary Fruits.


Hide/remove js-view-dom-id in just one specific view

Yes, you can easily create an override for views-view.html.twig which will only apply to a single View.
Taking the example from Views template files:

View, named foobar. Style: unformatted. Row style: Fields. Display: Page.

views-view--foobar--page.html.twig
views-view--page.html.twig
views-view--foobar.html.twig
views-view.html.twig

So if your View is called "articles", you can use views-view--articles.html.twig to override the template for the whole View, views-view--articles--page.html.twig to target just a display named page for the same view, and so on.


Internal server error on admin/modules/list/confirm

You need to check your PHP memory limit on php.ini.
If you use Linux, go to /etc/php.ini to find it out.


How to change rest export views field alias programmatically

You can create a ViewsField Plugin with the custom module and name whatever you want.


Does Drupal modify folder permissions during runtime?

Yes drupal modify default folder permission during runtime, and this folder is what exactly you should add it to your .gitignore because it contains user uploaded files which have not value to keeping in repository.


Set label of $entity programmatically in a custom form

It's not clear what entity type you have. In the question you ask for the label of a content type, which would be the entity node, then the label field is title. In the question title it is a more general question about the label of an entity and in the code you redirect to a group_content entity route, which would suggest this is another entity type.

In this case, if you don't know the entity type, you could use this generic code to get the label field name and set the label with it:

$label_field = $entity->getEntityType()->getKey('label');
$entity->set($label_field, 'New label');


How do I better play nice with weights, when overriding a form?

The only thing I usually do and can recommend is to leave "gaps" between your weigts. So instead of 1, 2, 3, 4, 5 or so, I use for example 5, 10, 15, 20, 25.

The idea is that it makes it easier for other modules to move a field to a different place, or move new fields in-between.


How to change the text in the revision log message?

Use the following code in a custom module or in your theme's template.php:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function YOURMODULE_form_CONTENTTYPE_node_form_alter(&$form, &$form_state, $form_id) {
  $form['revision_information']['log']['#description'] = t('Your new instructions.');
}

Note: replace YOURMODULE with your module/theme name and CONTENTTYPE with machine name of the content type you want to change.


Views 2 - Don't display results if user DOES NOT have a specific permission

Hook_perm to the rescue! I would suggest thinking the other way around: Grant access to the view's results if the user HAS a permission. Create a new permission and assign it only to the roles that may view the results.

In your custom module, add a new permission like so:

function mymodule_perm() {
    return array('can view results of my view');
}

Then in your view, change the 'Access' setting to your new permission.

You may run into problems if the roles that you're trying to exclude have the 'Access all views' permission (or a similar administrative views permission). If that is the case, you'll need to use a views hook to remove the results.

function mymodule_views_pre_render(&$view) {
  switch($view->name) {
    case 'the_view_name':
      if(!user_access('can view results of my view')) {
        $view->result = array();
      }
    break;
  }
}

I would flush caches in order to have this hook picked up by views.