Can't locate where Commerce Authnet stores the API and Key

I'm assuming you're using the latest version of Commerce authnet.

Drupal Commerce payment system (as well as discounts, taxes..) is based in rules, you can see here how the settings form are included: http://cgit.drupalcode.org/commerce/tree/modules/payment/commerce_payment.rules.inc#n250 in the rules UI, so it is basically stored by rules in a rules_config object, specifically in the unserialized data column.

So if you want to see the settings in the database, you can go to rules_config table and check the data db field.

Modifying this from outside rules is another story, I've never done this, but I'm quite sure that rules doesn't provide an API to alter this data field, you'll probably need to use the Database API to access rules_config table and unserialize/serialize the data information to alter it.

It is probably advisable to find an alternative way to do this, i.e providing a new module that runs a slightly modified version of the charge callback of authnet (http://cgit.drupalcode.org/commerce_authnet/tree/commerce_authnet.module#n750)


Updating field in external Drupal database

I have achieved the similar functionality with following code. I worked on Drupal 6. But, hopefully it worked for you.

I have two same drupal installation and when creating new node in one installation, I need to create node into another Drupal installation also. So, I customize the node form and added a submit function to node form.

Custom Submit function

function custom_node_export_form_submit($form, $form_state) {

  //Creating node object
  $node = new stdClass;

  foreach ($form_state['values'] as $key => $value) {
    $node->$key = $value;
  }

  db_set_active('domain');

  node_save($node);

  db_set_active('default');

}


how to value from one view to another view filter in drupal

One way to do it is to create a jumpmenu in your view's template and add it to the page that way instead of trying to do it with filters.

So in your view's Advanced tab, click on "theming" option, and a dialog box will open with your view's template name. Copy the views.tpl from the views module to your theme and name it that template name. Inside this template you can now find the place you want to output this jumpmenu and add the tax_terms code you have above. Only instead of outputting the options as a form field, convert them to links using JS here's one example. Or you can also create the jumpmenu as ctools like here.


How to implement a Views 3 exposed filter in block as a list of links, and update the view via ajax?

Try this patch: https://drupal.org/node/1268150#comment-7393486, it's for better exposed filters and it's to make it work with AJAX.

As for the default views select element, try using an argument.


Ajax User login failing with "Username field is required", "Password field is required"

It looks like user_login_submit doesn't work well when called as an AJAX callback. The error you receive is because Drupal tries to create a session for the user that should be logged in, but no values for uid is present, which is required.

I believe that Drupal will call the form submit hooks when the form is submitted by ajax, so you might be able to simply add an empty callback function.

Alternatively you will need to call the form submit functions yourself, which should fix the problem.


How can publishers create hierarchical taxonomy terms during node creation?

The Hierachical Select Module allows you to enable on the fly term addition into an ordered taxonomy.

It's unfortunately under minimal developent, but is available for D7 and gets the job done. If there are better options, pleaese let me know, but I think this should handle the above use case for now.


How to translate Global:PHP in the view?

Try by using your text inside t().

t('your text to display'); or t($string);


Views, Panels are your friend.

https://drupal.org/project/panels

You can also go with Omega Context and Delta

https://drupal.org/project/omega

https://drupal.org/project/context

https://drupal.org/project/delta

There are many ways to Rome....


How to disable htmlspecialchars in custom module form table?

You can use FormattableMarkup

Here's a simple example to get you started

use Drupal\Component\Render\FormattableMarkup; // place this at top of file

$options = [
  1 => ['foo' => 'Foo'],
  2 => ['foo' => 'Bar'],
  3 => ['foo' => new FormattableMarkup('I am a link', [])],
];

$header = [
  'foo' => t('Foo bar')
];

$form['table'] = [
  '#type' => 'tableselect',
  '#title' => t('Foo bar table'),
  '#header' => $header,
  '#options' => $options,
  '#empty' => t('No foos found.'),
];

So in your case $this->getOutput() may return something like (this is untested):

['vehicleName' =>  new FormattableMarkup(
  '@name',
  ['@id' => $vehicle->vehicleId, '@name' => $vehicle->vehicleName]
)]


I suppose you want to show a message after submitting the form. (But as Pierre commented, please be clear in what you want and do not make us assume things.) hook_form_alter() works during the building of the form. Your code probably works, but there is no message generated yet.

Instead, use hook_form_alter to add a new submit callback and place your code in there. Somewhat like this:

function alter_appointment_message_form_node_form_alter(&$form,&$form_state,$form_id)
{
  $form['#submit'][] = 'alter_appointment_message_post_submit';
}

/**
 * Custom submit callback.
 */
function alter_appointment_message_post_submit($form, &$form_state) {
 if($form['#node']->type == "appointment_request") {
   drupal_get_messages('status'); // Flush default simplenews status message
   drupal_set_message(t('An appointment has been requested'), 'status');
 }
}


Assign textfield to each checked option in a checkboxes field

The conditional fields module should be suitable for this

  Conditional Fields allows you to manage sets of dependencies between
  fields. When a field is “dependent”, it will only be available for
  editing and displayed if the state of the “dependee” field matches the
  right condition.


Uninstall and then do a fresh start.

jQuery update won't break any of your existing code by uninstalling.


Both LABjs and HeadJS are recent modules, actively developed by professional Drupal developers, both are offering versions for Drupal6 and 7 and both have less than 100 installations (see statistics).

Also both are aware of each other modules and collaborate together, see

Because they are so recent modules and you can't know how well they will be supported later in the future, I would  base my decision on which JS library fits your needs. Probably I would trust more on LABjs, that is much more tested and used (twitter, vimeo, etc are using it), plus it's a library focused in JavaScript loading, nothing else.

HeadJs library in the other hand also is offering other features: detecting CSS3 features, detecting screen resolution, etc something that can be good or not, depending what you are looking for. And also HeadJS is better integrated in the Drupal ecosystem: integration with Boost, CDN, Advagg modules.

If you are interested in this topic, I would recommend you a must read blog post from the author of LabJS to get a inside view of the technology under these JavaScript loaders (LABjs, HeadJS, ControlJS from Steve Souders, etc )


Is there a module to conditionally set a fields value depending another field?

No other module available apart from conditional field, you need to create your own module with hook form_alter() and use some code like

<?php
function wishlist_status_form($form_state) {
$form['status'] = array(
    '#type' => 'textfield',
    '#title' => 'Status',
    '#suffix' => '

',
  );

$form['ajax-submit'] = array(
    '#type' => 'submit',
    '#ajax' => array(
        'callback' => 'wishlist_status_change',
        'wrapper' => 'my-wrapper',
    ),
    '#value' => t('Save'),
  );
return $form;
}

function wishlist_status_change($form, $form_state) {
    dpm($form_state, 'state callback');
    return 'test';
}
?>


Conditionaly display fields of another node on a node page

At first you need to make a relation between Product and Company . to do that you have to install a reference module , Entity References or References .
After enabling the module (No different which one you install) you need to modify your product content type , remove your company field and add a new field of type reference to a node , then refer it to your Content type Company .

till now you have made a relation between Product and Company , now to do the rest of the job you can use Panels and Page Manager (included in CTools) .

Check this tutorial if you are not familiar with panels : Learning Panels and Page Manger


Responsive Images Not Scaled-Down Properly in Omega Theme just on Firefox

What kind of Mac are you using? For example, I have a Retina Mac. Firefox doesn't support Retina displays, so things generally look fuzzier in Firefox than say Chrome.

Also, if the responsiveness is aimed towards mobile devices, wouldn't it be better to test on those? You probably won't have a user with a desktop window of 600px wide. ;)


Workbench Moderation - Admin Preview - Show Current Revision in Front-End

It sounds like you want Page Preview.

  Page Preview is a low-impact alternative to Drupal's core node preview
  functionality.

  Why would I need this?

  Drupal's regular node add/edit form provides a "Preview" button that
  allows you to see what your node content will look like after all of
  the input filters are applied, without having to first save the node.
  However, it doesn't allow you to see what the entire node will look
  like within the context of a fully rendered page


Use multiple data blocks in the same chart created using forena reports

Using data contexts

This question is a (great) example of using "Data contexts" in Forena. To see an example of a "data context" at work (in a demo site), refer to the example about Master Summary with drill down. If in the report you click any of the linked columns (such as for state = VA), you'll get the Users in state Virginia report. In that report you should note these things:

... in state Virginia (in the report title).
... state with code = VA (near the top of the report).

If in the above example you pick another state, such as IL (Illinois), you'll get the report specific to that state.

Read more about "Data Contexts" in the Forena documentation, which you can also find in your own site within /reports/help.reportingfrx#datacontexts (after you installed Forena).

Below are some details about what's needed in this specific case (to use the user's country as your chart tile), based on these assumptions:

The user's country is contained in stored in a datablock named (say) "pec_reports/data_block2", within a column (say) "UserCountry".
The user's country is (say) "XYZ".
You want your chart title to be like (say) "Chart for country XYZ".

Based on these assumptions, this is what you should do:

Add a data context to the document in the  section of the document, which are preloaded before the report is rendered. The example below illustrates the syntax for preloading data in the head section:

<head>
  ..
  <frx:data id="countryinfo" block="pec_reports/data_block2"/>
</head>

Any data from any other section of a report may be used by referencing the datablock by its id and appropriate column name of that datablock. The example below contains an example of referencing the UserCountry column contained in pec_reports/data_block2:

<div> ... {countryinfo.UserCountry} ... </div>

The syntax for such reference is like so:

"Id" of the datablock, followed by a ".", and followed by the "ColumnName".
Preceeded by a "{" and followed by "}".

Same is true for any of the tags used to specify the details of the chart you want to create. So in this case you could use something like so:

frx:graph_title="{countryinfo.UserCountry}"

Ensure your SQL returns the correct value(s)

If you get a blank chart title after applying the changes as I suggested above, then most probably that is because the value of that chart title is blank. Looking at the SQL statement for your pec_reports/data_block2, here are a few tips to further verify (debug?) the actual SQL statement you're using:

Create a temporary (for debugging purposes only) tabular report using that same pec_reports/data_block2 data block, and run that report while logged in. Or as a variation, add that tabular report in your report with the chart, but in front of that chart. Do you get the expected "country" value for that user? I wouldn't be surprised if you get an empty output (which would confirm something is wrong in your SQL statement, and hence also explain your blank chart title). In that case continue with step "2." and/or "3." below.
In your from clause, change users to {users}, and rerun your temporary report in step 1.
In your where clause, change current_user to the value of the uid of your own user, and rerun your temporary report in step 1.

If none of the above seems to help, then I would use either (or both) of these other routes:

Have a look at the data blocks (SQL statements) related to the Drupal Administration reports that are delivered with Forena also, such as:

Active Users
Logs for User
Role Details

Use the query writing tool that comes with Forena, which is called the Forena Query Builder. This is a separated module that comes with Forena. It can be enabled as per standard Drupal instructions to enable an additional module. For a video tutorial about this query writing tool, checkout Define data blocks with optional filters.


You want to use the Scanner module:

  Versions 5.x-2, 6.x, and 7.x of Search and Replace Scanner can do
  plain text search-and-replace, or regular expression
  search-and-replace, against the title, body and text content fields on
  all nodes in your system. This is useful for finding html strings that
  Drupal's normal search will ignore. The module is very handy if you
  are fixing typos in a lot of content, changing the name of your
  company, or are changing the URL of a link included multiple times in
  multiple nodes, among other things.


Programmatically schedule the execution of a component

I know this is an older post, but I had the same problem, and found this post. I found the answer so maybe someone can use it later:

$state = new RulesState();
$state->addVariable('variable_name', $variable, array());
// 3rd parameter is called $info it must be an array, but i don't know it's function

$task = array(
'identifier' => 'unique_id_of_scheduled_task',
'date' => time(), // timestamp
'config' => 'id_of_the_rule_component_to_run',
'state' => $state,
);

rules_scheduler_schedule_task($task);

So you have to create a RulesState object and pass in that in place of the 'state' parameter.
I had to do this because in Rules I couldn't get the timestamp I wanted when I was configuring the "Schedule component evaluation" action.


On editing view, click the advanced settings then click relationships area, click Add.

There are many tables you can join to the content listing. In this case, search for "author" options, and select Content: Content author. Click Apply. Now add field 'user' in view also set filter criteria as needed.


Hide conditionally hidden fields from custom node template

Based on the comments:

generic template works, but custom does not

custom template overrides visibility rules

I would surmise that the problem is with the visibility, since the conditional field is likely only hidden, and not actually being removed - this would cause the code to execute every time, while in a standard render() it would remain hidden
Using Devel and specifically the dpm() function, I would find the element in the field array that manages the visibility of the field and use that as the basis for the if statement.

A suite of modules containing fun for module developers and themers


Load Javascript Conditionally Based on Form Value

You applied this code for all forms on your site, but only webform has $form['submitted'] element. To fix this issue you may use next code snippet

<?php
/**
 * Implements hook_form_alter().
 */
 function module_name_form_alter(&$form, $form_state, $form_id) {
   if (!empty($form['submitted'])) {
     if ($form['submitted']['formtype']['#default_value'] == 'type1'){
       drupal_add_js($js_path . 'type1.js');
     }
     else if ($form['submitted']['formtype']['#default_value'] == 'type2'){
       drupal_add_js($js_path . 'type2.js');
     }
  }
}
?>


How to bypass required fields in form validation function of a module?

If you are building your own form, you need to remove '#required' => TRUE, from field to bypass validation or assign FALSE value.

Example with required field:

$form['title'] = array(
  '#type' => 'textfield',
  '#title' => t('Subject'),
  '#default_value' => 'whatever',
  '#size' => 60,
  '#required' => TRUE, // remove this if you want to bypass or give it FALSE value
);

Check Form API Reference for more details

Now you can do the same for existing form by alter the form using hook_alter_form and unset required attribute or assign FALSE value.

Example:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'FORM_ID') {
    $form['FIELD_NAME']['#required'] = FALSE;
    // or
    unset($form['FIELD_NAME']['#required']);
  }
}


For a customer database table, do I have other options, beside creating a custom module?

Since you already have a module, I would rather not convert all the data in nodes.
I would not use nodes to store arbitrary data, since that is not the purpose of nodes, especially when I don't need to show all the data I store, or when I show a table with a pager only to the users with a specific permission. Nodes are by default readable by every registered user; making them visible only to users with a specific permission is not hard, but requires extra modules, and changing configuration.

With Drupal 8, there are few alternatives, but a custom database table is the easier solution, especially if you don't want to write migration code.

If the data is linked to user accounts (which means, that person field is a username or the user ID), you could use the user.data service.
That service, though, loads all the data for the specified user ID, module, and key. You cannot tell to the service to load just the first, or the last, N records, for the fact the service doesn't have a concept of record. You could assign the data to different keys (for example, a key for June, one for July, etc), but that means making the code more complex.
If the data is only pertinent to a site, and you don't want to export it to other sites, you could use the state service, but this still load all the data associated to a key (not module, user ID, and key) at once. The workaround is the same for the user.data module, with the same cons.
If the data needs to be exportable to different sites, you could use the configuration API, but with much data, it's probable you would get some performance issues. (Yet, creating different, but related, records is not that immediate.)
You could create a configuration entity for your data. In Drupal 8, configurations entities are used for user roles, content types, image styles, and much more.

The first three methods I described would not allow you to easily search for data as a SQL query would. The last one would allows you to get data using an API similar to the one used to query data from a database table.

If I wanted to quickly convert the code to Drupal 8, I would rather use the database approach I was using for Drupal 7. In that way, the data stored in the custom database table won't need any conversion when updating the site to Drupal 8, and you could easily control the users who access the data using a custom permission (in the same way you would do in Drupal 7).

If I wanted to make the code more "Drupal 8 code," I would use configuration entities. It requires to write code to migrate the data, but it's worth the effort.


Caching a variable for a fixed amount of time

yes there is a native function cache_set

<?php
cache_set('my_module_data', $my_data, 'cache', time() + 360);
?>

here is a great tutorial about caching in drupal


Drupal 8, use "query api" with "collection fields" (not via FieldCollectionItem::load)

Try to query the fields of the FieldCollectionItem with .entity:

 $user_ids = \Drupal::entityQuery('user')
    ->condition('houses.entity.house_size', 4)
    ->execute();


If you are looking to Migrate D6 Content (Nodes) to D7 system then you can use Drupal-to-Drupal data migration module.

Project page says

  migrate_d2d provides a framework based on the Migrate API for
  migrating content from Drupal 5, Drupal 6, or Drupal 7 sites into the
  Drupal 7 site where it is installed.


Small problem with Facebook Autopost module / Facebook App

I managed to fix this by setting appropriate permissions for each role under /admin/config/services/fbpermissions


The Secure Site module could be the best choice:

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

You can change the settings to use a page instead the popup. It's also possible to theme the login page - see the information here.


How to enable / disable a module in settings.local.php

I don't know if it is possible to enable / disable modules in settings.local.php but for downloading and enabling modules you can use drush, like so:

drush dl views
drush en views -y

For disabling the modules use:

drush dis views -y

Another method is to implement hook_update() in a custom module's module file to disable / enable modules.

/**
* Uninstall views module.
*/
function MODULENAME_update_7000(&$sandbox) {
   module_disable(array('views'));
   drupal_uninstall_modules(array('views'), FALSE);
}

Of cource you can also use module_enable in the hook_update()

/**
* Install views module.
*/
function MODULENAME_update_7001(&$sandbox) {
   module_enable(array('views'));
}

If you use hook_update then remember to do:

drush updb

and

drush cr

Hope this can help you.


how to get this functionality? views: Format options in ctool modal modify field data

You may use Display Suite module

  Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files. A predefined list of layouts (D7 only) is available for even more drag and drop fun!


How to display programmaticaly default user picture?

Its very straight forward. If you want to add a default picture then go ahead and add the picture from the admin page as the other answer suggested. Programmatically,
The default picture is loaded via the variable user_picture_default.
So you can do,

$user = user_load($uid);
print theme('image_style', array('path' => $user->picture->uri, 'style_name' => '<image-style>'));

if (!empty($user->picture)) {
  print theme('image_style', array('path' => $user->picture->uri, 'style_name' => 'CUSTOM_STYLE'));
}
else {
  $custom_default_image_path = 'public://default_image.png';
  print theme('image_style', array('path' => variable_get('user_picture_default', $custom_default_image_path), 'style_name' => 'CUSTOM_STYLE'));
}

However, you can also make the default image theme dependent/independent via the hook


How can I switch menus after a user logs in

You might do that with a simple block, rather than creating a menu, preprocess it to add the word between and check if the user is logged in.

Simply select anonymous/authenticated user under the "Roles" in block visibility settings.


How the handle an override of the schema of a field type

You have to write an update function that changes those fields live in your database so they match the new definition.
Time ago, this was done using the drush entity-updates command. However, this was dangerous in some circumstances. You can check the Support for automatic entity updates has been removed change record to get more information on this.
In this change record you can see:

Starting with 8.7.0, Drupal core no longer provides support for
automatic entity updates. Whenever an entity type or field storage
definition needs to be created, changed or deleted, it has to be done
with an explicit update function as provided by the Update API, and
using the API provided by the entity definition update manager.

Therefore, you need an update function. Probably, you should read the "Updating Database Schema and/or Data in Drupal 8" page, specially the "Adding a new column" section:

Here's an example of what to put into your hook_update_N() function to
add a new column to an existing database table:
  $spec = [
    'type' => 'varchar',
    'description' => "New Col",
    'length' => 20,
    'not null' => FALSE,
  ];
 $schema = Database::getConnection()->schema();
 $schema->addField('mytable1', 'newcol', $spec);

Devel Entity Updates module
As pointed out by @Ales, you may try the Devel Entity Updates module:

This command should be able to fully replace the legacy drush entup or
drush entity-updates commands.

However, this module is not meant to be used in production environments, see the following disclaimer from the module:

The goal of this module is to have a quick way to apply schema updates
while developing new entity types and ending up incrementally
adding/removing/changing entity type/field definitions.
When these changes are part of an official release (and not in the
scope of a code development session), they should absolutely rely on
DB update functions, as explained in the CR above, because that's the
only way the entity schema update process can be predictable and
reliable.

So, this approach is ok for you if don't have a production environment yet. Of course, you can ignore the warning and install the module on prod, but keep in mind that you may lose data because the operation is not safe.
You can try it on a test environment, and if you finally take the risk and use in prod make sure you have a recent backup at hand.
Why you need this
The problem you have a difference between the table data definition in code and the actual data tables in your database. Why does this happen? There are different circumstances that can lead to this. In your case, the State module has some data definitions that are applied when the module is installed. At this point, code data definition and actual data tables are matching. However, if you make any changes on the code that defines the data tables the problem arises: you have one definition on code and different actual data tables in the database.
So what you need to do is modify the tables to match the data definition. That's what my answer tries to explain. The two methods are writing an update function (so you control with that function how to modify the actual tables) or trust an automatic method (the entity update command). The command is easy but it has no brain so it just modifies the tables without thinking on possible issues. That's why you may have problems (data loss, mainly) using that command.


Which module should I use to manage translations in D7?

Excerpt from the Translation Management project page:

... provides complete workflow management for multilingual Drupal sites.
Content managers can manage all translations from one central page. The module shows which contents need translation and notifies translators about what they need to do.

Be aware however that this is a D6-only module, not at all suited for a D7 site.
For D7 there are basically 2 alternatives available:

Translation Overview, mentioned as a recommended add-on on the i18n project page also. From its project page:

... provides a table listing the site's nodes and showing what's been translated into each language. It also lets you assign priorities for translating nodes into the various languages.

Translation Management Tool, considered as the successor of the previous module, and "the" module to move forward with in D8 also. From its project page:

... provides a tool set for translating content from different sources. The translation can be done by people or translation services of all kinds. It builds on and uses existing language tools and data structures in Drupal and can be used in automated workflow scenarios.
This module does not make i18n or any other language module for Drupal obsolete. It does only facilitate the translation process.


How can you filter an integer column by "Starts with"?

You can do this with a combine fields filter.

You first need to include the field you want to filter on.
Once the field is in you add the filter combine fields filter and set it to exposed.
Change the operator to "begins with" and select the integer field.

Save the changes and you should have the filtering option with the begins with option on an iteger field.


You can solve above problem using Views PHP module.

  This module allows the admin account (user 1) to add fields, filters
  and sorts to views which use PHP code. It also supports additional
  accounts when the core PHP Filter module is enabled.

All you need to do is create a filter Global PHP and below code in the php filter. It's highly recommended that you include this within a module rather than directly in views. If it breaks it could be difficult to recover from.

function yourmodule_exclude_front($data) {
  if (!empty($data)) {
    $front_url = variable_get('site_frontpage');
    $url_parts = explode("/", $front_url);
    if (($url_parts[0] == 'node') && ($url_parts[1] == $data->nid)) {
     return TRUE; //Exclude the node
    }
  }
  return FALSE;
}

Then within your view php filter you would do something like:

 if (module_exists('yourmodule')) {
   return yourmodule_exclude_front($data);
 }

Exported view code below (not including module code from above, but inline code)

$view = new view();
$view->name = 'front_view_node';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Front View Node';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Front View Node';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Global: PHP */
$handler->display->display_options['filters']['php']['id'] = 'php';
$handler->display->display_options['filters']['php']['table'] = 'views';
$handler->display->display_options['filters']['php']['field'] = 'php';
$handler->display->display_options['filters']['php']['use_php_setup'] = 0;
$handler->display->display_options['filters']['php']['php_filter'] = '$front_url = variable_get(\'site_frontpage\');
$url_parts = explode("/", $front_url);
if ($url_parts[0] == \'node\' && $url_parts[1] == $data->nid) {
  return FALSE;
}
else {
  return TRUE;
}';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'front-view-node';


Superfish Menu links disappear on iOS (only if they have dropdown menus)

Enough tinkering and I found a solution. I'm not sure WHY it works, but it does.

During my experiments, I wondered if the z-index was the problem and if it was getting covered by something, so I cranked the z-index up to 10000 but that still didn't solve it.

I eventually discovered the position: relative thing I mentioned above. So I opened up the Computed Style box and toggled the position: relative rule on and off, on and off, which would break it, fix it, break it, fix it. Then I looked in the Computed values to see if anything else changed. Sure enough, the z-index changed. When it was in the working state the computed z-index was auto, so I created a css rule to explicitly set z-index to auto for those elements and viola... it's working.

Hopefully this will be helpful to someone else.


What is the equivalent of hook_property_info_alter()?

I suppose you want hook_entity_base_field_info(). By using a computed field based on a class, you can get a behavior similar to properties.

function hook_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
  if ($entity_type->id() == 'node') {
    $fields = [];
    $fields['mymodule_text'] = BaseFieldDefinition::create('string')
      ->setLabel(t('The text'))
      ->setDescription(t('A text property added by mymodule.'))
      ->setComputed(TRUE)
      ->setClass('\Drupal\mymodule\EntityComputedText');

    return $fields;
  }
}

I have copied a snippet from Drupal commerce, where a payment gateway reference is appended to a commerce_order entity (commerce_payment module altering an entity from commerce_order module).

/**
 * Implements hook_entity_base_field_info().
 */
function commerce_payment_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'commerce_order') {
    $fields['payment_gateway'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Payment gateway'))
      ->setDescription(t('The payment gateway.'))
      ->setRequired(TRUE)
      ->setSetting('target_type', 'commerce_payment_gateway');

    $fields['payment_method'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Payment method'))
      ->setDescription(t('The payment method.'))
      ->setRequired(TRUE)
      ->setSetting('target_type', 'commerce_payment_method');

    return $fields;
  }
}

By using ->setReadOnly(TRUE); or ->setComputed(TRUE), you can probably hide them from regular forms, making them behave like properties.


How to set default value for taxonomy autocomplete field?

Load taxonomy term using term id then, generate data in your required format.

 // Term id.
 $tid = 8193;
 // Obtain the term.
 $term = taxonomy_term_load($tid);
 // Format data.
 $data = $term->name . '[tid:' . $tid .']';

$form['field_school_locality_city_level'][LANGUAGE_NONE]['names']['#default_value'] = $data;


Ok it seems I'm implementing it wrong.
The SoapServer::handle() source code shows why:

 if (SG(request_info).request_method &&
        strcmp(SG(request_info).request_method, "GET") == 0 &&
        SG(request_info).query_string &&stricmp(SG(request_info).query_string, "wsdl") == 0) {.....

the Get parameter must be wsdl, which Drupal rewrites.
Also in essence using the SoapServer drupal module you get around this.
references to implement this properly:

example
More info
Soap server module


Create page with different content types

Yes, you can use Node Reference field on the "Client" content type. So you can reference from this node to another node like the Client Information which belongs to this Client.

To show all information at once, you can set the Node Reference field on "Manage Display" to render the full node.


How to merge two different vocabulary in one auto-complete text-field?

You can do it using Entity Reference module. You can able to reference multiple vocabulary terms using this module.

See the screenshot of field settings of field type "Entity Reference" and Widget types "Auto-complete (Tags Style)"


How do I get each taxonomy term associated to a node?

Don’t convert the node to an array, use the node object itself. Then methods will work.

// top of file...
use Drupal\node\NodeInterface;

function custom_preprocess_html(&$variables) {
  $node = \Drupal::routeMatch()->getParameter('node');

  if ($node instanceof NodeInterface) {
    $type = $node->getType();
    $id = $node->id();
    $terms = $node->get('field_yourfield')->referencedEntities();
    // code here for $terms...

    $body_classes[] = 'node-' . $id;
    $body_classes[] = $type;
    // ... etc ...
  }
}

I assume type is node type.. but this is where you want to be. $terms should be a list of Term objects, so you can iterate and grab whatever data you need.

You should also check that the node type is the correct one before doing anything as well as checking for existence of the field to avoid errors.


The node access control methods between Drupal 7 and Drupal 8 are largely the same and described in Node access rights.  There are still the same hooks, just some of the plumbing is different.

So, if you want to implement the Drupal 6 fine grained access in Drupal 8, you can either do hook_node_access() or proper grants.  Remember, node usage can exist in case other than the node pages (eg, lists); the node access system takes care of this.  Work has begun on the ACL module and dependencies which provide some abstractions for these.

Drupal 8 also has a new concept for route access.  It uses classes that implement AccessInterface, and then use YAML configuration for providing the requirements for the route.  Looking at how routing is set up for the code node module (which defines the Node entity), may be the best starting point for delving into this, though it uses the same Access classes as the node acccess system.  I think explaining it here may be too much.


Drush migration no longer working in 8.5

Ok answering this myself. I keep forgetting that Drupal often introduces breaking changes and treats comments as code. It looks like the annotation changed in 8.5

What was in 8.4:

/**
 * Drupal 7 file_entity source from database.
 *
 * @MigrateSource(
 *   id = "file_entity",
 *   source_provider = "file"
 * )
 */

in 8.5 should now be:

/**
 * Drupal 7 file_entity source from database.
 *
 * @MigrateSource(
 *   id = "file_entity",
 *   source_module = "file",
 * )
 */


You probably can do this with just a Global custom text field and some hidden view fields.

E.g.:

Add car id to the view but exclude from view.
Move this to the top of the list.
Add a global custom text field for your Favorite button using the replacement values.  Could be something like:

Add as Favorite

Notes:

Classes are bootstrap specific.

Href is the code to set the favorite.

Destination string is Drupal way to circle back to view.


How can I get the field settings in a field preprocess hook?

You can fetch the field settings in a preprocess hook by using the following code.

function YOUR_THEME_preprocess_field(&$variables) {
  if($variables['element']['#field_name'] == 'field_event_date') {
    $node = $variables['element']['#object'];
    $field_name = 'field_event_date';
    $instance = field_info_instance('node', $field_name, $node->type);
    $display = field_get_display($instance, 'default', $node);
    $variables['event_date_formate'] = $display['settings']['format_type'];
  }
}


Create URL aliases for Entityform submissions

Note: This answer only applies specifically for the input form (I misunderstood the question above)

I was able to accomplish this by using simply modifying the entityform made configuration.

Go to /admin/structure/entityform_types
Click on the edit link for the entity form you wish to change
Scroll to the bottom and in the URL path settings set the specific custom paths that you wish
Save

It's that easy and it works for both the preview and the actual form :)


trigger attribute AJAX using custom select element

I had the same problem and I managed to find the solution.

You need to call .attr and .trigger

    $('ul.choose-product-quantity li').click(function(){
      var quantity = $(this).children('.product-quantity').text();
      $('.form-item-attributes-field-product-qty input')
      .filter(function(index){
        return $(this).attr("value") == quantity;
      })
      .attr('checked', 'checked').trigger('change');
    });

See attached screenshot as well. Good luck. !

Custom attributes selector (image)


Add styles to a custom sidebar region in Zen

You create a sidebar region as same like other regions. And just edit the css and add the new region class there in existing sidebar css.

.sidebar1{
  background-color:yellow;
}
.sidebar1,
.sidebar_new{
  background-color:yellow;
}


How do I set the private file system path's permissions?

Your module has to implement hook_file_download(). By default all private files will give access denied.

If your access rules are not complex, you can also use one of contrib modules, ex. Private files download permission


How to parse mysql query output as variable into another command in linux via Drush?

Based on the query that you've provided, you're just getting one unpublished feed_item, then deleting it. This can be done in one line, without an intermediate bash step.

drush ev "node_delete(
  db_select('node')
    ->fields('node', array('nid'))
    ->condition('status', '0', '=')
    ->condition('type', 'feed_item', '=')
    ->range(0, 1)
    ->execute()
    ->fetchField()
);"

If you wanted to delete multiple nodes at once - or all nodes returned with your conditions, then use https://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_delete_multiple/7 , remove the range and use fetchCol() to return an array of NIDs.

drush ev "node_delete_multiple(
  db_select('node')
    ->fields('node', array('nid'))
    ->condition('status', '0', '=')
    ->condition('type', 'feed_item', '=')
    ->execute()
    ->fetchCol()
);"


Can webform conditionals require filling one of two fields?

The Webform Validation module has what you are looking for (Require at least one of two fields).

  The following validation rules are currently included:
  Numeric values (optionally specify min and/or max value)
  Minimum length Maximum length Minimum number of
  words Maximum number of words Equal values on
  multiple fields Unique values on multiple fields
  Specific value Require at least one of two fields
  Require at least one of several fields Minimum number of
  selections required Maximum number of selections allowed
  Exact number of selections required Plain text (disallow
  tags) Regular expression Must be empty (anti-spam:
  Hide with CSS) Words blacklist Must match a
  username


How to print render each term in a vocabulary?

You might be seeing Exception as

  EntityMalformedException: Missing bundle property on entity of type
  taxonomy_term. in entity_extract_ids()

Reason being:

  In taxonomy_term_view_multiple($terms,..)
  $terms: An array of
  taxonomy terms as returned by taxonomy_term_load_multiple().

    $vid = taxonomy_vocabulary_machine_name_load('finder_items');
    $tax = taxonomy_get_tree($vid->vid, 0);
    if (!empty($tax)) {
      foreach ($tax as $term) {
        $tids[] = $term->tid;
      }
    }

    // Get the term obj by passing array of term ids.
    $term_details = taxonomy_term_load_multiple($tids);
    $terms = taxonomy_term_view_multiple($term_details, 'full', 0, 'de');

   // Render the return array
   foreach($terms as $term) {
     print drupal_render($term);
    }


How to use current Workflow state as a Panels selection rule

I added a new select list field that would update to match the current workflow state each time the workflow changed.  I was able to use this field in panels and could accomplish what I needed.

It's not perfect, but it works.


adding drop-down subject (html select) to contact form

There is a select form element that you can add to your buildForm or hook override, depending on how you are building your form:

$form['example_select'] = [
  '#type' => 'select',
  '#title' => $this->t('Select element'),
  '#options' => [
    '1' => $this->t('Contact'),
    '2' => $this->t('Other'),
    '3' => $this->t('Customer Support'),
  ],
];

This is from the Drupal documentation: https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!Select.php/class/Select/8.2.x.


Features - branch 2.x results in large info files that exceed the 'info' column limit in the 'system' table

The way I see it, you have options:

Features

Break your Features down into smaller Features.  Yes, this might make the dependencies a little more effort to manage, but a Feature containing that many content types, as well as other config does seem a little extreme.

If you do break them up, and are worried about dependencies, create a controller module to deal with them.  Every time you add/break down a Feature, add it as a dependency to this controller module, then make your new Feature depend on the controller module.

This means that all other dependencies will be inherited by the Feature, but you've only had to declare it in one place. When you then disable any part of your Feature, everything will get disabled - which is the same behaviour as having one monolithic Feature.

As an added bonus, if you perform updates to your Features that require hook_install or hook_update_N, they can go in the controller module.

Configuration Management

If the idea of breaking down your Features really sends shivers down your spine, then check out Configuration Management, which can do what you want (track EVERYTHING), and if pretty easily extensible if you are happy writing your own code. This is also the route Drupal 8 is taking/has taken with configuration management, so with this method you'll be future-proofing your own knowledge.

My personal preference is Features, but if you are looking for something that wouldn't involve you breaking down a huge Feature into smaller ones, then Configuration Management is a solid option.


Converting Simplenews Subscribers to Users

this may be useful
http://bouteillenicolas.com/expertise-drupal/simplenews-save-subscribers-info

All you have to do is use rules, create a webform, and then use rules that handdles that webform and create the suscriber and the the user using the information sended through the webform


Calling node delete (node_delete_multiple) is not deleting all comments from database

you should check the watchdog table to see if there are any errors. The function calls comment_delete_multiple and with in that functions deletes all the replies as well.

If there was any error during this process it would rollback to a specific point in this case I guess it would be during the delete process of child comments. Tne information would be stored in the watchdog table with type set to comment. This would give you a hint as to why it was not deleted.


Cannot figure out where the tmp folder is to add the .htaccess file per http://drupal.org/SA-CORE-2013-003

Maybe I don't fully understand where outside the root dir is at? Isn't it the directory above where the installation is at?  Is it in the html folder, the sites folder, or above the html folder?

The tmp folder is where your configuration says it is.

I looks like you've already navigated to Administration » Configuration » Media  » File system, and found that the field "Temporary directory" says /tmp - so that is where it is (this is also the default location).

Now, this is a file system path, not a Drupal path.  The "/" in front tells you it is in the file system root.

To navigate to it, use the following command in the Gnu/Linux CLI:

 cd /tmp

  Will the instructions in http://drupal.org/SA-CORE-2013-003 work if I create a tmp folder in the html folder?

No.

  Where exactly do I create the tmp directory?

You don't create it.  It should already exist on your system.

To fix the error message regarding the .htaccess in /tmp related to the security update you mention, do as follows:

First, in the GNU/Linux CLI, use the following two commands:

 cd /tmp
 rm .htaccess

Then in the Drupal GUI, as admin, navigate to Administration » Configuration » Media  » File system.  Do not change anything, but press "Save configuration".  This will make Drupal create the correct .htaccess in the right place.


Delete multiple images at once from a node

I'm a little surprised there's nothing available to empty out a field, but in its absence you can just write your own action for VBO. Contrived (and most likely incomplete) example:

function MYMODULE_action_info() {
  return array(
    'MYMODULE_delete_images' => array(
      'type' => 'node',
      'triggers' => array('any'),
      'label' => t('Remove all images'),
      'behavior' => array('changes_property'),
      'configurable' => FALSE,
      'vbo_configurable' => FALSE,

    ),
  );
}

function MYMODULE_delete_images_action($entity, $context) {
  // Pick up pre-batch config entered by user.
  $foo = $context['foo'];

  // Remove all field vals. Using 'changes_property' behavior in the
  // info hook will trigger the entity to be saved, so no need
  // to do so manually.
  $entity->field_FOO[LANGUAGE_NONE] = array();
}

function MYMODULE_delete_images_action_form($context, &$form_state) {
  // Some custom context for the batch op.
  $form['foo'] = array(
    '#type' => 'textfield',
    '#title' => t('Some option'),
  );
}

function MYMODULE_delete_images_action_form_validate($form, &$form_state) {
  // Validate the submission.
  if (bar($form_state['values']['foo'])) {
    form_set_error('foo', t('Blah'));
  }
}

function MYMODULE_delete_images_action_form_submit($form, &$form_state) {
  // Ensure submitted values are passed through to the action callback.
  return array(
    'foo' => $form_state['values']['foo'],
  );
}

Obviously you could extend the pre-batch form to allow for a choice of which field to empty, and even make this generic to all field types with a little effort.


How do I disable some available countries in Commerce Shipping?

Easy (assuming Drupal commerce 7.1 in my testing) - you want to just navigate to

Admin > Store > Commerce Profiles > Profile Types > Manage Fields > [Your Address Field] > Edit

Under 'Available Countries', select the ones you want per the instructions 'If no countries are selected, all countries will be available.'

You may also refine the list of available countries that appear in the above-mentioned 'Available Countries' selection list (and any other country chooser in a Drupal 7.x site) with the countries module.


I'm almost new user of Drupal, but I encountered the same problem because I write myself my modules.
My need is to create a node and to insert it as submenu of a main menu Item. I solved my problem in this way:

I wrote this function

function mymodule_get_plid($menu_name , $name) {
    $menu = menu_tree_all_data($menu_name);
    foreach ($menu as $item => $menuitem) {
        if ($name == $menuitem['link']['link_title']) {
            return $menuitem['link']['mlid'];
            break;
        }
    }
    return false;
}

where $menuname is a string like 'main-menu', $name is the menu item for which I'm searching for it's Id. Function return Id if it find $name, false otherwise.

Now to complete node creation i wrote this.

$node = new stdClass();
$node->title = "YOUR TITLE";
$node->type = "page";  // Creating a node of Basic page type
node_object_prepare($node); // Sets some defaults. Invokes hook_prepare() and hook_node_prepare().
$node->language = LANGUAGE_NONE; // Or e.g. 'en' if locale is enabled
$node->uid = $account->uid;
$node->status = 1; //(1 or 0): published or not
$node->promote = 0; //(1 or 0): promoted to front page
$node->comment = 0; // 0 = comments disabled, 1 = read only, 2 = read/write

$node->menu['enabled'] = TRUE;
$node->menu['menu_name'] = 'main-menu';
$node->menu['plid'] = mymodule_get_plid('main-menu' , 'Inquiries');
$node->menu['link_title'] = 'MY SUBMENU NAME';
$node->menu['description'] = ''; // Needed even if empty to avoid notices.  /*

$node = node_submit($node); // Prepare node for saving
node_save($node);

Now all behaves well, "MY SUBMENU NAME" is created as a new node and appended as sub menuitem of the 'Inquiries' menu Item of the main menu.


I don't think so because data was deleted from database. If u have old copy of database, then here you can do something,
Create an other database and import that old database into it.
and Fetch the required tables(means required rows and column) and dump into your current database.


How do I access the data of a field using PHP?

Language negotiation is handled for you by field_get_items, and the delta is above the field column in the array hierarchy (it goes $field[LANGUAGE][DELTA][COLUMN_NAME]).

So using und isn't necessary, and you need to change how you're accessing each field item.

Code similar to this should work:

$field_lab = field_get_items('node', $node, 'field_lab_s_requested');
foreach ($field_lab as $field_item) {
  switch ($field_item['value']) {
    case "127":

      break;
    // ...
  }
}


Permission denied for a route implemented by a custom module

As suggested to me from @berramou the solution is:

  Add \ to Drupal\first_module\Controller\FirstController::content like
  \Drupal\first_module\Controller\FirstController::content and clear
  cash. – berramou 17 mins ago


Moving a Drupal installation to a subdirectory

You can use the module Pathologic that acts as a filter on your text formats (Full HTML, Filtered HTML) and basically rewrites URL's which are parts of fields depending the site configuration and Pathologic settings.

You can for example set Processed URL format to Path relative to server root (/foo/bar) and for the All base paths for this site, you fill in the different website URL's.


Drupal - user registration form- theming

Look at poll module for a good example of this.

You can simply (with item being something in your form);

$form = $variables['form'];
$variables['item'] = drupal_render($form['item']);
$variables['rendered'] = drupal_render_children($form);

However there are other ways of achieving this and keeping the rearranging within the UI (/admin/config/people/accounts/fields etc) by using hook_field_extra_fields - poll module does this as well I've noticed.  It can be used for adding existing base fields which don't otherwise show in the Manage Display UI (like node author, created, updated times, etc) - here's an example for user picture.


redirect internal body urls temporarily for local development

If there is given hard coded URL then you need to change it one by one , and if its coming through program or Drupal standard behavior then you can check it with clearing the cache.

Following are the way you can check:

1. Check settings.php to ensure that $base_url is set to "http://localhost"

2. Check settings.php to ensure that MySQL settings are correct

3. Take an SQL dump of the entire local database and searched for any references to live site URL

4. Delete all the local cache data from database

5. Check various blocks to ensure that there was no hard coding of links


I can't get my module to show up in the Navigation

At the end of your search_engine_menu() function, you need to return $items. Also, you should clear your drupal cache after adding a new menu item.

 function search_engine_menu() {
    $items = array();
    $items['results_page'] = array(
        'title'         => 'Search Results',
        'page callback'     => 'search_engine_results_page',
        'access callback'   => TRUE,
        'type'          => MENU_NORMAL_ITEM,
    );
    return $items;
 }


Dynamically size images for mobile first design (omega theme)

More of a CSS than Drupal question, but the standard solution is

img {
  max-width: 100%;
  height: auto;
}

You might get some funny results with images inside table columns that don't have an explicit or minimum width set, but those just have to be handled on a case-by-case basis.


How to use the Rules module to lock English nodes from editing?

For the event, "a node is updated", use the action "set data value".. Unchanged node's body > Changed node's body and set a site message explaining that the translation wasn't saved.

I'd also make the rule only apply to the translator role.


jQuery conflict issues with client embed code

I was able to fix this conflict by only displaying this embed code to users who are not logged in. This resolved the conflicts with the in place editor.

In my twig file where I was outputting the embed code, I wrapped it in:

{% if not logged_in %}
  {{ embed|raw }}
{% endif %}


Which permission is associated with variable_set()?

There is no permission associated to using variable_set(). Permissions are associated to pages, and not having a specific permission doesn't allow to see those pages; associated to part of the page, and not having a specific permission doesn't allow to see that specific part of the page; or associated to an action, and not having a specific permission doesn't allow to do/start that action.

There could be a module that checks the currently logged-in user has a permission before saving some data with variable_set(), but that doesn't mean every call to variable_set() needs the user to have a specific permission. variable_set() doesn't even check for any user permission.

As for what done from Drupal core and its modules, none of the functions calling variable_set() that aren't part of tests use code similar to the following PHP pseudo-code.

if (user_access($permission)) {
  variable_set($key, $value);
}

This means that, for example, in a form submission handler for a setting page used by Drupal core, the settings will be saved independently from the user permissions the logged-in user has. That user has the permission to see that setting page, though.
If you are noticing that setting values for a form are saved just when the user is administrator, and that happens also for setting pages handled by Drupal core modules, then there is something wrong happening.


Recommended taxonomy/structure for destinations site

Think of Drupal as an interface to a database (it is one) and vocabularies, when used as the basis for fields associated with your content items, as a means for filtering for values in a table.  If the terms in a hierarchy would have 1-to-many or many-to-many relationships, then you will want to have separate tables and therefore separate vocabularies so that you can use relationships to make selections.  In your case, the relationship between continent-county-city is one-to-one (with occasional duplicates such as two cities with the same name) so a single vocabulary, using a hierarchy, makes more sense.

The Views module is basically a UI for queries to the database, so you will use Views to make selections from your table, and menus can be structured as hierarchies to present selections to users using the same multi-level logic of your location vocabulary. You may choose to create content by defining a new content type article that has a field attached to it associated with the location vocabulary and perhaps a second vocabulary to identify the type of information it contains.  This second vocabulary would have terms such as geography, government, cuisine, hotels, restaurants, etc.  When creating an article about hotels in Paris, you would label the two fields from the vocabularies so that the articles can be filtered accordingly.  This is, in simple terms, how Drupal assembles sites.


Form alteration is not working from within my form class

Use your hello_world_form_alter in your module file. I guess should be hello_world.module. I guess you already have a folder hello_world where you placed the file above. In this folder you should also have an .info.yml file at the same folder place your hello_world.module file.

Please check https://www.drupal.org/docs/8/creating-custom-modules. You will find a lot of tutorials about how to create a custom module. Just google it!


How to display Block content on menu click?

Install the Menu Attach Block module

  Menu Attach Block allows you to embed blocks in menu items. You may choose to
  replace a menu item entirely with a block, or keep the menu link and embed the
  block after it in the wrapper element.


Trying to edit the breadcrumbs for views using Custom Breadcrumbs module

The stable Drupal 7 version of Custom Breadcrumbs is currently in the 1.x branch; support for Views has only been added in the 2.x branch, for which there is no stable release for either version (there's an RC available for Drupal 6 but only a dev version for Drupal 7).

I think your options are:

Try the 7.x-2.x-dev branch and report any problems you find back to the module issue queue
Implement hook_preprocess_views_view() for your view and set the breadcrumb in there programatically (with code similar to the below).
Add custom PHP code to the header of your view (not advised):

$breadcrumb[] = l('Home','<front>');
$breadcrumb[] = l('View Name', 'path/to/view');
drupal_set_breadcrumb($breadcrumb);

A number of other 'hacky' methods that involve overriding the theme_breadcrumb function and making changes based on the path of a View (see this post for some examples).


Email a Whole Node (Including template contents)

Here's another approach. (The code is available in this sandbox.)

nodemail.info

name = Nodemail
description = Sends node e-mails.
core = 7.x

nodemail.install'

<?php
function nodemail_enable() {
  $current = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
  $addition = array('nodemail' => 'NodemailMailSystem');
  variable_set('mail_system', array_merge($current, $addition));
}

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

nodemail.module

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

function nodemail_mail($key, &$message, $params) {
  switch ($key) {
    case 'node_mail':
      $message['headers']['Content-Type'] = 'text/html; charset=UTF-8;';
      $message['subject'] = $params['subject'];
      $message['body'][] = $params['body'];
      break;
  }
}

function nodemail_node_insert($node) {
  if ($node->type == 'mycontenttype') {
    $params['subject'] = 'Node "' . $node->title . '" was created';
    $params['body'] = render(node_view($node));
    $to = variable_get('site_mail', '');
    $from = 'noreply@example.com';
    $lang = language_default();
    drupal_mail('nodemail', 'node_mail', $to, $lang, $params, $from);
  }
}

The install file contents and NodemailMailSystem class are used to allow this module to send html e-mails. The 2 other functions are implementations of hook_mail() and hook_node_insert() that deal with sending the e-mails when a node of mycontenttype is created. One thing you'll have to note is that Drupal will use the node template file of the theme that is being used for node creation pages (or the core node.tpl.php if the theme doesn't have it) for the node view. You may also want to check out the node_view() and drupal_mail() functions that are used here. This whole thing should work with Drupal 7 core functionality (no contributed modules are needed).


Adding existing contact form in another page

You could use Contact Block module which will allow you to place a contact form block on whatever page and region you desire.

Once installed place a block as usual and filter for contact block, then in the block configuration settings you can choose which contact form to use. You can also add pages to display the block, remember to add pages with a slash "/my-pages-path"


how can i store an image in my postgresql database?

You need the Storage API module.

This allows you to set a field's upload destination to a custom storage class, one of which is database.

I've used this module for this exact purpose and worked well.


Dynamic form building - cleanest way to substitute tags with form elements?

If the tags are not dynamic you can have an array of possible form elements and then just foreach over them with matches from a regex. Then just have your mymodule_form call a builder function that would look something like:

<?php
function my_dynamic_forms_dynamic_form($form, &$form_state, $id) {
  $string = my_dynamic_forms_db_call_for_strings($id);

  $elements = my_dyanmic_forms_get_array_elements();

  $form = array();

  $reg = '/\[(.*?)\]/is';

  if($c = preg_match_all($reg, $string, $matches))
  {
    foreach($matches[1] as $match) {
      $form[$match] = $elements[$match];
    }
  }

  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Submit Form',
  );

  return $form;
}

function my_dyanmic_forms_get_array_elements() {
  $elements = array(
  'quantity' => array (
    '#type' => 'textfield',
    //other settings
  ),
  'type' =>  array (
    '#type' => 'select',
    //other settings
  ));

  return $elements;
}

function my_dynamic_forms_db_call_for_strings($id) {
  $sql = 'SELECT string s from my_dynamic_form_strings_table s WHERE id = :id';

  $result = db_query($sql, array(':id', $id));

  return $result->fetchField();
}
?>


How can i change the html generated of filter field of views?

On Drupal 6, if you don't want to work with tpl, you can use Semantic Views.


How to use Views Isotope in Commerce Kickstart?

Views Isotope works fine with Drupal commerce. (I'm using it now =-)

Make sure you have the isotope .js file in the correct location within libraries: sites/all/libraries/jquery.isotope/jquery.isotope.min.js

also when creating the View make sure (as the above video briefly covers) that the 'Taxonomy Term: Name' in the Views Isotope filter block has the 'link this field to its taxonomy page' option turned off (5:25 time in the YouTube tutorial you posted). If it is on the links wont work.

And of course as video stresses in the main Isotope View, make sure the last field in the list is the taxonomy field that is linked to the header block. IF you need to display that taxonomy also create two fields in the view and make sure one of them is last with the correct CSS overwrite styling as the video tutorial states.

Oh and lastly, make sure your Views' Ajax option in the advanced tab is turned off. It conflicts with Isotope and wont work.


Installling fails with no error messages

This is a typical white screen of death issue, ways to debug it are described here on drupal.org


Is theme('pager') designed to work only with dynamic query?

theme('pager') is not designed to work only with dynamic queries. The documentation for page_default_initialize() shows example code where dynamic queries are not used.

  // First find the total number of items and initialize the pager.
  $where = "status = 1";
  $total = mymodule_select("SELECT COUNT(*) FROM data " . $where)->result();
  $num_per_page = variable_get('mymodule_num_per_page', 10);
  $page = pager_default_initialize($total, $num_per_page);

  // Next, retrieve and display the items for the current page.
  $offset = $num_per_page * $page;
  $result = mymodule_select("SELECT * FROM data " . $where . " LIMIT %d, %d", $offset, $num_per_page)->fetchAll();
  $output = theme('mymodule_results', array('result' => $result));

  // Finally, display the pager controls, and return.
  $output .= theme('pager');
  return $output;

The other example given in that documentation page shows code that uses an external service to retrieve information which is shown. Also in that case, dynamic queries are not used. (The external service could not even running Drupal.)

The only difference I can see between that code, and the PagerDefault class is that PagerDefault uses a unique ID that passes as last argument of page_default_initialize().

/**
 * The unique ID of this pager on this page.
 *
 * @var int
 */
protected $element = NULL;

$total_items = $this->getCountQuery()->execute()->fetchField();
$current_page = pager_default_initialize($total_items, $this->limit, $this->element);
$this->range($current_page * $this->limit, $this->limit);

The other difference is that, as PagerDefault uses dynamic queries, its query can be altered with hook_query_alter(). In this case, as the added tag is pager, the query can be also altered with hook_query_pager_alter() which is a hook_query_TAG_alter() hook.

  public function __construct(SelectQueryInterface $query, DatabaseConnection $connection) {
    parent::__construct($query, $connection);

    // Add pager tag. Do this here to ensure that it is always added before
    // preExecute() is called.
    $this->addTag('pager');
  }


How to add custom "pay now" button and after submit, redirect to the checkout/orderId page

Use a rule. Example:

{ "rules_forward_user_directly_to_checkout" : {
    "LABEL" : "Forward user directly to checkout",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [],
    "REQUIRES" : [ "commerce_order", "rules", "commerce_cart" ],
    "ON" : { "commerce_cart_product_add" : [] },
    "IF" : [],
    "DO" : [ { "redirect" : { "url" : "checkout" } } ]
  }
}

Note that you don't need to redirect to checkout/%order_id, you just need to redirect to checkout and Commerce will take care of the rest.


How to avoid Rules adding blanks to eMail Id subscribed via Simplenews?

You didn't mention in your question what the data type is for that e_mail component. But you may want to experiment a bit to see if your problem is resolved by using token [data:e_mail-value-raw] instead of [data:e_mail-value].

Here is a quote from the description (in the Rules UI) about such "raw" values:

  The raw value of the selected component, e.g. "email-value-raw". However this is not cleaned up by check_plain(). This is raw user input so take care if you use this somewhere else.

If the above doesn't help, I'd also check if adding (some or all of) these Rules Actions would help (before your existing rules Action):

Add a variable, eg email_id
Set a data value for that email_id, to assign it the value [data:e_mail-value]
Convert data type of that email_id field (which you then use in your existing Rules Action).


Views is probably your best option, using a contextual filter, and various Views Blocks

If for example the url was www.mysite.com/user/12/profile, you could list all of any number of content types where the user id matches 12.

The specific answer depends on the structure however. If you include that information, I will update this answer with more specific direction.

EDIT 1:

create a separate view for each content type you want visible on the user's page
for each, set it as a BLOCK, not a page, and set the fields and order, etc as appropriate
set a contextual filter - this will depend on your structure, but I will show one as an example and you should be able to extrapolate. Contextual Filter->Content:Author uid
Contextual Filter, When not Available -> Provide Default Value, Raw Value from URL, Path Component 2 (for /user/12/*)
go to admin/structure/blocks and you should see the new views blocks. set them to only show on user/* for example to show in the profile pages, and place the blocks in the appropriate region


Are the functions you are calling from your implementation of hook_uninstall() defined in your .module file? If that is the case, those functions will not be found, as the module file is not anymore loaded in memory.

  When hook_uninstall() is called, your module will already be disabled, so its .module file will not be automatically included. If you need to call API functions from your .module file in this hook, use drupal_load() to make them available. (Keep this usage to a minimum, though, especially when calling API functions that invoke hooks, or API functions from modules listed as dependencies, since these may not be available or work as expected when the module is disabled.)


If all you're looking to do is offload your Files directory to a different server, and you have complete access to both servers, I would suggest you create an NFS (network drive) mapping to the storage server.

Then you can simply change your Public/Private files directory to /mynfs/drupal-files instead of /drupal/sites/default/files, which will pretty transparently offload storage to your other server.

You'll want to do some research into NFS and its alternatives that do the same thing.  I'm not familiar enough with the Storage API to know if it will work in your situation.  After researching it a little bit it seemed like you would have to do a decent amount of work as well.


Always expanded menu items not showing up expanded in custom menu

I have investigated this a bit more and made a bug report on Drupal.org. It turns out the 'menu_expanded' variable is basically a redundant layer of caching which must be set by _menu_set_expanded_menus whenever the cache is cleared. However, if Drupal tries to call that function more than once in a single request, it will be registered as a shutdown callback instead of called immediately. This would work fine most of the time in normal use, but during test cases the shutdown function won't get called until after the tests are over.

Knowing that most of the time this operation will handle itself correctly, and that even if it doesn't it's just a cache clear away from being fixed, I've decided it is acceptable to add a direct call to _menu_set_expanded_menus in the setUp function like so:

function setUp() {
  parent::setUp('custom');
  // Call this function now to set up expanded menu item processing. Normally
  // we could wait for it to be called in a shutdown function added during
  // the menu rebuild in parent::setUp() above, but in this case it must be
  // handled before the tests are run.
  _menu_set_expanded_menus();
}


Wiki-like "create this page" with page manager?

You should achieve that by using the following extensions:

wikitools
freelinking

You should have a look at this screencast:
http://www.youtube.com/watch?v=KHsjjHzYOSg

It is done with Drupal 7, however, wikitools is still in alpha for Drupal 7.


hook_menu parameter can contain a forward slash

Additional arguments are still sent to page callback functions.

You might try doing a check for additional arguments:

function get_resource($id) {
  $args = func_get_args();
  if (count($args) > 1) {
    $id = end($args);
  }
  /** rest of your code **/
}

This way if the public id was "unitedstates/public_id", func_get_args() would return two items, the second one being "public_id" which would be set as the $id if there is more than one argument. Note this will always set the last argument as $id if there is more than one.


adding a background image to a Drupal site

You can try the background image module

  This is an api module that provides tools to add background images to
  html elements using the css "background" property. A basic settings
  page is supplied as well as functions to easily add the "background"
  property to the page.


Views displaying only one record on pagination

Go to your view and Click on Pager settings. and change the items per page


drush 6.2.0 reports no version control found for core updates, but DOES find and use svn for module updates (pm-update)

I haven't used --version-control=svn for a while, and never liked --svncommit.  In any event, it looks like you have found a bug in Drush.  This should be reported in the Drush issue queue; however, since the current maintainers have pretty much moved on to git, I am not sure this code will continue to be supported unless a volunteer stands up to fix and maintain it.

In the meantime, you might try downloading Drush 5, and install it as a secondary version, perhaps setting up an alias 'drush5' to point to the older install, and use it only for core upgrades.  If that does not work, you could even try going back to Drush 4.  Note that neither Drush 5 nor Drush 4 are supported, though.


How to declare a click on a particular tab to be a new event for use with Rules?

Possible lead? The Rules Link module. The JavaScript option may be what you're after.
Here is a quote about it (from the module's project page):

... lets you create links which trigger arbitrary functionality with the help of Rules.
Example use cases:

Publish/Unpublish content
Subcribe users to current group
Mark nodes, comments (as Spam), unpublish it and block the author.
Batch functions like, delete all comment for a node

And many more...
Features:

Attach the link to any entities.
Show the link only for certain bundles.
Narrow the entities on which the link will be shown using the visibility conditions.
The links are usually displayed using Views.
For entities that can be displayed, the links can be shown on node view.
Supports an arbitrary number of additional Rules parameters for passing context via Views.
3 types of links: Javascript, Normal and Confirmation form links.
Use individual permissions for each link.

Usages:
There are three types of links:

Javascript - Links that will trigger the rules using Ajax.
Token - This are basic links, that will reload the page after calling them.
Confirmation link - Show a confirmation form before executing the rule.


Display multiple values of a field in separated rows

1) If you are using a view with field you can click on your field and have a look at

"MULTIPLE FIELD SETTINGS"

the checkbox "Display all values in the same row" is checked by default. If you uncheck it it's going to show your field in different rows.

2) If you are using a view with content (teaser, full etc..) you can modify the output in different way:

Have a look at Field API
The one you may need is template_preprocess_field()

function templatename_preprocess_field(&$variables) {
    if($variables['element']['#field_name'] == 'field_name') {
        if($variables['items']['0']['#markup'] == 'your_value') {
            $variables['items']['0']['#markup'] = '';
        }
    }
}

If you have Devel Module you can use the dsm() function to see how to manupulate it.

function templatename_preprocess_field(&$variables) {
        if($variables['element']['#field_name'] == 'field_name') {
            dsm($variables['element']);
        }
    }

It will show what's inside $variables['element'] as a drupal message.

3) You can use field.tpl.php and use field-name-[field_name].tpl.php to target only your field. Have a look at theme_field() .

If you want to change all your multiple value field in that way, use the second method without the if statement that targets your field.

Find out the method better fits your needs.


How can I indicate "NEW" content in faq module after updating an entry?

To do this you can use the Computed Field module.

Add a field to your FAQ content type and select Computed Field as the type.

In the Computed Code (PHP) box add the following code:

$entity_field[0]['value'] =node_mark($entity->nid, $entity->changed);

In the Display Code (PHP) box, enter the following:

$display_output=theme('mark', array('type'=>$entity_field_item['value']));

Set the field NOT to store the value in the database.

Go to admin/structure/types/manage/faq/display, move your field above the answer field, set the label to Hidden and the display format to Unsanitized.

This will display either 'New' or 'Updated' as the case may be for the FAQ page, just as it is displayed on the content list..


Alternate to field_get_items() ?? CCK fields reconstriction?

First off, 'und' is the value of the LANGUAGE_NONE constant, which is used for the content not associated to a particular language. Not all the fields have a value for that, and if you are trying to access it, you get a PHP warning.

For example, for taxonomy terms, the array structure could be one of the following.

tags

other taxonomy terms

If you need to get the field value that would be used for the currently used language, you can just use field_get_items(). Its code cannot be optimized, as it needs to determinate the language used for the field.

function field_get_items($entity_type, $entity, $field_name, $langcode = NULL) {
  $langcode = field_language($entity_type, $entity, $field_name, $langcode);
  return isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : FALSE;
}

Even the code for field_language() cannot be much optimized. You could avoid multiple calls to field_valid_language(), but that is the only thing you can do.

If you have your own code to decide which language should be used for the fields, you can access the field data directly, without using field_get_items().


Okay sorry ... it took some time, but I found the solution.

First I had the themed menu within the template, now I have the main menu direct as a block.

The solution was to edit the main menu and set the following option:

Translate and Localize. Menu items with language will allow
translations. Menu items without language will be localized.

That's it.


This Drupal 8 module does exactly that, in a tightly integrated way: https://www.drupal.org/project/editor_file


Generally speaking, as @Kevin aknd @kiamlaluno have noted, it's probably easiest to make one content type Landing page and use that for all landing pages on your site.  I actually did a similar thing on a site earlier this year.
You noted that you wanted to do three kinds of landing pages with different fields.
So to implement this, you could add all of the fields to the Landing page content type:

banner title
body
image
blogs
publications
news and events

Then, when you are adding content of type Landing page, just fill out the necessary fields.
Then you can make a theme template for your custom content type.  Copy the file web/core/modules/node/templates/node.html.twig and copy it to your custom theme's templates folder and rename the file node--LANDINGPAGE_MACHINE_NAME.html.twig.
For example: web/themes/contrib/MY_THEME_NAME/templates/node/node--landing-page.html.twig (Note: If the machine name is landing_page, you need to replace the _ with -.)
You can then edit this file to display the fields however you want to create the three kinds of landing pages.  You can display a field like this: {{ content.field_blogs }} where field_blogs is the machine name of your blogs field, for example.
If other users who don't know the rules might mistakenly fill out all the fields when they shouldn't (for example, if a node should not have values for both blogs and news and events), then you can add custom form validation to check for this.


View for latest articles - but able to override at page level

This is possible with attached displays. You would create a view with 2 displays: manual and reverse chronological.

Manual would use a relationship with node's field (entityreference field) that allows to pick releated nodes.

Automated will always select 4 recent articles.

Attach manual to an automated to appear at the top.

You gonna end up with 4 to 8 articles.

To remove extra nodes from results, implement hook_views_post_execute()


How can I hide one commerce specific shipping option without deleting?

You could try to remove the value from the form by using unset($form['commerce_shipping']['shipping_service']['#options']['express_shipping']);.

Also note that most of commerce's actions are handled by rules, there might be something there as well.


I would recommend using a small custom module to add your own queue:

http://api.drupal.org/api/drupal/modules!system!system.queue.inc/group/queue/7

Then use your callback to run each item through feeds.


The date module can be used to set up recurring events. An event on a specific date can occur multiple times. There's a basic tutorial at http://www.bentedder.com/recurring-calendar-setup-in-drupal-7/


Updated answer

Scrolling through the Drupal.org module library, I discovered Role expose. I have never used it, but it seems to do the trick as well:

  Role Expose -module gives site administrators ability to expose user
  their own user roles. Roles are listed on user profile page. Users may
  be granted an option to view own roles or all users roles.

Original answer

Looking at the render array, I feel you misunderstood a bit (unless you have configured a field on the user object where you already put a string of all his roles, but then you would not need the logic here)...

$user_profile['field_user_roles'] = array(
  '#entity_type' => 'custom',          // Nope, it is 'user'.
  '#bundle' => 'custom',               // Nope, it is 'user'.
  '#theme' => 'field',                 // Probably it is not a field, but a custom render element containing markup.
  '#field_type' => 'text',             // Probably not since it probably wasn't a field.
  '#title' => 'Roles',
  '#label_display' => 'above',
  '#field_name' => 'field_user_roles', // Probably not since it probably wasn't a field.
  '#markup' => '
' . $roles . '
',
  '#weight' => 5,
);

I guess it works better if you remove some of the data (see below).

On a small side note, logic should be avoided as much as possible within template files. So I'd recommend creating a small custom module and implementing hook_user_view_alter(). (If you are planning on supporting only one theme, you can also place it in the theme's template.php file. Use the theme name as the module name.)

function MODULENAME_user_view_alter(&$build) {
  // Obtain the account that user_view() stored for us.
  $account = $build['#account'];

  // Prepare roles string.
  $roles = '';
  foreach ($account->roles as $rid => $role) {
    $roles .= "
".$role."
";
  }

  if (count($roles) > 0) {
    $build['modulename_user_roles'] = array( // Prefix with module name to prevent collisions.
      '#type' => 'item',
      '#title' => 'Roles',
      '#markup' => '
' . $roles . '
',
      '#attributes' => array('class' => 'class-one class-two'),
    );
  }
}

Additionally you can implement hook_field_extra_fields() to expose the property on example.com/admin/config/people/accounts/display and choose its weight within the admin interface.

function MODULENAME_field_extra_fields() {
  $extra['user']['user'] = array(
    'display' => array(
      'modulename_user_roles' => array( // Make sure the name matches your custom property
        'label' => t('User roles'),
        'description' => t("Lists the user's roles."),
        'weight' => 5,
      ),
    )
  );

  return $extra;
}

Combined, the property should have been added to the $user_profile array and there is no more need to override the template file.

If you want to use the item_list, as proposed by Yogesh, your render array in MODULENAME_user_view_alter() should look something like this:

    $build['modulename_user_roles'] = array(
      '#title' => 'Roles',
      '#theme' => 'item_list',
      '#items' => $account->roles,
      '#type' => 'ul',
      '#attributes' => array('class' => 'class-one class-two'),
    );


Drupal Views in Glossary mode removing pager

From what I remember, you have to create the Glossary display of the view, and then you set the results page as an Attachment of that view display (attachment being the view display type).

Views ships with a default Glossary view, it's just disabled.  I would suggest enabling that and take a look to see how that does it.


Does Boost work together with Google analytics?

I am not a Boost expert, but I know Google Analytics. Google Analytics is client-side JavaScript, so as long as your pages render the Analytics code along with everything else in the HTML, you should be fine. Boost should have nothing to do with it.


I've just gone through the same thing myself, but without using CTools.

While I don't currently have time to write a comprehensive tutorial (which is what's really necessary, as most of the examples out there suck big time) - perhaps on the coming weekend - I can give you an overview of how I've done it. My scenario involves an existing form (for Entity Creation via the Entity Construction Kit).

First and foremost, I'm modifying the form via hook_form_alter(), but you can do the same thing in any form builder (for, say, a custom form). For simplicity, I'll refer to my implementation of hook_form_alter() as the 'form builder.'

The first thing my form builder does is determine the current 'state' of the form. I define 'state' as a single, distinct step of the form. I check for current state by looking for $form_state['current_state'] and defaulting it to a default (first step) state if not found.

It is important to understand that the data in $form_state will persist between steps of the multi-step, so when we trigger the rebuilding of the form, we can see what state we came from and act accordingly. So, we've set the $form_state['current_state'] to a default state (step1) and added the form elements we wish to display for this state into $form. (If you have other elements in $form which you don't want to show, set their #access property to false.) Now we can view the form and see our elements - great.

The next step is adding a new state and switching to it upon form submission. When the form is submitted, our submit handler looks at $form_state['current_state'] and figures out how to proceed. We can look at $form_state['triggered_element']['#value'] to figure out which button was clicked to submit the form, and act accordingly. Let's say our button in step1 was 'Next,' we can identify this click in the submit handler and do the following:

Save the current form values ($form_state['values']) into $form_state['step1_values'].
Change $form_state['current_state'] to be step2.
Rebuild the form by setting $form_state['rebuild'] = TRUE;

When the above events happen, the form builder will be called again, and now your $form_state['current_state'] will be set to step2, so you can identify this and show different form elements. Rinse and repeat for more form steps.

The tricky part I encountered was moving 'back' to a previous state and re-populating the form with previously submitted values. For some reason I had the impression that this would work 'automagically, because Drupal,' but no dice, I had to do it manually. This is no simple task, but (luckily for you!) you can get away with a single line of code:

form_set_defaults($fields, $values, $form);

... where $fields is an array of machine names for the fields you want to populate, $values is the data you saved in $form_state['step1_values'], and $form is the current form, which is accepted by reference and modified. As for the function itself, it's available as part of the form component in my DevTools module.

Disclaimer: form_set_defaults() was only tested in my own use case of a textfield, textarea, a series of checkboxes (referencing a taxonomy), and a couple FiveStar widgets. Your mileage may vary.

This should get you most of the way there!


Once I figured out that the access log was different than the $_SERVER variable, I called my hosting provider and discovered that their servers are only configured to allow GET and POST (haven't checked HEAD).

So I invented this hack to use the header, since it seems that Apache just transparently changes unrecognized methods to GET.

if( isset($_SERVER['HTTP_X_REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST' ) {
    $_SERVER['REQUEST_METHOD'] = $_SERVER['HTTP_X_REQUEST_METHOD'];
}


There are a lot of solutions for this kind of stuff. I would do it in the theme layer to have something really light. You can also use the variety of popup modules for this. One simple way to do this, use the Lightbox2 module, checkout this documentation page: http://drupal.org/node/252260


How to display the blocks to display in certain page in Drupal?

Use the context module. Though I'm not generally a fan of this module, this is one of the cases where it comes in handy.

Add a condition for a path. So if I want a block on page 1, but not page 2 or 3, I would write the paths like so, one for each block:

Case 1 - Block A

deserts/*
~deserts/*/*
~deserts/*/*/*

Case 2 - Block B

~deserts/*
deserts/*/*
~deserts/*/*/*

Case 3- Block C

~deserts/*
~deserts/*/*
deserts/*/*/*

The ~ means to exclude in this case. After that, add the block to the region you would like for it to show up. You can also add back in specific paths that might otherwise be excluded, and vice versa.


How to autoload classes from a 3rd party PHP library

Drupal use composer to manage the 3rd party libraries (Symfony, guzzle, etc...).
The problem is Drupal has versioned the vendor folder into the core directory; it is a problem because, if you added a new library in the root composer, you change the vendor directory and change the composer.json/composer.lock. So, if Drupal releases a new version, your changes will be deleted.

The Composer Manager module is created to solve the problem. You need to include a composer.json file in your module; the Composer Manager module downloads the library and registers a new autoload file (the second autoload).
The problem with this is only when you need use a middle-ware library, since the Composer Manager module registers a new autoload in the Request Kernel Event. This event is called after the middle-ware so this library is not available in the middle-ware layer.

In most cases, the Composer Manager module is the best solution to add new vendors.

There is the issue Remove external dependencies from the core repo and let Composer manage the dependencies instead.


If you want to create or edit a reference entity in a node add/edit form then you can use Entity Connect module.

If you want to have a separate page which will take an entity machine name and optionally id as input then you can have a look at the code in this module and build on that.

You may also take a look at Inline entity Form


You can get node id using :

$nid = $node->field_reference['und'][0]['nid'];

And you can check it out from this:

drupal_set_message($nid);


How to check for entity type in Views when using hook_field_access?

Based on @clive's comment above, I adjusted the code to check that $entity is actually present. I'm not sure if this is a problem unique to my install or not. I only saw the error when viewing a node of type 'lesson' through a paged view that depends on some custom relationship code, so entirely possible the error is mine somewhere in a custom module.

function HOOK_field_access($op, $field, $entity_type, $entity, $account) {

      //Check to make sure we have an entity. Abort if not.
      if (is_object($entity)) {

        //Check video field only when attached to 'lesson'.
        if ($field['field_name'] == 'field_video' && $entity_type == 'node' && $op == 'view' && $entity->type == 'lesson') {

          //Grant access only if user is logged in.
          if ($account->uid > 0) {
            return TRUE;
          }
          return FALSE;
        }
      }
    }


Yes, you can use Views as Patrick suggests. Make it a View of Order entities with relationships joining Orders to Line Items and Line Items to the referenced Products. You can then apply a contextual filter to only show results whose Product uid matches the currently logged in user's uid.
A couple things to keep in mind...

Such a View would need to "Disable SQL rewriting" in its advanced settings, because it won't work so long as normal entity access control conditions are applied to the query.
You should include in the View itself all the information you need the course seller to see rather than trying to link them directly to a standalone page per Order. If that's what you want, you're going to actually need to hook into the access control system via custom code.


Add css-class based on productpages' top level taxonomy term

Try something like this in your theme's template.php file (put it into MY_THEME_preprocess_page(&$variables) function):

if(arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
    $tid = arg(2);
    $term = taxonomy_term_load($tid);
    $parent = taxonomy_get_parents($term->tid);

    if(empty($parent)) {
      $variables['classes_array']['parent_cat_color'] = $term->name;
      // or $variables['classes_array']['parent_cat_color'] = 'parent_cat_color' .. it's up to you..
    }
  }

and open page.tpl.php and put $classes variable into your wrapper div..


Is the ckeditor or other editor supposed to be automatically installed?

No there's no WYSIWYG editor included with Drupal, you need to install one of the contrib modules.

WYSIWYG is the standard solution as it gives you a choice of editors, but there are others like the standalone CKEditor module.


How to save and append comment form without refresh the page in drupal 7

One option would be to use the AJAX Comments module:

  Provides ajax comments to Drupal sites. Features:

  Makes AJAX submits
  Allows replies to comments on the actual thread page
  AJAX comments deleting
  Works with CAPTCHA
  Cool jQuery sliding
  views integration

It will allow users to submit comments without a page refresh, bypassing the extra view count.


The problem is that the URL code in Drupal doesn't recognise your "outlook:" prefix, and so is trying to make it a valid version of a protocol it does know. Option (2) explicitly invokes the URL code, so it is not surprising that it changes the href.

I am slightly surprised that the rewrite version didn't work, and can only assume you had other options set in the View which caused this -- or that the page was cached.

If you cannot get the rewrite to work, I suggest you override the field with a view-specific field template (see "theme information" in the theme config), in which you can do whatever you wish.