You'll need to install the ACL and Content Access modules as well as uc_node_access.

Every site is different, but the general workflow goes something like this:

Create a new content type, and use the content access features to make nodes of this content type inaccessible to users by default
Create your 'paid content' node using the new content type. These nodes will not be viewable by site users by default.
Create a node of type 'product' (an ubercart node type). Users who purchase this product will gain access to the 'paid content' node.
Add a feature to the product node of type 'node_access' (Edit the product node, click the features tab, and add a node_access feature). Here's where you specify the node that purchasers of this product will gain access to.
Repeat steps 2 thru 4 for each node that you want to offer for purchase.
If you've done everything correctly, then users who purchase the product node will gain access to the corresponding 'paid-access' node.

I've used the D6 version of uc_node_access on a few sites, and it works flawlessly for me. Can't speak for the D7 version of uc_node_access, but I'm guessing it works equally well. Takes a bit of setup, but it does work.

For track anonymous viewing the only thing I know is use the browser's cookies, but that method will only work in the actual session if the user do not registers and clear his browser's caches then he can see 3 nodes again, I think you should look for alwasy force the user to register, or show only a teaser of the nodes for anonymous and force them to register for see the full node, then you can only let registered users see 3 nodes, then they have to pay, that way is possible and better. Its just a suggestion


How to change the view for a rendered product?

You have two high level options: 1) create page templates for your product displays in the theme layer that include the markup your CSS needs to position things or 2) use a module like Panels that lets you build page layouts from within the Drupal admin UI itself. (I'm assuming this is Drupal 7, but if you are on Drupal 8, you should give the core Layout Builder module a try vs. Panels.)


Add comments to Webform Submission pages

You would need to create a module for this. It doesn't need to be complex though. But you need a place to store the comments and some code to add the form and handle form submissions.

If you wanted to make something a little bit fancy, you could notify users when new comment on submissions are made.


Drupal 7 - can't uninstall Features module

You are missing the menu_custom table which is defined by the menu module. Most likely the problem is dependencies. If you install the menu module, that should fix it. If the menu module is already installed, the problem is that your database is broken.


If this is an file attached through a file or image field, you can instead implement hook_file_download_access(), which gives you the $field, $entity_type and $entity to which the file belongs.


How do you know if user_login_submit was successful in Drupal 7?

You can check if user is logged in or not by using global $user variable, if user is not logged in then $user->uid will be 0 for anonymous users.


The DevelDumperManagerInterface interface is implemented by DevelDumperManager. This class is in turn used as a service, 'devel.dumper'.

One way to use this function would be the following:

$ddumper = \Drupal::service('devel.dumper');
$ddumper->debug($variable_name);

Good luck!


How do I grab multiple commits from a different release branch?

A normal merge should work fine. It shouldn't remove the merged branch. If it does, you can always recreate the branch.

If you want to take just some of the commits, use "git cherry-pick".


In Drupal 7, to implement a new widget, you need to implement the following hooks:

hook_field_widget_info()
hook_field_widget_form()
hook_field_widget_error()

hook_field_widget_info() returns information about the type of widget implemented, such as the fields supported from the widget and for which the widget can be used. An example of implementation is image_field_widget_info().

function image_field_widget_info() {
  return array(
    'image_image' => array(
      'label' => t('Image'),
      'field types' => array('image'),
      'settings' => array(
        'progress_indicator' => 'throbber',
        'preview_image_style' => 'thumbnail',
      ),
      'behaviors' => array(
        'multiple values' => FIELD_BEHAVIOR_CUSTOM,
        'default value' => FIELD_BEHAVIOR_NONE,
      ),
    ),
  );
}

hook_field_widget_form() is the hook that returns the form field(s) necessary to get values for the field, which is what in Drupal 7 is called widget.
The reason you don't find any HTML in a module implementing a widget is that a widget is made of one or more form fields, which are defined using a form API array. If you look at file_field_widget_form(), you will notice that it uses a managed_file form field, but it also uses a theme function, and a form field process function.

  $element_info = element_info('managed_file');
  $element += array(
    '#type' => 'managed_file',
    '#upload_location' => file_field_widget_uri($field, $instance),
    '#upload_validators' => file_field_widget_upload_validators($field, $instance),
    '#value_callback' => 'file_field_widget_value',
    '#process' => array_merge($element_info['#process'], array('file_field_widget_process')),
    '#progress_indicator' => $instance['widget']['settings']['progress_indicator'],
    // Allows this field to return an array instead of a single value.
    '#extended' => TRUE,
  );

  if ($field['cardinality'] == 1) {
    // Set the default value.
    $element['#default_value'] = !empty($items) ? $items[0] : $defaults;
    // If there's only one field, return it as delta 0.
    if (empty($element['#default_value']['fid'])) {
      $element['#description'] = theme('file_upload_help', array('description' => $element['#description'], 'upload_validators' => $element['#upload_validators']));
    }
    $elements = array($element);
  }

As I said, a widget is used to get the value associated with a field; when you need to show the value associated with a field, you need to create a formatter through hook_field_formatter_view(). See Field Formatter API for more information.


hook_init() must be implemented in a custom module. In your example, the function mymodule_init() would go into a file named mymodule.module in a custom module named mymodule. You would also supply a simple mymodule.info file and put both files in the sites/sitename/modules/mymodule directory.

The custom module must be enabled like any other. Also, when creating a hook implementation, it is usually necessary to clear the cache for Drupal to recognize it. Finally, note that mymodule needs to be a unique name different from other modules or themes.

As a minor usage point, current_path() returns the current URL which may not be the current alias (e.g., node/5). Using drupal_get_path_alias() is recommended to always return a friendly alias.


How to make a stacked flexslider slideshow carousel

Got it to work, but using views slideshow. I just clicked "View Action Advanced Options" in the action setting, setting it to two slides. I also renamed the flexslider library and made sure that I downloaded the full version of cycle. And that's it!


There are couple of options:
1. Using the view's tempate file
2. The easiest and my favorite in that case - using css :after selector to add the '|' to the li's

Hope that helps.


Commerce one-off products in admin interface

The line item title in 1.x is derived from the line item type's title callback. Your simplest option is going to be to define a new line item type, as you've surmised, and have its title callback pull the value from a field you add to the line item type and expose to administrators to edit. Alternately you could edit the various Views to render this field directly ... but then you'd still need some way to allow creating ad hoc line items on the back end.

Sorry, I wish it were easier.


Pass Preprocess Values From Custom Module to Custom Form

It seems that you can get the list of blocks from this answer: How do i get the all the regions available in the current theme programatically?

MYMODULE/src/form/MyModuleForm.php:

protected function getEditableConfigNames() {
    return [
        'module_config.module_config_settings',
    ];
}

public function buildForm(array $form, FormStateInterface $form_state) {

  // Get the block list based on previous Q/A
  $theme = \Drupal::theme()->getActiveTheme()->getName();
  $system_region = system_region_list($theme, REGIONS_ALL);

  foreach ($system_region as $region) {
    $form[$region . '_title'] = [
      '#type' => 'textfield',
      '#title' => t('Form ' . $region . ' Title'),
    ];
  }

  return parent::buildForm($form, $form_state);
}


How can I access all values of a multi-value field?

To get all values of a multi-value field:

$node = $variables['node'];
$values = array();
foreach ($node->field_name->getValue() as $value) {
  if (!empty($value['value'])) {
    $values[] = $value['value'];
  }
}

OR

$node = $variables['node'];
$values = array();
foreach ($node->field_name as $item) {
  if (!empty($item->value)) {
    $values[] = $item->value;
  }
}


Translating pages, only the last version remains

The problem is the 'synchronize translations' submodule of i18n was enabled.
I took the privilege of disabling it on your test site.
I know multilanguage is a tricky part in D7 but you should start with the basics of multilanguage by enabling locale, content translation, Internationalization, block languages, multilingual content and string translation. Just to get a feeling of what you're doing.
Later on you can activate some other submodules of the i18n module but in my opinion it is never a good idea to activate all at once. Activating to many modules at once can result in losing control of your installation like you're having right now.


Automatically import data from Google spreadsheet using feeds module

Sorry, bit late to the party. How I solved this was:

Publish the file to the web using the option in Google Sheets' file menu. This gets you a special link to an always up-to-date version with the format of your choice. I used CSV.
Select HTTP fetcher as fetcher.
Select appropriate parser (CSV in my case) and set up mapping
Set up periodical imports.
Enter the URL you got from Google Sheets as source when importing.

Your updates to the Google Sheets file will be imported with the periodical imports.


How to render / preprocess list of entity reference nodes?

As per @Clive comment, Fences module may be able to help with that.

A quite straightforward option would be to implement hook_node_view() in a custom module and add a #prefix and #suffix to the field element (prefix of <div class="foo">, suffix of </div>)


How to create a view to display event registrants?

For displaying user entries only one, open the  Query settings: Settings located at bottom of the Advance section.
There u can check the Distinct checkbox which will make the view display only distinct items.

Hope this help you...


After deleting all nodes, how do I reset the node ID to start from 1 again?

ALTER TABLE `node` AUTO_INCREMENT = 1;

P.S - Others who have replied on this question: I just did a small check after deleting content and the associated content is indeed deleted, node_revisions and field_* tables are empty. node_delete says the same - http://api.drupal.org/api/drupal/modules--node--node.module/function/node_delete_multiple/7

Sometimes on migrations projects when you migrate from other platforms (ex. ASP + MSSQL), sometimes it becomes unavoidable to reset the nid due to lot of factors. I am sure it could be avoided but time/code tradeoff is always there.


How do I use a preprocess function for a node template?

Instead of using print_r() enable devel module and their new submodule called kint. And use kint() instead of print_r(). You can also use print_r() but is messy.

  How can I preprocess my variable array for a node template?

function YOURTHEME_preprocess_node(&$variables){
  kint($variables);
}

If this does not work it might be a cache problem.  I will recommend you to set you website into dev mode using DrupalConsole. drupal site:mode dev

Why ?

  The Twig engine provides options for configuring debugging, automatic
  reloading (recompiling) of templates, and caching compiled templates
  in the filesystem. By default, the Twig theming engine compiles
  templates into PHP code and stores the compiled code in memory.
  Compiled code is unsuitable for development, since changes in Twig
  templates are not immediately updated in your Drupal site. Twig cache
  can be cleared through Drupal's clear cache interface, but for ongoing
  development it's easier to change Drupal's settings so that Twig
  doesn't cache anything at all.

Running  drupal site:mode dev will disable all twig cache. For more information about debugging please visit - Debugging compiled Twig templates


How do you use hook_query_alter to get inside a query's creation?

Just to close this item out: It appears that my definition of hook_query_alter was, in fact, working correctly.  My problem was in assuming that I would be able to do things like  dsm($the_query) and see the components of the query object in preparation for doing stuff with them.  This doesn't seem to be the case -- dsm() wasn't returning anything of real use other than alterTags, but the orderby() (and other similar actions) did in fact alter the query.  So, I'd argue that it's a bit confusing, but works-as-designed, I guess...


How to reset validation errors in ajax callback?

You need to set limit_validation_errors to an empty array for it to ignore the rest of the fields in the form.  Here's an example:

  $form['a_field'] = array(
    '#type' => 'button',
    '#limit_validation_errors' => array(),
    '#value' => t('Click here'),
    '#name' => 'a_field',
    '#submit' => array('my_submit_function'),
    '#ajax' => array(
      'callback' => 'my_function',
      'wrapper' => 'my_wrapper',
    ),
  );


Addressfield module depends on the country for displaying the right structure of the form that is configured by the plugin, I'm afraid country is mandatory so you can just select one in the field settings so you don't have the selector, then you'll need to do some theming magic for hiding it when it's displayed


An AJAX HTTP request abnormally terminated in autocomplete textbox

i am using the following code to auto complete the name of the partners (store owners) in a search box in a form to edit a store's detail (not all form elements used are shown here):
the auto_complete call back returns the list of all the partners in the database.
(here one partner owns one store)
you could try and workout something similar:

the submit button links to a submit handler that updates the database.

function partner_store_form($form, &$form_state, $sid = 0) {
      $edit = NULL;
      if ($sid != 0) {
      $query = db_select('store', 's')
        ->fields('s', array('partner_pid'));
      $query->leftJoin('partner', 'p', 's.partner_pid = p.pid');
      $query->condition('s.sid', $sid);
      $query->addField('p', 'name', 'p_name');
      $edit = $query->execute()->fetchObject();
      }
      $form['pid'] = array(
        '#type' => 'textfield',
        '#title' => t('Partner Name'),
        '#size' => 30,
        '#required' => TRUE,
        '#default_value' => isset($edit) ? $edit->p_name . "  [Id:" . $edit->partner_pid . "]" : '',
        '#maxlength' => 96,
        '#autocomplete_path' => 'partner/autocomplete'
      );

      $form['submit'] = array(
        '#type' => 'submit',
        '#value' => isset($edit) ? t('Edit') : t('Save'),
        '#submit' => array('partner_store_form_submit')
      );
    }

    ----------

    $items['partner/autocomplete'] = array(
        'title' => 'store autocomplete',
        'page callback' => 'partner_store_autocomplete',
        'access arguments' => array(CONST_PERM_LIST_PARTNER),
        'type' => MENU_CALLBACK,
      );

    -----------------

    function partner_store_autocomplete($string) {
      $store = array();
      $query = db_select('partner', 'p');
      $return = $query->fields('p', array('pid', 'name'))
        ->condition('p.name', '%' . db_like($string) . '%', 'LIKE')
        ->condition('p.remove', 0)
        ->execute();
      foreach ($return as $field) {
        $store[$field->name . "  [Id:" . $field->pid . "]"] = check_plain($field->name);
      }
      if (empty($store)) {
        $store[''] = t('No Such User');
      }
      drupal_json_output($store);
    }


Drupal 7 - How add posfix '.html' to all paths?

AFAIK, it is not possible to simply configure Drupal for that. If you serve your Drupal site with Apache, you can configure mod_rewrite to remove the .html suffix. But you will not be able to configure Drupal to add it to the links it produce.

In a custom module, you could implement hook_url_inbound_alter() and hook_url_outbound_alter() to remove/add to .html suffix to all paths.


Allow users to sort stories by date or content type

i think you might be confusedly mixing a few different concepts?

"story" is one of the default/example content types distributed with Drupal and is nothing special, ie. not quite sure what you mean by "story view".

I assume from the way that you're phrasing your question that you're new to Drupal, have you discovered Views and CCK?

exposing filters is relatively easy in Views 2 and 3, but exposing sort options in general is more difficult in Views 2 (you'll probably need some basic PHP knowledge to achieve this) but can be done through the UI in Views 3.

popup calendar widgets for date fields exist in the Date module once you install the jQuery UI module.

if you want a calendar widget that is "inline" (doesn't popup from a dropdown menu) then you'll likely have to do a little coding, but it isn't very hard as jquery UI provides a good API for inserting calendars into your page.


How to get the NodeID from ItemID of connect Item from Field Collection

you may want to try hostEntity() method (link)

  Returns the host entity, which embeds this field collection item.

Then you'll be able to extract nid from the result returned by hostEntity().

but it is not clear what are you loading with field_collection_item_load($did);

is $did the id of the field_collection item - meaning the field collection and not the field in it? if so, than you can do something like this

$entity = entity_load_single('field_collection_item', $did);
$host_entity = $entity->hostEntity();
$nid = $host_entity->nid;  // returns node id of the node that hosts given field collection


This is because I have search specific caching enabled on the view. This is a Search API caching plugin for views which caches both the results of a query and the HTML (I think).

So when a query is repeated it returns the HTML and doesn't load the entity objects. Because that's the entire point of the cache! (In fact it skips the entire view generation, i.e. both hooks like module_views_post_render and theme_preprocess_views_view)


How to catch twig errors and display custom 500 error page?

Just checked, there is no special handling of Twig exceptions in core, so they end up in FinalExceptionSubscriber. You can add a custom exception subscriber catching Twig_Error_Loader or Twig_Error_Syntax and return a themed response (though you might need to theme this yourself when the theme layer is broken because of the Twig error).

error.inc has nothing to do with this as long as there is no fatal error not catchable by Symfony (but this would be a failure of the Twig layer, which normally protects you from low level errors)


You're really just passing an argument ("john") to a view (or multiple views, view blocks, etc.) to control what content is being displayed. I'm sure there is a way to do this in domain access but you can bypass that overhead by adding the logic in the view itself as a contextual filter. In rough detail:

Create your view listing the content you would want to show
Add a contextual filter based on Content: Author uid, and select 'provide default value'
I would recommend using 'PHP Code' to provide your default value and having it return value from a custom function which you can place in a module for better maintainability, ex: return _my_custom_function();

Your custom function should be returning the UID of the user you are looking for and could look something like this:

function _my_custom_function() {

  $domain = $_SERVER['server_name']; //reserved php variable
  $host = explode('.', $domain);
  $subdomain = $host[0]; // probably a more elegant regex to use here..

  // your code here that takes the subdomain 'john', sanitizes it, runs security checks, then pulls the uid for this username from the user table or wherever

  return $uid;
}


How to show fields of referenced entity when referencing entity is being loaded?

Depending on where you want to create the block/ show the information the way to retrieve the data from the referencing node may vary. Here's a simple example for rendering from within a node.tpl.php:

$referenced_node=node_load($node->reference_field['und'][0]['target_id']);
print drupal_render(field_view_field('node', $referenced_node, 'field_something', 'displayname'));

This solution makes use of standard Drupal rendering methods/ display suite rendering for your referenced node. Change displayname to the proper display you want to use for rendering, you might want to add a custom one with different settings.


How to open various files(image,video,txt) as pop-up on the current browser page instead of opening in separate page?

What you're describing is a modal window. There's a few modules out there for Drupal that create modal windows. The one that probably best fits your use case (media consumption) is Colorbox. Out of the box, it only handles images but there are a number of supporting modules that can handle other media files. See the Colorbox project page link for more information.


Which Drupal log file is available to proof when exactly some content was deleted and by whom?

Check out their http://example.com/admin/reports/dblog. You should have messages like this one:

Type        content
Date        Wednesday, June 5, 2013 - 09:11
User        admin
Location    http://localhost/node/1/delete
Referrer    http://localhost/node/1/delete
Message     page: deleted test.

For future, you can use hook_watchdog()

  This hook allows modules to route log events to custom destinations, such as SMS, Email, pager, syslog, ...etc.


Automatic username generation from name fields at registration

This is an interesting case in Drupal 8. Previously we could look at the user registration form's validation processes, which in Form API were callback strings in the #validate property array (or attached to each element in the #element_validate property. Note that the Drupal term "element property" means an item in a form array prefixed with a "#".

A basic strategy is similar: alter the form's #validate property and add, not replace, a string referencing a valid PHP callable. Again, probably best to re-order validate callbacks for first-in, first-out.

// Probably best to add this as the first element of #validate
$form['#validate'][] = 'my_register_form_validate';

Then implement the function or callable.

function my_register_form_validate($form, FormStateInterface $formState) {
  // This should do the trick.
  $formState->setValue('name', $name);
  // But you might need to get the entity from form state storage?
}

But we also need to make sure that the user account form doesn't let you change user name, of it does, then add the same validation/form alter.

In Drupal 8, entities often have their properties validated not in the form but as part of Symfony Constraints as part of their Typed Data data definition. This is so that Drupal is more API-first rather than form-driven (like in Drupal 7).

So I think you're on the right track to look kind of into user_validate_name, but it appears to be unused except in the installer. I think that modifying the entity's base field definition and adding a new constraint would work too.

To do this implement hook_entity_base_field_info_alter. Also see the following question How to easily alter an entitys base field definition per bundle?.

function my_register_form_entity_base_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'user') {
    $fields['name']->getConstraints()
  }
}

Then implement a Constraint plugin and its corresponding ConstraintValidator class. The ConstraintValidator class might have a validate method like this:

public function validate($items, Constraint $constraint) {
  // The entity should be available on all fields as a parent typed data via FieldItemListInterface::getEntity method
  $entity = $items->getEntity();
  // Generate user name as say $name.
  $items->set($name);
}


The 'managed_file' FormElement plugin specifically stores the uploaded file as a managed file entity. This plugin stores the file entity id inside form state value as part of its validation.

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    drupal_set_message($this->t('@can_name ,Your application is being submitted!', array('@can_name' => $form_state->getValue('name'))));
    // Use the fid to load the file entity. Unfortunately ManagedFile loads the file entity, but does not store it in form state.
    $fid = $form_state->getValue('resume');
    $file = \Drupal\file\Entity\File::load($fid);
    // Do something other than "echo" $file->getFilename() here.
  }


Redirect user back to the private page after they have logged in

For logindestination to work properly all you need to do is add an entry using <current> as the redirect location.  Leave the "Redirect to Page" option as Internal page or external URL.  This configuration will send a user back to the page they were trying to access before being sent to the login page.


How do I know what setSetting is suppose to be?

You can look at the source code of the corresponding field type class to get an idea of the available settings.

target_type is something specific for an ER field

Base classes for field types provided in Drupal core

Almost all field types are derived from one of the above base classes, e.g. there are several number field types deriving from NumericItemBase

Custom field types are usually located in module_name/src/Plugin/Field/FieldType


Clean urls working everywhere except my custom module

Turns out the issue was in my company's custom configuration. Certain pages are routed via Drupal while others are handled by a legacy system. All I had to do was add my module's path to our config and everything works now.


Custom theme function and template suggestion

/**
 * Implements hook_theme().
 */
function mycustomtheme_theme($existing, $type, $theme, $path) {
  return array(
    'custom_function' => array(
      'template' => 'my-template',
      'path' => path_to_theme(),
    ),
  );
}

OR for the my-template.tpl.php file is in the module directory

/**
 * Implements hook_theme().
 */
function mycustomtheme_theme($existing, $type, $theme, $path) {
  return array(
    'custom_function' => array(
      'template' => 'my-template',
      'path' => drupal_get_path('module', 'mycustomtheme'),
    ),
  );
}


I disabled a module and my website turns into code

Try using Drush if you have installed it.

> drush dis your_module_name
> drush cc all


What (basically) does views/includes/plugins.inc line 9 views_include('base') actually do?

From views.module:

/**
 * Include views .inc files as necessary.
 */
function views_include($file) {
  static $used = array();
  if (!isset($used[$file])) {
    require_once './' . drupal_get_path('module', 'views') . "/includes/$file.inc";
  }

  $used[$file] = TRUE;
}

so to your question, it is trying to load up base.inc out of the Views module includes directory.  Unfortunately, for whatever reason, the views module itself doesn't appear to be loading up (and thus defining the function to begin with).


Using ajax to filter drupal autocomplete form

I know it's too late but for others who might find this questions, the answers are here:

form auto complete how to restrict results by previous drop down

and

Dynamic select list in the form (dependent dropdown)


You can use drupal_goto("custom 404 page") to redirect a user to your custom page. For your second question you can check if user is anonymous using this condition. if($user->uid == 0)

Thus your hook can be rewritten like this.

function MODULE_NAME_node_access($node, $op, $account) {
  global $user;
  if ($op == 'view' && $node->status == 0 && $user->uid == 0){
    drupal_goto("custom_404_page");
   }
}

See here for drupal_goto documentation

Note: This function has been removed in Drupal 8. In Drupal 8 you can do this by this way.

return new RedirectResponse(\Drupal::url('user.page'));

or this way
`use Drupal\Core\Controller\ControllerBase;

class MyControllerClass extends ControllerBase {
   public function foo() {
   //...
   return $this->redirect('user.page');
  }
}`

See here for Drupal 8 redirect info


Views to display different text than field

"To display Yes or No for field_url" - I done something similar to this but with Drupal 6 and Views Custom Field.

So for Drupal 7, I think you need to use Views PHP and add Custom Field:PHP field in your view and make conditions.

<?php

$static = $this->view->display_handler->get_handlers('field');

$x=$static['tid_1']->last_render;
$y=$static['tid_2']->last_render;

if($x !== null)
{
echo ""."Yes"."";
}
else
{
echo "NO";
}

?>

note: tid_1, tid_2 are field tokens, instead change it with your fields token.


Is the block appearing as part of the view, or just in the Colorbox? If it's just showing in the colorbox, and you go into Structure > Blocks, you should see that "HR Admin" block listed - you can set it to show only on the pages where you want it to appear. You can read about the visibility settings in the Block documentation. If it is appearing in your view, you may have to give more details for troubleshooting.

This answer may help: How to disable a block on a certain view?


How to find the image cache url for images

You can use the imagecache_create_url() function:

$path = imagecache_create_url($presetname, $filepath);

$presetname: String specifying an ImageCache preset name.
$filepath: String specifying the path to the image file.


Why do I get errors abot undefined variables and errors with unserialize()?

The best way to get the issue resolved would be to file an issue for the Commerce Kickstart project on drupal.org.

The reason you're receiving those notices is because ideally, in a perfect world, line 1305 would say something like this (to avoid such notices):

  if (function_exists('i18n_string_update') && isset($instance['widget']) && isset($instance['widget']['type']) && $instance['widget']['type'] == 'link_field' && isset($prior_instance['settings']) && isset($prior_instance['settings']['title_value']) && isset($instance['settings']) && isset($instance['settings']['title_value']) && $prior_instance['settings']['title_value'] != $instance['settings']['title_value']) {

But as you can probably see, that if statement is now twice as big. And since it's only a notice you're receiving, chances are the developer(s) won't put that issue as a top priority.

The easiest way to resolve the issue on your own though is to set the value of error_reporting to E_ALL & ~E_NOTICE inside your php.ini file, like so:

error_reporting = E_ALL & ~E_NOTICE

That should suppress all notices that you might be seeing, including the third notice regarding unserialize.

Hope that helps... :)


Ambiguity of using '.' as a separator in the site directory name might have security implications?

Your virtual host rules are as secure as you've written them. If you want complete control on what URLs map to what multi-site installations then use the sites.php placed in sites/sites.php of your sites folder to explicitly set what URL(s) go to which Drupal installation using PHP.

The sites.php file resolves the URL -> site mapping after the webserver directs traffic to Drupal.

EDIT

Drupal can be run in multi-site or standalone. This is accomplished on how you configure your webserver. The "problem" you're describing is you want to use multi-site but not have Drupal try to discover invalid site addresses. This is purely dependant on how you setup your webserver.

An example of how to setup Apache for multisite might be:

<VirtualHost *:80>
  ServerName example.com
  ServerAlias *.example.com
  DocumentRoot /var/www/example.com
</VritualHost>

This will resolve example.com to the docroot and any subdomain site at *.example.com -- including "invalid" subdomains which may not exist and attempt to route to an invalid url as you've described. This is by design by Drupal when using multi-site installation.

How might this be fixed for Apache? By fixing Apache vhost entries to limit what valid domains the virtual host is used for. This is not necessarily fixable via Drupal (although I still like using sites.php personally).

For instance we can change our virtualhost to the following:

<VirtualHost *:80>
  ServerName example.com
  ServerAlias site1.example.com abc.example.com xyz.example.com example
  DocumentRoot /var/www/example.com
</VritualHost>

This revised Apache virtualhost routes example.com and exactly 4 subdomains and no others to the docroot. No other domain traffic will be routed to this drupal installation from the webserver.

A similar technique should be available for most webservers. Your virtual host rules are as secure and as organized as you've written them for your own production servers. I use Nginx as a proxy for Apache on a few websites, and Nginx as the sole webserver for at least 1 site, but I haven't had to try to solve this problem myself using only Nginx (but I'm familiar with the Apache solution above).


Why do I get this error when I save my custom field?

Use the Json class in core, it’s set up to use associative arrays (rather than the default object from json_decode, which is causing your current issue):

$decoded = \Drupal\Component\Serialization\Json::decode(...);


Fatal error: Class name must be a valid object or a string

The function entity_get_info() is responsible for gathering up this data about your entities. I would try to debug that one, and see what goes wrong.

You will want to have just cleared the cache when you do this, or you debug results will not be correct.

Can't think of a better answer to the question that is still generic enough to be useful for someone else.


No. The whole point of EntityFieldQuery is that it is SQL-agnostic, so you can switch from MySQL to MongoDB for example, and it still works.


Can we use current views exposed filter values to prepopulate another form?

After googling this question some, I came up with the following receipe:

Install prepopulate and exposed filter data
Modify exposed_filter_data.tpl.php provided by exposed filter data to produce a dynamic prepopulate URL for creating a new user

Hope this helps!

P.S.: Inspired from this discussion => https://www.drupal.org/node/1630198


Fatal error: Declaration of ... must be compatible with

BlockBase implements BlockPluginInterface, which defines blockForm() as follows:

public function blockForm($form, FormStateInterface $form_state);

Interfaces are like contracts. Any class that implements an interface (or one of it's descendants) must define all the functions in the interface, and they must be defined exactly as in the interface. This is so that developers can replace classes, but ensure the code will still work, since the function definition will always expect the same values, as defined by the interface.

When you add a typehint to force $form to be an array, you break the contract of the interface. The interface says that any value should be allowed for the $form argument, but you are saying it must be an array. If you used your code, and a function passed a non-array value, it would cause an error. The interface is there to prevent such errors from happening. This is why you cannot change the function definition.


How to render a DS fieldgroup programmatically in a node template?

node_build_content is probably not suitable for your use case. However you should use node_view instead which calls node_build_content anyway but returns you the actual renderable array after it processes it and sends it through an alter as well.

For example:

function mytheme_preprocess_node(&$vars) {
  if (!empty($vars['node'])) {
    $node = $vars['node'];

    if ($node->type == 'my_content_type') {
      $vars['content'] = node_view($node); //optionally supply view_mode as a second argument
    }
  }
}

Now you can just drupal_render($content) from your node template.


How to put a custom message in the message module template?

Checkout the setArguments(), getText() and the processArguments() function in the Message Entity class:

$message = Message::create(['template' => 'sfbu_progress']);
$message->setArguments([
   '@my_argument' => 'my_argument_value',
]);
$message->save();

And in your Template which you create over the UI write the @my_argument to the textarea. It should be replaced with your text.

It is also possible to add an callback function as argument. Therefor checkout the declaration of the argument property in MessageTemplate Entity class.


I have never used this module, but seems to do what you want: Read only mode.


You can list the number of results instead with a snippet of php code in the header:

<?php
  $view = views_get_current_view();
  print $view->total_rows;
?>

Learned this trick from: https://stackoverflow.com/a/2989197


Trigger a JS function only if the view has no more results. or is empty?

All you have to do is check if the "load more" div does not exist. (check if the load more button is no longer there).

(function ($) {
    $(document).ajaxComplete(function() {
               if ($(".loadmore").length = 0){
                   // do something here
               }
    });

})(jQuery);

Check the actual name of the load more div, I just made it up for this example


Manual crop is not working when authenticated user adds a new content

Manual Crop (currently) doesn't have any permissions of itself, the File entity permissions are only required if you're using the Media module.
If you're using an administration theme for node adding and editing, then the users that are allowed to edit nodes should have access to it.


How do I invalidate cache of an embedded view?

Try to use buildRenderable(), that should ensure that the necessary cacheability metadata is added automatically.

$vars['content'] = $view->buildRenderable();

Hint: You might be interested in my Views Custom Cache Tag project. The node_list cache tag is invalidated every time any type of node is saved, even though your view only changes when an event changes. Using that module and a bit of custom code as shown on the project page, you have fewer cache invalidations and better performance.


How to wildcard cache clear in Drupal 8?

Not sure why the existing answer was deleted, it was (almost) correct.

Wildcard cache clears was removed. It was extremely complicated to support in backends like redis and memcache, which have no wildcard support.

Cache tags is the replacement and it is not that complicated to use. You just pass along a list of strings as the 4th argument (a bit annoying that you have to set the default timestamp argument, a separate method would be nice):

\Drupal::cache('default')->set('state:info', $your_data, Cache::PERMANENT,
['state']);

and then call:

\Drupal\Core\Cache\Cache::invalidateTags(array('state'));


Slideshow caption when logged in displays in different location when logged out

You are checking your CSS by log in as an administrator. Try those of you who have Google chrome installed.

Go to Option
Open a new incognito window (or shortcut Ctrl+Shift+N)

and check your css there when you logged in as an administrator. The extra space your slogan is getting is due to the edit this link and all other links which are for administrator use only.For a normal user these links are not available (which is the case when you logged out) so it works fine.


The solution was to use the hook_node_prepare($node) and there to check
     if (!empty($node->translation_source))

The above are the conditions that must be filled in to be in the "add translation" event.


How to create dynamic select option field in webform module

Go to Modules > Webform and see what version it is. If it is version 4+, as RoloDMonkey has mentioned, than conditionals are built in. If your Webform module isn't 4.x then I suggest updating it so that you can use this feature.

Go to Content and find your webform and open it.
Click "Webform" tab
Click "Conditionals" link
Click the (+) button
Implement the logic:

If "[select question that has the conditional answers]" is "[select name of answer that opens the textbox]" then "[name of textbox]" is shown
If "[select question that has the conditional answers]" is "[select name of answer that opens the selection menu]" then "[name of selection box]" is shown.

Make sure you have all possible options set up already in the webform before applying the conditionals.

Here is a demo someone built using Webform Conditionals:
http://www.sixmiletech.com/node/15


How do I move files and directories after installation?

I would expect you just need to clear (or 'rebuild' as it is often called nowadays) the cache, as 4k4 is suggesting in a comment.

There are several ways you can do that:

The "built-in" option is to go to /admin/config/development/performance and hit the clear cache button there.
Another popular option is with drush, where you could issue drush cr to rebuild the cache from the command line. Your site or server would need to have drush installed, though. It can be a lifesaver if for whatever reason you can't get to the UI page, though.
In a similar vain, drupal console (a tool quite similar to drush) can do the same thing, with drupal cache:rebuild, drupal cr or drupal cc.
If you are running with the default database cache mechanism, you can truncate the tables that start with cache_ as their table name. Treat this as a last resort, though, and do make a backup in case you make a mistake. In particular, do not truncate the cachetags table.


See the CCK Fieldgroup Tabs module for Drupal 6. It displays CCK fieldgroups in tabs. Enables splitting up content onto tabs in both editing and display.

Note: For Drupal 7, see the Field group module, which includes tabs support.


How to take the node reference field from views

What you do is set up a relationship, as the image itself isn't the node reference, rather a field in that node.  So, you go into Views and after setting it up to grab your article fields, you then set up a relationship, and there, you select that node reference field from your article type.  Then, in fields, you go and select that image field, and there, you use that relationship.  What this does is go and grab that image content type's node id from your article and then using that node id, grab the image field out of it for display.


How to display a BACK button but ONLY if the user came from somewhere else on my site

There are many ways to do this.
One of it would be to use $_SERVER['HTTP_REFERER'] to detect where the user comes from.

Put the following code in your template file.

if (strstr($_SERVER['HTTP_REFERER'], 'facebook.com') !== false) {
     // Facebook brought me to this page.
     print 'Go Back';  }


I have found a module called openid selector that does exactly what I am looking for.


How to use a block as a field in Drupal 7

No, fields are totally independent concept than blocks. Of course there is a way to have a region inside field, and you could then drop that block to region, but there would be no connection between block's uploading capabilities and created node.

If you have a fancy file uploading requirements, it would be better to write them down and ask what module can do it for your file or image field.


Go to admin/structure/menu/manage/main-menu (drupal 7) You can drag the menus to set the order. Or give then weight.


You currently cannot use MongoDB for all your data. The MongoDB module clearly states what it can store in your mongodb: Cache, Field storage, Session, Watchdog, Lock, Block and Queue. This cover most of your site data. But a SQL database will always be needed.

This tutorial gives configuration to put in your site settings.php to enable various MongoDB storage. But it may be outdated.


How do I pass a value to a content type field with a custom submit please

I guess you have multiple options.

You set the field value in the alter as a #value, this is not editable by the user, not like #default_value. Then drupal will save it automatically on successful save.
You set the field value in the validate callback into the $form_state variable. Not too elegant, but the drupal will save the value automatically (normally) on successful submit.
You create a custom submit (as you did) and then you load your node (D7: node_load($nid) D8: \Drupal::entityTypeManager()->getStorage('node')->load($id);), set the field value (D7: $node->field_name[LANGUAGE_NONE][0]['value'] = 'something'; D8: $node->set('field', 'field_value');), and then save the node (D7: node_save($node);, D8: $node->save();).
You can use hook_ENTITY_TYPE_insert() to update your field and save the entity again. (https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_ENTITY_TYPE_insert/8.2.x)
You can use hook_ENTITY_TYPE_presave() you just set the field value here, you don't need to save it. Drupal's next step will the save. (https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_ENTITY_TYPE_presave/8.2.x)

For D8 a bit more detailed: https://www.heididev.com/how-programmatically-update-fields-value-drupal-8
And also, maybe the entity is already loaded, check this: https://www.drupaleasy.com/quicktips/drupal-8-getting-entity-id-formstate


Dynamically modify number of columns in view, responsive layout

I can't see the Hulu link, I'm not in the US, so I can't comment on the slideshow aspect.

I have used Display Suite to create my own layouts and Panels to access the responsive layouts within Adaptive Theme (AT Commerce) because Display Suite layouts are not responsive. I enabled only the core Panels module, trying to do the same with Panels got messy and Display Suite allows you to draw in fields from various sources.

There is a great series of tutorials on using Display Suite here: http://www.youtube.com/playlist?list=PL7E361A55994F1648

You can also use Flexslider to make your images responsive


How to check which enabled modules are really used?

It sounds as if you're installing modules on a production site willy-nilly, just to try them out.  I suggest you stop doing this.  While people like me earn some of our living from helping the owners of such garbage piles sort through their wreckage, I'd rather get paid for building stuff than for cleaning up.

Instead:

Set up a staging site for testing stuff. Only deploy on the production site if it is proven useful.
Keep a log of everything you deploy on the production site, with details about when and why. Log also when you disable and uninstall, so you don't forget and make the same mistake twice.

The above is absolutely essential if more than one person runs the web site - but I've found it helpful even if there is only a single webmaster that does it all.

There is really no way of keeping tabs on "what you really use" automatically or semi-automatically. Configuration management is just one of the tasks a webmaster is supposed to do as part of a honest day's work.


How can I show the Sales Report for particular user?

Attempt to answer the "Why does an affiliate get an empty report?" part of your question (which I believe is part of your question): could it be related to some "permission" you have not granted to an affiliate (yet)?

Here are a few links related to permissions that may be helpful:

Drupal Commerce issue nr 1303194.
What's the explanation for my product permission issue in a Drupal Commerce view? (and/or some of the "related" questions there).


How to validate a field value programatically in Drupal 8?

The $form_state now become a classed object as documented here

You can use getValue() to get field value instead of converting it into an array

$form_state->getValue('name');

instead of:

$form_state = get_object_vars($form_state);
$name = $form_state['values']['name']);

Same thing for form_set_value.

And form_set_error() became $form_state->setErrorByName().


You could use hook_form_alter() to change the field type for the field you want to hide to "hidden". The code would be something like this:

mymodule_form_alter(&$form, &$form_state, $form_id) {
  switch($form_id) {
    case "user_register_form":
      $form["fieldname"]["#type"] = "hidden";
      $form["fieldname"]["#value"] = $form["fieldname"]["#default_value"];
      break;
  }
}

This function will get called for every form displayed, so the switch statement makes sure it's the right form. That being the case, the next line changes the type of the field to a hidden field. Finally, it copies the default value of the field into the actual value (hidden fields don't have a default value).

Unfortunately I don't know what the name of the field you want to change is, so you'll have to investigate that.

Hope this gets you on the right track.


Creating a node with multiple joined fields

I'd recommend keeping the contributors separate with their own fields. In order to edit them on the one form you can use a number of different modules. We use Inline Entity form.
https://www.drupal.org/project/inline_entity_form


The D8 Editor File upload is using the Drupal file system, so the files uploaded through module do have FID and can be listed in Views.

Here are steps to create a block to show only the files used on the currently visited node:

Create a View of type File with a Block display showing Filename (you probably have this already)
Add a Contextual filter in your Views Block Display called Entity ID from the File Usage Category.
Adjust the settings for that Contextual filter:
When the filter value is NOT available
Provide default value
Type to Content ID from URL
When the filter value IS available or a default is provided:
 Specify validation criteria
 Validator to Content
 Content type [choose appropriately]
 Leave the rest as default
Place the Block in a region you like, adjust the Block options File Usage: Entity ID to Node from URL and restrict to display only on relevant Content types.

Now when you visit nodes of the types you selected in Block and Contextual filter settings will list only the files uploaded to those nodes.


Two ideas:

(1) Expose the sort to the user to allow them to control sorting. You need to enable "Expose this sort to visitors, to allow them to change it" for the sort criterion in views. See below for more detail on how to get the two sorts grouped together.

(2) Present the data in a table and make the columns you want the user to be able to sort, "sortable". You'll find this option under Format: table > Settings.

With both approaches, you can set an initial sort, so the user will see content in the order you wish when the page first loads.

Edit: more detail for #1: by default, views will sort the output based the first sort criterion, and clutter the exposed form with sort order controls. To get the default sort you want, and to clean things up, you can try:

Add both sort fields and expose to visitors (post date first)
Under exposed form options: enable autosubmit and hide the submit button
Under exposed form options: disable "Expose sort order"
Adjust exposed sort labels if needed for clarity

(exposed form options are in the Advanced section of the view)

When the view loads, the user will see a single select list that contains both sort options, and no submit button. The view will be sorted according to the first option.


Profile2_path form_alter - Anonymous user form - access denied problem

I set devel module permissions of 'Access developer information' to anonymous user .
Make sure to disable this module on a production site.


Formatting elements without formatting similar elements throughout entire site

while writing your css for any html element you  need to be more specific. Suppose you are writing a css for an h1 tag which you want to get applied on that tag only , then be more specific by giving the h1 tag an id or class so that this css do not apply on other tags .More over you can alos filter your result as shown...
eg you have a h1 tag in your header region eg.

 Hello There i am in header tag region 1

 Hello There i am in header tag region 2

 How are you I am not in header tag

CSS
h1 {                            for last h1
color :red;
}
header #first h1 {
color:green;
}
header #second h1 {
color:blue;
}

..
output
Hello There i am in header tag region 1 and i will be green
Hello There i am in header tag region 2 and i will be green
How are you , i will be red
................
now if you write your css in this way..
h1 {
color : #262626 ;
}
then it will get applied to all the h1 tags...so you just need to be more specific
you can also filter the tags by using pseudo classes...
you can learn about the css specificity on these links...

http://www.youtube.com/watch?v=0ZOV-KTTI1E

http://www.youtube.com/results?search_query=css+specificity&oq=css+spe&gs_l=youtube.1.2.0l4.1505.7011.0.9461.7.7.0.0.0.0.247.1042.1j4j2.7.0...0.0...1ac.1._LOJTw6jxBA


Template file for Views exposed filter block

Actually, although the exposed filter block does not have any template file in the list under Theming information, you can theme it with a views template file like this:

views-exposed-form--MYVIEWNAME.tpl.php

There is an example views-exposed-form.tpl.php in the Views module theme directory.


I think you should try something like this

function mymodule_menu() {
  $items['example/car/%'] = array(
    'title' => 'Example RSS feed',
    'page callback' => 'example_feed',
    'access arguments' => 'mymodule_abc_view',
    'type' => MENU_CALLBACK,
    );
    return $items;
}

function mymodule_abc_view() {
    return 'TRUE after checking something';
}

your URL should pass the car id or something to check the permission.


How to suppress output of  tags in a views2 field output?

You could go through the effort of overriding the template for that field, or you could just target the p tag with css and set the margins to 0px.

Views adds pretty granular classes to every field and row to make it easy to target.


Here are some links to some articles which might be helpful. I've been compiling them myself, to help figure out how to tackle the same issue you're having.

Exploring Deployment Methods

http://torylawson.com/index.php?title=Moving_Drupal_7_site_to_a_new_server
How to migrate from test environment to production environment?
Creating a Drupal development environment - achieving development, stage and production: http://groups.drupal.org/node/24196
http://developmentseed.org/blog/2009/jul/09/development-staging-production-workflow-problem-drupal/
http://www.slideshare.net/eaton/drupal-deployment-presentation

Moving Configuration out of the Database with Features

Bundling site settings using Features - http://drupal.org/node/580026
http://developmentseed.org/blog/2009/may/29/making-and-using-features-drupal/

Using Git with Drupal (http://github.com)

Drupal Git Tutorials List - http://drupal.org/node/1054594
Building a Drupal site with Git - http://drupal.org/node/803746
Drupal + Git database management - http://patrickavella.com/blog/git-drupal
https://stackoverflow.com/questions/5364498/drupal-on-git-what-to-do-with-the-database
http://www.opc.com.au/web-development/drupal-release-management-drush-and-git
http://www.viget.com/extend/backup-your-database-in-git/

Useful Contrib Modules

http://drupal.org/project/backup_migrate
http://drupal.org/project/features
http://drupal.org/project/drush


hook_boot runs on every page, even on cached pages. Implement it in a custom module.

Generally it's better to not require code to run on cached pages, but that's the best option you have, as opposed to hacking index.php. The primary problem I see with depending on hook_boot, is that you open your self up to a very simple denial of service attack. Anyone with curl and a shell can potentially bring your site down with much less resources when caching isn't used well.

One option to consider it relying on javascript to make a call the site via ajax. That way you can save yourself quite a bit of load on the server.


Some #states not working for custom field but do work on identical webform field

Webform form elements have additional goodies, not available in Drupal Core. But you can add those additional features with just a few lines of code:
<?php
public function buildForm(array $form, FormStateInterface $form_state) {
 $config = $this->config('custom_module');
 // Define the element(s).
 $form['nodes'] = [
   '#type' => 'entity_autocomplete',
   '#title' => $this->t('Select favorite articles.'),
   '#multiple' => 15,
   '#target_type' => 'node',
   '#selection_handler' => 'default:node',
   '#selection_settings' => [
     'target_bundles' => ['article' => 'article'],
     'sort' => ['field' => 'title', 'direction' => 'ASC'],
   ],
   '#default_value' => $config->get('nodes'),
 ];
 // Process the element(s).
 $this->elementManager->processElement($form['nodes']);
 // Attach behaviors. Unsaved: Warn users about unsaved changes.
 $form['#attributes']['class'][] = 'js-webform-unsaved';
 $form['#attached']['library'][] = 'webform/webform.form.unsaved';
 return parent::buildForm($form, $form_state);
}

Notice the elementManager->process() and the additional libraries. Watch the video in the linked blog post to get an idea where to get the elementManager and the libraries.
https://www.jrockowitz.com/blog/webform-apis


How to grant a role permission to edit terms in a specific vocabulary

The only module I can think of is the Taxonomy access fix module, which has only a version for Drupal 7.

  This module

  adds 1 permission per vocabulary: "add terms in X"
  changes the way vocabulary specific permissions are handled
  changes the Taxonomy admin pages' access checks
  alters the vocabularies overview table to show only what you have access to edit or delete

  The module does what native Taxonomy lacks: more specific Taxonomy permissions (and checking them correctly).


How to get node editing form in a custom module

15 is the node ID of the node whose edit form you want, not the actual ID of the form. This makes sense since node edit forms are defined per nodetype, not per node.

You'll need to call drupal_get_form() with the form ID, something like [nodetype_name]_node_form.

The second parameter should be the node object, e.g. node_load(15).


Creating a Feeds Plugin Child from a custom module and calling the new method

I have the issue fixed however this may not be the best method.  If you know what is then please let me know.

You can set a Plugin with 'setPlugin'

$this->importer->setPlugin('PreviewFeedsParser');

This wipes the config though.  So the following code shows - getting the config, setting the plugin and readding the config.

$this->importer->setPlugin('PreviewFeedsParser');
$this->importer->parser->setConfig($config);
$result = $this->importer->parser->parse($this, $result);


Webform data tables name change d7 to d8 tables to delete records from

I agree that you should use the 'Entity API' but if you are deleting 1000's of records I understand why you would want to do it using SQL.

Below are all the tables that are used to store webform submission related data.

webform_scheduled_email
webform_submission
webform_submission_data
webform_submission_log


How do I show the current node title in page.html.twig OR in node.html.twig?

The node is already available in the page template thanks to template_preprocess_page, so there's no need for the preprocess function. You can output the title with:

{{ node.label }}

The page title itself is a block, so if you don't need it any more just remove it from the region at /admin/structure/block. No need to copy the template to your theme or alter the original.


How to mock a node field value for phpunit?

The following should work using PHPUnit Mock Objects as in your example.

First mock FieldItemListInterface __get magic method.

$fieldDescMock = $this->getMockBuilder('\Drupal\Core\Field\FieldItemListInterface')
  ->disableOriginalConstructor()
  ->getMock();
$fieldDescMock->expects($this->any())
  ->method('__get')
  ->with('value')
  ->willReturn('blah');

Then mock the Node/ContentEntityBase __get magic method.

$node->expects($this->any())
  ->method('__get')
  ->with('field_description')
  ->willReturn($fieldDescMock);


Grant/restrict access according to node's author & moderation state

A helper module that I use for managing node access is ACL .

  The ACL module, short for Access Control Lists, is an API for other modules to create lists of users and give them access to nodes. It has no UI of its own and will not do anything by itself

What I suggest is that instead of handling the grants yourself, you outsource it to ACL. The module has a simple (YMMV) to use high-level API that let you grant individual users access (and revoke it).

The documentation is a little sparse, but on the ACL project page existing client projects are listed.  I learnt how to use it by reading the source code of those.

Alternatively, you can read the source code of ACL to see how to do low-level manipulation of permissions.

If you end up writing your own module, the introduction to this page gives a good introduction to how Drupal's node access system works.  In particular, you should be aware of:

  Node access modules always GRANT access and never restrict it. (It is a whitelisting rather than a blacklisting system.)

I understand you already use DNA (Devel Node Access), but if somebody else stumble across this: DNA (part of the Devel project) is absolutely essential if you are going to debug node access.


If it's an 'unmanaged' file, i.e one that doesn't have a database entry, you can use either

file_unmanaged_move or
file_unmanaged_save_data


CKEDitor removes class names, even with the exception in config

Go to "Admin >> Configuration >> CKEditor"; under Profiles, choose your profile (e.g. Full).

Edit that profile, and on "Advanced Options >> Custom JavaScript configuration" add config.allowedContent = true;.

Don't forget to flush the cache under "Performance tab."


I think you'll need to do some custom magic voodoo ;)

I built a similar site earlier this year:   The client provided a list of users (with their email addresses) in an Excel spreadsheet.  I created a new column with a unique 8 character registration code for each user.  I then imported that file, including the code, as new users.

The registration code was saved as a plain-text field in their user profile.

Create a custom user login form that only requires the registration code,  mail out the reg codes.


You can do it simply using hook_node_delete.

function hook_node_delete($node) {
  if ($node->type == 'any_content_type') { // for specific content type
    // here your code use $node->nid
  }
}


How to resize automatically when users upload images by CCK image field

Imagecache is great, but since it keeps the original file around, it won't save space. In fact, if you have multiple presets, it will increase your disk usage as it creates its caches of images of those sizes.

What you may want to investigate is putting some logic into nodeapi() (or, if on Drupal7, its equivalent function) when saving your node that looks at the filepath of whatever image field you are concerned with and does some image manipulation on it if it is over a certain size and then saving it in place.


Is there a safer way to make preprocess changes?

In an ideal world, you would create a sub-theme off of your master theme.  For example, most people don't use the Omega or Zen themes directly; rather they use the starter kit which is included as the basis for the sub-theme.

The sub-theme will inherit features from the base theme, but allow you to customize as needed.  When the base theme gets updated, the sub-theme doesn't get touched.

Whether you can retrofit your theme to actually be a sub-theme depends on your situation, but I suspect it is possible.


How do I update existing Nodes field through Import without having to delete all content and re-importing everything?

I'm pretty sure you'll be happy with the excellent Feeds module, which does this every day for thousands of sites. More advanced/customizable techniques are available with Migrate module, which always requires code, but gives enormous flexibility. Both will allow you to update existing nodes. Had you used them for your initial import, you'd be done now. I think you still may be able to use them as long as you have a unique identifier on your existing nodes.


Access currently logged in User profile from search index view?

I am assuming you are using views module to create this listing. In that case, this is certainly possible.

But first, I am not sure what you mean by current user. Is this the user who created the particular product? Or is it the currently logged in user?

If the user is the creator of the product node, just add a
relationship to the user using Relationships section in the View.
And then all the user profile fields will be accessible to you in
the Fields section. Easy.
If you're talking about the logged in user, then you can use views_php module. Install views_php and then add a PHP field to your view. In that field's output, write your php code which fetches that particular value. For example, the following code will give you the uid of the user. You can similarly extract more fields from his profile.

global $user;
echo $user->uid;

You can inspect this $user object using dsm(), which is provided by devel module to inspect where your field lies in this object.

One important thing, write the above code in the output section of the views_php field, and INCLUDE php tags.


How to make gmap marker tooltip display node title without tags?

Quote from the Comparison of mapping modules:

GMap is considered a legacy module.

So maybe you want to have a look at the IP Geolocation Views & Maps module. Partial quote from its project page:

Despite what the name may suggest, IP Geolocation Views & Maps (IPGV&M) is first and foremost a mapping engine.
The module makes it very easy to create Views-based mapping solutions using the map renderer of your choice (Google, OpenLayers or Leaflet) with any location storage module of your choice, e.g.:

Get Locations,
Geofield,
Geolocation Field
Location.

This allows you to bring together modules and feature sets that without IPGV&M you would not be able to combine.
Like beautiful animated marker clustering on Google or Bing or Mapbox ... any of various map providers.
But more importantly IPGV&M adds some features you won't find as conveniently packaged elsewhere.
These include marker differentiation based on field values or ranges (2nd screenshot) with or without font icons, various centering options, super-imposing the current visitor's location, allowing multiple content types to be displayed on the same map, full screen button and mini-map inset (bottom screenshot), polygon support (Geofield), marker tags and tool tips and cross-highlighting of associated content on the page when markers are hovered (and vice versa).

Head over to its (impressive) project page for even more information about it. That project page also includes various screenshots.


When does the computed field get calculated?

From  Computed Field Module:

Computed Field is a very powerful CCK field module that lets you add a custom "computed fields" to your content types. These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it. (Feeling the power yet? :) ) You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views. (Although you should note that Views use requires database stored values.) This field is literally the Swiss Army knife of CCK fields. So start cooking up your PHP based values!

In the documentation page ( http://drupal.org/node/126522 ) it also says:

When is the field actually computed?

If you wish to store the values in the database then you have to update or re-submit the node to compute the value of the field.

If it is not stored in the database then the value computes when the node loads and only when the node is loaded. The field will not work in views nor will it function properly if it depends on other non-stored computed fields.

More information from drupal.org and what appears to be a good page of snippets is http://drupal.org/node/149228


Dynamic loading using Tabs module and CCK Fieldgroup tabs

That example page uses Quick Tabs module.

  I want to dynamically load each tab
  only when it is clicked. How can I
  accomplish this?

Quick Tabs gives the option to dynamically load content with ajax. Here is demonstration linked to by the Quick Tabs project page. To get that solution please read the Quick Tabs documentation.

Yes, the example you give uses the Quick Tabs module. It says so in the markup. class="clear-block quicktabs_tabs quicktabs-style-excel ui-tabs-nav tabs primary"


There are multiple possibilities that may be causing your issue. So below is 1 hint for each of them to verify ...

Hint 1:

To simplify your debugging, just for temporary unit testing, add a Rules Action (as the very first Rules Action) to "Show a message on a site", e.g to say 'Bingo, let the Rules party begin (we did find a combination of Rules Conditions to continue building on)'. This is much easier to do debugging then the ultimate set of Rules Actions you want to get to work.

Hint 2:

Not sure if it is "the" reason why your rule doesn't work, but try to add an extra Rules Condition like ""entity has field" (for your field-paid field). And make sure this is added before any other Rules Condition in which you want to check the value of that field. The bets are open ...

Hint 3:

As per your question, your field-paid field can only have value "yes" (or no value at all I assume). So replace your last Rules Condition (= "not empty") by a "data comparison" (to check if the value is NOT "yes", and note the NOT-negation here). Also note that after you applied hint 1, the "entity has field" will contradict your "not empty" (so both Rules Conditions can never be true together, so your Rules Conditions would never be executed).


You can use dialog ui or colorbox, just attach this scripts to the page and add custom click event for menu item to open popup. Or you can use ctools but it's more complex.


The only solutions I know except coding it by yourself its Content Templates module. This module allows you to change the template directly from you back office.

The advantage it's that you don't need to deploy your code if you need small change.

You've also Display Suite that seems promising, I never tried but the description sounds good for what you need.


How can I check the value of an aggregated field without direct access to Solr?

There is a way to do this in Views.

Go to the search index config page (/admin/config/search/search_api/server/MYINDEX/edit) and selected Retrieve result data from Solr.  Then clear all caches a few times to be sure they are really clear.

After that, you can go back to the view and add the aggregated fields as Fields to the display.


How to hide custom fields on the registration form?

You can configure the registration form in "Manage form display" of the "Account settings":

/admin/config/people/accounts/form-display

Go to the bottom of this page and in "Custom Display Settings" enable the use of custom display settings for the "Register" form.

Then you get a tab "Register" at the top of the page. Here you can configure which fields are displayed.


Use orConditionGroup with query (non entity)

I was able to get it to work by added the select method to the connection object like so:

$orConditionGroup = $connection->select($table)
                    ->orConditionGroup()
                    ->condition('address', $fulladdress, '!=')
                    ->condition('full_name', $fullname, '!=')
                    ->condition('telephone', $workphone, '!=');


CKEditor: *During* WYSIWYG edit, how to show caption beneath image?

As of CKEditor 4.3, they now have widgets in the CKEditor side. They have introduced the Image2 plugin/widget, which supports image captions. The problem I've seen here is that Drupal has not caught up with this, so if you're using the media module for a file browser, it looks like that functionality is not yet ported to this newer version. However, if you just care about captions, it works.

See: http://ckeditor.com/addon/image2 for the plugin. I've been using it with the CKEditor Module, but it should work just as fine with WYSIWYG + Ckeditor Library.


Custom panels-pane tpl based on some identifier

After a lot of working around & trial & error methods, I got this.

Copy your "panels-pane.tpl.php" in your current theme's template directory.
include dpm($pane); in a php tag. This will give u the list of all the panes on ur current panel page.
Note down the pid ($pane->pid) here.

If you are looking for a particular page the unqiue identifier for that whole page would be did ($pane->did) which is the display id.
Basically, every panel page has a unique did (display id) & different pid (pane Id) for all the panes on that particular page.

Now in your "panels-pane.tpl.php" in the div code block with class="pane-content" you could write a php code like

if($pane->pid=='some id' & $pane->did=='some id') {
//modify your pane data from the variables at $pane->configuration & store in $content.
   $content = your modified data;
   print render($content); // render this pane with my modified data
else
print render($content); // (and) render other panes as normal
}


Changing the logic for an exposed taxonomy select in a view

You need to use hook_views_query_alter(). And the logic would be as below.,

Both -> Show only content tagged Both
When the user selects the Both, make no changes in the hook, just return the default result. So by this way the contents tagged under Both will be displayed.

Alpha -> Show only content tagged Alpha and Both
Now use the alter hook, by default the query will have alpha's tid in it. Here you need to add the Both's tid to the query. So now the Alpha and the Both will be displayed.

Beta -> Show only content tagged Beta and Both
Now use the alter hook, by default the query will have Beta's tid in it. Here you need to add the Both's tid to the query. So now the Beta and the Both will be displayed.

In simple term, just use the alter query and add the Both's tid to it. So that we will get the Both's content in all cases.


It depends on way how you made the redirection. Rules? Then add condition that tests user-agent and identify if it is not FB crawler. If you don't like PHP snippets you can do it by check Context which tests user-agent.


Change path prefix URL for multilanguage

your node edit link should be rather something like

www.mysite.com/zh/node/NODE_ID/edit

I guess you are using the alias of the node and you are appending "/edit", which would not work usually.


Default values for panelizer and fieldable panel panes

The methods hook_entity_insert() / hook_entity_update() don't check whether an entity has dedicated panelizer settings or not and just always saves the panelizer object found for it. Which can be the defaults of course.
The attached patch looks worse than it actually is. It basically introduces the property entity_custom_panelizer which indicates if a panelizer setting is dedicated to the entity or not.
And the hooks hook_entity_insert() / hook_entity_update() only save the settings into the panelizer_entity if the flag is set.
I really hope I didn't miss something but first smoke-tests look promising.


Site wont let me into administator areas

Why has it happened?

OpenAtrium is not a module, is an installation profile

You are mistaken an installation profile with a module. An installation profile contains the whole drupal core plus some extra modules and themes.

It means, you cannot put it in the modules directory of another Drupal installation. If you want to use an installation profile you do not need to use Drupal core.

How to fix it?

A: Re-install Drupal using OpenAtrium

If you want all the features in Open Atrium and you do not care about your current website, you'd better delete the whole thing and re-install Drupal using OpenAtrium.

Extract the content of OpenAtrium package to your document root (which is /Applications/XAMPP/xamppfiles/htdocs/ in your case). Then install it again.

B: Remove OpenAtrium and keep the current installation

If you already have a working Drupal installation and want to keep it, first you will need to remove OpenAtrium package out of it. There is no way you could use an installation profile along side a current installation.

First remove all the OpenAtrium files.

Then clear all caches. You can go to database and clear the content of all tables starting with cache_.

To access database you can use phpMyAdmin in browser (learn how) or an app like SequelPRO.

If the problem persists, you will need to rebuild the menu.


How can can I get theme callback to work for an error page?

In menu_get_custom_theme(), you can see that theme callback on menu router would not be called if the menu router doesn't exist. But you can achieve that with hook_custom_theme().

I'll go like this:

/**
 * Implements hook_custom_theme().
 */
function MYMODULE_custom_theme() {
  $router_item = menu_get_item();
  if (empty($router_item)) {
    return 'THEME_NAME';
  }
}


You will need to load JQuery in "noConflict mode" or MooTools in "Dollar Safe mode"; your best bet is to use "Dollar Safe mode" to avoid effecting Drupal.

See MooTools, Framework Compatibility, and Dollar $afe Mode, and The Dollar Safe Mode.


I just had the same similar situation happen just today.  I'm not sure if you resolved your issue, but in case you or others have the problem again, there's a simple solution that worked for me.

I'll post it here, but please go to this link (https://www.drupal.org/node/2417855) as a reference to my situation... thanks!

  This is the error message I was getting PDOException: SQLSTATE[42S02]:
  Base table or view not found: 1146 Table 'dbxxx.xxxfile_metadata'
  doesn't exist: SELECT * FROM {file_metadata} WHERE fid IN (:fids_0);
  Array ( [:fids_0] => 38 ) in file_entity_file_load() (line 201 of
  /sites/all/modules/file_entity/file_entity.file.inc)

Here's what I did:

  UPDATE

  I did my own recon work ... somehow, I was able to get out of the
  situation and the error message disappeared. I am either very
  resourceful or EXTREMELY lucky!! lol

  Here's what I did before the error message ... I Installed and enabled
  the following modules:

  Media and File_Entity ... then the error showed up and froze me I then
  tried to disable, but it wouldn't let me. Here's what I did AFTER the
  error message to fix the problem:

  I went directly to the database and disabled the two modules within
  then I ran the "update.php" from my site It then processed the
  "file_entity" module All is good now I'm guessing the module did not
  upload properly ... I don't know, but I'm back online again... whew =)

I hope this helps =)


How to allow users programatically to post and view posts regardless of they are trusted contact or not in drupal commons

I found out that commons_trusted_contacts module is setting content access as private while posting for trusted contacts, which add post to user group so that only user's trusted contacts sees posts.

In order to post regardless of users are trusted contact or not, I've changed value of group_content_access to public. This way posts are not assigned to any group so it's visible for all users. In database, gid is then set to 0 instead of uid representing user group.

Bellow the line I've changed

$wrapper->group_content_access->set(OG_CONTENT_ACCESS_PRIVATE);

to

$wrapper->group_content_access->set(OG_CONTENT_ACCESS_PUBLIC);


You need to use route:<nolink> to achieve this. Then it will validate and render without a link.


Delete button not working on forum comment

There is a bug report about this

According to one of the comments written by Ravathi.M

  i am also having the same issue the comment wraper class is
  missing.for the initial execution.then i have added the
  ajax-comment-wraper class by custom js code.now it is working fine

Looks like the solution is that you need to add the ajax-comment-wraper comment-wrapper-[post#] class name to your forum comments.

Go to /sites/all/modules/advanced_forum/styles/naked folder and replace the advanced-forum-naked-post.tpl.php with this code:

<?php

/**
 * @file
 * Theme implementation: Template for each forum post whether node or comment.
 *
 * All variables available in node.tpl.php and comment.tpl.php for your theme
 * are available here. In addition, Advanced Forum makes available the following
 * variables:
 *
 * - $top_post: TRUE if we are formatting the main post (ie, not a comment)
 * - $reply_link: Text link / button to reply to topic.
 * - $total_posts: Number of posts in topic (not counting first post).
 * - $new_posts: Number of new posts in topic, and link to first new.
 * - $links_array: Unformatted array of links.
 * - $account: User object of the post author.
 * - $name: User name of post author.
 * - $author_pane: Entire contents of the Author Pane template.
 */
?>

<?php if ($top_post): ?>
  <?php print $topic_header ?>
<?php endif; ?>

<div id="<?php print $post_id; ?>" class="<?php print $classes; ?> ajax-comment-wrapper comment-wrapper-<?php print str_replace('post-','',$post_id); ?>" <?php print $attributes; ?>>

      <?php print $date ?>

      <?php
      // This whole section is for printing the "new" marker. With core comment
      // we just need to check a variable. With Node Comment, we need to do
      // extra work to keep the views caching used for Node Comment from
      // caching the new markers.
      ?>
      <?php if (!$top_post): ?>
        <?php if (!empty($new)): ?>
          (<?php print $new ?>)
        <?php endif; ?>

        <?php if (!empty($first_new)): ?>
          <?php print $first_new; ?>
        <?php endif; ?>

        <?php if (!empty($new_output)): ?>
          <?php print $new_output; ?>
        <?php endif; ?>
      <?php endif; ?>

    <?php /* End of posted on div. */ ?>

    <?php if (!empty($in_reply_to)): ?>
     <?php print $in_reply_to; ?>
    <?php endif; ?>

    <?php /* Add a note when a post is unpublished so it doesn't rely on theming. */ ?>
    <?php if (!$node->status): ?>
      <?php print t("Unpublished post") ?>
    <?php endif; ?>

    <?php print $permalink; ?>

 <?php /* End of post info div. */ ?>

      <?php if (!empty($author_pane)): ?>
        <?php print $author_pane; ?>
      <?php endif; ?>

      <?php if (!empty($title)): ?>

          <?php print $title ?>

      <?php endif; ?>

        <?php
          // @codingStandardsIgnoreStart
          // We hide the comments and links now so that we can render them later.
          hide($content['taxonomy_forums']);
          hide($content['comments']);
          hide($content['links']);
          if (!$top_post)
            hide($content['body']);
          print render($content);
          // @codingStandardsIgnoreEnd
        ?>

      <?php if (!empty($post_edited)): ?>

          <?php print $post_edited ?>

      <?php endif; ?>

      <?php if (!empty($signature)): ?>

          <?php print $signature ?>

      <?php endif; ?>

  <?php /* End of post wrapper div. */ ?>

      <a href="#forum-topic-top" title="<?php print t('Jump to top of page'); ?>" class="af-button-small"><?php print t("Top"); ?>

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

  <?php /* End of footer div. */ ?>

<?php /* End of main wrapping div. */ ?>
<?php print render($content['comments']); ?>

Since the forum post and the 1st comment have the same number 1 you will notice that clicking reply will affect the node post as well. Therefore, you will need to use jQuery to modify or remove the 1 from comment-wrapper-1 of the forum (node) post.


Change workbench moderation state with VBO does not work properly

The patch in https://www.drupal.org/project/workbench_moderation/issues/3160301#comment-13758806 fixes the issue.


Your default value in the select element must be the array key of your values not the value it self.So i set an empty "value" and check for that.

That said i got this working like:

$form['wrap'] = array(
  '#type' => 'select',
  '#title' => t('How many item(s) do you wish to have wrapped?'),
  '#options' => array('--', '1', '2', '300', '400'),
  '#default_value' => 2,
);
$form['textarea'] = array(
  '#type' => 'textarea',
  '#title' => t('How many item(s) do you wish to have wrapped?'),
  '#states' => array(
    'visible' => array(
      ':input[name="wrap"]' => array('!value' => 0 ),
      ),
    ),
  );

In the example above my default value is 300.
The state visibility will work onload and onchange and will show the textarea only when the value is the empty value (0 => '--')


You probably need to do something like this:

$protocol = (!empty($_SERVER['HTTPS'])) ? 'https' : 'http';
$base_url = $protocol . '://mysite.com';

...so that Drupal knows which protocol to use depending on how the site was accessed.


It works with me after disable some modules related to commerce like payment, order, cart, tax and then clear cache products saved.

I still didn't know the reason for that error


Despite its instructions to not use it for adding JS to every page, hook_init() will allow you to add JS in an more sophisticated way with drupal_add_js().

That said, it is rare that a JS file must be loaded on EVERY page, so there is likely more optimization you can do. Also see the FAPI property #attached for adding JS to a form.


You need to use pathauto module and configure URL alias >> patterns >> content paths set opinion/[node:title] path alias for opinion content type. All content path for opinion now change as your requirement.


Need clarification for "use this hook and some code" type of answers

TL;DR version: Most hooks_something() go inside your custom module's
  .module, but not always. You can put alter hooks in your theme's
  template.php file for D7 or in .theme in D8.

There are several assumptions packed into those answers, and yeah they can be hard for people getting used to Drupal. Here are some assumptions cooked into those answers.

First, they assume you know have the tools and knowledge to write code for your project. Often people give those kinds of answers when asked a question where someone was looking for a module that already does what they are asking. Some of that is the nature of the community, and some of that is the nature of sites like this one.

Second, they assume you have a module or theme for custom code already started (or know how to start one).  Lots of Drupal projects will have a module that is just there to provide a few needed hooks to handle an edge case.

Third, they assume you know when to use a module vs a theme for adding the hook. Some hooks really need to be in a module, some should be in a module, and some should be in a theme. But in the end that's is often use case specific (or in the case of agencies done to be consistent with seven sites already supported by the same team).  Rarely do people give guidance which is the right choice.

Fourth, for some hooks they are assuming you know how to figure out how to get it called. Some Drupal 7 hooks (e.g. views) have a different pattern where you declare you have the hooks in your main .module file and then you define the hooks in their own file.

See also: Is it possible to define hook functions in template.php instead of the module?


Why are the labels for two different form elements so different? Can I make them the same?

The differences here come down to the differences in the two types of form elements.
From the MDN docs for the label element:

The HTML  element represents a caption for an item in a user interface

From the MDN docs for the legend element:

The HTML  element represents a caption for the content of its parent .

Looking at the example from the legend documentation, we see how the two types of elements, labels and legends, are semantically different.
<fieldset>
    <legend>Choose your favorite monster</legend>

    <input type="radio" id="kraken" name="monster">
    Kraken

    <input type="radio" id="sasquatch" name="monster">
    Sasquatch

    <input type="radio" id="mothman" name="monster">
    Mothman
</fieldset>

Each radio button has its own label element with text describing it. Meanwhile, the set of radio buttons is wrapped in a fieldset with a legend element to describe the group as a whole.
While you may be able to alter the markup for your radios, to replace the legend element with a label, you should not, especially if you're trying to build an accessible website (and you should be). This answer to Is it good practice to use  for non-input/non-interactive elements? provides a more detailed explanation for why you shouldn't use a label in a context like this.


How to get list of contents of a particular content type programattically

To create a list of content with filters (e.g. by type) you probably want to use either Views or, if you have a reason to load whole entities by ID rather than individual fields, an EntityFieldQuery.

Since there may be a large number of nodes, this type of use case usually uses an autocomplete field by entity title rather than a dropdown.

To create a dropdown, you'll want to use the core Form API to create a form, and the #options array for the dropdown field would be provided by either the View or EntityFieldQuery you create.


Creating multiple blocks programmatically

The following code should help.  You'll obviously need to add your 5 blocks as appropriate, but it's just to show how you can add multiple blocks in one module:

function MYMODULE_block_info() {
 $blocks = array();
 $blocks['myfirstblock'] = array(
   'info' => t('My block admin info'),
   'status' => 1,
 );
 $blocks['mysecondblock'] = array(
   'info' => t('My second block admin info'),
   'status' => 1,
 );

 return $blocks;
}

function MYMODULE_block_view($delta = '') {
  $block = array();

  switch ($delta) {
    case 'myfirstblock':
      $block = array(
        'subject' => t('My first block title'),
        'content' => t('My first block content'),
      );
      break;
    case 'mysecondblock':
      $block = array(
        'subject' => t('My second block title'),
        'content' => t('My second block content'),
      );
      break;
  }

  return $block;
}

Reason for status => 1 from hook_block_info() API docs:

  status: (optional) Initial value for block enabled status. (1 =
  enabled, 0 = disabled). Most modules do not provide an initial value,
  and any value provided can be modified by a user on the block
  configuration screen.

I'm not sure where you got the one block per module idea from.  You can create as many blocks as you'd like in a module.


An easy way could be using Rules and a custom content type.

The content type should have a title which can be used as the email title, a body for email body, and a field to hold email address(es) (or perhaps a reference field to site users or roles).

Then configure a new rule. Select new content event, add a filter to restrict to defined content type, then as an action select send email. Map the proper inputs and you are done.


Alphabetically ordering vocabulary terms in a translated

I found an old solution for Drupal 7 and just changed it until it worked. ;)
function MYMODULE_form_views_exposed_form_alter(&$form, $form_state) {
  if (array_key_exists('MYEXPOSEDFILTERKEY', $form)) {
    asort($form['MYEXPOSEDFILTERKEY']['#options']);
  }
}

It's fairly simply and works as at that point the options are already translated. So, you just need to sort the options in the respective filter.


Well if you want ideas for one page websites you can look here for some awesome one page websites.
    onepagelove.com

you can pick any one of these as design however you will have to heavily custom theme your drupal site.


forcefully / manually remove content type

If you have devel install then go to sitename/devel/php and execute the following code.

node_type_delete('content_type_machine_name');

else you can run the same code inside hook_init() of your custom module.
Hope it helps.


its approved now I just added the new release yesterday

Hijri

  This is a smart module that basically extends Drupal's display date to provide Hijri Date integration with Drupal core date field and with other Drupal contributions.


PreExistingConfigException: Configuration objects provided by progweb_migration already exist in active

This is a core issue, not specific to Migrate. The problem is, config entities are copied into the active store when you enable your module but not deleted when you remove your module. This is what causes the errors when re-enabling your module.

I would highly suggest Config Devel for developing migrations. It will allow you to synchronise your migrations back into the active store without re-installing.


Searching through nodes and outputting the details on gmap

Does it have to be a search box? If not, use GMAP's Views integration and create exposed filters for the fields you want to filter by. Instead of a search box, use a dropdown for bedrooms, city, and whatever other filterable fields you include.

Using a text input/search box may cause usability issues. You can't account for the variety of keywords a user may input, nor will you be able to filter appropriately for unknown terms. Giving the user defined filters (which they are familiar with) will be much easier for them to understand and use.

Better Exposed Filters may come in handy here depending on what type of filters you use -> http://drupal.org/project/better_exposed_filters


If you're using the rendered entity style I don't think you can do it through the UI - Views passes off the display to node_view() in that case, and doesn't get involved with the markup for the row.

The easiest way to do what you want is to implement hook_preprocess_node(), look for a View in the current context, and if the node is being rendered as part of that display, you can make some alterations.

For example

function MYMODULE_preprocess_node(&$vars) {
  if (!empty($vars['view']) && $vars['view']->view_name == 'foo') {
    $nid = $vars['node']->nid;
    $vars['extra_link'] = l('Some text', "node/$nid");
  }
}

Then in your node.tpl.php file you'll have access to $extra_link.


Is there some way to make the lock expire after a while?

lock_acquire takes a second parameter, defining the lifetime of the lock:

https://api.drupal.org/api/drupal/includes%21lock.inc/function/lock_acquire/7.x

The Drupal 8 version would be:

lock->acquire($name, $timeout);

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Lock%21DatabaseLockBackend.php/function/DatabaseLockBackend%3A%3Aacquire/8.2.x


How to transform data from the Google Analytics Reports module into charts?

You can use the API sub-module within the Google Analytics Reports module and use

DataViz module for the visual representation.

You could use http://blog.amazeelabs.com/en/comment/257249 for reference.


How can I allow users to send private messages without revealing sender's address?

The 7.x-1.x branch of Private Message has this setting in the PM Email Notify submodule. When enabled, there is a E-mail notify tab on the settings page (/admin/config/messaging/privatemsg) that allows you to configure the email's from header.

By default, if this is blank, it will use the site's default system email. It sounds like the module is configured with another token that's referencing the sender's init email.


If the custom content type is set up from within a module you're testing, then no you won't have to implement hooks from within the testing environment or anything. However, if your custom content type is set up through the interface on your site then yes you will need to do the same in your test. It is very important to realize that tests run in Simpletest are from the perspective of an absolutely clean environment - no users, no permissions, no custom content types, etc - so all of that needs to be implemented in code.

It's not such a big task once you get used to writing tests though. You can probably set up your custom content type in the DrupalWebTestCase::setUp() method. A simple series of form posts (with $this->drupalPost('path/to/form', $form_values, t('Save'));) and your custom content type will be set up in no time.


Create a new revisions only at the time of specific state transition

I would look into using Rules, You can have something like the below:

Event: Workflow state has changed
If: Workflow state is x (choose your state)
DO: Create a new pending revision of the node


Slightly different menus for different domains

Right. So I have written my own module to do what I wanted, using hook_form_menu_edit_item_alter() for configuration, and hook_translated_menu_link_alter() for displaying.

If anyone is interested in checking it out, initial dev version of the module is available in my sandbox here - http://drupal.org/sandbox/maciej.zgadzaj/1209152 - before I promote it to full project...

Edit:

Now promoted to full version available here: http://drupal.org/project/domain_menu_access


Well It was a monkey's code in the one custom module: It implements hook_node_view() and, if the path  was similar to node/1/bla-bla, it redirected users to node/1.


Redirect to anchor after form validation in Drupal 6

Use this and put in you form

$form_state['redirect'] = 'url';


Term name converted to term id filter removed?

The predefined view "taxonomy term" might have the answer.
It will always show results based on the TID.
I believe that if you just add an alias to your URL, it will work just fine. You can use the module pathauto to automatically create an alias.