Workflow module missing content type mapping

The recent versions of workflow module comes with workflow_field and workflow_node modules. If you want to use workflow_field, a new feature, then you have to create a workflow field in your content type and it can also be used in any entity. But if you to use it the old way then enable workflow_node module and you can assign the content type to the workflow, but it can only be used for nodes.


Update problems when updating to Varbase

The https://www.drupal.org/project/varbase/issues/2953417 shows Varbase is using Content locking module, which is causing the reported error. Try temporarily disabling it to proceed.


Can a student gradebook be created without a custom module?

I think no. You need content type and views as you write. I think that you also need to use taxonomy (for year and class) so you can assign students to years and class. For calculation you need to write some module, maybe you can do also that in view.

Try the Computed field module.

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


Ubercart Numerical Attributes Not Respecting List Position Settings

Ubercart manages options twice. First in the overall (global) attributes, which may be applied to any individual product, then in the realm of the individual product. Since the product may have only a subset of the global options selection, once you have applied an attribute to a product, you are able to select which options apply, and re-order the sort order for that product. The default sort in Drupal is alphabetical.

Edit your product, go to the options tab, and set the options order the way you want to see it. The select list will respect the order you set. (And yes, this will require you to repeat the process for every product.)

EDIT:

One possible way to brute force the ordering is with direct access to the database.

First go to /admin/store/products/attributes and open the options list(s) for your attribute(s). Drag and drop to get the options in the correct order, then save.

Then run the following query (after backing up your database in case it blows up):

UPDATE uc_product_options p JOIN uc_attribute_options a ON p.oid=a.oid SET p.ordering = a.ordering;

Just be aware that if you ever edit the attributes on a product, they will re-order with the selected options at the top, and the unselected options at the end of the list. You WILL have to double check the order before saving, as the selected attributes will probably be in alphabetical order.


Ok, I found a way to do this.

Went into the specific menu as admin, and looked through the urls each of the menu items were pointing to (painful process when you have 60 some items). Found the menu item and deleted it from the menus interface and that worked.


To restrict the search you can use the Custom Search module, this module adds options to select:

which content type(s) to search,
which specific module search to use (node, help, user or any module that implements search),
which input type to use (with Elements),
advanced criteria

And if you want modify the search result page you can modify the tpl file search-result.tpl.php


"the website encountered an unexpected error.Please try again later" after db_update

Once try to insert manually in mobile_users(phpmyadmin) table with same data.
Then check for any errors, if not then check recent logs/apache error logs for more suggestions.


Rendering a Block Region in My Custom Theme

clear your theme cache to see your custom regions working: http://drupal.org/node/337176

Also see this link to review if something more is missing in your process: How-to create custom regions in a theme?


Upgrading a simple drupal 7 module to drupal 8?

I've spent the past few months doing a lot of D7 -> D8 upgrades. I haven't used sub_name (or even seen it), so I cannot comment on that, but as for the path, it's the same path you declared as the array key in your hook_menu definition - however note that with D8 you need to include the preceeding forward slash.

So if your D7 hook_menu() definition for a path was:

$menu['path/to/something']

In D8 your path in the routing file would be:

path: /path/to/something


How to track location of a sign-up form in a block?

have you fully tested your guess?  what you've described should work, AFAIK.

other options would include:

1) modifying the form to have a hidden value, set using drupal_get_path_alias() ...  it would set the value on load, rather than looking it up on submit.

2) a google analytics event tracker attached to the submit button the form.


Getting book pages in same level like getting child pages

If book module is enabled, it also creates a block called "Book navigation". You can display the block in any of the "Region" defined in your theme (e.g. "Sidebar first" in Bartik theme), by visiting http://your-site-url/admin/structure/block.

The block will be displayed(in the selected region) whenever you open the book page. And by default it will show the the book pages at the same level(sibling) pages.


I have not tried any of the following before, these are result of googling, so might not work.

I see two ways, hope any one helps you.

Solution might be as simple as using Apache Solr Image module, but not sure if it will work with user image.
The second needs custom coding, which will basically tell apache solr to index the image field uri and then add the uri field in your views and finally theme it as image using a custom template, Refer this for sample code.


Getting an element of a CCK field to use and modify in hook_form after_build

You are on the right track. You want to set the #title attribute of the form element whose label you want to change, which can all be done at the hook_form_alter() time.

In order to change the label of the 'week_night' form element, try something like this:

function rates_override_form_alter(&$form, $form_state, $form_id) {
  if($form_id == 'ldisilink_property_node_form') {
    $form['field_rates']['week_night']['#title'] = t('My new label');
}

This is assuming the 'week_night' form element is nested within 'field_rates' fieldset. If that is not the case, use:

$form['week_night']['#title'] = t('My new label');

instead.


Using the Flag, Views and Rules modules (as in your question) is indeed a way to get this to work. But assuming you have way more then just 2 (= a+b) users, you probably also want to add the Views Bulk Operations (VBO) module to this. Read on for more details ...

  Admin creates a node which requires to be read and confirmed and flags user a+b

Use Flag to create a (1st) flag to flag your nodes, and which at first will be used by the admin to set the flag for "user a+b" (as in your question), as further detailed below. The labels for this flag could be something like this:

to flag: "Confirmation outstanding".
to unflag: "Confirmed".

To actually set the flag for user a+b (imagine you have dozens ...), you should create an appropriate view (using Views) to create a list of such user a+b. And use Views Bulk Operations (VBO) to transform that view, so that the "operation" to be performed by that VBO-list is to execute a Rules Component (created with Rules).

If you're not familiar with how to do so, have a look at the video about Using Rules components with VBO". You may also want to watch the subsequent "Using Rules components with more than one parameter" video.

The actual Rules Component to be used by this VBO list, is simply a rule to flag a node by a single user. The trick here is the value to use as flagging user: it should use the uid as contained in the VBO list row being processed (so not the current uid, which would be the admin using the VBO list).

  User a+b receives an email staying there is a new content that requires them to read it.

Just enhance (extend) the Rules Component from the previous step to add an additional action, which is to also send an eMail to each user being processed. Tune the subject and body of the eMail to fit your needs.

  User a goes to the page and reads the content and clicks "I confirm I have read this" which cannot be reversed by user a

Use Flag to create a (2nd) flag with labels for this flag that could be something like so:

to flag: "I confirm I have read this".
to unflag: "I already confirmed to have read this".

When user a visits this page, all that's needed is that user a clicks the link which says "I confirm I have read this". After user a flagged it like so, the (1st) flag set for the node by user a needs to be removed (= unflagged). That's something you can do with a 2nd rule, which looks like so:

Rules Event = after flagging (with 2nd flag).
Rules Action = unflag (with 1st flag)).

However, after user a flagged the node (with the 2nd flag), the link to unflag it again will be shown. But you don't want user a to be able anymore to unflag it again. To prevent that to happen, a possible solution is to create a 3rd rule to either disallow such attempt to unflag, or to capture such attempt and automatically flag it again. Another approach could be via a custom template, which will simply hide the unflag link.

  When admin views the page they can see that user a has confirmed read but user b hasn't.

Create a Views block to list all users who have not flagged the node anymore with the 1st flag (these would be your users like a). And a similar block to list all users who have still flagged the node with the 1st flag (these would be your users like b).

Note: the above approach is entirely entity based, and may be considered as a possible alternative to some of the facilities provided by the Legal module (your question might be about similar functionality).


Can administration menu be configured with a stripped down menu that only gives the user access to post content?

From the role permission settings you can do so allowing him for access administration menu and then checking required permission sets (e.g. access administration pages)


How to change the starting order number for Commerce 2?

I used the command in the given explanation on my commerce 2 projects and it worked without any problems. So I am pretty sure you can't do anything wrong with this command.


How do I copy an already existing field in manage display?

The approach I would use would be to use a custom php snippet in a block to pull the field value out of $node and to format the field. I would then place the block in a region of the page where I needed it.

<?php

if (arg(0) == 'node' && is_numeric(arg(1))) {

$node = node_load(arg(1));

if (isset($node->field_node_reference['und'])) {

foreach ($node->field_node_reference['und'] as $other_node) {
  $link = '/node/' . $other_node['node']->nid;
  $title = $other_node['node']->title;
  print (l( $title, $link));
}

}

} ?>

This would be the core code for a node reference field. You should pretty it up to format your display, but this gets the information on your page a second time.


email address not appearing in user profile

copy the default profile template into your theme directory (the default template I copied is /modules/user/user-profile.tpl.php)
just after the initial  insert this code:

$profile_user = user_load(array('uid' => arg(1)));

 if($profile_user) {

   print '
Contact Information
';
   print '

Email
';
   print '
mail . '">' . $profile_user->mail . '

';
 }

That's it, all your profiles should have email addresses.


Show views active filter values as pills without using Facets

Facet API seems to be the common module for Facets in D7.
It seems there is the "Summary" option that is the "pills" feature you're looking for.


Any way to alter script tag for some javascript and add custom attributes?

There is, but it's not pretty. The markup produced by drupal_get_js() is pretty closed off; it uses theme_html_tag(), but what it provides for variables means identifying the Drupal.settings script is a pain.

This is about as good as you'll get. In custom module:

function MYMODULE_preprocess_html_tag(&$vars) {
  if ($vars['element']['#tag'] == 'script' && strpos($vars['element']['#value'], 'jQuery.extend(Drupal.settings') === 0) {
    $vars['element']['#attributes']['cf-async'] = 'false';
  }
}

As you rightly mentioned through the comments you could also attack it at the theme override level instead of the module level. In template.php:

function MYTHEME_preprocess_html_tag(&$variables) {
  if ($variables['element']['#tag'] == 'script' && strpos($variables['element']['#value'], 'jQuery.extend(Drupal.settings') === 0) {
    $variables['element']['#attributes']['cf-async'] = 'false';
  }
}

If you have modules that mess with JavaScript (e.g. LabJS), the string match will be slightly different.


Views block that shows all references to current node (cross references)

After knowing that this approach is called "reverse entity reference".
I found this tutorial:
https://mushtaq.ch/blog/4/drupal-8-reverse-entity-reference-in-view
But in step 3 I needed to use "Content USING field_myfield" instead of "Content referenced from field_myfield".
Thanks for your help!


Entityqueue - Get field values from the queue

I have found a solution.
After you create the entity queue, go to view and create/edit a view block.
Select Relationship as Content queue, now you can get the fields in the fields section.
Hope this helps.


How to do a "Corner Stamp" with Masonry Views?

Here's a thread in which considerable progress has been made: http://drupal.org/node/1988588#comment-7411276


You have to render the full form, so drupal_render($user_edit) is needed.


You can append a different query string to each link, which will allow you to track each one individually. Lets say your contact page is at mysite.com/contact. You can create several url's with a query string that lead to the same page. Ex:

mysite.com/contact?link=1

mysite.com/contact?link=2

mysite.com/contact?link=3

etc.

You can always append a query to a URL without creating any aliases or anything. Simply add ?key=value (obviously you can change 'key' and 'value' to anything you'd like). Google Analytics will track all of these separately.

The only downside is that Google Analytics won't batch all your contact page visits under 1 url anymore, but instead each different query will be listed separately.


How to add menu items to system.admin_content parent?

Dont use test.links.menu.yml instead use test.links.task.yml

in test.links.task.yml try the below code...

entity.admin.test:
  title: 'Test entities'
  route_name: entity.admin.test
  description: 'List and edit site test entities.'
  base_route: system.admin_content


Is it possible to rewrite the output of this CSV item with Feeds Tamper?

I agree with MPD. Plugins are easy to write. That looks like a serialised Python object. Is that right?

If you want to avoid that then I think your only option is the regular expression tamper. Use a site that allows you too test your expression on your sample string to help get it right while being fuzzy enough to handle edge cases. Here's one.

https://regex101.com

This seems to work though I'm not 100% on why it only returns the last match so use with caution. Match is in $2.

\[{2}.+?\],\s*\[(u'(.+?)'\,*\s*)+\]{2}

Actually this might be more robust. Match is in $1.

\[{2}.+?\],\s*\[.+\,\s{0,1}u'(.+?)'\]{2}$

https://regex101.com/r/qQ0cC0/3


How to let view display selected field content according to nid

I think this is what you're looking for

Add a contextual filter of

  content: nid

then do as the picture below.


Cache images in custom module without caching entire render array

Blocks are cached by default in Drupal 8.  The image non-cachable warning isn't a drupal issue.  It's a false flag from chrome.  Because image derivatives in Drupal (those generated from an image style) have a query argument chrome thinks it's not cachable.

To test that your block plug-in is caching, you can put a die() statement inside the build method to test if the code runs on each page load.  If it is running on each page load, you can comment out elements until it does use cache.  Then it should run the code once and then on subsequent page loads it won't run the code.

To make sure your block is refreshed when certain nodes are cleared, you can add them to the cache tags in your build array.  This may happen automatically if you are pulling the render array from each image from the node it came from.  Otherwise you can add them in your code like this:

$build['image']['#cache']['tags'][] = 'node:123';

To test, clear the cache and reload the page.  Verify on the cache_render table that the block is cached and your tag is there.

To test that editing that node updates the block, first update that node.  Then on the next page load of the page with your block, it should re-run the code for your block plugin.

To make sure the block is unique per user, you can add the user context to the cache contexts array

$build['image']['#cache']['contexts'][] = 'user';

To test, clear the cache, then reload the page with your block.  Check on the cache_render table that the cached item has user in the cid column.

Something like:

entity_view:block:my_block:[languages:language_interface]=en:[theme]=abilitylab_theme:[user]=123

Then test the block with a different user, and there you go:  Unique block per user.


Drush 6 does not support Drupal 8 and you need to upgrade to drush 7 (well I just upgraded to drush 8):

Drush Version   :  8.0-dev

See duplicate issue: Running Drush returns an error

Edit: If you are working on Drupal 8 you need the Drupal Console its syntax is a bit long-winded, but it is incredibly powerful.


By default Drupal don't save anything about who create a user.
If you want do it, go to user account fields  admin/config/people/accounts/fields add entity_reference with select list widget, then in your custom module in hook_form_alter set default value for field with get current user uid and then hide it there, in this manner the current user id (the user that create user) saved in fields without he/she know that this, also you can dont use hook_form_alter just get $user->uid(the current user that create user ) form global $user in hook_user_insert

shortly

add a entity reference field to user save creator uid in
hook_form_alter when or hook_user_insert


Programmatically select image style for use with custom file entity view mode

Sounds like something like this should work for you, to set the file display for the image file type, view mode name VIEW_MODE (replace with your custom view mode), to display original image. It either adds a new file display or updates an existing one:

$displays = file_displays_load('image', 'VIEW_MODE', TRUE);
$formatter = 'file_field_image';
if (array_key_exists($formatter, $displays)) {
  $display = $displays[$formatter];
}
else {
  $display = (object) array(
    'api_version' => 1,
    'name' => 'image__VIEW_MODE__' . $formatter,
  );
}
$display->status = 1;
$display->settings['image_style'] = '';
file_display_save($display);


I ended up using "template suggestions" feature of drupal 7.  Now I only have one content type called Article Page.  I added a custom field to it called field_template, which takes the name of the template i want to use not including the page-- prefix and not including the .tpl.php suffix.  So if field_template has the value 'landingpage', then the template will be 'page--landingpage.tpl.php';

Then in my ~/sites/all/themes/THEMENAME/template.php file, I wrote the following function

function THEMENAME_process_page(&$variables) {
  if (array_key_exists('node', $variables))
  {
        if($variables['node']->field_template['en'][0]['value'])
        {
        $variables['theme_hook_suggestions'] = array('page__'.$variables['node']->field_template['en'][0]['value']);
        }
        else
        $variables['theme_hook_suggestions'][] = 'page__'. $variables['node']->type;
  }
}

Replace THEMENAME with the name of your theme.


Drush error on core update "corrupt (wrong md5 checksum)"

By looking at this drupal issue queue thread, https://www.drupal.org/node/1961304 , if you are using Drush Make and having problems try --no-cache option for your build.

Otherwise assure the downloaded Drupal version, or module, is readable by the Drush user. If drush cannot read the file then the md5 checksum cannot be run and Drush will report a corrupt file:

  @sobi3ch: this appears to be a permissions issue. If i'm reading the
  Drush output correctly,
  "md5_file(/var/www/vhosts/etcc.pl/drupal-7.38.tar.gz): failed to open
  stream: Permission denied" is saying the md5 checksum function is
  unable to open the file to validate the checksum on it, which causes
  drush to think the file has the wrong checksum.


How is DRUPAL_CACHE_PER_USER handled for anonymous users?

Yes. If a user is not logged in then uid is 0. So all anon users share the same user id.

I guess you will have to do your own caching, e.g. based on the IP address.


You a use a geo IP database/service to lookup a lat/long based on the user's IP address. There are many PHP API's out there to do this. The most popular Drupal module based solution is Smart IP.

  Smart IP identify visitor's geographical location
  (longitude/latitude), country, region, city and postal code based on
  the IP address of the user. These information will be stored at
  session variable ($_SESSION) with array key 'smart_ip' and Drupal
  $user->data object with array key 'geoip_location' of the user but
  optionally it can be disabled (by role) at Smart IP admin page. Other
  modules can use the function smart_ip_get_location($ip_address) that
  returns an array containing the visitor's ISO 3166 2-character country
  code, longitude, latitude, region (FIPS), city and postal code. It
  provides a feature for you to perform your own IP lookup and admin
  spoofing of an arbitrary IP for testing purposes.


Drupal forum post not showing on forum index

The red box means the post has been unpublished.  You are still able to see the post, but everyone who is not a webmaster gets a 403.

Drupal.org uses a number of automated tools to detect and unpublish unwanted posts (e.g. suspected spam).  The most likely explanation is that your post tripped up one of these automated tools.

If you believe your post was unpublished in error, request it to be republished in the Drupal.org webmasters issue queue.


Go to your view settings. Add term relationship - your term field. Add Filter critera - Parent term. Operator 'equal' value - leave empty


I would approach it this way:

Have a branch master:

Create 2 separate branches fed from the master (master being prod):
- stage
- test

Create a new branch abcfeature based from master, after complete, merge to stage/test.

Use domain alias's to setup different URLS in your test environment.


Apply condition between two fields in drupal 7 by using JQuery

I have tried your code and got a quick solution i.e. reset second select box every time first is changed.

look how I have implemented the same:

$(function(){
$("#edit-main-field-i-am-field-und").change(function() {

    $('#edit-main-field-look-for-field-und').val("_none"); // added to reset second select box on chanage of first one

       var value = $(this).val();
       var optionText = $(this).find('option[value='+value+']').text();
    $('#edit-main-field-look-for-field-und').find('option').show();
       if(optionText=="A" || optionText=="C" )
       {
         //alert("12345");
           $('#edit-main-field-look-for-field-und').find('option').filter(function(){
               if($(this).text()=="A" || $(this).text()=="C")
                 return true;
              else
                 return false;
           }).hide();
       }
      else
       {
           //alert("98765");
           $('#edit-main-field-look-for-field-und').find('option').filter(function(){
               if($(this).text()=="B" || $(this).text()=="D")
                 return true;
              else
                 return false;
           }).hide();
       }
    $('#edit-main-field-look-for-field-und option:visible:eq(1)').prop('selected',true);
   // alert($('#edit-main-field-look-for-field-und').val());
    });
});

I have just added $('#edit-main-field-look-for-field-und').val("_none"); in .change function.


Not sure what version of Drupal you are using, but have you looked at the Forum Access module?  For D6 there is a stable release and the D7 version is in Beta. The module is also very straight-forward

From the module's page:

  This module changes your forum administration page to allow you to set
  forums private. You can control what user roles can view, edit,
  delete, and post to each forum. You can also give each forum a list of
  users who have administrative access on that forum (AKA moderators).

  This module requires the ACL module in order to function. The D7
  version also requires the Chain Menu Access API module.

  Forum Access is compatible with the core Forum module, Advanced Forum,
  and Content Access, Domain Access as well as all other well-behaved
  node access modules.


Dynamically creating menu links from a node's fields

You can do it with Field Group module and also use Display Suite which gives lot of options to display your content. Check out the image, it was created using field group.


How do I create a Machine Name type of field?

There is a machine_name element type for the Form API, but it appears there is no machine name field type in core or in a contrib module. From there, I see three code-driven solutions:

It should be possible to crudely alter your node form to replace a text-field widget with a machine name element,
but the proper way would be to define a new Field API widget type based on the machine name Form API element type.
You can also not use the Field API for, directly add a machine name element in your node edit form through a form alter hook and handle storing it's value yourself.


Organic Groups Views contextual filter is not working

I had a similar issue and it took me hours to finally find this solution:
http://drupaleasy.com/blogs/ultimike/2013/05/sneaky-previously-undocumented-views-feature

I know it's for overriding the title, but it worked for me when I wanted to display a certain content type in a view for a specific group based on what page I was on. I fiddled for quite some time with relationships and different combos. But, all you need is the contextual filter: OG Membership: Group ID with a default value provided (current OG group from context) and specify validation criteria (OG GrouP).

Hope this helps!


If you go through the panels module README file. It clearly says the below:

dependencies:
  - ctools
  - layout_discovery
  - drupal:system (>= 8.3.x)
test_dependencies:
  - page_manager

Make sure you have the above modules pre-installed for Panels.

For further help you can follow here: https://www.ostraining.com/blog/drupal/panels-drupal-8/

Else, revert back for further help.


The $content variable is an array (a 'render' array in Drupal parlance). You'll be able to render the parts of the content individually instead of all in one go if you want, and wrap them in specific HTML:

  <?php echo render($content['body']); ?>

  <?php echo render($content['field_some_image_field']); ?>

You can even provide a template file for just the content type you want to change, by calling it node--content-type-name.tpl.php, and just apply the changes to that particular content type.

For styling, each field will already be wrapped in HTML with many, many classes attached to it. Just fire up developer tools/firebug, inspect the elements, and you'll find the correct selectors to target with CSS. If that fails, you've can add the wrappers in yourself like in the code example above.


Panels - Style region to become a drop down/expandable menu

I solved this by using the following module & some code:

http://drupal.org/project/panels_extra_styles

Panels region > Change style > Wrapper: raw.

Content prefix:

<form>

    <fieldset class="collapsible form-wrapper">
      <legend>
        Attachments
      </legend>

Content suffix:

    </fieldset>

</form>

Save and update. Voila!

References: Supplied if needed.


CCK uses theme_fieldgroup_fieldset by default to render field groups. The single argument to that function usually contains all the fields that belong to that field group (apart from a rendered representation of those fields). So if you could override how to theme your specific field group, you would be done.

One way is to override this function in your theme: add a function foo_fieldgroup_fieldset to your theme (if your theme is called foo). Note that this function is then used for all field groups. The function would have to decide on its own whether to show or hide empty fields. See Overriding themable output for more details.

A different way would be to use a template file for rendering field groups. You would have to implement hook_theme for this to work (either in your theme or in a module). Advantage of this is, that preprocess functions are executed before rendering the field group. Preprocess functions allow you to add template suggestions, so you could have a custom template for one field group and a default one for others.

Also: have a look at the Theme developer module. It tells you for each item on a Drupal page which theme functions, templates and preprocess functions where involved in the rendering and how you could override the output.


Define ckeditor add media library location

You could use the Views Media Browser module

  This module adds a Views based Media browser to the site that allows filtering files based on fields attached to the various file types.


Cannot apply my custom styles to HTML tags in ckeditor

So I resolved this problem by clearing cache.  Not Drupal's cache (I'd tried that about a zillion times) Chrome's cache.  Duh.


8 How to configure add-on products in Commerce 2.x

Commerce Product Add-on now has a beta release for D8.


"Did not meet requirements; missing migrations" error

You don't describe precisely how you're doing your custom migration, but the key to missing requirements on migrations you are omitting is to remove the dependencies. The migration that is complaining will have in its configuration something like

migration_dependencies:
  required:
    - d6_user
    - d6_node_type
    - d6_node_settings
    - d6_filter_format
  optional:
    - d6_field_instance_widget_settings
    - d6_field_formatter_settings
    - d6_upload_field_instance

Simply remove references to migrations which you are not running.


Files (±50MB, audio) automatically repetitively deleted (after ± a couple of hours-days?)

Does this has something to do with CRON (just a wild guess)?

No, drupal won't delete files in the folder, it must be something else on your server.

  Is it not smart to manually (FTP) upload files into the root folder? Should a module be used at all times?

Files should be in your files directory (usually sites/default/files) if you're uploading them via the UI so Drupal can manage them.  If they're more static, they should be in a module/theme folder.


I found the answer to my question by tinkering. Like most solutions to my aggravating questions, it's stupidly simple.

I checked "remove tags from rendered output".

Upon inspection of the HTML page source, I found that the attribute content="[long, granular-to-the-millisecond datetime]" (e.g. content="2011-08-01T00:00-04:00") was plopped inside a  tag that was wrapped around the rendered output. So even though it looked like it was being grouped only by the 4-digit year value, it was actually being grouped by this whole, long value:

[Year]

Since each of these contained a totally unique datetime value, it appeared not to be grouping by year at all.


Can I update directly from 7.7 to 7.12?  Or do I have to do 7.7 to 7.8, 7.8 to 7.9, etc?

You should be able to go right from 7.7 to 7.12.  The messages from update.php depend on changes to the database schema from version to version made by drupal and other modules, and they are normal.

You may be interested in drush.  It allows you to run updates with the pm-update command and automatically runs update.php for you.  It also saves backups in your home directory.  There is a website, http://drushmake.me/, that allows you to build out sites with drush make if you are using drush version 5.


I think you need to follow following approach:

 /**
 * Implements hook_entity_property_info_alter().
 */
function modulename_property_info_alter(&$info) {
  $info['node']['properties']['concat_field'] = array(
    'type' => 'text',
    'label' => t('Concatenated form of all the taxonomies that has been added to the node'),
    'sanitized' => TRUE,
    'getter callback' => 'modulename_search_api_property_concat_field_callback',
  );
}

/**
 * Getter callback for concatenate terms field.
 */
function modulename_search_api_property_concat_field_callback($item) {
  /** Do all your processing/functionality here. **/
  return <resultant concatenated value>;
}


Use Google Analytics to Track Home Page Links Differently

You actually can see the Landing pages and their behavior flow in your Google Analytics account. Login your Google Analytics account and go to "Reporting > Behavior > Behavior Flow", and you will see all the landing pages and interaction. The home page should be the "/".


HTML being removed when rewriting field in Views

Adding a class and then the style to your stylesheet is the normal practise.  Quick fix

.slides-full-screen-image {
Background-image:  url....

}

If you have more calls to that class where you don't want the image then you should add an additional class name.


Caching problem. Site only works with cache off

Here is how I do in my local projects, may be it can help you.

I have one main project(local) and four its instances(cloned). Same files, same db structure (I'm using Memcache Storage module).. First time when I've tried to clone and work on them I faced some strange problems, then I found that they were sharing cached data (I was using default memcached instance with 11211 port).. Then I just copied the default memcached.conf file as memcached_1.conf(memcached_2.conf,...) and changed their port as 11212,... in them, restarted all memcached instanes(sudo service memcached restart), and specified those ports to to my cloned projects in their settings.php, that solved my problem..


why not use substr() let the SQL statement bring it all then use this function in your result

would be something like this:

<?php

$result = db_query('Your SQL statement');

print substr($result, 0 , 199);

?>


How to prevent bots to enter specific pages on my site by a capture

It sounds like you want to guard against robots that ignore robots.txt. Or possibly against spambots that are trying to exploit your comments section. I think the easiest way is to not allow anonymous users access to the page. Then, if you protect the login page with captcha, you should be able to keep any bots where you want them.

You will need the Content Access module and the Captcha module.


Can't login to Drupal after Varnish install (reverse proxy)

I'd like more details.  To start, here's what I have in my settings.php:

/**
 * Varnish settings
 */
$conf['cache_backends'][] = 'sites/all/modules/varnish/varnish.cache.inc';
$conf['cache_class_cache_page'] = 'VarnishCache';
$conf['reverse_proxy'] = true;
$conf['cache'] = 1;
$conf['cache_lifetime'] = 0;
$conf['page_cache_maximum_age'] = 21600;
$conf['reverse_proxy_header'] = 'HTTP_X_FORWARDED_FOR';
//$conf['page_cache_invoke_hooks'] = false;
$conf['reverse_proxy_addresses'] = array('127.0.0.1');
$conf['omit_vary_cookie'] = true;
$conf['page_cache_invoke_hooks'] = FALSE;

All of that might not be necessary, like $conf['page_cache_invoke_hooks'] = FALSE - but it's working for me

First, did you set Varnish to port 80 and Apache to port 8080?  First try to access the site via http://example.com:8080 to see if Apache is still serving pages.  Another way to check for servers working is by opening terminal via ssh and typing 'netstat -anp | grep httpd'.  Here is my output:

netstat -anp | grep httpd
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      324/httpd

netstat -anp | grep varnish
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      24841/varnishd
tcp        0      0 127.0.0.1:6082              0.0.0.0:*                   LISTEN      24840/varnishd

You can see that apache (httpd) is working on :8080 and varnishd (d for daemon i.e. service) is running on :80 and :6082 where :80 is varnish and :6082 is its backend.

If you CAN see site on :8080 and you have varnish running on :80 and :6082 you should go to the varnish drupal config page via http://example.com:8080/admin/config/development/varnish

From there you should select the correct Varnish version set, the Varnish Control Terminal set to 127.0.0.1:6082, and your Varnish Control Key set.  You can find this by seeing the output of the secret file.  In CentOS you can do this by: cat /etc/varnish/secret - this will give you a 30ish char long string to input.  At the bottom of this settings page you will find "Status: Varnish Running" hopefully.

If you have all of this working and still can't get the site to show, it will be giving you an output noting Varnish and a Guru Meditation.  This shows you that varnish is indeed running but just isn't configured correctly, most likely in your .vcl file.  If no guru meditation and site not working, you probably haven't set the sysconfig correctly.  Edit - again CentOS - /etc/sysconfig/varnish using vi or nano.  I have the following uncommented:

// using Alternative 2, Configuration with VCL
DAEMON_OPTS="-a :80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s file,/var/lib/varnish/varnish_storage.bin,1G \

Check that the .vcl file is correctly referenced and that the port (:6082) is the same as what you found with netstat above.

Finally, if you are getting the Varnish Guru Meditation the .vcl is the issue.  In this case here's some of what I have for the .vcl:

BEGINNING OF FILE ->
backend default {
  .host = "127.0.0.1";
  .port = "8080";
  .connect_timeout = 600s;
  .first_byte_timeout = 600s;
  .between_bytes_timeout = 600s;
}

sub vcl_recv {
//TRY THIS AT BEGINNING ->
return(pass)
..
}

The return(pass) will pass EVERYTHING and thus Varnish won't actually be caching anything, but you can use for diagnosis.  Remember after changing anything varnish related you need to restart varnish by: service varnish restart - if you .vcl has any errors it won't restart.


Varnish/Drupal caching for logged in users

You have two options:

Solution 1: Disallow caching in the browser

In order to prevent a browser from storing and reusing a page, you have to make sure that Cache-Control:no-cache, must-revalidate, post-check=0, pre-check=0 is on the respective (HTML) pages.

You can force this header in sub vcl_deliver. Just make sure that you do not put that header on static assets (like images, CSS and JavaScript files):

sub vcl_deliver {
  set req.http.Cache-Control = "no-cache, must-revalidate, post-check=0, pre-check=0";
}

Solution 2: Ensure that Vary: Cookie is on the response

If you want to force the browser to invalidate its cache whenever the cookies change (i.e. a session is opened), you have to ensure that the Vary: Cookie header is on the response.

sub vcl_deliver {
  if (resp.http.Vary !~ "Cookie") {
    set resp.http.Vary = resp.http.Vary + ", Cookie";
    set resp.http.Vary = regsub(resp.http.Vary, "^,\s*", "");
  }
}

Again, the cache is more effective if you restrict this fragment the page / filetypes which have different contents depending on whether a user is logged in or not.

Safari (at least v5 which is the last one for Windows and the one on iPad 1 and some older iPhones) has a nasty bug. I recommend to add the following snipped in order to deactivate the Safari browser cache:

sub vcl_deliver {
  if (resp.http.X-Generator ~ "Drupal" && req.http.user-agent ~ "Safari" && req.http.user-agent !~ "Chrome") {
    set resp.http.Cache-Control = "no-cache, must-revalidate, post-check=0, pre-check=0";
  }
}

Note: This is a little bit different from the solutions proposed in the comments of the bug report. By placing the snipped into vcl_deliver instead of vcl_fetch we avoid having to separate the bins. Also note that by matching on X-Generator ~ "Drupal" we avoid disabling the browser cache for static assets.

Today (November 2013) I reproduced this misbehavior on Safari 5.1.1 (Windows), 6.1 (Mac OS X 10.8 / Mountain Lion) and 7.0 (iOS 7).


Drush error during adding an install profile as platform

The solution for me was to use the HTTPS-link instead of the SSL-link.

projects[drupal_development_base][type] = "profile"
projects[drupal_development_base][download][type] = "git"
projects[drupal_development_base][download][url] = "https://joachimroeleveld@bitbucket.org/joachimroeleveld/drupal_development_base.git"
projects[drupal_development_base][download][branch] = "master"


What you're asking doesn't quite make sense if I understand it correctly.  You see, the view you're choosing when setting up the field is used before your user has even entered anything in the auto-complete field.  So you can't have that be an argument.  The view is generated and used prior to any input.

The view is used simply to determine which set of users are available for the auto-complete field.  It doesn't make sense to generate the view after the user has already entered in a value, because at that point they've already made a selection anyway.

So - I'm wondering, since you're asking about basing that view on user input, if what you're looking for is simply something like the 'auto-complete' functionality which exists with entity and user/node references.  If you select for your field to be Autocomplete, when the user starts typing in a username, a list of related suggestions will automatically appear at the bottom.

Here's an example of a user reference field with autocomplete turned on


How to create a eCommerce site products slideshow using views

You can use view_slideshow module

https://www.drupal.org/project/views_slideshow

Before installing read README.html file present in the module. you can achieve the required output.

If you need more customization in the slider, you can use

https://owlcarousel2.github.io/OwlCarousel2/  also...if above one does not satisfy your requirement.


Access one field from another when using entities

You mentioned you are using ECK to create a new entity, whereas in your code, you are using 'node' instead of the machine name of your entity.

I am referring to the line:

$field_image_positon = field_get_items('node', $variables['element']['#object'], 'field_image_position');

Change node in this line to your_entity_machine_name.


I will assume you are referring to using the Insert module.

Once you have inserted an item into a node field (most likely the body), it then becomes a simple string of text within that field and is processed as such. There is no longer anything linking it to the image field that you used to upload it, and no way to hook onto it and perform any programatic changes. The only "theming" that can be done to the image at this point is CSS changes.

You could potentially add optional styles for the images via your WYSIWYG's configuration or you could use the Image Resize Filter module to allow the node editor to change the size of the image and/or create a link to the full-size image.

If you could give some details about what exactly you are wanting to do to that images that have been added via the Insert module, there might be another solution someone can suggest.


Is complex field validation possible with WebForm?

Try using the WebForm Validation module.

  The following validation rules are currently included:

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


Extending a base template file such as field.html.twig renders no results?

If you want to only override the field template.

Try with with the following.

Implement hook_theme like the following no needs for variables and file keys.

  /**
     * Implements hook_theme().
     */
    function myModule_theme($existing, $type, $theme, $path) {
      return [
        'field__parent_task' => [
          'template' => 'field--parent-task',
          'base hook' => 'field',
        ],
      ];
    }

Create templates folder in your module root.
Create field--parent-task.html.twig inside your templates folder.
Copy and the paste the base template code into your template file.
Clear the cache.


How can I use WordPress-like short codes?

The Shortcode module provides this functionality, it even has this comment:

  Initial work is based on the Wordpress Shortcode API but was reworked for Drupal.

So I think it's the closest thing you're going to find (although the Drupal 7 version is currently only in alpha).

It's not quite the same as the one in Wordpress from the looks of it. It seems you'll need to define a shortcode for each function that you want to run (using hook_shortcode_info()), or else define a more complex shortcode that will allow the adding of arbitrary functions.

There are a few extension modules included with the main module that look pretty easy to understand so I'd have a look through those to see exactly what you need to do to add your own functionality.


strcmp() expects parameter 2 to be string error on configuration and system status page

It looks like this issue can occur if two modules return the same array key from hook_requirements?

Here's a similar result affecting LinkedIn Integration:

#1711604: On installation errors reported from system.module and system.admin.inc

According to that issue, this will happen if two separate modules add a requirements check with a key of curl. The solution is to namespace requirements checks (use a key of linkedin_curl, simpletest_curl and so forth).

You could debug this and check the issue queue for the affected module(s).

Disabling the most recently added modules might help you identify the cause (see if the symptom goes away).
If you still feel stuck and don't feel able to dig further, try updating your question with the list of enabled modules on your site. That may help narrow it down.
If you're running all contrib modules, googling for "strcmp _system_sort_requirements drupal" might show results that help you identify the affected module.
If you have Drush + Devel module, try drush fn-hook requirements to see which installed modules are implementing hook_requirements.
Or just start hacking on your system settings page and trace the problem down old-school :)

If this is the cause, once you identify the module(s) causing the issue you should check the issue queue, file an issue if none already exists, and help be a part of getting it fixed!

I've tagged several affected modules in #933684 - Same requirements from different modules causes warnings in _system_sort_requirements()


Token filter does not show image field with FlexSlider formatter

My solution.

Install custom_formatters module.

Create a view with FlexSlider formatter:

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

    /* Display: Master */
    $handler = $view->new_display('default', 'Master', 'default');
    $handler->display->display_options['use_more_always'] = FALSE;
    $handler->display->display_options['use_more_text'] = 'more';
    $handler->display->display_options['access']['type'] = 'perm';
    $handler->display->display_options['cache']['type'] = 'none';
    $handler->display->display_options['query']['type'] = 'views_query';
    $handler->display->display_options['exposed_form']['type'] = 'basic';
    $handler->display->display_options['exposed_form']['options']['submit_button'] = 'Apply';
    $handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'Reset';
    $handler->display->display_options['exposed_form']['options']['exposed_sorts_label'] = 'Sort by';
    $handler->display->display_options['exposed_form']['options']['sort_asc_label'] = 'Asc';
    $handler->display->display_options['exposed_form']['options']['sort_desc_label'] = 'Desc';
    $handler->display->display_options['pager']['type'] = 'full';
    $handler->display->display_options['pager']['options']['expose']['items_per_page_label'] = 'Elements';
    $handler->display->display_options['pager']['options']['expose']['items_per_page_options_all_label'] = '- All -';
    $handler->display->display_options['pager']['options']['expose']['offset_label'] = 'Skip';
    $handler->display->display_options['pager']['options']['tags']['first'] = '« first';
    $handler->display->display_options['pager']['options']['tags']['previous'] = '‹ prev';
    $handler->display->display_options['pager']['options']['tags']['next'] = 'next›';
    $handler->display->display_options['pager']['options']['tags']['last'] = 'last»';
    $handler->display->display_options['style_plugin'] = 'flexslider';
    $handler->display->display_options['style_options']['optionset'] = 'gallery_in_text';
    $handler->display->display_options['row_plugin'] = 'fields';
    /*  */
    $handler->display->display_options['fields']['field_gal']['id'] = 'field_gal';
    $handler->display->display_options['fields']['field_gal']['table'] = 'field_data_field_gal';
    $handler->display->display_options['fields']['field_gal']['field'] = 'field_gal';
    $handler->display->display_options['fields']['field_gal']['label'] = '';
    $handler->display->display_options['fields']['field_gal']['element_label_colon'] = FALSE;
    $handler->display->display_options['fields']['field_gal']['click_sort_column'] = 'fid';
    $handler->display->display_options['fields']['field_gal']['settings'] = array(
      'image_style' => '',
      'image_link' => '',
    );
    $handler->display->display_options['fields']['field_gal']['group_rows'] = FALSE;
    $handler->display->display_options['fields']['field_gal']['delta_offset'] = '0';
    /*  */
    $handler->display->display_options['sorts']['created']['id'] = 'created';
    $handler->display->display_options['sorts']['created']['table'] = 'node';
    $handler->display->display_options['sorts']['created']['field'] = 'created';
    $handler->display->display_options['sorts']['created']['order'] = 'DESC';
    /*  */
    $handler->display->display_options['arguments']['nid']['id'] = 'nid';
    $handler->display->display_options['arguments']['nid']['table'] = 'node';
    $handler->display->display_options['arguments']['nid']['field'] = 'nid';
    $handler->display->display_options['arguments']['nid']['default_action'] = 'not found';
    $handler->display->display_options['arguments']['nid']['exception']['title'] = 'All';
    $handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed';
    $handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
    $handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
    $handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
    /*  */
    $handler->display->display_options['filters']['status']['id'] = 'status';
    $handler->display->display_options['filters']['status']['table'] = 'node';
    $handler->display->display_options['filters']['status']['field'] = 'status';
    $handler->display->display_options['filters']['status']['value'] = 1;
    $handler->display->display_options['filters']['status']['group'] = 1;
    $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
    /*  */
    $handler->display->display_options['filters']['type']['id'] = 'type';
    $handler->display->display_options['filters']['type']['table'] = 'node';
    $handler->display->display_options['filters']['type']['field'] = 'type';
    $handler->display->display_options['filters']['type']['value'] = array(
      'page' => 'page',
    );

Go to the custom formatters settings, create new formatter for Image field:
Format: PHP
Field types: Image
Formetter (php):

  print views_embed_view('field_slider','default', $variables['#object']->nid);

Or import this:

    $formatter = new stdClass();
    $formatter->disabled = FALSE; /* Edit this to true to make a default formatter disabled initially */
    $formatter->api_version = 2;
    $formatter->name = 'gallery_views';
    $formatter->label = 'Gallery views';
    $formatter->description = '';
    $formatter->mode = 'php';
    $formatter->field_types = 'image';
    $formatter->code = 'print views_embed_view(\'field_slider\',\'default\', $variables[\'#object\']->nid);';
    $formatter->fapi = '';

Then go to the Token tab (admin/structure/types/manage/[your_content_type]/display/token), set the Gallery views formatter. Now it works.


Can't save any changes on the Content Language & Translation page

I tried the max_input_vars fix and that didnt work.
I had to check the entity, pretend it was called MyCustomEntity in 'Custom language settings' at the top... but also scroll down to the individual MyCustomEntity settings further down on the page, and also check that checkbox. When I saved, now it worked


if you use Drupal7, you should not use

drupal_set_message(kint($variables));

but

kint($variables)

or

dpm($variables)

An example that you can see, enter in the following link:
 https://api.drupal.org/api/drupal/modules%21comment%21comment.module/function/template_preprocess_comment/7.x

function bartik_preprocess_comment(&$variables) {

  $variables['classes_array'][] = 'myclass';
  dpm($variables);

}

You can also create a file "comment-wrapper.tpl.php" and add the classes you want and placeholder.

Example:

<?php

/**
 * @file
 * Bartik's theme implementation to provide an HTML container for comments.
 *
 * Available variables:
 * - $content: The array of content-related elements for the node. Use
 *   render($content) to print them all, or
 *   print a subset such as render($content['comment_form']).
 * - $classes: String of classes that can be used to style contextually through
 *   CSS. It can be manipulated through the variable $classes_array from
 *   preprocess functions. The default value has the following:
 *   - comment-wrapper: The current template type, i.e., "theming hook".
 * - $title_prefix (array): An array containing additional output populated by
 *   modules, intended to be displayed in front of the main title tag that
 *   appears in the template.
 * - $title_suffix (array): An array containing additional output populated by
 *   modules, intended to be displayed after the main title tag that appears in
 *   the template.
 *
 * The following variables are provided for contextual information.
 * - $node: Node object the comments are attached to.
 * The constants below the variables show the possible values and should be
 * used for comparison.
 * - $display_mode
 *   - COMMENT_MODE_FLAT
 *   - COMMENT_MODE_THREADED
 *
 * Other variables:
 * - $classes_array: Array of html class attribute values. It is flattened
 *   into a string within the variable $classes.
 *
 * @see template_preprocess_comment_wrapper()
 */
?>
<?php
    //add placeholder
    $content['comment_form']['subject']['#attributes']['placeholder'] = t('Title');
    $content['comment_form']['comment_body']['und'][0]['value']['#attributes']['placeholder'] = t('Comment Body');
  ?>
<div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
  <?php if ($content['comments'] && $node->type != 'forum'): ?>
    <?php print render($title_prefix); ?>

<?php print t('Comments'); ?>

    <?php print render($title_suffix); ?>
  <?php endif; ?>

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

  <?php if ($content['comment_form']): ?>

<?php print t('Add new comment'); ?>

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


Is it possible to control a User's Role based on their Email Address?

"Auto Assign Role" and "Apply for role" modules seem to be close to what you are asking for.

https://www.drupal.org/project/autoassignrole
https://www.drupal.org/project/apply_for_role

If they don't fit your exact use case then I suggest looking at the way autoassignrole_user_presave() works as a starting point for custom coding. http://cgit.drupalcode.org/autoassignrole/tree/autoassignrole.module#n183


I know it was not that difficult but I was not getting the actual thing how to achieve it but now it is working for me.

Things to do:

Go to your /admin/config/workflow/rules/components and click on "Add new Component"
Select "Action set" under Component plugin & Press Continue.
Give appropriate Name.E.g: Flag Node.

Data type : Content, Label: Node, Machine name:node & Press Continue.
Click on "Add action"  & select "Flag a node" ,once it returns the result data,Select which flag should be clicked.

For => node :Data selector use node &

For =>User on whose behalf to flag : Data selector use node:author

& Press Save.

Done with the component.

Now Add a New Rule
Go to your /admin/config/workflow/rules and click on "Add new Rule"
Give appropriate Name.E.g: Flag Node Rule.

React on event : After updating existing content. (as you need)

& Press Save
You can add conditions if you want whether it should be published or should belong to any content type or what so ever you need.
I have used Content is of type.
This is the thing which works like a magic to schedule your event(Here Flag).
Click on "Add action" & Select "Schedule component evaluation" under Rule Scheduler

& Select the Component Value ** as (**Flag Node) which we created just before configuring this rule & Press Continue.
Enter Scheduled evaluation date which will schedule your event when to get triggered.

Data selector :(Enter Your values as +2 minutes, +2days, +2 weeks etc as your need)
Identifier => Value : [node:title] has been Flagged.(You can use any message you want to see on /admin/config/workflow/rules/schedule along with list of scheduled events.)
Node => Data selector : node

& Press Save.

Done with the Rule.

Configuration is done. You can test it now.

But please have a look into this. I was not checking such thing so was not able to see the result.
Your event will respond you only after the cron run because it is executed by the cron. The cron triggers a query to check whether something should be published or flagged.If your cron runs every hour and you want something published on 22:35 and it is past that time it will be actually published the next time your cron runs. So if your cron runs at 22:30 and 23:30 the publish will be at 23:30.

Hope this will be helpful for someone.


content types vs. paragraphes types + taxonomy

Personally I don't think this is a good use case for paragraphs. I don't see any benefit of having only a single content (node) type, you are just moving comeplexity from nodes to paragraphs.

I think the key here is to carefully plan and reuse fields across entities. If your car equipment and your plane equipment both have a weight attribute, reuse the same field (or to be more precise: reuse the field storage), so e.g. you can use it to as filter in a shared view for both equipment types.


I put this in my drushrc.php file to change the default rsync mode to -rlptz for all sites:

$command_specific['rsync'] = array('mode' => 'rlptz');

You could also put it in each site alias if you did not want the change to be affected on a global basis:

$aliases['mysite'] = array(
  'root' => '/path/to/drupal',
  'uri' => 'mysite.org',
  'command-specific' => array(
    'rsync' => array(
      'mode' => 'rlptvz',
    ),
    'sql-sync' => array(
      'mode' => 'rlptvz',
    ),
  ),
);


Can I use the first value of a multivalue field as another field? ("Cover" use case)

I'm not aware of a "wrapper" field type, but you have a few options.

I've done the same myself in Views by filtering by the "delta" value, which is the individual values in a multivalue field. That way it's easy to require "delta = 0" and get the first value. This has a limitation of currently not working with arguments/contextual filters though.

A second option is the to ctools recently added support for delta values. You can render a field and set both offset, range and reversal of deltas.

Final option I can think of is Computed Field, which could be programmatically coded to act as field wrapper.


How can I see multiple terms on a single view?

Grouping can be enabled in Format section of your View [Format > Settings]. Select title field for grouping and then exclude it from display to avoid rendering it twice.
Aggregation in this case will not give you the result that you're looking for.


Taxonomy terms with numeric names and views filtering within range

I believe a numeric range can be filtered using regular expression.

The following regex can effectively filter values within the range 10500 - 11000 (both ends inclusive)

(10[5-8][0-9]{2}|109[0-8][0-9]|1099[0-9]|11000)

Here is a sample view that works as expected with the above regular expression

You can create any numeric range as a regex using this generator http://gamon.webfactional.com/regexnumericrangegenerator/

Alternativelly what you can do is to add an extra numeric field to populate with term name (as a number) and than using that field to filter the view OR create a more complex function using hook_views_query_alter as you mentioned


Views not displaying on page, but show up in preview

Few possible things you may try to resolve the above problem are:

Make sure the path you are accessing is same as the path you have assigned to page display.
Not using the same path elsewhere (e.g: either in the hook_menu, panels, etc.)
Try changing the path (adding some random chars) for testing and check if it works.
Perform a search in the menu_router table for the path you are using, and if it already had an entry than you need to change the path.


Looks like 'path' is required.. maybe it's always been like this and I just didn't realize. Installing Pathauto (from GitHub) and Token (from Drupal.org) corrects the issue.


{Date_Repeat} Every day of the week doesn't work

Is there any chance that in your time zone there's a Daylight Saving Time change on Saturday, November 6 ? Like for exemple in Los Angeles.
Because this would explain the shift of one hour you get after the 5th of November (remember, remember :) ).

  Inspiration: OMG Ponies!!! (Aka Humanity: Epic Fail), Jon Skeet -
  Stack Overflow Dev Days London 2009, video and transcript.


Drupal multisite: Same theme, different colors

Well, I found out something that is quite useful:

Instead of trying to import the color.less file in each 'basic' theme css file, I do it the other way around: I import all the basic theme css files in colors.less, like this:

@basis: blue;
@donker: black;
@licht: pink;

@import "../all/themes/Theme/css/basic.less";

Then I had to remove all the stylesheet definitions in the .info file and changed the template function to:

$css = drupal_add_css(conf_path() . '/colors.less', array('group' => CSS_THEME, 'weight' => 115, 'browsers' => array('IE' => 1, '!IE' => 1), 'preprocess' => FALSE));

No hassle with php, and it works, is cached when I want it, and fast!


Should one avoid lots of use statements in a custom modules .module file?

The use statements alone are definitely not going to be a performance concern. I doubt that we're even talking about nanoseconds here. So that really doesn't matter. I'm guessing that this is resolved at compile time anyway.

Especially in a .module file, use statements usually grow, the more code you have, the more use statements, as a .module file is often doing many different things, implementing various hooks and so on.

If you want to optimize something, look at your actual code, forget about the use statements. Some hooks can be moved into include files, especially those that are only needed when rebuilding caches, like hook_views_data().  Other things can be done in services. But also here, the argument is most likely not going to be runtime performance, parsing code is really, really fast. It's your performance in understand the code, finding bugs, writing  test and so on. Optimize for that.


How do I set different front pages for domain access sub sites?

You didn't mention versions, so I will assume the most recent: Drupal 7 and Domain Access 7.x-3.9.

The preferred method requires that your 'secondary front page', as you call it, has a different path than your primary front page.

Make sure the Domain Settings module (part of the Domain Access package) is enabled. This will allow you to specify domain-specific configuration options on several admin forms.

Now, when you go to /admin/config/system/site-information, you will see a fieldset at the bottom of the page saying "Domain-specific settings". Choose the domain for which you want a different front page. Under "Default front page" higher up the form, enter the path of your secondary front page and click the save button.


Repeatation of class while adding class in twig template

If you don't want to add a class, but to replace the existing classes, you can use setAttribute().

<li{{attributes.setattribute('class', 'page-previous')}}>


What are the Steps to Translate the Current Search Block and Facet Search block(s)

I was able to solve this issue; however not in an ideal way:

see: https://drupal.org/node/1478908

see: https://drupal.org/node/1387504

see: https://drupal.org/node/1376786

see: https://drupal.org/project/facetapi_i18n

By implementing hook_block_view_alter and passing pieces of the markup to the translation function.

function MY_MODULE_block_view_alter(&$data, $block) {
    if($block->module == 'current_search'){
            $original_markup = $data['content']['results']['#markup'];
            $original_filtered = strip_tags($original_markup);
            $results_count_int = filter_var($original_filtered, FILTER_SANITIZE_NUMBER_INT);
            if($results_count_int){
                    $new_text = t('Search found @count item(s)', array('@count' => $results_count_int));
                    $new_markup = "
$new_text
";
                    $data['content']['results']['#markup'] = $new_markup;
            }
    }

}


If you are using the views_data_export module and you have command line access you can try the following:

cd [your_drupal_docroot]
drush views-data-export [view-name] [display-id] > [path-to-output-file]

You could then add this to cron as a one-liner, e.g. this would run every Monday at 5:59 AM:

59 5 * * 0 cd [absolute_path_to_drupal_docroot] && drush views-data-export [view-name] [display-id] > [path-to-output-file]


I may have had the code correct at some time yesterday, but I was running out of memory on my localhost. I ended up rewriting some of the code and - once I realized I was having memory issues - moved everything onto the server, where it all worked like a charm. Sorry for asking the question. And, thanks, Simon, for provoking me to question everything anew with your comment.
Here is my final code;
            $cropped_image = imagecrop($precrop_resource, $rect);
            imagedestroy($precrop_resource);

            $file_path = \Drupal::service('file_system')->realpath('public://');
            imagejpeg($cropped_image, $file_path . '/temp-image.jpg');

            // load the image
            $cropped_data = file_get_contents($file_path . '/temp-image.jpg');
            $cropped_file = file_save_data($cropped_data);
            unset($cropped_data);

Then I added the image to the node object and saved the node.
EDIT:
I eventually realized a couple issues with the above code. First, it was not just my memory on the localhost; processing 10MB+ jpegs would exhaust the memory on the server as well because the GD2 image tools process everything in uncompressed format. Second, the files were saving without .jpg on their filenames, so using them could be a problem.
So, I ended up using the ImageMagick to process things and added another variable to the file_save_data function call.
Here is my new and improved final code:
            // crop the image
            $precropped_image = new Imagick($precrop_file->getFileUri());
            $precropped_image->cropImage($rect['width'], $rect['height'], $rect['x'], $rect['y']);
            $precropped_image->writeImage($file_path . '/temp-image.jpg');

            // save the cropped image in the Drupal DB
            $cropped_data = file_get_contents($file_path . '/temp-image.jpg');
            $cropped_file = file_save_data($cropped_data, 'public://' . $image_title . '-og.jpg');


Are you using https://www.drupal.org/project/title ? If that's the case you must treat it like a field:

$node->title_field[$node->language][0]['value'] = 'Node Created on ' . date('c');


My usual answer for this is product access permissions haven't been set that would allow anonymous users to view all products, but since you're creating this query directly it isn't clear to me that that would be getting in the way. I suppose Drupal is still running query altering on this and somehow alerting the product module that it's involved?

A simple way to rule that out would be to grant anonymous users permission to view any product of any type and see i they get results. But really seeing the query actually run by Drupal would be useful.


Access denied when using webform submissions email link

Those permissions are for viewing the webform itself - you would need to set permissions to view/edit/delete the submissions.  You can find these settings under "Webform" at /admin/people/permissions


As per my further research I found that there is a module named Content Synchronization which works well with the same issue. As in Drupal 8 blocks as served as content now and block types as entity types.


Adding steps, breadcrumbs, or navigation to multistep webform

It seems the issue of the Webform steps module.

  webform_steps-7.x-1.x is the currently stable version. It works with webform-7.x-3.x only.

Webform steps module doesn't work well with Webform 7.x-4.x version. see the issue

If you're using webform-7.x-3.x version. Here are the steps to make it work.

Webform steps module uses pagebreak labels as Step labels. So go to your form webform settings and change the pagebreak labels as you want to use as steps

For example if you want to use label steps as Step-1, Step-2 .. Step-10. Change the page break labels like Step-1... Step-10


Count content views show in number with icon

Assuming you're using D7, you can implement hook_node_view() in your custom module and override statistics count text as per your requirement. Check example below:

/**
 * Implements hook_node_view().
 */
function [YOUR_MODULE_NAME]_node_view($node, $view_mode) {
  if ($view_mode != 'rss') {
    if (user_access('view post access counter')) {
      $statistics = statistics_get($node->nid);
      if ($statistics) {
        // Alter text as per your requirement below.
        $links['statistics_counter']['title'] = format_plural($statistics['totalcount'], '1 read', '@count reads');
        $node->content['links']['statistics'] = array(
          '#theme' => 'links__node__statistics',
          '#links' => $links,
          '#attributes' => array('class' => array('links', 'inline')),
        );
      }
    }
  }
}


How do I only allow authenticated users to interact with Organic Groups "groups"?

I ended up answering my own question.
There is no access control with organic groups which disallows anonymous users from seeing public organic groups.
You can use the "Domain Strict" module and have the website that the organic groups is to be hosted on not allow "Anonymous" users to view that domain.  This is a configuration option with Domain Strict.

This has the desired effect.  The only downside is that your domain which hosts your organic groups will not allow anyone who is not authenticated to view any content on said domain.

To change this go to Structure-->domains-->User Defaults
find your domain that will hold your OG groups and uncheck "Anonymous User"
Click save configuration.

Tada!


Notice: Undefined index: node-readmore in theme_preprocess_node()

Probably the page view of the node not including the read more link.

e.g

function theme_preprocess_node(&$vars){
  if(!$vars['page']){
    $vars['content']['links']['node']['#links']['node-readmore']['title'] = t('Read more →');
  }
}

or perhaps

function theme_preprocess_node(&$vars){
  if(isset($vars['content']['links']['node']['#links']['node-readmore'])){
    $vars['content']['links']['node']['#links']['node-readmore']['title'] = t('Read more →');
  }
}

No need for the str_replace either if just setting the full text string.

Note, an alternative is to translate that text,

e.g with stringoverrides or in settings.php

$conf['locale_custom_strings_en'][''] = array(
  'Read more'      => 'Read more  →',
  'Old text 2'      => 'New text 2',
);


Possible to customize the look/length of CKEditor Styles dropdown?

After a good bit of trial and error (I'm slow, but persistent), I've figured out the classes to modify the height and item styles in the CKEditor Styles dropdown. Here's an example using values that work for me:

div.cke_combopanel {
  height: 300px !important;
}
li.cke_panel_listItem a {
  padding: 3px 5px !important;
  font-size: .8em !important;
}

The div and li prefixes aren't required; I've included them here simply to identify the element types involved. Setting a fixed height for cke_combopanel is an imperfect solution, but better than the short one I get by default.


There is a patch to add an image as an enclosure field to core here:
https://www.drupal.org/project/drupal/issues/2511878


Creating a Custom Formatter to replace a Link with an Icon / Image

Just click on the rewrite results option in the view for the field you want the changes then just add the following :

 href ="www.example.com/page7 ">

In a similar way you can add images


I had this problem before with some friend about files folder

The solution to this problem is:

1.- in your apache conf or nginx conf or .htaccess disable all formats php in the path /files/*

2.- if you have the opportunity change the permissions to the folder but the first point works, they will upload files php but, they will not run it.

3.- remove estrange files php and search for every file that contains text like base64, search something about this in google or other searcher.

They enter by a port using exploits and add a file like image.php.jpg, and after the file is uploaded, they change the name to image.php (it is not the real name but you get the idea).

That file is an php form, they upload files php through it, like a command line and do a lot of things...

I hope this help you.


From my pesonal experience I can recommend you:

General protection

http:BL module to block most of bots from just viewing your site
CAPTCHA module with reCAPTCHA or Captcha Riddler submodule (other are useless) to protect registration and password reminder forms

Anonymous comments protection

listed above captchas (but that will disable caching on pages with comments)

or

AntiSpam module with Akismet

That will stop at least 99% of spam.


How do I programmatically insert the entity ID?

Why don't you use a module providing this functionality, like profile2 ?

The user is not created in your submithandler, so either you save it:

function foo_user_register_form_submit($form, &$form_state){
    $edit = array(
          'name' => $form_state['values']['name'],
          'pass' => user_password(),
          'mail' => $form_state['values']['mail'],
          'init' => $form_state['values']['mail'],
          'status' => 1,
          'access' => REQUEST_TIME,
          'field_first_name' => array(LANGUAGE_NONE => array(array('value' => $form_state['values']['field_first_name']))),
    );
    user_save(drupal_anonymous_user(), $edit);
}

For more details see the docs.

Or you could try to add a custom submit handler, which would be fired after the user is created, in form_alter:

$form['#submit'][] = 'your_custom_submit_handler_function';

In there the user should already be created. so:

function your_custom_submit_handler_function(&$form, &$form_state)
    {
        $fe_id = db_insert('field_revision_field_first_name')
        ->fields(array(
            'field_first_name_value' => $form_state['values']['field_first_name'],
            ))->execute();
        drupal_set_message(t('your form entry has been added'));
    }

  But keep in mind, that this custom inserting maybe needs some more
  code, here you only add the revision entry ..


How to add JavaScript or CSS library to Composer project?

The library can be installed into a custom path by utilizing extra : installer-paths to for e.g.:

web/sites/libraries/{$name}

Additional to that, we define the required package repository with the needed type of drupal-library. Example composer.json for a project:

{
    "name"              : "example-composer/example-project",
    "description"       : "Project template for Drupal 8 projects with composer",
    "type"              : "project",
    "minimum-stability" : "dev",
    "prefer-stable"     : true,
    "scripts"           : {
        "post-install-cmd" : "sh ./scripts/composer/post-install.sh"
    },
    "require"           : {
        "composer/installers"       : "^1.0.20",
        "drupal/entity_browser"     : "8.1.0-alpha1",
        "cweagans/composer-patches" : "~1.0",
        "drupal/core"               : "8.0.*",
        "drush/drush"               : "~8.0",
        "drupal/console"            : "~0.9",
        "drupal/devel"              : "dev-8.x-1.x",
        "drupal/entity_browser"     : "8.1.0-alpha1",
        "drupal/inline_entity_form" : "8.1.0-alpha2",
        "drupal/dropzonejs"         : "8.1.*@dev",
        "enyo/dropzone"             : "dev-master"
    },
    "repositories"      : [
        {
            "type" : "composer",
            "url"  : "https://packagist.drupal-composer.org"
        },
        {
            "type"    : "package",
            "package" : {
                "name"    : "enyo/dropzone",
                "version" : "dev-master",
                "type"    : "drupal-library",
                "dist"    : {
                    "url"  : "https://github.com/enyo/dropzone.git",
                    "type" : "drupal-library"
                },
                "source"  : {
                    "url"       : "https://github.com/enyo/dropzone.git",
                    "type"      : "git",
                    "reference" : "origin/master"
                }
            }
        }
    ],
    "extra"             : {
        "installer-paths" : {
            "web/core"                    : [
                "type:drupal-core"
            ],
            ...
            "web/sites/libraries/{$name}" : [
                "type:drupal-library"
            ]
        }
    }
}

The dist part can be left off and is only needed for --prefer-dist cases when installing via php composer.phar update --prefer-dist (opposite: --prefer-source). To install a version and not the latest from the master branch, you need to set the version directly at the package to require then from there. Example:

"require" : {
    "enyo/dropzone" : "v4.2.*@dev"
},
"repositories" : [
    {
        "type"    : "package",
        "package" : {
            "name"    : "enyo/dropzone",
            "version" : "v4.2.0",
            "type"    : "drupal-library",
            "source"  : {
                "url"       : "https://github.com/enyo/dropzone.git",
                "type"      : "git",
                "reference" : "origin/master"
            }
        }
    }
]


A month-long operation is a good sign that something went wrong? How did you launch the import? If you used a Web GUI, the operation probably timed-out without updating the UI. I doubt your webserver is configured to allow a month-long HTTP request processing. Are you able to connect to the server to check if a PHP process is indeed still running?

Instead of looking for a module to download the imported file every hour, you could rely on a simple cron job using curl or wget to download the file:

0 * * * * wget http://my.supplier.com/products.xml -a /var/log/supplier-products-download.log --no-verbose -O /some/path/products.xml

If I remember correctly, the default XML parser for Feeds uses SimpleXML. It will load the complete XML tree in memory beofore processing it. For a 8Mb file this could start to be an issue (depending on your PHP memory configuration). A beast approach would be to write your own Feed parser (as a Feeds plugin) using the XMLReader API which support a streaming mode (ie. data are processed when reading the file).


Why isn't local.css file used in styling a page on a site?

Well, I've got it to work by moving  the file into the Sub-stark directory instead of a sub directory and changing the .info file.  I am working on Windows 7 using an Oracle VM with Ubuntu, so there may be that is causing a problem.


What might cause drupal to give me Japanese values for the user profile, when the site is set to English?

Using a debugger and some spot googling, I finally found an answer for this.  In my language detection and selection options I had session turned on as one of the means of detection, and saw that the query variable used for setting this option was language.  adding ?language=en to the end of my url caused the language to switch back and stay that way, but I am not sure how it got that way in the first place, or how to make sure it doesn't happen unintentionally again without disabling the session option.


simplesamlphp_auth installation fails on Centos 8-server

Sorry for the trouble. The problem was caused because I had somewhere in the past installed those modules to this (test) site of my own and forgotten it totally. After removing the old simplesamlphp_auth things seemed to go OK.


Add more fieldset with remove option custom module

I got solution by this way. Here is solution code:

$form['emails'] = array(
    '#title' => 'Education Information',
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    //'#size' => '30',
    '#required' => FALSE,
    '#prefix' => '
',
    '#suffix' => '
',
);
if (empty($form_state['num_names'])) {
    $form_state['num_names'] = 1;
}
for ($i = 0; $i < $form_state['num_names']; $i++) {
$form['emails'][$i]['candidate_email'] = array(
    '#title' => 'Email',
    '#type' => 'textfield',
    '#size' => '30',
    '#required' => FALSE,
);
}

$form['emails']['add_name'] = array(
'#type' => 'submit',
'#value' => t('Add one more'),
'#submit' => array('hook_add_more_add_one'),
// See the examples in ajax_example.module for more details on the
// properties of #ajax.
'#ajax' => array(
  'callback' => 'hook_add_more_callback',
  'wrapper' => 'names-fieldset-wrapper',
),
);

if ($form_state['num_names'] > 1) {
$form['emails']['remove_name'] = array(
  '#type' => 'submit',
  '#value' => t('Remove one'),
  '#submit' => array('hook_add_more_remove_one'),
  '#ajax' => array(
    'callback' => 'hook_add_more_callback',
    'wrapper' => 'names-fieldset-wrapper',
  ),
);
}


Text format field missing for minimal installation

Look in the standard profile:

core/profiles/standard/config/install

In comparision the minimal is rather empty:

core/profiles/minimal/config/install

You can take this yml-file for the text format, put it in the sync-folder and import it:

core/profiles/standard/config/install/filter.format.full_html.yml

But probably you need much more configuration, did you consider to start over with the standard profile?


Render page callback output in another region than "content"

Instead of defining a page via hook_menu it is better to define a block that you can place everywhere across the site.

Is there any requirement that restricts you to using a page?

If not the following code creates a block:

/**
* Implements hook_block_info().
*/
function YOUR_MODULE_block_info() {
  $blocks = array();
  $blocks['YOUR_BLOCK_ABC'] = array(
    'info' => t('YOUR BLOCK NAME'),
  );
  return $blocks;
}

/**
* Implements hook_block_view().
*/
function YOUR_MODULE_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'YOUR_BLOCK_ABC':
      $block['subject'] = '';
      $block['content'] = _YOUR_MODULE_BLOCK_ABC_CONTENT();
      break;
  }
  return $block;
}

function _YOUR_MODULE_BLOCK_ABC_CONTENT() {
  // This is where you code you use for the page goes.
  return t('Hello world');
}

Code from http://kahthong.com/2013/06/create-your-own-custom-drupal-block-programmatically

You can restrict the block visibility in the block settings to only be shown on single pages. Maybe this might solve the problem. To access arguments from the current page you can use the arg function.

Cheers
j


Can't connect to remote DigitalOcean database

I was able to resolve this from the info found here:

https://skoop.dev/blog/2019/10/04/PHP-and-the-DigitalOcean-MySQL-cluster/

The problem stemmed from the default authentication method for MySQL v8 is caching_sha2_password, which the article above suggests is not supported by php yet.

As the article suggests, we can switch back to the old authentication method with the following query:

ALTER USER 'myuser'@'%' IDENTIFIED WITH mysql_native_password BY 'thepasswordyouwant';

After making this alteration to the dbuser, I was able to connect to the digitalocean database without issue.


How to compare date from table with variable using db_query?

You are going to need to insure that the format of your $date variable is formatted exactly the same as the format of the date value in your database (field_date_value). For example, if your database is storing its date values in unixtime, then your $date variable needs to be unixtime. If your field_date_value field is storing mm:dd:yy hh:mm:ss, then your $date variable needs to reflect this same format accordingly. Refer to date() to formate your $date variable the appropriate way.

Once you've formatted your $date variable to the same formate of your sql data, you can run a condition method like this:

->condition("tablename.field_date_value", $date, ">=")

This will query for everything equal to or greater than the specified $date value.


Fatal error: Call to undefined function wincache_ucache_get()

I would assume that this is cache related. Try clearing your cache directly on the database by truncating the cache_* tables (since Drush is not working).

You cannot delete modules by removing them from in your modules folder. You have to disable/uninstall the module first, if you cannot disable the module through Drush or UI you can edit the system table by searching the column 'name' for your module and setting the column 'status' to 0. After that clear your cache again.


you can utilize twig's if/else condition:

Find the twig's template file for your custom block using twig debug mode
use twig's if/else syntax (reference)

{% if field_NAME_OF_YOUR_SECOND_FIELD.0 == false %}
    {{ field_NAME_OF_YOUR_FIRST_FIELD.0 }}
{% endif %}

check this for extracting the values of different fields


Is performance affected on local server?

You should be able to set up Drupal on your local machine without an Internet connection, where you can do most of your development work. See this post on Drupal.org for info about setting this up properly. You shouldn't be getting any HTTP errors, I'd check to make sure you don't have any some external images, files or other resources (like feeds) embedded which would require the browser to fetch from www.


How can I filter an index view using REST?

The solution is to add a search filter to the view.

In the view settings, under Filter Criteria, you'll see Content: Published (= Yes) and Content: Content type (= Regions) (or whatever your view is for).

Click add. In that box that shows all the fields you can add, type Search: Search Keywords.
Tick Expose this filter to visitors, to allow them to change it.
(optional) Rename the Filter Identifier from keys to query or terms or whatever you see fit.
Save the view.

You'll then be able to make a GET http://example.com/api/regions/?_format=json&keys=my+search+string!


Customize Login Widget (set Default values in login input fileds)

There are a couple modules for this (quotes included are from their project pages):

In Field Labels:

  ... creates integration with the In-Field Labels jQuery Plugin.

Compact Forms:

  ... presents text fields for selected forms in a more compact fashion using jQuery.

  The form item/element fields are overlaid with their respective labels. When the user focuses a field the label fades away nicely, and if the field is left empty the label fades back in again.

  By default, only the user login block is switched to compact style, but the behavior can be added to any form by adding the corresponding CSS ids to the Compact Forms configuration.

  Degrades back to the original form when JavaScript is switched off.
  Fields like textareas and checkboxes are currently not affected.
  Inspired by A List Apart.


Automatic Login after Successful Registration

Have a look at the Logintoboggan module. This offers you to login new users immediately.


How to use Rules to auto populate field B with the value of field A after saving a new node or updating an existing one?

Here is a rule (in Rules export format) that does exactly what your question is about:

{ "rules_auto_populate_fields" : {
    "LABEL" : "Auto populate fields",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_presave" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "title_field" } },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_tagged_as" } }
    ],
    "DO" : [
      { "data_set" : {
          "data" : [ "node:field-tagged-as" ],
          "value" : "[node:title-field]"
        }
      }
    ]
  }
}

Notice the "entity has field" conditions, for both fields. Those conditions will make the fields available in the Rules Action ... (so that you can reference field A and set the value of field B).

If you have the Rules UI enabled, and if the machine names of your fields are indeed "title_field" (for field A) and "field_tagged_as" (for field B), you should be able to just import this rule in your own site. If you're using other machine names, just adapt the machine names prior to importing this rule (and apply similar changes in the fields mentioned in the Rules Action).


Any Modules to help with price caculator?

if you need an admin interface for this your best bet is to write a small module for it in PHP, not jQuery. Unless you want your "rates table" to be handled by nodes as well..


How to create specific role permissions for authenticated users in Drupal 7

You could have a look at User points module, you also need userpoints_nodelimit, part of User Points Contributed modules to limit the number of nodes a specific user is allowed to create. For the deletion of nodes you'll need the rules modules so you can give the user a point back.

You could write your own implementation, but depending on your skills this might be harder, in short you need to implement:

an access callback where you check the user and the number of available points
use hook_menu_alter to replace the access callback of 'node/add'
implement hook_node_delete and hook_node_isnert to change the counter


How to get an export option as a pdf for views?

Try Views Pdf module

Descriptoin about viewspdf module:

  With this module you can output a view as a PDF document. Each field of the view can be placed on the PDF page directly in the
  administration interface. Therefore a new display called "PDF" is
  added.

  There are already some PDF solutions such as Print. But these solutions use the HTML output and converts this to PDF. The downsides
  of such an integration are:

  No control over page flow (e.g. page break).
  Little or no control over page header and footer.
  You need HTML skills to change the layout.
  The rendering is slow and need a lot of memory, because it needs to render the HTML.
  Complex tables make troubles.
  Vector graphics can not be implemented, therefore the printing of the document can be problematic.
  You are limited by HTML's capabilities.
  No hyphenation.

  You can also specify a background PDF document. This enables you to put unlimited static content to the dynamic PDF. This static PDF
  can be exchanged dynamically by using a File Field. The PDF can be
  created by any PDF creator such as Adobe Acrobat Professional or Open
  Office.


How to refresh new migrations in Drupal 8 migration module?

I found this worked for me

  drush config-import --partial --source=modules/custom/migrate_module/config/install/


Is there a way to stop comment_node_view from firing?

You can implement hook_module_implements_alter() and stop the hook being run for the comment module:

function MYMODULE_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'node_view') {
    unset($implementations['comment']);
  }
}

Once you clear the cache comment_node_view() won't be called any more.


It basically means that when you include the view as block on a node page, it will get the term id from the page's taxonomy terms (magically) even though the term id is not really on the page's URL path.

I agree that the description for that option is really confusing.


After wrong submit redirects to wrong url

You can do this by using below ways :

Using Rules module.

  The Rules module allows site administrators to define conditionally
  executed actions based on occurring events.

Using Webform Rules module.

  This module adds rules integration on webforms.


Get the value of a field of the taxonomy term referenced with an Entity Reference field

The user is already associated with the boolean field via the taxonomy term.

For example, load your user's account:

global $user;
$account = user_load($user->uid);

Now load your taxonomy term:

$partner = taxonomy_term_load($account->taxonomy_field_name[LANGUAGE_NONE][0]['tid']);

And then get the boolean value of field_1:

$boolean_value = $partner->field_1[LANGUAGE_NONE][0]['value'];


How can I insert a block into each page of a view if the page is loaded via ajax?

You want to add a javascript such one below to either your custom module or theme (would recommend module). This will react on a view that has a class view-infinitestack, so replace it to match yours view.

Where the debugging code is (console.log) you can add whatever JQuery you need. Eg. ajax call to fetch new content and inject it in another div, sidebar, or anywhere else on the page just by using JQuery, etc...

(function($) {
  Drupal.behaviors.events = {
    attach: function(context, settings) {
      $('.view-infinitestack', context).ajaxSuccess(function(){
        // add your js here to refresh a block
        console.log('success');
      });
    }
  };
})(jQuery);


No visible files in DIR (site/default/files) throught the IMCE

Filefield sources applies a filter to the file list. It won't list files that can not be used in file field.

https://drupal.org/node/1099994

If you are using File Field sources that's your problem.


caching views based on arguments as taxonomy term id

http://drupal.org/project/cache_actions might help you out.

Cache actions provides rules actions for clearing drupal caches.

It currently provides actions for:

  Clearing Drupal cache bins
  Clearing CSS/JS cache
  Clearing The cache of specific views
  Clearing The cache of specific panel pages
  Clearing The cache of specific mini panels


What is the difference in State API and Config API?

Configuration is a place to store information that you want to synchronize from development to production. This information is often created during site building and is not typically generated by regular users during normal site operation.

You should use the State API, not Configuration API, for storing local variables that shouldn't travel between instances.

The State API provides a place for developers to store information about the system's state.

State information differs from configuration in the following ways:

It is specific to an individual environment.
You will never deploy to deploy it between environments.
You can reset a system, losing all state. Its configuration remains.

Hope that helps.

Thank you :)


How to make a form that captures a value from $_REQUEST[]

The answer was to use #default_value instead of #value.

http://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/6#default_value


Converting a timestamp to PHP date format for a field in a node template

As already pointed out by  Mohammed Shameem:

<?php print gmdate("m-d-Y", $node->field_event_image['und'][0]['timestamp']) ?>

However, the Drupal way would be:

<?php print format_date($node->field_event_image['und'][0]['timestamp'], 'short'); ?>

The latter construct will render the date in the standard short date format set up for the site.  The former will use the format you pick.  The Drupal way ensures that the date format is standardized throughout the site.