Drupal 7 connection to MS SQLServer/PostgreSQL

Can MySQL handle this amount of data?

Yes, MySQL can theoretically handle many millions of rows (see How many rows in a database are TOO MANY?).

What actually matter are your server resources, configuration, and indexes. If you're not sure about the first two, consult with a professional dba who will be able to help you fine tune your settings for both Drupal, and, more importantly, the specific usage of your app.

Drupal core tables are heavily indexed (as are many tables provided by contrib modules), so it'll probably come down to the custom/contrib modules you have installed from that respect.

  if not Can Drupal 7 connect to MSSQL Server and work with it as good as it works with MySQL? what about PostgreSQL?

Yes, Drupal can use both MSSQL and PostgreSQL. How well any of those perform will entirely depend on the same things mentioned above. I doubt you'd see massive differences in any of them, unless your app is used in a particular way that one or another is better suited for (but the only way to work that out is by benchmarking).


Can I use taxonomy term as relationship in view?

You can create a view of jobs:

with a taxonomy term relationship on your field_company_name in order to show the taxonomy term name and any other fields it might have.

In order to show the email of user that is referenced from the taxonomy term you will also need a relationship (via the field_company_name relationship) on user so that you can access the user fields (eg email). The option to add this relationship will now be available from the relationships list, if you filter by user.

Sidenote: You may want to consider using an additional email address on the user for this in case the user does not want to receive job applications at their own personal email address, but wants to use their personal email address to manage the account.


How to disallow users with a username containing test to login?

Custom username validation would be an option

  allows to define a validation pattern for the username on registration. it's also possible to customize the error message on validation failure.


How to hide Authoring information,Revision information,Publishing options tabs in create/edit node for any content type

I usually do this with a custom module and drupal's Form API and setting #access = FALSE for form elements I want to hide (and test it with 3rd party modules to assure it doesnt break anything).

Recently, I've been made aware of Override Node Options which does exactly this for Drupal 7/6.


Specific Content Access only after successfull checkout

You can actually accomplish this with no code using the Entity Reference, Content Access, and Access Control List modules. I just implemented this for a client! I added an entity reference field to my product type that I used to point to the node the customer should be granted access to upon successful purchase of that product. I then added a rule when an order is first paid in full that grants access through the access control list to the referenced node.

The trick is to configure your node type used for the premium content so that those nodes are only visible to administrators and then depend on the access control list to grant access to users on an individual basis. One advantage of this, too, is that you could create an "all you can eat" subscription using a user role that may also have access to view any content of that type if you wanted to.

To show a list of content the user has access to on their profile, you can simply create a list of nodes of the specified type, and Views's automatic inclusion of access control on node queries should ensure users only see the nodes in the list they have access to.


I'm using the module Twig Tweak, so you don't have to create a block, but you can add in in your twig file.

In my views-view--view-id--page.html.twig file I use it like this:

<div>
 {{ drupal_block('facet_block:facet_id') }}
</div>

Where the facet_id is the machine name of my facet.


Prevent loading certain script set in .info file in Drupal 6

I do not think there's a way to really un-set scripts once they've been added, in D6.  D7 provides hook_js_alter, but not D6.

Do you have control over the theme? Your best bet would be to remove the scripts from the .info file and only add them as needed by calling drupal_add_js().  Which hooks or preprocessors you need to use to make those calls to drupal_add_js() will be something determined by the purpose of the scripts themselves.  But you'll want them added before template_preprocess_page() is called since that's where the $scripts variable is generated.


How can I require multi-user approval for a node?

Maybe write your own module

#1 push message for each team member

#2 for each member approval check if this it's all, if yes then push invite to new member/user

#2b if new member accept invite then add her/him to the group (you can do it with og API e.g.)

#3 if someone from group disapprove then remove invite from awaiting list

#x you can add some settings page so e.g. if 50% of team members agree with invitation then proceed to #2 and invite new user


How to limit access to content to only users with the same role as the content author?

Option 1 - Group module

You could, for sure, use the Group module for this. Group allows for creating arbitrary collections of your content and users on your site, and grant access control permissions on those collections. It is available as of D7, and has a D8 version also. The Group module creates groups as entities, making them fully fieldable, extensible and exportable.

For more details about the various roles and permissions, refer to my answer to "What are the various roles supported by the Group module?".

Resources

Community documentation for the Group module.
Video tutorial "How to use the Group module in Drupal 8 to manage editorial access control to different areas of a web site".

Option 2 - Possible alternatives

Refer to my answer to "Recommended modules for managing Content access?" for some other modules that you might want to consider as a possible alternative. Even though it's not part of your question (today), I don't think any of them have a D8 version already.


How do I get an instance of AccountInterface in my Unit Test

You most likely want to mock your dependencies rather than trying to instantiate actual objects because a unit test should only test the class it describes. However this is not always as convenient.

In this case you are trying to call the \Drupal::currentUser static method which is dependent on the dependency injection container. An empty container can be created and used for the test, and test doubles available for it.

protected function setUp() {
  // use Drupal\Core\DependencyInjection\ContainerBuilder;
  $container = new ContainerBuilder();
  $account = $this->prophesize('Drupal\Core\Session\AccountProxyInterface');
  $container->set('current_user', $account->reveal());
  \Drupal::setContainer($container);
  $this->user = \Drupal::currentUser();
}

However you do not actually need the container, and can just use the test double.

public function testResult() {
  $accountProphecy = $this->prophesize('\Drupal\Core\Session\AccountProxyInterface');
  // Mock some methods.
  // $accountProphecy->getUserName()->willReturn('admin');
  $MyModuleQuery = new MyModuleQuery(1, $accountProphecy->reveal());
}


How to hook_views_query_alter arbitrary field and use it in view GUI

You could add a normal number field to the user profile in the drupal ui, then translate the rogue column into this normal drupal field by populating the field from the table column with an SQL query (or several queries via a looped php script) on your database.

This would mean that the field would become available in the normal drupal way within views, and would also avoid you having these sorts of issues on another occasion.

I am sure it does not need to be said, but obviously you would backup first and perform this operation in a local development to test.

Note: It should even be possible to export the numeric value against uid and use feeds to bring the value into a profile2 field using the uid as unique, if that felt more comfortable than the naked sql population.


How to send an email to an author on a specific date using date field specified in a node?

You might use the Rules Scheduler module (included with Rules) for this. The following tutorial explains a case similar to yours: http://www.webwash.net/tutorials/how-send-follow-emails-using-rules-scheduler-drupal-7

In short, you would need to:

create a "send email" component that sends an email with a user as
parameter
create a rule triggered when a node of your content type is
modified
set the action for that rule to an "scheduled component
evaluation" that uses the "send email" component you created.
in the "scheduled evaluation date" of the action you need to press the "switch to data selection" button, and then to select the date field of your node from the dropdown menu.

Note that the scheduled component evaluation is triggered by cron. You need to make sure that cron is configured correctly in your site.

Hope that helps,


Custom Pricing based on anonymous customer input

User has role can indeed be used to setup a rule for Anomymous user, see the image:


performant way to load many complete node-objects

node_load() is the preferable way to load a node object, especially if the node object is passed to some functions.
Take in mind that, in Drupal 6 the result of node_load() is locally cached in a static variable by default; if you are going to load a bunch of nodes, it is better if you call the function as node_load($id, NULL, TRUE). If you are sure that, for some reasons, the code could load the same node in consecutive calls to node_load(), then you can consider resetting the static value after X calls to node_load().
The result of node_load() is not cached, if the $revision parameter passed to the function is not NULL.

Caching the value obtained from node_load() is possible, and your code could use its own cache for that purpose. The cache should be invalidated when nodes are updated, which includes also the case when a node is reverted to a previous revision.
Rather than implementing a cache in your own module, it would be better to use a module that caches the nodes for third-party modules.

In Drupal 7, both node_load() and node_load_multiple() accept a $reset parameter that resets the node cache kept as instance variable from the object of class NodeController that is created from Drupal, which uses the instance variable implemented by DrupalDefaultEntityController, the class that implements the default methods necessary for an entity controller.


Trying to fix errores with the admin_menu module

Admin menu hasn't had any development effort for comfortably more than 2 years now. It doesn't have a Drupal 8 release to speak of; the chances of getting the module working without major surgery to the code are pretty slim.

If you can get the module successfully uninstalled by commenting out some code, then definitely do it (then probably delete the module folder so you don't accidentally enable it again).

The Admin Toolbar module is its successor. It integrates with the core toolbar, and has a sub-module which provides the tools menu that you'll be familiar with from Drupal 7 (with clear cache links etc).


Unable to show form using controller (module)

You need define new function theme bive_page_theme before call it. You can see docs and example. In your case, you can write more code in file .module

/**
 * Implements hook_theme().
 */
function Your_Module_theme($existing, $type, $theme, $path) {
    return [
        'bive_page_theme' => [
            'variables' => [
              'form' => NULL,
            ],
            'path' => $path . '/templates',
        ]
    ];
}

and create file bive_page_theme.html.twig in folder templates of module. Clear cache and go to page.


Views relationship between user and custom created entity

Ok ! finally found out !

I had to use the hook_views_data_alter to put the relationship on the user :

/**
 * Implements hook_views_data_alter().
 */
function MYMODULE_views_data_alter(array &$data) {
  $data['users_field_data']['cards'] = [
    'title' => t("Users cards"),
    'help' => t("Link the users to their cards"),
    'relationship' => [
      'group' => t('Cards'),
      'label' => t("User cards"),
      'base' => 'cards', // database table
      'base field' => 'owner', //database field to join on
      'relationship field' => 'uid',
      'id' => 'cards',
    ],
  ];
}


You need to use search_data().

  Perform a standard search on the given keys, and return the formatted results.


Feeds mapping to Entity ref by Entity ID not working

Might be important: Are the product displays (the albums) already in the site or are you importing those as well?

Entity IDs are generic unique identification numbers that entities use to reference each other. Nodes are a certain kind of entity and their id is "Node ID" but you are looking for the Product ID, which, Kickstart 2 does a really good job of hiding from the site builder. Try going to admin/commerce/products/variations to see all your products and when you click edit on one, the number in the url is your entity id for that product.

So, when you create an album with mp3s, the structure looks like this:

Album (node id: 123)
  |__ commerce_product (field), Value: 23,24,25

MP3-1 (product id: 23)
MP3-2 (product id: 24)
MP3-3 (product id: 25)

All of the "id"s are entity ids.

Regardless, you can use the entity field query finder function of the feeds_tamper module to locate an entity reference while importing a CSV using Feeds.


How do I move content from one field to another?

Let's consider that your content type is article and existing field is field_old and new field is field_new. Then you can use the script at once to copy all the data from old field to new field.

$article_nodes = node_load_multiple(array(), array('type' => 'article'));
foreach ($article_nodes as $article_node) {
  $article_node->field_new = $article_node->field_old;
  field_attach_update('node', $article_node);
}

Am not sure, if this is what you are looking for.


You can implement hook_preprocess_field() and add the class there.

Get field type :

$element = $variables['element'];
$type = $element['#field_type'];

Add something to field class :

$variables['classes_array'][] = 'class-name';


Is there a way to show a message to specific users?

Copy the following snippet to your module, then you have to replace MODULE with your module machine name

/**
 * Implements hook_preprocess_HOOK().
 */
function MODULE_preprocess_page(&$variables) {
  $message = t("You have been served!");
        $request = \Drupal::request();
  $session = $request->getSession();
  $message_was_displayed = $session->get('mymodule_message_was_displayed', FALSE);
  if ($message_was_displayed === FALSE) {
    $messenger = \Drupal::messenger();
    $messenger->addMessage($message);
    $session->set('mymodule_message_was_displayed', TRUE);
  }
}


Add the image field twice(!) to the fields list. Use the frame style on the first image and the no-frame style on the second. Exclude both fields from display and place them before the checkbox.

Next, rewrite the output of the checkbox field to use [field_image] if the checkbox is checked (normal rewrite) and [field_image_1] if it is not (no result behaviour, Treat 0 as empty).


Panelizer page manager variants not selected

I found a workaround.
In the site_template variants i made a selection rule on the node type. Problem was, that i have pages that arent nodes, just simple pages. I cloned the Variants and removed the selection rule. Then i choosed this site_template in de pages.

Now i've got a lot of site_template variants wich is not so nice, but it works.


field output dependend on mime type of another field

This can be done with a template preprocess added to the template.php file in your theme. You would need to test for the video mime type on the correct node and then use Drupal's hide function, to tell Drupal to skip the field on render.

    /**
     * Override or insert variables into the node templates.
     *
     * @param $variables
     *   An array of variables to pass to the theme template.
     * @param $hook
     *   The name of the template being rendered ("node" in this case.)
     */
    function THEMENAME_preprocess_node(&$variables, $hook) {
      $type = $variables['type'];

      switch ($type) {

          case 'NODE_TYPE_MACHINE_NAME':

            if (isset($variables['FILE_FIELD_MACHINE_NAME'][0])) {
              $mime_type = $variables['FILE_FIELD_MACHINE_NAME'][0]['filemime'];
              $mime_regex = '/^video/';
              // We have to check the string for the presence of "video", because it could be any of 18 video mime types.
              $is_video = preg_match($mime_regex, $mime_type);

              if ($is_video) {
                hide($variables['content']['IMAGE_FIELD_MACHINE_NAME']);
              }

            }
          break;
      }
    }


The "global" header and "global" footer built in Drupal Views isn't treated as a separate translatable entity like a node is.

One recommended approach (that will also avoid giving content managers access to edit views) is to setup a single custom content type for view headers and footers and then with the Entity API module enabled, set/embed an entity reference to the specific node in the view header (and/or footer). A breakdown of steps for this approach is below:

Make sure your site has the Entity API module installed and enabled.
Create a custom content type (it can be just a body field and title.  NOTE:  the title will render in the embedded entity in the view, so you may want to utilize it for the view page title/H1 in lieu of the specific "title" field on the specific display of the view. Otherwise you can preprocess the node type to exclude the title or use css to hide it.
Enable internationalization/translations for the new content type.
Create a node for each specific view header or view footer where you need manageable/translatable content, noting the node ID upon save.
Export a backup of the views impacted.
Edit the desired views; be sure to be editing the specific "view display" that applies to your block or page.  In the "Header" or "Footer" section of the view edit/config page (where you currently have a global textarea), click "ADD".
In the modal, make sure the selector in the top left corner is set to apply changes to "This Page"/"This Block"/etc and not "All Displays".  Select Entity: Rendered Entity and click Apply (this display).
Input the node ID and choose the desired display mode (full node should suffice as outlined, unless you need a custom display mode setup on the node/content type).
Remove the Global Text object in the View Header or View Footer.  After applying this change (and assuming you have no other custom objects in the view header or footer), you should only see the referenced entity in the View Header or View Footer section.
Save and test the page where the view appears.
If you decide to revert, import the backed up copy of the view as Admin1 to restore it.


print data to twig file from custom form submit via controller

When you set rebuild in a form submit there is no controller involved. The next page displayed is the rebuilt form, where you can print the my_report twig template by adding it to the build array $form.

You don't need to transfer the values in $form_state, because they are available while rebuilding the form. You can check in the form build function whether these values are present. If not, you are building a new form. If they are, this is a form rebuild, then display the result template:

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

    // build form

    if ($form_state->hasValue('role')) {
      $form['my_report'] = [
        '#theme' => 'my_report',
        '#role' => $form_state->getValue('role'),
      ];
    }
    return $form;
  }


Conditional fields for the field type 'managed_file' is not working in Drupal 8

I don't know, if this as anything to do with managed files, but I think #options should look like this:

'#options' => array(
  'text' => t('Enter The Text'),
  'upload' => t('Upload a Text File'),
),

and in #states the options key, not the translatable value:

'#states' => array(
  'visible' => array(
    ':input[name="field_type"]' => array('value' => 'text'),
  ),
),

If it has something to do with managed_file, then this old issue is back:

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

You can check this by changing temporarily managed_file to file.


Translation issues-How can we set admin in default English language in multilingual site

Try setting your language detection to be "user preference" first.  That way your account setting will override any other detection.


Page Manager and Panels settings — where do they live?

This ended up requiring API calls, since Panels and Page Manager definitions can live in code or in the database.

First I got the tasks with page_manager_get_tasks().

This gave me a list of tasks, which appear to be high-level Page Manager stuff. My Workbench, Node add/edit form, Node template, User template, User edit form, and Custom Page were the tasks.

Custom Page had subtasks that included all my custom pages, so I did page_manager_get_task_subtasks() on each tasks that had subtasks, and then page_manager_load_task_handlers() on each subtask. Within the handlers, there is information about the Panels and other objects that go on that page.


File entity doesn't currently integrate with Pathauto but integration is being worked on in Add support for Pathauto.

Please help test the latest patch and provide feedback including if it works correctly and any issues you might have found!


It's very rare to need to use the Drupal API outside of a hook/callback function.

That's what's causing the problem in this case - your module file is simply being included before that of the libraries module, so the interpreter doesn't know what libraries_load() is yet.

I'd recommend moving your code into an appropriate function that gets invoked when Drupal is properly bootstrapped, and all enabled modules are loaded.

Failing that, you might get some joy out of tweaking the weight field in the system table for the modules in question. If your module has a higher weight than Libraries, you might be able to get it working. But moving the code to a more reliable place would arguably be better.


I was thinking that would be a great idea, until I remembered that Drupal contributors have already offered quite a few solutions for this as demonstrated by a quick search of the Drupal site. Of course, Flag module provides a great abstract way of creating these types of systems. There's also Favorites and Add to favorites, but those are for Drupal 6 only right now. I would recommend Flag I think just because I've used it for precisely this type of thing as have many others (even though it's still in beta), and quicksketch and fago are great Drupal developers.


The default mail implementation in Drupal does not support attachments.

You will need one of the contrib mail modules which support attachments, for example http://drupal.org/project/mailmime. I wasn't able to find any useful docs and it seems that the maintainer is aware of it and hopefully working on something.


Your form_set_error like that

form_set_error('field_address][postal_code', t('enter postal code'.));


A line feed gets added in the "Let's Encrypt Challenge"

Turns out the module works like a charm, the problem was theme related, sending out a blank line at the top of the page: this was enough to confuse Let's Encrypt when running the validation of the site.


Use Drush commands instead like

Drush urol command

Or update existing role with the proper permission to access your backend admin

Drush add permistion command


Render view array programatically within template

There are a few steps involved with applying a template to view. But thankfully they are all fairly simple.

I found one of the most helpful tutorials was this one, which goes through the process. I think this process should give you sufficient control over the theme for each field.

I'm not sure why you might be getting the 'previously declared' errors though.


You must activate the module Taxonomy translation (i18n_taxonomy) then go to admin/structure/taxonomy/YOUR_TAXONOMY_NAME/edit and select:

Translate. Different terms will be allowed for each language and they can be translated.

Add a term and select the language and click the button Save and translate in the next page click the link add translation and create the translation.

Then create a node with this term that you hace create and you will have this functionality in your site.


How to change layout of node add/edit form with Display Suite?

That is possible yes. Display Suite contains a submodule called 'Display Suite Forms' which allows you then to select a layout and move the fields around in that layout.

Note that it's impossible though to move the individual elements in the vertical tabs. That will always remain the same and will rendered at the bottom of the layout.


Why is my Cache Expire "0" even when I set it to be time() + 3600?

Worked using cache_set('custom_data', $navigation, 'cache', $expire);


Go to Configuration > Site Information. Under the Front Page section, change FRONT PAGE to include your node information - meaning set the path you want to show as front page and then click save. see the below screenshot.

If you made the above settings then it will show the new front page without summary.


Show node in overlay using drupal 7 overlay module

The faster way is to implement hook_admin_paths_alter() in a module to redefine which of the menu items defined in hook_menu() by other modules are administrative paths.
The value returned from the implementations of hook_admin_paths(), which are then altered from the implementations of hook_admin_paths_alter(), are used from the Overlay module to decide which pages are rendered as overlay. As other modules could use the same information to render the pages using a different theme, the module should require the Overlay module as dependency, to be sure the additional pages are effectively rendered as overlay.

function mymodule_admin_paths_alter(&$paths) {
  $paths['node/*/view'] = TRUE;
}

If you notice that this implementation doesn't work when the users are viewing, for example,example.com/node/1, but only when they are viewing example.com/node/1/view, then I would implement the hook using the following code. The first implementation I provided should work, as the "View" tab is the default one, and when users are viewing example.com/node/1, Drupal is really showing example.com/node/1/view.

function mymodule_admin_paths_alter(&$paths) {
  $paths['node/*'] = TRUE;
  $paths['node/*/view'] = TRUE;
}

As the first line could catch all the node pages (I didn't verify that), I would verify if there are other pages under that path that should not be rendered; in that case the implementation can be changed as the following one ("node/*/backlinks" is only an example):

function mymodule_admin_paths_alter(&$paths) {
  $paths['node/*'] = TRUE;
  $paths['node/*/view'] = TRUE;
  $paths['node/*/backlinks'] = FALSE;
}

Normally, modules implement hook_admin_paths() to report which of their menu items are administrative pages; this means that if a page is not an administrative page, an entry for that page is not added to the returned array.
hook_admin_paths() is implemented for the menu items defined in your own module; to redefine when menu items defined from other modules are administrative pages, you need to implement hook_admin_paths_alter().
To the pages that are defined as administrative pages is not automatically applied an access control; this means that the module defining those menu items that are reported to be administrative pages still need to use "access callback" and "access arguments" to define which users can access those menu items associated with administrative pages. Pages defined as administrative pages are only rendered differently, if there is a module that does that.
The node module defines the node editing pages as administrative page only when a checkbox in an administrative page is selected; those pages are already handled.


Can I have multiple nested forms within the same fieldset?

You can have both buttons in the same form. Inside the form's #submit handler (or each button's separate #submit handler), based on which button has been used to submit the form, you can either save the data, or do a drupal_http_request() to execute the external script.

Your form would include buttons roughly like this:

'save' => array(
  '#type' => 'submit',
  '#value' => t('Save'),
  '#submit' => array('save_function_name'),
),
'process' => array(
  '#type' => 'submit,
  '#value' => t('Process'),
  '#submit' => array('process_function_name'),
)

Then, the two functions save_function_name() and process_function_name() would do the job.


You can export all the nodes of content type "Inmuebles" with the drush command

drush -u 1 ne-export --type=inmuebles

Then maybe try deleting the content type and creating it again.

Although it doesnt make sense for a content type to just get corrupt, maybe if you check your error reports or apache log you will get a better look.


Digit 2 Appended to Field Name on Column in Entity Field Query

If you use Email module, use email instead of value, because the module store the value in field_name_email not field_name_value like other field like text ...
So you Query should be like:

$dup_query1 = new EntityFieldQuery();
$dup_query1->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'fair_participant')
    ->fieldCondition('field_last_name', 'value', $last_name , '=')
    ->fieldCondition('field_first_name', 'value', $first_name , '=')
    // use email not value.
    ->fieldCondition('field_email', 'email', $email , '=');

$fpmatch_fandl_email = $dup_query1->execute();


How can I insert a variable from a preprocess function in template.php to Block Body in admin

You can't do that.

The block content doesn't ahve access to variables you add in the block preprocess function.
The block preprocess function code runs after the block content has been generated.

Since you have a PHP block just add that code from your preprocess function directly to it.

So put this at the top of your block content:

$theme_url = base_path() . drupal_get_path('theme', variable_get('theme_default', NULL));


@rakibtg, To change the comment button text you are not supposed to change any comment module which is available in the core. Simply Never hack Core!!!

For your question, to change the comment button text,

1.You need to write up a custom module with hook_form_alter,

  function mymodule_form_comment_form_alter(&$form, &$form_state, $form_id) {
     $form['actions']['submit']['#value'] => t('Post Comments');
 }


How do I add a class to HTML bookmarks generated by core?

Those anchors are added in comment_view(). To override them you'll need to implement hook_comment_view_alter() and reproduce a bit of the logic from the original view function:

function MYMODULE_comment_view_alter(&$build) {
  $comment = $build['#comment'];
  $node = $build['#node'];

  if (empty($comment->in_preview)) {
    $prefix = '';
    $is_threaded = isset($comment->divs) && variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED) == COMMENT_MODE_THREADED;

    // Add 'new' anchor if needed.
    if (!empty($comment->first_new)) {
      $prefix .= "\n";
    }

    // Add indentation div or close open divs as needed.
    if ($is_threaded) {
      $prefix .= $comment->divs <= 0 ? str_repeat('
', abs($comment->divs)) : "\n" . '
';
    }

    // Add anchor for each comment.
    $prefix .= "cid\" class=\"bookmark\">\n";
    $build['#prefix'] = $prefix;
  }
}


Attach js to the module using libraries with inline property

drupal_add_js() has been deprecated, and you cannot use it anymore.

Pass the inline variables with the #attached property as :

$var[$delta]['#attached']['drupalSettings']['yourmodule']['example'] = $example;

And then access the example variable in the JS file as

drupalSettings.yourmodule.example

Note: I have not tried this code, but I think it should work.


Get node ID for all results for current view including its filters, disregarding the pager

I ran into this problem on a recent project.  I decided against a EntityFieldQuery or db_query()/db_select() solution for four reasons.

Views can do some really weird things when it builds a query.  For example, in some instances when you add a sort, the sort key will be added to the returned field list.  This can alter what gets returned when you enable aggregation, reduce duplicates, etc.
Views tends to use LEFT JOIN instead of INNER JOIN.  You can do this with db_query() and db_select(), but not EntityFieldQuery.
SQL can be unpredictable with the undefined ordering between having a LIMIT or not.  For example, if you are sorting by titles and have duplicates, I have seen different results orders.  This mans you may need to be really explicit with sorts, if order is important (I was implementing prev/next through a result set, so it was).
I really don't like implementing things in code when I know a non-coder may want to adjust the View.

So, I ended up using this:

$all = views_get_view('my_view');

$all->display['default']->display_options['pager'] = array(
  'type' => 'none',
  'options' => array(
    'offset' => 0,
  ),
);

$all->set_display('my_display');

$all->display[$all->current_display]->display_options['pager'] = array(
  'type' => 'none',
  'options' => array(
    'offset' => 0,
  ),
);

$all->pre_execute();
$all->execute();

$nids = array();

foreach ($all->result as $result) {
  $nids[] = (int) $result->nid;
}

This will

Manually instantiate the view.
Reset the pager on the master to show all results starting from 0.
Set the display to whatever I am using.
Reset that pager, too.
Execute the view
Loop through the results for what I need.


How to have Drush make automatically find libraries download path?

As Molot states, there's no way for drush to know about any arbitrary library; you need to know the source URL to give it.

For any custom module project, you can use git or file download type to retrieve it from a git repo or an HTTP source.

projects[example][type] = "module"
projects[example][subdir] = "custom"
projects[example][download][type] = "git"
projects[example][download][url] = "git://github.com/jane_doe/example.git"
projects[example][branch] = "dev"

projects[example][type] = "module"
projects[example][download][type] = "file"
projects[example][download][url] = "http://example.com/example.tgz"
projects[example][subdir] = "custom"

The same for libraries

libraries[ckeditor][download][type]= "get"
libraries[ckeditor][download][url] = "http://download.cksource.com/CKEditor/CKEditor/CKEditor%203.4/ckeditor_3.4.zip"
libraries[ckeditor][directory_name] = "ckeditor"
libraries[ckeditor][destination] = "libraries"

Lastly, for local files you can use the file:// protocol in the url property to source the file from the local machine. See the Drush makefile docs for more information.


Try to add in different views to a single page, keep getting "Error" message?

As the error says the data for some columns is too long. I had the same problem in some where else, so I simply opened the phpmyadmin, found the column and change it's type to something else with more capacity. In my case the type was blob and I changed it to the long blob and it worked.

Try this and I guess it will work


Billing address missing for recurring orders

Some workaround:
  // For unknown reason recurring orders are not getting billing profiles.
  // This method is checking of order has billing profile and if not
  // it finds it's initial order over subscription and copies it's
  // billing profile.
  public static function addMissingBillingAddress (Order $order)
  {
    if ($order->getBillingProfile() == null) {
      $subscriptions = self::collectSubscriptions($order);
      $subscription = array_shift($subscriptions);
      $initialOrder = $subscription->getInitialOrder();
      $billingProfile = $initialOrder->getBillingProfile();
      $order->setBillingProfile($billingProfile);
      $order->save();
      return;
    }
  }

  public static function collectSubscriptions($order) {
    $subscriptions = [];
    foreach ($order->getItems() as $order_item) {
      if ($order_item->get('subscription')->isEmpty()) {
        // A recurring order item without a subscription ID is malformed.
        continue;
      }
      /** @var \Drupal\commerce_recurring\Entity\SubscriptionInterface $subscription */
      $subscription = $order_item->get('subscription')->entity;
      // Guard against deleted subscription entities.
      if ($subscription) {
        $subscriptions[$subscription->id()] = $subscription;
      }
    }
    return $subscriptions;
  }

When I'm processing recurring order I'm checking if billing address is missing and if it does I'm collecting one from initial order (over subscription) and injecting that one.
Of course, I would like to know why it's not added at first place.


How to access Machine name fields in PHP?

Here is a little code snippet that should load the value of field_fname into a variable called $first_name.

global $user;
// Load the user object
$user = user_load($user->uid);

$first_name = $user->field_fname[LANGUAGE_NONE][0]['value'];


Given that db_select is much slower than db_query, why would I want to use it?

There are 5 reasons to use SelectQuery

You are building dynamic queries with a varying number of conditions, joins, fields and so on. See field_read_fields() for an example.
You want to use so called Extenders. Example extenders are PagerDefault (replaces pager_query()) and TableSort (replaces tablesort_sql()). These allow to add additionally functionality to SelectQuery. See also How do you make sortable tables with a pager with data from a custom table?. An example: node_page_default().
You want to allow other modules to alter your queries. Then you can add so called tags and SelectQuery will automatically call a corresponding alter hook for that tag. I'm am heavily relying on this with my Privatemsg module (We already did that in D6 with a custom query builder).
If you want/need to use the node_access system to only show nodes the user is allowed to see. Just add the 'node_access' tag to your $query. This replaces db_rewrite_sql().
SelectQuery has a few features that help to make your code work the same across all supported databases. For example there is SelectQuery::orderRandom(). And if you have a LIKE condition, ->condition('field', $value, 'LIKE') will make sure that it is always a case insensitive comparison. In D6, you had to use LOWER() for that which was much slower. But AFAIK, there aren't more than this two right now.

If none of these reasons apply for a specific case, use db_query().


How to get bundle machine name when viewing the creation form?

Writing your own question is always useful.

I may have a solution, even if you may have something different, so please share.

I have built a Views block with a custom text (my link) as unique field (only show one result, you do not need to repeat the link, of course).

I have added a contextual filter based on content type with a default value provided by url, raw value, third component (node/add/mybundle_name), with case transform in lower case.

My link looks like :

Clone existing

And it works.


I have this error number of times while refreshing or uploading modules.
it seems to be a server error. because some time server does not respond.


I think your best bet would be to use hook_preprocess_region() in a module or theme:

function MYTHEME_preprocess_region(&$vars) {
  // Make sure it's the right region
  if ($vars['region'] == 'sidebar_first') {
    // Get the count of blocks
    $count = count(element_children($vars['elements']));

    // Add the class if necessary
    if ($count > 1) {
      $vars['classes_array'][] = 'some-class';
    }
  }
}


File/image upload via CCK and Nginx + FastCGI

Ok, turns out unbeknownst to me someone had added rules in the .htaccess file pointing image loading to another server, which, of course, did not have the created presets and thumbnails. Gah!

Another gotcha in this was the $base_url variable was set in settings.php to force Drupal to load a from a specific site, regardless of the one requested.

Hopefully this will help someone in the future.


How to choose what tables to skip for drush sql-sync @dev @staging?

Drush sql-sync does not support shared databases that use prefixes.  You might have some luck if you wrote a wrapper script that used drush sqlq 'show tables;' to get a list of available tables, filter them manually by prefix, and then pass them back to sql-sync via the --tables-list option.


Two login forms on a same page (user/login)

Here are some quick thoughts that should help you thinking.

I'm not sure yet if it's the best option (have to think about it for a while and I don't know all your details) but:

Create a new page via custom module, say /login.
Implement hook_page_alter() in the custom module and redirect all requests from /user/login to /login. Simply by:

if (arg(0) == 'user' && arg(1) == 'login') {
  drupal_goto('login');
}

Create an alternate login form through your custom module with different submit handlers etc.
On /login page, create any markup you need and pass the two forms. First form will be the regular drupal login form (you can get it by drupal_get_form('user_login')) and the second one will be the one you created manually. This way you have 2 login forms on the same screen with different submit handlers.

Check out user_login() function in the user.module file. That is the function that creates the login form.

Important: I didn't test this. Check it in and out to make sure there are no conflicts with other modules or workflows.

Hope this makes sense!


How to display the table select query values in the same form in drupal 7?

This is actually very easily done out of the box with form-api, you just have to know how to use it. You have to read up on drupal 7 forms, especially the validate and submit functions/hooks. A quick and dirty example to output form values in submit function (called after function form_*_validate() hook) is shown below.

function form_example_tutorial_7_submit($form, &$form_state) {
  drupal_set_message(t('The form has been submitted. name="@first @last", year of birth=@year_of_birth',
    array('@first' => $form_state['values']['first'], '@last' => $form_state['values']['last'], '@year_of_birth' => $form_state['values']['year_of_birth'])));
}

Of course, you can also show messages like this in the validation step. You would need to change above code to use whatever variables you want shown.

Tons of very helpful form api code examples here.

If videos are more your thing, these explains the basic basics ok.

Cheers!


Ubuntu crontab is not triggering when site is in maintenance mode and also revert to online

When the site is in maintenance mode it makes sense that regular cron tasks are halted. For example email notifications about new content should not be sent if you are working with content in maintenance mode - unless you want users to go to a site down page.

If you manually trigger the cron to run after disabling maintenance mode it should restart the jobs.


Product Reference inside a Product Reference?

I figured this out by using taxonomy terms (categories in commerce kickstart), and then yes, indeed, make a product for each combination. (ive heard bulk product creation can do this, and incase you are dealing with a customer input size (how many inches long do you want it), then check out custom line items and Pricing rules.

Thread on drupal commerce > http://www.drupalcommerce.org/questions/7894/adjust-variation-price-based-next-variation#comment-7566


The best way for creating data output from Drupal is by relying on Services it will give you XML-RPC or REST server which will be capable of outputting data in precisely the way you want.
 I will lay out in steps:

Installing Services module
Creating an endpoint and firring up a server.Here is simple guide how to do that.
To format Service output you will need to create a simple module or rely on contributed modules.

Writing a module may seam bit tricky for a beginner so I suggest using modules like Services Views which will let you add a Service type view page or use Services Entity API or Services SearchAPI.


Letting anonymous users vote in a poll when using Varnish

https://drupal.org/project/pollanon
This lets anonymous users vote in a poll more than once, and here's an article on using ESI to allow parts of your page to remain cached while other parts remain dynamic.

Accepting votes from anonymous users on Drupal polls is complicated when you use caching. By using Edge Side Includes (ESI), you can dynamically load some parts of a Drupal page while caching the rest of it. The addition of the Poll Enhancements module allows multiple anonymous users to vote on polls by using cookies to track who has voted.

Edge Side Includes integration
The ESI module includes two Varnish VCL files (located in the docs directory of the module:

docs/esi_blocks.vcl - custom sub-routines to handle ESI-block integration.
Copy this file to the Varnish config directory, /usr/local/etc/varnish/
docs/default.vcl - example code showing how to include the ESI blocks VCL in your Varnish config. Portions of this should be added to appropriate places your Varnish config file. We'll do it by creating a copy, /usr/local/etc/varnish/default-esi.vcl, that has the portions we want:
include "/usr/local/etc/varnish/esi_blocks.vcl";
sub vcl_recv {
  call esi_block__recv;
}

sub vcl_hash {
  call esi_block__hash;
}

sub vcl_fetch {
  # don't ESI anything with a 3/4 letter extension
  # (e.g. don't try to ESI images, css, etc).
  if (! req.url ~ "\..{3,4}$") {
    esi;
  }

  call esi_block__fetch;
}

Then, edit /usr/local/etc/varnish/drupal.vcl and add a line near the beginning:

include "/usr/local/etc/varnish/default-esi.vcl";
Restart the Varnishcache:

svc -t /service/varnish
With the module enabled in your Drupal site, block configuration pages now have an ESI Settings section with two options: Enable ESI, and a TTL value.

Poll Enhancements
Installing this module allows anonymous users to vote on polls. By using cookies to track who has voted, multiple users who are behind a firewall will be able vote on polls. There's a threshold setting for how many votes from a single IP in a time period. The module also provides a Use AJAH option - I needed to enable this to have the ESI-enabled Poll block work properly.

Configure Varnish to ignore the poll cookie ( pa-[nid] ) by editing the vcl_recv section of /usr/local/etc/varnish/drupal.vcl and inserting a line to remove the cookie:

// Remove pollanon cookies.
set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(pa(.*))=[^;]*", "");
Restart Varnish:

svc -t /service/varnish

Source: http://www.productionmonkeys.net/guides/drupal/performance/pressflow/varnish/varnishing-polls


date in spanish webform component coming out in day month year , need month day year

Posted on behalf of Diana that can't do it due to reputation limits.

Go to /admin/config/regional/date-time/locale/es/edit and change the date format to month first for the long, short and medium dates.


How does Drupal know when to run an update script?

To store/get the version information for a module use the global functions:

drupal_set_installed_schema_version()
drupal_get_installed_schema_version()

For example set a new version for mymodule with drush:

drush ev "drupal_set_installed_schema_version('mymodule', '8123')"

Print the version with drush, in this example for the module comment:

drush ev "var_dump(drupal_get_installed_schema_version('comment'))"

The functions are defined in schema.inc. Here you can see how to access the key_value table through the keyvalue api, if you want to use your own code:

/**
 * Updates the installed version information for a module.
 *
 * @param string $module
 *   A module name.
 * @param string $version
 *   The new schema version.
 */
function drupal_set_installed_schema_version($module, $version) {
  \Drupal::keyValue('system.schema')->set($module, $version);
  // Reset the static cache of module schema versions.
  drupal_get_installed_schema_version(NULL, TRUE);
}


Views filter criteria date field is greater than current date

You should be able to choose the Operator Is greater than or equal to, and the Value type set to offset with value Today:

This will include events happening today. If you want strictly from tomorrow you can choose Is greater than as the Operator.


I was doing the following:

    <csharp>line1
    line2
    line3</csharp>

Those extra 4 spaces in the beginning made Markdown put that in a <pre>, and then geshi still processed the csharp block.  Taking out the spaces in the beginning made it work correctly.


i. If you have drush installed (http://drupal.org/project/drush) — if you don't have it, think about that next time :), open up the console (WIN+R) in Windows or Ctrl+Alt+T in Linux point to your site folder (e.g. cd /www/mydrupalsite/ and type:

 $ drush cc all

from the command line.

ii. Another method is to log into your phpmyadmin select your cache_ tables and flush/empty  them.


Module and functions goes missing intermittently

I may have tracked this down to memcache, though it's such a strange error I can't be sure.  Sometimes a group of nodes we put into cache was over the memcache 1mb default limit.

So instead of caching the nodes, I ran them through the theme layer first and reduced the required caching space by about 80%.

This didn't exhibit on my local host as I don't have memcache installed, rather relying on Drupals database caching.  Running some queries like this helped identify the potential problem:

SELECT cid, LENGTH(data) AS Cache_Size FROM cache ORDER BY Cache_Size;


Drush command needs higher bootstrap level - Pantheon Drush Alias Setup

While sites on Pantheon don't require a settings.php file in order to serve web requests, due to the fact that database credentials are dynamically injected, they will still need a settings.php configuration file present in order to enable the remote execution of Drush commands. With Drush 5 installed locally, there is unexpected behavior with Pantheon aliases run from inside a local Drupal docroot. In addition, the --strict=0 option needs to be appended to most commands when using Drupal 6 on your local dev environment.

Source: Drush error “Could not find a Drupal settings.php file” or missing system information from status


Sanitized text input for EntityMetadataWrapper set()

It turns out that if you just set the value, Drupal will not display your HTML without converting your tags to entities. So the value
Foo bar
 will be displayed literally in Views (and other areas) as &lt;p&gt;Foo bar&lt;/p&gt;.

Rather than attempt to create a sanitized safe_value myself before calling set(), I found that if I passed a format value, Drupal will take care of the sanitization for me with the filter settings defined for that format.

So the correct syntax is:

$quip = array(
  "value"  => $form_state['values']['field_quip']['value'],
  // Change to match the text format of your field.
  "format" => "general"
);
$node_wrapper->field_quip->set($quip);


You should use the colorbox-node instead of colorbox-load First check have you already installed the Colorbox and the Colorbox Node modules.

Then, your link would be similar to the following one.

Als E-Mail versenden


Ubercart refuses to believe it is updated

It sounds like you may have two copies of ubercart in your drupal file system.

Check your database "system" table for the ubercart module path ( filename ).

e.g, raw SQL:

SELECT name, filename FROM system WHERE name LIKE 'uc_%';

Make sure the path matches what you expect.

If on linux, you could also run:

find /var/www/my-site -name 'uc_*' -type d

to list the uc_ folders ( type=directory )


Help with Geocoding and Openlayers missing markers

I have gone through this same problem.

I believe this is happening to you, because you did not set the Openlayers Data Overlay on Views.

And if you did, you did not selected/activated it on your Openlayers preset:

And if you did, you did not map the fields on the openlayers data overlay display settings:


use

function hook_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == "search_block_form") {
    $form['#submit'] = array('custom_search_redirect');
  }
}

function custom_search_redirect($form, &$form_state) {
  $search_data = $form_state['values']['search_block_form'];
  $form_state['redirect'] = "search/my-search".$search_data;
}


Placing the contextual filter in the master view makes sense if every display has it, thus it still can be overridden. If there is only one block display out of X other displays, I would place the contextual filter in that display.

The contextual filter will be available as 'field' in your view and you can use it in the filter-criteria.

Contextual filters are passed via the url (in most cases), no matter if AJAX or not.
Or when using views_embed_view as method-arguments.

For your propose, conditional filters nor relationships will not work.

You could then add the other view display as fields and make them conditional. But this is not really good practice nor performant. (Use also a caching module)

From views_field_view:

  This view handler can accept arguments from fields of the parent view
  using tokens and pass them into the child view for each row. Raw or
  rendered token values can be used, as well as static values.

A ctools tools multi step form wizard is a better approach. here's an example https://github.com/jgottwig/ctools-wizard-example.


Temporary files directory not fully protected .htaccess

Ugh, so I just realized that the directory was /tmp, not tmp. Meaning that directory is at the root of the file system, not at my site's root. I checked at / and low and behold, there is my tmp folder. Now I know where to place this .htaccess file.


Ajax not working inside hook_field_widget_form()

Just assign the value in callback function.

/**
 * Implements hook_field_widget_form().
 */
function test_field_widget_form($form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $form_field['autocomplete'] = array(
    '#type' => 'textfield',
    '#title' => 'Tags',
    '#autocomplete_path' => 'taxonomy/autocomplete' . '/' . $field['field_name'],
    '#size' => $instance['widget']['settings']['size'],
    '#maxlength' => 1024,
    '#element_validate' => array('taxonomy_autocomplete_validate'),
    '#prefix' => '
',
    '#suffix' => '
',
  );

  $form_field['search_tags'] = array(
    '#type' => 'button',
    '#value' => 'Recommend Tags',
    '#ajax' => array(
      'callback' => 'call_ajax_replace_value',
      'wrapper' => 'subscribers-name',
      'method' => 'replace',
    ),
  );
  $element += $form_field;
  return $element;
}

function call_ajax_replace_value($form, &$form_state) {
  if (isset($form_state['values']['autocomplete'])) {
    $form_field['autocomplete']['#value'] = 'new value';
  }
  return $form['field_tags'][LANGUAGE_NONE][0]['autocomplete'];
}


Shopping cart not cleared after checkout

This looks like a permission issue. Check the permissions page admin/people/permissions and make sure only relevant roles can edit orders.

By default, only the following permissions should be granted to authenticated users, and to any customer role you may have created  :

Create Order orders, optionally Create orders of any type
View own Order orders, optionally View own orders of any type

About the items remaining in shopping cart after checkout, have you tested yourself ? I'd more believe your customers edited orders from their orders page if they had permission to... Else, a custom rule or a custom module may cause that behaviour.

As explained in drupalcommerce.org

  At the heart of Drupal Commerce is the ubiquitous Order. This Order is
  first created when a user adds a product to a cart. The Order is
  actually the "cart" when it has a status of "Shopping Cart."

Cart is only one of the possible states of an order.


Try printing $source->id ( even if $source seems empty ). This should return the machine name.
It's what I always use.


Did anyone have success in configuring Mod security?

Using OWASP CRS v3.0.2 (https://github.com/SpiderLabs/owasp-modsecurity-crs/releases/tag/v3.0.2) you should find no major issues here. Drupal has it's own set of exclusions out of the box because it does things that can be considered bad practice (passing tags via parameters, etc). As outlined in the docs you should uncomment rule 900130 and enable the Drupal exceptions. There is even an example of how to do so.

https://github.com/SpiderLabs/owasp-modsecurity-crs/blob/v3.0/master/crs-setup.conf.example#L302

Enjoy!


drupal_http_request() with POST returns a 405 error

In your post request you have specified

'Content-Type' => 'application/x-www-form-urlencoded'

but your post data is in JSON format.

Perhaps you need

'Content-Type' => 'application/json'

alternatively, pass the raw $data array as the post data for key=value&key1=value2 form encoding.

You also need to pass the function parameter $options instead of $data

$request = drupal_http_request($url, $options);


How to disable quickedit for specific block, but keep contextual links

It looks like you can use module https://www.drupal.org/project/block_content_permissions for that. To cite the project page:

Add the following permissions to allow access to edit blocks in-place (on-page):

Use contextual links (Contextual Links module)
Access in-place editing (optional, Quick Edit module)

However, it might not be feasible depending on the number of blocks on you site.


Adding $terms to the byline in node.tpl.php for Drupal 7 and Acquia Prosper & Fusion Framework

If you look at the Drupal 7 documentation for the variables available by default in the node.tpl file, $terms is not on the list: http://api.drupal.org/api/drupal/modules!node!node.tpl.php/7

If you want to display additional variables in your template files (from what's already there by default), you should make sure that these additional variables are actually being set in your template.php file first.

So, go into your theme's directory and find the file called template.php.  Does it have one of the following preprocess functions, in which it adds additional variables for your template file:

THEME-NAME_preprocess_node() or
THEME-NAME_preprocess_node_blog() (assuming your content type's machine name is 'blog')

If either of those exist in your theme's template.php file, look to see if the $terms variable is being set in a statement that should start with

$variables['terms'] = ...

If that is not happening in the template.php file, then the variable is never being set and will be empty.

If your theme's preprocessing isn't somehow prepping that variable for you, however, you can still try printing out your tags this way:

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

Where you can substitute 'field_tags' with any field you have on that node. :-)


Possibility to limit old content that is displayed to a new user

To do this, you probably should implement hook_node_access($node, $op, $account).

You should return:

NODE_ACCESS_ALLOW if content is new, or user have premium role
NODE_ACCESS_DENY if content is old and user does not have premium role
NODE_ACCESS_IGNORE if you do not want to control access for this content type

There are already contributed modules to sell roles, or to take payments, so this part should be easy.

Note that hook's documentation says:

  See Node access rights for a full explanation.

I strongly advise to do it.


Which access control module will allow me to use limit visibility of individual nodes?

BAM!
Taxonomy Access Control to the rescue.
Access control for user roles based on taxonomy categories (vocabulary, terms).

Automatically controls access to nodes (based on their taxonomy
terms).

Configuration page for each user role.
Three node access permission types: View, Update, Delete.
Two term access types: View tag, Add tag.

Just create a term called something like "Members only" and add that term reference to your video content types.


How to Make field required depending on other field?

You can do this with the Conditional Fields module.

It allows you to configure dependencies between fields (visible / required / etc.). It's still a development release, but it should work.


display suite: limit field - determine what bundle values?

It's the machine name. You can think of the bundle as the specific settings for a specific entity. So, DS is asking you for the machine name associated with the individual content type, vocabulary, etc. that you'd like to target.

For example, say you've created node configurations (Structure > Content Types) called "Article," "Store Location," and "Job Openings." If you'd like to make your DS custom code only available in the display settings for "Job Openings," you'd put in...

job_openings|*

...or you could limit it to a specific view mode by specifying which one in place of that wildcard, such as...

job_openings|teaser

Easiest way to find the machine name is to look at the edit url for your entity and/or view mode.


This is due to using Autocomplete functions. Disable autocomplete module and Sure error will be gone.


What are the possible exploits if settings.php is writable?

Option 2 is marginally better, but if you get p0wned, a hack script will chmod the file before it tries to append to it, which pretty much renders permission-based protection useless.

Personally, I would make up shell scripts to take care of the permissions for you.
For deployment, something like

find docroot/ private/ -type d -exec chmod 555 {} \;
find docroot/ private/ -type f -exec chmod 444 {} \;
find sites/default/files/ -type d -exec chmod 755 {} \;
find sites/default/files/ -type f -exec chmod 644 {} \;

Then, when you want to run drush or make updates

find docroot/ private/ -type d -exec chmod 755 {} \;
find docroot/ private/ -type f -exec chmod 644 {} \;

You should also read through Securing file permissions and ownership.  This article includes a different version of shell script for fixing permissions, and uses a slightly more restrictive scheme.


How to add Vue.js validation attributes to input elements?

I suppose you only want to add Vue specific attributes to certain form elements, not every single one of them (including admin/backend forms).

Presuming you are using Drupal 8, I'd recommend enabling Twig debugging. That will help you to identify which fields you want to alter.

Once twig debugging is enabled Drupal should expose theming details for each element. In your case you need to know about template and hook names.

The input field shown in the screenshot is using input.html.twig template file from core/themes/classy/templates/form/input.html.twig, and theme hook is input__textfield

For your specific question, I recommend adding those attributes via preprocess hooks in your theme. For example;

<?php
function YOURTHEME_preprocess_input__textfield(&$variables) {
  $element = $variables['element'];

  if ($element['#name'] === 'title') {
    $variables['attributes']['autocapitalize'] = 'none';
    $variables['attributes']['v-model'] = 'name';
    $variables['attributes']['v-validate.initial'] = 'name';
    $variables['attributes']['data-rules'] = 'required|alpha|min:3';
  }
}

My example above is NOT very specific, it only alters "textfields" with the name "title". I recommend targeting more specific form elements.


PECL uploadprogress installed - but no progress bar, just spinning gif

Managed to solve this by changing the widget type of the field - back to normal 'File'. Then if you go to the manage field display for this, you should now have an option to set the progress indicator to either 'Throbber' or 'Progress Bar'. If you select progress bar, then flip the widget type back to drag n drop module - it seems to do the trick. Cheers


Drush commands report "hostname: Name or service not known"

Drush calls the hostname program to determine if a given fqdn for a remote site alias is actually the localhost.  There appear be other incidental uses for this program, since it is called when you run drush status.

If your system is saying 'name or service unknown', it means that you networking is not completely configured on the host server.  This isn't a Drupal/Drush issue, but see:

http://www.linuxquestions.org/questions/linux-networking-3/ssh-name-or-service-not-known-479307/

If that does not solve your problems, try asking in a SuSe forum.


Status message "The changes have been saved" displays when updating user data using AJAX and Services module

On your menu callback function ( at /api/internal/user/%user ) you can call drupal_get_messages('status');. This will clear the status messages displayed to the user. A better approach would be to check the message first:

$message = drupal_get_messages('status', false);
if( $message == t('The changes have been saved.') ) {
  drupal_get_messages('status');
}

If this is not a custom module, you should build one and use hook_page_alter() like this:

function yourmodule_page_alter(&$page){
  if(arg(0) == 'api' && arg(1) == 'internal' && arg(2) == 'user') {
    $message = drupal_get_messages('status', false);
    if( $message == t('The changes have been saved.') ) {
      drupal_get_messages('status');
    }
  }
}


Problem with views recent comments block

This is because the title and author being shown belongs to the node not the comment. There are some options under the comment group of a views fields or you can use a relationship to specify the node's author or the comment's author.


Inside the views-view-field.tpl.php, you can use the $row variable to get your other fields.
If you're using the Devel module, just send a dsm($row); to get the path to the fields you want to access.

For example I've this inside a views field template, to check if a user have something inside the field "twitter_account" :

$twitter_account = "";
if(isset($row->field_field_twitter_account[0]['raw']['value'])){
    $twitter_account = $row->field_field_twitter_account[0]['raw']['value'];
}


How can I pass proper querystring when Search from Drupal using my custom search box?

If you use the default search block for Drupal, it will give you the functionality you need.

EDIT: Go to Structure > Blocks and enable your Search Form Block by adding it to a region.

If you perform a search using your default search block, it will redirect to a path in the format /search/node/QUERY where QUERY is what you are searching for.

By default the search form outputs (for example):

                <form action="/" method="post" id="search-block-form" accept-charset="UTF-8">

Search form

                                Search
                                <input title="Enter the terms you wish to search for." type="text" id="edit-search-block-form--2" name="search_block_form" value="" size="15" maxlength="128" class="form-text">

                                <input type="submit" id="edit-submit" name="op" value="Search" class="form-submit">

                            <input type="hidden" name="form_build_id" value="form-4gEUIDHcVH7lHHH3JpkfkVs9xBmPhHXdDQAMFMF9dHA">
                            <input type="hidden" name="form_token" value="afNo5gRQlaauXmqeZYDf80o5dEwKlg0VP6U-Ir8-p6k">
                            <input type="hidden" name="form_id" value="search_block_form">

                </form>

Now if I search for "test", it redirects to /search/node/test


What is the best way to get array in some drupal data

I'd recommend you to look at entity_metadata_wrapper() function which comes with the Entity API module.

  The Entity API provides wrapper classes you may use to make dealing with the values of an entity's properties and fields easier. Wrappers make it easier to get and set the values of fields and properties as well as to programmatically retrieve additional information about these elements and iterate over lists of values in a consistent manner.

For example, using entity_metadata_wrapper() you can modify a field (or a "subfield" with your terms, I think you mean a field in a field collection) in a following way:

// You should first wrap your node with entity_metadata_wrapper().
$node_wrapper = entity_metadata_wrapper('node', $node);

// To get the value of a field
$field_value = $node_wrapper->field_example->value();

// To get the value of a field in a field collection etc.
$field_value = $node_wrapper->field_example->sub_field_one->value();

// To set/modify the value of a field in a field collection etc.
$node_wrapper->field_example->sub_field_one->set('Some new value');

// To save the entity after modifying some values
$node_wrapper->save();


Of course you can create custom order form and page in new custom module. I think you understand drupal 7 FORM API, so you have to create new page with form.
You can process form values (i mean in form submit funtion) using entity API.

To create an order for current user:

global $user;

$order = commerce_order_new($user->uid, $status = 'pendig', $type = 'commerce_order');
commerce_order_save($order);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);

To add billing info:

$profile = new stdClass();
$profile->type = 'billing';
$profile->uid = $user->uid;
$profile->status = '1';

$profile->commerce_customer_address['und'][0]['country'] = $your_country;
$profile->commerce_customer_address['und'][0]['locality'] =$your_locality;
$profile->commerce_customer_address['und'][0]['postal_code'] = $your_postal_code;
$profile->commerce_customer_address['und'][0]['thoroughfare'] = $address;
$profile->commerce_customer_address['und'][0]['first_name'] = $first_name;
$profile->commerce_customer_address['und'][0]['last_name'] = $last_name;

commerce_customer_profile_save($profile);

$order_wrapper->commerce_customer_billing = $profile->profile_id;

Then you can add products to this order:

Presume that $products is an array of arrays of products ids and quantity of this product user is buying (EG.

$products = array(
array('product_id' => 22, 'quantity' => 1),
 array('product_id' => 23, 'quantity' => 3),
);

foreach ($products as $item) {
$product = commerce_product_load($item['product_id']);
$line_item = commerce_product_line_item_new($product, $item['quantity'], $order->order_id);
commerce_line_item_save($line_item);
$order_wrapper->commerce_line_items[] = $line_item;

}
//to save line items and billing info in your order
commerce_order_save($order);


Show all nodes in the Getlocations map with diffrent marker colors per Content Type?

There is a bug in getlocations.views.inc line 96 & 97:

if (isset($options['node_marker__' . $location['type'] . '__' . $location['field_name']])) {
              $marker = $options['node_marker__' . $location['type'] . '__' . $location['field_name']];

You need to strtolower $location['type'], then it works:

if (isset($options['node_marker__' . strtolower($location['type']) . '__' . $location['field_name']])) {
              $marker = $options['node_marker__' . strtolower($location['type']) . '__' . $location['field_name']];


You'll want to have the Token filter module installed and configured in your text formats to use tokens in the node body.


How to make get for drupal behaviors to run only once?

If your script is high-level, which is most likely, then only run it when the context is equal to the document.
I found this trick in the autologout module and use it almost everywhere now:
Drupal.behaviors.dosomething = {
  attach: function attach(context, settings) {
    if (context !== document) {
        return;
    }
    // Do stuff here but still use .once when attaching behaviors.
  ...


Preventing Authors from entering pre-formatted text into filtered html field

If you're using the Filtered HTML text format, it should be stripping out spans/divs that contain inline styling. You can double check this at the /admin/config/content/formats/filtered_html path. Make sure the limit HTML tags box is checked and the Allowed HTML tags don't contain any of the HTML elements you're trying to get rid of.

If you're using the CKEditor (I'm not sure of other editors combined with the WYSIWYG module), you have a few other options to scrub bad markup when it's pasted in. You can check this by editing your Filter HTML profile under /admin/config/content/wysiwyg.

One the toolbar options contains a Paste from Word button, that allows you to paste Word-copied markup into CKEditor. I tend to avoid this myself, but you might find it useful if your users work with many Word documents.

My prefered option is to use the paste plugin to strip out markup altogether; going this route allows you to restrict your toolbar to HTML elements that will render correctly in both the editor & your theme. You can find this option in paste plugin tab in your WYSIWYG profile page.


No, there's no such feature out of the box.

For D7, there is a module for that, but I haven't see a Drupal 8 version: https://www.drupal.org/project/erri.

We did build something like that ourself based on the entity_usage module, we alter the node delete form and display a warning that shows where the node is used.


{% set full_name = [content.field_firstname ~ ' ' ~ content.field_lastname] %}

Note: We use ~ in twig to concatenate two or more strings instead of "+"


For what it is worth here is a link to Chromebook help for "This webpage is not available".

Assuming you've typed in the right URL, it looks like Chrome will give you this error message if it thinks the site takes too long to respond.  The help page also suggests:

Clear your cookies.
Adjust your proxy settings

You could also try to use another browser to access the site (both Firefox and MSIE work OK for me).


user empties cart how do I redirect that user to originating page

In your first rule "Redirect to cart after adding a registration" you probably are using a "Page redirect" action. If so you can do the following.

Edit this action and set "APPEND DESTINATION PARAMETER" to true (see screenshot).
This will add the referring page as a query parameter to your url e.g. example.com/cart?destination=node/3

Then in your second rule you can retrieve this destination parameter by using the function drupal_get_destination. Use the return value of that function in the drupal_goto function and the user will be redirected to the url they were coming from.

{ "rules_redirect_user_to_originating_page_after_removing_all_items" : {
    "LABEL" : "Redirect user to originating page after removing all items from cart",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Cart" ],
    "REQUIRES" : [ "php", "rules", "commerce_cart" ],
    "ON" : { "commerce_cart_product_remove" : [] },
    "DO" : [
      { "php_eval" : { "code" : "drupal_goto (drupal_get_destination());" } }
    ]
  }
}


How to add content inbetween node fields on node creation?

I guess this inbetween content is static or else you would have it as a field as well. So, I think you should just edit the template file of this node and add the fields and whatever other info you want between them directly on the file.

It would look sth like:

<?php print render($content['field_firstfield']);?> // first custom field
<div>
whatever you want inbetween
</div>
<?php print render($content['field_firstfield']); ?> // second custom field
<?php print render($content['body']);?> // all the rest content


Drupal Commerce order completes but reverts from pending to billing

Most likely the order processing rules.

Look into whether your payment gateway is firing an IPN / notification which changes the order. If some orders process in a different order (eg some browsers varies in speed and fires checkout rules in a different order to the others) then you can see this sort of inconsistent behaviour.

Your checkout rules can permit EITHER the IPN or customer redirect to provide checkout notification - this can avoid showing some customers "we're awaiting confirmation from payment gateway". Just check order status and don't update an order which is already completed.

Your gateway may refer to IPN under another name. IPN requests can be discerned by the differing origin IP and authentication (if purchase is from a logged in user, but the above image is an anonymous purchase so not discernible there).


Drupal node "ranking" based on views sorting

No need to make things that difficult; Views supports a field that display the sort index. It's labeled Global: View result counter.

It won't get you total results, but you can put that information in the header/footer with the Global: Result summary field.


You have to set the #default_value (as you would nearly any FAPI element) if you want the current set value to show up on the form when you visit the page. I have code such as the following in my module:

  for($i=1,$z=MAX_FRONTPAGE_IMAGES;$i<=$z;$i++) {
  $form["frontpage_image_fid_$i"] = array(
    '#type'            => 'managed_file',
    '#upload_location' => 'public://site_theme_assets/',
    '#default_value'   => variable_get("frontpage_image_fid_$i", ''),
    '#title'           => t("Random Image #$i for Frontpage"),
    '#description'     => t('This image will appear on the frontpage of the  site and have line1 and line2 on top of it.'),
  );
  }

The only gotcha I have when trying to use managed_file is that after save, on edit I get an error about the File status. That's because you should notify the file_usage table that your module owns/uses the file upon upload, eg:

/** callback for fapi admin settings page form that uses managed_file elements */
function foundation_frontpage_admin_submit($form, &$form_state) {
  for($i=1,$z=MAX_FRONTPAGE_IMAGES;$i<=$z;$i++) {
    if ($form_state['values']["frontpage_image_fid_$i"]) {
      $f = $form_state['values']["frontpage_image_fid_$i"];
      // Load the file via file.fid
      $file = file_load($f);
      // Change status to permanent.
      $file->status = FILE_STATUS_PERMANENT;
      // Save.
      file_save($file);

      // I was receiving an error on Edit of a filled out form/file upload.
      // Managed file: the file used in the field may not be referenced
      // The solution is file_usage_add() to this module as commented here.
      //
      // http://drupal.stackexchange.com/a/4819/3279
      file_usage_add($file, 'foundation', 'variable:frontpage_image_fid_', $i, 1);

      variable_set("frontpage_image_fid_$i", $f);
    } else {
      variable_set("frontpage_image_fid_$i", NULL);
    }
  }
  drupal_set_message('Changes saved for frontpage.');
}


Render a Views row ID using NID (Node ID)

In most Views templates, the entire $view object is available.  So, assuming you have a nid field in the row, you should be able to access it with something like this:

$view->result[$id]->nid

so, give

id="my-nid-is-<?php print $view->result[$id]->nid; ?>">

a try in your template.

If this doesn't work exactly, a print_r($view->result); up at the top of the template will give you a gander at what you have to work with.


What is the easiest way to get the value of a string field in a twig template?

You are referring to paragraph--bar.html.twig? Then this depends on what you want to do with the value.

Render the field value:

{{ content.field_example }}

Write code with it:

{% if paragraph.field_example.value == 'foo' %}

The field value is "foo".

{% endif %}

See this blog post for node.html.twig, which applies here as well, only that the entity is paragraph. instead of node.: https://www.md-systems.ch/de/blog/techblog/2017/02/20/twig-and-entity-field-api-or-how-to-take-control-of-nodehtmltwig


How to escape single quote from a token to use it in SQL query?

Disclaimer: you shouldn't be using the PHP filter module, ever, it's very bad practice and can open your site up to security holes. Adding a custom rules action is very easy and should always be the preferred implementation method for something like this.

As a technical exercise, though, something like this might work:

$text = <<<EOF
[node:field-text-drupal]
EOF;

$title = <<<EOF
[node:title]
EOF;

$args = [':text' => $text, ':title' => $title];
$sql = "UPDATE table SET text_database = NULLIF(:text, '') WHERE title = :title";
db_query($sql, $args);


It seems the hybridauth module passes the username trough a hook before output an if the user is registered through hybridauth,
You should be able to get your desired outcome by also using the Real name module which Hybridauth seems to integrate with.


Try this:

 $terms = taxonomy_node_get_terms_by_vocabulary($node, $vocabulary->vid);
 if ($terms) {
   print 'Event Type: ';
   foreach ($terms as $term) {
     print $term->name;
   }
 }


What are the problems with merging DB dumps?

If you use Git to version DB dumps and merge dumps from dev. and live, you can also do that with Drupal. But the Drupal DB schema is dynamic, new modules add new tables and some configuration (mainly CCK) changes can add or remove columns or rename tables. Because of this, handling (configuration) changes with DB dumps merge is hard and error prone. That's why alternative methods like Features-driven workflow are recommended to manage (configuration) changes management between multiple environments.

See also The Development -> Staging -> Production Workflow Problem in Drupal and the Code driven development: using Features effectively in Drupal 6 and 7 presentations.


How to redirect user to new page after submitting user register form?

The syntax that you use is not the same as in the API docs. The qis to much.

Also, you shouldn't manipulate $_GET, that's not at all reliable. The correct way to achieve what you want, is to add a custom form submit handler and when that is called to set $form_state['redirect'].

Have a look at the accepted answer to this question: https://stackoverflow.com/questions/14542975/drupal-7-redirect-to-a-specific-page-a-tab-after-form-submit


How do you disable strict errors for PHP 5.4 & 5.5 in Drupal 7 via the settings.php file?

And the Drupal way:

Add this line in settings.php

$conf['error_level'] = 0; // 0: None, 1: Errors and warnings, 2: All messages

You can set any persistent variable this way. You can get the variable names simply using Firebug or any browser's developer tool and check the name attribute of the input field in the administration form. Which in you case the Logging & Errors page. If you look at the source code, the radio buttons have the name attribute error_level and each radio button has a value attribute. Simply set this value to the variable in you settings.php using $conf array.

You can also set any variable using variable_set() function in any custom module, in an update script for example.

Or using Drush:

drush vset error_level 0


How do I add a customized parameter to image links

You can do this with a preprocess function THEMENAME_preprocess_field and check whether the field is an image and it has a URL

function THEMENAME_preprocess_field(&$variables) {
  if($variables["element"]["#field_type"] == "image"){
    if(isset($variables["items"][0]["content"]["#url"])){
      $variables["items"][0]["content"]["#url"]->setOption('query', ['param' => '0']);
    }
  }
}


I suspect your host is not using UTF-8 for their filesystem (rather rare these days, for example, in the early 2000, I've seen hosts using ISO-8857-7 or CP-1253 encodings for their files, because that's what Microsoft Windows did). Alternatively, Plesk or FileZilla is not using UTF-8, but that would only be a problem displaying the file names and Boost should work.

If it is because of the filesystem of your host, you could try to forward-port this old patch from 6.x-1.x which would convert with iconv the filename before saving it to disk:
https://www.drupal.org/node/797136

To detect the encoding used on the filesystem, type the command "locale". It should display:

LANG=en_US.utf8

If it display anything else than utf8, such as iso8859-xx or cp-xxxx, that would probably be the source of the problem (and will require patching Boost).

Boost does store on disk the filename unescaped, e.g. it stores it in unicode, not by escaping the characters (ex: %CE%BC%CF%80%CE%BF%CF%85).

Here is a test using Greek, Cyrillic and Latin accents:
https://www.bidon.ca/fr/μπου-χου-добър-ден-éàĉç


Programmatically validate required fields of node object

Passing form submit means passing the form's validate handlers. Once validation is passed, the node is written into database and no more validation will be done(not sure about this). That's why node_save api function does not return anything.

It means that "Required" fields are to be validated only in the Form validator. You can however choose to even write a Node without "Required" fields filled in. For example to can choose to empty "Required" fields in hook_presave(D7).

node_load does not check if all fields are set or not. It simply creates a node object which is consistent and also calls various hooks. It saves us from portability issues if we were to write our own functions to read the database and build node object.


On Input filter option (admin/settings/filters) you can check the user permission for each type of input filter you have on the site.

Then if you are using the WYSIWYG module, at admin/settings/wysiwyg you can check which type of editor is using each input filter.

If the WYSIWYG editor is working for anonymous user on one theme but not on the other, you could also check (with Firebug or Chrome DevTools) if there are Javascript errors. If that is the case, please, update this post with the error message.


Need Steps to Install multisite configuration using only drush. i.e multi-site install having different database

Try:

drush site-install --db-url=mysql://USER:PASS@localhost/DATABASENAME --sites-subdir=sitename

You may also need to add --db-su and --db-su-pw if necessary to provide the right credentials to create the database if the user specified by USER:PASS does not have permissions to do this.

See drush help site-install for other useful optional options you might want to specify, e.g. site name, admin account details and so on.


Short answer is yes you are on the right track. Altering form values on validation can get a little tricky and complex depending on the form. You might want to check out form_set_value if you haven't already.


Is there a way to know the type of output inside a template file?

I think you're looking for the $theme_key global, which gives you the:

  Name of the active theme.

You can use it like so:

global $theme_key;
if ($theme_key == 'mobile_theme') {
  // ...
}
else {
  // ...
}


How to execute ajax action after image file upload with media widget?

If I understand your question correctly, I believe you can do this with hook_form_alter. You can create a new form submit handler to do anything you want to do the data before it's saved. I'm not sure why you would need ajax.

my_module_form_alter(&$form, &$form_state, $form_id){
    $form['#submit'] = array();
    $form['#submit'][] = 'my_module_submit_handler';
//this makes sure your submit handler is run first
     array_unshift($form['#submit'], 'my_module_submit_handler');
}

Then create a function to make your changes and call the original form submit function...

function my_module_submit_handler($form_id, &$form_state){
     /*
       changes to the values submitted to your form
     */
   }

This is off the top of my head but should put you on the correct path. I believe that your handler will execute and then the default handler will execute.


is there any option in drupal to create a node for a particular user?

The easiest way I see to do this is by following these steps:

Install References module.
Enable User reference module under admin > modules
Create a content type (say "lab result"), and add a field of type user reference.
Now, every time you create a "lab result" you could associate it with an user.
For listing the "lab result" of a particular user you could use the Views module.


Allow role to edit node with same taxonomy term

A few year's back, I had to do this for a D7 site with 100s of content providers that could only post in specific areas.  Did this by have a protected section taxonomy field on the user profile.

Then used hook_node_access to test if the node had a term that matched on of them on the user profile.

That's the basics.

I think I had to do a custom validator for the node create form to check that they were creating nodes with approved terms.

I also think the node create form and edit forms had the term lists cut down to just allowed terms by using a view as the source of the selection list.

Sorry for being general, I haven't worked on that site for years and don't have the code anymore.


Multiple fields that are generated dynamically in forms

You can use session to store your data like:

$session = new \Symfony\Component\HttpFoundation\Session\Session();
$session->set('counter', $session->get('counter',0) + 1);
$counter =$session->get('counter');

$form['counter'] = array(
   '#type' => 'hidden',
   '#value' => $counter
);

Tuto : http://www.drupal8.ovh/en/tutoriels/25/save-user-temporary-data-on-session


Give Role Permission to 1 Admin Configuration area?

you can write your own "access callback" function returning TRUE just if the current user have the role you choose. Something like this:

function predeparture_menu() {
  $items = array();
  $items['admin/config/eap-predeparture'] = array(
    'title' => 'Manage Site',
    'description' => 'upload the valid predeparture csv file from this page.',
    'position' => 'left',
    'weight' => -100,
    'page callback' => 'system_admin_menu_block_page',
    'access callback' => 'my_access_callback',
    'file' => 'system.admin.inc',
    'file path' => drupal_get_path('module', 'system'),
  );

function my_access_callback() {
  global $user;
  return in_array('the role', $user->roles);
}


Load login / register block in custom template

The user/login page is different from the the user login block. To add the user login form to an arbitrary page, then you would need to add the user login block to a region you want, and configure it to display only on the front page. This can be done using the Block administration page (documentation).


How can i display view specific content type based on dynamic term name in node page?

The resource list view should accept the branch as contextual filter. Have a look here: Views contextual filters taxonomy name

Maybe also consider using quicktabs for showing these views.


Is there any way to get only the custom roles?

As @stevekeiretsu said in a comment ->

The Role entity doesn't really make any distinction. Looking at the roles in my own db (filter config table by name LIKE user.role%) the only potential contender I can see is that the three default ones have a dependency on _core, so you could check that via getDependencies, but that feels arguably flakier than a static filter to me.

So for Drupal 8 there is no function defined.


It is, but requires a bit of coding. You need to create a ctools content type plugin. I had the same issue a few months back, and found this to be a reasonably good guide for writing you r own content type:

http://shellmultimedia.com/articles/creating-content-type-ctools-panels-3

There are also a couple other options:

Expose the data your function is providing in a block. Blocks are automatically supported by panels.
You could (likely) use custom PHP in a panels pane. (highly discouraged)


Multiple Ubercart? Trying to do a multi-seller site.

Have a look at Marketplace.

The modern alternative to ubercart is commerce and there is a marketplace module too, though it's still in beta.


I could not figure out a way to conditionally map content to public and private fields in one migration.

But, I did figure out how to resolve the issue.

I migrated all d6 files, public and private, to the d7 public attachments field.
I created a query that finds all the private files migrated into the public attachments field:

SELECT * FROM migrate_map_f43b6e55cfile mm inner joinfield_data_field_attachments fa on mm.destid1 = fa.field_attachments_fid inner join file_managed fm on fa.field_attachments_fid = fm.fid where fm.uri like '%private%' and fa.entity_type = 'node' order by fm.filename

The private files can be identified because they will have 'private' in their URI.

I iterate through the query results and switch the private files from the public attachments field to the private attachment field.

This process, while requiring an additional step after the actual migration, works perfectly.


When i Google drupal image sliders the second result leads me to this.

Available modules

There are many modules that provide some sort of slideshow / rotator functionality.

Views Slideshow Liquid Slider - A fully responsive, HTML5 jQuery content slider for both web and mobile devices.
Content Glider - Another jQuery plugin for image slider, very easy to use.
Flex slider - provides a client-side automatic adaptation of the slides size according to the window size (Responsive). Can work with the Views module. Poor documentation.
jCarousel - This module allows developers and themers to make use of the jCarousel jQuery plugin. It includes a developer API that other modules can use, as well as Views integration in the 2.0 version so that you can turn any list of content or images into a carousel.
Dynamic display block - Enables you to create and present blocks of content in a dynamic and attractive way. Uses the jQuery Cycle Plug-in.
Views Nivo Slider - a Views style plugin using the Nivo style slider.  Drupal 6 version requires imagecache, imagefield and jquery update.
Views Slideshow - a Views style plugin using jquery cycle. Provides an extensible API that allows other cycles, rotators, and carousels to plug into the module, so they don't need to recreate the Views functionality.
Views Slideshow: Dynamic display block - a Views slideshow plugin which enables you to present slideshows in an attractive way.
Views Slideshow Xtra is an enhancement module for Views Slideshow, providing the ability to create animated slideshow overlays.  This module can also help automate the creation of any Drupal 7 Views Slideshow, using the Views Slideshow Xtra Example sub-module, which creates a Slide content type, a default Slideshow View, and example Slide nodes.
Views Slideshow: ImageFlow - offers an ImageFlow option to Views Slideshow, similar to Apple's CoverFlow.
Slideshow Creator - adds an input format filter to allow you to add slideshow creation code to the body of a node and other text fields.
Featured Content Slider - select nodes based on content type and create up to 3 blocks of featured content.
Slider - create a "slider" content type with a multi-value nodereference field to create carousel-style sliders of the referenced nodes.
Ajax Slideshow - Sequential presentation of any of the site nodes, using various effects. The slideshow is ajax-based which means the page load-time is agnostic to the amount of content included.
Media Nivo Slider - Provides the ability to expose the content of a Media Gallery to a Nivo Slider block.
Nivo formatter - Nivo formatter is an image field formatter that transform any image field
    to awesome Nivo Slider image gallery.
Nivo Slider - Nivo Slider is a stand-alone solution for creating a simple slideshow for your website.


SORT CRITERIA by GROUP BY datepart in Views

I couldn't find any way to do this using the options in the View UI. One way to accomplish it, however, might be to add an additional field to your content type that stores only the day/month/year for the date (set the default to 'now' so that you don't have to manually enter the date, and set the field to 'hidden' on the display options), and then you could use that field to group by in the view.


Here is what I would do.

Do not set a default image for your image field.

In views, instead of using a content: teaser use content: fields. Then in No Results Behaviour of your image field you put <img src="/link/to/image.png">

Then you create a "full" version using content: fields, which you don't do a No Results Behaviour.


List of content types posted/commented by users I follow

Humm, I couldn't find a way to easily put them all together (comments and nodes authored by the users followed) but could create separate views.

For nodes created is easier:
Create a new View, change from Show Content to Show Users and in the Relationship add a Flags: User flag, choose your flag and Current user.

For comments created:
Create a new View, select Show Comments. In the Relationship add Comment: author to expose the Authors ID, select require this relationship. Add new Relationship, this time look for Flag: User flag, select the author's relationship created before and your flag.

As stated before, you might get all the content together but I couldn't get it in any easy way.


How to delete a taxonomy term with a broken URL

To solve this I was able to open up the database and view the url_alias table.

From there I simply changed the url back to the automatically generated url that I overwrote.


Error: Call to undefined function in inc file

files (Optional)
Drupal supports a dynamic-loading code registry. To support it, all
modules must declare any code files containing class or interface
declarations in the .info file, like so:
name = Really Neat Widget
...
files[] = tests/example.test

When a module is enabled, Drupal will rescan all declared files and
index all the classes and interfaces that it finds. Classes will be loaded automatically by PHP when they are first accessed.
Currently this mechanism does not natively support namespaced classes.
Source: Writing module .info files (Drupal 7.x)

This approach only works with Object Oriented PHP. You would have to create a class.
If you want to keep with your current approach, add this to the top of the draws.module file after the <?php open tag.
module_load_include('inc', 'draws', 'draws.fixturesSavings');


Passing variables to JS from theme folder .tpl files

Take a look at the variable_set function. If my memory is correct, I used this to move variables between PHP and java script.