Migrating single drupal instant to a multi-site thats live

On the local machine:

Execute SHOW TABLES to get a list of tables.
Copy the table names into a text file, one table per line.
Use your favorite tool to transform the lines from

tablename

to

RENAME TABLE tablename TO prefix_tablename;

Choose a table prefix different from the ones you have on the server. This ensures that no tables are overwritten when you import them to the server.
Execute the resulting script on the DB of your local installation.
Edit the settings.php to use the chosen table prefix.
Export the local database. You can use Backup and Migrate but you have to make sure to also export the structure of the cache tables, but not the content. You can also use phpMyAdmin, but you should empty (not delete) the cache tables and the watchdog table first. These tables can get quite large and their content is not essential to the operation of a drupal site.

On the server:

Import the SQL file of the backup into phpMyAdmin. This creates the necessary tables and fills them with the contents from you local machine. If the file is large, you might run into issues with max_execution_time and upload_max_filesize.
Create a new subdirectory under the sites directory and copy your local settings.php file into it.
Copy any modules, themes and file uploads required by your local site to the server.
Copy sites/example.sites.php to sites/sites.php. The file sites/sites.php allows you to map Drupal sites to arbitrary paths within the sites directory. Read the comments in that file for details.
Edit sites/sites.php so that the URL of the site to replace points to your new directory within sites.

Now you can make further adjustments to your new site without damaging the old one. Problems are usually caused by different locations of modules, themes and uploaded files. These problems cannot be solved by a simple search and replace on the database, because of the way Drupal stores some configuration information (serialized PHP arrays or objects). You might want to switch the site to maintenance mode while fixing such problems.
In case of panic, remove sites/sites.php and you have your old site back.


For this to work you might have to restructure some of your blocks into mini panels but you could implement this module, Panels Ajax Tabs. Ajax can now be used when loading content via panels, either as a tab or container.

  Provides the ability to have a tabbed panel-pane that displays mini-panels within it.

If you require more control; instead you could utilize Ctools AJAX. Of course this is a much more hands on approach.

Hope this helps,


Database Size, suggestions on Dev > Staging > Production

Use backup and migrate module.

http://drupal.org/project/backup_migrate

It has an advanced backup options page, where you can choose tables and data to exclude.


How do I allow custom .php files to be accessable?

This should do the trick:

 RewriteCond %{REQUEST_URI} !/learning/[^/]*\.php$

For more info please look at this thread, unable to run custom php script inside drupal.


How to add css classes to modal forms module

You can use #attributes to add some classes to the elements:

$form['name']['#attributes'] = array('class' => array('your-class'));

Will output something like this (class added to input element):

  Username *
  <input type="text" maxlength="60" size="60" value="" name="name" id="edit-name" class="your-class form-text required">
  ...


Can I create surveys with unique URLs for each recipient?

You can use the webform API in a tiny module to access the form to add a hidden element to it. Then use the handy Drupal arg() function to determine the value of your unique URL argument. After, use the webform API function to change values before saving to the hidden field for administration usage later.

I can't guarantee this will work so hopefully some of the other Drupal Stack Exchange folks can verify this.


Shipping address, rates selection asked even if there's no physical products

I've been able to sort this out by adding the condition "Commerce order contains shippable products" supplied by the physical product module to the existing shipping rules, and also added a new shipping flat rate service called "No Payment". And this new flat rate shipping service is £0.00 amount and checks for condition "NOT Commerce order contains shippable products" (Negated, hence the "NOT").

I also unchecked the tickbox labelled "Require a shipping service at all times, preventing checkout if none are available." in Store-> Configuration-> Checkout Settings, and Shipping Service pane config.


Simplenews newsletter producing undecoded base64 email

It turns out this was a bug in the SMTP Authentication Module. It uses uses 8bit encoding in the Content-Transfer-Encoding header for the base64 encoded body. I applied this patch with success:

https://www.drupal.org/node/1741082#comment-9121815


You could take a look at themekey module.

  ThemeKey allows you to define simple or sophisticated theme-switching rules which allow automatic selection of a theme depending on current path, taxonomy terms, language, node-type, and many, many other properties.

One other property is "host", which would fit into your demands, although this wouldn't be actually a copy of your site. Instead you would just switch the theme on another domain. (On a side note you should consider avoiding "duplicate content" for better serach results.)


How do I access the loaded comment object?

It is better to use kint() function of the devel module for debugging entities because you will get also a list of available public methods.

You cannot get all comment fields values by looping them as different fields have different array result structure.

Using $comment = \Drupal::entityTypeManager()->getStorage('comment')->load($commentID) you get full comment object.

$comment->get('comment_body)->value you get comment body value as it uses some text format (eg. full html).

You also can covert comment object to array $comment = $comment->toArray().


How to tokenize a value in a custom field formatter for views?

I found out how to do this. We have the views object via the parameter "display", so we can use:

$display['views_view']->style_plugin->tokenize_value($settings['pager']['active'], 0)

to tokenize a field value.


Compare specific fields of two nodes side-by-side

Install and configure Node Compare module.

Some more details about this module (from its project page):

  The module to provide node comparison functionality on user request.
  It compares the values of the fields of nodes.


Global $user object isn't always "Fully Loaded"

Nope, you are doing it right as this is a known issue/behavior.  Check out http://api.drupal.org/api/drupal/developer%21globals.php/global/user/6 for a lot more information on it.  A link from there, http://drupal.org/node/57287, talks to your point directly (it is for D7 but is germaine to D6).


It sounds like you're off to a good start. Next, you'll need to add a new field to your content type for links to external news articles.

Home >> Administration >> Structure >> Content types >> News >> Manage fields

/admin/structure/types/manage/news/fields/add-field

Add a new field of type Link and label it something like News Link. Save the field.

Decide if you want to allow only one link to be saved in this field, or multiple values. Save the field settings.

Decide if you want to allow external links only in the field (the default is "Both internal and external links"). Save settings.

After that, you'll still need to make a whole bunch of decisions about how to display News content items ... but the Link field seems to be a missing link in your description.

Good luck!


Clearing a Date Field value in the Edit Node form

You just need to set the default value to 'No default value' in the content type of where the field is created.

Please see in the screenshot


Drupal Login for my Android application?

Services module allows remote login validation using REST calls.


In general, yes, you can do this. There is no limitation on the number of cache entries that can be stored. However, if using the default database cache backend, it can fill up your database and when additionally using the default cache bin, it can slow down other cache lookups. So, I would recommend:

Use a custom cache bin instead of the generic cache table. Especially important if you don't follow the second point. Because the cache bin 'cache' usually holds information that is requested on almost every request.
Use a different cache backend, e.g. Memcache. That avoids that your database gets big due to these cache entries and makes cache lookups faster. See https://drupal.stackexchange.com/questions/12307/where-is-the-best-place-for-cache-bins-drupal-7

Two additional tipps:

Monitor the number reads/writes of that cache to see if the cache actually helps. If, say, 50% of the cache entries are only written and never read, you might want to consider to avoid caching this information.
Especially when using a cache backend like Memcache (which has a smaller overhead for cache calls), it might be helpful to split the data up into several separate cache entries. There a number of benefits for this:

You can cache certain information longer than others (maybe there only is a new announcement every few days but multiple new comments/whatever per hour
Some of the data might not even be user specific but only specific for the roles a user has or even global. So for example, all anouncements could be read from a single cache entry.
You can use cache_clear_all() to clear specific caches on defined events. For example, clear all news caches if a new news is published. By doing this, all users will be able to see the news immediatly. If this is working well, you can increase the cache expiration time.


You want to go through this guide.  It discusses in depth the appropriate filesystem permission settings you should have on every part of the Drupal installation (public files, private files, etc.)  If you follow that guide to the letter your filesystem problems will sort itself out, and you'll have a more secure Drupal installation.  Let me know if you have any questions.


Automatically create hyperlink based on span class

You could do this in your field-template file.

<?php foreach($class in $classes)): ?>
  <?php if ($class == 'johns' ): ?>
    // do something
  <?php endif; ?>
  <?php if ($class == 'sarahs' ): ?>
    // do something
  <?php endif; ?>
<?php endforeach; ?>

Downside this way is you need to maintain a list in the templatefile.


In short, the Views module can be used to do that. This question and answer from the main StackOverflow site covers the same issue, including a link to a tutorial with more details.

Start by installing the Views module. Create a new view to list content. Under the Advanced section for the view, add UID as a contextual filter. From there, you can either create a block display or a page display, to output the view. If you add a page display, you could have it appear as a tab on the user's page, by setting it as a "Menu tab."


There is a module called Commerce Wishlist

Alternatively, for ajax functionality, you could use the Flag module to replicate a similar sort of functionality


How to provide a filter based on json:api for referencing nodes with a term reference field?

The module maintainer was able to provide with the answer.

field_share_to.entity.tid = 64

And also with a link to further reading


It's possible to pass custom variables into Views?

You have to write a custom module that creates a suitable handler (for example, a Views area handler). In that handler you can read your custom variable and act accordingly.

Keep in mind Views cache. So, if you change that variable you should invalidate the cache object for that view or views that uses that handler.


how to correctly write drush sql-sycn using drush_invoke_process()

From your php code:

$values = drush_invoke_process('@none', 'sql-sync', array('@site1', '@site2'), array('tables-list' => 'table1,table2,tableN'));

$values will be an array containing various interesting information about the Drush call.  In particular, check $values['error'] to see if the command succeeded or not.


How to get one time URL when we are writing hook_mail_alter?

Bingo! Found the Solution myself:

    function custom_module_mail_alter(&$message) {
      if (!empty($message['id']) && $message['id'] == 'user_password_reset') {
        $token_service = \Drupal::token();
        $language_interface = \Drupal::languageManager()->getCurrentLanguage();
        $account = $message['params']['account'];
        $one_time_url_token = '[user:one-time-login-url]';
        $one_time_url = $token_service->replace($one_time_url_token, ['user' => $account], ['langcode' => $language_interface->getId(), 'callback' => 'user_mail_tokens', 'clear' => TRUE]);
      }
    }


Use dropdown in views exposed filter on text fields with node->title?

I solved the problem, here the code:

<?php

function views_dropdown_form_views_exposed_form_alter(&$form, &$form_state) {
global $user;

// Only alter forms with the necessary field
if (isset($form['title'])) {

// Build a query to get all node ids having the specified field
$query = new EntityFieldQuery();

$results = $query->entityCondition('entity_type', 'node')
                  ->entityCondition('bundle', 'rapporto_di_lavoro')
                  ->propertyCondition('uid', $user->uid)
                  ->propertyCondition('title', 'NULL', '!=')
                  ->execute();

// Attach the field values to the nodes
$ids = array_keys($results['node']);
// Add a default so the filter is optional
$options = array('' => '<select>');

// // Buld the options array based on the query results, overwriting duplicate entries
$query = db_select('node', 'n')
            ->fields('n', array('title'))
            ->condition('n.nid', $ids, 'IN');

$results = $query->execute()->fetchAll();

foreach($results as $id => $node) {
  $value = $node->title;
  $options[$value] = $value;
}

// // Alter the field
$form['title']['#type'] = 'select';
$form['title']['#options'] = $options;
$form['title']['#size'] = 1;
}}

I hope could help someone :)


Page caching with multiple versions of the cache

If you're using Varnish, you can simply add the cookie as a hash key - there's lots of information about how to do this.

One example and one based on mobile devices.

If you mean Drupals internal page cache then maybe look to this module.


Event calendar help - creating view of event with all registered users in a block

You can create a block and output your view with PHP, that way you can control which argument to pass:

<?php
  print views_embed_view('your_view_name', 'display_id', $your_argument);
?>

You can get 'your_view_name' and 'display_id'from the view's edit page:

'your_view_name' from the URL, something like admin/structure/views/view/your_view_name
'display_id' on the right side under "Other" > "Machine Name". It's usually something simple like 'block_1', or if you have a single display, try 'default'.

Also remember to set the text format to PHP code.


The famous counter module "counter" is marked unsupported

The Visitors module is pretty good option for the counter module.

Reports provided by the module:

  View pages that have recently been visited.
  View pages that have been hit frequently.
  View pages count per month.
  View pages count per day of month.
  View pages count per day of week.
  View pages count per hour.
  View pages count per host.
  View access log.
  View user activity report (hits, nodes, comments).
  View referrer list.


In your webform add an "email field" for the recipient (say email_recipient).
Go to node/123/webform/emails to set the recipient to be your previously created field.
Create a hook_form_alter to put the email address you your webform field.

<?php
function CUSTOM_form_alter(&$form, &$form_state, $form_id) {
  //you need to set up a CUSTOM module to store this.
  //use devel with dsm($form); to figure the name of each field
  if ($form['#id'] == 'webform-client-form-123') {
    //load the node from the url
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $node_email = node_load(arg(1));
      //set your webform field to your email
      $form['submitted']['con_email_recipient']['#default_value']
           = $node_email->field_email_recipient[0]['value'];
    }
  }
}
?>

Add some CSS to hide the field, and it should work, code untested but I'm pretty confident about the steps, also have a look at Working with Default Values.


Display a message when no results are returned from an exposed filter

When you edit your view (D7), under 'Advanced' you will find an item labelled 'No Results Behavior' which gives you a selection of options. The usual is to select 'Global Text Area' and return a no results found message.


How to track the number of clicks on a link?

This link might help you. http://activelamp.com/blog/add-and-track-any-link-google-analytics


A module similar to Innovation News Module for Drupal7?

I think you can easily replace this module by a bunch of other module and that maybe the reason why the module is not anymore maintained. I will try to give you some clues to archive your goal, but maybe you need code a bit.

Flag - Flag allows you to associate content to an edition.
Views - Flag work with views, that allows you create views for each edition
Views Bulk Operations - With Views and VBO you can easily create control panel for each edition.

I hope this can help you.


Syntax to use form_alter with array in name attribute

Why are you using field's attribute 'name' instead of it's machine name 'field_prenom'? If you check in 'kint' you would get the hierarchy of 'placeholder' attribute.

You can update placeholder using form_alter only. Check the below example.

$form['field_name']['widget'][0]['value']['#placeholder'] = 'Nom';


How do I create and apply a configuration schema for an existing custom module?

To have the "Translate" tab listed on your module's configuration page you additionally need to provide a module_name.config_translation.yml in your module's root.

module_name.settings:
  title: 'Module Name'
  base_route_name: module_name.admin_settings
  names:
    - module_name.settings

Look for existing module_name.config_translation.yml file in core and contrib and you'll get the pattern no problem.


How to fix warning message related to Pantheon module?

Try using module_missing_message_fixer

with drush

you just need to run the following 2 commands

drush en module_missing_message_fixer
drush mmmff pantheon

without drush using the user interface

Enable the module
make sure you have the permission Administer Module Missing Message Fixer
Go to: admin/config/system/module-missing-message-fixer


How do I get a link to an image CCK in Drupal 7 in the node view?

You want to use the Drupal link function l()  for this.

  $link_html = l('some cool link text', $node->field_main_photo['und']['0']['uri'];

then you can either print that $link_html variable OR you can return it some other function will be rendering it.

Bonus:
You can replace the 'some cool link text' with the name of the file by using this:

$node->field_main_photo['und']['0']['filename']

So that would give us:

$link_html = l($node->field_main_photo['und']['0']['filename'], $node->field_main_photo['und']['0']['uri'];

Make sense?

Also... print_r() can often ve difficult to parse through. I recommend that you enable the DEVEL module and instead do the following:

dpm($node);

This will render the node on the page in a manner that you can click through and inspect each element and array and object. Even better, you can double click the value and the variable path to that value shows up for you to copy and paste into your code.

I hope this helps! :-)


Get list of webforms that can be created by the current user

I'll autoanswer my question :)

By grep-ing inside Webform source code I found that the permission name is not "create", but "submission_create", even if dpm($entity) is referencing "create".

$ grep -r "access" * | grep submission_create
webform_node.routing.yml:    entity_access: 'webform.submission_create'
Webform.php:                 if (!$webform || !$webform->access('submission_create')) {
(...)

So, this works as expected:

$entities = \Drupal::entityTypeManager()->getStorage('webform')->loadMultiple(NULL);
$forms = array();
foreach( $entities as $entity_id => $entity )
{
    if( $entity->access('submission_create', NULL) ) {
        $forms[] = $entity_id;
    }
}

It returns only the webforms that you are entitled to send submissions to.


How to add custom field to image area where Alt and Title fields are showing?

I put element in IF condition in MYMODULE_image_field_widget_process and it works fine.
What it does is, it checks for ALT attribute if it is ENABLED so it will then add the CUSTOM field, you can instead add the CUSTOM field visibility option in image setting page and check for that.

function MYMODULE_image_field_widget_process($element, &$form_state, $form) {
   if ($element['alt']['#access']) { // IF condition added here
      $element['custom'] = array(
        '#title' => t('Custom Field'),
        '#type' => 'textfield',
        '#default_value' => isset($item['custom']) ? $item['custom'] : '',
        '#weight' => 1,
      );
   }
   return $element;
}


How to make custom end user text in a form available for editing for a e.g. editor role?

As long as the string or text is passed via t() function you can override it using String Overrides module. Here is a quote from module's project page:

Provides a quick and easy way to replace any text on the site.

UPDATE
You can also use Variable module. Quote from project page:

... provides a registry for meta-data about Drupal variables and some extended Variable API and administration interface.
This is an API module so it must be installed only when other modules require it.


I've solved my problem as follows:

Download the i18n patch from here
Apply the patch using any preferred technique, you can refer to Drupal
Applying should be on a test drupal installation in order to avoid any problems
After that go to modules page and enable the Poll Aggregate module under i18n, this will synch the voting results for all installed languages
After testing the patched module and getting happy result, install the module on your live site.

I have test this solution and it is OK with some small problems that I am trying to solve, and I will share the new things.


Debugging the result property in a ViewExecutable

Your code works fine for me so perhaps your view has no results?
Anyways, the Drupal log is not really meant to be used for printing variables for debugging purposes. Use an appropriate tool like Devel which has/comes with another module called Kint, enable Kint.
use Drupal\views\ViewExecutable;

/**
 * Implements hook_views_post_execute()
 */
function mymodule_views_post_execute(ViewExecutable $view) {
  kint($view->result);
}

Flush cache and you'll see this

For more info on how to use Kint, see Welcome to Kint 101


Theming the field.tpl.php - accessing variables from a field collection

In standard field.tpl files you can access your field collection items using this code:

foreach ($items as $k) {
  foreach ($k['entity']['field_collection_item'] as $id => $field_collection) {
    $field_collection_item = field_collection_item_load($id);
    $field_wrapper = entity_metadata_wrapper('field_collection_item', $field_collection_item);
    $field_colour = $field_wrapper->field_colour->value();
  }
}

I don't know if it is a best practice to do that, but this is my way.


Display data from web service using views

You can take a look at https://www.drupal.org/project/wsdata

This module allows you to bypass the default data storage location for fields and entities and instead load the data from a web service.

This is useful when your primary data source is in another system but you want to display/use this data in your Drupal site without the hassle of syncing or importing data.


How do I set up jumbotron so that I can control it through a panel?

So I just recently created a jumbotron functionality for a site I worked on. I used panels, bootstrap and a custom node type to achieve this and it worked pretty well.

The video from the link you provided looks like they did something similar except they have some enhancements to panels and the node creation page that may be from a custom module or another module I am not familiar with.

What you will want to do is to create a new content type called Jumbotron and add the fields you want. You could also install the Field Group module to help with getting grouped fields together.

You will need to create a new template file for that node view but I am going to assume you know how to do that to get your fields to render correctly and that you know how to use a hook_preprocess_node function as needed as well.

You can then create as many jumbotrons you want the normal way of creating nodes, and using panels, you can add the same jumbotron entity to as many pages as you want using the "Add Existing Node" option.

To get the EXACT functionality from your link I don't know if there is a  list of contrib modules to get you that without doing anything custom.

Hope that helps,


Change form submit #access as a result of ajax callback

You really shouldn't alter the form in your ajax callback.  What you want to do is set a variable in the form_state in the ajax callback, and your form code should look for that variable to decide how to set #access

So in your ajax callback, lets say whatever conditions are met, and you want to disable access when it reloads...

So set a variable like, $form_state['access_to_field_revoked'] = TRUE

Then your form code:

$form['actions'] = [
  'id_lookup' => [
    '#type' => 'submit',
    '#title' => 'Submit',
    '#value' => 'Lookup ID',
    '#access' => empty($form_state['access_to_field_revoked']) ? TRUE : FALSE,
    '#ajax' => [
      'callback' => 'my_module_populate_id_info',
      'wrapper' => 'id_info',
      'method' => 'replace',
      'effect' => 'fade',
    ],
  ],
  'submit' => [
    '#type' => 'submit',
    '#title' => 'Submit',
    '#value' => 'Register for Event',
    '#access' => !empty($form_state['access_to_field_revoked']) ? TRUE : FALSE,
  ],
  '#weight' => 100
];

You will probably need another variable like $form_state['generate_additional_fields'] = TRUE;
and put your FAPI for those fields in the form callback, and not the ajax callback...
so in your form callback:

if(!empty($form_state['generate_additional_fields']) {
// add your additional form fields now
}

Almost never a reason to alter the $form variable in the ajax callback. It is always best to set a variable in the form_state and then look for that variable in the form callback to actually set the FAPI up.

UPDATE:
Misread the post, so your code was in the form handler, not the ajax handler, and that will work.

One way that the #access property would not get updated is if the 'actions' buttons are outside of the wrapper div that ajax replaces. If they are, they would be showing via the '#access' value from initial form load.  One solution would be to make sure that the wrapper that the ajax callback refreshes includes the action buttons, so that they are re-rendered.

In the FAPI inside your conditional, there is a suffix, with an extra /div . This maybe the closing div for your wrapper, and if that was placed after the form actions, perhaps they would get refreshed by the ajax callback, and it would work


I think that you are mixing up things. By doing

drush config-delete migrate_plus.migration.ID

you are just deleting migration_plus configuration but you are not disabling the module, it is still enabled. If you really want to disable the module and of course the configuration, you'll have to drush pm migrate_plus.

Concerning the "No migrations found" message, your custom module has to define correctly the new migrations (.yml files).


You should write the if-else structure like:

<?php
global $user;
if (!$user->uid) {
   print '

Oops!

tekst hier

';
}
else if(arg(0) == 'node' && is_numeric(arg(1))) {
    $nid = arg(1);
    print 'Voeg een album toe!';
}

?>

Note that after 'else' you want to test some conditions so you need to put an 'if' statement in front of your test.


Can Drupal nodes and taxonmy be used to store "data" rather than "content"?

I recommend leaving the database structure to Drupal, its modules will handle all of the management process and you will not have to code anything.

Taxonomy is very flexible for creating categories.  These taxonomy vocabularies can be attached to a content type.  Create a new type and add fields for each applicable vocabulary.  You can make assigning values to each field mandatory if you want and Drupal will enforce the requirement when new content is generated.

You will then use views to filter through all of your content and deliver custom pages.  It is incredibly flexible but can take a while to learn.  Check out the "Taming the Beast" video series at NodeOne.SE for an excellent video series to master views.


Body field is not displayed in Comment Views

Well.. at this point you may have to resort to the following.

First of all, make a backup of your database.

Plan A) Disable views and uninstall it (so all the database tables are erased), then delete the views folder. Download it again, upload the folder and enable it. If this fixes your problem, you can use the view's export/import to quickly import all the view's you had.

Plan B) Disable every module you have in sites/all/modules folder except for Views. Then if it works now, enable them one by one to see which one is causing this.

Plan C) If A or B doesn't work, well... I hate to say it, reinstall Drupal :(


nodeaccess prevent some roles to view views contents even if they allowed to access

I found this module node_view_permissions, it did what I want in my use case, so I removed nodeaccess.

  Node view permissions module enables permissions "View own content"
  and "View any content" for each content type on permissions page as it
  was on Drupal 6. It's as simple as that.

  It's implemented in a non-conflict way, so you can use it with any
  other permissions related module.


Entity query on custom entity is not checking access rights

You will need to implement hook_query_ENTITY_TYPE_access_alter  ( hook_query_project_member_access_alter) to apply the custom query access check.
For example https://api.drupal.org/api/drupal/core%21modules%21node%21node.module/function/node_query_node_access_alter/8.9.x
You might need to $query->addTag(‘project_member_access’) but from memory that tag may now be added automatically by the entity query handler.


How to limit access to a meeting content type to only the participants specified via Entity Reference?

Use the Node access user reference module. Since you're already using Entity reference, it should fit. Some more details about this module (from its project page):

Gives content access permissions to users for content that references the users with User reference or Entity reference.
This is great if you want your content authors to be able to choose additional authors, or choose who can view their content, as well as being able to display the list of authors or viewers within your content, or in views displays.

You should configure the module similar to the settings shown in the screenshot on its project page, which is like so:

Though I would uncheck the Grant for all users option (= view).
That way the users who can create such meetings (nodes) have all permissions they need (since they'll be the author). And the "specified users" will be able to view it, which appears to be exactly what you want.
To actually configure these settings, refer to the module's README.txt, which includes these instructions:

Create a field to reference users in a content type using the Field UI.  The field's configuration page will contain the settings for Node access user reference. For detailed instructions on using the Field UI see:
https://www.drupal.org/documentation/modules/field-ui


Want a select option of a field saved in another form

The module is Webform Views Select.

This question is related to this question.

Webform select option list from another submission data


Webform Module can't send email from user anonymous

Anonymous users can absolutely submit webforms. On the Form Settings page under submission access, there are permission checkboxes for each role. You can use Captcha or Mollom to help prevent spam submissions.

The error you're having seems like you have SMTP misconfigured. Are you currently using the SMTP module? If so, run a test to send an email to yourself. If that fails, then it's definitely the problem.


how to get radio value from radio button by form api drupal

if you are looking for the submitted values you need to look in the $form_state and not the $form array.

use $form_state['values']['your field name'],
depending on element type you might have ['und'][0] or just [0] on the end.


How to add variables to Drupal.settings using form#attached?

Documentation is available:

Form API

$settings = array('id' => 'mymodule-element-1');

$form['#attached']['js'][] = array(
  'data' => array('mymodule' => $settings),
  'type' => 'setting',
);

Managing JavaScript in Drupal 7

$element['#attached']['js'][] = array(
  'type' => 'setting',
  'data' => array('myModule' => array('key' => 'value')),
);

Both are roughly the same as what OP (@drupality) said worked for him in a comment on Jun 14 2013.

The code in the original question that the OP said he tried but fails seems roughly the same as the working code, so I can't see what the original error was.


I'm not seeing any hook named hook_vote_rate_vote_alter(), and the Drupal 8 version of the module is in development still. Your problem may be there.


In short: wget is your friend when you want to warm up your page cache.

In more detail: http://linuxreviews.org/quicktips/wget/ for example. If you want to warm the cache for page requisites (all images, css, js etc linked to from any page) too, you can use wget -p which is not mentioned in that article.

Got more interested about this and found some Drupal specifics: http://www.metaltoad.com/blog/how-drupals-cron-killing-you-your-sleep-simple-cache-warmer

To summarize: just setup your system's scheduled tasks (cron on *nix for example) to run wget in a manner that finds all your pages before your cache runs cold.


Add custom title and custom alternative text to Logo Image Settings

You can alter theme form using, form_system_theme_settings_alter in theme-settings.php

function test_form_system_theme_settings_alter(&$form, &$form_state, $form_id = NULL)  {

$form['logo']['settings']['alt_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Alt Text'),
    '#description' => t("Alt text")
  );
$form['logo']['settings']['title_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Title Text'),
    '#description' => t("Title")
  );

}

You can get this value theme_get_setting('title_text') in page.tpl.php,and i haven't tried this. Check from your side, let me know if you face any issue.


I found the solution, As previously i was not using   'renderer'    => 'quicktabs', . Also

 $tabs[] = array(
          'title' => t('Tab3'),
          'type' => 'freetext',
          'text' => 'Hello wecome to Tab3',
        );

was not working.
Use this working function.

function test_quicktabs(){

    $quicktabs_options = array(
        'style'   => 'Basic',
        'ajax'    => FALSE,
        'renderer'    => 'quicktabs',
    );

    $quicktabs_name = 'newinstance';

    $custom_tabs = array(
        array(
            'title' => 'Tab 1',
            'contents' => 'tab1',
            'weight' => -10
        ),
        array(
            'title' => 'Tab2',
            'contents' => 'tab2',
            'weight' => 0
        ));

   return  quicktabs_build_quicktabs($quicktabs_name, $quicktabs_options, $custom_tabs);

}

If anyone find better implementation using quicktabs hooks. Please do answer.


Views with logged user contextual filter stop working after adding relationship

Sounds like a permissions issue.  User 1 has access to everything, others do not.

What I would do is:
1) Either backup your site, or note (screenshot) what permissions you have set currently
2) Start adding several permissions at a time, and going back to check if the view has changed, until you've exhausted all permissions


You cannot send email without line breaks.

The SMTP standard requires that lines be limited to 1000 characters. 998 really because the line must end with "\r\n".

If you successfully avoid having line breaks inserted for you, what will happen is that many email servers on the Internet will reject your email. Some will accept it, because they decided to ignore the standards. Guess who does that.

Many servers will not.

The correct answer to this problem is to create HTML email that has line breaks. This is really easy to do. Pick a few elements that occur fairly often, like </tr> if you use tables, and CSS rule end braces, and put a newline after it.

Reviewing your HTML will also help you avoid very stupid looking HTML text, if you care. I was just viewing source on a newsletter email from TweakTown where they first include a bunch of CSS rules at the top. Then every single table row repeats the same CSS as inline styles. Really. Why? No wonder their lines are more than 1,000 characters long.

So, are people intentionally creating HTML with no line breaks to save space? Because if so, CSS rule spam is the opposite of saving space.


Create Taxonomy with Hierarchy from an Array

Here is a solution ...

// First create your array of terms
$terms = array(
  'level1-1' => array(
    'level2-1' => array(
      'level3' => array(),
    ),
    'level2-2' => array(
      'level3' => array(
        'level4' => array(),
      ),
    ),
  ),
);

// Create your vocabulary.
// First check if the vocabulary exists otherwise an error will be thrown when trying to create it.
$vocabs = taxonomy_get_vocabularies(NULL);
$vocab = new stdClass();
foreach ($vocabs as $vocab_object) {
    if ($vocab_object->machine_name == 'vocab_short_name') {
        // Vocab found.  Grab the object.
        $vocab = $vocab_object;
        break;
    }
}
// If the vid is not set then create the vocab.
if(!isset($vocab->vid)) {
    $vocab = new stdClass();
    $vocab->name = 'Vocabulary Name';
    $vocab->machine_name = 'vocab_short_name';
    taxonomy_vocabulary_save($vocab);
}
// Recursive function that will create the hierarchical terms.
mymodule_add_hierarchical_terms($terms, $vocab->vid);

function mymodule_add_hierarchical_terms($vocab, $vid, $parent = null) {

  foreach($vocab as $term_name => $term) {
    // Create the term
    $term_object = new stdClass();
    $term_object->vid = $vid;
    $term_object->name = $term_name;
    if(isset($parent)) {
        $term_object->parent = $parent;
    }
    taxonomy_term_save($term_object);

    if(is_array($term)) {
      // Recursively call the function, passing the term id of the parent.
      mymodule_add_hierarchical_terms($term, $vid, $term_object->tid);
    }
  }
}


Datetime fields in Drupal 8 are stored as strings. So you need to convert it into string.

You can use the format method, e.g.

$formatted_date = $date->format('Y-m-d H:i:s');

Refer Inserting the value from Datetime field form

You can also use T as separator,

Like:

\DateTime::format("Y-m-d\TH:i:s"); //need a escape character in front of T.

Refer Why is my Datetime field not saved?


How to convert query string http://example.com/myview?page=1 to http://example.com/myview/page/1 in views?

Try using the module: Query parameter to url(https://www.drupal.org/project/query_parameters_to_url), It will work for you.

Just specify the pattern {^myview} inside /admin/config/search/query-parameters-to-url after installing and activating the module.

Let me know if any helps needed.


Errors from custom FieldItemList::getConstraints() displayed next to every single property

We can place the errors with three modifications in the widget class.

First, we add the empty form element non_field_errors we can attach the errors to.

class YearRangeWidget extends WidgetBase {
    ...
    public function form($items, &$form, $form_state, $get_delta = NULL) {
        $formElement = parent::form($items, $form, $form_state, $get_delta);
        $formElement['non_field_errors'] = ['#type' => 'item'];
        return $formElement;
    }
    ...
}

Second, in the flagErrors method, we collect all errors that do not belong to any property and call a separate method to treat them.

class YearRangeWidget extends WidgetBase {
    ...
    public function flagErrors($items, $violations, $form, $form_state) {
        $listViolations = [];
        foreach ($violations as $key => $violation) {
            if ($violation->getPropertyPath() === '') {
                $listViolations[] = $violation;
                $violations->remove($key);
            }
        }
        parent::flagErrors($items, $violations, $form, $form_state);
        $this->flagNonFieldErrors($items, $listViolations, $form, $form_state);
    }
    ...
}

Third, we define the method treating the separated errors.

class YearRangeWidget extends WidgetBase {
    ...
    public function flagNonFieldErrors($items, $violations, $form, $form_state) {
        $field = $items->getName();
        foreach ($violations as $violation) {
            $form_state->setError(
                $form[$field]['non_field_errors'],
                $violation->getMessage()
            );
        }
    }
    ...
}


As long as you have the uuid of an entity you can use Drupal's entity storage interface to load it given that property. It should be as simple as using the loadByProperties method.

$node_loaded_by_uuid = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['uuid' => $your_uuid]);
$node_loaded_by_uuid = reset($node_loaded_by_uuid);

UPDATE: milkovsky is correct. loadByProperties returns an array. If you want the actual node object at the top of it you will have to use the reset function.


How to add one more field in disqus form

Disqus does not provide titles, therefore, it is not possible.

What the Disqus module does is embed the Disqus chat/comments as an iframe. For security reasons, you cannot modify/alter anything that is inside an iframe.


Adding new fields using hook_field_schema_alter()

You would need to call the field_create_instance() function passing a new array.

 $instance = array(
    'field_name' => 'field_my_custom', // ** This already exists, or check with field_info_field()
    'entity_type' => 'node',
    'label' => 'a label',
    'bundle' => $content_type,
    'widget' => array(), // if you're not sure about your widget settings, take a glimpse at an existing field instance using debug(field_info_instance(...));
);
field_create_instance($instance);

More links to read and better understand the above functions:

https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/field_info_field/7
https://api.drupal.org/api/drupal/modules%21field%21field.info.inc/function/field_info_instance/7
https://api.drupal.org/api/drupal/modules%21field%21field.crud.inc/function/field_create_instance/7

Also, take a look at the Examples for Developers module, node example and field example.


You cannot get the user's password from what Drupal saves in the database. Drupal doesn't encrypt the password and saves it in the database, but it saves in database the hash of the password, which is the value returned from a one-way function; this means that is not possible to calculate the value that originated the hash.
That is the reason why hashes are saved instead of the passwords: If somebody access the database used by a Drupal site, it is not possible to retrieve the passwords, and access that site as one of the users registered in that site. (It could still possible to find a word with the exact same hash; so far, collision attacks are shown possible in short time only with MD5.)

Drupal is able to send an email to reset a user's password, which is not what you are asking for, but it could be helpful if you want the users to reset their password after X months. In this case, you could be interested to the code used by _user_mail_notify().

  // By default, we always notify except for canceled and blocked.
  $default_notify = ($op != 'status_canceled' && $op != 'status_blocked');
  $notify = variable_get('user_mail_' . $op . '_notify', $default_notify);
  if ($notify) {
    $params['account'] = $account;
    $language = $language ? $language : user_preferred_language($account);
    $mail = drupal_mail('user', $op, $account->mail, $language, $params);
    if ($op == 'register_pending_approval') {
      // If a user registered requiring admin approval, notify the admin, too.
      // We use the site default language for this.
      drupal_mail('user', 'register_pending_approval_admin', variable_get('site_mail', ini_get('sendmail_from')), language_default(), $params);
    }
  }


Actually there is no function (built into core, at least) called drupal_is_front(). I believe what you're looking for is drupal_is_front_page() and in your case you could use it like this:

<div id="content_<?php if (drupal_is_front_page()): print 'main'; else: print 'something_else'; endif; ?>">
  ....

Or

<?php
if (drupal_is_front_page()) {
  $divid = 'content_main';
}
else {
  $divid = 'content_something_else';
}
?>
  <div id="<?php print $divid; ?>">
    ....

I think it's also worth mentioning that if you're applying the code to a template file, you should also be able to use the variable $is_front in place of the function drupal_is_front_page(). The difference might be minuscule, but using a variable rather than a function should save you a little bit of overhead on your server.


How to show/hide the prefix/suffix for fields?

When you look at the code of the numeric field formatter:

NumericFormatterBase::viewElements

  public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = [];
    $settings = $this->getFieldSettings();

    foreach ($items as $delta => $item) {
      $output = $this->numberFormat($item->value);

      // Account for prefix and suffix.
      if ($this->getSetting('prefix_suffix')) {
        $prefixes = isset($settings['prefix']) ? array_map(['Drupal\Core\Field\FieldFilteredMarkup', 'create'], explode('|', $settings['prefix'])) : [''];
        $suffixes = isset($settings['suffix']) ? array_map(['Drupal\Core\Field\FieldFilteredMarkup', 'create'], explode('|', $settings['suffix'])) : [''];
        $prefix = (count($prefixes) > 1) ? $this->formatPlural($item->value, $prefixes[0], $prefixes[1]) : $prefixes[0];
        $suffix = (count($suffixes) > 1) ? $this->formatPlural($item->value, $suffixes[0], $suffixes[1]) : $suffixes[0];
        $output = $prefix . $output . $suffix;
      }
      // Output the raw value in a content attribute if the text of the HTML
      // element differs from the raw value (for example when a prefix is used).
      if (isset($item->_attributes) && $item->value != $output) {
        $item->_attributes += ['content' => $item->value];
      }

      $elements[$delta] = ['#markup' => $output];
    }

    return $elements;

You see three things, first this is fully configurable, so it has not to happen in the first place, second it's hard to change afterwards, because the field content and the prefix/suffix is concatenated into one string and third you can get the raw values without prefix/suffix from the items attribute content:

field--field-number.html.twig

Field raw values:

  {% for item in items %}

{{ item.attributes.content }}

  {% endfor %}


I've been running the same script included on that page for sites running either Drupal 7 or Drupal 8, with no adverse effects. I would recommend just using that.


What is the best way to show custom field information in node.tpl.php in Drupal 7

Something like this might demonstrate the fields available

<?php
$file = $node->field_yourfieldname[ $node->language ][0];
$mime = $file['filemime'];
$size = round($file['filesize'] / 1024 / 1024,1); // in MB
$description = $file['description']; // optional
$filename = $file['filename'];
$link = file_create_url($file['uri']);
?>

Hmmm, if $node's not available try something like this at the start

$file = $content['field_yourfieldname']['und'][0];


Can a VBO form be integrated with the Commerce Add-to-Cart form to allow adding optional add-on products with checkboxes?

You could do it with Custom Line Item Fields for checkboxes and either just track the add on products using the line item or create a rule that adds the matching product to the cart when an line item is added that has checkbox field values.

PS: If you go with line item fields only approach, you should use pricing rules to change the final price of any line item with those check boxes to add prices to them. If you do that, then you might want this patch that allows line item fields to automatically ajax update the price when something changes:

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


Form block: how to choose which fields are being displayed?

I needed to adjust custom field permissions for the field I wanted to show and once I set the field permissions to "public" they showed. The permissions were under edit field in manage display of the content type.

I had originally looked in both permissions and in edit display.


Take a look here.
This may help you.  hook_line_item

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


How to add the search form in Bootstrap theme?

After some search I figure out the following solution, it is working, But the issue is it is applying to search_block_form also, might be function lsubtheme_bootstrap_search_form_wrapper($variables) is the reason, which is getting applied everywhere. Might be giving False positive result.

PLEASE anybody have any suggestion, how to imptove this, I am trying will update.

Codes in template.php

function lsubtheme_preprocess_page(&$variables){
  $search_form = drupal_get_form('search_form');
  $search_box = drupal_render($search_form);
  $variables['search_box'] = $search_box;
}

/*
 *  Form alter to add missing bootstrap classes and role to search form.
 */

function lsubtheme_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_form') {
    $form['#attributes']['class'][] = 'navbar-form navbar-left';
    $form['#attributes']['role'][] = 'search';
  }
}

function lsubtheme_bootstrap_search_form_wrapper($variables) {

  $output = '
';
  $output .= $variables['element']['#children'];
  $output .= '
';
  $output .= '<button type="submit" class="btn btn-default">Search</button>';
  $output .= '
';
  $output .= '
';
  return $output;
}

Code in page.tpl.php

 <?php print $search_box; ?>


I have a small module hosted on GitHub that does just that:
Locale Menu
From the README file:

Overview
Alters the href of any menu item whose title is "English" or "Español" to point to the translated version of the current menu item. If no translation exists for the current menu item, the link will point to the translated version of the homepage.

You'll need to tweak Lines 6, 15, and (especially) 21 of the localemenu.module file to match the name and language code of your language.


How to embed drupal content in other sites (remove X-Frame-Options: SAMEORIGIN)?

Drupal 8 adds the response header X-Frame-Options: SAMEORIGIN to all pages. This prevents that the content is included in iframes on third party sites.

You can check this for example in the google image search that your content does not appear in the preview frame.

This feature was introduced in drupal 8 beta 13.

The change record

Core is now protected against click-jacking by default (X-Frame-Options: SAMEORIGIN)

is not correct in that the priority has to be higher, in fact it has to be lower. The code example changes the request but it has to change the response.

To provide a solution to the question here is the complete code including the yaml file to put this in the service container:

mymodule/src/EventSubscriber/RemoveXFrameOptionsSubscriber.php:

<?php

namespace Drupal\mymodule\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

class RemoveXFrameOptionsSubscriber implements EventSubscriberInterface {

  public function RemoveXFrameOptions(FilterResponseEvent $event) {
    $response = $event->getResponse();
    $response->headers->remove('X-Frame-Options');
  }

  public static function getSubscribedEvents() {
    $events[KernelEvents::RESPONSE][] = array('RemoveXFrameOptions', -10);
    return $events;
  }
}

mymodule/mymodule.services.yml:

services:
  remove_x_frame_options_subscriber:
    class: Drupal\mymodule\EventSubscriber\RemoveXFrameOptionsSubscriber
    tags:
      - { name: event_subscriber }


How to fetch a list of nodes by content type in a Rules Action set?

Introduce a variable of type Text Token with the content type as the value.

Parameter: Type: Text token, Value: content_type

And then use this new variable as the value for comparison with the property.


What is the URL for configuring OAuth2 services?

You enable OAuth2 authentication in admin/structure/services/list/$yourserver, then on the Authentication tab (admin/structure/services/list/$yourserver/authentication) you select the OAuth2 server.
After that, once you go to the Resources tab (admin/structure/services/list/$yourserver/resources) you will see the mentioned settings in the Settings column for each resource.

Make sure that you have the latest -dev release of Services, or the patch mentioned on the OAuth2 Server project page applied, otherwise it won't work.


How do I remove taxonomy links from nodes?

In the Manage Display page of your content-type i.e.: admin/structure/types/manage/product/display you should be able to set the output format for your terms to 'plain text'.


Looks like the documentation around that theme function is out of date. Please open a bug report for that.

Have a look at template_preprocess_links, it is using url, not href. Also not that url is a Drupal\Core\Url object, not a path, so your code should look like this:

$links[$key] = array(
  'title' => $definition['title'],
  'url' => Url::fromRoute('module.show_format.' . $entity->getEntityTypeId(), array('module_format' => $key, 'entity' => $entity->id())),
);


How do I NOT clear memcache or other cache tables?

One setting you can play around with is the minimum cache lifetime setting. It will help, but it won't solve the issue.

The standard Drupal cache doesn't allow for what you are describing. One can do some exotic stuff to update caches in the background but unless you have a large developer budget to make this work I would move on. Note: The 6.x version of boost is the only thing I know of that allows for the cache to be updated in the background.

If you are looking to build a spider, http://drupal.org/project/httprl/ is the way to go. I hope to be developing with this more in the future.


Redirecting the home page to index.php, not index.html

Why use separate index files when you can use a splash screen:

  We define a splash page as being content that shows up at a specified interval, at a specified location, one time. If someone goes to a certain page for the first time, we want to make sure the splash content shows up. But if the person is coming from an internal link on the site, we don't want the splash content to show up over and over again (otherwise, the splash page would become a nuisance).

These modules implement the flash features in a Drupal site:

For D6 : https://drupal.org/project/splash
For D7 : https://drupal.org/project/splashify


Post Migrate Development to Live Production Server issue

The first place to look would be the BlueHost Error Logs; their article at https://my.bluehost.com/cgi/help/562 describes where to find them within cPanel. If you're seeing failed calls to functions / modules that you know exist in your codebase, there's a strong probability that Drupal's registry is not current.

Drupal caches extension (module and theme) file locations within its registry. Given that you are importing an existing site database into a different structure, those locations are out-of-date.

If you haven't already, I suggest installing Drush (the DRUpal SHell) using the instructions at https://drupal.org/node/1181480

Then, clear the site cache:

drush cc all

If that does not clear it up, the next step is a registry rebuild. This forces Drupal to rescan executable file locations. Install the Drupal contrib project registry_rebuild using the instructions on the project homepage, then

drush rr

to rebuild the registry.


How can I get the uploaded file path of a contact form in drupal 8

You can get the file entity directly from the field and check if the field is not empty before applying any methods on the file object:

/** @var \Drupal\contact\Entity\Message $contactMessage */
$contactMessage = $message['params']['contact_message'];
$file = $contactMessage->field_file->entity;
if (!empty($file)) {
  $fileInfo[] = [
    'value' => $file->getFilename(),
    'url' => $file->url(),
  ];
}


Import external modules yaml config through own hook_update_N implementation

If you have no data then reinstall the module.

If you want to keep the data then this depends what you have changed in the configuration. You can try how far you can get with the method you've described. If you only add fields, this will probably work. Also minor changes to a field can work. But if you change how a field is stored in the database this will not work.

The official way to do this is described here https://www.drupal.org/node/2554097.


Send email only if a field has a certain value

I would use a technique similar to what is described in my answer to "How can I compare data comparison with values submitted in a webform?". For short:

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


If I understood you correctly:
You have exposed filter in block, which have for example two fields, search by title and checkboxes.

So you can use: https://www.drupal.org/project/better_exposed_filters

After installing module: change Exposed form style from Basic to Better Exposed Filters
Click to BEF Settings
Check Enable secondary exposed form options
Expand yours fields what you need to hide before type in search box and check this: This is a secondary option
Use jQuery:

$("input.yourSearchBox").keyup(function(){

    $(".views-widget-filter-secondary a").trigger('click');

});


How to programmatically associate a taxonomy term to a field

appendItem takes an array.
Try $profileEntity->field_entry_university->appendItem(['target_id' => $term->id());


How to deal with SalesforceException: HTTP Method 'PATCH' not allowed

The format of the HTTP SFDC API callback for inserting/upserting records is:

/services/data/v20.0/sobjects/ObjectName/customExtIdField__c/Id

The ObjectName is the Name of an Salesforce table i.e. 'Contact' or 'Account'. And Id is the Id of a specific record you want to update in the table.

The possible cause of the error for that would be that you're calling SFDC API with the invalid data.

Please check if your REST URL is correct, probably your objectId is not passed through. E.g. If you have dependencies between the other objects, check if these were created in the first place, before creating your main object.

Related:

Update records using Salesforce REST API - Patch method not working


I think the easiest way to resolve this is to use Content Access and specify the View permission for a Webform, rather than Webform's "can submit" permission.  In other words, by using the Content Access module's View Permission instead of the Webform "can submit" permission, you can utilize the code you're currently using.  To do this you'll have to set a separate View permission for each Webform.

The problem originates from Webform's permissions conflict with Drupal core: Drupal's standard View permission may be true, but the Webform "You can submit this form" permission can be false, which gives a different Access Denied message from above.

I attempted to dig up an alternate solution, creating some custom code to derive the access for Webform menu items, but it really was looking horrendous.  Webform does not have a function that returns "You can submit this webform" access, and trying to efficiently determine if a menu item is a webform was looking pretty foul.


Can't get drupal_array_get_nested_value to work

The function actually takes an array as the input and the first value is the array to be searched.

so your code should be as follows

$field_type = array('my_field_type');
$value = drupal_array_get_nested_value($form,$field_type);


You can leverage field_attach_load() for this:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node', '=')
  ->propertyCondition('status', 1, '=')
  ->propertyCondition('type', 'wall_of_words', '=');
$result = $query->execute();

$nodes = $result['node'];

// Get all fields attached to a given node type
$fields = field_info_instances('node', 'wall_of_words');

// Get id of body field
$field_id = $fields['body']['field_id'];

// Attach a field of selected id only to get value for it
field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' => $field_id));

Now you have $nodes array of "half-loaded" nodes, where you can get your field data from like it were a usual node, just do something like this:

foreach ($nodes AS $nid => $node) {
  print $node->body['und']['value'];
}

Note. I used 'und' for language here. You may want to query for node language field here to get a dynamic language data if needed.

So this should work.

UPD. One note to this. field_attach_load() doesn't invoke hook_node_load(), so if some data is being manipulated via hook_node_load() you won't get its representation via described method. This is the only drawback of this method. But in most cases it is safe to use. Just check if it works in your circumstances.


Far from needing extra libraries, Drupal needs less libraries then you're giving it.

Drupal 7 ships with jQuery 1.4, and can be updated to 1.5.2 with the jQuery Update module. Updating to v1.7 is not really feasible at the moment (see How do I update jQuery to the latest version I can download?, and search the site for 'latest jquery' for more information on that).

Even if the core/contrib Drupal JS worked well with v1.7, you can't just add it to the page and expect it to work, it will conflict with the core jQuery libraries added by Drupal (see jQuery.noConflict() for background).

That said, I can't see anything in your code that would necessitate using jQuery 1.7, so just remove the erroneous line from your .info file, clear the caches, and move on :)

To address the problems with your code now that the correct jQuery files are being included:

Your JS looks like this:

if (thumbstart[i].title && thumbstart[i].title.length > 0)

So the wrapper won't be added unless the  has a title. If you look at the source code of http://icon-guideline.fanlobby.net/ you'll see that the markup is as such:

As you can see, there's no title on any of the images, so your JS condition will never resolve to true, and the wrapper will never be added.


How to add a button to report (flag) some content item to an administrator for that content?

You should investigate the flag module https://www.drupal.org/project/flag and Rules https://www.drupal.org/project/rules (remembering to use version 2.7 of the latter if using drupal commerce) that should allow you to create a "report" flag and send a notification to an admin.


In the end the Semantic Views module helped me achieve what I wanted to do.

I specified that rows had no tag and fields instead were <li>, I had to modify the template too, for consistency and theming reasons to reproduce the original layout of a normal view.


Drush syntax error, unexpected T_FUNCTION in webform.module

It's seems to be a problem with the anonymous function. I read some post that talk about a problem with eAccelerator and the PHP version. The recomendations are:

disabling eAccelerator and opcode caching
replacing eAccelerator with Zend's opcache
reverting to PHP 5.3

You can read more at:

The Webform issue about "Parse error: syntax error, unexpected T_FUNCTION"
http://php.net/manual/en/functions.anonymous.php#113422


In the leftmost column, Format > Show needs to be changed from Content to Fields. Hat tip to https://drupal.stackexchange.com/a/5413/4371


Internationalization -- impact on other modules?

The i18n modules can have a huge effect on a site, as they integrate with a large number of modules. Many modules for example deal with taxonomy terms and displaying them, so they all need to be compatible with i18n.

The main problem is that many content elements (like menus, taxonomies, ..) are not designed to be translatable or even just language aware. So the i18n project needs to alter a lot of things and build data structures and API's on top of those provided by core.

Also, there have been a number of API changes unfortunately, so it's possible that the modules you mentioned have a broken i18n integration due to that.

You need to provide more details on what exactly isn't working to get more help than this. You can also try to check the issue queue of the broken modules to see if there already is an issue for this and if not, open one.


Ajax modal does not show for authenticated users

For use-ajax to work for Anonymous as well as Authenticated user, Core core/drupal.ajax library must need to be loaded on page, where we're using 'use-ajax' class.

You can include this library with either using #attached in your Form or Controller or you can implement hook_page_attachments hook and attach ajax library.

If you're trying to add link to text inside your form, you can directly use #ajax instead of using classes as per directed in Ajax commands for opening and closing Dialogs and generic Dialog Controller added to core

  $form['link'] = [
    '#type' => 'link',
    '#title' => 'Link 1 (modal)',
    '#url' => Url::fromRoute('ajax_test.dialog_contents'),
    '#ajax' => [
      'dialogType' => 'modal',
    ],
  ];

Hope this helps.


How can I create a display in views with different filter criteria

You can clone your first display. In your second display you can add additional filters. Be sure when you add filters to choose to override from the dropdown menu, located at the top-left of your filter modal. This way, the additional filters are applied only to your second display.


Disable displaying user picture in page--user.tpl.php

If you don't want it at all in the user registration you can navigate to : admin/config/people/accounts/settings and uncheck "Enable user pictures" on that page.

If you dont want it only on the user profile page you can add this snippet to template.php in your theme folder

function THEME-NAME_preprocess_page(&$variables){
  if (arg(0)=="user" || arg(0)=="users" ){
    unset ($variables['page']['content']['system_main']['user_picture']);
  }
}


How to display the variation of a custom display in Twig

You can create another template for that specific view mode.

The naming of that template should be commerce-product-variation--product-type--view-mode.html.twig.

So you can create a template called commerce-product-variation--PRODUCTTYPE--teaser.html.twig, and then print the image field from there.


D7 Organic Groups - Set group context in panel

Ahh. After a week of fighting with this, I figured out that the "OG Members" Content Pane will work after some extensive customization. Somehow, I deleted this in my install, so I didn't know about it. I will use this as a starting point template for future group/panel needs.


Go to /admin/config/development/performance

Uncheck Aggregate and compress css files

Now with your browser right click and inspect element, hover mouse over the .css file and it will tell you where it is at.

If it's coming from a contrib module, you should add your css on your theme's CSS file (in your case being local.css), as when you update that contrib module, it will lose the changes.

As you can see in my screenshot, that is coming from my theme's homepage.css file.

PS: After you're done, remember to turn back on (check-mark) Aggregate and compress css files in Performance.


Missing tabs in Media Library widget in Drupal 8.8

This can happen when the field is not configured to reference any media types. It's a quirk of the underlying entity reference system that can be exposed under some circumstances.

The solution is to edit the field settings and ensure that the field is configured to reference at least two media types. (If only one media type can be referenced, the widget has no relevant settings to display.)


how to programmatically alter the rendering of a field in Views

You can do that in the views interface, no need for pre- or post- processing on the theme level (as your script snippet suggests).

I assume that you are using Drupal 7.x and Views 7.x-3.x.

Go to the UI for the view you want to change:

http://example.com/admin/structure/views/view/yourviewname/edit
or Home » Administration » Structure » Views » Yourview

Make sure you are on the Display that you want to change (towards the top: Display has tabs "Page", "Add" and maybe others like "Block" or similar)

Under "Format", it shows "Format" and "Show". "Show" needs to be set to "Fields".

The click on the field with your url, like:

 Content: URL (URL)

A popup window will open with:

 Configure field: Content: URL

Click on "Rewrite Results" - a number of options open, check:

 Rewrite the output of this field

A couple of additional fields now open up.

Click on "Replacement patterns" and identify your url field, for example:

[field_url]

Now, enter the text you want to display into the "TEXT" field (can be html tags like an image tag):

An image tag
Some text

Check "Output this field as a link", and enter the replacement pattern into the "Link path " field [field_url].

If you want to use another field from your content type to show instead of something generic, that field needs to be on the "Fields" list BEFORE the field_url field, but can be marked as "invisible" if you don't want to display it otherwise.


Didn't see this before.

The shortest way to get the referenced entity for a single-value field is this:

$node->field_image->entity->url()

You can also specify the delta explicitly:

$node->field_image[0]->entity->url()

This works with a lot of ArrayAccess and __get() magic.

See also the great cheat sheet at http://wizzlern.nl/drupal/drupal-8-entity-cheat-sheet. and https://www.drupal.org/node/1795854 and the other documentation pages there for more information (still very much work in progress).


How can I edit the html of the title of my node page

Depending on your current theme, the title may be found in the node.tpl.php, the page.tpl.php (usually this one) or html.tpl.php. Enable theme debugging to toggle theme debug comments. That way, you see which templates control which portions of the page.

Add the following to settings.php and refresh a couple of times (clear cache if it becomes stubborn). Then inspect the page.

$conf['theme_debug'] = true;

With theme debugging on, you'll also see the progression of template name suggestions in the comments, with the top most/most specific/longest name being selected first.

You can also add to this list by altering the theme_hook_suggestions property in the variables argument of the appropriate hook_preprocess_ hook. If I remember correctly, there's no suggestion content type suggestion for templates. If so, you'll have to add one.


Search API Views Indexed Node Filter by Author Role

You need to index the author's roles so that Search API can query that field.

Visit the fields configuration page for your node index (probably admin/config/search/search_api/index/default_node_index/fields if you're using the default node index).  At the bottom of the list of fields you'll see a fieldgroup called "add related fields".  Expand that, choose author, click "add fields".

When the page reloads your big list of fields will now contain a bunch of new Author-related fields including Author » User roles.  Check the box next to that one, choose how you want it indexed (integer or string are probably the only ones you'd care to use for this purpose), save your changes, and re-index your content.

I've found that with these sorts of changes I need to clear my cache twice in order for the proper data to be registered with Views and for the appropriate filters to appear in my Views.


How do I create a view that shows the results of a content type related to the current page?

You need to include a Node ID contextual filter as well that is set to Content ID from URL. Then make sure that each of the Fields are set to relate to the relationship entity reference field you are using. I'll try to explain below.

Adding a Contextual Filter that looks for the Content ID from URL is required as the view will use the found nodeID and use that to know what node it should relate it's fields and relationships too.

You will then want to add a Relationship field that is the Entity Reference field that creates the relationship between the Trips (children) and the Mountain (parent).

Now with the fields, if you just add fields and do not modify any settings, the view will only display content that is available in the original node. For instance, adding the Title field will display the title of the Mountain and not the title of the Trip reports. This is because it doesn't know it should get the information from anywhere else, even though we added the Relationship field before.

This is why you need to modify the fields and set their Relationship to the Entity Reference field. This will now tell the view that even though we are on the Mountain node and have it's ID, the fields are going to output the content related to the entity that is referenced by the nid in the contextual filter.


Normally with drupal you would not have several databases each with their own fragment of the database, and combined you have a whole site.

With drupal 7, drupal now supports database masters and slaves from within the application. What this means now is say you need 3 database servers to support your sites non-functional requirements (availability, performance etc), you can now add:

<?php
$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => 'drupaldb1',
  'username' => 'username',
  'password' => 'secret',
  'host' => 'dbserver1',
);
$databases['default']['slave'][] = array(
  'driver' => 'mysql',
  'database' => 'drupaldb2',
  'username' => 'username',
  'password' => 'secret',
  'host' => 'dbserver2',
);
$databases['default']['slave'][] = array(
  'driver' => 'mysql',
  'database' => 'drupaldb3',
  'username' => 'username',
  'password' => 'secret',
  'host' => 'dbserver3',
);
?>

This definition provides a single "default" server and two "slave" servers. Note that the "slave" key is an array. If any target is defined as an array of connection information, one of the defined servers will be selected at random for that target for each page request. That is, on one page request all slave queries will be sent to dbserver2 while on the next they may all be sent to dbserver3.

The above is straight from the docs ;)

I would recommend the above approach as this is a supported configuration, if you decide to create your own custom drupal schema or load splitting algorithm - you now have to support it.

With drupal 6 - you are pretty much forced to use pressflow. Pressflow is a performance based fork from the drupal code base that tries to keep 100% API compatibility with drupal. Lullabot wrote an awesome article on database replication with pressflow 6.

It turns out lullabot released their views 3 slave query module on github as well, fork away!


"Site off-line due to technical problems" (no extra info in message). What causes this?

I'd wager you're using Drupal 6. And yes, it means a fatal error in connecting to the database.


Storing permanent value in Form while in validation handler

$form_state['storage'] is probably what you're looking for. I've used it on multi-step forms myself to preserve necessary data that I need during various stages of the form processing. As an example you can define a storage variable like this:

$form_state['storage']['mykey'] = 'myval';

Edit:
Considering the additional information you provided it is indeed not quite as simple in your specific case. Setting $form_state['rebuild'] = TRUE; in the form validation handler also means that the user set form values will be lost. So what I think you could do is the following:

In the form validation handler function:

if (!isset($form_state['storage']['mykey'])) {
  $form_state['storage']['mykey'] = 'myval';
  // Save all the user set form values.
  foreach ($form_state['values'] as $key => $val) {
    // If you want to skip some values do it here.
    $form_state['storage']['values'][$key] = $val;
  }
  $form_state['rebuild'] = TRUE;
  drupal_set_message('Press submit again to confirm');
}

In your form builder function use the stored values as defaults. Example:

$form['key_1'] = array(
    '#type' => 'radios',
    '#title' => t('Title'),
    '#options' => array(0,1,2),
    '#default_value' => $form_state['storage']['values']['key_1'],
);

Not sure how well the example code fits your needs, but it should get you started or at least give further ideas/options to try out.


hook_form_alter doesn't load load my form_id

You have 3 options if you wish to hide a form item:

Use .css and make your life simple using display:none;
create a custom module (see below)
Why even have the cck field if you are going to hide it? What's the point of that?

Please note that the above tutorial DISABLES the field and does not HIDE it. Disabled fields can not be edited, but they are still displayed!

To point 2:
Is this function in your themes template.php? If yes, I presume your theme is called 'video_tutorial', if not, you should rename your function so it is THEMENAME_form_alter.

However, since you're using the edit node form it will actually be using the admin theme, not your front end theme - unless you have changed permissions for certain usergroups not to be able to access the admin theme or you are using the front end theme as your admin theme (unlikely) -, so you're better off creating your own module to override the form rather than using the themes template.php file:

How to create your custom module:

Create a folder, call it whatever you like - but it should make sense - eg:

custom_admin_overrides

In it, create two blank text files:

custom_admin_overrides.info
custom_admin_overrides.module

Open custom_admin_overrides.info and add the basics so drupal can see your module:

name = Custom Admin Overrides
description = Custom Module that provides Admin Area Overrides
package = Custom
core = 7.x

Save the .info file and add the following to your custom_admin_overrides.module file:

<?php
function custom_admin_overrides_form_alter(&$form, $form_state, $form_id) {
 if($form_id == 'YOUR_FORM_ID') {
  $form['FIELD_NAME']['#disabled'] = TRUE;
 }
 // YOU CAN UNCOMMENT THE BELOW FOR EXTRA HELPFUL DETAILS
 // GET FORM ID UNCOMMENT BELOW
 drupal_set_message("YOUR_FORM_ID is : " . $form_id);
 // GET ALL FORM ELEMENTS UNCOMMENT BELOW
 // drupal_set_message(dprint_r($form, TRUE));
}

Note that we aren't closing the

Save and upload the folder to your site/all/modules/custom/ folder.

Now enable the module and from that point onwards you should see the form id's displayed on all admin pages in the drupal message box at the top.

Now go to your specific node create/edit page and make a note of the form id and the field name you wish to disable. Now reopen your custom_admin_overrides.module file and replace the values for

YOUR_FORM_ID

and

FIELD_NAME

Save and now your field should be uneditable. Uncomment the following line to stop displaying the form id's:

drupal_set_message("YOUR_FORM_ID is : " . $form_id);


Right. In order to "do" anything with views in a module, you have to implement hook_views_api. Without this, your module won't be recognised by Views, at all, ever (AFAIK).

Please add the following to your module code:

/**
 * Implementation of hook_views_api().
 */
function alterform_views_api() { // your module name into hook_views_api
  return array(
    'api' => 2,
    // might not need the line below, but in any case, the last arg is the name of your module
    'path' => drupal_get_path('module', 'alterform'),
  );
}

This should fix it so your module is at least recognised, then you can start debugging it :)

A good way to start debugging a view (i.e. a baby step) is to put dpm($view); right at the start of the views function you're implementing. In most cases, that will dump info onto the screen that will help you see where you're at. Would suggest doing this with devel.module installed/switched on.

Edit: This assumes Views 2 and Drupal 6. You'd best ask around if those aren't your weapons of choice.


To theme a custom template for profile2, try the following:

copy profile2.tpl.php from your module folder, to your theme's template folder
rename the file profile2--machine_name.tpl.php (profile2--user.tpl.php)
adjust the template as desired
clear the cache


How to redirect search result page in drupal

You can use the redirect attribute in form_state as follows,

function mytheme_search_box_form_submit($form, &$form_state) {
   $form_state['#redirect'] = 'Your path to redirect';
}


Convert dropdown of exposed sorting of view into Checkboxes

I Suppose this may help you using Better Exposed Filters


How to specify AND, OR with dynamic query

I don't have the same structure of your table  but i test it with the following statement it works:

SELECT *
 FROM `node__body` AS n_b
 WHERE n_b.`deleted` = 0
 AND (
 n_b.`revision_id` IN (32,6,17)
 OR  n_b.`langcode` IN ('fr')
 );

here is the code snippet for your case:

  $query = $connection->select('inventory', 'inv')
    ->fields('inv', ['part_number'])
    ->condition('inv.visable', '1', '=');
  //- Set Or Query group
  $group = $query
    ->orConditionGroup()
    ->condition('inv.part_number', [SUBQUERY_1], 'IN')
    ->condition('inv.part_number', [SUBQUERY_2], 'IN');
  //- Add Or group
  $query->condition($group);
  $result = $query->execute()->fetchAll(PDO::FETCH_ASSOC);


How to manually check if a username and password is correct?

Drupal 6 and 7

user_authenticate($username, $password);

Drupal 8

// Inject user.auth service..
$uid = $this->userAuth->authenticate($username, $password);
// or
$uid = \Drupal::service('user.auth')->authenticate($username, $password);

Source: How to check logged in user username/password/role using Drupal function for validation


Not sure but try grouping with all the fields that are common between this 2 like the job title should also be in group so that it will be display only once


You need to install (or perhaps just begin using) Commerce Discount.

Discounts are applied either to the individual product line items (product discounts) or the order total (order discounts).


Try this, it works for me, I just tested. I don't think you need #type and http-equiv needs to match in the html head call.

/**
 * Implements template_preprocess_html().
 *
 */
function mytheme_preprocess_html(&$vars) {

    $element = array(
        '#tag' => 'meta',
        '#attributes' => array(
          'http-equiv' => 'X-UA-Compatible',
          'content' => 'IE=edge,chrome=1'
        ),
      );
      drupal_add_html_head($element, 'http_equiv');

}

Beyond that, if it does not work, then you have some other issue. Be sure to clear all caches.


How to use redirects on Nodes that are only used to populate block Views

You can use Rabbit Hole module for this.

  Rabbit Hole is a module that adds the ability to control what should happen when an entity is being viewed at its own page.
  Perhaps you have a content type that never should be displayed on its own page, like an image content type that's displayed in a carousel. Rabbit Hole can prevent this node from being accessible on its own page, through node/xxx.

  Options

  This works by providing multiple options to control what should happen when the entity is being viewed at its own page. You have the ability to

  Deliver an access denied page.

  Deliver a page not found page.

  Issue a page redirect to any path or external url.

  Or simply display the entity (regular behavior).

  This is configurable per bundle and per entity. There is also a permission that lets certain roles override Rabbit Hole completely.


Admin Approval for Webform Submitted data

You can try something like this for admin approval:
 1. create custom content type;
 2. create fields just like your webform has;
 3. copy copy webform-confirmation.tpl.php and change the name webform-confirmation-NID.tpl.php
4. there write something like this:

include_once(drupal_get_path('module', 'webform') .'/includes/webform.submissions.inc');
$nid = arg(1);
$sid = $_GET['sid'];

$submission = webform_get_submission($nid, $sid);

$otzyv_text = $submission->data[1]['value'][0];
$name = $submission->data[2]['value'][0];
$email = $submission->data[3]['value'][0];
$title = mb_substr($otzyv_text, 0, 10);

$node = new stdClass();
$node->type = 'response';
$node->title = $title;
$node->language = LANGUAGE_NONE;
$node->body[$node->language][0]['value'] = $otzyv_text;
$node->body[$node->language][0]['summary'] = '';
$node->body[$node->language][0]['format'] = 'filtered_html';
$node->field_name[$node->language][0]['value'] = $name;
$node->field_e_mail[$node->language][0]['value'] = $email;
$node->uid = 1;
$node->status = 0;
$node->promote = 0;

node_object_prepare($node);
node_save($node);

(this is what i've done when my customer wanted to have an ability admin approval). By this way you will have unpublished nodes when someone submits your form (administrator can publish them whenever he wants).  After that in IF statement you can write something like:

$node = menu_get_object();
if($node->type == 'YOUR TYPE' && $node->status == 1) {
  // Display submitted data... You can fetch them from node object
}

or with Views module you can create block or anything you want by that content type...


What are some drawbacks/benefits of using ctools?

Discovered the best place to learn this is actually from a lecture from drupalcamp austin in 2010 by Erik Summerfield.

http://vimeo.com/17957123

That's just a start. Otherwise going through example ctools integrated modules has helped as well. The fact is (at this moment) documented use case examples are limited.


I want to make ajax call to module functuion

Please reread the documentation to drupal ajax documentation, particularly how Drupal behaviours do work.

You are missing one crucial part. Drupal calls the attach-function of your behaviour on documentReady or before DOM-elements get injected into the current document. As your JS-code does not have an attach-method, nothing happens. The code below should give you an idea how to fix your problem:

Drupal.behaviors.custom = function (context, settings)
{
  attach: function(context, settings) {
    $(document).on('click', '#clear-filter', function() {
      console.log("Hello");
      jQuery.ajax({
        type: 'POST',
        url: 'custom/field-work',
        dataType: 'json',
        success: function(data){
          console.log(data);
        },
      });
    });
  }
};


Search using external sites Google Search

It's simple ,, if you know the HTML part so make your form action to the search site and call your GET parameters into the form!

something like this:

        <form  action="bar.gov/gsearch" target="_blank" method="GET" id="search-block-form">
        <input type="hidden" value="q" name="terms">
        <input type="hidden" value="foo.com" name="search">
<button type="submit" value="Search">Search</button>
    </form>

edit: you need to make sure you have HTML tags enabled and not stripped in anyway so the form and any other HTML tags be available .


How to make the custom module effect on the node and only one content type?

If you want to add content to nodes, you can in drupal 6 use the hook_nodeapi where op is view.

As you get the node object, you can detect the node type ect. You would need to add something like this to your module

module_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch($op) {
    case 'view':
      if ($node->type == 'node_type') {
        // $a3 indicates if teaser
        // $a4 indicates if page
        $node->content['my_additional_field'] = array(
          '#value' => 'HTML', // create html with theme or form function.
          '#weight' => 10,
        );
      }
      break;
  }
}


How to supply hidden field value to node based on webform?

You can pass a field's value as a token to the webform.

You would need to add 'field_white_paper_title' to your webform node and then change the "Default webform submission data (YAML)" to

white_paper_title: [webform_submission:node:field_white_paper_title]


how i create panels with custom tag like header, section footer etc..?

I am not sure it will be the correct answer. However my opinion is the following.
From the code you have specified it looks that you want to make your entire website with panels. (Remember with Panels you design only the node section of the website).

So you may want to consider  Panels Everywhere Module.
After Quick research I've just discovered that there is a new Theme AT Panels Everywhere.
It is a Subtheme of Adaptive Themes - the best Drupal responsive theme (it is my opinion and I use it on every project).

I think you should invest some time learning Panels, Panels Everywhere and Adaptive theme, it will certainly pay for the efforts!

Best regards!


It works when $uuid is initialized inside the function.

function emailf_form_submit($form, &$form_state) {
  global $user;
  $uuid = $user->uid;

  $bb = $form_state['values']['emailf'];
  $query = db_update('users')
    ->fields(array('email_f' => $bb))
    ->condition('uid', $uuid, '=')
    ->execute();

  drupal_set_message('Email frequency successfully changed');
}


how could the global $user be different between the Drupal interface and Services module?

Nice question!
After reading your question.
you are not logged in to your app because you are sending the anonymous requests after login.
Workflow should be like this :
1)User register on the site.you will get the session id and session name.
2)Now need to set the session id and session name in headers then send the requests. you can check the same in drupal logs that whether your requests are coming from anonymous user or authenicated user.
if drupal getting the requests from anonymous user then make sure that headers are properly set. See the services module documentation to learn out about this.
Browser tools :

The Poster add-on for Firefox.
The REST Console app for Chrome.

if you are using the services module then take a look at its documentation


Date field in FormAPI, remove Day field?

There isn't a setting for that, but you could do it with the #after_build option, as it will allow you to alter the form element after it has been processed (day, month and year fields have been created).


Taxonomy terms not translating on the edit/add node form

Best guess based on your description is that you need to enable the URL detection at

  /admin/config/regional/language/configure

since that appears to be how you are distinguishing the interface. This recipe from http://drupal.org/node/1281704#comment-5253460 should also help:

Enable ALL i18n modules
Add your extra languages
(optional) - Enable Localization update and run Update translations at /admin/config/regional/translate/update
Enable URL detection method at /admin/config/regional/language/configure
(optional) - Throw that Language Switcher block into a visible section of your site
Add your Localized vocabularies and translate them
Add your terms and translate them
Edit the content types you want term references to appear in and Enable Multilingual Support (with translation) in Publication Options vertical tab
(recommended) - In the Synchronize Translations vertical tab check the first two checkboxes of the Extended language options. That is: "Set current language as default for new content" and "Require language (Do not allow Language Neutral)"
Add term reference fields to the content types you want


Video host URL different in full content page links than in View links

The solution was to install the Dev version of module Image Link Formatter (7.x-1.0+6-dev). It now seems clear, this module (the current recommended version) was invisibly rewriting the URL, as there is no other way it could be specified to be rewritten in the standard interface options for the content type's fields. Although there was no documentation found for this issue in the issue queue or in documentation about the Dev version, apparently it is a bug that was fixed.


You just need to change the line to:

$form['#validate'][] = '::mycustom_form_validate';

Drupal has special handling for that :: prefix (see FormState::prepareCallback), and processes the above to an equivalent callback of:

[$form_object, 'mycustom_form_validate']

Which will correctly resolve to your custom method.


How to change URL alias when importing books?

Have you created a vocabulary for these books?

If not:

Create a vocabulary, e.g. "books_category"
Add to your content type field, e.g. "books_category" (field type: Term reference), choosing the vocabulary you previously created as reference

After that, click at replacement patterns (admin/config/search/path/patterns); choose group "Tokens related to individual content items," or "nodes"; you will find a group of patterns related to your "books_category" field.

I assume you installed the Pathauto module.


in hook_form:

$form['first_element'] = array(
  '#prefix' => '
',
  '#title' => t('First name'),
  '#type' => 'textfield',
  '#default_value' => '0',
  '#required' => TRUE,
);
$form['last_element'] = array(
  '#suffix' => '
',
  '#title' => t('First name'),
  '#type' => 'textfield',
  '#default_value' => '0',
  '#required' => TRUE,
);
return $form


How to force display of a specific page of paged data

I'm half way there!
In hook_views_pre_build(\Drupal\views\ViewExecutable $view) I figured that the $cnt item was the most current; from there it was a simple matter to calculate which page that item would appear on and to set that as the current page.
$pager = $view->getPager();
$defaultPageNum = round($cnt/$pager->getItemsPerPage());
$pager->setCurrentPage($defaultPageNum);

This works like a charm; however, the pager links at the bottom of the page do not auto-magically update and still indicate that I'm on page 1 (instead of page 62).
Anyone know how I get these links to update?


How to get defined display names (id) from selected view?

This will loop through every page display and set a menu item.

  $view = views_get_view('VIEW_NAME');
  foreach ($view->display as &$display) {
    if ($display->display_plugin == 'page') {
      // Add an if or switch statement here to check $display->id
      // so you can set different menu items for each display.
      $display->display_options['menu'] = array(
        'type' => 'normal', // Menu item type.
        'title' => t('Menu item title'), // Menu item title
        'description' => '', // Menu item description
        'name' => 'main-menu', // Menu name
        'weight' => 0, // Menu item weight
        'context' => 0, // Not sure off the top of my head what this is for.
      );
    }
  }

However this will set the same menu item for each display.
You will need to check the $display->id for each one so that you can set a different menu item for each display.

Also, that example sets a normal menu item.
If you want a local task or default local task it will be slightly different.

...also, why do you need to do this? why not add the menu item via the views UI?


How do I sort or filter a View by proximity using Search API location?

If you want to filter based on some user selection, you can have PHP code which gets the value and filters result based on that.

Please check this http://murtuza88.blogspot.in/2014/11/use-drupal-location-module-to-filter.html for detail steps on how to filter view based on user selection.


I guess it's a bug in WebKit/Blink http://dev.ckeditor.com/ticket/9998. I don't know what you did with your text so I can't help more. But if it does not happen within Firefox or IE, then it is definitely that bug.


Allow views custom plugins on a particular filter criteria only

You can use a hook_form_alter to add a conditional display of your filter based on the video selected option.

 /*
  *Implement hook_form_alter
  */

function MY_MODULE_form_alter(&$form, &$form_state, $form_id) {
   //dsm($form) -> to get the form['#id']
   if ($form['#id'] == 'views-exposed-form-YOUR_VIEWS_NAME-DISPLAY') {
      $form['YOUR_FIELD_NAME']['#states'] = array(
       'visible' => array(
        ':input[name="THE_VIDEO_FIELD_NAME"]' => array('value' => 'THE_VIDEO_KEY'),
        ),
     );

   }
}

YOUR_FIELD_NAME is the field to display conditionally


drupal site is really slow on VPS server

Isn't it closer to 4Gb RAM based on your posted stats?
A server with only 1Gb RAM will most likely not work properly with a full application stack. Apache and MySQL require memory to be performant. The least I'd recommend based on personal experience is 2Gb RAM.

What you can also do is perform traces on your site with xhprof to see what the slowest items are, and improve those.
APC and memcache can also help to boost speed. Or if you only have anonymous users, using the boost module can be a very quick fix, although it's not maintained actively anymore for Drupal 6 it seems.


You will need to make sure that users import content by creating a node. You can then map the author of that node to the author of the feed items that get created.

Make sure your importer is attached to a content type. Users can then import content by creating a node of that type. If you use the standalone import form, you cannot track which user uploaded what.

Map "Feed node: User ID (parent:uid)" to "User ID (uid)". This will make sure that the author of all nodes that get created will be the same as the author that is set on the feed node.

If you are using the CSV parser, manually enter parent:uid instead as source.