If your description of what you do is accurate, the problem is simple to solve.

Clicking "Go online" is only the first step required to take your site out of maintenance mode.  You also need to remove the tick from the box to the left of "Put site into maintenance mode", and then click "Save configuration".

However, if you go through all these steps, and it still fails, you need to update your question to accurately descibe what you do, and we'll take it from there.


How to display node title using computed field?

To get the value:

$value = $entity->title->value;


How to change page not found page error message in drupal 8?

You can do this by overwriting the route system.404 with a custom controller:

mymodule/src/Controller/MyHttp4xxController.php

<?php

namespace Drupal\mymodule\Controller;

use Drupal\Core\Controller\ControllerBase;

class MyHttp4xxController extends ControllerBase {

  public function on404() {
    return [
      '#markup' => $this->t('Custom 404 message'),
    ];
  }

mymodule.routing.yml

system.404:
  path: '/system/404'
  defaults:
    _controller: '\Drupal\mymodule\Controller\MyHttp4xxController:on404'
    _title: 'Page not found'
  requirements:
    _access: 'TRUE'

mymodule.install

<?php

function mymodule_install() {
  module_set_weight('mymodule', 1);
}

You have to be sure, that your module runs after the system module, so that you can overwrite the route from the system module. This is why you need to set the module weight to 1. You need to reinstall the module, when you implement this.


Are you using the Profiler library to drive your installation profile? If so, there's a "feature" in the 7.x-2.0-beta1 release that causes this behavior. In short, there's some legacy code that disables all blocks in the database upon installation.

If you're using the Profiler module, upgrade to the latest development snapshot to get the fix.


Drupal 6 Module Storing configuration setting in file

The Question was not so clear to me but I can suggest you 2 things.

You can use variable_set('salt', 'unique_hash'); in the .install file in hook_install(). Then this variable will be stored in the variables table. In hook_uninstall() you add variable_del('salt'); So this will remove the variable from the table if the module is uninstalled. You can access it via variable_get('salt', 'default_value'); Also if you want to change it then make a form text field and in the hook_submit for that form make a variable_set('salt', 'edited_value') call. This will update the variable in the variables table. Use user_access() to restrict all users to access it.
The second is, to make a text file in the server file system and make it's permission as 644. Then read the file by php's fread() function and access the file value.


Place to put patched module under contrib or custom

You may leave it in place (a good reason for doing this is given in the reply from alexkb).

However, this is not all there is to working with patches.  Sometimes the maintainer is reluctant to include the patch in the official branch.  This means that there may be new releases (security fixes!, bug fixes, feature enhancements) of the module without the patch.   You need to think about how you deal with that.

Here is what I do: I set up staging area for where I keep all my custom modules.  For the patched contrib modules, I connect those to the origin repo using git. I also setup a Makefile (or some other script file) to pull from the origin repo and semi-automate the reapplication of outstanding patches. Then, when a new release of the module is issued, the Makefile will pull and patch, and then send an email to me with the result.  If the patch applies succesfully, I test and if the test turns out OK, I manually copy from staging to production.  If the patch fails to apply due to some conflict, I try to resolve conflicts and try again.

This has two advantages:

Even when you're using a patched module, you're able keep up with the official branch.
You don't have to watch the issue queue, just set up your local repo to sync with origin at regular intervals (using CLI cron or similar).

The above workflow assumes some familiarity with the CLI and tools such as git, cron and make.  It also takes some times setting this up to run semi-automatically.  But if you need to work with patches, it is - IMHO - well worth doing.


How do I handle smart quotes and curly apostrophes?

Converting to straight quotes (and using Typogrify to render them as
smart quotes) would be fine too, if you can tell me how to convert to
straight quotes.

I had to do that for an online dictionary I built recently with Drupal 9.2. What I did is to create a drush command that updates all nodes (creating a new revision) converting all quote characters to straight quotes or ASCII quotes:
<?php

namespace Drupal\diccionari_custom\Commands;

use Drush\Commands\DrushCommands;

/**
 * A Drush commandfile.
 */
class DiccionariCustomCommands extends DrushCommands {

  /**
   * Standarize quotes.
   *
   * @usage diccionari_custom:standarizeQuotes
   *   Usage description
   *
   * @command diccionari_custom:standarizeQuotes
   */
  public function standarizeQuotes() {

    $query = \Drupal::entityQuery('node');
    $entity_ids = $query->execute();
    foreach ($entity_ids as $nid) {
      $node = \Drupal\node\Entity\Node::load($nid);

      $new_title = str_replace('‘', "'", $node->title->value);
      $new_title = str_replace('’', "'", $new_title);
      $new_title = str_replace('ʹ', "'", $new_title);
      $new_title = str_replace('ꞌ', "'", $new_title);
      $new_title = str_replace('“', '"', $new_title);
      $new_title = str_replace('”', '"', $new_title);
      $new_title = str_replace('&#x2018;', "'", $new_title);
      $new_title = str_replace('&#x2019;', "'", $new_title);
      $new_title = str_replace('&#x02B9;', "'", $new_title);
      $new_title = str_replace('&#xA78C;', "'", $new_title);
      $new_title = str_replace('&#x201C;', '"', $new_title);
      $new_title = str_replace('&#x201D;', '"', $new_title);
      $node->setTitle($new_title);

      $new_content = str_replace('‘', "'", $node->body->value);
      $new_content = str_replace('’', "'", $new_content);
      $new_content = str_replace('ʹ', "'", $new_content);
      $new_content = str_replace('ꞌ', "'", $new_content);
      $new_content = str_replace('“', '"', $new_content);
      $new_content = str_replace('”', '"', $new_content);
      $new_content = str_replace('&#x2018;', "'", $new_content);
      $new_content = str_replace('&#x2019;', "'", $new_content);
      $new_content = str_replace('&#x02B9;', "'", $new_content);
      $new_content = str_replace('&#xA78C;', "'", $new_content);
      $new_content = str_replace('&#x201C;', '"', $new_content);
      $new_content = str_replace('&#x201D;', '"', $new_content);
      $node->body->value  = $new_content;
      $node->body->format = 'basic_html';

      $node->setNewRevision(TRUE);
      $node->revision_log = 'Converting quotes to straight quotes';
      $node->setRevisionCreationTime(REQUEST_TIME);
      $node->setRevisionUserId(1);
      $node->save();

      $this->logger()->success(dt($nid . ':' . $node->title->value));
    }
  }
}

Now, when outputting the content, you can use a text format and Typogrify module to do the conversion to smart quotes.
And if you have to perform that conversion in the title too, see my last comment in this Drupal.org issue.

Preferably your solution will handle other characters as well.

Both the drush command example and Typogrify settings can easily be extended to handle other characters.


Giving permissions to a node to multiple accounts without creating a new role

How about using Entity Reference to designate non-owner users that may edit the node?

You could make your own module with a function to handle permission checks, i.e. "return TRUE if user is referenced on node".

Then use other hooks (hook_form_alter() for instance) to show/hide edit buttons and override edit privileges on nodes.

You can secure it by making the entity reference field only accessible by the content owner.


You don't have to accept this as an answer, but I would recommend not using CKEditor with the PHP input format. In D7's CKEditor module you're able to attach CKEditor to input formats, as opposed to D6 where you specified textfield IDs and paths and such. Therefore, you can just attach CKEditor to the "Filtered HTML" and "Full HTML" input formats and leave PHP alone. I just think it's a bad idea to try and use wysiwyg formatting that contains code like this.

So, my recommendation would be:
1) Disable CKEditor for the PHP input format.
2) Edit the handful of nodes and replace <!--?php with <?php


How to get in Views RESTful API non latin's letters on fields?

The Drupal 8 Rest module relies on the Serialization module to create the JSON output. This module, in turn, is using the Serializer Symfony component, which outputs escaped characters by default (it is not passing the JSON_UNESCAPED_UNICODE constant to the json_encode call).

As far as I can see, the escaped UTF8 characters are fine (they are legal in JSON) and you should be able to parse it back to UTF8 from any REST client having a JSON decoder. They are just not very readable if you try to read the JSON directly.


Programmatically created node gets created three times, produces error

Have you installed the drupal for a specific language. If yes than please take care of the language on the time of node creation. e.g. for engisg code is en.

Also please make sure that the function you are calling is attached to only 1 menu. It should not be called by several other source on that module. So, please check HOOK_install, HOOK_menu, HOOK_init wherever you add code for the same.


How to customize profile2 module profile edit form using template method?

You should use form_id as theme key in hook_theme(), which is user_profile_form in the case.
function MYTHEME_theme(&$existing, $type, $theme, $path) {
  return array(
    'user_profile_form' => array(
      // …
    ),
  );
}

See Theme Profile2 Form, a support request opened for the Profile2 module.


Looks like you've stumbled across the same stumbling block as I have a couple of times. Try with this piece of code - note the create entry after canonical:

 *   uri_paths = {
 *     "canonical" = "/foolzz_rest_api/profile/{uid}",
 *     "https://www.drupal.org/link-relations/create" = "/foolzz_rest_api/profile/{uid}"
 *   }
 * )

Read more at:
https://www.drupal.org/node/2811757
and
https://www.drupal.org/docs/8/api/restful-web-services-api/restful-web-services-api-overview

Oh and for the post request, I'd use ModifiedResourceResponse instead of fiddling with cache headers by hand (I learned about the existence of that from Drupal Core's EntityResource)


Cannot Upload Image or Cannot Display Image

Make sure the directory exists and write permissions are set to 777 (probably 775 on production).

Check the permissions on site/default/files . You might have to ask your shared host admin for this. If you have ssh you can do chmod 777 site/default/files.


Generate PDF from custom fields, and link from Views page

I know there is a module called Views PDF. I did have it working on a test CiviCRM 4.2 site, but formatting the PDF was somewhat tedious and I have never used it on a live site.


Feeds module and feed that includes external files as nodes

Feeds module can be setup to do this with XPath Parser and Feed Tamper. Give feeds tamper a try - https://drupal.org/project/feeds_tamper


My tab links turned into /user/%/edit, node/%/edit, etc

Line 775 of /include/menu.inc was commented out.


Fixed it by going to Views, selecting this particular view, selecting Block display and in the Field section editing the Node: title checking the box labelled "Link this field to its node".


Userpoints: deduct points programmatically

You can use userpoints_userpointsapi and pass points in negative if you want to deduct.

example

    $params = array(
      'uid' => $user->uid,
      'points' => -5,
      'operation' => 'mymodule_some_operation',
    );
    userpoints_userpointsapi($params);

For more information http://drupal.org/node/993376  http://api.worldempire.ch/api/userpoints/userpoints-7.x-1.x%21userpoints.module/function/userpoints_userpointsapi/7-1


I needed to do this in the past. I exported with a View, and used a Representative payment transaction relationship, using Commerce Payment Transaction: Status as the representative sort criteria. Then I just added the Commerce Payment Transaction: Created date field. Assuming that the entire payment is done in one go, I think this method's sound.


Alright, so I'm still not sure why the fields are empty, but they the keys are certainly there. Either it is a bug in the core, or some weird behaviour of my installations.

I fixed it now manually by implementing the preprocess_search_result hook in mytheme.theme:

function mytheme_preprocess_search_result(&$variables) {

    $variables['type'] = $variables['result']['node']->get('type')->getString();
    $variables['nid'] = $variables['result']['node']->get('nid')->getString();

    switch ($variables['type']) {
        // some other adjustments based on the node tpye
    }
}


Not able to overwrite old value in Drupal.settings

I think you can not do it this way. Data Drupal.settings only run in first load. This data store in tag head of page.

When you call ajax your function was execute, but tag head don't reaload. So Data.settings don't change.


On a recent drupal project I used multistep and ran into similar issues.

To work around this I used with drupal "workflow" states, to keep the incomplete forms as draft, and have users explicitly set the form to complete by changing the state on the last page.

We then rewrote all the drupal views that we used for reports, so that they filtered out any draft nodes or nodes with state not set.

You might also be able to change the state automatically, by hooking into node save and writing some code to check whether the user is on final page, and doing any extra checks to confirm that the node is completed and should be moved to a different state.

 $step = _multistep_get_current_step($type);

Do watch out that the multistep current_step may be return 0 if the user or admin user viewing all steps on one page. Also watch out for loopholes where users can skip past steps onto final page without completing everything.

I realise for some applications that a lot of partially completed nodes is just untidy, but
advantage for us was that our users could come back to partially completed forms and continue later, and that it also gave us an insight into how many people gave up part way through, all of this could be managed using normal drupal views to produce lists of items in draft state.


List Drush specific add ons, plug ins, extensions, or modules to use drush dl in automated script

I would personally lean towards simply installing with -y. Adding -y onto the command you've listed will return Y accepting the default on any prompt that comes up (like the one you mention).

drush dl drush_extras -y

If you still want to check if it’s installed, you can check if the directory exists,

if [ -e $HOME/.drush/drush_extras ]; then
  # some logic here
fi

This won’t help you if the directory is empty though.

Another option is checking the output of

drush someCommand -h

Where someCommand is a command provided by drush_extras. You can compare the output of a valid one to an invalid one. If they match, it’s not installed.


I created two forms and called the second one only after the first form is submitted. To create a table i used table theme.

if (!empty($form_state['values']['text'])) {

 //db_query here to search the key word
 $text = $form_state['values']['text'];
$header=array(t('patient id'), t('patient name'));
$row = array(
    array(
t('one'),t('two')
    ),
);

 $form['table']=array(
 '#theme'=>'table',
 '#header'=>$header,
 '#rows'=>$row,
 );
 }
 else {

 $form['text'] = array(
'#type' => 'textfield',
'#title' => t('patient_id'
));

 $form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit Button'),
//'#ajax'=> array('callback'=>'anonymous_page'),

);
}
return $form;
}

in the form submit add

$form_state['rebuild']=true;


Content Type based template not working for Medical Zymphonies Theme

JamieR has provided a snippets in Drupal.org

function themeName_preprocess_page(&$vars, $hook) {
  if (isset($vars['node'])) {
    // If the node type is "blog_madness" the template suggestion will be "page--blog-madness.tpl.php".
    $vars['theme_hook_suggestions'][] = 'page__'. $vars['node']->type;
  }
}


form_set_error highlights only select fields and not other required field types

This was because of CSS overwritten by Zero Point theme, added more classes in my custom CSS file:

    /* .form-item input.error, */
    .form-wrapper .fieldset-wrapper .form-item input.error,
    .form-item textarea.error,
    .form-item select.error {
            border: 2px solid red;
    }


Is there a way to generate dummy content for custom entities?

To create some demo entities programmatically, you can use a while loop in your function.  To create 100 entities:

$i = 1;
while ($i <= 100) {
  $i++;

  // Create an entity here.  See https://www.drupal.org/docs/8/api/entity-api/working-with-the-entity-api#s-create
  // To create random strings (e.g. for fake titles), refer to the comments at https://www.php.net/manual/en/function.rand.php -- In here you will find different ways to create random strings.
  // Generate some Lorem Ipsum text if you like: https://stackoverflow.com/a/20633400/861826

}


I don't know why it's not loading on some pages, but ultimately it's because the library isn't required for those pages. If a module's library is required by your theme then you need to declare it as a dependency.
You can do this for your library in your theme's libraries.yml file. See the Declaring dependencies documentation.
# my_theme.libraries.yml
# It's not clear if you want the bare or full cookie compliance library
my_library:
  js:
    js/my_libary.js: {}
  dependencies:
    - eu_cookie_compliance/eu_cookie_compliance
    - eu_cookie_compliance/eu_cookie_compliance_bare


Exposed date filter adds a timezone offset in query

The following helps when rendering views programmatically:
$event_date_time = new \DateTime($query->get('date'), new \DateTimeZone('America/New_York'));
$event_date_time->modify('+1 day');
$event_date = $event_date_time->setTimezone(new \DateTimeZone('America/New_York'))->format('Ymd');

$view = \Drupal\views\Views::getView('events');
$view->setArguments([$event_date]);
$output['events'] = $view->preview();


How to implement Commerce USPS Shipping?

Have a lok at the README.txt that comes with the Commerce USPS module, here is the content of it:

About this module
Commerce USPS module provides shipping calculations from the USPS
WebTools API
Dependencies
This module depends on the Commerce module
(http://www.drupal.org/project/commerce).
In addition, the following modules are required:

Commerce Physical - http://www.drupal.org/project/commerce_physical -  this module is used to define the physical properties (weight and  dimensions) of each product. This information is necessary to
determine  a shipping estimate.

Commerce Shipping (7.x-2.x) -  http://www.drupal.org/project/commerce_shipping - this provides the
infrastructure for Commerce UPS to fully integrate with the Commerce
module.

Installation

Install and enable the module and all dependencies (be sure to use  the latest versions of everything). Add dimensions and weight fields
(new field types via the Commerce Physical module) to all shippable
product types. Populate dimensions and weight fields for all products.

Configure the "Shipping service" checkout pane so that it is on the  "Shipping" page. The "Shipping service" checkout pane MUST be on a
later  page than the "Shipping information" pane.
(admin/commerce/config/checkout)

Configure the USPS settings  (admin/commerce/config/shipping/methods/usps/edit). You'll need to
create USPS WebTools account and obtain a username via
https://secure.shippingapis.com/registration/.

Limitations
Eventually, all of these limitations may be addressed. For now, be
warned.

Single "Ship from" address for all products.

Doesn't ensure product dimensions are less than default package size  dimensions. In other words, if you have a product that is 1x1x20
(volume=20) and your default package size is 5x5x5 (volume=125), even
though the product won't physically fit in the box, these values will
be  used to calculate the shipping estimate.

Doesn't play Tetris. For example, if you have an order with 14  products with a combined volume of 50 and your default package size
has  a volume of 60, the shipping estimate will be for a single box
regardless of if due to the packaging shape they don't actually fit in
the box.

Doesn't limit the weight of packages. If you're trying to ship a box  full of lead that weighs 600lbs, this module will let you
(instead of  breaking the order into more packages).

Doesn't account for packing material. If you need to account for  packing material, then you may want to adjust product dimensions
accordingly.

Methodology
Calculating estimated shipping costs is a tricky business, and it can
get really complicated really quickly. Knowing this, we purposely
designed this module with simplicity in mind. Here's how it works:

Every order must contain at least one package.

The number of packages is determined by calculating the total volume  of all products in the order, dividing by the volume of the
default  package size, and rounding up.

The weight of each package is determined by dividing the total weight  of all products in the order by the number of packages.

If you need custom functionality, you have several options:

Determine if it is something that can be generalized to suit a number  of users and submit it via the issue queue as a suggestion for
inclusion  in this module.

Hire one of the maintainers to create a custom module that interfaces  with Commerce UPS to add your custom functionality.

Break open a text editor and start coding your own custom module.

Apart from that, the module's project page contains this extra info:

Please refer to the README.txt file for additional information about how this module works and how to set it up.

Install and enable the module and all dependencies.

Add dimensions and weight fields (new field types via the Commerce Physical module) to all shippable product types.

Populate dimensions and weight fields for all products.

Configure the USPS settings (admin/commerce/config/shipping/methods/usps/edit). You'll need to create USPS Web Tools account and obtain a username https://secure.shippingapis.com/registration/ and call USPS to have the account moved into production (tell them you are using 3rd party software).


How can I suppress the "connection to @remote closed" message?

--ssh-options="-o LogLevel=QUIET" suppresses the SSH message but still produces a blank line. Although I couldn't put this into the command line I was able to add this to the self.site.yml file.
ssh:
  options: -i /cert.pem -o LogLevel=QUIET


Term not being migrated into taxonomy reference field

I'm sorry that in 8 months no one has answered this question.
I was stuck on this as well and finally got it to work by using the following format nested under the process key of your migration that will look up the previously migrated taxonomy:
field_taxonomy_term:
  plugin: migrate_lookup
  migration: migrate_taxonomy_terms_en
  source: field_taxonomy_term

The field_taxonomy_term from your node source should be the entity id of the taxonomy term.
Also it should be noted that I migrated the taxonomy vocabulary and the node that will reference the taxonomy as a group.  I'm not sure if that matters or not.  The order the migrations are executed in is determined by setting the dependency on the taxonomy migration in the node migration.


Create a printable document from template

This use-case is perfectly normal for Drupal, but you're better off not using Word at all.

Create a content type (let's call it fillable) that contains all of the fields you require including an Image field which requires the ImageField module.
Give your users the 'fillable: Create new content' and any of the other relevant permissions for that content type that you wish them to be able to do.
Edit the content type and go to the manage display tab, determine how you want the fields to show (with labels? as links?).  If you need to group fields you can use the Field collection module.
Use your theme to make the node page layout how you want it to be
Put a print.css file in your theme and use that to fine-tune how the document prints

If you want to make other changes to the output of the node (like extra text in certain places, or complicated formatting), you can create a node template for that specific content type by giving it a name such as node--fillable.tpl.php


Creating a Paragraph type programmatically

There are two issues here. To start with, the config files for a paragraph type should be placed in the config folder of the module, for which there is now a console command. See Export Paragraph bundle with Drupal Console

Then there is the general problem, how sites can update the config of an already installed module. You'll find different solutions in this topic How do I update the configuration of a module?


How do I create a view with some customization?

I wouldn't use Fields setting for this case.

Try to override template for specific content type and set your view to display your content type in specific 'view mode' for example teaser.

In your view change 'Format' to 'unformated list' and change 'Show' setting to 'teaser' for example. This will display your content type in specific view mode, so now you can override your template for this custom content type using:

node--my_content_type_machine_name--display_mode.html.twig

be aware of correctly using double dashes, otherwise your template won't be registered by drupal. Then you can code custom HTML template for your content type in this specific view mode and you can customize your layout according to your needs.


Custom user profile fields, not editable by user

You could try looking at the Field Permissions module.  Simply don't allow editing of your specific fields for the role that the registering/registered user has.


Multiple Drupal sites using the same code base

coleopterist is right.

Let's say you want mydomain.com and sub.mydomain.com to share the same codebase, you will have to put two folders in sites/ :

sites/mydomain.com/
sites/sub.mydomain.com/

If you want modules and themes to be available to all domains defined in sites/, all you have to do is to put them in all/ :

sites/all/modules/
sites/all/themes/

Then, in sites/{domain}/settings.php you can redefine the databases strings like so :

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'database_name',
      'username' => 'user_name',
      'password' => 'p4ssw0rd',
      'host' => '127.0.0.1',
      'driver' => 'mysql',
      'prefix' => 'drupal_',
    ),
  ),
);

Note that you should launch the DrupalRoot/install.php script for each different domain to create its database tables.


How to use PHP Evalution in rules scheduling

After struggling so many days I found the solution that how we can do scheduling using php evaluation. To do this I have simply pick the value in data selector(under my rule) that is set by user in his rental form as shown in my 1st screen short. Now I need to schedule that rental date according to the alerts set by user in alert section (screen short2) where i was stuck.Under PHP evaluation section we have to use $value variable that returns the value that we selected in data selector.In case of dates  it returns the timestamp not the actual date. So then I used PHP code to add/substract the days according to the user set in alert section and succeed to do scheduling.

I hope it will helpful for others.


Go to /admin/appearance, uncheck the box name 'Use the administration theme when editing or creating content', and save.


How to render a template declared in hook_theme directly in a twig template without preprocess?

In D8 there is no theme() function, so if you want to render a template you use a render array for it. Put it in a twig variable and print it:

{% set partial = {
  '#theme': 'partial',
  '#current_url': url('<current>'),
} %}

{{ partial }}

As a side note, because of a security issue for Twig in Views you might be no longer be able to do this in Drupal 8.6 and are forced to use PHP in the near future. There is an ongoing discussion what to do about the code execution vulnerability without (hopefully) preventing such valid use cases, see https://www.drupal.org/project/drupal/issues/2860607


How to get the valid URL of a Link field from within a Twig template?

Your PHP from your latest edit would translate into twig like this:

{{ node.field_my_link.0.url }}

This works like this, 0 returns the first item of the field item list, url gets the url object and because twig will cast this object as a string this will call the magic method toString() and will output the url as a string value.

You only need to use url, because twig looks automatically for the method getxyz() if there is no property with that name xyz.


How do I add extra cost with cash on delivery?

It's been a long time since this has been asked, but I'm adding my input here since I bumped into this while looking for the exact same thing for one of my projects. The way I found as the cleanest and most straight forward, while reading through the documentation, is the use of an order processor class that would check the current order for the use of the payment method in question and add an adjustment accordingly. You can have a look here on information as to how to setup an order processor https://docs.drupalcommerce.org/commerce2/developer-guide/orders/order-refresh-and-process.
The class has to implement the \Drupal\commerce_order\OrderProcessorInterface and it has to provide an implementation of the process method.

class MyCustomProcessor implements OrderProcessorInterface {

    public function process(OrderInterface $order) {
        $payment = $order->get('payment_method')->first()->entity;
//   or
        $payment = $order->get('payment_gateway')->first()->entity;

//... your logic here depending on what you'd like to do

        $order->addAdjustment(new Adjustment([
            'type' => 'fee',
            'label' => 'Payment method fee',
            'amount' => new Price($fee, 'EUR')
        ]));

    }
}


How can we output unfiltered HTML in a CCK field

OK after searching high and wide for a solution, I finally came across this article: http://drupal.org/node/1100430

Basically the CCK component module "Text or Node Reference" causes an issues that hides the "Text Processing" options, disabling this module allowed us to change the input filter format!


Create a custom template for displaying a custom content type - and Views in Drupal 7

Create node--flowers.tpl.php, put the default code from modules/node/node.tpl.php, and edit it.


The change record says if you have entityTypeManager injected, use

$query = $this->entityTypeManager->getStorage('node')->getQuery();

For non-OOP code, $query = \Drupal::entityQuery(); is not deprecated and can still be used.

The linked example for sorting an entity query by using $query:

$query->condition('type', 'blog_post')
  ->sort('field', 'DESC');
$nids = $query->execute();


How to set default body message for Privatemsg embedded on page?

Have a look at the descriptor of the privatemsg_new function in privatemsg.pages.inc:

privatemsg_new($form, &$form_state, $recipients = '', $subject = '')

It doesn't take a $body argument so you will need to alter the form once it has been created.

Make a custom module
Use hook_form_FORM_ID_alter
Set $form_state['values']['body'] to your desired value


I am guessing you are adding it as a block to a specific path.
If yes, follow the steps below:

Go to the block configuration
Scroll down to the Visibility Settings
Click on "Pages" tab
Select the option "Pages on which this PHP code returns TRUE (experts only)"
Write your PHP logic to read the GET parameters and return true only if the specific parameter you are looking for is not found.


I solved this for the CKEditor module for Drupal 7 by altering the widget itself using hook_field_widget_WIDGET_TYPE_form_alter():

/**
 * Implements hook_field_widget_WIDGET_TYPE_form_alter().
 * Set the '#wysiwyg'-attribute to false for the summary fields.
 */
function YOURMODULE_field_widget_text_textarea_with_summary_form_alter(&$element, &$form_state, $context) {
  if (isset($element['summary']) && !isset($element['summary']['#wysiwyg'])) $element['summary']['#wysiwyg'] = false;
}

Hope this helps!


Setup custom required field validation for a field in custom form

How do I add a custom validation to an existing form/field?

If you want to add your custom validator in addition to the default, you will have to add something like this in hook_form_FORM_ID_alter (or similar):

$form['#validate'][] = 'my_test_validate';


Toggle translation in a multilingual site

I recommend using the Language icons module. It will provide a block where languages can be toggled with a Flag. Btw the i18n (at least in D6) provides a similar block but with no flags, you can use this instead too and add the flags with a little CSS. HTH.

http://drupal.org/project/languageicons


Check if the screenshot settings work for you,this the setting for the field you want to hide when empty. It provides option to hide the rewritten content as well.


How to save the input values in an unfinished node form

You could save the values in the users session ($_SESSION) and clear the value(s) when the form is submitted. You would have to use AJAX to update the values whenever a field is changed, as you can't do it when the user decides the leave the page.


How can I re-format (not validate) the value of a field that a user inputs into a node?

In Drupal 6, you could do something with the nodeapi() hook, eg,

function MYMODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL)

  if ($node->type=='TYPEOFNODE' && $op == 'presave') {
    $node->field_WHICHEVERFIELD[0]['value']=ucwords($node->field_WHICHEVERFIELD[0]['value']);
  }

  // other nodeapi()ing goes here

}

In Drupal 7, you could use the node_presave() hook with similar logic.


override the node template and remove title from there.


Organic Group visible only by authenticated user

I used the Content Access module to deny access to anonymous user.

In your Organic Group content type admin interface (admin/structure/types/manage/committee) a new ACCESS CONTROL tab appears. Unckeck anonymous user for the view View any committee content.

If authenticated user is check it will over-right Organic Group settings (ie. the Private / Public will have no effect and the content will be accessible to all authenticated user).

source


hook_form_alter is probably a good approach for displaying the search words in the form.

Assuming you're not submitting the form via AJAX, you need a way of passing the search words to the next page load. One way might be to redirect to the same URL but adding your search words as URL query parameters. You could do that by setting $form_state['redirect'] or calling drupal_goto in your submit function.

Another way, maybe easier, would be to save your search words in the user's session and reading them back in the subsequent page.


Use MYTHEME_preprocess_node($vars) instead of MYTHEME_preprocess_page($vars) to get your declared variables in template.php to get in node.tpl.php.

I see you are already using template_preprocess_node(), so just put all those things which are intended for node.tpl.php in that function.


There are two option:

Use a different template for the front page you have to name your template page--front.tpl.php and clear the theme registry. Please check Theming Guide for more details.
There's also the Front Page module: http://drupal.org/project/front


2 separate Profile2 Views (one faculty, one staff)

You could add a field "user type" to the current profile and then add a views filter or views "contextual filter" to only show one type at a time. You may need to add a "relationship" on the profile2.

Alternatively, profile2 lets you specify different types of profiles. So you could make a 'faculty' profile and a 'students' profile.

It really depends on what would work best in your setup.


Add a non-base field to a content entity form

You can ship a locked Field with yml only, see core/modules/forum/config/field.*. Ie just make the fields in the ui and copy the yml files from your active store to a config folder inside your module.

This ships a locked boolean field for the container flag. You'll also need form and entity display entities, but you can create them in the ui and grab the yml for them too.


You can override the output by implementing theme_status_messages in your theme.

You could work from something like this. See $myprefix that I've added.

function MYTHEME_status_messages($variables) {
  $display = $variables ['display'];
  $output = '';

  $status_heading = array(
    'status' => t('Status message'),
    'error' => t('Error message'),
    'warning' => t('Warning message'),
  );
  foreach (drupal_get_messages($display) as $type => $messages) {
    $myprefix = $type == 'error' ? 'ERROR: ' : '';
    $output .= "
\n";
    if (!empty($status_heading [$type])) {
      $output .= '
' . $status_heading [$type] . "
\n";
    }
    if (count($messages) > 1) {
      $output .= "
\n";
      foreach ($messages as $message) {
        $output .= '
' . $myprefix . $message . "
\n";
      }
      $output .= "
\n";
    }
    else {
      $output .= $myprefix . reset($messages);
    }
    $output .= "
\n";
  }
  return $output;
}


How to download programmatically a module?

Normally you want to use drush, e.g.

drush -y en module_name

which would download, install and enable your module of interest.

Check drush.api.php to use appropriate API hooks which could be useful.

If you don't want to use Drush, check how Update Manager does that in update/update.manager.inc, e.g.

update_manager_file_get
update_manager_archive_extract
etc.

To get the list of available files to download for specific project you've to fetch and parse the release history which is available at:

https://updates.drupal.org/release-history/project_name/7.x

the same as drush does that (check by drush -vd dl foo) and get the links from there.


How to create a module to insert some analytics code in the footer of website pages?

These two links should get you started:

https://www.drupal.org/node/206761

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


Is there way to create regions for view modes programmatically?

You should be able to theme the fields behaving like a css-grid-system, maybe provided by your theme. Name view field templates like this:

views-view-field--foobar--page--field_name.tpl.php

And

Make sure they have the correct order in the view.
Empty fields wont be displayed.

If they have different names for the different content types, just include all field-names in your selectors ..

Maybe also have a look in the docs, and views have name suggestions under Advanced -> Theme: Click on Information


Adding HTML5 placeholder to all drupal forms

Because I'm using the webform module I could just theme the global webform template (webform-form.tpl.php) and put it in my theme folder. No need to complicate things with a module.

foreach ($form["submitted"] as $key => $value) {
    if ("textfield" == $value["#type"]) {
        $form["submitted"][$key]['#attributes']["placeholder"] = t($value["#title"]);
    }
}

I put this at the top of the template file.


How can I add a new field from config inside hook_update_N?

Yes, you can't create content before the relying config has been imported. That's a classic Drupal 8 paradox which has just recently been solved by a new hook: hook_deploy_NAME(&$sandbox).
Update to the latest Drush and from now on run drush deploy as part of your deployment routine, which replaces the old drush updb && drush cim routine. Then create a new file in your module: MYMODULE.deploy.php. In there implement MYMODULE_deploy_NAME(&$sandbox) where NAME can be any unique name (or an incrementing number as well). And use this hook to create the terms, same as in the hook_update_N(&$sandbox) in your question.
drush deploy will ensure that this hook will be picked up at the very last in the deployment routine, after the relying config has been created from configuration import.


Can not update drupal/core with composer

The trick is, that drupal/core and webflo/drupal-core-require-dev always have to point to the very same version.

If you use composer update composer will look for this and pull the needed actual versions alone.

There are some articles recommending not to do so, but instead to update in minor parts and specify a concrete packet for better testing and reverting possibilities if something goes wrong. This means typing:

composer update drupal/core --with-dependencies

This may be true, but I often run in such errors with dependencies then I have to solve myself. You have now to specify both packets in the same command, then it will work too:

composer update drupal/core webflo/drupal-core-require-dev --with-dependencies

My private conclusion:

If I have time to go the suggested way and solve such dependencies, than I will specify the single packet to update.
If it makes problems and I have an actual backup of my codebase and my database (as you should alwas have before updating anything!) and have not so much time, I simple type composer update and mostly all will work out of the box at the first try.


Using db_insert with a reserved keyword as the column name

You can try to pass column name in `parenthesis` to db_insert. Just be sure you escaped them if needed, as they have their own meaning in php itself.
If this does not work, well, you can:

fill a bug against core, or post in existing one.
use good old db_query
Or use thesaurus to get rid of reserved words from your app. There is always a "good reason" to use them, of course there is for any common word, but word-oriented languages simply have to reserve some words.


Drupal 7 - Display Content type as Block and Block Naming Convention

So, if I understand this correctly, your asking how you can make a block which displays fields from a content type based on some logical requirements, then provide an .tpl override so you can do some custom work to the output of those fields? I hope thats right.

So this is relatively easy depending in how you want to go about this.

Step 1: You've created your content type and added all of the fields that you want. I'm assuming you've also created some content already to test the next part.
Step 2: You need to create a view that has a block display. See screenshot for an example. https://skitch.com/therealwebguy/8ksue/block-step-1
Step 3: Set up your block view appropriately. See screenshot for more specific details for this: https://skitch.com/therealwebguy/8ksw9/block-step-2
Step 4: If you refer to the screenshot provided in Step 3, you'll notice in the bottom right that I have highlighted the "Information" link for the Theme layer. Clicking this link will bring up a list of all of the .tpl files you can create for this view to target what you need. It has everything from the top-level view tpl to the output of a single field being rendered by the view. Choose the one that's best for you needs, copy the HTML provided and add it the view.tpl.php file you've chosen to use.

Lets recap:

We've create a content type and added fields to it.
We've added actual nodes of the new content type for testing.
We've created a new view which will provide a block display, showing us the field values of our content type that we want to show.
We've created a custom tpl override for the view of our choice to do some more customization at the theme level that best fits our needs.

The only thing left to do is to head over to your blocks administration and put the block where you want it.

Good Luck!


Views exposed filter - Replace '-Any-' by Select All

This question is already answered. Please find the answer in below link
https://stackoverflow.com/a/5975294/5093173

or use this code

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'view name') {
      $form['filter_name']['#options']['All'] = t('select all');
}

}


Hide Profile2 fields depending on it's value when viewing user profile

You'd be better off putting your code in a custom module, as you can implement hook_profile2_view() instead. That will give you far more control over the output.

Without more specifics it's hard to be accurate but generally speaking the code would look something like this:

function MYMODULE_profile2_view($profile, $view_mode, $langcode) {
  $field_items = field_get_items('profile2', $profile, 'field_name_of_field');
  if ($field_items) {
    $value = $field_items[0]['value'];

    if ($value == 'something') {
      $profile->content['field_name_of_field']['#access'] = FALSE;
    }
  }
}


What you're describing is a content recommendation system. This isn't what Google CSE is built for and implementing the way you describe would likely result in poor results.

You're better off implementing one of Drupal's existing recommendation modules or some other 3rd party recommendation service (e.g. OutBrain).

Some of Drupal's recommendation modules include:

Recommender API: Broad API that ties into other Drupal entities.
Similar By Terms: Use similar taxonomy terms to find related content.
Similar Entries: Uses MySQL full text searching to find related content.


How to add a category in the FAQ_ask module

In order to use categories with the FAQ module you need to have the taxonomy module enabled.

Once you have the taxonomy module enabled you will need to create at least one vocabulary and associate it with the "FAQ" content type.

Once you've completed the above step you can visit the FAQ categories configuration page (admin/settings/faq/categories) and set up how you would like the categories to be display and there expected behavior on the faq page.

Hope this helps.


This should really be addressed to the fmath project maintainers. I've mailed them to point out some security concerns in the code. If they don't respond I'll edit this post to answer the question here, but hopefully they will respond with a new version ;)

Original comment - mailed to fmath maintainer:

Some key things this is missing that you would want to get right:

CSRF protection - If you don't use the form API (which includes this already) then you can manually use drupal_get_token and drupal_valid_token are helpers.
Malicious file types - file_munge_filename is a helper here
Too many/too big of files
Temporarily uploading the file to a temporary directory outside of the webroot and giving it a random name so that it can be validated in that temporary location before moving it to the final location
Ideally you would validate the file contents (e.g. virus scan, confirm the file is a valid file of whatever the extension/mime type says it is).
Control where the file can be placed.

This script looks like it would only allow jpg or png files to be uploaded, but it misses out on a few other security features

There are probably a few other things to worry about, but I think that list is a good start.

I also wonder about this piece and whether you could sneak base64 encoded html into a "jpg" file and then some veresions of internet explorer and safari will do mime type detection and execute the html (i.e. cross site scripting attack):

   echo base64_decode($_POST["image"]);


drush "The drush command 'self-update' could not be found."

self-update was removed a while ago. I'm not sure what the official replacement is, but a simple git pull; composer install does the job for me with the latest version (run it in the drush lib folder, probably in /usr/local/Cellar if it was brewed).

theme list (and theme) don't appear in the list of available commands (although self-update does, ironically). Maybe you're looking for

drush pm-list --type=theme


How to override checkout form validation error message?

You'll want to use:  theme_status_messages.

First, use drupal_get_messages to clear the queue.

Then, use drupal_set_message to add your new generic message.


Can I have a webform in sidebar block reload current page

This is an old question, but it comes up high in search results, so I thought I'd provide an answer.

The behavior you've described is the intended behavior. The module maintainer states that the original implementation of the No Redirect option was designed "under the assumption that if you were starting a form you'd enter minimal information (such as an e-mail address) to start the form, then you'd want the rest of the form on a larger page."

To achieve your desired behavior (i.e., reload whatever page the block form is submitted from), you need to take one extra step: From the block configuration page, check the box for Show all webform pages in block and save the configuration.


Maybe you should use a Search API and Search API database module? It's more flexible in terms of working with index. For example, you can configure index settings(which fields to index)and rebuild index after it.
Try to use Google Custom Search module.


Apache SOLR index or retrieve the node a file is attached to

I am not sure if this can be done with a generic file field. It could be possible if it was a media or entity reference field. I think the simplest approach is to use hook_search_api_solr_documents_alter to find and add the node ID to the document when it is being indexed.
You can, possibly, then use the new field to create a relationship to Node table in the view to display the link or simply handle it on the theme level.


yml settings file is just read on module install

This is normal, because if the user modifies the settings, he doesn't expect that the changes are overwritten by a module update.

If you want to change the settings in an update hook, you can use the config API.

\Drupal::configFactory()->getEditable('mymodule.settings')->set('mysetting', $value)->save();

In development you can export the complete config of your site once to the sync folder. There you will find the yml file: /sites/default/files/config_hash/sync/module_name.settings.yml.

Edit the yml file in the sync folder and import the config as often as you want until you find the final version. After you've finished the development you can copy the final version of the settings yml in the module folder.

For export and import you can either use the admin configuration interface or use drush config-export and drush config-import.

Another option is to directly edit the config on the command line:

drush config-edit module_name.settings

After closing the editor the settings are imported in the active config. After you've finished the development open the settings one more time and copy and paste the end result in the yml file of your module.


how to make $page['content'] stop replacing HTML

Try going to admin/config/content/formats/html where 'html' is your WYSIWYG profile and check your filter processing order.

Mine:

Insert view filter
Convert Media tags to markup
CKEditor Link Filter
Convert URLs into links
Correct faulty and chopped off HTML
Limit allowed HTML tags

If I put 'Limit allowed HTML tags' at the top I get similar issues to what you are describing.

EDIT: The order did not actually cause the issue for me. I had just forgotten to add <h3> to the allowed list.


Ok, the answer is unfortunately Drupal can not handle this situation. What should be done is the following:

On Windows

Go to: C:\Windows\System32\drivers\etc

Open: hosts file

Add at the end:

100.200.10.20 yourdomainname.com
109.200.10.20 www.yourdomainname.com

On Mac

Open Terminal (Applications -> Utilities -> Terminal)

Open hosts file: $ sudo nano /private/etc/hosts

Type your user password when prompted

Add at the end:

100.200.10.20 yourdomainname.com
109.200.10.20 www.yourdomainname.com

Save the file Flush the DNS cache: $ dscacheutil -flushcache

NOTE: The IP is the IP of your server. You can get it by logging into Plesk, Home>System Overview


Drupal 7 Organic Groups, Drupal Commerce and Paypal

Please check out Commerce Node Checkout Module It gives you a basic Pay to Pubish workflow, which is exactly what you are try achieve.

As the project page says the module helps you

  Integrate with Commerce in order to allow you to charge users to
  create nodes.


Why are default values in a checkboxes $form not displayed?

For form elements expecting multi-value defaults, Drupal expects an array where keys and values are equal to the keys in your options array. Something like the following should work:

$defaults = array(
    'uid' => 'uid',
    'name' => 'name',
);

You may also use $defaults = drupal_map_assoc(array('uid', 'name'));.


How to concatenate fields in Views with different separators (Settings)?

Solution 1:

As @rooby suggested here are the steps you can follow

Add the fields Last Name, First Name, Middle Name and Suffix to the view in the same order
For the first 3 fields Last Name, First
Name, Middle Name select the option "Exclude from Display" and save.
In the settings of the field "Suffix" check the option "Rewrite
the output of this field" under the section "Rewrite Results".
In the TextArea that gets displayed enter [field_last_name],
[field_first_name] [field_middle_name] [field_suffix]

For the exact field names you may click on the link "Replacement Patters" below the text area.

This approach works fine if the Suffix field is a required field and all the records for it. If not the complete value is not displayed if the suffix is empty.

Solution 2:

Add the fields Last Name, First Name, Middle Name and Suffix to the view in the same order
Add "Global: Custom text" field to the view at the bottom of all the fields.
For the fields Last Name, First Name, Middle Name and Suffix select the option "Exclude from Display" and save.
In the settings of the custom text field enter [field_last_name],
[field_first_name] [field_middle_name] [field_suffix] under "Text" and save
Look at the replacement patterns for the exact field names in your system

This approach works fine even if there are empty values for any of the fields.


Found this thread, which was very helpful:

Metatags and Commerce - pass taxonomy metatags to commerce product view

I adapted that approach to have metatag generate the tags from the first entity returned by the view:

/*
 * Implement HOOK_views_post_render to run code for each view render
 */
function THEME_OR_MODULE_views_post_render(&$view, &$output, &$cache) {
  // check for a particular view and view display page
  if ($view->name=='YOUR_VIEW' && $view->current_display == 'YOUR_VIEW_DISPLAY') {

    // retrieve the first node in the view
    $entity_type = 'node';
    $entity = entity_load($entity_type, $view->result[0]->nid);
    $language = entity_language($entity_type,$entity);

    // Generate metatags output
    if ($tags = metatag_generate_entity_metatags($entity, $entity_type, $language, 'YOUR_ENTITY_DISPLAY_MODE')) {
      list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity);
      $instance = "{$entity_type}:{$bundle}";

      // register the term's metatags
      metatag_page_set_metatags($instance, $tags);
    }
  }
}

Here is alternate code which doesn't rely on the Metatag module, and allows for more finely tailored meta tags based on view results:

function HOOK_preprocess_html(&$vars) {

    // only operate on the front page
    if ($vars['is_front']) {

        // get the view results
        $view_results = views_get_view_result('YOUR_VIEW_NAME','YOUR_VIEW_DISPLAY_NAME');
        // load up the first node
        $node = entity_metadata_wrapper('node',$view_results[0]->_field_data['nid']['entity']);

        // get some data
        $title = $node->label();

        // some fields may require more processing
        $description = trim(drupal_html_to_text($node->field_description->value()['safe_value']));
        $image = image_style_url('YOUR_IMAGE_STYLE',$film->field_image->value()['uri']);

        // generate and output the meta tags
        $tag = array(
        '#type' => 'html_tag',
        '#tag' => 'meta',
        '#attributes' => array(
          'property' =>  'og:title',
          'content' => $title,
        )
        );
      drupal_add_html_head($tag, 'og_title');

        $tag = array(
        '#type' => 'html_tag',
        '#tag' => 'meta',
        '#attributes' => array(
          'property' =>  'og:description',
          'content' => $description,
        )
        );
      drupal_add_html_head($tag, 'og_description');

        $tag = array(
        '#type' => 'html_tag',
        '#tag' => 'meta',
        '#attributes' => array(
          'property' =>  'og:image',
          'content' => $image,
        )
        );
      drupal_add_html_head($tag, 'og_image');
    }
}


How do I create relevant keyword search?

You would need Search API and Search API Solr for this, along with a Solr instance to get relevancy scoring and support for fuzzy searching (e.g. iphone iphane etc).

https://www.drupal.org/project/search_api
https://www.drupal.org/project/search_api_solr

It is mostly configurable from the Drupal UI.


What is causing "Object of class stdClass could not be converted to string"

Please pass $tids array direct to the function.
E.g:

$terms = taxonomy_term_load_multiple($tids);

NOTE: Also before passing $tids to the function, please check it is include only tids.
E.g:

$tids should be like $tids = [10,11,12,13,...];


Run a Drupal website offline (±without server)? --- E.g. hand it over on a usb-stick / by mail? --- Run it from the HD, while retaining functionality?

Drupal is too large a project to be run on slim architecture or dumb terminals. If you're going to buy a USB stick (memory) to store Drupal then buy a "computer stick" and run Drupal off of Sqlite on the stick, for example a Gumstix product with Ubuntu on it $200 USD is hardly more expensive then an expensive large USB memory stick. https://store.gumstix.com/index.php/products/283/


Updating my very first install of Drupal

If you can use Drush, do. It makes life very easy. If memory serves it's as simple as issuing a drush up drupal command, and following the prompts.

If you can't use Drush then copying the core Drupal files over the top of the old ones is the way to go, but make sure you don't replace the /sites folder. On most production servers the /.htaccess file will also have been modified so make sure you don't overwrite it if there have been changes made.

Either way, make sure you take a backup of the code and database before upgrading so you can easily rollback if something goes wrong.

You may find the Update your Drupal site from one minor 7.x version to another minor 7.x version page a particularly useful read before getting started.

Also, as Kalabro points out in the comments, never run an update on a production server without having tested it on your dev/staging environment first.


Using Drupal 8's Migrate API, how can I map a nested (hierarchical) taxonomy term to the imported entity?

On my project, I created a group migration with two migrations

taxonomy migration all taxonomy term.
taxonomy_parent update parent for terms have parent.

There are example code (I use the embedded_data source plugin for the sake of simplicity so that this example can be copy-pasted as a working example ) and source like that:

Migration group: migrate_plus.migration_group.taxonomy.yml

id: taxonomy
label: Import Taxonmy
description: Import Taxonomy.

Migration all term: migrate_plus.migration.taxonomy.yml

id: taxonomy
label: Import term taxonomy
migration_group: taxonomy
source:
  plugin: embedded_data
  data_rows:
    -
      id: 1
      name: 'Parent 1'
    -
      id: 2
      name: 'Children 1'
    -
      id: 3
      name: 'Children 2'
    -
      id: 4
      name: 'Children children 1'
  ids:
    id:
      type: integer
destination:
  plugin: entity:taxonomy_term
  default_bundle: custom_taxonomy
process:
  name: name

Set parent for term: migrate_plus.migration.taxonomy_parent.yml

id: taxonomy_parent
label: Set parent taxonomy
migration_group: taxonomy
source:
  plugin: embedded_data
  data_rows:
    -
      id: 2
      parent: 1
    -
      id: 3
      parent: 1
    -
      id: 4
      parent: 2
  ids:
    id:
      type: integer
destination:
  plugin: entity:taxonomy_term
  default_bundle: custom_taxonomy
  overwrite_properties:
    - parent
process:
  tid:
    plugin: migration_lookup
    migration: taxonomy
    source: id
  pid:
    plugin: migration_lookup
    migration: taxonomy
    source: parent
  parent: '@pid'

and result:


Running cron tasks before clear all your cache.
During development it is necessary to clear the cache very frequently.
Clearing caches is relatively harmless. Sites might slow down for a bit afterwards while the cache fills back up.


new comment notification in teaser mode in links

There is history db table in Drupal: "A record of which users have read which nodes."
It contains last time when user viewed a node. This data allows to show new content and new comments to user.
Comment module uses it to determine how many new comments appeared while user was not on the node page in comment_num_new() function.
Link “2 new comments” was added by this code in comment.module file through hook_node_view() hook:

  // Show a link to the first new comment.
  if ($new = comment_num_new($node->nid)) {
    $links['comment-new-comments'] = array(
      'title' => format_plural($new, '1 new comment', '@count new comments'),
      'href' => "node/$node->nid",
      'query' => comment_new_page_count($node->comment_count, $new, $node),
      'attributes' => array('title' => t('Jump to the first new comment of this posting.')),
      'fragment' => 'new',
      'html' => TRUE,
    );
  }


How to style an "all day event" to have it styled like any other event?

As far as I understand it this is a CSS question. All you need to do is add styles to overwrite the color change. It is actually two different styles that need to be changed. The following code will set them back to the yellow and light grey color that is the default for the calendar module.

.calendar-calendar .month-view .full td.multi-day div.monthview,
.calendar-calendar .week-view .full td.multi-day div.weekview,
.calendar-calendar .day-view .full td.multi-day div.dayview {
  background: #ffc;
  color: #777;
}

.calendar-calendar .month-view .full td.multi-day .inner .monthview .continues,
.calendar-calendar .month-view .full td.multi-day .inner .monthview .cutoff,
.calendar-calendar .week-view .full td.multi-day .inner .weekview .continues,
.calendar-calendar .week-view .full td.multi-day .inner .weekview .cutoff {
  background: #ffc;
  color: #777;
}


hook_module_implements_alter() allows just to alter the hooks implemented by modules, and hook_theme_registry_alter() alters only the theme functions, not hooks.

If you look at the code of drupal_alter(), the function that invokes all the alter hooks, you will see the following code, which deals with alter hooks implemented by themes.

// Allow the theme to alter variables after the theme system has been
// initialized.
global $theme, $base_theme_info;
if (isset($theme)) {
  $theme_keys = array();
  foreach ($base_theme_info as $base) {
    $theme_keys[] = $base->name;
  }
  $theme_keys[] = $theme;
  foreach ($theme_keys as $theme_key) {
    $function = $theme_key . '_' . $hook;
    if (function_exists($function)) {
      $functions[$cid][] = $function;
    }
    if (isset($extra_types)) {
      foreach ($extra_types as $extra_type) {
        $function = $theme_key . '_' . $extra_type . '_alter';
        if (function_exists($function)) {
          $functions[$cid][] = $function;
        }
      }
    }
  }
}

The alter hooks implemented by the base themes run first; if you have a sub-theme, and that is the current theme, its alter hook will run last. The only thing I see you could do is (in the implementation of the same hook done from your theme) to remove the changes introduced by seven_form_node_form_alter() that you don't want in your theme.


drush sql-dump with --gzip from remote to local machine

Here are few checks you should do:

make sure that your gzip program is in your $PATH (just check if you've gzip command),
disable any drush verbose messages to avoid printing any extra lines from  terminal which could break the compression,
temporary use -vd to check how the command look like (Executing or Backend invoke) and make sure you've --gzip in your argument list, if it's not - you're getting the plain version of it for some reason (so you can redirect to .sql file instead)

If your --gzip is not invoked, even you're specifying one and gzip is configured correctly, then it's probably a drush bug. I think this could depend on PHP version which you're using as I've the same problem with PHP 5.5.


Reference to parent node on entity form type

Prepopulate works by lifting values from the request url and inserting them into the rendered form. If it is not in $_GET it will not appear. Using views with a menu tab will mean that you will have to add parameters to the url whether you use Prepopulate or not. I think you should back up and reconsider your approach.

I would suggest exposing the form as a block right on the pages you want. That way the page is easier to identify. If you use Bean it is a simple matter to create a block for your Entity Form Type.

Enable the Bean and Bean UI modules.
Go to /admin/structure/block-types and click 'Add new block type'.
Give the block type a name (eg Entity Form Type Block).
Under 'Manage fields' add an 'Entity reference' field. Select box widget is fine.
Under 'Manage display' select 'Rendered entity' and 'Render as full content'.
Go to /admin/content/blocks and click 'Add new block'.
Give the block a Label (eg. Request more information block) and a title.
Select your form from the dropdown, and save.
Go to /admin/structure/views/add and create a view called 'Node List' showing 'content' of type 'all'. Uncheck the 'Page' display. You are creating the master only. Click 'Save and Continue'.
In the view edit screen, Add a display -> references.
Configure the 'Title' field and uncheck everything (no label, no link).
Under 'Advanced' configure a contextual filter in Content:NID. Check 'Provide default value' and select 'Content ID from URL'. Save your view.
Go to /admin/structure/entityform_types and click 'Manage fields' for your entity form. Edit the nodereference field and set it to required, number of values = 1, and at te bottom under 'Views - Nodes that can be referenced' select your 'Node list - references' view.
Go to /admin/structure/block and set your block to display on the nodes you want, and for the roles you want. It is important to note that the block permissions will override any access permissions you have set on the form.

The entity form will now display on the selected pages, and the user will be required to select the node reference to submit the form. The list presented will be limited to the current page.


The question about "How to create a node out of a webform submission?" that you linked to, is about D8, while yours is about D7 ...

In D7, for sure,, you can use the Rules module for this. As an example, consider this rule (in Rules export format), which does what you're asking for:

{ "rules_create_a_node_from_webform_data" : {
    "LABEL" : "Create a node from webform data",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "webform_rules", "rules" ],
    "ON" : { "webform_rules_submit" : [] },
    "IF" : [
      { "webform_has_id" : {
          "form_id" : [ "form_id" ],
          "selected_webform" : { "value" : { "webform-client-form-191" : "webform-client-form-191" } }
        }
      }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "The webform submitted contains these fields:\r\n\u003C\/ul\u003E\r\n\u003Cli\u003Ethe field labeled \u0022[data:demoform_title-title]\u0022 which has value \u0022[data:demoform_title-value-raw]\u0022.\u003C\/li\u003E\r\n\u003Cli\u003E the field labeled \u0022[data:demoform_text-title]\u0022 which has value \u0022[data:demoform_text-value-raw]\u0022.\u003C\/li\u003E\r\n\u003Cli\u003E the field labeled \u0022[data:demoform_number-title]\u0022 which has value \u0022[data:demoform_number-value-raw]\u0022.\u003C\/li\u003E\r\n\u003Cli\u003E the field labeled \u0022[data:demoform_option-title]\u0022 which has value \u0022[data:demoform_option-value-raw]\u0022.\u003C\/li\u003E\r\n\u003C\/ul\u003E" } },
      { "variable_add" : {
          "USING" : { "type" : "text", "value" : "[data:demoform_text-value-raw]" },
          "PROVIDE" : { "variable_added" : { "var_demoform_text" : "Form variable text" } }
        }
      },
      { "variable_add" : {
          "USING" : { "type" : "text", "value" : "[data:demoform_number-value-raw]" },
          "PROVIDE" : { "variable_added" : { "var_demoform_number_text" : "Form variable number text" } }
        }
      },
      { "data_convert" : {
          "USING" : { "type" : "integer", "value" : [ "var-demoform-number-text" ] },
          "PROVIDE" : { "conversion_result" : { "var_demoformvar_number" : "Form variable number" } }
        }
      },
      { "variable_add" : {
          "USING" : { "type" : "text", "value" : "[data:demoform_option-value-raw]" },
          "PROVIDE" : { "variable_added" : { "var_demoform_option" : " Form variable option" } }
        }
      },
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "article",
            "param_title" : "[data:demoform_title-value-raw]",
            "param_author" : [ "user" ]
          },
          "PROVIDE" : { "entity_created" : { "article_created" : "Created article" } }
        }
      },
      { "data_set" : {
          "data" : [ "article-created:body:value" ],
          "value" : [ "var-demoform-text" ]
        }
      },
      { "data_set" : {
          "data" : [ "article-created:field-free-format-nr" ],
          "value" : [ "var-demoformvar-number" ]
        }
      },
      { "data_set" : {
          "data" : [ "article-created:field-optionlist" ],
          "value" : [ "var-demoform-option" ]
        }
      },
      { "data_set" : { "data" : [ "article-created:comment" ], "value" : "0" } },
      { "entity_save" : { "data" : [ "article-created" ], "immediate" : "1" } },
      { "drupal_message" : { "message" : "A new article got created, with nid=[article-created:nid] and url=[article-created:url]" } }
    ]
  }
}

Anybody a bit familiar with Rules and Webform, while know that it's often a struggle to get access to the data contained in a submitted Webform. Mostly because they are not available to select them when building Rules Actions.

However by introducing those var-demoform-... variables (as in the above rule), you can make the typical Rules magic happen. Refer to my answer to "How to create a node from a Webform using rules?" for more details about all this.


I've resolved the sorting problem with sorting data inside the formatter. Here's my code in case someone had similar problems.

<?php

/**
 * @file
 * Contains \Drupal\restful\Plugin\formatter\OrderFormatter.
 */

namespace Drupal\my_module\Plugin\formatter;

use Drupal\restful\Plugin\formatter\FormatterJson;
use Drupal\restful\Plugin\formatter\FormatterInterface;

/**
 * Class OrderFormatter
 * @package Drupal\restful\Plugin\formatter
 *
 * @Formatter(
 *   id = "order_formatter",
 *   label = "ORDER FORMATTER",
 *   description = "Output filtered data",
 *   curie = {
 *     "name": "dis",
 *     "path": "doc/rels",
 *     "template": "/{rel}",
 *   },
 * )
 */
class OrderFormatter extends FormatterJson implements FormatterInterface {

  /**
   * Content Type
   *
   * @var string
   */
  protected $contentType = 'application/json+sort; charset=utf-8';

  /**
   * {@inheritdoc}
   */
  public function render(array $structured_data) {
    $i=0;
    foreach ($structured_data['data'] as $v) {

      $structured_data['data'][$i]['unsortedThings'] = $this->sortBy($structured_data['data'][$i]['unsortedThings']);
      $i++;
    }
    return drupal_json_encode($structured_data);
  }

  public function sortBy($arr) {
    $results = [];
    foreach ($arr as $k=>$v) {
      $results[$k] = $v['weight']; //this is my sorting field
    }
    asort($results, SORT_REGULAR);

    foreach (array_keys($results) as $key) {
      $results[$key] = $arr[$key];
    }
    $results = array_values($results);
    return $results;
  }

}

You run this formatter by adding header to your request: Accept: application/json+sort; charset=utf-8


Randomize the result of a database query

For MySQL you can do

ORDER BY RAND()

To order by random, for PgSQL RANDOM() instead should yield the desired result.


Minimally working end-to-end example of drush batch job execution

I've written drush CLI commands. I've also written some Batch API processes. On each individual topic you've asked about there is alot of documentation.

I'm not sure why you want to use the Batch API specifically via Drush. The Batch API in part is used to avoid HTTP request timeout in long PHP processes. If you're using Drush from the command line -- you have no max_execution_time to worry about from php.ini essentially ...

How to use the Queue API (and Batch) from DrupalCampLA2012 I attended

which goes to the actual link for the slides

A batch tutorial from March 2012 I have have referenced in creating my own BatchAPI stuff in the past (site db was down so I linked to a google cache page)

EDIT: Have you looked into the Migrate source to see how they run Batch stuff from drush cli?


Rather than loading a page based on nid and then returning the loaded output as an HTML , use drupal_goto function like below :

drupal_goto('node'/.$nid);


It seems that FileViewer has been folded into a module called PDF, which uses JavaScript to render PDF files.

So the next logical question is: How do you render Word docs, like Google Docs? And the answer is: Google Docs Integration module, which lets you show a list of Google docs, but doesn't let you display the documents.

Web searches give up nothing else.

Good luck...


Redirect from route when the controller has been changed

With the help from @4k4 I found a solution.

I created an event subscriber that extends the HttpExceptionSubscriberBase class. There I created the redirect like this:

public function on404(GetResponseForExceptionEvent $event) {
  $response = new TrustedRedirectResponse('https://google.com', 307);
  $event->setResponse($response);
}


It's been a while now since I've used D6 but can't you just disable the comments module?

Alternatively what about just blocking /comment with htaccess (SO thread on the subject)?


As @Beebee pointed out, Drupal stores its pages in a Database. That means the actual "pages" aren't going to be available via FTP.

The first thing you need to verify is, do you have a copy of the old Drupal website's database? If not, try reaching out to your old website host to see if they can recover it for you.

If the database isn't available, then your best bet to see the old website would be to use:

https://archive.org/web/

If you do have the old database, here's how you can set up and see the old website:

On your website host, set up a subdomain through cPanel (e.g.
drupal.example-ymca.com)
Place a copy of all the old Drupal files inside this new subdomain directory (e.g. ~/www/drupal - so the index.php file that comes with Drupal lives here: ~/www/drupal/index.php)
Create a new MySQL database, user and password through cPanel (take note of each while doing so)
Import the Drupal database into this empty database
Open the ~/www/drupal/sites/default/settings.php file and input your database credentials in the database config section
Visit your old website, e.g. http://drupal.example-ymca.com/

Here's a Google Search Result set that has additional topics:

https://www.google.com/search?client=ubuntu&channel=fs&q=drupal+transferring+from+host+to+host&ie=utf-8&oe=utf-8

I'd also like to point out, that it is possible to create/edit pages in Drupal by writing custom code (via an FTP if you wish) by using hook_menu(). This is a slightly more advanced topic, but nonetheless, a very important one to understand when working with Drupal. Once your site is up and running, locate any custom modules that implement hook_menu() to see custom pages (if any) that were created this way.


How do I enable editing the body of a block?

You are facing this issue because you probably created the block as a user who has access to a text format like Full HTML but the other user doesn't have that permission :( Here's what you can do:

Sign in as the root user (uid 1) who created the block;
Change the text format to Basic HTML or Restricted HTML.
Go to Admin > People > Permissions page and make sure the other non-admin user has the permissions to use the text format you applied.
Depending on your requirements, you can ignore point 2 and give Full HTML permissions to the concerned user.


Modify the page title of view and set custom title for it

Found one that works

function MYMODULE_views_pre_render(&$view) {
  if ($view->name == 'menu') {
    $view->build_info['title'] = "TEST TITLE";
  }
}


How to install a drupal distribution using Drush quickstart command?

The drush command is

drush site-install <profile>

as noted here in the quickstart documentation, you can use this to install a full drupal site using a specific profile from a single command, ex:

drush site-install onepagecv --db-url=mysql://[db_user]:[db_pass]@localhost/[db_name] --site-name=Example

This assumes you already have Drupal core downloaded and this profile in your profiles folder.


You could use the Disable Messages module for this. Here is a quote from its project page:

  Gives a site owner options to disable specific messages shown to end users. The core drupal message system as offered by drupal_set_message is an excellent way for modules to send out messages to the end users. However not all drupal site owners are keen to show all the messages sent out by drupal core and all modules to their users. This module gives site administrators a reasonably powerful way to filter out messages shown to the end users.

Some of its features are:

  Filter out messages that match a full text string exactly.
  Filter out messages that match a regular expression.
  Permissions to specifically hide all messages of a given type from any role.
  Disable all filtering for specific users.
  Disable all filtering for specific paths.
  Apply filtering only for specific paths.
  Debug system to get messages in the HTML without showing it to the end users.

Available for either Drupal 6 or Drupal 7 (and a DEV version for Drupal 8).


How can I fix, or troubleshoot, Fatal Error Class not found with XHProf Module

The backtrace what you see could be improved by adding the following settings in your xdebug.ini file:

; Data
xdebug.default_enable = 1           ; bool: The stacktraces will be shown by default on an error event.
xdebug.collect_vars = 1             ; bool: Gather information about which variables are used in a certain scope.
xdebug.show_local_vars=1            ; int: Generate stack dumps in error situations.
xdebug.collect_assignments=1        ; bool: Controls whether Xdebug should add variable assignments to function traces.
xdebug.collect_params=4             ; int1-4: Collect the parameters passed to functions when a function call is recorded.
xdebug.collect_return=1             ; bool: Write the return value of function calls to the trace files.
xdebug.var_display_max_children=256 ; int: Amount of array children and object's properties are shown.
xdebug.var_display_max_data=1024    ; int: Max string length that is shown when variables are displayed.
xdebug.var_display_max_depth=5      ; int: How many nested levels of array/object elements are displayed.
xdebug.show_mem_delta=0             ; int: Show the difference in memory usage between function calls.
xdebug.show_exception_trace=0       ; bool: Show a stack trace whenever an exception is raised.
xdebug.max_nesting_level=200        ; int: Controls the protection mechanism for infinite recursion protection.

This will give you more meaningful data.

Basically you're missing a class, so you should try to clear you caches and rebuild your registry. Also restart memcached/redis if it's in use.


How to transfer data from views-view-fields.tpl to views-view-unformatted.tpl in D7?

You should use $view->result variable.

do dsm($view->result) and see if you find what you where looking for.


Users, subusers, and assigning subuser to multiple users

There is a Subuser module to create subusers and a Profile2 module to create user profiles for every user.


Can hook_field_extra_fields be used with field collections?

The entity name for a Field Collection is actually field_collection_item and not field_collection (if you run var_dump(entity_get_info()) you'll see this).

This means your implementation should actually look as follows:

/**
 *  Implementation of hook_fields_extra_fields().
 */
function my_module_field_extra_fields() {
  $extra = array();

  $extra['field_collection_item']['my_field_collection']['display'] = array(
    'some_extra_field' => array(
      'label' => t('TESTING FIELD 123'),
      'description' => t('This is a test of hook_field_extra_fields on FCs'),
      'weight' => 100,
    ),
  );

  return $extra;
}

Also, dont forget your t()'s ;-)


In Drupal 7, how do you git clone a module project quickly?

Just use the format you say doesn't work. This is the correct format. The URL does matter. (Do not use the format that produces the error.)

I.e. to clone branch 7.x-1.x of tb_megamenu, you should use:

git clone --branch 7.x-1.x http://git.drupal.org/project/tb_megamenu.git

You may skip the --branch option and branch identifier when cloning.  This will clone the current HEAD, which may (or may not) be the head of the branch you want.


You can add the needed configuration files of the content types and fields needed for the site in a folder named config/install in your theme directory. These configuration gets imported when we install it.

for eg: if you want to create a content type test when your theme is installed

Create a file node.type.test.yml in your_theme/config/install folder paste the code in it

langcode: en
status: true
dependencies:
  module:
    - menu_ui
third_party_settings:
  menu_ui:
    available_menus:
      - main
    parent: 'main:'
name: test
type: test
description: ''
help: ''
new_revision: true
preview_mode: 1
display_submitted: true

Easy method is to

create the content types and fields form backend
export the configuration
Take the newly created files from it and remove the line uuid from it
paste it in your theme folder


thanks to 4k4 comment, i have made it working

/**
 * Setting 40x template suggestions
 */
function amu_http_status_code_display_theme_suggestions_page(array $variables)
{
  $path_args = explode('/', trim(\Drupal::service('path.current')->getPath(), '/'));
  $suggestions = theme_get_suggestions($path_args, 'page');
  //mapping the route with its suggestion hook
  $http_error_suggestions = [
    'system.403' => 'page__403',
    'system.404' => 'page__404',
  ];
  $route_name = \Drupal::routeMatch()->getRouteName();
  if (isset($http_error_suggestions[$route_name])) {

    $suggestions[] = $http_error_suggestions[$route_name];
  }

  return $suggestions;
}

/*
 *
 * make drupal knows the templates are located in the module
 *
 * */
function amu_http_status_code_display_theme($existing, $type, $theme, $path) {

  $arguments403= array(
    'template' => 'page--403',
    'base hook' => 'page',
  );

  $arguments404= array(
    'template' => 'page--404',
    'base hook' => 'page',
  );

  //mapping the hook with its template
  return array(
    'page__403' =>  $arguments403,
    'page__404' =>  $arguments404,

  );
}


Using Acquia for a production site and running Wordpress concurrently

Acquia Installer is just an *AMP package. It installs standard versions of Apache, MySQL, and PHP, so you can configure Apache for multiple vhosts just as you would on any other machine.

Here's a guide to setting up vhosts on drupal.org http://drupal.org/node/111238

If you are deploying to IIS, I'd suggest at least testing your site locally before you push to live. These links may be of help:

http://learn.iis.net/page.aspx/505/install-drupal-on-iis/
http://www.microsoft.com/web/downloads/platform.aspx

The second is a Microsoft IIS installer with native Drupal support. MS are supporting Drupal as part of their Windows 8 push, so there are more resources around for IIS as a platform than previously.


Quick question: horizontal align taxonomy @ node/add?

You would do that with pure CSS. In your example you would assign a float:left to your fieldgroups.


How to get the view fields in rows in the word document generated using Views data export module?

As an alternative to using the Views data export module, you may want to use the Forena module (disclosure: I'm a co-maintainer of it) to create a "report" that includes the data that you're interesting in (i.e. the "content" as in your question). As part of the report design, indicate which export formats you want to allow for exporting the data included in it. DOC (for MS Word) is one of the typical formats that are supported (apart from CSV,  XML, HTML, etc). By using Forena, the layout of the exported table (in your MS Word doc) would not  be "coming out in columns rather than rows" (as in your question).

Have a look at the Simple Table of States example, and think of it as the equivalent of your "posts that you want to export". And note the hyperlinks in the upper right, which are:

CSV.
XLS.
HTML.
XML.

Try any of these links to get the equivalent of the extracted information, but in the format you requested (there or other supported formats such as PDF, DOC, JSON, etc).

Checkout Forena's Community Documentation for (way) more details, and/or the documentation that comes with the module.

Forena versus Views

Forena can be used together with the Views module, or as an alternative to it, more specifically:

As an alternative to Views, to create reports (and derivatives such as charts and/or exports of data) which you cannot, or not easily, create with only Views. E.g. to pivot data, where you want to create tables in the format of what in Forena is called "Render a report in FrxCrosstab format".
Integrated with Views, as explained in the Forena tutorial pages, i.e.:

  Using the Forena integration with the Views module, it is possible to use Forena reports as a views row style, so that in a view you can use the Forena templating engine to do the formatting. Although this can be done through the views templating engine Forena users may find they have more control with this engine.


Point me in the direction of developing new forum features?

In order to create a forum in drupal, you can start with the forum module. It is a core module, so it will already be installed. The following steps can make forum development simpler:

Enable the module-

Go ahead and navigate to Site Building>>Modules and check the box next to forums to enable the module.

Set up containers-

you need to navigate to administer >> forums to start setting up your new forum

Set up forums-

Each container "contains" several forums. In other words, your
containers are children of the root node and your forums are children of
your containers

Customize your forum for adding content or ideas-

The following modules can be used for content entry:

BUEditor or wysiwyg
Live
Quote
Smileys
Signatures for Forums
Comment Upload

In order to add the voting/rating features, use the following:

VotingAPI
Rate

Advanced Forum may also be used if you wish to enhance Drupal's core forum module features.


How to properly attach a library to CheckoutPaneForm

As usual, I was messing something up.  JS libraries need : {}.  Updating commerce_paypal.libraries.yml to this solves it:

paypal.checkout:
  remote: https://www.paypalobjects.com/api/checkout.js
  license:
    name: MIT
    gpl-compatible: true
  js:
    https://www.paypalobjects.com/api/checkout.js: {}
express-checkout:
  js:
    js/paypal_ec.js: {}
  dependencies:
    - commerce_paypal/paypal.checkout


How to create a theme function for custom HTML markup and then call it in my node template?

You should be able to use the template_preprocess_node function to move your logic from your tpl files into the theme function. In order to use the function, replace template with the name of your theme.

function mytheme_preprocess_node(&variables){
  if($variables['node']->type == 'my_content_type'){
    //change what you want to the node here.
  }
}

You could do the logic you need to inside this functionn, save the output to a variable in $variable (it's a reference var, so it dosn't need to be returned) and then just print out that variable in your tpl.php file.


review permissions in the /sites/all/files directory. you can test inside files directory, changing permissions to test the correct permissions. for example you, for test, can change to 755 in recursive mode: chmod 755 files/ -R. also review the owner of directory. According my experience, the owner can be a cause.

(According I remember, permission 777 number is the most higher number, but not is recommended).


Redirect a Users Name (Link) to a User Homepage in Panels Using Rules

So, you want to make the username link to a different page?

You can do that by overriding theme_username e.g, in template.php

You could also use hook_preprocess_username for the theme preprocess function and also change the entity_uri for the user entity, though the first option is probably simplest.


This can be done with https://drupal.org/project/entityreference_prepopulate.

You should create registrationlinks like this for it to work auto: /user/register?og_user_node=X where X is the groupid.


Migrate old admin's posts to his new user

Node data is stored in node table also.. It's a bad practice to change node content directly using sql queries...

You can use Views Bulk Operations (VBO) module to change node authors in bulk...

  This module augments Views by allowing bulk operations to be executed
  on the displayed rows. It does so by showing a checkbox in front of
  each node, and adding a select box containing operations that can be
  applied. Drupal Core or Rules actions can be used.


Get node author's real name in views or convert username

If you don't use any special modules and you have simply added fields to the user acount (on /admin/config/people/accounts/fields then you should be able to add those fields in the Views UI. Just like you do it with all other fields, except that you use the author relationship that you have already created.


Programmatically get exposed filters from view

I think everything is fine. You have to load the taxonomy term names manually like:

\Drupal\taxonomy\Entity\TaxonomyTerm::load($ids)

Or maybe you can do a custom query to load only the taxonomy term titles without any field data (because that is what you need).


How do you change the URL alias of a contact form?

I went under Configuration --> URL Aliases, and added a new alias for /contact-us that points to /contact/contact_us

I expected the result to be that anyone typing in /contact-us would end up at /contact/contact_us, but instead the opposite is happening. Anyone typing in /contact/contact_us is now redirected to /contact-us and the page is shown there.

This is a little different from how Drupal 7 works, but this is the answer I needed.


Pass value into a view using block input

Not answering directly, because I don't know if you could do this with a configurable Views block without custom code.
A different approach only using UI would be on entity level, creating a block type containing two fields, the taxonomy drop-down and an EVA field passing the other field's value via a token. The site admin has then to use the Custom Block Library to create a custom block for this block type.
Add the EVA field to the block type with this module: https://www.drupal.org/project/eva


I think that if your feature set variables or configurations that are already stored on db, you have to revert it. instead this does not happen for "new" configurations.


How can I create a view which includes all parent terms of a taxonomy term?

I guess you can't do it directly in views. You can use "Contextual filter: Taxonomy term: Term ID" and write small php code by selecting "Provide default value".

Here is the code you can use:

$parent_terms_string = '';
$current_tid = 3; //The term ID of whose all parents you want to fetch.
$parent_terms_tid_array = array();
$parent_terms_array = taxonomy_get_parents_all($current_tid);
foreach($parent_terms_array as $term){
  if($current_tid != $term->tid){
    $parent_terms_tid_array[] = $term->tid;
  }
}
$parent_terms_string = implode('+',  $parent_terms_tid_array);
return $parent_terms_string;


How do I apply cufon.js only for Internet Explorer, in template.php?

You can't apply JS only to one browser using Drupal functions. What you can do is:

CSS workaround:

apply CSS only to IE
assign some style that will not be visible, but also will not be present in non-IE, like white 1px border on white background
use css() jQuery method to test if element has property you expect it to have in IE, and if true, execute your code.

JavaScript way:
Use jQuery Browser Plugin or similar solution to identify browser inside your js file. Execute your code if it's the browser you need it executed in.


Use hook_cron, and implement your functionality in it. This functionality will get executed when the server will ping cron.php.

You just need to set specific time period on which cron will be executed.


Link to a different view mode from entity reference

a link: /some/somthing/here is just a link. It resolves to a resource on Drupal (see hook_menu).

A node by default lives at the url node/NID which shows the full view mode. You need Views, a Context, a Panel -- and a different url then node/NID to show a different view mode.

So yes ... you can make a different url to show a teaser. How you make the url is up to you.


Is there a module or configuration that logs PHP mail errors?

Have a look at maillog and Mail Logger. They both log all mail activity handled via drupal_mail. See what they have to offer as far as mail errors go.


Your first assumption was right. The taxonomy items should be for categories and the products should be nodes to type product.

It looks like this is not as simple to setup for D6 where you could use

[term-raw]/[title-raw]

This comment on drupal.org has some helpful suggestions

Download Entity API
enable entity and entity tokens
Setup a path something like [node:field-category:name]/[node:title]