Drupal\Component\Plugin\Exception\PluginNotFoundException: The "glossify_taxonomy" plugin does not exist.

There are two approaches (if you don't want to reinstall the module's source code to production and work through the same steps to fully uninstall it).

If you have command line access to the webserver, you could try using drush to uninstall the module on production. Run drush pm-uninstall glossify_taxonomy and then drush pm-uninstall glossify
If that fails, you could schedule a content freeze, download the database to your local instance, and manually set the module as "disabled". Unlike Drupal 7's variables table however, each module does not have it's own row of data.  Instead all module enabled/disabled states are aggregated and saved in the row of data where cid = core.extension within both the config and cache-config tables. To disable the module without fully uninstalling:

load the exported database from prod locally and:
Open ‘config’ table
Search row with ‘core.extension‘
Download Blob object
Unserialize Data (http://www.unserialize.me/ is a quick online tool to serialize and unserialize)
Unset the glossify & glossify_taxonomy modules or remove them from the array.
Serialize Data
Upload Blob object
Save the edited record
Open ‘cache-config’ table and repeat steps 2-8
Export the modified local database
Before making changes on production, keep a backup of the database for quick reversion if needed.
Import the modified local database back to prod
Test to see if you continue to observe the Missing Module warning/error.


Instead of using header redirect try using RedirectResponse class which comes together with the Symfony HttpFoundation.

use Symfony\Component\HttpFoundation\RedirectResponse;

 function my_menu_callback_foo() {
    //....
    return new RedirectResponse(\Drupal::url('user.page'));
 }

Refer link for more details.


Setting up the private file directory (nginx)

Have a look at Perusio's config, it has all the information and explanation you need. Here is a quote from it:

  This config assumes that private files are stored under a directory
  named private. I suggest sites/default/files/private or
  sites/<sitename>/files/private but can be anywhere inside the site
  root as long as you keep the top level directory name private. (...)
  Example: Calling the top level private files directory protected
  instead of private.

location ^~ /sites/default/files/protected {
  internal;
}

  Now any attempt to access the files under this directory directly will
  return a 404.

...

  The usual practice involves setting up a directory outside of
  files directory and giving write permissions to the web server user.
  (...)  I think it to be less advisable, in the sense that now there's another directory that is writable by the server.

  I prefer to use a directory under files, which is the only one that is
  writable by the web server, and use the above location (protected or
  private) to block access by the client to it.

In short, marking it as internal is enough.


How is a field's value (rather than its key) obtained?

As you can see, you pass to field_get_items() the $node parameter. This should tell you that this function will return you a value stored in this Entity. The values of your field are stored in the field itself. You can get your options array as following.

$fieldData = field_info_field('field_group');
$options = $fieldData['settings']['allowed_values'];


I'm assuming this is Drupal 8 so my answer is for Drupal 8.

You need to do two things:

Create a service provider in your custom module that extends ServiceProviderBase.  The name of this class must be your module name, in camel case, plus "ServiceProvider", i.e. MyUserAuthenticationModuleServiceProvider.  Then, implement the alter function which sets the class for the user.auth service, like this:

    public function alter(ContainerBuilder $container)
    {
        $definition = $container->getDefinition('user.auth');
        $definition- >setClass('Drupal\my_module\AuthenticationClass');
    }

The class you specify in the call to setClass above has to extend \Drupal\user\UserAuth and implement the following function, which returns true/false based on successful authentication

public function authenticate($username, $password)


I'm not sure if in D8 webform submissions are useable, fieldable entities yet.

Although I believe the EForm module may work as you expect. Allowing you to define forms the public can fill out and then very easily turn the content into drupal "pages" or reachable content at some url pathauto pattern.

Allowing the public and administrators to modified different fields, or subsequently edit submitted data is a Roles/Permission issue that drupal Core or other modules such as Field Permissions will let you achieve.


Why am I not able to pass a variable to my JavaScript code?

Have you try changing the order?

First load the drupalSettings attachment and after the library?

$build['#attached']['drupalSettings']['module_machine_name']['morris']['memGraph'] = $graph_total;
$build['#attached']['library'][] = 'module_machine_name/morris';


How to trigger an action when a site receives an email?

Here is how you might get it to work:

Use Mailhandler to create nodes by eMail. The content of the node could be the actual content of the request as contained in the eMail.
Use Rules to react to the event "after saving content" and combine it with the Message module to send the eMail back to the user.

If you're not familiar (enough/yet) with Rules, checkout the 32 (!!!) great, and free, video tutorials Learn the Rules framework, organized in 7 chapters. For more details about the Message module, refer to some interesting Use Cases detailed within its Community Documentation.


Omega theme conflicts with CSS of Seven administration theme, how to resolve?

When Drupal loads the Seven theme for admin, it doesn't load files from any other theme. Same goes vice-versa. So it's unlikely either theme can be to blame, or even involved.

There's no way to guess from here what styles are overwriting others unfortunately, you'll just need to dig further with dev tools until you find the culprit.

Methodically disabling contrib/custom modules and testing the results each time is a good idea if you can't see any where else to look in the dev tools, you can find or at least rule out a culprit that way.

You could also search the files for those modules for instances of "views-ajax-popup", maybe something you have installed is specifically targeting it through CSS or javascript.


Get current region name in node template Drupal 7

If anyone else runs into this and wants to know what region the node is being displayed in within the node template using the node block module or something like it. You can use the template_preprocess_node($vars) function and add the region to the content so that it will be in the content array in the node template like this.

$vars['content']['region'] = $vars['elements']['#block']->region;


Views - Rewrite Content:Link field based on content type

I think you need Views Conditional Field module for this. Based on condition show other field which will output different text.

Module page explains :

  Views Conditional is a simple module that allows you to define
  conditionals (if xxx then yyy) with fields in views. Conditions
  include:

Equal To
Not Equal To
Greater Than
Less Than
Empty
Not Empty

  Views conditional allows you to output text based on the result of the
  condition.


Insecure content warning with D7 and SSL

Simply remove $base_url from your settings.php file; Drupal will detect $base_url automatically.

If you must set this value explicitly, you can add a little conditional logic to your settings file, such as:

if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
  $base_url = 'https://example.com';
}
else {
  $base_url = 'http://example.com';
}


How to create an 'Add item' contextual link for views?

Checkout the Custom Contextual Links module. I haven't personally used it but it looks like it does what you're after. It also supports views as of 7.x-1.1.


Trying to import existing Drupal site to a Linux Mint VM - getting redirected to install.php

Some of what was said was correct for this issue.  Going through the install process would have been correct, however the install.php page was not loading because when I had gone through the install process on the previous server, acquia dev desktop had deleted the install.php.

The fix was to take my sites folder and put it into a freshly extracted Drupal directory (so that the install pages were all there), update settings.php to correct database info, then go through the install process, and finally drop the tables and import the back up of the database with the information I needed.

Another note:
Acquia dev desktop will add the database settings to the BOTTOM of settings.php which can be easily missed.  If you're developing on Windows for whatever reason, I recommend using a virtual machine.  WAMP is wonky with some Drupal modules and Acquia Dev Desktop can be hassle when trying to migrate Drupal sites so having a *nix VM can be very useful.


Adding nodes to term instead of terms to nodes


Sounds that you need Views Datasource module:

  Views Datasource is a set of plugins for Drupal Views for rendering content in a number of shareable, reusable formats based on XML, JSON and XHTML.


How to discard unsaved changes to a variant?

Finally got the answer from a Drupal guru- just deleted an entry from the ctools_object_cache table in the database. Everything works fine now.


Can you display data dynamically from a textfield in the URL and Name of Views?

I think you can still use taxonomy for this. The taxonomy can be open ended not need to make it closed to the terms you define.

When you add a taxonomy reference field choose the widget as autocomplete this will enable the user to add their own taxonomy term which may not be there in the list already.

If you are very particular about using the field then you can use that a contextual filter in a view so that it would appear in the url as mentioned.


Also display the block on slides content in full page view, and in your view add the contextual filter "Content: Nid" with the following settings :

  Provide a default value : Content ID from URL

It will be automatically filtered, but will still display all slides on your home page


Fatal error: Call to a member function diff() on a non-object

It seems like you're getting confused with your $to and $to1 objects. There is typo in your code. Try this on your later code:

$ot_hour =  $to1->diff($from);
$ot_minute =  $to1->diff($from);
$hour = $ot_hour->format('%h');
$minute = $ot_minute->format('%i');
$hourtominute = $hour*60;
$total = ($hourtominute+$minute)/60;
$entity_field[0]['value'] = $total;


I've never used (or even seen) that function before, but following the trail down to _node_mass_update_helper(), I think you need to use a format like this:

$updates = array('field_votes' => array(0 => array('value' => $votes)));

That array format is the standard way to update CCK fields in Drupal 6, and since the helper function does this:

foreach ($updates as $name => $value) {
  $node->$name = $value;
}

immediately before calling node_save(), I think that's what the problem is.


How to specify English path alias for Chinese?

Instead of using [node:title], use [node:menu-link] instead.


Setting up a development environment for drupal site

Yes it is possible to have the same DIR structure as on your live site using sym links.

Suppose subsite.example.com is a folder on live site on production you need a link like beta-subsite.example.com -> subsite.example.com And you can use subsite.example.com in both your environments.

SO folders on Live site will be

default
subsite.example.com

In dev environment one extra link has to be created pointing to subsite.example.com.


How do I customize the flag/unflag links?

Here is a solution that ended up working for me. In my MYTHEME.theme file, I put the following:

function MYTHEME_preprocess_user(&$vars){
  $f = \Drupal::service('flag.link_builder');
  $link = $f->build('user',$vars['user']->id(),'followed');
  $link['link']['#attributes']['class'][]="btn";
  $vars['follow_link'] = $link;
}

Then, in the user.html.twig template, I put {{ follow_link }} in the appropriate place. It's not a perfect solution, though, because it is not compatible with AJAX links (in which case the button styling is lost after the button is clicked). But with normal links, it works.


How to notify users from within a module

drupal_set_message() is what you're looking for.

Sample usage:

drupal_set_message('Mailchimp action is successfully executed.');


Is it stable to run Drupal 7.8 on php 5.3.8?

Yes. In fact, it is recommended to do so.


Limit node.js updates if the view is active

I had and just have the same problem with node.js views update. It seems that the module is refreshing every view that's in use.

I managed to get a workaround by styling my news feed with an open comment section. But i think this is only a solution when you do not expect a hughe amount of comments.

In another use case I implemented another workaround with jQuery:

On my page users can create requests and other users are able to answer these request. A request is a node type and an answer is a node type. They are connected through entity reference module and i wanted to have some sort of inbox functionality where every answer to a specific request is shown in a menu on the specific request page. A user could then click on a answer-menu-item and the whole answer is shown under the request. To give it a more chat feeling I implemented the comment form of the specific answer and styled it to look like a chat form.

This is done with two views implemented on that page. The menu functionality is done with jQuery (Click on menu item -> show related views row of second view). With node.js views refresh I managed to get the chat feeling (When a new comment is added -> refresh first and second view).

I then ran into the same issue like you described above. Each time a user submitted a new comment both views refreshed but the views returned to the their output states - for example: the user was reading an answer of user G and was commenting on that answer when the view was refreshing because of a new comment on an answer of user Y. The view returned to its output state and was not showing any answer because they were initially hidden to achieve the inbox / menu functionality.

My workaround for that problem is:

var content = [the views-row belonging to the menu entry]
$(specific-menu-item).click(function(e){
    $(".my-second-view .views-row").hide();
    $(content).show();
    Cookies.set('latest-viewed-answer', content);
    return false;
    e.preventDefault();
});

$(document).ajaxComplete(function() {
  var latest = Cookies.get('latestmessage');
  $(".my-second-view .views-row").hide();
  $(latest).show();
});

To get the Cookie thing working https://github.com/js-cookie/js-cookie

Sorry for my long answer, but i thought that it would be necessary to understand my needs to understand my workaround...

Because this is still a workaround and because I'm asking myself if there will be performance and server issues with our approaches (news feed and chat) I would love to see a solution that is really solving the problem.


How to sort drush status messages in test scripts?

You can log your debugging messages in database using watchdog
 and you will find the logged message in order at "admin/reports/dtblog"

Updated:
Check the document page, as for [status] , watchdog has $severity parameter to set the status for your message.Following values can be set as status for the logged message.

WATCHDOG_EMERGENCY: Emergency, system is unusable.
WATCHDOG_ALERT: Alert, action must be taken immediately.
WATCHDOG_CRITICAL: Critical conditions.
WATCHDOG_ERROR: Error conditions.
WATCHDOG_WARNING: Warning conditions.
WATCHDOG_NOTICE: (default) Normal but significant conditions.
WATCHDOG_INFO: Informational messages.
WATCHDOG_DEBUG: Debug-level messages.

As a simple example, check this

 watchdog('your_script_name', '!message', array('!message' => "something_happened"), WATCHDOG_ERROR);

the above will log message when called keeping severity as "error".


That's off-topic. But try this:

$ composer require ramsey/uuid

And then put the whole use statement without use into get_class_methods():

ksm(get_class_methods('Ramsey\Uuid\Uuid'));

Putting that into a new ReflectionClass() would actually give you much more useful output:

$class = new ReflectionClass('Ramsey\Uuid\Uuid');
$methods = $class->getMethods(ReflectionMethod::IS_PUBLIC);
ksm($methods);


Using hook_form_alter on exposed view filters on Drupal 7

You can get access to the view object within hook_form_alter by accessing $form_state['view']. That allows you to identify a specific view:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'views_exposed_form') {
        $view = $form_state['view'];
        if ($view->name == 'my_view_machine_name' && $view->current_display == 'display_name') {
            // alter your exposed form here
        }
    }
}


Entity storage is a storage controller for the entity that handles the actual CRUD operations of entity data in the storage. That means it is responsible for inserting and deleting the entity data in the actual storage/repository.

The storage can be a .yaml file (for config entities) or a SQL database (for content entities). There are some specific use cases for null storage (like e-mail message) which basically means no data is stored anywhere and entity with such storage is just virtual: It exists only per single request as you define it.

You can additionally write your own storage controller and use remote storage, a file, a stream or whatever the requirements are.


Can jquery code be triggered by ajax success?

Yes this is possible to track ajax reuests anywhere in code by jQuery alone, there are some Global Ajax Event Handlers in jquery you can use methods from it like:

.ajaxComplete():Register a handler to be called when Ajax requests complete. This is an AjaxEvent.

.ajaxError(): Register a handler to be called when Ajax requests complete with an error. This is an Ajax Event.

.ajaxSend(): Attach a function to be executed before an Ajax request is sent. This is an Ajax Event.

.ajaxStart(): Register a handler to be called when the first Ajax request begins. This is an Ajax Event.

.ajaxStop(): Register a handler to be called when all Ajax requests have completed. This is an Ajax Event.

.ajaxSuccess(): Attach a function to be executed whenever an Ajax request completes successfully. This is an Ajax Event.

The last one .ajaxSuccess() is what you need.

you can use it like this:

$( document ).ajaxSuccess(function( event, xhr, settings ) {
  if ( settings.url == "ajax/test.html" ) {
    $( ".log" ).text( "Triggered ajaxSuccess handler. The ajax response was: " +
      xhr.responseText );
  }
});


Hide a block when viewing own profile page - Show when viewing other people's profile?

You can use hook_block_access()

/**
 * Implements hook_block_access().
 */
 function mymodule_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\Core\Session\AccountInterface $account) {
  if($operation == 'view' && $block->getPluginId() == 'block_id') {
    $uid_from_url = Drupal::requestStack()->getCurrentRequest()->get('user')->id();
    if($account->id() == $uid_from_url) {
      return \Drupal\Core\Access\AccessResult::forbiddenIf($block->getRegion())
        ->addCacheableDependency($block);
    }
  }
  // No opinion.
  return \Drupal\Core\Access\AccessResult::neutral();
}

See more document function hook_block_access


D7: HTML email sent shows markup, how to fix?

Fixed.

Edited php.ini:
/etc/php5/apache2 # nano php.ini

-->

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -i -t

Set mailsystem to htmlmail, voila.


Try this out :

Make sure you set the right display of the field, like the following picture.
loop through Items and render vocab fields.

<?php foreach ($content['field_city']['#items'] as $item): ?>
   <?php print render($item['taxonomy_term']->name); ?>
<?php endforeach; ?>

Note : print only name field, if you have another fields in your vocabulary add them, like $item['taxonomy_term']->some_field


How to create a block to show a digital clock?

100% agree with Jimajamma above on extracting the stuff you need from the timeblock module, all it is really doing is just adding two javascript blocks with a minimal amount of formatting. For example, to replicate the 24-hour clock, all you have to do is create a new block with an 'unformatted' input format and add this code (extracted from the time block module):

Quick fix to replace the body unload with a jquery $(document).ready() call, though probably not necessary inside a block.


Now this problem has been solved, after VAP add percentage function
http://cgit.drupalcode.org/views_aggregator/commit/?id=2539ac5

Now I can add additional column calculating the percentage (as an example below):


How do I add a suffix to the price field?

Do you need to include the value in the field? If not, you could just put it in place with a template file. You can create a template file that formats that specific field, for example; see Drupal 7 Template (Theme Hook) Suggestions.

Otherwise, you can use the Simple Field Formatter module.

  The Simple Field Formatter module allows site administrators to easily control the display of field values with following features.

  Features:

  Prepend the field value with specified text/HTML
  Append the field value with specified text/HTML
  Reverse the Field Value
  Trim the Field Value
  Convert the field value to lowercase letters
  Convert the field value to uppercase letters
  Convert the first character of the field value to uppercase
  Convert the first character of each word in the field value to uppercase (7.x-1.x-dev)
  Replace some characters with some other characters in the field value (7.x-1.x-dev)
  Link the field value to node(7.x-2.x-dev)


Override the output of views with angular directives

After a lot of research and debugging i came across to this solution...

The problem of restriction of custom text field of a view is that it uses Xss::filterAdmin function (core/modules/views/src/Plugin/views/PluginBase.php:398 line)...

So i created module, then in mymodule.views.inc file I alter "hook_views_plugins_field_alter", i changed class that uses the views custom text filed in my own class that i created in mymodule>src>plugin>views>field>my_Custom.php.
 This class is copy/paste of core/modules/views/src/Plugin/views/field/Custom.php and changed only the \Drupal\views\Plugin\views\PluginBase::viewsTokenReplace only this form:

$build = [
    '#type' => 'inline_template',
    '#template' => $text,
    '#context' => $twig_tokens,
    '#post_render' => [
      function ($children, $elements) {
        return Xss::filterAdmin($children);
      }
    ],
  ];

to:

 $build = [
    '#type' => 'inline_template',
    '#template' => $text,
    '#context' => $twig_tokens,
    '#post_render' => [
      function ($children, $elements) {
        return $children;
      }
    ],
  ];

and from now the custom text don't escapes html tags...

For more control i created also one checkbox in field setting to control f i want to escape the text or note for this field and accordingly to the value of checkbox i activate or deactivate the Xss::filterAdmin function


I realize this is a bit late, but just in case it helps anyone who stumbles across this...

1) MENU_CALLBACK - Menu callbacks are a special type of page that isn't meant to be viewed by a user. They are used as an endpoint for APIs (such as AJAX requests). Menu callbacks sort of act as a way for an API to "call a function".

2) MENU_DEFAULT_LOCAL_TASK - The default local task is just the local task that is selected by default. An example of this is the "view" tab on nodes. See more about local tasks below.

3) MENU_LOCAL_TASK - Local tasks are tabs. When viewing a node as an admin, several tabs are visible (view, edit, etc). Each of those tabs a local task.

4) MENU_NORMAL_ITEM - This is a page. Simple as that.

5) MENU_LOCAL_ACTION - Local actions are similar to local tasks, except they are meant to conduct an action, rather than display information. An example of this is the "Add Content" link that displays on the Content Administration page.

6) MENU_SUGGESTED_ITEM - This is almost exactly like a regular menu item, except it's disabled by default. This can be used by module makers to suggest a menu item to the user, but leave it up to the user to actually enable it.


You can add query string or another argument to the link of article, for example:

node/[nid]/magazine or node/[nid]?ct=magazine
node/[nid]/book or node/[nid]?ct=book

After that you need to add visibility to the Book and Magazine block that appears in sidebar.

For Book block:

node/*/book

For Magazine block:

node/*/magazine

Hope it will help.

P.S. You can add argument or query string to the link of article through template_preprocess_node function by changing $vars['node_url'].

P.P.S. Just figured out that you can only use new argument, not query string.


How do I get link the files in libraries.yml with absolute url path

This is the example from the official documentation, notice this bit type: external:

angular.angularjs:
  remote: https://github.com/angular/angular.js
  version: 1.4.4
  license:
    name: MIT
    url: https://github.com/angular/angular.js/blob/master/LICENSE
    gpl-compatible: true
  js:
    https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.min.js: { type: external, minified: true }


How to create a user after ldap authenticaion?

The LDAP module will also allow you to automatically create a user after authentication.

Once you configure your server, look at the third tab LDAP
authorization Choose edit to configure that server
Under basic, enable and Only apply the following LDAP to drupal role
configuration to users authenticated via LDAP.
You can set the role of the new user by checking  drupal roles are
specified by LDAP attributes under IIB. Also name the field that will
be use to determine role
Configure part III. LDAP to drupal role mapping and filtering For
example, if the title field is Staff you may want to give a staff
role Staff|staff
Part 4    IV.B. When should drupal roles be granted/revoked from
user? Check "When a user logs on"
IV.C. What actions would you like performed when drupal roles are
granted/revoked from user? Check Revoke drupal roles previously
granted by LDAP Authorization but no longer valid.

There are other settings that you can configure but this should get you started.


The website encountered an unexpected error. Please try again later (WSOD). Debugging scenario

1- Install Drush if you have not installed it already.

2- Clear cache using drush.

3- Still if you are facing issues start debugging with error logs as following.

Add the following lines to your settings.php

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

While editing settings.php change its default file permission to writable.
And you may also add following to your settings.php

$config['system.logging']['error_level'] = 'verbose';

Additional information is available here!

4- If you see any error related to any custom/contributed module after enabling error reporting service.You may overwrite the particular module folder with its latest release or even try with its dev release

5- You can read the server log messages for additional error informations. These log files may vary as per the server configurations. Some information about the server log file available here!


Remove "Submitted by [user] on [date]" from content shown on a Views page

Go to Administration > Structure > Content Types. Find the content type on which you want to disable author information, click edit. At the bottom of the edit page you'll click on "Display settings" and uncheck "Display author and date information".

This will disable the display of author info for all content view modes, but you will still be able to pull out this info when constructing a View via Views module if you need to.


Can the BaseFieldOverride class be used to implement hook_entity_bundle_info()?

According to the issue you linked the answer is no:

  So, in theory, contrib modules can implement non-config-based bundle fields, but we don't provide an implementation class with which to do so.


By disabling modules enabled by the profile, you may be working against yourself.  There is known issue that D7 does not enforce module dependencies listed in the .info of a profile.  So if some of the modules you are disabling were enabled on install because they are listed in http://cgit.drupalcode.org/commerce_kickstart/tree/commerce_kickstart.info, then you will find that the profile itself is actually disabled.  You can tell if this has happen by looking in the system table and/or the status report.  In the system table, the status on of the profile will be 0.  In the status report you'll see the profile's name, but no version number. You can read more about the D7 issue in https://www.drupal.org/node/1170362.  Some progress has been made on addressing this in D8 in https://www.drupal.org/node/820054.

Because Drupal also uses a variable to tell which profile is being used, a disabled profile may not cause any issues beyond preventing update status lookups.  But if a module is being included as a dependency in the .info, it's worth taking the time to understand why the profile's maintainer added that dependency in the first place.

As far as removing modules with a status of 0 to achieve a slightly smaller system table, that is unlikely to have a measurable impact on performance.  Where you may see a performance hit is from lots of extra .info and .install files. Creating the list of modules at admin/modules requires scanning several directories for .info files.  Checking for updates scans the .install files for any update hooks that haven't already been applied.  Beyond that, modules that are not enabled shouldn't be impacting the performance when Drupal renders a page.

You should consider using https://www.drupal.org/project/profiler_builder to generate your own profile and .make from one of the sites you built from scratch.  That would give you the advantage of getting another site started quickly without the overhead of a general purpose kickstarter style profile and distribution.

If you do create your own profile, please consider sharing it on Drupal.org so that other members of the community can benefit from the a more efficient (while less robust) Commerce configuration.


Can I simply delete the File Entity folder from Modules if I am using Media 7.x-1.3

Do you have backups from before the 2.x version of File entity was installed? That would be the ideal solution because frankly, things are bad. You can't just remove the File entity 2.x module directory, because at this point the module has been installed and your data is at quite a dirty state. The only real solution is to try an in-UI disable/uninstall of File entity and any Media related modules to try and get your site to a more clean state before again installing and enabling the proper versions you need/want.


How to set additional node type options programmatically?

Is there a better way of doing this than the improvised soluton I
  currently use?

I don't think so. Also I don't find it improvised.

Here's a D7 module I once made that creates a new content type: https://github.com/leymannx/drupal-personality-test/blob/master/personality_test.install

/**
 * Implements hook_install().
 */
function MYMODULE_install() {
  node_types_rebuild();
  $types = node_type_get_types();

  // Add a body field
  node_add_body_field($types['MY_CONTENTTYPE']);

  // Add custom fields
  add_custom_fields();

  // Default to not to be promoted
  variable_set('node_options_MY_CONTENTTYPE', array('status'));

  // Disable comments
  variable_set('comment_MY_CONTENTTYPE', COMMENT_NODE_CLOSED);

  // Hide date and author information
  variable_set('node_submitted_MY_CONTENTTYPE', FALSE);

  // Disable node preview
  variable_set('node_preview_MY_CONTENTTYPE', 0);

  // Disable menu entry
  variable_set('menu_options_MY_CONTENTTYPE', array(0));
}

I experienced just the same and solved it exactly like you via hook_install. If I remember it right, I probably found the code in core when looking how the article and page node types get created.

Related: How to set node type options programmatically (where another tiny module gets recommended you'd need to have everything together in hook_node_info).


Is entittyfieldquery result can be loaded into select list?

Can this array can be loaded into select list directly? or we need to apply node_load_multiple on $results array.

A FAPI select list expects an Array with id and title. An entityfieldquery returns only a list of IDs unless you get creative. Typically you perform extra work to load fields you want to show as text in your select field. You can do this via SQL, node_load a view resultset ... whatever means you're comfortable with.

EDIT

Well I didnt say you have to use node load. There are various extensions to EFQ that let you use community created EFQ classes:

The most recent is https://www.drupal.org/sandbox/mikeytown2/2209909
A slightly older less pretty module is https://www.drupal.org/project/efq_extra_field


Styling Superfish menu with Zen and Sass

The latest version of Zen is organized according to the SMACSS way. However, what SMACCS calls modules is called components in Zen. This to avoid confusion, since Drupal already has a definition for 'modules'. SMACSS defines modules (or components in Zen) as follows:

..Module is a more discrete component of the page. It is your navigation bars and your carousels and your dialogs and your widgets and so on...source

All SASS code concerning components is stored therefore in your_zen_subtheme/sass/components/_misc.scss file. I would choose to add style rules for your Superfish menu there. You can use the Superfish classes (with the .sf prefix) to target only the Superfish menu instead of all menus.


It may be caused by the "Show as expanded" unchecked checkbox by default on your menu items edition page. Check 'admin/structure/menu/item/{mid}/edit'

By the way, devel's module dpm(object) function is the Drupal way of print_r / var_dump inspecting things.


How to hide title of any content type without using a module?

You could do it in template.php in your theme dir, technically not a module.

e.g:

/**
 * Implements hook_preprocess_node
 */
function MYTHEME_preprocess_node(&$variables){
  if ($variables['node']->type == 'article') {
    $variables['title'] = FALSE;
  }
}

Replace "MYTHEME" with your theme name and clear all caches at Admin > Config > Performance to apply.


I think your view is setup to show 1 node per page.

  Go into views admin/build/views
  Choose the view that is used for those pages most probably taxonomy_term view
  On basic settings: use pager click on the cogwheel and change the items from 1 to 20 items per page
  After saving this setting the basic setting should look like the following image


Custom form values in hook_form_alter() not available in custom validate function

This pair of functions should do the trick:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if (stripos($form_id, 'node_form') !== FALSE) {
    $form['custom_form'] = array(
     '#type' => 'textfield',
     '#title' => t('Custom field'),
     '#default_value' => 'enter custom text here',
    );
    $form['#validate'][] = 'mymodule_custom_form_process_values';
  }
 }

function mymodule_custom_form_process_values($form, &$form_state) {
  // Check to see if the default text has been altered by the user.
  if ($form_state['values']['custom_form'] != $form['custom_form']['#default_value']) {
    // Do something here...
  }
}

Tested on Drupal 7.53.


Flood table not respecting X_FORWARDED_FOR

$conf['reverse_proxy_addresses'] had my old load balancer IP, thanks to AWS changing the IP without telling me.  Once I updated with the current LB address, it worked as expected.


How do I get the fivestar module's vote on a review node to count towards a product node?

The problem was that I had just switched the links between my Reviews -> Products to use entity relationships (instead of node links) and Fivestar does not support that.

A patch that seems to work was posted two days ago.  As soon as I applied the patch, the "target node" field appeared.  http://drupal.org/node/1488914

In addition, the product's Fivestar field had to be set to "rate while viewing" and the Review's Fivestar field had to be set to edit while eediting.


Is a custom module the best way to build out a Form with full custom AJAX?

Building custom module for mentioned requirements would make your work easy and dynamic. Dynamic in sense you can add more links if you publish any new page in future.
It would be great if you use ctools-modal with custom module. I was facing the same problem. I had wasted a week for finding better way to get link with ajax form.


unable to set CONTEXTUAL FILTERS according to Raw Value from Url

You need to add a relationship to the content, and use the title (or whatever field contains "robert") as the contextual filter instead.

Currently the query that's getting built is trying to find content with an ID of "robert", which won't work as nid is numeric.


Show specific fields in a list to everybody, but only registered user can see that node

I think Field Permissions is right module for you.

  Features

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


function where_ever_extra_data_originates_from() {
  $extra_data_to_pass_on_stored_here = &drupal_static(__FUNCTION__);
  $extra_data_to_pass_on_stored_here = $actual_extra_data
}

function my_validation_function($form, &$form_state) {
  //Here's our extra stuff now
  $extra_data = &drupal_static(where_ever_extra_data_originates_from);
}


The problem is that because of the auto-submit, you submit an ajax request as soon as the first filter is changed. It then doesn't matter that you make a second change, and the answer to the first request is already being processed.

The only solution that I'm aware of, is to not use the ajax functionality in Views, and instead implement your own, that for example waits one second after changing the first filter before submitting the form, allowing several filters to be changed in one request.


There isn't an easy solution for this since the field data is stored in multiple tables and is based on configuration which is also stored in the DB.

You're better off trying to use Registry Rebuild and Commerce Repair to get the site working and then using export tools to get the data.


Found a way – this is how to retrieve image url and image html from given sid:

if(isset($vars['node']->field_teaserbild['und'][0]['sid'])) {

    $img = $vars['node']->field_teaserbild['und'][0]['sid'];
    $atom = scald_atom_load($img);
    $image_uri = $atom->base_entity->uri;
    $vars['img_style_url'] = image_style_url('my_img_style', $image_uri); // style_url
    $vars['img_html'] = theme('image_style', array('style_name' => 'my_img_style', 'path' => $image_uri)); // html

}

Just in case somebody is still hoping for an answer…


Changing the format of drupal pagers numbers

There is a theme_pager function in drupal which help you to format pager. However i am not sure it can change the number from 1 to 01.

But, You can achieve this style with few lines of jquery. I am not proficient in jquery bu t a rough code is given below which may help you

(function($){
    function pad (str, max) {
        return str.length < max ? pad("0" + str, max) : str;
    }
    $( ".pager li" ).each(function( index ) {
         var number = $(this).text();
         if(number < 10){
           var new_number = pad(number, 2);
              if(($(this).attr('class')) == 'pager-item'){
                $(this).children().text(new_number);
              }else{
                $(this).text(new_number);
              }
          }

    });
})(jQuery);

The output


The EditableViews module should serve your purpose well. Here is part of the module's project page:

  Editable Views lets you create Views where the fields can be edited. Fields show both the current value and a form to edit it. A 'Save' button allows saving of all the entities shown in the View.


Try disabling Clean URLs and see if it works.
If it does, it might be a problem with the module you are using.

Do this behavior also happen if you disable slipjq module?
If no, I recommend that you build this functionality yourself using jQuery. It would be easy.
If yes:

Have you created any alternative URL's pointing or coming from /user ?
If yes, try removing it.


Multiple facets are shown with Content fields with multiple words

Found the solution.

I was using Search API for indexing, and within that type of field to index was set to Fulltext. I changed it to String and it got fixed.

Thanks.


Get file or image path as string from uid

Yep. There is a function for that.

http://api.drupal.org/api/drupal/includes%21file.inc/function/file_create_url/7


How to exclude nodes from a view if they appear on another view?

Try the Views Excluded Previous module:

  The Views exclude previous module provides a views filter that excludes nodes that have already been loaded/displayed on the current page.

  This is very useful when you have pages with several embedded views, and you want to make sure that a given node only appears once in the page.


yes, this is sounds good, you can nicely use the replacement pattern for the views, and there is nice tutorial for css3 hover effect you can use this. Click here
After adding two field to your view hide the first image field and use the replacement pattern of the next field.In that replacement pattern you can put the variables as like bellow..this is just an example

<div id="cf">
 [fieldone]
 [fieldtwo]
</div>

then this two image will wrap with a div now you can add class name to the image tag as shown in the example.Hope this will help you.


How to allow users to edit a specific field of content?

You can set permissions for fields who can edit or not
Please have a look into this module

Field Permissions

  The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity.


Moving data from a Drupal 6 site to a new Drupal 7 site

I think the approach you are looking at is good. You may need to reconsider your requirements slightly.

Move content but not upgrade.
Move some content which is provided by modules (which need to be upgraded).
Move content which is provided by modules but not the modules themselves.
Not use Migrate or table wizard.
Do so in the best way.
Do so in the quickest way.

I think many of these requirements are mutually exclusive.

The best approach I can see, is to clone your existing site. Turn off everything you don't want in the D7 site. Then consider your upgrade options.

A Drupal install is a complex interaction of code configuration and content. it is difficult to completely consider one without the others.

update

You could look at migrate Drupal 2 Drupal for migrating your content.


Call Drupal behaviour when AJAX form is submitted?

AJAX callbacks only return an array of commands, and those commands are then executed by Drupal. It is the method I prefer when dealing with AJAX in Drupal.

Behaviors are attached to every page. If you really want to call the behavior, detached from a Drupal AJAX response, then your behavior needs to react when the form is submitted by attaching to that event without using AJAX event on the submit button of the form. See this answer: https://drupal.stackexchange.com/a/87600/57.

With an AJAX command, you can ensure that your command only executes if the form is validated without messing around with a lot of Javascript - though it depends on what you are doing. If you are showing a modal or some notification to the user about submitting the form, you may want to opt for the command so that you aren't running JS if the form did not really submit (i.e. not validated).

In your case, if you are using AJAX submission, then the submit event won't bubble up to the document. You can use ajax_command_invoke however to call a method. I recently had to do this on an AJAX'd form to push data to Google. Here is an example:

$commands[] = ajax_command_invoke(NULL, 'onFormSubmitSuccess');
return array('#type' => 'ajax', '#commands' => $commands);

Javascript file:

(function($) {
  $.fn.onFormSubmitSuccess = function(data) {
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
      'event' : 'formSubmitted',
    });
  };
})(jQuery);

https://api.drupal.org/api/drupal/includes!ajax.inc/function/ajax_command_invoke/7


getFieldDefinitions on Drupal 8 (why all these deprecated functions on DP8?)

Drupal::service('entity_field.manager')->getFieldDefinitions(xxx, xxx);

Is the current way to get field definitions.

It's the EntityManager service that has been deprecated, not EntityFieldManager::getFieldDefinitions. A deprecation notice on a method doesn't apply to the code used within the method, just the use of the method itself.

The former currently proxies straight through to the latter, so it isn't really useful any more.

As a general rule, functions are deprecated when they're no longer useful, or when they break convention with the rest of the codebase. Don't fear it, embrace it. Progress is a good thing :)


What is the equivalent of hook_user_view()?

hook_user_view() is still available in drupal 8, but the hook naming schema has changed, because the hook can now be used for all entity types:

https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!entity.api.php/function/hook_ENTITY_TYPE_view/8.2.x

A more D8 way to do this could be a custom access check on the route:

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


How to prevent the conversion of text URL to link?

As far as I know this is not a problem if you a using CKeditor.

I tried to write some text URLs in both Basic HTML and Full HTML format. It worked fine, if you want to see how I did I have made a little video for you:

https://vimeo.com/234845994


First install and configure "Comment goodness" module - it will allow you to sort comments to display newest first.

Then in your template.php create.

function THEME_preprocess_comment_wrapper(&$variables) {
   // Remove pager.
   unset ($variables['content']['comments']['pager']);
   // Leave only latest comment.
   $last_comment_id = reset(element_children($variables['content']['comments']));
   $variables['content']['comments'] = array (
     $last_comment_id => $variables['content']['comments'][$last_comment_id]
   );
}


How to get different image styles in the same view?

The Twig Tweak can help you.

Firstly, you should write a specific condition for check if the image is first.

{% if loop.index == 1 %}

Inside condition you need to fetch an uri to the image and apply the Image Style Filter.


You may have a look at Block Refresh, and implement your custom logic on top of it whenever you want to send a Cache-Control: max-age=0 :

//Override external cache max age if set
  if (isset($settings[$block_id]['bypass_external_cache']) && $settings[$block_id]['bypass_external_cache'] != '') {
    drupal_add_http_header('Cache-Control', 'public, max-age=' . intval($settings[$block_id]['bypass_external_cache']));
  }


Does CAPTCHA Module still disallow page caching?

Yes. The Captcha module is still incompatible with Drupal's caching. In fact once the captcha modules is enabled it gives you a nice warning on Drupal's performance settings page that says:

 The CAPTCHA module will disable the caching of pages that contain a CAPTCHA element.

Most challenge/response modules like this will disable caching. Take a look at something like the honeypot module. It helps in deterring spam bots from completing forms on your Drupal site. It basically inserts a hidden form field to Drupal (or other) forms with a field name like 'homepage' (you can set it to whatever you want). End users don't see the field, so they don't fill it out. But spam bots (usually using prewritten scripts) do see the field (usually), and add something to it. The Honeypot module detects this and blocks the form submission if there's something in the field. It does this without disabling cache.

Note: The Honeypot provides two methods. The timestamp method does disable caching, so use the Honeypot method.


I am puzzled by your description of the problem.  Drupal 7 should not complain if  A user name is the same as account B email address.

However, without making a too big deal of that, there is a way you can change an email address to avoid any conflict within Drupal, and still get mail delivered to that user without interruption.

Simply insert the character + and some string after the name part of the address, like this:

User account A:
Username   - usernameX
user email - usernameX+a@gmail.com

User account B:
username   - usernameX@gmail.com
user email - usernameB@gmail.com

Drupal allows email-adresses with a + in them.

And for string comparison purposes:

usernameX+a@gmail.com ≠ usernameX@gmail.com

While for mail delivery purposes:

usernameX+a@gmail.com = usernameX@gmail.com

This technique, known “plus-addressing” allows users to sign up for different services with different aliases and then easily filter all e-mails from those services (provided their mail server doesn't strip it). Mail servers deals differently with “plus-addresses”. MS Exchange strips it, while Cyrus and GMail retains it - but AFAIK all mail servers deliver mail with “plus-addresses” to the intended recipient.


How to fetch data from already saved nodes to the edit-form for node creation?

SOLVED:

Via http://drupal.org/node/1028952#comment-3968840 i found this little module

http://github.com/Itangalo/Node-creation-block--Drupal-7-

that resolved my issue.

Another possibilty (although in dev-status) is the use of this module: http://drupal.org/project/formblock


How to create a layout with different size grid theming with Views?

This you can do using combination of Views and Panels. Views will provide whatever data you want. This will be the easiest and straight.

Views is for -> Fetching the data
Panels/DS is for -> To arrange Display layout

Panels,

  The Panels module allows a site administrator to create customized
  layouts for multiple uses. At its core it is a drag and drop content
  manager that lets you visually design a layout and place content
  within that layout.

Or instead of Panels, Display suite also,

Display suit,

  Display Suite allows you to take full control over how your content is
  displayed using a drag and drop interface. Arrange your nodes, views,
  comments, user data etc. the way you want without having to work your
  way through dozens of template files.


Setting #states property for a field_collection item added with the add_more button

I could solve it myself...

The solution is to alter the field_collection widget. In the point 3 of my question, I have made a mistake in the code. Here is a generic code to handle this behavior for changing the visibility of a text field according to the value of a select field:

function your_module_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {
  $fn = $context['items']->getFieldDefinition()
    ->getName();
  if ($fn == 'your_field_collection')  {
    // Get the delta
    $delta = $element['#delta'];
    $element['your_fc_text_field']['widget'][0]['value']['#states'] = array(
      'visible' => array(
        "select[data-drupal-selector=\"edit-your-field-collection-$delta-your-fc-text-field\"]" => array(
          'value' => "your_value_when_visible"
        )
      )
    );
  }
}

Note 1: I used "data-drupal-selector" because this was the only jquery selector which was working for the "select" (select seems more tricky then other fields)

Note 2: Adding ":" before "select" like ":select[data..." is breaking the feature. I don't know why!

Note 3: take care of the $delta in the data-drupal-selector

Note 4: Use "Inspect element" of your browser to get the correct value of your "data-drupal-selector"


Place the footer AND the copyright blocks at the bottom of the page responsive

If you are indeed looking to create a sticky footer, not sure what option this particular theme gives you but the idea is the same with any drupal theme

Add both blocks to a region that you will dedicate for this purpose
if no available region exists you can just create a new one
using custom css on your theme you can make this specific region position: fixed but there are other ways as mentioned by No Sssweat


FYI, here is how I solved it. Thanks Rock, for the step in the right direction!

Overview: Used a custom module that creates a block that displays one of two view displays.

Programmatically created a view (hook_views_api, hook_views_default_views) with two displays: one that shows upcoming events (ascending order, up to 4 items without a pager), and one that shows the last four events in the database (descending order, 4 items without a pager)
Programmatically created a block (hook_block_info) that displays (hook_block_view) one of the two view displays based on the number of results in the "Upcoming" display ( $results = views_get_view_result('view_id', 'display_id');).
Created a custom template file (views-view-unformatted--view-id--display-id.tpl.php) for the second display, which reverses the order of results so that they are still displayed with earliest date first.


How can I leave Subject as blank when fill nothing in the subject field of a comment?

You can use hook_ENTITY_TYPE_presave to do this, just call

 if (!$entity->getSubject()) {
   $entity->setSubject('');
 }

if it isn’t filled.

Hope it makes sense.


Best way to drop a field from a content type

There are two api functions to delete fields:

field_delete_field To delete the entire field (all instances of of the field)
field_delete_instance To delete only an instance of a field - which is how it's attached to an entity.

If you don't want to reuse the field, it might be a bit cleaner to delete the entire field instead of only delete the instance of it on the content type in question. Only you can be the judge of that.


How to grant create and update permissions to a custom role?

You may grant your permissions on install time of your module with a simple config in config/install/user.role.publisher.yml (about this):

langcode: en
status: true
dependencies: {  }
id: publisher
label: Publisher
weight: 3
is_admin: null
permissions:
  - 'add contact entity'
  - 'edit contect entity'

Your code above is not a "grant", it's a runtime-check of users permissions.


Here we go again.  These answers are mostly right. One thing you can't forget about is "cache tags" and "cache contexts".

I was setting up a taxonomy term on a node as a breadcrumb.

I got it working with advice from this post, but then I clicked around and noticed the same breadcrumbs on every page.

Long story short, make sure to set some cache contexts and tags.

Here's my service in a gist: https://gist.github.com/jonpugh/ccaeb01e173abbc6c88f7a332d271e4a

Here's my build() method:

/**
 * {@inheritdoc}
 */
public function build(RouteMatchInterface $route_match) {
  $node = $route_match->getParameter('node');
  $breadcrumb = new Breadcrumb();

  // By setting a "cache context" to the "url", each requested URL gets it's own cache.
  // This way a single breadcrumb isn't cached for all pages on the site.
  $breadcrumb->addCacheContexts(["url"]);

  // By adding "cache tags" for this specific node, the cache is invalidated when the node is edited.
  $breadcrumb->addCacheTags(["node:{$node->nid->value}"]);

  // Add "Home" breadcrumb link.
  $breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '<front>'));

  // Given we have a taxonomy term reference field named "field_section", and that field has data,
  // Add that term as a breadcrumb link.
  if (!empty($node->field_section->entity)) {
    $breadcrumb->addLink($node->field_section->entity->toLink());
  }
  return $breadcrumb;
}


How to set fields value in Views PHP module?

First you need to load the node

$node = node_load($data->nid);

then you can either access

$value=$node->field_name['und'][0]['value'];

or assign

$node->field_time['und'][0]['value'] = $value

values to the node items. You may need to print out the content of the $node object to see the actual field_name

$node_r = print_r($node, true);
watchdog('NODE PRINT OUT', "$node_r");

then view it in the recent log mesages

admin/reports/dblog

Ensure the DBlog (Database logging) core module is enabled


Multiple results being returned using search for same node

There is a join in the query that is causing multiple instances of the same node to be returned.

Edit the view and under the "Other" section click on Query settings and choose Distinct.

The description says:

"This will make the view display only distinct items. If there are multiple identical items, each will be displayed only once. You can use this to try and remove duplicates from a view, though it does not always work. Note that this can slow queries down, so use it with caution."

Here is the "Other section" in the view settings:

EDIT:

If this doesn't work then try the Views Distinct Module that Sage mentions in his comment below.


How to sql-sync database between two remotes which share the same host?

Here is how drush sql-sync works between two remotes:

Logs into remote @destination via SSH and creates destination database if needed via sql-create.
Backs up database on @sourceby performing sql-dump on source unless told otherwise and saves it into drush-backups folder.
Logs into @destination remote via SSH and executes rsync to transfer database from Source to Destination.

Example: rsync @source:drush-backups/db.sql.gz @destination:/tmp/db.sql.gz

To make this work, you have to make sure that:

both local and remote drush have the same version (either 6.x or 7.x),
on Destination the @source alias should be accessible for drush,
rsync tool doesn't support two remotes, so only one may be remote.

Based on above it seems you can't use sql-sync drush command to transfer the database between two remotes in drush 7.x (see: #161).

As for workaround, first dump the database from your source onto your local and transfer back to the destination, in example:

drush @source sql-dump | drush @destination sql-cli

This should transfer the database between two remotes without sql-sync limitation.


Why i get the error "Call to undefined function node_object_prepare()" while i try to add a node programmatically in Drupal 7?

I think you will have to include node.pages.inc to be able to use this function from within your module:

module_load_include('inc', 'node', 'node.pages');

I just tried the using node_object_prepare() from a sample module without using the above code and it seems to work just fine. As @Clive mentioned is his comment you should add your code for creating a node programatically inside a module hook and not directly in your module file.

// create a node using 'hook_menu' in your module, this might not be the
// best hook for doing this but it should work
function <MODULE>_menu() {
  $node = new stdClass();
  $node->type = "page";
  $node->title = "Your title goes jere";
  $node->language = LANGUAGE_NONE;
  $node->path = array('alias' => 'your node path');
  node_object_prepare($node);
  // ...
}

Reference: Module hooks


Is it possible to hide a field on a form without writing code?

If you simply want to hide the field and have the default value saved, you should be able to simply hide the field with CSS. Find the ID of the wrapper surrounding the field and set it to display: none;.  Here is a working example from my D6 site:

#edit-field-vendor-sort-order-0-value-wrapper {
  display: none;
}


Use Rules module and create redirect rules.

Project page says

  The Rules module allows site administrators to define conditionally
  executed actions based on occurring events (known as reactive or ECA
  rules).

Example use cases

Build flexible content publishing workflows changes
Send customized mails to notify your users about important
Create custom redirections, system messages, breadcrumbs, ...
Build an eCommerce store using Drupal Commerce And many more...


Access CiviCRM event fees via Drupal Views

Try using Views Field View following: https://www.ostraining.com/blog/drupal/views-field-view/

You'll need to create the context on Price Set ID in Price Fields, not Price Set.

I don't think this is an efficient way to do this.


How to share menus and blocks across domains, but not users and content data?

There really is not "Easy" way but you are on the right track. From your description it sounds like you need to be using Domain Access. In order to share content all sites need to be using the same shared database. As for content/users, you will have to configure your data and users to not be shared across all domains. These are all permission settings that can be set from Domain Access. Set each user to only have access to a specific domain. And set each content type to be visible for the domain it was created under.

With domain access you can have a different theme set up for each domain, so that will help you have a different "backend" experience for your authenticated users. So to answer your question, Domain access is the most effective apporach for this type of scenario. Its all just a matter of configurations and permission settings.


I would be curious to hear a alternative solution but this works too (albeit hackish):

I removed the reference to the stylesheet in *.info and simply added the call inside template.php:

function MYTHEME_preprocess_html(&$vars) {
    drupal_add_css(path_to_theme().'/styles.css', array(
      'group' => CSS_THEME,
      'preprocess' => FALSE
    ));
}


Search based on user profiles in Drupal 7

Searching with Drupal core is not very performative because you are doing search queries in a mysql database.

Apache Solr is much more performative and includes a much greater feature set for searching Drupal content: http://drupal.org/project/apachesolr

If you want to limit search results just to users you can use the solr module above plus Facet API http://drupal.org/project/facetapi and only expose the facets for the content authors. You can also create a view using Solr Views that will return the author in the search results.


Add CSS just to the main content and not to include comments

In my own Omega subtheme, which is quite standard, page content with comments has this structure (closing tags omitted for brevity):

   (node body)

    (another node field I'm displaying)

So a CSS selector of:

node > content

would get you all the fields in the content, but not the comments. Or if you just want to style the body, you could choose it specifically.

Note that the content class is used a number of different places in a page. Alternatively you might want to set up  some default CSS for most of the node and style the #comments or .comment-wrapper separately.

This is not profound: I just poked around with Firebug to figure it out.


Possible parent values for parent of links

You can go to the menus structure and click on edit of the menu link under which you want to place the new link. The example from your question would open in this url:

/admin/structure/menu/link/system.admin_config_system/edit

Then you'll find the parent name in the slug before /edit.

But the easiest way is to register the menu link without parent, which would place the new link in the top level of the menu and then drag and drop the link where you want it to be.

You probably need to specify the menu name in the yaml file:

menu_name: admin

In the exported configuration the links you've moved in UI appear in this configuration file:

core.menu.static_menu_link_overrides.yml

where you'll find the parent value where you dragged the link to. You could then use this information for module.links.menu.yml, if you want to deliver your module with this information.


When you implement hook_node_view(), don't forget to check if you're really displaying the node using this code:

function MYMODULE_node_view($node, $view_mode, $langcode) {
  if ($view_mode == 'full' && node_is_page($node)) {
    //Do something...
  }
}

This should correct your errors.


error 403 when trying to log in during checkout

My problem was a session bug with my version of php (5.6.3) the code from here contains a workaround:

function mymodule_user_login(&$edit, $account) {
  $_SESSION['mymodule']['ulogged'] = 1;
}


The server.js file has indeed been removed from the package. The solution is in the readme:

  Setup

  Install drupal-node.js packge with npm:

  npm install drupal-node.js

  Make sure to do this outside of your Drupal modules directory, else
  Drupal may try to process folders containing Node.js module
  information and fail. Follow the install instructions in the
  drupal-node.js NPM package. You will need to provide the hostname and
  port of your Drupal site to the Node.js process, and ensure that the
  service token matches between Drupal and Node.js.

I suppose they separated the server from the Drupal module to allow more frequent updates.
The npm package contains a settings file and app.js, which includes server.js.


Group By Taxonomy term on view but show all articles containing it

In my example I have Article with taxonomy term reference field tags and have create following content/terms

2 Tags: test1, test2
4 articles (2 including test1, 2 including test2)

Create a view of content displaying fields and filter to display articles only

add title field
add tag field (can exclude it from display)
format settings > choose grouping field Nr 1. > tags


How to add Shipping method for commerce flat rate module?

The Rules module integrates with Drupal Commerce in order to handle this type of requirement. There are many video tutorials available that explain how to setup various shipping rules.

There is also a module called Conditional Rules that may be useful if you need to have branching logic in your rules.

In this case I think you would only need two rules:

Conditions: type of shipping == "Free shipping" AND order total > $100 Actions: shipping cost = $0
Conditions: type of shipping == "Express" AND order total > $140 Actions: shipping cost = $0

You would set the default pricing for the "Free shipping" to $4 and the for the "express" to $12. The default prices would be overridden by the Rules in those two cases.


Password-protect page and its dependencies

Webform protected downloads seems to be an answer.


Display Suite is not what you need, field_permissions is, check out the screen.

DS is mostly used to change the global look and the availability of some fields and labels (like Teaser, Product, Fullpage ...)


Workflow for an entity based menu system?

I have pretty much abandoned the menu system for most of my sites, or at least the main menu, in favor of Taxonomy Menu. Here is a link to my most recent site that takes advantage of Taxonomy Menu

buyagainbaby.com

The main menu there as well as all the blocks you see on the front page are done with taxonomy menu.

The types of sites I design usually categorize some type of product or other information, and it's easy to use views to do some pretty amazing things with taxonomy as arguments, which you cannot do with just the default menu terms or IDs alone.  Take a look at some of my other questions having to do with taxonomy menu, or ask any questions about implementation if you have any.


After much debugging this appears to work. This code appears to revert to the most recent revision properly and does not cause a 2nd node save to occur:

/**
 * Implements hook_action_info().
 */
function revert_last_revision_action_info() {
  $action = array(
    'REVERT_LAST_REVISION' => array(
      'label'        => t('Revert to Last Revision'),
      'type'         => 'node',
      'configurable' => FALSE,
      'triggers'     => array('any'),
      'behavior'     => array('view_property'),
    ),
  );
  return $action;
}

/**
 * Action function for REVERT_LAST_REVISION.
 */
function REVERT_LAST_REVISION(&$entity, $context = array()) {
  $revision_list = node_revision_list($entity);
  unset($revision_list[$entity->vid]);
  if (count($revision_list) > 0) {
    $last_revision = max(array_keys($revision_list));
    $entity = entity_revision_load('node', $last_revision);
    $entity->revision = TRUE;
    $entity->log = "Reverted via bulk operation action.";
    entity_save('node', $entity);
  }
}

Does anyone know what is causing the final node save in ViewsBulkOperationsAction::execute to not fire? I can't tell if it's because of the action info behaviors not set as: save, pre-save, or changes_property values. Or perhaps it's the usage of entity_save here  instead of a node_save ...

I've debugged this with a few nodes using Batch and single nodes.


In hook_preprocess_page() add the following code.

$block_entity = Drupal\block_content\Entity\BlockContent::load(BLOCK_ID);// BLOCK_ID
$block_view = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block_entity, 'DISPLAY_VIEW_NAME');
if ($block_view) {
    $variables['page']['my_block'] = $block_view;
}

In your Twig template, print the block with the following code.

{% if page.my_block %}
  {{ page.my_block }}
{% endif %}


If you have drush set up, you can use drush watchdog-list to look at the items logged to watchdog.

If you don't have access to drush, but your DB is up and running fine, you can always query the watchdog table with Select * from watchdog;

From personal experience, you might want to check your apache error logs as well to see if those hold anything that can help.


Calling get_theme_setting from php-as-css file

I recommend you to take a look to less css:

http://lesscss.org/

In fact there is a drupal module for this:

http://drupal.org/project/less

I used it a project and works great.


facets not showing all the options drupal commerce

you should probably set the filter in the view like this


How to revoke edit access to the node's author after publishing a node?

Approach 1:

Here is the rule (in Rules export format) that I think is what you are looking for:

{ "rules_disallow_edit_own_content_after_node_is_published" : {
    "LABEL" : "Disallow edit own content after node is published",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "content_access_rules" ],
    "ON" : { "node_update--manuscript_submission" : { "bundle" : "manuscript_submission" } },
    "IF" : [
      { "data_is" : { "data" : [ "node-unchanged:status" ], "value" : "0" } },
      { "data_is" : { "data" : [ "node:status" ], "value" : "1" } }
    ],
    "DO" : [
      { "content_access_action_revoke_node_permissions" : {
          "node" : [ "node" ],
          "permissions" : { "value" : [
              "view:3",
              "view_own:3",
              "update:3",
              "update_own:2",
              "update_own:3",
              "delete:3",
              "delete_own:3"
            ]
          }
        }
      }
    ]
  }
}

Just import this rule in your own environment to review/qa-test it.

Some more details about the "clue" (magic?) of this rule:

The Rules Event is related to "Updating a node of content type manuscript_submission.
The Rules Condition is to ensure that the Rules Action is only triggered the moment that the node changes from unpublished to published.
The Rules Action simply REMOVES the permission for the author of the node (cfr. "own" in Content Access terminology) to edit that node for rome "authenticated user".

Note: The above rule is "tuned" to content type with machine name manuscript_submission. Change that machine name to any other content type (eg: article). Make sure to perform such change before you actually import this rule (because the Rules UI do not allow you to change that "event" after importing anymore).

Approach 2:

You can also use a work-around to implement "... revoke the modification access for the node author..." that you are asking for, as detailed below.

Have a look at my answer to the question about "How to specify a Rules condition like 'Before creating new content'?". Here is a quote from it, which I also recommend in your case here:

  Try using Rules (System) event "Drupal is initializing" (= init), which is actually BEFORE your edit form is shown.

With that, you actually don't (have to) "revoke access", instead you just the Rules module to capture the Rules event that somebody is about to start an edit session of a node. And then, depending on the extra Rules conditions you want to check (in your case: 'is the current user the author of this node?' AND 'is the status of this node published?'), you just use a Rules action to redirect a user to "somewhere else" (instead of showing them the edit form they asked for).

Note: If you want to use my proto-type Rules example in my answer I mentioned above, it's obvious that you'll have to adapt the Rules conditions and/or Rules actions to make it fit for you case (like the URL of your edit form?).


How do I display an error message on a basic page when the user does not have permissions to see the nested view inside the basic page?

You can create a basic Block with your text message and set up Visibility to only Anonymous users, and to show on your basic page.

This way anonymous will see the Block, authenticated will see the Views block.


Which menu should a third-party module choose, between "Structure" and "Configuration"?

This and many other D7UX related things are best explained in the UI Patterns session from yoroy and Bohjan: Drupal 7: Interface patterns.

In short, Structure is meant for structural things which are used regularly (mostly during site building). If those modules add their stuff their and are not Views, Panels or similar, chances are that they are doing it wrong. :)

Not everyone exactly agrees on the IA (Information Architecture) of Drupal 7 yet or simply doesn't know about it. Not even Drupal 7 core is very consistent IMHO; I don't think the contact.module settings belong to Structure, for example, when not even those from path.module are, which are most likely way more often used.


Where does drush look for the path of the mysql socket (on MAMP)?

First of all, check which php and php.ini file is used by drush:

$ drush status --full
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database hostname               :  localhost
 Database username               :  root
 Database name                   :  drupal7
 Drupal bootstrap                :  Successful
 Drupal user                     :
 PHP executable                  :  /usr/local/opt/php56/bin/php
 PHP configuration               :  /usr/local/etc/php/5.6/php.ini

Then edit its default MySQL socket name for local db connects:

pdo_mysql.default_socket=/path/to/mysql.sock

as by default it points to /tmp/mysql.sock unless PHP was configured with different (--with-mysql-sock).

Check by:

$ php -i | grep ^pdo_mysql.default_socket
pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock

So probably that's why /var/mysql/mysql.sock didn't work, as it was looking for /tmp/mysql.sock instead.

Then the symbolic link should work as expected.

If drush is using wrong instance of PHP, then add it into PATH (as you did) or specify with --php=</path/to/file>, so the right php.ini would be loaded.

Alternatively specify unix_socket in your settings file (as you already did).


How do I show a product attribute in a cart?

The price must be showing because that is all that is configured to be rendered for the referenced entity in whatever view mode it's defaulting to. If you want something like you've pictured, you're going to need to use the individual fields, which likely means adding another reference to get the attribute / value data, adding all three of the fields you want to render (course name, attribute value, and period), and then configuring the View to ensure all three of those fields are rendered into the single column.


URL alias, tokens is replacing 0s and 1s with node and entity

This seems pretty similar to what is asked in the question about Tokens causing incorrect text substitutions .

Refer to my answer in that question for various options to further debug what might be going on. If you can, please enhance your question (by editing it) to indicate which of the possible reasons in your case do apply, or don't apply at all.

Also note the brand new comment there (from "diego"),
here is what that comment says:

  I was able to find a work around at east for the Webform submissions. If I use a Rule to send the email (using [data:{field-name}-display] tokens) instead of the Webforms built in email function it doesn't seem to substitute any of the tokens.


Have a look for the following modules:

Click to Schedule

It has sync capabilities for Outlook, Google calendar or iCal for Mac. Meetings are automatically confirmed, added to your Outlook, Google Calendar, or iCal and confirmation emails are sent to both parties.

CiviCRM activities iCalendar feed

Users can access an iCal feed of their upcoming (future) Activities, suitable for subscription via Google Calendar, Microsoft Outlook, and/or similar software.


How to add a custom field to a taxonomy term

$term = Term::create([
  'name' => 'fashion',
  'vid' => 'special',
])->save();

'fashion' is the new taxonomy item name and 'special' is the existing vocabulary machine name.
The fashion will the taxonomy term under the vocabulary special


How to delete or autodelete unused images in a Drupal site?

The following drush command:

drush image-flush

may be used to remove all the image style copies generated as image styles via image-field or CKeditor. This is completely safe, as it will not touch the originals.

Those still in use will be regenerated when needed.  Those no longer used will not not be regenerated.

As noted in a comment by cptstarling:

  If you don't have access to drush, you may consider the Image style flush module.


What determines who can view an unpublished node?

It is handled by node_access:

it checks for the "view published content" - without this permission every operation is denied, published or not.
it checks the view own unpublished content permission.
it checks if hook_node_access gives either deny/allow. If not...
If no module implements hook_node_grants then there's a default allow for published nodes (and therefore a deny if not).
If modules do implement hook_node_grants then the node_access table is consulted. I found that published content receives a "default grant" in the node_access table thanks to node_access_acquire_grants, meaning anyone can view it. Unpublished content has no default grant so is therefore denied.


how to apply 'noindex' to all nodes and leave Alias indexable to prevent perceived duplicates for SEO

For Drupal8 and 9 what you need is simply this module: https://www.drupal.org/project/redirect. It will redirect all /node/* to its alias. For Drupal7: https://www.drupal.org/project/globalredirect


Would replacing hooks with events be a good practice?

Perhaps. I know other developers are using Hook Event Dispatcher because they want to guard against if the hook system goes away in D9. Thus, saving time in the future if indeed they go away.

Whether they go away its pure speculation at this point.


You don't want to be putting that much PHP code into a tpl template file. Your menu item should have two parameters (user account, and profile type) and the page callback is specified as the desired function.

If you are doing this another way, you still need the user object and customer profile. In a preprocess function or in a custom page callback, you can create the form as a variable:

template.php:

// you can load a user account in various ways, ill assume this is behind a user path
$account = menu_get_object('user');
// you will need to verify this is the right function to use.
$customer_profile = commerce_customer_profile_load(profile_id_here);

$variables['profile_form'] = commerce_addressbook_profile_options_edit($account, $customer_profile);

in your tpl file:

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

I am not familiar with the commerce_addressbook module, but there is a chance you'll need to include the file that defines those functions too, especially if they do not live in a .module file but live in a .inc file.

In which case, you'd need:

module_load_include('inc', 'commerce_addressbook', 'filepath/filename');
$variables['profile_form'] = commerce_addressbook_profile_options_edit($account, $customer_profile);


How to filter content in Views based on multiple term custom fields?

I have finally found a solution - it's necessary to add another relationship for the same field :

Content: Taxonomy terms on node, Identifier: term
Content: Taxonomy terms on node, Identifier: term2

The second contextual filter should use the second relationship (term2) and then everything works as expected.


Forms API: 'file' or 'managed_file' type with multiple/unlimited values

If you are trying to build this functionality for a custom form using the Forms API, it may not yet be possible.  It's documented on Drupal.org to be an issue. See this discussion, the bottom talks about the problems with implementing AHAH with a file field.


It's not secure at all to store or send credit card numbers in the database and via plain text email. Without careful consideration bad practice to do so.

I think you need to rethink the order fulfilment process.

You should instead consider using the refund feature of your payment gateway to refund payment after the transaction is completed, if it fails validation.

Alternatively, look at providing some sort of API process so the stock and shipping details can be verified during the checkout process, prior to payment.

There's also an option of "Authorize" vs "Capture" payment modes provided by some payment gateways to allow delayed payment capture.

In the meantime, please review PCI Compliance requirements:

http://en.wikipedia.org/wiki/Payment_Card_Industry_Data_Security_Standard
https://www.pcisecuritystandards.org/security_standards/why_comply.php
https://www.pcisecuritystandards.org/pdfs/pci_ssc_quick_guide.pdf


Before calling drupal_render($view) inspect the $view array. (Use devel's dmp or print_r to inspect the array.)

Find out what part of the array contains information about your images, and then unset this before calling drupal_render.

E.g.

unset($views['my-image-field']);
print drupal_render($view);


Your module needs to implement hook_views_data().

The example given in the hook documentation is for a table defined from the following SQL.

CREATE TABLE example_table (
  nid INT(11) NOT NULL,
  plain_text_field VARCHAR(32,
  numeric_field INT(11),
  boolean_field INT(1),
  timestamp_field INT(8),
  PRIMARY KEY(nid)
);

function mymodule_views_data() {
  $data['example_table']['table']['group'] = t('Example table');

  $data['example_table']['table']['base'] = array(
    'field' => 'nid',
    'title' => t('Example table'),
    'help' => t('Example table contains example content and can be related to nodes.'),
    'weight' => -10,
  );

  $data['example_table']['table']['join'] = array(
    'node' => array(
      'left_field' => 'nid',
      'field' => 'nid',
    ),
  );

  $data['example_table']['nid'] = array(
    'title' => t('Example content'),
    'help' => t('Some example content that references a node.'),
    'relationship' => array(
      'base' => 'node',
      'base field' => 'nid', // The name of the field on the joined table.
      // 'field' => 'nid' -- see hook_views_data_alter(); not needed here.
      'handler' => 'views_handler_relationship',
      'label' => t('Example node'),
    ),
  );

  $data['example_table']['plain_text_field'] = array(
    'title' => t('Plain text field'),
    'help' => t('Just a plain text field.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );

  $data['example_table']['numeric_field'] = array(
    'title' => t('Numeric field'),
    'help' => t('Just a numeric field.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  $data['example_table']['boolean_field'] = array(
    'title' => t('Boolean field'),
    'help' => t('Just an on/off field.'),
    'field' => array(
      'handler' => 'views_handler_field_boolean',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_boolean_operator',
      'label' => t('Published'),
      'type' => 'yes-no',
      'use equal' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  $data['example_table']['timestamp_field'] = array(
    'title' => t('Timestamp field'),
    'help' => t('Just a timestamp field.'),
    'field' => array(
      'handler' => 'views_handler_field_date',
      'click sortable' => TRUE,
    ),
    'sort' => array(
      'handler' => 'views_handler_sort_date',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_date',
    ),
  );

  return $data;
}


If you want to export a View as XML or CSV, you will want Views Data Export.

Edit: now that I know this is for Drupal 6, you will have to dig to find the releases for 6.x on the project page. Here they are.


Assuming this information is from the user profile.

You could do the following

blend.theme

function blend_preprocess_node(&$variables){
    $node = $variables['node'];
    $variables['firstname'] = $node->getOwner()->field_first_name->value;
    $variables['lastname'] = $node->getOwner()->field_last_name->value;
}

From there you can use {{ firstname }} and {{lastname}} anywhere in your template.


To figure out what was the problem, thanks to this post I opened include/error.inc

and replaced

print theme('maintenance_page', array('content' => t('The website encountered an unexpected error. Please try again later.')));

with

print theme('maintenance_page', array('content' => t('The website encountered an unexpected error. Please try again later.'.$fatal.' '.var_export($error,true))));

The new command prints out some useful info that can be used to debug. In my case, it turned out that messaging module caused the problem. I disabled messaging, and could login afterwards.

Note: before going to production, switch back to original error.inc, since the error outputs can be a gift to attackers.


There is a typo in your code - the function name is "rules_example_actions_hello_world" in your actions definition, while the actual function is called "rules_example_action_hello_world".


How to offer Views as options in a Content-Type field

You could create a taxonomy for that content type and assign values to it like "Certificates of Completion", etc. Here is the Link for the taxonomy docs.


How to change the widget of a multimedia asset from media browser to multiupload

Did you check the field widget and change it from media browser to multiupload?
You can change your widget without affecting the other nodes which has already images on it.

hope it helps.


Views date filter by year - only one select list for the year

Add filter criteria of Year field.
Now expose this field by selecting 'Expose this filter to visitors, to allow them to change it' option from field setting.
For Ajax behaviour, choose Use AJAX from advance view section.


In Drupal 7 the NID is the group ID so you could just output $node->nid.


Why is my rules created shipping profile not being used?

It doesn't appear that you're assigning the profile you created to the order. You need to set the order's shipping profile to the one you just created.


Google Store locator Store Phone and Store Web not visible

There is a patch you can apply that should fix your issue.

Check out the thread here https://www.drupal.org/node/2383773 and the related thread here https://www.drupal.org/node/2528458

This one https://www.drupal.org/node/2528458#comment-10125006 will take you straight to grabbing the patch, the top two will give you the context of what happened.


How to filter Search API index view by taxonomy parent

I just figured this out the answer was simpler than I thought.

I was trying to use contextual filters & relationships like other answers said but what worked was just simply adding the Taxonomy Field to Filter Criteria then selecting the desired parent. That's it. No need to add a relationship to it.

Edit:
There is still a problem: it doesn't work when using a grouped exposed filter it gives this error:

  A value is required if the label for this item is defined.

Log Message:

  PHP -  Warning: trim() expects parameter 1 to be string, array given in ...

I tried changing the filter to Combined field filter with the Taxonomy as a field so the input would be string but I still get another error.

  PHP - Error: Call to undefined method ...


How do I add classes to an img tag inside the node?

you could preprocess the content in the template, but it would be a little difficult, or you could do it via attachBehaviors in jQuery.

If you mind the jQuery way you can add this script:

(function($) {
  Drupal.behaviors.classadd = {
    attach: function(){
      $('.node img').addClass('class1 class2 class3');
    }
  }
}

This way you can easily add classes to your node with .node class. even when you load content dinamicly via ajax. the attachBehavior is a useful Drupal technic to attach actions to your content, and it's widely implemented in all the Drupal framework.


How would you implement a limited time featured node?

I would do the following, but it assume that you use Panels.

Create a panel page.
Add your first node as Content.  Add a Visibility rule, choose PHP, and add in code that checks your date range based on the current time.
Add your second node as Content.  Add a Visibility rule, choose PHP, and add in inverse of the code above.

I wouldn't be surprised if you can also accomplish this with the Scheduler module, but I am not sure how the URL would be handled in this scenario.


How to use tokens in php code of the rules module?

It turns out that the above code works when I turn of the Ajax Comments module. With that module, it throws an internal server error.

I reported it as issue.

This hook does the job now:

function hook_comment_insert($comment) {
  //dpm($comment);

  if ($comment->uid) {
   db_merge('history')
     ->key(array(
       'uid' => $comment->uid,
       'nid' => $comment->nid,
     ))
     ->fields(array('timestamp' => REQUEST_TIME))
     ->execute();
  }
}


Date field in view Filter Criteria, where date may be blank

The conditions I had set above were too many

content is published
AND content type is TYPE
AND Start date is blank OR Start date is not blank AND start date is <= NOW
AND End date is blank OR End date is not blank AND end date >= NOW

and should have been:

content is published
AND content type is TYPE
AND Start date is blank OR start date is <= NOW
AND End date is blank OR end date >= NOW

because the NOT blank is implied.

Using the 'And/Or, Rearrange' feature of the Filter Criteria, I was able to create 3 groups joined by AND's with Group 2 and 3 joined by OR's. Like so:


Override an url with hook_menu_alter : problem with the file path

You can set the file path explicitly:

  file path: The path to the directory containing the file specified in "file". This defaults to the path to the module implementing the hook.

So your code might look like:

$items['node/%node/delete']['page arguments'] = array('myfunction', 1);
$items['node/%node/delete']['file'] = 'includes/custom_node_delete_confirm.inc';
$items['node/%node/delete']['file path'] = drupal_get_path('module', 'mymodule');

Be careful not to completely overwrite an existing router item unless you absolutely need to, in your example you're removing the required access callback/access arguments, and also the title; instead only change the values you need to as in the example above.


Make sure your parent links are set to Show as expanded on the /admin/structure/menu/manage/main page


How to capture credit card information to manually process later?

Check out Commerce and Ubercart shopping carts. This is the right and best way to do this as it will save you the PCI headache as well.

However, seems that neither of the two do not have SqareUp payment integration, so you will have to do that yourself. You will have to read their API documentation and make appropriate custom module for integration.


How to get/access field values while inside hook_block_view?

You seem to need information about the field itself and not about its instances (neither globally nor in the context of a given entity).

Hence, you would want to do a:

$field = field_info_field('field_my_field');
$keys = array_keys($field['settings']['allowed_values']);
// $keys will now have the set of unique keys for your options as set from
// the field settings page. Eg. Alsace, Aquitaine etc.

field_my_field is the unique name of your field that you have also attached to a content type. To find this out, ensure the Field UI module is enabled, go to the Manage fields page for your content type and look up the Name column for the field in question.

If you are interested in knowing how the values you had set from the settings form go here, check out list_field_settings_form(). Here is a link to the documentation of field_info_field() as well.


I fixed it...

I had a similar module installed (commerce_paypal_ec) and it was conflicting with commerce_paypal submodule for EC.

i misunderstood the concept, i tought i had to install submodules but those exist already in commerce_paypal.

in case somebody run into the same problem.

kind regards,
kevin


Get prefix and suffix from a Number field

After some trial and error and cache problems I found the answer to this myself. Here is how I got the prefix/suffix;

$prefix = $translated_node->get('field_price')->getSettings()['prefix'];
$suffix = $translated_node->get('field_price')->getSettings()['suffix'];


You may not be able to alter the system_requirements array directly, but you can hack around it in the theme layer by implementing theme_status_report.

 theme('status_report', array('requirements' => $requirements));


Help me understand themes with sidebars and how to populate the sidebar from drupal

In Drupal, themes have regions. The sidebars are regions, just like the header, footer, conternt etc regions. Over simplifying a bit, content is places in blocks, then the blocks are placed in the regions, and changing the theme usually requires the blocks to be allocated again. Fields are part of the content, not the theme. There is no 'sidebar field'.

I would suggest that you set up a drupal test-bed, and play with it for a while before you take the leap of trying to migrate a site. Drupal is powerful, but there is no way to bypass the learning curve. You need to roll up your sleeves and work with it for a while.

Good luck.


Trying to configure parent link and child links in menu

Your 2nd menu link needs the parent property referencing your first custom_forms_entity_export_csv.export route :
custom_forms_entity_export_csv.export_sales_form:
  title: 'Export Sales'
  description: 'Export Sales to a CSV file.'
  route_name: custom_forms_entity_export_csv.export_sales_form
  parent: custom_forms_entity_export_csv.export


How to generate an unique serial ID based on a select value

You can use webform hooks for add your custom code before sending the data or saving it into the database. Create hidden field in webform and set the value of the same using hook_webform_submission_presave
For Ex.

function yourmodule_webform_submission_presave($node, &$submission) {
  // Update some component's value before it is saved.
  $component_id = 4; // where 4 is your hidden component id
  // Add your logic for registration code
  $submission->data[$component_id][0] = 'registration_code_you_wish_to_set';
}

Or If you want unique registration number check this module http://drupal.org/project/regcode

Hope this helps.


"access ckeditor" permission missing - buttons inactive

Thank you for your suggestions. I suppose it probably is some permissions problem. I now granted the "Customize CKEditor appearance" permission for the role Editor and the toolbar is now functional. However it leaves me puzzled why this paprticular permission would trigger whether a user / role is allowed to use the toolbar buttons or not.

Customize CKEditor appearance
Allow users to customize CKEditor appearance.

Either it's a wording problem and granting that permission is the right thing to to – or I now actually have granted permission to customize the CKEditor appearance (as the wording would suggest) and I have a slight security problem However – i'll submit a request for support issue over at drupal.org and edit this post once I know more…
PS: Even thought this question might leave the impression – it's not my first time on drupal. It's just the first time I'm using CKEditor instead of WYSIWYG.