Problem with equal height of columns in Display Suite

Create your own layout for display suite and use CSS.

Add the folder 'ds_layouts' to you theme folder root.
Under that folder ad another folder: two_col_fluid_stacked_fixed_height

Ie Must look like this: YOURTHEMEFOLDER -> ds_layouts -> two_col_fluid_stacked_fixed_height

Add the following files to two_col_fluid_stacked_fixed_height folder:

two_col_fluid_stacked_fixed_height.inc

<?php
function ds_two_col_fluid_stacked_fixed_height() {
    return array(
        'label' => t('two col stacked fluid fixed height'),
        'regions' => array(
            'header' => t('Header'),
            'left' => t('Left'),
            'right' => t('Right'),
            'footer' => t('Footer'),
        ),
        'css' => TRUE,
    );
}

two-col-fluid-stacked-fixed-height.tpl.php

<<?php print $layout_wrapper; print $layout_attributes; ?> class="<?php print $classes;?> ds-2col-stacked-fluid-fixed-height clearfix">
  <!-- Needed to activate contextual links -->
  <?php if (isset($title_suffix['contextual_links'])): ?>
    <?php print render($title_suffix['contextual_links']); ?>
  <?php endif; ?>

    <<?php print $header_wrapper; ?> class="group-header<?php print $header_classes; ?>">
      <?php print $header; ?>
    </<?php print $header_wrapper; ?>>

    <div class="center-wrapper">

    <<?php print $left_wrapper; ?> class="group-left<?php print $left_classes; ?>">
      <?php print $left; ?>
    </<?php print $left_wrapper; ?>>

    <<?php print $right_wrapper; ?> class="group-right<?php print $right_classes; ?>">
      <?php print $right; ?>
    </<?php print $right_wrapper; ?>>
    </div>

    <<?php print $footer_wrapper; ?> class="group-footer<?php print $footer_classes; ?>">
      <?php print $footer; ?>
    </<?php print $footer_wrapper; ?>>

</<?php print $layout_wrapper ?>>

<!-- Needed to activate display suite support on forms -->
<?php if (!empty($drupal_render_children)): ?>
  <?php print $drupal_render_children ?>
<?php endif; ?>

two_col_fluid_stacked_fixed_height.css

.ds-2col-stacked-fluid-fixed-height > .group-header {
}

.ds-2col-stacked-fluid-fixed-height .center-wrapper > .group-left {
    float: left; /* LTR */
    width: 50%;
}

.ds-2col-stacked-fluid-fixed-height .center-wrapper > .group-right {
    width: 50%;
    height:99999px;
    position:absolute;
    right:0;
}

.ds-2col-stacked-fluid-fixed-height .center-wrapper {
    overflow:hidden;
    position:relative;
}

.ds-2col-stacked-fluid-fixed-height.group-one-column > .group-left,
.ds-2col-stacked-fluid-fixed-height.group-one-column > .group-right {
    width: 100%;
    float: none;
}

.ds-2col-stacked-fluid-fixed-height > .group-footer {
    clear: both;
}

/*delete this*/
.group-left {
    background:yellow;
}
.group-right {
    background:red;
}

Clear you cache and use this layout in display suite. Tweak CSS to your liking.


Wrong path when moving from MAMP multisite to remote website

It sounds like in MAMP you're using one domain, localhost, instead of three separate domains for three separate codebases.

You should set up three domains in MAMP and then you can use relative urls such as "/node/50" instead of "/site1/node/50".

Then your config would be in /sites/default/settings.php, with an included settings.local.php that is git excluded to use different database credentials between the local and production sites.

Multisite is a different set up.

You wouldn't have three separate codebases, such as "/htdocs/site1", "htdocs/site2" and "htdocs/site3".

You would have one codebase such as "htdocs/mymultisite".

With a non-multisite set up with three separate codebases, you would create three hosts in MAMP and then point each docroot to that site's docroot, for example, "/htdocs/site1", "htdocs/site2" and "htdocs/site3".

For a multisite set up, you would use one codebase (such as "htdocs/mymultisite" and create a sites folder for each domain.  First, you would copy example.sites.php to sites.php in the /sites folder of your repo. Then for each host, you would set up a folder with a separate settings.php, for example:

/sites/site1.local/settings.php
/sites/site2.local/settings.php
/sites/site3.local/settings.php

with the folder name corresponding to the domain set up in MAMP.

(With a non-multisite set up with separate codebases, you can just use the /sites/default/settings.php)

For both separate codebases and hosts in mamp, and for multisite with sites folders, it should work to visit each domain, such as site1.local in your browser, the urls will be relative to that URL.

If you are using multisite, when you want to go to production, you can set up a folder for production.  Set up a folder for production:

/sites/mysite.com/settings.php

There is a lot of information about setting up multisite Drupal.


What is the CCK module? Is it a core module in drupal 7 or do I have to install it?

Most of the CCK code is part of Drupal 7. Actually, the code in Drupal 7 is quite different from the code used from the CCK module in Drupal 6. That is the reason why there is a Drupal 7 version of CCK; the other reason is that not all the code that is part of the CCK module was ported to Drupal 7 core.
In short, you need CCK for Drupal 7 to upgrade a Drupal 6 site using CCK to Drupal 7.

As for using the Drupal 7 development snapshot, the usage statistics say there are 36007 sites using CCK for Drupal 7 out of 222100 sites using CCK, while 3081 sites are using the Drupal 5 version.


function mymodule_node_add() {
 module_load_include('inc', 'node', 'node.pages');

  //I'm doing a print here instead of returning because I'm calling this page
  //in an AJAX popup, so I don't want the whole page to output, only the form.
  $form = node_add($node_type);//You need to pass content type here. THat's it.
  print render(drupal_get_form('mymodule_node_add_form'));
}


Is it possible to remove the contextual link for deleting a node?

You can implement hook_menu_contextual_links_alter() to remove the "delete" link from the contextual links.

function YOURMODULE_menu_contextual_links_alter(&$links, $router_item, $root_path){
  unset($links['node-delete']);
}

However, if your users are irresponsible enough to believe that "deleting" a node does not actually delete it, you may be better off simply removing those users' permissions to delete nodes at all.


In Views, how can I show a blank end date if no value is entered?

To answer my own question:

I used the Views Conditional module and set it up as follows:


Webform-CiviCRM integration: autocomplete employer

The anonymous user does not have permission to view contacts in your database. Be thankful for this default, it can save you from accidentally exposing your entire database to the world!

You can override this default by editing the "existing contact" field (from the webform tab) and unticking "Enforce Permissions". Typically you would also set one or more filters on that form (e.g. pick a group) to limit the autocomplete to just the organizations you want to expose.


How do I set the default value of a datetime form element?

use Drupal\Core\Datetime\DrupalDateTime;

and in form

$form['start_date'] = array(
  '#type' => 'datetime',
  '#title' => t('Start Date'),
  '#default_value' => DrupalDateTime::createFromTimestamp(time()),
);


I don't really advise this but here is a solution.

Create a php file in your Drupal root containing the following

<?php
define('DRUPAL_ROOT', getcwd());
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
?>

That will give you access to the full Drupal api. You can then put whatever markup you wish underneath.

A better method (but more complicated) would be just to create a custom page callback in a module then you can use that to either bypass Drupals theming, or you can make it change the theme to a custom one that produces very basic markup (you'd have to create that yourself).

If you want any details on how to do that let me know :)


Drupal paid subscription manager where nodes are removed upon expiration

You want Commerce License, a framework built exactly for that. You can write a custom license type that creates / deletes the node when the license status changes (and it would be a good candidate for a generic contrib).

The recurring side is handled by Commerce License Billing.

EDIT: There is now a Commerce License Node project too, doing what I described.


In Ubercart auction final bid amount adds sell price instead of highest bid amount in the cart?

/**
 * Implements uc_cart_alter.
 */
function mymodule_uc_cart_alter(&$items ) {

  foreach ($items as $index => $item) {

   //you can add condition for your bid product

    $items[$index]->price = 100;
  }
}

For reference:

http://www.ubercart.org/docs/api/hook_uc_cart_alter


"Censor" View results/ CCK fields (Censor based on a role)

The only way I can think of to do this without making two views (which would be my preference to be honest) would be to use the Views Customfield module and use a PHP snippet to check permissions and display the result accordingly.

Create your view as normal and when choosing the field that you wish to change, make sure you check the bock that says "Exclude from display".  Then add a custom PHP field directly after it and use code along these lines:

<?php
  // Check the logged in user
  global $user;
  // Check if the user has a certain role
  if (in_array('USER ROLE', array_values($user->roles))) {
    print $data->FIELDNAME;
  }
  else {
    print "Withheld";
  }
?>

Obviously you'll need to replace 'USER ROLE' with the role that you're looking for and you'll need to replace $data->FIELDNAME with whatever the Views fieldname is, for example $data->nid or $data->title.

Otherwise you could use a View with two slightly different block displays, embedded in a contextual Panel that checks for users permissions and displays accordingly.

Edit after asker comment: Craig, a few things. Firstly, I don't think you're approaching the problem correctly at all.  What you want to do is difficult and a  outside of the scope of your question - you asked how to alter a value on a view, not show two different values globally depending on permissions. Before you can get the solution you need to ensure you're tackling the right problem. You simply need to hide a value in two situations depending on a permission, nothing more.

Secondly, I'm not going to give you another solution as I have given you a perfectly good solution to your question.  This may not be perfect for you but with some initiative you could very easily solve this problem with what I've given you. If you persevere with this information you can use the Content Templates module and the same code as above to hide the value on a node.

Thirdly, never hack modules.  If you want to change the behaviour of a module, write another module to alter it.


How to transfer field content of a view to a another view as a filter by clicking this content entry

{{field_example__value}}

view-> Field-Content field_example _> overwrite output.

Works as well. Thx to 4*4 again.


How can I add a tab to the admin/content page

Similar to Drupal 7, tabs are called "local tasks". Your module should implement a local task and a route.

The complexity in this is that /admin/content is a views-generated route with a system module fallback in case the view is disabled (as explained by @Berdir below), and the base route should be system.admin_content.

mymodule.mytask:
  title: 'My Task'
  route_name: 'mymodule.mytask.route'
  base_route: 'system.admin_content'
  weight: 1

If the view itself isn't altered, then the route is view.ID.page_NUMBER. I've done this latter thing working on an entity example module in my sandbox (Shift).


Does deleting a field in a content type remove the data?

Deleting the field deletes the data too.
As far as I can see, the database tables used to contain the field data are renamed, but they are emptied.

Visiting the page at admin/structure/types/manage/forum/fields, I deleted the "Forums" field used for the "Forum" content type; this is what I see watching the content of the database used for my Drupal test site, after I removed the field.

To notice also that the "deleted" column in the "{field_config_instance}" table is set to 1 for deleted fields.


function mytheme_preprocess_image(&$variables) {
   if ($variables['style_name'] == 'slides') {
       $variables['attributes']['data-original'][] = file_create_url($variables['path']);
       $variables['attributes']['class'][] = 'lazy';
       $variables['path'] = '/sites/all/themes/mytheme/images/grey.png';
   }
}

Regards


In Drupal 7 Commerce, how do you change the "View Cart" link in the cart block to something else?

There's a couple of ways.

You could implement the Commerce hook to adjust the line item summary info

hook_commerce_line_item_summary_link_info_alter

e.g:

/**
 * Implements hook_commerce_line_item_summary_link_info_alter
 */
function MY_MODULE_commerce_line_item_summary_link_info_alter(&$links) {
  if (!empty($links['view_cart'])) {
    $links['view_cart']['title'] = t('View the magical cart');
  }
}

See also commerce_cart_commerce_line_item_summary_link_info for the default data.

Another way, as mentioned by 4life, is with the stringoverrides module or if you aren't using it already, you can change the text in settings.php without an additional module

$conf['locale_custom_strings_en'][''] = array(
  'View cart' => 'View the magical cart',
);

Either of those approaches should work there.


Find an entity that most recently referenced a particular entity

I am afraid, it's impossible to achieve what you want with a simple entity reference field alone.

The problem is that while the wardobe content saves the date of its most recent edit, you can not tell which (if any) product was added during that editing session (unless you use versioning consistently and compare the products saved in different versions manually). To complicate things further, an entity only saves the date of its most recent edit (saving over the previous edit date) which makes it very inadequate to track when a particular product was added to a wardrobe.

The biggest issue you face is that the information you need (when an item is added) is not directly tracked at all. While you could probably figure it out if you use versioning, this data would still be very hard to access in views.

What you can do is make a list of wardobes a particular item is part of and order them by most recently updated wardobe (though this most recent edit may or may not have actually added that product). If that's not what you want you need to find a way to track the missing date information yourself.

Possible starting points which come to mind:

Custom compound field with joined reference + date fields: https://www.phase2technology.com/blog/compound-fields-in-drupal-7/
Custom module which adds a db table with columns for wardrobe id, product id and date. You can access these data on node save, during which you can still access the old version of the wardobe, check which (if any) products were added, and add those entires to the db.


How to load to panels a referenced node?

You'll want to add a display to your view of type "pane". Give it a descriptive title so you can find it from your Page Manager.

Then you'll create a Page Manager variant that displays on the entity (user) to which you want to attach this view. Under "content" you'll click the gear that appears in the top left, and click "add content". Select "view panes" and then select the view pane you just created.

In order to pass the node ID to the view pane, you'll go back to the view. Under "pane settings" select "argument input" and set it to "from panel argument". You'll probably want the first argument.


Views Calendar Pager Skips a Month Forward

This is a bug in the Date module, fixed by this simple RTBC patch in comment #35

https://www.drupal.org/node/2375235#comment-10205617


Use the Json::decode() method:

use Drupal\Component\Serialization\Json;

...

$decoded = Json::decode($data);


Just add this style to your CSS file

#squeeze .right-corner .left-corner .breadcrumb {
  position: static;
}

This will position your breadcrumbs div according to the normal flow of the page.


Module to import github content onto local drupal server

I made my own module. You can see part of the code here. I put that code on a cron_hook.


I found a better explanation here so I'm not going to explain much about the $form_state itself here.

To present a form, you have to use drupal_get_form() function that returns a render-able array of the form.
To build the form, you need to give a form ID (to get the form API arrays) and the state of the form. Form State ($form_state) becomes handy when you need to store arguments, previous step values, and many more (see the linked post above).

Ctools modal forms has many basic features.

Detecting whether JavaScript is available in the user's browser.
Falling back to normal HTML forms if JS is not enabled in the browser.
Keep form validation and submit functions working in the popup form.
Executing certain functions when the form is submitted.

Here is an example of a full Modal form menu router item. Note that I'm not using %ctools_js menu loaders to make this simple:

function quotes_editform_ajax($form, &$form_state, $quote){
  ctools_include('ajax');
  ctools_include('modal');
  $form_state = array(
    'ajax' => true,
    'title' => t('Edit quote'),
    'is_ajax_update' => TRUE,
    'quote' => $quote,
  );

  $output = ctools_modal_form_wrapper('quotes_editform', $form_state);

  if (!empty($form_state['executed'])) {

    // Add the responder javascript, required by ctools
    ctools_add_js('ajax-responder');

    // Create ajax command array, dismiss the modal window.
    $output = array();
    $output[] = ctools_modal_command_dismiss();
    $output[] = ctools_ajax_command_reload();
  }

  print ajax_render($output);
  exit();
}

Explanation:

  ctools_include('ajax');
  ctools_include('modal');

These functions will include specific ctools plugins for our use.

  $form_state = array(
    'ajax' => true,
    'title' => t('Edit quote'),
    'is_ajax_update' => TRUE,
    'quote' => $quote,
  );

Here we build the $form_state to pass to the form builder function (drupal_get_form(). ctools_modal_form_wrapper() calls drupal_get_form()).

$output = ctools_modal_form_wrapper('quotes_editform', $form_state);

Here, we build renderable array of the form. But the difference between drupal_get_form() is that it's actually in Ajax response form.
quotes_editform is a function that returns a form array.

function quotes_editform($form, &$form_state) {
  $form['name'] = array(
    '#title' => t('Name'),
    '#type' => 'textfield',
    '#default_value' => !empty($form_state['quote']->title)
       ? $form_state['quote']->title
       : '',
  );
  return $form;
}

In this $form_state array, ajax and title keys are ctools-specific. The title will be the popup's title and ajax is required to Ajax-ify the form.
Pay attention to the #default_value of the above snippet. If we are going to show an edit form, we need to know the existing values. So we send whatever we have to the form builder function.

Node forms are a little complex that there is a base form and child forms for each form.
This form ID is same as what you receive as the third parameter in hook_form_alter($form, $form_state, $form_id) hooks.

You are free to store whatever in this $form_state array.
$form_state array is passed to submit and validation functions so any of those functions can make use of those data.


One way to implement this, assuming that you will show the entire document library as a block.
I'll build this in reverse order because in Drupal, there is no "tree" structure; philosophically, Drupal adopts a "tag" (multivalue) structure, so you have to nudge the tags into a tree structure.
This can seem like a disadvantage coming from a tree-based system, but it's one of Drupal's strengths because tags allow for multiple parents.
So first, for each sub category, create a view mode called "Show documents".
View mode creation path: /admin/structure/taxonomy/manage/MY_VOCAB_MACHINE_NAME/overview/display, scroll down and choose "Manage view modes" under "Custom settings."
After adding the view mode, go back to /admin/structure/taxonomy/manage/MY_VOCAB_MACHINE_NAME/overview/display, check the box for "Use custom display settings for the following view modes" and press Save.
Now you can edit this view mode to get the display of content you want.
For that, I would create a view.  This view should use a contextual filter to get the current taxonomy term, and then it should use fields to list the title, image, and file link.  The display mode should be block.
After you create the view, enable the Layout Builder module. This will allow you to completely customize the layout per view mode.
Now, you can go back to the view mode page and attach the block showing the content to the term.  Depending on how you implement the accordions, you should be able to adjust the CSS classes in Layout Build and the Views UI (for the block) to get what you want.  Using a view mode will also let you target a theme template specifically to that view mode.
Finally, you can make another view (block) of the sub categories, this time grouping them by parent.  And then set the view to show the display mode of the sub categories to the view mode that you created earlier, which will automatically bring in all the accordions.
This is not the only way to do this; another way is to use the embed feature of views, which lets you embed one view inside another.


Include content on module install of a custom block

Use https://drupal.org/project/default_content for install time content. For ongoing content, there is Entity Pilot (disclaimer: my product) https://drupal.org/project/entity_pilot.


You can use the hook_form_alter() to alter the form and change the weight attribute, if your field is field_username you can use something like this:

function YOUR_MODULE_NAME_form_alter(&$form, &$form_state, $form_id) {

  if($form_id == 'YOUR_FORM_ID') {

    $form['field_username']['#weight'] = -50;
    $form['field_email']['#weight'] = -49;
  }
}


I don't think the $user->data value can be read by views.  You are probably better off creating a field to store the email value.


correct way to load JS library for custom module

drupal_add_library() works only with libraries defined from hook_library() implementations. Since the d3.js module implements hooks used from the Libraries API module, you need to use the functions this module make available.

See Using Libraries API 2.x (as a module-developer) or Using Libraries API 1.x (as a module-developer), basing on which version of the Libraries API module you are using.

Normally, with the 2.x branch of the Libraries API module, you just call libraries_load('d3') which will call drupal_add_js(), or drupal_add_css(), or both, depending on what the library contains. Otherwise, if you need to check when a library has not been loaded, you use code similar to the following one.

if (($library = libraries_load($name)) && !empty($library['loaded'])) {
  // The library has been loaded.
}

Even better, using a render array, you just need to use code similar to the following one, which is for the case the library needs to be attached to a form element.

$form['myelement']['#attached']['libraries_load'][] = array('d3');

For an hook_page_build() implementation, adding the library at the page bottom requires code similar to the following one.

function mymodule_page_build(&$page) {
    $page['page_bottom']['d3_library']['#attached']['libraries_load'][] = array('d3');
  }
}


Import files into a file field in Drupal 7

I am currently working on the exact same thing, except using photos.  If you click my profile name, you will see a series of questions related to learning how to do what you are asking to do.

I was able to easily accomplish the code to loop through all the files in my folder and add them to my nodes.

$file = new stdClass();
$file->filename = basename($local_path);
$file->filepath = $local_path;
$file->uri = $local_path;
$file->filemime = $mime;
$file->filesize = filesize($local_path);

// Set this at the very beginning to correspond to USER you want posting items.
$file->uid = $uid;
$file->status = FILE_STATUS_PERMANENT;
file_save($file);

$images[] = array(
'fid' => $file->fid,
'alt' => $page_data['title'],
'title' => $page_data['title']
);


I ended up doing this by creating an event subscriber and listening for the webform ajax response as described on this issue page: https://www.drupal.org/project/webform/issues/2911409

The keylines (amended for brevity):

// The event to listen for
KernelEvents::RESPONSE

// Check to see if it is a webform ajax request
if(
    $event->getResponse() instanceof WebformSubmissionAjaxResponse and
    $event->getResponse()->getWebformSubmission()->isCompleted()
)

// Add my custom Ajax command
$event->getResponse()->addCommand(new UrlHistoryCommand)


How to set the comment body field to be required?

For What ever content type you are giving comments options, you need to go to

structure >> Content types >> Edit the particular content type >> there will be comments fields tab >> over there  will be list of comments field, in that    comment_body(machine name) wil be required by default.

If not, make it required by editing that field.


Changing date format in monthly archive in Views

Create a template file of your view Display output: views-view--view-post-by-date--block.tpl.php

Make some slight changes where row is printing in your tempalate file:

         <?php if ($rows): ?>

         <?php
   $output = '';
 for($i=0;$i<5;$i++){
$filter_link = date("Ym",strtotime("-$i months"));
$filter_display = date("Y F",strtotime("-$i months"));
$link = $GLOBALS['base_url'].'/post-by-date/'.$filter_link;
 $output .= ''.$filter_display.'('.count($filter_display).')
';

  }
print $output;
// print $rows; ?>


How to link user taxonomy-term to a list with all users with that term applied?

First of all, I assume that the views module is installed and both the views and views_ui modules are enabled.

In the views admin page (/admin/structure/views), there is a view Taxonomy term. If you click edit to see the view settings, you will see that the view is only configured to show Content (i.e. nodes of a content type).

Off hand, I am not sure how to configure the Taxonomy term view to also show Users.  Anyway, I would not take this approach.

My suggestion is to:

Step 1) In the manage display screen for the User fields (/admin/config/people/accounts/display), set the display of your term field to Hidden.

Step 2) Add a new view page display that lists users associated with a term.  You need to use a Contextual filter on the term id (TID).

Step 3) Add a new view block display to lists terms associated with a User.  You need to use a Contextual filter on the user id (UID), so that only the terms related to the user are displayed. For the term field, Rewrite the output so that it is formatted as a link to the aforementioned view page (Step 2) and passing the TID as an argument.

Step 4) Display the view block on the user page such that it appears in a region below the user fields.

This is somewhat involved, but should work.

You may also want to take a look at the module https://www.drupal.org/project/taxonomy_display. This module may open up some other options.


I have a similar use case on my site.  I ended up making stores a content type for that very reason.  Entity reference is your friend cause you can create page a and b and link em to the store content entity.


Not very beautiful and dynamic but as a quick fix you could for instance add a Global: Text area to your views. (See screenshot also)

Show nodes from last year
Show all nodes

To make this more dynamic you could enable the php module (not recommended! https://drupal.stackexchange.com/a/2512/8606) and use date("Y",strtotime("-1 year")); to retrieve the previous year dynamically


How To Force Search API To Reindex a Node / an Entity

You can dive deep into the code of search_api to find solution for issue. See function search_api_entity_update() and search_api_search_api_index_update(). In case reindex number of comment, you can try this code:

// Example reindex after has new comment at node article id 1
$entity = Node::load(1);
$indexes = ContentEntity::getIndexesForEntity($entity);

foreach ($indexes as $index) {
    // Becarefull with indexes. Just for this case.
    // $datasource_id: entity:node (entity type)
    // $updated_item_ids: 1:en (node ID and Language)
    $index->trackItemsUpdated('entity:node', ['1:en']);
}

You can debug in search_api.module to more info.


theming username field in user-register form

As you can see on the Form API reference page, '#theme' Only affects the input box itself. To remove other things generated by the form API, you'll have to clear the array -

$form['account']['name']['#title'] => '';
$form['account']['name']['#description'] => '';

or just

$form['account']['name'] = array(...);

To reset existing elements.


How to calculate the sum of a list of integer in Rules

I found the solution.

Add a variable (integer) "total", for example.
Loop the list of integers:

Calculate a value, input 1: [total], input 2: [line-item], return: "result".
Set a data value, data: [total], value: [result].

Outside of the loop, the [total] value is still available.


How do I troubleshoot a jQuery/AJAX issue?

It is because you are using jQuery 1.9 or superior.

To fix it, use jQuery Update version 7.x-3.0 and enable the jQuery Migrate plugin.


Drupal statistics does not count visits when I see the node from a custom panel

It's because panels doesn't invoke node_view(). Please try following code:

function MODULE_ctools_render_alter(&$info, &$page, &$context) {
  if ($context['handler']->task == 'node_view') {
    $key = $context['handler']->conf['context'];
    $node = $context['contexts'][$key]->data;
    statistics_node_view($node, 'full')
  }
}


Ajaxified form in modal window does not dimiss

I'm not familiar with that ctools command, however try:

$commands = [];

$commands[] = ajax_command_name();

return ['#type' => 'ajax', '#commands' => $commands];

What you ultimately want is for Drupal to receive and render the commands array which should trigger the dismiss and not print the commands to the screen.

(On phone, sorry for formatting)


How can I attach multiple pdfs to drupal_mail() function?

You forgot to add headers to the params array.

I did something like :

$attachment = array(
      'filecontent' => $filepathname,
      'filename' => $namefile,
      'filemime' => 'application/pdf'
      );
//where $filepathname should contain the path to the file and $filename should contain the name of the file.

$params = array(
  'headers' => array('Content-Type' => 'text/html'),
  'key' => 'test',
  'to' => 'test@example.com',
  'from' => 'test@example.com',
  'subject' => 'Test email',
  'body' => 'test',
  'attachment' => $attachment
);

drupal_mail($module, $key, $to, $language, $params, $from, $send);

which worked for me.

In your case:

Check the value of $filemime variable.
Add headers to the code.


Fallback to local images when Cloud Files breaks?

In javascript, you can listen to the image's onerror event listener.

set the source as normal. in onerror, set this.src to your local image path:

<img src="//somecdn.com/cat.jpg" onerror="this.src='/localpath/cat.jpg';" />

you could use jquery to loop over all images on the page and add the onerror event listener


Like geoff mentioned one option would be to use the Mime Mail module, but you can also enable your custom module to send HTML e-mails with some extra code. In short you'd need to alter the mail_system variable and write your own implementation of MailSystemInterface. An example of that is the following code.

Inside 'mymodule.install':

function mymodule_enable() {
  $current = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
  $addition = array('mymodule' => 'MymoduleMailSystem');
  variable_set('mail_system', array_merge($current, $addition));
}

function mymodule_disable() {
  $mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
  unset($mail_system['mymodule']);
  variable_set('mail_system', $mail_system);
}

Inside 'mymodule.module':

class MymoduleMailSystem extends DefaultMailSystem {
  public function format(array $message) {
    $message['body'] = implode("\n\n", $message['body']);
    $message['body'] = drupal_wrap_mail($message['body']);
    return $message;
  }
}

You'd have to replace mymodule instances with your actual module's name then disable and re-enable your module to get the variable changed after which things should be working. For a complete example you can check out my answer here. Additionally this page on drupal.org is from where I originally got all the information from.


What you are wanting to create is a Drupal Installation Profile. This is a method of packaging together multiple Drupal contributed modules and/or themes, plus potentially custom code and functionality, into a neat package that can be distributed and installed with the same resulting "full" website every time.

You'll want to refer to the drupal.org documentation on building installation profiles to get the basics behind how this is done.

Also very helpful will be the Features module. Features allows you to easily package together different sets of Drupal configurations, such as content types, views, and system variables. There are many different documentation and tutorial resources for Features. This is a good video tutorial on the basic concepts of Features.

There are a lot of additional extensions for Features that will help you package additional items into a Feature, such as node content, taxonomy terms, theme settings, etc.

In addition, some of the work you want to do in your installation profile (re: "populate the database with the data as well...") may need to be executed within custom code - either a custom module or as part of your installation profile's install tasks and/or install script. You can even set up a form to allow users to choose from a set of options during the installation.


How to add number of records per page filter in views

I found the answer.

You can add items per page filter from pager option views

Views->pager options->EXPOSED OPTIONS


Commerce Price: Hide formatted amount if empty

This should be fixed in Drupal commerce, but until it gets fixed you could add a custom template file to your theme. Copy /sites/all/modules/views/theme/views-view-fields.tpl.php to /sites/all/themes/[YOUR_THEME]/templates/views-view-fields--[YOUR_PRODUCT_TYPE].tpl.php and edit it.
Add something like: <?php if($id == 'commerce_price' && empty($row->commerce_price)) continue; ?> to your template file.

<?php foreach ($fields as $id => $field): ?>
  <?php if($id == 'commerce_price' && empty($row->commerce_price)) continue; ?>
  <?php if (!empty($field->separator)): ?>

...


Making the size of two fields in comment form the same programmatically

In the core comment form the 'author' element is an array of form elements:

  $form['author']['name']['#size'] = 30;
  $form['author']['mail']['#size'] = 30;


Social Media Managament - Feed Scheduling

You can create a Feed that aggregates any data you need at the rate/schedule you want.

Once you have your feed set up, you could use a service like twitterfeed.com to automatically post your data to the social networks of your choice.

Basically you'd just create an RSS feed and plug it into twitterfeed.


What to do if you don't want to load JS files on mobile devices

The easiest (probably only realistic) way would be to create a second, javascript-less theme, and use the ThemeKey module to show that theme to mobile users based on user agent string. It's not exactly a foolproof method but then device-sniffing never is.

The other option would be to write some javascript which responds to the Omega media query change event, and hooks/unhooks all other javascript events on the page based on the current device size. I can imagine that being very difficult to manage though.

The proper solution would be to design the theme in a mobile-first manner, building up the javascript functionality as you go and managing how it reacts to different breakpoints at an earlier stage.

Removing all javascript for mobile devices means your users will be experiencing a site like they would have 10 years ago, with no UI richness. These days people expect more than that, especially since their devices can easily handle javascript/


How to implement click event on dynamically generating ?

Since you are running D6, you should look into the live() jQuery handler ( http://api.jquery.com/live/ ) that can be used to attach these click handlers to your dynamic elements.

More information on this can be found by googling or otherwise searching for

jquery click event on dynamically generated elements

You might also want to look into the Drupal.behaviors method of including jQuery and javascript instead of the $(document).ready() approach you've used.


A straight grep for the full string may not find these, but they're used. For instance look in the modules/node/node.module, where you find calls such as:

if (user_access('edit any ' . $type . ' content', $account)
  || (user_access('edit own ' . $type . ' content', $account)
  && ($account->uid == $node->uid))) {

Note that the string is constructed on the fly, where the content type (e.g. page) is inserted into a template to form the string "edit own page content".

These strings are mostly used to call user_access, so to see where and how they're used, you may want to search for this function.


Most of the time it is because the file is not picked up, there are a few common cases for that:

Ensure that the filename matches the class name exactly, case sensitive. Without the extension of course.
Ensure that the namespace matches the folder path exactly, case sensitive.
Restart Apache to clear apcu cache, I've had issues with this when renaming/moving files with a class quite a bit in Drupal 8. Also setting class_loader_auto_detect to FALSE in settings.php should solve this one.

There are even more things to check if you're actually the one providing the plugin type such as the plugin manager.


Node values not retrieving properly in .theme and Twig files

not sure if you still need an answer, but the problem is how you want to retrieve the values from the fields. I get confused all the time, so I usually check out what the column name in the database is of the value I want to get from the field.

Links:

$node->field_vanilla_home_link->uri;
$node->field_vanilla_home_link->title;

Images are a bit more complicated, maybe there are more ways, but this is how I usually do it:

$entity = $node->field_vanilla_home_thumbnail->entity;
    if ($entity) {
      $variables['field_vanilla_home_thumbnail'] = $entity->getFileUri();
    }

OR with this you could load different image styles (don't forget to import ImageStyle class):

ImageStyle::load('thumbnail')->buildUrl($entity->getFileUri());

For the image alt:

$node->field_vanilla_home_thumbnail->alt

And I guess you know how to use those values in twig to print links and images (just basic html) :)

Edit: For your problem with your long text with summary, you can filter the markups with "raw":

{{ field_vanilla_main_content | raw }}


Use form-submit to display results table on page

I don't think you can return a themed table on form submit. Instead, what I suggest is to use $_SESSION variable to store the form field values to query the database and redirect to a URL. In the callback function of the URL query the database and return the themed page.

Example:

function mymodule_myform_submit($form, $form_state){
   $_SESSION['somevar'] = $form_state['values']['somefield'];
   drupal_goto('someurl');
}

And in the URL callback function get the value of the session variable $somevar = $_SESSION['somevar'];


How to use webform submission data in a Rules Condition?

The "clue" to what you're trying to get to work, is that you have access to all labels and all values of any field of a webform, ie:

[data:MachineFieldName-title] contains the Label of a field with machine name MachineFieldName.
[data:MachineFieldName-value] contains the Value of a field with machine name MachineFieldName

So in your case, you should be able to get it to work using something like [data:grade-value].

For way more details on this, and a prototype rule about this, refer to the answer to "How to create a node from a Webform using rules?":

the 1st attempt relates to using "Entity has field" (which doesn't work for Webform)
the 2nd attempt explains what to do in case of Webform.

The above is a good start, but not sufficient to achieve your goal (= validate "... a second condition to compare the filled out value the be 7, 8, 9, or 10, so I make an data comparison condition", as in your question).
However, you can 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 (yes, "Rules Action", not "Rules Condition" ...) to Add a variable, with a value assigned to it equal to your [data:grade-value-raw] (and with a data type which is probably integer).
Use the Conditional Rules module to perform the data comparison as in your question (if it is 7, 8, 9, or 10). However, in this data comparison you now refer to the value of the variable you just added (that's the clue!).

In this answer I'm using the Conditional Rules module, though you could also rework the Rules Action to performing Rules Components (in which you add the appropriate Rules Conditions), so that you don't need this extra module. For more details on that, refer to the answer to "What's the alternative to using the Conditional Rules module?".

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


form_set_error not working in node form validation

If you check the source of form_set_error(), you will see that if you don't supply the name of the form element for which you are setting the error, error messages will not be set.

As long as the first argument is NULL, form will be submitted. Your code was being executed, but it didn't stop the submission.

What you need to do is to pass the name of the field for which you want the error to show. This goes as the first argument for form_set_error().

Example:

form_set_error('YOUR_FIELD_NAME', t('Your message'));


views_get_view is returning some outdated version of the view

views_get_view('some_view') doesn't actually execute the View, it just retrieves the specification for the View.

How are you executing the view?

From the comment on your question, I see that you're doing:

$view = views_get_view('some_view');
$view->execute();
print_r($view);

On this thread, merlinofchaos (the primary author of Views) recommends the following sequence:

$view = views_get_view('some_view');
$view->init_display();
$view->pre_execute();
$view->execute();
print_r($view);

which is roughly equivalent to this:

$view = views_get_view('some_view');
$view->preview();
print_r($view);

...except that the later also renders the view as HTML, which, if you're not going to use that rendered HTML, is wasteful.


Conditional 404 response based on inclusion of /node/# in URL

What about using hook_init in a custom module?

function hook_init() {
    // check arg(2) is empty as otherwise will block node edit and delete pages
    if(substr($_SERVER['REQUEST_URI'], 0, 5) == '/node' && arg(2)=='') {
        die(); // to stop completely
        //return drupal_not_found(); // to return 404 page
        //return drupal_access_denied()(); // to return 403 page
    }
}

Saying that it would be quicker to block these pages in .htaccess...


In your view add two fields:
- Node title
- Taxonomy Term

You are right up to here.

Now:

Set the "Taxonomy Term" field to "Exclude from display"
Select your views' format as unformatted list; use "Edit settings" for the format
Set "Grouping Field" as "Taxonomy Term"

For details, view my views' export data in pastebin.


What's the difference between 'attachment before' and 'block' in views?

Block - separate views display that can be outputted in any region of the site.
Attachment - views display that can be outputted in addition to another views display, so you can attach this display to output of another views display.

Attachment has some special options like Inherit contextual filters:Yes, Inherit exposed filters:No, so you could use one exposed filters form for both displays.


How to display panes/views/blocks based on time of day and day of week?

Oddly enough, it doesn't look like any of the Date modules integrate with ctools for selection rules.

I think you have two options, that are essentially the same thing.

Panel page variants support PHP code selection rules.
Panels panes support PHP code visibility rules.

So, your page(s) could have variants based on date/time, and each variant could have panes that are only visible based on date/time.

Your PHP selection rules will use time and/or date.  For example, this should set a rule to only select or be visible on Monday.

$now = time();
$day = date("D", $now);
return $day == "Mon";

The date function does default to the current time, but explicitly using a $now parameter can prevent problems when you call date multiple times when you cross midnight.


You can do it using this module :
Views D8 Upgrade

Tentative upgrade instructions (these may change):
Before upgrading your site to Drupal 8, update to the latest 7.x-3.x
release of Views on your Drupal 7 site.
Back up your data and place your site in maintenance mode.
Install the 7.x-1.x release of this module.
Navigate to admin/build/views_d8_upgrade and click "Perform upgrade."
warning: This will copy your Views data and uninstall the
Drupal 7 Views module.
Follow the Drupal core instructions for
upgrading to Drupal 8, including updating this module to its D8
version. This will convert your old Views data (still saved in the
database) to Drupal 8 Views.


Display a Quicktab content in Colorbox pop-up Drupal 6

If the Quicktab content is a node or any other internal entity, you can do this by using the colorbox-load class and appropriate href. If you aren't able to alter the links in any of the preprocess functions, you can use JS to accomplish this and use Drupal.attachBehaviors() to add the colorbox functionality.


How can the author choose when to publish an article, whether the article gets a teaser or not?

If I understand your question, then this can be done by checking the Promoted to Frontpage box on the article.

You can then change your view to filter out nodes that have Promoted to Frontpage checked.


is there any way to load commerce_products into a collection in rules configuration

I found that VBO (Views bulk operation) give me ability to load views result into a collection in rules.

Just install VBO and make a view and use it.


Creating a View of nodes with field for workbench moderation state without showing every revision?

Immediately after asking this question, I realized there is a filter criterion that can be added for this.

Workbench Moderation: Current can be set to filter based on whether a revision is the current one, and all previous ones can be excluded.

This will also exclude nodes that haven't been created or edited since the enabling of Workbench Moderation for their node type but will include newly created or edited ones.


Go to Administration > Configuration > Regional and language > Translate interface and search for !day-abbreviation. Then translate these strings to the language you prefer.


How to print taxonomy term name with published node count and with a custom link?

Although it looks like you have come up with a solution, you might want to compare against the Taxonomy List module.


The way you construct your myViews variable seems to be the reason this doesn't work for you.

What worked for me was changing this:

            myViews = '.view-dom-id-' + element.settings.view_dom_id;

to

            myViews = '.js-view-dom-id-' + element.settings.view_dom_id;

I just tried a simple version of that without any form submiting, simply calling this from my browser's console:

jQuery('.js-view-dom-id-c58e9660da223aaf7c1645b2746e0b2e16f6a2f3e1de74c8533e6ad6117613db').trigger('RefreshView')

and it worked as expected. As a final remark and as is commented in the code you provided, your views should be Ajax enabled, otherwise, this will not work.

Good luck!

P.S.: The most relevant piece of information from the codebase (this comment says it all):

// Add a trigger to update this view specifically. In order to trigger a
// refresh use the following code.
//
// @code
// $('.view-name').trigger('RefreshView');
// @endcode

(http://cgit.drupalcode.org/drupal/tree/core/modules/views/js/ajax_view.es6.js#n94)


The relationship between tables and their exported datasets is declared via the export key in a table's schema definition. We can see that key both for page_manager_pages and panels_display.

ctools also allows the definition of a default hook. If non was provided it will fall back to default_{table}.

When loading a ctools exportable via ctools_export_load_object() ctools will first query the table for objects, then invoke the default hook to retrieve any objects stored in code.

When page manager pages are exported, panels_display objects are not declared separately under their own hook, but are wrapped in hook_default_page_manager_pages().
In order to retrieve them by their UUID they would have to be declared within hook_default_panels_display().


How to add dynamic created css using drupal_add_css

I found a alternate way to include css file which is in some other location other than modules and themes.In my case including a dynamically generated file.
Even though i can't find a way through drupal_add_css(),this helped me in adding css.

This is the way i included dynamically generated css file which is located at sites/default/files/color/theme-768/color.css

In the theme folder in the html.tpl.php  after <?php print $styles;?> include this

<?php
       print '<style>';
       print '@import url("' . $filepath . '")';
       print '</style>';
?>

This includes the css file.


How to print paragraph field values in paragraph template?

To print out single fields I usually use, {{ paragraph.field_action.value }}. That should also work for you.

In the case of an entity reference field, you need to use {{ paragraph.field_action.entity.field.value }}.


Pages are not searchable by Google anymore

Check your root folder for a robots.txt file. Using Google Webmaster Tools you can test this; see Block or remove pages using a robots.txt file.


How to prevent Profile2 fields from loading on user registration?

Been struggling for quite some days now so if anyone has clues on how
  to prevent the loading of the whole profile form

Looks to me that the magic happens in profile2.module from line 436 to 460

/**
 * Implements hook_form_FORM_ID_alter() for the registration form.
 */
function profile2_form_user_register_form_alter(&$form, &$form_state) {
  foreach (profile2_get_types() as $type_name => $profile_type) {
    if (!empty($profile_type->data['registration'])) {
      if (empty($form_state['profiles'][$type_name])) {
        $form_state['profiles'][$type_name] = profile2_create(array('type' => $type_name));
      }
    }
  }

  // If we have profiles to attach to the registration form - then do it.
  if (!empty($form_state['profiles'])) {
    profile2_attach_form($form, $form_state);

    // Wrap each profile form in a fieldset.
    foreach ($form_state['profiles'] as $type_name => $profile_type) {
      $form['profile_' . $type_name] += array(
        '#type' => 'fieldset',
        '#title' => check_plain($profile_type->getTranslation('label')),
      );
    }
  }
}

Usually I would never hack a contrib module directly, but unfortunately here there is no other option considering you have a profile field that loads 30,000 terms. So comment this out and flush/clear cache.

Just remember if there is ever an update to this module, it will override your changes, so you will have to comment it out again then.


for load paragraph query must like this

query{
  nodeQuery(filter: {conditions:[{field:"title",value: ["artistname"], operator: EQUAL}]}){
    count
    entities {
      ...on NodeArtist{
        nid
        title
        fieldAlbum {
          entity{
            ... on ParagraphAlbum {
              fieldName
              fieldReleaseDate
            }
          }
        }
      }
    }
  }
}

https://github.com/drupal-graphql/graphql/issues/676#issuecomment-423912937


How to turn off " " surrounding vars in the output of t()?

There is actually an excellent comment in the documentation for this. Pasting here for completeness

There are three styles of placeholders:

!variable, which indicates that the text should be inserted as-is. This is useful for inserting variables into things like e-mail.

$message = t("If you don't want to receive such e-mails, you can change your settings at !url.", array('!url' => l(t('My account'), "user/$account->uid")));

@variable, which indicates that the text should be run through check_plain, to escape HTML characters. Use this for any output that's displayed within a Drupal page.

$title = t("@name's blog", array('@name' => $account->name));

%variable, which indicates that the string should be HTML escaped and highlighted with theme_placeholder() which shows up by default as emphasized.

$message = t('%name-from sent %name-to an e-mail.', array('%name-from' => $user->name, '%name-to' => $account->name));


How can you add the ID to the content type fields?

By default template_preprocess_field doesn't initialize the attributes array, so you don't see it when viewing the variables with the Devel module. You can achieve this and any other attributes by adding it in a template_preprocess_field() from your themes template.php file. When added it will get output to the field in template_process_field(). Here's a generic example of adding an attribute to a field. Swap all caps items for your use case...

/**
 * Implements hook_preprocess_field().
 */
function THEMENAME_preprocess_field(&$variables) {
  $content_type = $variables['element']['#bundle'];
  $view_mode = $variables['element']['#view_mode'];
  $field_name = $variables['element']['#field_name'];

  switch ($field_name) {
    // We make sure it only effects the correct field ...
    case 'FIELD_MACHINE_NAME':

      // ... and, assuming you want to limit the where an id is used, we only add on a certain content type's full node page.
      if ($view_mode === 'full' && $content_type === 'CONTENT_TYPE_MACHINE_NAME') {
          $variables['attributes_array']['id'] = 'my-id';
      }
      break;
  }
}


How to hide Forums from anonymous users?

You can change the permission associated with a route doing what Altering existing routes and adding new routes based on dynamic ones / Altering existing routes says to do.

Create a service that is tagged with name: event_subscriber
The class implementing the service extends RouteSubscriberBase
The service class defines its alterRoutes() method that in RouteSubscriberBase is an abstract method

In your case, the alterRoutes() method would be similar to the following one.

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('forum.index')) {
      $route->setRequirement('_permission', 'access forum pages');
    }
    if ($route = $collection->get('forum.page')) {
      $route->setRequirement('_permission', 'access forum pages');
    }
  }

Instead of access forum pages, you can use a different permission, including an existing one that you think it suits more.


keywords and description for front-page of drupal 7 site

Try the Meta tags module

It'll allow you to set keywords and descriptions to your site, and you can override those settings to be different for the front page.


Views Taxonomy get children of a specific parent term within a vocabulary

I'm not exactly sure what you need to implement, but here are the steps to get you what I think you need. For demonstration, I created my own vocabulary with animals like so:

Then I created a view that will accept any of the term names as a contextual filter and return its children like so:

If that's what you need, then here is how you create the view. I'm not sure how you wanted to display them, so I didn't create a page or block display.

Step 1: Add new view

Step 2: Add contextual filter for parent term

Step 3: Configure the contextual filter like so

Save that contextual filter to the view and it will return the children based on the name of the term you pass to it. There may be additional steps to get it working the way you want it, but you weren't really specific. I hope that gets you started.


How to save the definition of an entity?

Yes, the module providing the entity type needs to be enabled for the entity to work correctly, and any module using that entity should include the defining module as a dependency. Drupal modules are generally not factories that produce configuration and can then go away (the major exception being modules generated with the Features module which can behave this way at times), they generally provide ongoing functionality that Drupal will expect to be available on demand.

In your case Drupal loads the class from that module under a variety of conditions (not the least of which is anytime you load an instance of that entity) and so needs to continue to be active as long as you use the entity. That module is also the place to define any special behaviors of the new type of entity you have defined (like changes to the save/load process, or other actions the entity may provide).


Form element's #required set to FALSE, but form submission still consider it as required

Yes, theming the form only changes its markup. If you want to change the form you have to hook_form_alter.

I once wondered how to add required styles to elements that weren't actually required. Your question just gave me the answer.


D8. How can check is a formatter in use?

Solved.

See the function dsbox_system_info_alter() of the Drupal Swipebox module to get detailed informations of the solution.
Or, here is the link to the code of the module file: dsbox.module


If you want to find the link to load a tab, just hover over the tab and copy the link of that tab. You will notice that the link has an argument appended on the end that looks something like:

?qt-myquicktab=1#qt-quicktabs

      Note: The # sign and anything after that in the argument above is not actually required.
      You should change it to ?qt-myquicktab=1

This tells Quicktab to load the second tab (Quicktab starts counting at 0) in the third Quicktab block that you have created (a Quicktab ID of 3).

All you need to do is,place this URL argument on the end of any link that you want to load the alternative tab as the default and you are done.


How do I get entity_type and entity_id from any entity page?

In Drupal Core, you cannot do this. The relevant issue to add such functionality is here.

What core itself does is always passing around two arguments:

function($entity, $entity_type)


You should be able to "set different statuses for comments, like approved, pending, spam and unapproved" using Flags, which are D7 only.

I could not find anything that adds revisions to comments, or comments to flag changes.

The workflow module allows you to assign states to nodes, and comment each state change, but the comment_workflow module is available only for D5. Hopefully someone else might have better news.


All "administration pages" in English and admin menu always LTR?

After you change default site language to Farsi, and admin pages language to English, go to your user:admin page and change the admin's language to English as well to bring it in accordance with the management backend language (English).

Maybe flushing of cache will be needed; In any case if it didn't work then it's a bug and should be reported at Drupal.org ...


Is there a modules "wish list" anywhere?

Check out the Contributed Module Ideas group on groups.drupal.org.

The Google Summer of Code group can also be a good source of inspiration. Some of the ideas may not be big enough to sustain a student for the entire summer, so they don't get picked up otherwise.


How to access the value of a Drupal\Core\StringTranslation\TranslatableMarkup object within a form?

You can get the string value by calling the magic function ->__tostring() or casting the object to a (string). But most time you don't need to do this, because if you use the translation object in a string context it will return the translated string automatically.

You can't change the original string in the translation object. You have to generate a new one with the t-function:

$button['#value'] = $this->t('new text');


URL aliases [node:language] repetition issue

That happens because Drupal is using the language prefix to generate the language URLs, and you are using the [node:language] token in the path pattern. As consequence, the language prefix appears twice.
In the first case, as English is the default language, the prefix doesn't appear twice because [node:language] is replaced from an empty string.

Just use [node:title], instead of [node:language]/[node:title] as path pattern.

The reason for allowing the use of [node:language] is that the other method to generate language URLs is through a domain for a specific language. Suppose you set http://exemple.com has domain for the French language; with your path pattern, the URL alias would be something like http://exemple.com/fr/recherche-de-mots, which is perfectly acceptable.


What is the difference between profile and content profile module?

Assuming you're in Drupal 6, Content Profile allows you to set up a node type that will act as user profiles.  this is more extensible than the core profile module, which essentially just adds basic fields.

Also, because Content Profile profiles are nodes, you get more flexibility with what fields you can have on a user profile.  Any core or contrib field will be usable with Content Profile ( e.g. image field, file field, node reference), whereas the core profile module has limited options.  You can also use Content Profiles with Views more efficiently.

In short:

Content Profile creates user profiles as nodes, with all the benefits that entails (Views being the big one for me).

Core profile module adds a basic profile to the user that has less customisation/options.

Check out this video for some more help with Content Profile.


I'd just get the Date module and add a date field to the profile called something like field_user_birthday.

  This package contains both a flexible date/time field type Date field
  and a Date API that other modules can use.


How do I hide specific node fields to users not registerd to that specific node?

You need  to use Field Permissions module, with the help of this module you can do your stuff. Which allows site administrators to set field-level permissions to edit, view and create fields on any entity. With this module you can hide the certain node field to anonymous user.

  Enable field permissions on any entity, not just nodes.
  Role-based field permissions allowing different viewing patterned based on what access the user has.
  Author-level permissions allow viewing and editing of fields based on who the entity owner is.
  Permissions for each field are not enabled by default. Instead, administrators can enable these permissions explicitly for the fields
  where this feature is needed.


I believe it needs to be node--code-excerpt.tpl.php

don't forget to clear the cache.

Copy node.tpl.php to node--code-excerpt.tpl.php then modify code as necessary.

Here is my node.tpl.php file

<?php
/**
 * @file
 * Default theme implementation to display a node.
 *
 * Available variables:
 * - $title: the (sanitized) title of the node.
 * - $content: An array of node items. Use render($content) to print them all, or
 *   print a subset such as render($content['field_example']). Use
 *   hide($content['field_example']) to temporarily suppress the printing of a
 *   given element.
 * - $user_picture: The node author's picture from user-picture.tpl.php.
 * - $date: Formatted creation date. Preprocess functions can reformat it by
 *   calling format_date() with the desired parameters on the $created variable.
 * - $name: Themed username of node author output from theme_username().
 * - $node_url: Direct url of the current node.
 * - $terms: the themed list of taxonomy term links output from theme_links().
 * - $display_submitted: whether submission information should be displayed.
 * - $classes: String of classes that can be used to style contextually through
 *   CSS. It can be manipulated through the variable $classes_array from
 *   preprocess functions. The default values can be one or more of the following:
 *   - node: The current template type, i.e., "theming hook".
 *   - node-[type]: The current node type. For example, if the node is a
 *     "Blog entry" it would result in "node-blog". Note that the machine
 *     name will often be in a short form of the human readable label.
 *   - node-teaser: Nodes in teaser form.
 *   - node-preview: Nodes in preview mode.
 *   The following are controlled through the node publishing options.
 *   - node-promoted: Nodes promoted to the front page.
 *   - node-sticky: Nodes ordered above other non-sticky nodes in teaser listings.
 *   - node-unpublished: Unpublished nodes visible only to administrators.
 * - $title_prefix (array): An array containing additional output populated by
 *   modules, intended to be displayed in front of the main title tag that
 *   appears in the template.
 * - $title_suffix (array): An array containing additional output populated by
 *   modules, intended to be displayed after the main title tag that appears in
 *   the template.
 *
 * Other variables:
 * - $node: Full node object. Contains data that may not be safe.
 * - $type: Node type, i.e. story, page, blog, etc.
 * - $comment_count: Number of comments attached to the node.
 * - $uid: User ID of the node author.
 * - $created: Time the node was published formatted in Unix timestamp.
 * - $classes_array: Array of html class attribute values. It is flattened
 *   into a string within the variable $classes.
 * - $zebra: Outputs either "even" or "odd". Useful for zebra striping in
 *   teaser listings.
 * - $id: Position of the node. Increments each time it's output.
 *
 * Node status variables:
 * - $view_mode: View mode, e.g. 'full', 'teaser'...
 * - $teaser: Flag for the teaser state (shortcut for $view_mode == 'teaser').
 * - $page: Flag for the full page state.
 * - $promote: Flag for front page promotion state.
 * - $sticky: Flags for sticky post setting.
 * - $status: Flag for published status.
 * - $comment: State of comment settings for the node.
 * - $readmore: Flags true if the teaser content of the node cannot hold the
 *   main body content.
 * - $is_front: Flags true when presented in the front page.
 * - $logged_in: Flags true when the current user is a logged-in member.
 * - $is_admin: Flags true when the current user is an administrator.
 *
 * Field variables: for each field instance attached to the node a corresponding
 * variable is defined, e.g. $node->body becomes $body. When needing to access
 * a field's raw values, developers/themers are strongly encouraged to use these
 * variables. Otherwise they will have to explicitly specify the desired field
 * language, e.g. $node->body['en'], thus overriding any language negotiation
 * rule that was previously applied.
 *
 * @see template_preprocess()
 * @see template_preprocess_node()
 * @see template_process()
 */
?>
<?php if (!$page): ?>
  <article id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php endif; ?>
    <?php if (!$page): ?>

    <?php endif; ?>
      <?php print render($title_prefix); ?>
      <?php if (!$page): ?>
      <h2 class="title" <?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?>

      <?php endif; ?>
      <?php print render($title_suffix); ?>

      <?php if ($display_submitted): ?>
        <?php print $submitted; ?>
      <?php endif; ?>

    <?php if (!$page): ?>

  <?php endif; ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php
      // Hide comments, tags, and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      print render($content);
    ?>

  <?php if (!empty($content['links'])): ?>

      <?php print render($content['links']); ?>

  <?php endif; ?>

  <?php print render($content['comments']); ?>
<?php if (!$page): ?>

<?php endif; ?>


Rate/VotingAPI - Add class to button if user has voted

This change will only work for "Thumbs up" widget. You can place this code in your template.php under your custom theme or in a custom module.

function MODULE_NAME_OR_TEMPLATE_NAME_process_rate_template_thumbs_up(&$variables) {
  extract($variables);

  $classes = 'rate-thumbs-up-btn-up';

  if (isset($results['user_vote']) && $results['user_vote'] == $links[0]['value']) {
    $classes .= ' user-voted';
  } else {
    $classes .= ' user-not-voted';
  }

  $variables['up_button'] = theme('rate_button', array('text' => $links[0]['text'], 'href' => $links[0]['href'], 'class' => $classes));
}

Make sure to replace MODULE_NAME_OR_TEMPLATE_NAME with an actual template name or module name.


Field Collection, with Entity Reference, can get value

Hah, I should've given the anonymous user the privilege to view the data.


You can export it with Features module. Basically it creates a new module which you download and plug into modules folder. There you can further edit it's code.


Is this the correct way of iterating through users and check if they have a determined permission?

That code works, but as you found out, it needs to load each user completely and is therefore very slow.

Unfortunately, the database schema of permissions/roles in D6 is really crappy. It stores all permissions of a role in a single role, separated with a comma.

But still, it should be possible to query that information directly. What you want to query is  which roles have a specific permission and then which users that have at least one of these roles.

Something like this:

db_query("SELECT u.uid, u.name FROM {users} u INNER JOIN {users_roles} ur ON u.uid = ur.uid INNER JOIN {permission} p ON p.rid = ur.rid WHERE p.perm LIKE '%s'", '%, $permission_name_here,%');

There are a few special cases where this doesn't work/needs additional checks:

uid 1 does have all permissions
all users automatically have the authenticated user role (rid 2) but that is not stored in the users_roles table. So if a permission could possibly be assigned to that role, then you need to explicitly check that and if yes, return all users.
It is possible to dynamically assign roles to users based on some conditions. In this case, the query won't work for that...


You can use the project Edit Own User Account Permission. It adds a new permission to People > Permissions called "Edit own user account". You can then allow specific roles the ability to edit their own account.


Send email on comment to users depending on Taxonomy term selection in node

You should Load the Entity (node) from the comment's data.

Then pass that node to a component rule, which actually checks the taxonomy of the node and sends the appropriate email.

Here's a step by step.

First create a component:
1) Go to Rules -> Components -> Add new component
2) Select Rule
3) Name and Tag the component
4) In variables select 'Entity Node' and give it a label and a machine name. Example 'comment_node'
5) Add your conditions. Probably good idea to check node type and of course the taxonomy term you were looking for.
6) Add an Action. Here you should send an email.

Now go to your rule:
1) In actions add 'Fetch entity by Id'. Select 'node'. Use data selector and put 'comment:node:nid' in the id.
2) Then add a Loop
3) In the loop add an action. That action should be your component you created previously.
4) Pass the fetched entity into the component and you should be done


Anonymous users can't access to image style field

The purpose of a field configured in a view mode is to render the output.

To process field values in code use the entity object. You'll find this in a block template in this variable:

$variables['elements']['content']['#block_content']

So in TWIG you can try to access the field value like this:

{%
  set style = elements.content['#block_content'].field_image_style.target_id
%}


Notice: unserialize() [function.unserialize]: Error at offset 0 of 13 bytes i UserController->attachLoad()?

Take a look at the Variable Check module (http://drupal.org/project/variablecheck). That will give you a list of the variables stored in your db that are causing the problem. Once you've identified those bad variables, you can delete them from the 'variable' table in your database.


this is a Module Drupal 6 to import nodes from CSV, but acording their description, you can import taxonomy with its hierarchy: http://drupal.org/project/node_import

to Drupal 7 exist an alternative: Feeds http://drupal.org/project/feeds


How can I get a default value in a dropdown using form API?

For required items a -select- item is added automatically. If the form field is not a required one, you'll have to add it manually, for example with the following code.

  $options = array('_none' => '-select item-') + $options; //Places an extra option at the start

If it's the first item it should be selected automatically but if you want to be safe.

  // Use the array key, not the value.
  '#default_value' => '_none',

You'll have to filter it out the '_none' value in the submit handler afterwards.


Don't show a field if it is not filled in

Okay dear readers,

I find the solution/problem:

I forgot the extension .tpl in my template name. Stupid of me. Everything is working fine now.

Thanks for reading!

kristof


How do I create a Url object from the public file URI?

I believe that the following should do what you need:

Url::fromUri(
  File::load(1)->url()
);

(I've tested this in a local 8.4.2 installation, and it yields a Url object that can be rendered without an error.)

The functions are admittedly named very misleadingly. Even though ::fromUri() sounds like it should accept the return value of ::getFileUri(), namely public://..., it actually only accepts internal:, base:, entity: and "external" URLs.

So you need to use ->url() to get the external URL of the file, and then pass that to ::fromUri().


Using this answer as a base you can add views_field_view to include a view of content filtered by term.

In more details

1. Create a view of terms that includes count of content using each term

Create a view that displays terms
enable aggregation
add relationship Content with term
add sort content uuid with aggregation type: count (optional)
add field content uuid with aggregation type: count
add field taxonomy term

Your view should look similar to the following

2. Create a view that will display the content

Include contextual filter on the vocabulary of your interest (tags in this case)
Add any filters or fields that you need

This view will look similar to

3. Add last view as a field to first view (step 1.)

Download and enable views_field_view module
Go to view from step 1. and

add field Taxonomy term: Term ID
add field Global view ) (made available from views_field_view)
on the settings find the view from step 2.
use {{ raw_fields.tid }} as contextual filter

Next screenshot shows the changes from original view and settings for view field

You are done

Your view now should display the terms with count and all the content that have used it.


What's the correct way to enable clean urls when Drupal is hosted in a sub directory (linux server)?

Locally, I only work with sub folders. The times I had problems with getting clean URL's working correctly, it was the rewritebase setting (part of the mod rewrite class of settings) that was not set correctly.


Do you have a node type "company" that exists?
Is the machine name correct?
Does your $title have a correct value?

You might just be missing ->enforceIsNew() but I'm not sure if that is required.

Try the below code and build further from there. (Edit the required values!!)

$newNode = Node::create([
  'type' => 'your_node_type_machine_name',
  'title' => 'the title of the new node',
]);

$newNode->enforceIsNew();
$newNode->save();

Also make sure you include

use Drupal\node\Entity\Node;

But looks like you already have that.


If user requests page that is unpublished, gets permission denied and page dies with too many redirections

The problem was, i had settings for user to redirect to user/login after permission check, so teh system somehow ended in loop. I set special node page for such occassions, and now everything went normal again. Gisle thanks for comment (which easily could be answer to question)


Issues trying to understand and debug simplesamlphp error

It turns out that the issue was the entityID on the authenticator end containing the port number, and the default entityID provided by simplesamlphp not so. Having the authenticator change their config entries, dropping the explicit port reference, resolved the issue.


The most obvious issue with your code is that you are trying to override the entire form structure within a theme preprocess hook. This does not work. Such hooks will be able to alter the output of forms or any other templates by providing additional variables, altering existing (theming) variables, or adding theme wrappers. They will not be able to alter the processing logic of a form.

Instead, you should manipulate your entire form within hook_form_FORM_ID_alter().

The second issue is, that your implementation of hook_form_FORM_ID_alter() is missing the _form_ part between mymodule and the form ID.

Also, consider using the t() function with English texts for all labels and add your desired translations to Drupal I stead of using hard-coded strings.


I know how to do it with Views and Panels modules.
First you need to create two Views:

First one is Lecture_view create a block and add fields you want to display(Title, body, most important - Content: Nid  and any other fields your Content type has).
Second one is Notes view, create same block but fields for notes to display, and also in a
Contextual filters menu add  new filter (Content) Content: Nid

Now you should go to Lecture view and in Advanced menu, click on theme information link, and you need to create template file, find row with Field Content: Nid and create one of suggested fields, something like (views-view-field--conversations--page--nid-1.tpl.php) in /sites/all/themes/YOURTHEMENAME/views/YOURVIEWNAME(lecture_view--block)/YOURTEMPLATEFILE(views-view-field--conversations--page--nid-1.tpl.php) in this file you will past code from theme view, its something similar to

<?php print render($output); ?>

you need to add one more thing embed that views:

<?php print views_embed_view('notes', $display_id='default', $row->nid); ?>

your contextual filter should work, and now you can add this view to your Panel to display, in Panel menu.

Maybe this is not the best way to do this


How do I filter the user who have logged in once in a view?

Take a look at the User Stats module.  This will provide a count of how many times users log in and it integrates with Views 2


Filter a Drupal View by a Taxonomy Term Reference

Create view (block)
Add fields (title, a small image, date, whatever you like). Or teasers, what works as well.
“Arguments” is from now on called “Contextual filters”, so go there.
Add the filters: “Content: Has taxonomy term ID (with depth)” and “Content: Has taxonomy term ID depth modifier”
Configuration on this filter: → When the filter value is NOT in the URL: → Provide default value → Type: Taxonomy Term ID from URL → under that, check the box “Load default filter from node page, that’s good for related taxonomy blocks.” → now check the boxes of the taxonomies you want involved here
Now you need to add the second filter in order to exclude the current node from the list. Click [+] button of the contextual filters section.
Select Content: Nid
Set the ‘when argument is not present’ to ‘Provide default argument’
Set the ‘Default argument type’ to ‘Content ID from URL’
Go to “MORE” , and check the “Exclude” box.
Move the filter “Content: Nid” to the top position.
Add a block to your view and embed the block on your node pages
Save your view


Not able to access the key value of a list in a twig file

I changed the entity_view_display of my paragraph so that my field output the key, instead of the value. I was then able to access the key. I hope that helps?

I'm able to use this: content.field_button_chrome[0]['#markup']


How to upload files using the Feeds module?

You need to use Feeds XPath Parser module.

You may need this module if you would like to:

  Import XML or HTML documents into nodes, users, taxonomy terms, or
  regular database tables.
  Scrape webpages like regular feed sources with scheduling, updating, and expiring.
  Extract content from HTML documents to create a semantic data bank or mashup.

Below links will help you to set up.

Feeds XPath Parser, a full-fledged XML parser that utilizes the XPath syntax for scraping feeds.
Importing from XML, from drupal.forhumanists.org.
Drupal 101: What I learnt from hours of troubleshooting Feeds.


D7 how to check does the uploaded photo have EXIF data?

If you want to check a file that is being added through a file field on a content type you can use hook_node_presave. Unless you need the exif module for other reasons you can do without this module and just use the exif_read_data function. Make sure to enable to the exif extension in php.

function mymodule_node_presave($node) {
  if ($node->type == 'article') {
    // Still needs some checking here to see if a file is provided
    $fid = $node->field_file['und'][0]['fid'];
    $file = file_load($fid);
    $hasExif = exif_read_data($file->uri, 0, true);
  }
}


How to avoid rendering of same node in two different view blocks on same page ?

Install Views exclude previous module.Then your views filter criteria will have a option like this

Views: Views Exclude Previous (<> Exclude nodes that where loaded in any node based view.)

This will restrict the same content to be displayed in page more than one time.

Hope this answers your question.


hook_form_alter() belongs to template.php, or in a module, as only there it can be recognized; it doesn't work the same as preprocess functions. See also this Reddit.


How can I update a module to a specific version using Drush?

By default, drush pm-update will update Drupal core and all enabled projects to the latest recommended releases. The optional project argument allows you to provide a list of installed projects to update, thereby limiting the scope of the update.
You can also pass a specific version of Drupal core as a project argument and Drush will limit the upgrade to that version of core (and core only, unless you pass other projects along as arguments.)
drush pm-update entityform-7.x-2.0-rc4


How do I show a percentage value in a views_field?

to achieve some calculations I see 2 different solutions.

1/ You create a custom sql query with (db_query) inside a custom module that gonna trigger a view to render, your select clause will make the calculation for you so you will have your result that you are going to display inside a custom field in your view.
You can see the actual query you are executing by using the devel module and then tweak it.

2/ You can use computed_field module but it's a really dangerous thing to integrate PHP inside a field somewhere, because if your php breaks, you will break your complete site, and need to rollback your database. But I don't suggest this solution because it's really risky for your site.

I hope it helps

Cheers


how to specify the file directory in drush config:status

There's no option to do this with drush config:status. See the drush 10 documentation for config:status.
Presumably, you want to check if the config has changed so you can export it to your sync directories. Why not export it to them directly? If there are no changes, there will be no changes. But if there are changes, you'll see them in your repository, e.g. with git status.
I've always used Moshe's recommendation from comment #7 in your linked issue:

You must get your configuration right before you run a config import. Specifically, the config in the import must represent the values AFTER hook_updated_n runs. The developer workflow I advocate is to run the hook_update_n() locally, run drush config:export, and and then commit the results. Only then is the saved config ready to be imported.

I.e., start with a site in a clean state in your local environment:

Update your project(s) with composer.
Run drush updb to perform the db updates
Run drush cex to export any config changes made during those updates
Add any changes to your repo, commit, and push.
Pull the changes on your new environment
Run drush deploy


I was having the same issue.

I ended up copying the contrib folder into: /usr/local/tomcat
So I had: /usr/local/tomcat/contrib/
and: /usr/local/tomcat/solr/drupal/

That error about contrib/extract/lib went away, but now I'm getting:
"Failed to load file /usr/local/tomcat/solr/drupal/solrconfig.xml"

As seen on the logging screen: http://screencast.com/t/MqtSNpqUljI

UPDATE: I went to the admin section on Solr and tried to add the core called drupal. So it tried to process the solrconfig.xml and found an error: http://screencast.com/t/EEmU4P9M
I had the useCompoundFile twice. I fixed it and added the core. After that, it was working fine.
I hope this helps out someone. I installed solr on centos by following the lullabot guide: http://www.lullabot.com/blog/article/installing-solr-use-drupal


How to embed "Exposed form in block" into top bar? Using foundation theme

Views UI -> create a page view
Set 'Exposed form in block' -> Yes
Go to Structure -> Blocks
Find the exposed filter block which you recently created and configure the Region and Visibility settings

EDIT:
to specify a new region modify .info file and page.tpl.php file of you page: e.g.
MY_THEME.info:

....
regions[top_bar] = TOP BAR
...

page.tpl.php:

...
    <?php if($page['top_bar']): ?>
    <div class="header_top_bar">
      <?php print render($page['top_bar']); ?>
    </div>
    <?php endif; ?>
  ...

Documentation

or if you want to insert a block into template file here is an issue.


How to override default theme to custom module path theme

The "most drupal" approach would be to place a copy of your template in your theme's directory named page-mymodule.tpl.php (eg, page-PATH.tpl.php) and be done with it. However, there are some cases where you may want to do this theming in a module, in which case you could do something along these lines in mymodule.module:

  // tell drupal that you want to use page-mymodule.tpl.php if you
  // are looking at www.yourhost.com/mymodule

  function mymodule_preprocess_page(&$vars) {

    if ($_GET['q']=='mymodule') {

      $vars['template_file']='page-mymodule';

      $vars['new_variable']=array('foo','bar','baz'); // $new_variable is now available in the template

    }

  }

  // tell drupal to look in .../mymodule/tpl/page
  // for page templates before looking anywhere else

  function mymodule_theme_registry_alter(&$theme_registry) {

    $theme_hook = 'page';
    $modulepath = drupal_get_path('module', 'mymodule') . '/tpl/page';
    array_unshift($theme_registry[$theme_hook]['theme paths'], $modulepath);

  }

Now, if you have page-mymodule.tpl.php in the directory .../mymodule/tpl/page and you rebuild your theme registry, easy if you have the Admin Menu module installed, otherwise, just clear all your caches, you should be on your way to using a page template in your module for that path.

(And, of course, in your page callback, you can return whatever content you want displayed in the content area of this template without using any of the theme functions you have in your original question.)

ADDITION:  you can use the preprocess_page() hook to add any number of variables that are to be available to the template.  So, in the above, you now have $new_variable available to use in there.


Webform2PDF has dependencies, did you install them?

  Third-party tools:

  TCPDF

  4.5.000 or later required from webform2pdf 2.x or 3.x
  6.0.000 or later required from webform2pdf 4.x


Load all titles and body text from one content type into array

If yau have lots of node's than its difficult load all nodes at a time and also , to get only title and body, its not fair to load complete node.
Rather than load node and get values, we can use select query and fetch required values.

I am using cache concept here, once your query loaded, set it in cache untill any node values changes or any new node creates.
Use node hooks to remove cache for "node_data"
Below is the query:

  $nodedata = array();
  // Check cache exists
  $cache_node = \Drupal::cache()->get('node_data');
  if ($cache_node) {
    $array = $cache_node->data;
    $nodedata = json_decode($array, TRUE);
  }
  else {
    // Query for node title and body.
    $connection = \Drupal::database();
    $query = $connection->select('node', 'n');
    $query->leftJoin('node__body', 'b', 'b.entity_id = n.nid');
    $query->leftJoin('node_field_data', 't', 't.nid = n.nid');
    $query->fields('t', array('title'));
    $query->fields('b', array('body_value'));
    $query->condition('n.type', 'glossary', '=');
    $result = $query->execute()->fetchAll();
    foreach ($result as $key => $value) {
      $nodedata[] = array(
        'node_title' => $value->title,
        'node_body' => $value->body_value,
      );
    }
    // Set Cache.
    \Drupal::cache()->set('node_data', json_encode($nodedata));
  }
  dsm($nodedata);


I found the answer, it was in fact filter: alpha(Opacity=45); inside the IE fix, but apparently it needed to be in the -inner of the class, instead of the regular class.


twig template suggestion for comment reply form

It's a bit unclear what exactly you want to achieve. But you can easily add another template suggestion based on the form ID by implementing hook_theme_suggestions_HOOK_alter for forms. The form ID can be found in the $variables then. But no matter if you are on the node route or the reply route this will simply give you comment_comment_form.

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function MYTHEME_theme_suggestions_form_alter(array &$suggestions, array $variables) {
  $form_id = $variables['element']['#form_id'];
  // Add template suggestion based on form ID.
  $suggestions[] = 'form__' . $form_id;
}

If you want to do something different on the reply route you could check the current path for the /reply and /comment arguments OR check if the route parameters contain a PID, which would be the parent comment ID.

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function MYTHEME_theme_suggestions_form_alter(array &$suggestions, array $variables) {
  // Add template suggestion based on form ID.
  $suggestions[] = 'form__' . $variables['element']['#form_id'];
  // Add template suggestion based on form ID and parent comment ID.
  if ($pid = \Drupal::routeMatch()->getParameter('pid')) {
    $suggestions[] = 'form__' . $variables['element']['#form_id'] . '__reply';
    $suggestions[] = 'form__' . $variables['element']['#form_id'] . '__reply__' . $pid;
  }
}

Which will give you the following theme suggestions.

<!-- FILE NAME SUGGESTIONS:
   * form--comment-comment-form--reply--1.html.twig
   * form--comment-comment-form--reply.html.twig
   * form--comment-comment-form.html.twig
   x form.html.twig
-->


Address book problem when user edit the billing address

I found this patch which worked for me: http://drupal.org/node/1774932


How to create another Front Page and switch between the two? (in dev process)

You can use context http://drupal.org/project/context to achieve this.  You can filter on the path and then add blocks to that specific page.

But you will need a holder page.  Sometimes I create a holder content type and then modify the node template to not display anything or just the title.  Then I can attach any view/block or w/e to it.  So that piece of content is just a "holder".


Is it possible to use a replacement kernel without hacking core?

Well, let's take a look at the classes implementing DrupalKernelInterface. Beyond DrupalKernel, you will find

TestKernel
InstallerKernel
TestRunnnerKernel

Especially the second and the third are very interesting and gives you an idea what these can be used for: if you have a very unusual request flow which should be much more rare than in Drupal 7 then you can write a special Kernel to help. Your entry point will not be index.php but that's fine.


Forbid or autocorrect a certain term in a vocabulary

The autocorrection scenario is one the use scenarios covered by the Synonyms module. It's a general purpose tool that works with taxonomy term references (tags) as well as other entities. It also has other integrations with projects that help with mitigating complexities with  duplicate taxonomy terms (e.g. Term Merge).


This guide shows how to create a multi-lingual content.

https://www.ostraining.com/blog/drupal/d8-multi-lingual/

If not success please post some code you're trying to do. Remember to clear the cache.


Your existing view listing all locations is fine for now (assuming a path like "/locations"). Create another display in that view (or a complete different view if you want). This second display/view should first get a relationship to the (location) entity referenced by the field "location". Then the view should have a contextual filter on a node id using that relationship; argument should be in the URL, e.g. by using something like "/locations/%/maintenance" as path.

So if you have two locations (nids: 1 + 2) and 4 maintenance nodes (nids: 3-6), you should see all locations at "/locations" and all maintenance for the first location at "/locations/1/maintenance". Now you just need to link from the first view to the second one by using the correct path "/locations/[nid]/maintenance" and it should be the way you want it. You can take it a step further by displaying all locations along with the maintenance on a single page. You'll need an additional module (if not yet installed): views_field_view.

If that is installed, you can proceed to the next step and include the maintenance view in the location view. Add two new fields, first of type "Content: Nid" and second of type "Global: View". For the latter field choose the maintenance view in the dropdown and enter "!nid" in the argument textbox. By doing this, the current nid of the location is send as an argument to the maintenance view and thus only displaying maintenance nodes that are connected to that current location.


I know an old post anyway. There two solutions to this, here is one, but for this you need to define the type of the view as comment view right from the start, However another solution is that (Assuming Review 1, Review 2 are nodes being pulled and a relationship is set on the comment and node), right below the Title block you have the FORMAT configuration block, set it to Unformatted list and to display the fields (Notice: I have not tested on other formats such as table etc), click on Settings after the |pipe symbol and you can see Grouping field Nr.1  with a drop down, choose nid as your grouping method. In other cases there might be Grouping field Nr.2/3.. and so on. This should be able to group all your comments together for a node.


Creating node via REST POST gives "leaked cache metadata" error

That's a core bug, see https://www.drupal.org/node/2626298 and https://www.drupal.org/node/2663638 (either of those two would avoid this).

The views reference thing is a good hint. Sounds something runs there that then triggers this exception. You could open an issue for that too if you can find the exact reason.


conditional removal of a field in a view

Take a look at Views Nodes Split. Module Monday: Views Nodes Split gives more information about how to use the module.

  Setting up the module is simple: just turn it on, and build your View as you normally would. Then, click on the View's Format option and select the newly available "Splited Content" row style. While the grammar is awkward, the results are great: you can specify separate build modes and display styles for the first node and all subsequent nodes from a simple config screen. In fact, you can even adjust where the cutoff happens: you might want the first three nodes to display in full, for example. No other changes are needed for your View; this module's new row style handles the rest.


A view of full nodes with comments that are a content type

First thing that comes to mind:

make a view for the nodeTypes
make a view for the customComments
take the corresponding view-template (depends on your views, check the views theme-information) of the nodeTypes-view and render the customComments-view inside it using views_embed_view()

Maybe there is a simpler approach for that.


PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined:

A parameter to a query is something that will go in the WHERE/HAVING clause, it can't be used to substitute text into the SELECT or FROM (or any other part) part of the query. As you've only got two proper parameters in the query (those after the WHERE clause), and you're passing several more as the arguments, you get an error informing you of the count mismatch.

You're also trying to pass in arrays as single string parameter replacements to the SELECT and FROM parts of the query, which will just never work (even if you could use parameter replacement in those part of the query). When cast to a string, the array will simply be the string Array, which is pretty much definitely not what you're looking for.

If you want to build those parts of your query dynamically you'll need to use db_select() instead. This code isn't a complete representation of your example but should get you going:

$query = db_select('content_' . $table_name, 'image');

$query->addExpression('image.' . $field_name);
$query->addExpression('image.' . $field2_name);
// etc...

$query->condition('vid', $vid);

$results = $query->execute();