Drupal doesn't send email to reset password While having difficulty logging, I reset my password but the page stays and does no form action.

After I changed my password in the mysql database, I went to log in and the page does nothing even when I hit submit. Is there something wrong with my installation?

Taking a quick peek at your code (at http://cie.austin.utexas.edu/uex-cm/user/password) it looks like something is overriding the default HTML output for your forms. You're missing the <form> tags and the associated action and method attributes.

If you're looking for a quick fix (just to login one time) you can use Chrome Inspector or Firebug or similar to add the form tags around your form elements:

<form action="/uex-cm/user/login" method="post" id="user-login" accept-charset="UTF-8">
  // Your existing form elements
</form>

But ultimately, you'll need to figure out what is stripping the <form> tags from your HTML.


How to set custom user view mode for comments How do I control which view mode of a user account appears on different pages?

I have a Compact user view mode with two fields I want to appear in forum posts and comments. I then have a more complete user view mode I would like to have appear on the users home page and eventually i would like a different view mode for article bylines.

I cannot, for the life of me though, figure out how to actually have any of these display.

I want to modify the layout of user.html.twig for the user home pages to have additional headings and information. But then it gets used wherever the user entity appears. Am I suppose to create specific twig templates for every user appearance or is there some more sensible way to control the fields that appear?

I tried accessing specific user entity fields and styling them in templates such as node--forum.html.twig but I can only seem to access the complete user entity with {{ author_picture }} - why is it named that if it is the entire entity? or the user name with {{ author_name }}

How do I do this?

The variables {{ author_picture }} and {{ author_name }} are prepared in preprocess in the hook template_preprocess_node(). You can modify these variables or add your own in a custom preprocess hook.

Or you can make the field uid configurable in UI by modifying the field definition in the node entity:

mymodule.module

function mymodule_entity_base_field_info_alter(&$fields, $entity_type) {
  if ($entity_type->id() == 'node') {
    if (isset($fields['uid'])) {
      $fields['uid']->setDisplayConfigurable('view', TRUE);
    }
  }
}

and you'll find the Authored by field in the Manage Display page, where you can configure how the referenced user entity is formatted (which view mode is used).

A third and IMHO perferable option is to use the module Display Suite.


Override a content page in drupal 7 There is any way to override the content page of a particular content type in drupal 7.

By default the content page has the sidebar on the right hand side and the content is placed on the left side

 Page design:

 Content- width 650px | Left sidebar 500px

Here if the content type is company_profile then the width of the content type should be 1050px and the side bar should be below the content page with width 500px as show in the below image

Can anyone help me how to override the content page when the content type is company_profile

You can either use hook_preprocess_node() and if the content type is company_profile, change the styling. Or you can have a node--company_profile.tpl.php file and render that particular content type the way you want.

Then you can use CSS to do get things done. If you use a grid based layout such as 960.gs, this would be easier.


Provide a default image for image field programmatically at theme level I have an image field on a node, which will not always be populated. In the case where the field is empty (no image), I want to alter the markup to display a random image which always exists in a specified directory of the files dir. The second part isn't a problem, but I am struggling with the alter part. I am trying to find the correct hook or theme function to test if the image field is empty and then render some markup in it's place. I am lead towards a theme function. Any ideas?

Thanks

use hook_node_view_alter. Check over there that if images is empty then fetch image from your whatever custom directory and print it. For printing an image use theme_image.


Looking for most reliable and compatible (with other Drupal modules) multiple photo uploader and gallery system in Drupal 6 and Drupal 7? DrupalGardens hosted (Drupal 7) sites use a fantastically easy multiple photo uploader - i.e. one can select multiple image files from an Explorer Browser box (or other OS equivalent) using CTRL, SHIFT and upload them all at once into a gallery.

Question 1) What modules is this based on, so that I can export and deploy a site outside of DrupalGardens?

More importantly:

Question 2) If I was building a Drupal 7 site from scratch with my own hosting, what modules would I need to achieve this?

Question 3) If I was building a Drupal 6 site from scratch with my own hosting, what modules would I need to achieve this?

I wish to stay with Drupal 7 in my consideration as to which version to use. But if Drupal 6 has more rich functionality then I may use that.

They use Media Library on Drupal garden but this is only for D7 and it's still in dev. You can also try Cincopa which is really interesting, it's for D6 but they are developping a D7 version


How can I get node url in rules for facebook auto post Event is: After saving new content

When I add new blog type content it shows error. I know this error is occurred for

  Set a data value
  Parameter: Data: [entity-created:field..., Value: [node:url]

1. I know the problem is occurred  Value: [node:url]
2. But I need the url of the created node
3. how can I get this url

Make sure when you use [node:url] in any code, it must be in "" so for example

$path = [node:url];

is wrong, it must be

$path = "[node:url]";

As another solution

When you Set a data value you can use Value textarea and php codes to generate the node url.

this is an example where I post a trimmed field_body and the node url to Facebook. If you need to post the node alias to Facebook, you can use

$nid = [node:nid];
$path = drupal_get_path_alias('node/$nid');

to get the alias then print it in the <?php segment.


What is the purpose of rerender FormState property? I am trying to understand With a taxonomy term view Exposed form in block has incorrect action URL /taxonomy/term/all, not taking into account term id and breaking filtering without AJAX/JS and in the process I see the rerender property is mentioned in code a lot, such as on Render exposed filter without creating block and How to programmatically render a view exposed filter inputs with form state maintain? The original problem is that the code runs the second time and it doesn't get view arguments, but I don't see where the rerender property can influence this process and how it's reasonably used at all. The only place I see is in an Ajax sub-folder, but I don't have Ajax enabled on my view yet.
What problem does this property solve?

The only place in core that checks for, $form_state->get('rerender') in an if statement is in:
/core/modules/views_ui/src/Form/Ajax/ ViewsFormBase.php
// If the form has not been submitted, or was not set for rerendering, stop.
if (!$form_state->isSubmitted() || $form_state->get('rerender')) {
  return $response;
}

// Sometimes we need to re-generate the form for multi-step type operations.
if (!empty($view->stack)) {
  $stack = $view->stack;
  $top = array_shift($stack);

  // Build the new form state for the next form in the stack.
  $reflection = new \ReflectionClass($view::$forms[$top[1]]);
  /** @var $form_state \Drupal\Core\Form\FormStateInterface */
  $form_state = $reflection->newInstanceArgs(array_slice($top, 3, 2))->getFormState($view, $top[2], $form_state->get('ajax'));
  $form_class = get_class($form_state->getFormObject());

  $form_state->setUserInput([]);
  $form_url = views_ui_build_form_url($form_state);
  if (!$form_state->get('ajax')) {
    return new RedirectResponse($form_url->setAbsolute()->toString());
  }
  $form_state->set('url', $form_url);
  $response = $this->ajaxFormWrapper($form_class, $form_state);
}
elseif (!$form_state->get('ajax')) {
  // if nothing on the stack, non-js forms just go back to the main view editor.
  $display_id = $form_state->get('display_id');
  return new RedirectResponse(Url::fromRoute('entity.view.edit_display_form', ['view' => $view->id(), 'display_id' => $display_id], ['absolute' => TRUE])->toString());
}
else {
  $response = new AjaxResponse();
  $response->addCommand(new CloseModalDialogCommand());
  $response->addCommand(new ShowButtonsCommand(!empty($view->changed)));
  $response->addCommand(new TriggerPreviewCommand());
  if ($page_title = $form_state->get('page_title')) {
    $response->addCommand(new ReplaceTitleCommand($page_title));
  }
}

The if (!empty($view->stack)) { part will only pass if the form is a multi-step form and you're not in the last step; otherwise, it will proceed to close the modal. Ex: when you click "Apply" or "Cancel" or "Remove". (Ex: when adding a field) it triggers the else:
else {
  $response = new AjaxResponse();
  $response->addCommand(new CloseModalDialogCommand());
  $response->addCommand(new ShowButtonsCommand(!empty($view->changed)));
  $response->addCommand(new TriggerPreviewCommand());
  if ($page_title = $form_state->get('page_title')) {
    $response->addCommand(new ReplaceTitleCommand($page_title));
  }
}

Conclusion
As it only gets checked in the views_ui module, this setting is basically a way to tell the Views UI Form:
if the setting form is a multi-step form, like when you're adding a field:

to keep the modal open and build a new $form_state for the next form

Otherwise, its like when you click apply/cancel/remove it tells it to close the modal, show save & cancel buttons, and show/refresh the live preview.


Display of hierarchical Taxonomy in views along with the related content I have a Hierarchical Taxonomy like:

  Bachelor of Degree
  -Year1(child term of Bachelor of Degree)
  --Term1(child term of Year1)
  -Year2
  --Term2

  etc etc...

The contents content1, content2... of a Content type will go under Terms Term1, Term2...

Can you kindly help me in getting the view as:

  Bachelor of Degree
  -Year1(child term of Bachelor of Degree)
  --Term1(child term of Year1)
       content1
       content3
  -Year2
  --Term2
       content2
       content4

1-
Use Hierarchical Select module. it may help you.

2- by using the Taxonomy menu module

3- use Views Tree and Views Field View


What is the difference between page callback and access callback? Can anyone please explain with example for difference between page callback and access callback in drupal?

page_callback is a function called which will be used to generate contents of the page
access_callback is a function called which will be used determine if a user has access to view the page. This can be used where a simple permission isn't enough. An example would be that the author of the node would be allowed to edit the node or any user with a special admin permission.
Note the access_callback will by default be the user_access function which will check that the user has a specific permission.

Both of these keys have a sidekick, [page/access] arguments which should be an array of arguments that is passed to the function. arguments can either be static or you can use numbers to reference the URL. If a load function us used on a URL arg, like %user, referencing it will yield the return of the load function, like the user object instead of the user id (uid).

Page callbacks will receive any URL args that aren't used for pattern matching. So if you define an URL foo/bar and user goes to foo/bar/baz, baz will be added to the list of args passed to the page callback. This can be handy in some cases where you can provide a default argument that can be overridden in the URL.

If in doubt always check the api refference api.drupal.org


How do I specify a parent domain in a multi-site install? I'm not sure the best title for this question so sorry if it was confusing.

Setup

I have a multi-site install that I regularly add new sites to.

They are generally in the format:

example.com (default)
sub1.example.com
sub2.example.com
sub3.example.com
sub3.com

I also have a wildcard dns and vshost so I don't have to edit them every time I create a new site:

example.com my.ip.add.ress
*.example.com my.ip.add.ress
sub3.com my.ip.add.ress

<virtualhost *:80>
  Name example.com
  alias *.example.com
  alias sub3.com
</virtualhost>

Sites.php has a few entries like:

sites[sub3.com] = 'sub3.example.com'

All of this works great.

The problem.

Most of these sites are not publicly visible. being disabled with robots.txt and permission preventing users from see them. So I could care less about those. However some sites are public. In the example above the example.com and sub3.com are both public facing sites.

When a user visits rando.example.com the multi-site will send them to example.com but the url will appear as whatever they typed in. Also the sub3.com site will be visible as both sub3.com and sub3.example.com.

The question.

How do I, preferably using only Drupal, redirect the non-existent subdomains to the default. Not just show the default but actually do a 301 redirect to the url desired.

My attempts.

To my knowledge I can not solve this with:
-  redirect module as it does not let me specify a subdomain or a wildcard.
-  global redirect does not affect subdomains.
-  sites.php as it does not redirect but a sites[*.example.com] => example.com would be cool.

Qualifiers

I understand that I could fix this in the vhost by removing the wildcard name and just adding a new entry for each sub-domain. I do not want to have to edit my vhost every time their is a new sub-domain.
I understand I may be able to solve this with .htaccess files but I do not want to have to edit that file every time I create a new site either. And I don't really want it to be overridden from default. Plus I have my server pull the file only on reboot and I don't want to reboot apache just to add a site.
I understand that canonical urls would prevent bots from indexing unused sub-domains but that's not good enough I don't want users using a subdomain that doesn't exist.

My ideal solution would be a redirect that supports sub-domains or something similar. Changes to sites.php or database changes are the goal.

It is called multi-site aliasing, hence the results. Drupal offers you to server multiple domains from the same folder in order to preserve the paths in the database. So you would use the same folder for example.com and sub3.com because you might want to disable one of them later on. Aliasing is meant on a file level here. What you need is a redirect.

A 301 redirect code can be issued by your webserver-software itself (e.g. Apache/nginx config or apache .htaccess) or by sending a header via the scripting software.

The "drupal-way" solution for you would of course be to use a module for sending that header. My recommendation would be multisite_redirect, because it would only need a one time setup for your case outlined above.


Why are most of the commands missing? Most of console commands are missing from the output of drupal list.

I am using Drupal Console version 0.11.3, which outputs the following error message.

  [WARNING] In order to list all of the available commands you should install Drupal first.

The multi-site is correctly configured.

I have created an empty /sites/default/settings.php and it is still not working, i.e. it still not showing most of the Drupal console commands.

Why do I get that error message?

Specifying the root resolved this for me. Having used composer to install drupal through drupal-composer/drupal-project the site is put in a "web" folder so the following worked.

drupal --root=/var/www/html/web list

I had also run the init command beforehand

drupal --root=/var/www/html/web init


display node's field in Is it possible to display a node's field in a table? Is there any module providing it?

For example I have a node "English idioms" which has a field named: "Idiom" and "Explanation". I would like to put them both in a (table->tr->td - each).

At the moment I have these fields in div's with classes but I would like to avoid it if it's possible.

Kind regards.

You could use field_group nad field_group_table

  Fieldgroup will, as the name implies, group fields together. All fieldable entities will have the possibility to add groups to wrap their fields together. Fieldgroup comes with default HTML wrappers like vertical tabs, horizontal tabs, accordions, fieldsets or div wrappers.


How Can I Enable a Multi-Lingual Catalog Block on Drupal 6.32 + Ubercart 6.x-2.13 Description of Problem

No matter what I try, I cannot get my Ubercart Catalog Block to change languages when I use the Language Switcher.  You can test this behaviour for yourself at:

holistichorsecare.com/zh/products/aromadog-arf-ritis-pain-relief-1oz

Regardless of the language context (English or Chinese, "en" or "zh-hant"), the shopping cart block on the left margin of the page, under all circumstances, displays this text:

Shopping cart

There are no products in your shopping cart.

0 Items   Total: HK$ 0.00

Go ahead and give it a try.  Load the page and click on English or Chinese as they appear in the page header.  The shopping cart block does not change languages- and I'd like it to.

The Localization Files are Installed - I Think...

I've installed the following localization strings packages using the Administration front end and they appeared to be loaded correctly.

ubercart-6.x-2.13.zh-hant.po
uc_ajax_cart-6.x-1.0.zh-hant.po

Checking out the Module Code

Looking into:

holistichorsecare.com/www/content/sites/all/modules/ubercart/uc_cart/translations/zh-hant

I see the following entry around line 1926:

msgid "There are no products in your shopping cart."
msgstr "ä½ (å¦³)ç
                 è³¼ç©è»è£¡æ²æä»»ä½åå."

(the garbled text is the multi-byte characters breaking up in my shell)

Looking into

holistichorsecare.com/www/content/sites/all/modules/ubercart/uc_cart/cart.module

I see the following call around line 706:

$output = '
'. t('There are no products in your shopping cart.') .'
';

So it appears that there is a call to t() to translate the string, but none is forthcoming from whatever system there is that serves up the alternatives.

Can someone please tell me where I need to go in the administration front end to enable localization/translation for the shopping cart block (ajax cart) in Ubercart?

I'm thinking I just missed a check box somewhere to turn on the translation, or have to tell Drupal/Ubercart that the strings in the Shopping Cart Block are to be translated, but I don't know where to go or how to do this.

P.S.:  When I called i18n_get_lang() in troubleshooting code I got the right answer back (i.e. "en" or "zh-hant"), so the system knows what language context it is in.

Thank you.

Sorry but you CAN NOT HAVE Ubercart multilingual because the project was started on the wrong way and now the developer team have no interest/possibility/capability to rewrite a lot of code!


Getting the original form with error message in drupal ajax call back I have a drupal form which accept email id and ajax call is implemented for the submit button.In addition to submit call back.The return values are collected in the wrapper and my requirement is to display the form along with an error message if the email is not valid.

I tried to return the form along with message to the wrapper from submit,but the ajax call was not happening.

Also i tried to reset the form_state array empty in the submit call back, but execution stopped at that point.

Am i on the correct track?
Please help me in solving this.Sorry for my english.

For Drupal 7 you can use the below code

    /**
     * Implements hook_menu().
     */
    function hook_menu() {
        $items['test_ajax'] = array(
            'title' => 'test ajax',
            'page callback' => 'drupal_get_form',
            'page arguments' => array('demo_form'),
            'access callback' => TRUE,
            'type' => MENU_CALLBACK,
        );
            ....
    }

    /**
     * Implements hook_form().
     */
    function demo_form($form, &$form_state) {
        return array(
            'email' => array(
                '#type' => 'textfield',
                '#title' => t("Join our Newsletter"),
                '#required' => TRUE,
                '#attributes' => array(
                    'placeholder' => t("mail@example.com")
                ),
            ),
            'submit' => array(
                '#type' => 'submit',
                '#value' => t('Subscribe'),
                '#ajax' => array(
                    'callback' => 'demo_form_ajax_submit',
                    'wrapper' => 'demo-form',
                    'method' => 'replace',
                    'effect' => 'fade',
                ),
            ),
        );
    }

    /**
     * Ajax callback function.
     */
    function demo_form_ajax_submit($form, $form_state) {
        drupal_set_message();
        $message = '';
        if (!empty($form_state['input']['email'])) {
            if (valid_email_address($form_state['input']['email'])) {
                $message = "subscription successful!!!";
                $status = 'status';
            }
            else {
                $message = 'Please enter valid email ID!!';
                $status = 'error';
            }
            drupal_set_message($message, $status);
        }
        $form_state['rebuild'] = TRUE;
        return $form;
    }


Show children of a Taxonomy Term I make use of the view: "taxonomy term". Is there an easy way to also show the children of a term, next to the nodes beloging to this term?

Example:

Cars
- Volvo
--- Family_cars
--- Sports_cars
- Honda
--- Parts
--- ...
Trucks
- ...

When you see the "cars" page I want to show all articles about cars (but not about Volvo, Honda, ...) AND I want to show the children (Volvo, Honda, ...) When you click one of these I want to show all the articles belonging with them, again with their children.

If I understood you correctly, you want to display nodes that have a term, but not the nodes that have a child term.

You also want to display the child terms.

There are some different ways of handling this, since you are using the default view, you should get a View already that displays the correct nodes - so all you are missing is the terms.

The best way to deal with this, is not through Views, but a module called Taxonomy menu. It will create a menu with the same structure of a vocabulary which can expend, to show child menus. As with menus you get use the block system to add them on the term pages. Beware of a bug with the menu system though see the issue.

A quick fix is to add this in your settings file:

$conf['menu_default_active_menus'] = array(
  'navigation',
  'management',
  'user-menu',
  'main-menu',
  'your-menu-here',
);


Should I down-grade to Drupal 6.x? There seems to be much better support! If I'm only looking to throw some easy-to-use modules together for a client and then put the Zen theme on, should I stick to Drupal 6.x? I've noticed in my exploration of Drop-down menus in 7.x that there is very little support for it in the form of modules.

D6 is certainly an option, and will likely retain a sizable installed-base for some time to come.  That said, D7 is where the focus is, now, and will continue to be in the future.

In my experience, the simple/basic/popular modules are already quite well supported in D7; it's the more 'exotic' modules that are not quite there yet.  I've moved my site to D7 with relatively few issues -- D7-specific documentation, or lack of it, can be a challenge.

With regards to drop-down menus, Superfish is provided as a D7 module now -- http://drupal.org/project/superfish.  Works well enough here, and the project seems active.


Why there are two payment for one order with same remote ID Right now, I am using Commerce Paypal to capture payment. But I found there is a order which shows me two logs for capturing payment. However, I just find one in my paypal account and also I found the Remote ID in both two logs are same.
The customer bought one item which costs $17, but the total shows on drupal is $34. What is the exact total price for this order? Does anyone know why this happened? Is there something wrong during my config?

Here is a screenshot for this strange order:

For some reason the IPN for that payment triggered the creation of a second payment transaction within Drupal Commerce. Couldn't tell you exactly why it happened, though it could've been the result the customer's page request and the IPN request being processed simultaneously. The module ought to filter out IPNs to not duplicate transactions like this, so if you see it again, file a bug report in the module's issue queue.

To answer your direct questions, the order cost $17, the balance is now negative (meaning it appears overpaid within Drupal Commerce, even though it wasn't), and it would be safe to delete one of the transactions (but you'd need to be logged in as an administrator).


Is there a recommended method to construct a form on a grid (2-dimensional array) with Form API? Possible Duplicate:
  Theme Drupal Form API checkboxes as a grid

I would like to create a form that is able to accept values which will be saved into a multidimensional array. Is there an advised method on how to accomplish this with Form API?

As an example:

  |  A  |  B  |  C  |
--+-----+-----+-----+
1 |     |     |     |
--+-----+-----+-----+
2 |     |     |     |
--+-----+-----+-----+
3 |     |     |     |
--+-----+-----+-----+

I would like to have a textfield for each grid square and save the end value into a single array which will be serialized and saved as a variable.

EDIT: Just to clarify, I don't particular care if the form is output as a TABLE in a HTML sense, but it would obviously be nice to have it stored as a multidimensional array from a PHP perspective.

If you need a table and put checkboxes on the left you could use http://heine.familiedeelstra.com/new-tableselect-form-element-in-core

Alternative you could theme your form. Therefore you have to write a theme_form_id which
drupal_render the elements and put them together with theme('table').

PS: This will perhaps land in drupal8: http://drupal.org/node/80855


What does drupal_clone($node) do What does drupal_clone($node) do in Drupal? Will it clone a node?  I know the node will be saved only if node_save($clone) is rendered. So what will happen when drupal_clone($node) is rendered ?

/**
 * Generate a node preview.
 */
function node_preview($node) {
    if (node_access('create', $node) || node_access('update', $node)) {
        // Load the user's name when needed.
        if (isset($node->name)) {
            // The use of isset() is mandatory in the context of user IDs, because
            // user ID 0 denotes the anonymous user.
            if ($user = user_load(array('name' => $node->name))) {
                $node->uid = $user->uid;
                $node->picture = $user->picture;
            } else {
                $node->uid = 0; // anonymous user
            }
        } else if ($node->uid) {
            $user = user_load(array('uid' => $node->uid));
            $node->name = $user->name;
            $node->picture = $user->picture;
        }

        $node->changed = time();

        // Extract a teaser, if it hasn't been set (e.g. by a module-provided
        // 'teaser' form item).
        if (!isset($node->teaser)) {
            $node->teaser = empty($node->body) ? '' : node_teaser($node->body, $node->format);
            // Chop off the teaser from the body if needed.
            if (!$node->teaser_include && $node->teaser == substr($node->body, 0, strlen($node->teaser))) {
                $node->body = substr($node->body, strlen($node->teaser));
            }
        }

        // Display a preview of the node.
        // Previewing alters $node so it needs to be cloned.
        if (!form_get_errors()) {
            $cloned_node = drupal_clone($node);
            $cloned_node->build_mode = NODE_BUILD_PREVIEW;
            $output = theme('node_preview', $cloned_node);
        }
        drupal_set_title(t('Preview'));

        return $output;
    }
}

Real Issue

I am getting the node cloned when clicking the preview button. Is it related to any code changes?

allows users to make a copy of an existing item of site content (a node) and then edit that copy. The authorship is set to the current user, the menu and url aliases are reset, and the words "Clone of" are inserted into the title to remind you that you are not editing the original content.

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


How to combine two batch operations for views data export into one? I have been using a custom module that was posted here:

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

I slightly modified this module and created two copies of it, as I have two views and planning to add third one but it currently doesn't work properly so let me explain:

dvm_reports module#1 for Denmark

function dvm_reports_views_data_export_batch_alter(&$batch, &$batch_redirect) {
  $view = views_get_view($batch['produkty_denmark_xml']);

  // Add in another operation that will store the file on the server in a location
  // of our choosing.
  $batch['operations'][] = array(
    'dvm_reports_views_data_export_batch_finish', array($batch['eid']),
  );
}

function dvm_reports_views_data_export_batch_finish($eid) {
  $export = views_data_export_get($eid);
  $view = views_data_export_view_retrieve($eid);
  $view->set_display($export->view_display_id);
  $view->display_handler->batched_execution_state = $export;
  $view->display_handler->remove_index();

  // Get path to temp file
  $temp_file = $view->display_handler->outputfile_path();
  file_unmanaged_copy($temp_file, 'public://denmark.xml', FILE_EXISTS_REPLACE);
}

It starts to generate the file correctly when I go to domain.com/denmark

dvm_reports module#2 for Sweden (I copied the denmark module and renamed it from "dvm_reports" to "dvm_reports2")

function dvm_reports2_views_data_export_batch_alter(&$batch, &$batch_redirect) {
  $view = views_get_view($batch['produkty_json']);

  // Add in another operation that will store the file on the server in a location
  // of our choosing.
  $batch['operations'][] = array(
    'dvm_reports2_views_data_export_batch_finish', array($batch['eid']),
  );
}

function dvm_reports2_views_data_export_batch_finish($eid) {
  $export = views_data_export_get($eid);
  $view = views_data_export_view_retrieve($eid);
  $view->set_display($export->view_display_id);
  $view->display_handler->batched_execution_state = $export;
  $view->display_handler->remove_index();

  // Get path to temp file
  $temp_file = $view->display_handler->outputfile_path();
  file_unmanaged_copy($temp_file, 'public://produkty.json', FILE_EXISTS_REPLACE);
}

it starts to generate the file correctly when I go to domain.com/sweden

Problems:

I would like to combine those two modules into one but I don't know how to do it.

Please advice if you can

I suppose you should be able to merge them into one module by first checking if the view is available in the batch (stop otherwise) and provide the filename within this check. Code has not been tested though.

function dvm_reports_views_data_export_batch_alter(&$batch, &$batch_redirect) {
  // Check for Denmark.
  if ($view = views_get_view($batch['produkty_denmark_xml'])) {
    $filename = 'denmark.xml';
  }
  // Check for Sweden.
  elseif ($view = views_get_view($batch['produkty_json'])) {
     $filename = 'producty.json';
  }
  // Check for Norway.
  // ... Code goes here

  // Leave if nothing was found.
  else return;

  // Proceed if something was found.

  // Add in another operation that will store the file on the server in a location
  // of our choosing.
  $batch['operations'][] = array(
    'dvm_reports_views_data_export_batch_finish', array($batch['eid'], $filename),
  );
}

function dvm_reports_views_data_export_batch_finish($eid, $filename) {
  $export = views_data_export_get($eid);
  $view = views_data_export_view_retrieve($eid);
  $view->set_display($export->view_display_id);
  $view->display_handler->batched_execution_state = $export;
  $view->display_handler->remove_index();

  // Get path to temp file
  $temp_file = $view->display_handler->outputfile_path();
  file_unmanaged_copy($temp_file, 'public://'. $filename, FILE_EXISTS_REPLACE);
}

There might however be a bigger problem with your module. I cannot see your hook menu implementation, but if anonymous users are also able to access domain.com/denmark they could DDoS your site. Prevent that.


Boost plus Cloudflare Can we use Boost together Cloudflare?

I am curious whether using both can be enabled on the site, and whether doing so will actually improve performance.

I currently use Boost and Cloudflare together on a medium sized site, I don't have any current performance figures to show you but there is a substantial improvement in performance and scalability by using the boost module with the cloudflare service. I don't use the cloudflare module itself as it only allows you to submit Spam reports & ban/whitelist IP addresses.

I use the boost module and have then setup my account on cloudflare.com to cache static assets like images etc
Boost on its own does a great job of serving more pages faster. However as my site has a lot of static assets and that is primarily why i use the cloudflare service.


Spamicide field still visible To prevent spambot making fake user accounts I've installed Spamicide.

I've enabled the module Spamicide (7.x-1.0-beta3) and enabled the field for form_id user_register_form, filled in a Spamicide directory and chose a custom FORM FIELD NAME.

Now when creating a new account I still see a empty field with a description:
"To prevent automated spam submissions leave this field empty". I was expecting that this was hidden by CSS?

Also the directory name I've setup can't be found, is it not created by itself?

The flooding of spambots creating fake accounts is stopped, but the empty field and belonging message looks stupid for real users.

Can you tell me if I did setup something wrong or if this could be an bug?

It's not really a bug. Simply hide it in your theme instead. Just try to use technique a bit less obvious than display: none; as many bots know it already. Note that newest version of Spamicide module (7.x-1.0-beta3 at the moment of posting) does not even provide CSS file. All it does is:

/**
 * #post_render callback on the spamicide field. This will wrap the field
 * in a div so it can be hidden with CSS.
 *
 */
function _spamicide_field_post_render($content, $element) {
    return '
' . $content . '
';
}

See line 81 of spamicide.inc.


How to enforce users to input user account's fields after user registeration? I'm useing D7.

What I want to do is...

Step1: Let users register only by inputting their email address & password on  user registration form (http://www.my_website.com/user/register)

Step2: Redirect them to user account edit page (http://www.my_website.com/user/user id/edit) after their registration. And then, enforce them to input the rest of fields such as [first_name] & [hobby] on the edit page.

The 'step1' was able to be done by using  'Email Registration' & 'User registration password' module. And I think I can redirect users to the edit page. But I don't know how to enforce them to complete the rest of fields in edit page.

I want to do this without using Profile2 module. Does anybody have idea to do that?

I'm really sorry if this is an entry-level question to you. But I'm very new to Drupal and I have been struggling with this for a week, but I couldn't find the way. Please somebody help me!

Thank you!

Try using Rules. You could add a new field into the users' accounts that is Completed Profile Fields and it could be a single boolean or possabily a multi-value field.

Then your rule could check:

If login, or page load -- has user completed profile fields? If yes, continue to any page -- else show a profile form page (not necessarily their account page).
I'm not sure it would be easy to do this globally, or test the profiles have been filled prior to going to a /node/add page for instance.
After filling in the profile values the Rule could update the user account field completed profile fields to True.

If you don't want users to see this completed profile fields field -- you can install and use Field Permissions.

EDIT

If you dont want the user to see this special completed profile fields but still want the rule to update the value you may need to set the uid of the user updating this field. I do this usually by creating a fake user for the system called like mysite-system-user and give him a special role called system role for instance.


How to print a taxonomy term's field value alongside a Views grouping header? In Drupal 8.4.4 I have a "Living Things" taxonomy vocabulary. One field on the terms in the vocabulary is "Most Common Name", with machine name field_most_common_name. On my "Animalia" term its value would be "Animal".

In Views, I have a "Taxon Media" view which lists media related to the taxonomy term. I display it in a block on the taxonomy term's pages themselves (not on nodes). In the view I group media by another field, "Primary Taxon", which is a reference to the term. It prints on the page as the grouping heading (e.g. "Animalia").

How can I print the value of my "Most Common Name" field next to that title? i.e. "Animalia Animal".

I have made a template, views-view-grouping--taxon-media.html.twig, cloned from the one in the Classy template, tested that works, then added the 4th line and tried a few other things such as content.field_most_common_name, but cannot get the field's value to display:

    {{ title }}
    {{ field_most_common_name }}

{{ content }}

Thanks to Mario's helpful hint in the first comment, I was able to do this in the View and not in the twig template:

In the FIELDS section of the View, add "Most Common Name" as a field.
Select "Exclude from display", because I only want it in the title, not the results themselves.
(3. Select "Link to the Taxonomy term", because I want it to be a link.)
Next to "FIELDS", under the "Add" drop-down menu, choose "Rearrange".
Drag "(field_primary_taxon: Taxonomy term) Taxonomy term: Most Common Name" above "Media: Primary Taxon" > Apply
Click "Media: Primary Taxon [hidden]" field
Check "Override the output of this field with custom text"
REWRITE RESULTS > and copy the required tokens from the "REPLACEMENT PATTERNS" list, and paste into the "Text" area. I also inserted brackets outside of those tokens, so my Text area looks like this:

{{ field_primary_taxon }}
(
{{ field_most_common_name }}
)
Apply > Save > Clear all caches if necessary > Refresh the page.
Title now in my example is "Animalia (Animal)". "Animalia" and "Animal" are links to the taxonomy page.


Layouts versus theme templates When I add a layout to my theme using .layouts.yml, it will show up in the display settings for various entities (for example, paragraphs and blocks).
I can then set the display to be of a certain layout, but doing so gives me template suggestions. When I try to implement one of the template suggestions, it doesn't even use the template in themes/custom//templates/.

So I am a little confused. Which should I use?  It's easy enough to use a layout, but I feel like I should use templates more often than layouts.

I do remember reading that layouts were added in Drupal 8.3 as experimental module, so it sounds like templates existed before layouts. It sounds like it's up in the air as to which one is better to use, but I just wanted some more opinions.

Before Field Layout was added to core this functionality was provided in contrib by Display Suite. With these modules you can configure layouts in UI instead of theming them in node/block/paragraph templates. This is not about one versus the other, this is more about the skill level needed to change the layout. You can use both methods at the same time. However, when you install one of these modules they add a new layer to theming, so you need to adjust any existing node/block/paragraph templates which changed the field layout.


Using putty to patch to cloze module I use Putty to apply cloze module patch. Here are my steps:

I go to this directory: sites/all/modules/contrib/cloze
I save the patch: wget https://www.drupal.org/files/issues/cloze-report_form_quiz_compatibility_fixed-2216049-1.patch
Save as: cloze-report_form_quiz_compatibility_fixed-2216049-1.patch
I apply patch: git apply cloze-report_form_quiz_compatibility_fixed-2216049-1.patch (nothing happen. no error)
I check the status: git status

Result:

  fatal: Not a git repository (or any of the parent directories): .git

How come?

After your step 1, make sure to initialize the GIT repository, which will add the .git directory, subdirectories and files that store your repository data.

To do so, just use command git init while in your directory sites/all/modules/contrib/cloze.

If you're new to using GIT with Drupal, you may want to look at the community documentation located at Building a Drupal site with Git (+ its child pages).


How do I add different URL to the HOME link in the breadcrumb for the authenticated user I'm using breadcrumbs in my drupal 7 website.

How and where do I change the URL for the [home] breadcrumb, based on role/authentication of the user - when the authenticated user signs in, they are taken to role based page, when they hit the home breadcrumb, I want them taken back to their role-based home page/url, not the main/anonymous user home page.

I think I want to add a preprocessor function to the template.php that will say--> function themename_breadcrumb() {if auth_user home url is $this else $homeURL is $this}.  How would I write this?

You could use the theme_breadcrumb hook and change the link for the home breadcrumb by checking the role of the currently logged in user.

I've put some sample code in below, but I am assuming that your breadcrumbs array will always have the 'Home' breadcrumb as the first element.

This code should go in template.php

function yourtheme_breadcrumb($variables) {
  global $user;
  $breadcrumb = $variables['breadcrumb'];

  if (!empty($breadcrumb)) {

    // Check if the user has the right role.
    if(in_array('your_role', $user->roles)) {
      $breadcrumb[0] = l('Home', 'path-to-role-homepage');
    }

    $output = '
' . t('You are here') . '
';
    $output .= '
' . implode(' » ', $breadcrumb) .'
';
    return $output;
  }
}

Hope that helps out.


Module not returning echoing or printing variable I'm writing a module to change a user's shopping cart order ID based on a stored value from their profile, which cannot be edited from the users.

In the hook call to commerce_cart_order_id I tried the following code, but it doesn't change the order ID. Printing $orderidentifier with krumo() shows 1; if I change return $orderidentifier; with return 1;  my cart changes just as I'd expect it to.

global $user;
$user_full = user_load($user->uid);
$orderidentifier = $user_full->field_currentcartorder['und'][0]['value'];
return $orderidentifier;

Can anyone tell me what I'm missing?

fixed it I had to add an $orderidentifier = intval($orderidentifier); to convert it to an integer so the hook I was calling could understand it


How can I adjust the css within fusion theme based on the size of the screen? I'm using the Fusion theme for its responsive components but there are some things I want to tweak on the different layouts based on the screen size of the device viewing.

How can I apply style changes to say the phone layout, but not change the desktop and tablet layouts?

As a working example, lets say I wanted to accomplish the following:

/* Desktop + Tablet */
h1 {
  color: red;
}

/* Phones */
h1 {
  color: blue;
}

Are there selectors I should be using to accomplish this type of fine tuning?

You might find this post on media queries and width attributes useful.


How can I add a real name field beside username to user information? I want to add a real name field beside the default username when I creat a new user in admin/people/create. How can I do this?

I have checked the RealName module but is not doing what I need.

Simply add a textfield (or two, if you want first/lastname) to your users at admin/config/people/accounts/fields. That will allow them to enter their realname and it will be displayed on the user profile page.

And if you want to display that name in various places (like node author), that's exactly what Realname module is for. It allows to configure the displayed name based on tokens (which can either be profile fields or user fields).


Is it possible for 3rd Party Script to Create Users Our company has many systems that require for users to have user names and passwords.  We have been able to use SAML to cut down on the number of accounts we must manually create.  With that said, we do currently manually create Drupal users.

Would it be possible to have an "external script" provide Drupal with the variables it needs to create a new user.

Example:

External system collects user information in one spot.
1) User is created in Drupal according to data passed
2) Users are simultaneously created in other systems.

If it were not Drupal, I would google "API" for the system but with Drupal, I think API can mean a lot of different things and I was not able to easily find anything that might point me in the right direction.

And also it's very simple to create users in D8 by program:

$newuser = \Drupal\user\Entity\User::create([
          'name' => $name,
          'pass' => $pass,
          'mail' => $mail,
          'status' => 1,  // or 0 if inactive
          'init' => $initmail,
          'created' => time(),
          'login' => 0,
          'access' => 0,
        ]);
      $newuser->addRole("myrole");
      $rc = $newuser->save();
      if ($rc == SAVED_NEW) {
    ...whatever...
    }

For bootstrapping external scripts, you can look i.e. here: Bootstrap from external script


What's the syntax of drush generate --answers argument? So I am trying to automate theme creation using drush.
There is no documentation on how to fill the --answers argument there
https://drushcommands.com/drush-9x/core/generate/

I have tried:

drush generate theme --answers='{"Theme name":"test", "Theme machine name":"test", "Base theme":"Classy"}'

to no avail:(

Finally found it:

drush generate theme --directory themes/custom --answers '{"name": "test", "machine_name": "test", "base_theme": "Classy"}'

in the absence of documentation, you'll find the needed json keys in the sources of drush code generator:

/sources/vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Theme.php

in the "interact" method


Show a product field programmatically I created some fields such as Color called field_color (taxonomy terms) in the product content type but whatever I do, when I create a product and set the field_color, the color name doesn't show up on the product page. I also tried to create fields programmatically with hook_install and hook_schema_alter but to no avail. Maybe I'm doing something wrong as I have never created any fields/schema before.

Here's how you create a term reference field to a CONTENT_TYPE:

Create a taxonomy vocabulary called, say, "Color" at admin/structure/taxonomy/add.
On admin/structure/taxonomy, click "add term" next to your new vocabulary.
Add terms, such as, say, "blue", "red", etc.
Go to /admin/structure/types/manage/CONTENT_TYPE/fields
Add a new field called, say, "Color", and, set its "field type" to "term reference". Select an appropriate widget, such as "select list".
Go to /admin/structure/types/manage/CONTENT_TYPE/display and set the field's display to, say, "link". You can try different display options, such as "plain text" too.

Hope that helps.

Appendix:

To create a node and save this field programmatically, follow this example, which has instructions for saving term reference fields.


Contextual filters multiple value title I've added title override %1, to contextual filter. Filter uses taxonomy to get nodes.

If I open page "catalog/1" I get title from term1 with all the content
If I open page "catalog/2" I get title from term2 with all the content
But if I try "catalog/1+2" I get title "No name" and the content for both terms.

How to define page title as title of first (any) term in the filter?

Upd it appears that there's a problem with title override. If I add title override %1, then I have "No name" title for multiple terms...

Go to your View. In Contextual filter configuration >> More >> Check "Allow multiple values". So if selected this, users can enter multiple values in the form of 1+2+3


Why does Drupal url alias field allow apostrophes and passes validation? In the node creation form, when a user unchecks the "Automatic alias" checkbox, the user can put apostrophe and other punctuation marks, which is not good in a URL.

How can I prevent this from happening?

Use hook_form_FORM_ID_alter() to add your own validation function to node edit forms. In this validation function you'd check for characters that you want to allow/deny, and throw a form_set_error() on that field if there's a problem.


Does [Cache blocks] in Performance means that blocks generated by Views are also cached? I am working on an old Drupal 6 project.
My goal is to boost the performance of the website as much as I can.
Among other things I have done, I have already enabled cache

Configuration > Development > Performance

My question is, does [Cache blocks] in Performance means that blocks generated by Views are also cached or I have to enable caching inside Views?

In D6 views caching you have two kinds of options

Cache your query results -- Length of time your raw query results should be cached
Rendered Output -- Rendered HTML Output to be cached

In Block Cache in Performance settings

Block Rendered HTML Output to be cached which will be same as view setting.

For best performance you should use Views Caching option since it provides query level caching as well as rendered output caching.


Add classes to the menu item ? In hook_preprocess_menu(), I want to add custom classes to the <li> tag.
I tried the following lines of code, one at a time.

$item['attributes']->addClass('section');
$item['attributes']->setAttribute('class', array('section'));
$item['attributes']->setAttribute('class', 'section');

In any case, this is the HTML markup I get.
<li class="Array class">

How do I add the desired classes?

Assuming your theme extends Classy, you can add a menu.html.twig file in your theme to override the menu twig used:

https://api.drupal.org/api/drupal/core%21themes%21classy%21templates%21navigation%21menu.html.twig/8.6.x

This block here:

{%
  set classes = [
    'menu-item',
    item.is_expanded ? 'menu-item--expanded',
    item.is_collapsed ? 'menu-item--collapsed',
    item.in_active_trail ? 'menu-item--active-trail',
  ]
%}

Simply add a new line:

{%
  set classes = [
    'menu-item',
    item.is_expanded ? 'menu-item--expanded',
    item.is_collapsed ? 'menu-item--collapsed',
    item.in_active_trail ? 'menu-item--active-trail',
    'section'
  ]
%}

If your theme does not use Classy as a base, then you have to refer to the Stable theme twig file which does not do this:

https://api.drupal.org/api/drupal/core%21themes%21stable%21templates%21navigation%21menu.html.twig/8.6.x

In this case, you would have to add the set block within the for item in items loop just like the Classy file does, and add addClass(classes) method on the li item:

{%
  set classes = [
    'menu-item',
    item.is_expanded ? 'menu-item--expanded',
    item.is_collapsed ? 'menu-item--collapsed',
    item.in_active_trail ? 'menu-item--active-trail',
    'section'
  ]
%}
<li{{ item.attributes.addClass(classes) }}>

This will add the 'section' class on every single li in the menu though, so, if you only want it to apply to the top level menu items for example, you could do:

{%
  set classes = [
    'menu-item',
    item.is_expanded ? 'menu-item--expanded',
    item.is_collapsed ? 'menu-item--collapsed',
    item.in_active_trail ? 'menu-item--active-trail',
    menu_level == 0 ? 'section'
  ]
%}

Additionally, if you only want this to apply to a particular menu and not all menus, then your Twig file needs to be named menu--MENU_NAME.html.twig. Clear caches to see any changes.


Drupal modules to display external RSS feed what Drupal modules should be installed and enabled to display external RSS feed? I mean not default Drupal Aggregator module, but another, more flexible way to display feed in any page as content. (I had all this preconfigured, but a long time ago)

Feeds (previously FeedsAPI) is the one you want. Here is a quote about it (from the module's project page):

Import or aggregate data as nodes, users, taxonomy terms or simple database records.

One-off imports and periodic aggregation of content
Import or aggregate RSS/Atom feeds
Import or aggregate CSV files
Import or aggregate OPML files
PubSubHubbub support
Create nodes, users, taxonomy terms or simple database records from import
Extensible to import any other kind of content
Granular mapping of input elements to Drupal content elements
Exportable configurations
Batched import for large files


Adding Extra weight to order total Am working on an ecommerce site and am using ubercart module for that. Now am stuck with an issue which is ' if the weight of order total is >=1kg, i want to add an extra 150g to the order total and final amount calculated should include this extra grams aaded. for example if i have an order for a product worth 1kg, in the checkout page the final weight of order is 1.150 kg. but the product weight should not be increased.only the final order has an extra weight added. can anyone help me to solve this issue?

Thanks in advance..

Using code we can calculate total weight using product quantity and weight from uc order. Then its possible to add additional weight according to your conditions and pass the calculated total weight according to your need.


drupal 7: hook intercept url file requests located within the "Public File System Path" For Drupal 7 when going to: admin/config/media/file-system you can set up both a Public and Private File System Path.

Is it possible for files that are within the "Public File System Path" that when they are directly accessed via url that a hook could intercept that file request and decide based on the users role whether to allow or send them to a goto like (drupal_goto('user', array('query' => array('destination' => $pre_alias)));)

I know that the hook_file_download can intercept file requests for private files but if possible I don't want to have to spend this extra time setting up a private area.

Not as standard, no.

Drupal's .htaccess file has these conditions in it for the main index.php rewrite:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Which basically means requests for physical, existing files are passed through without Drupal's involvement.

To change that behaviour you'd need to override those conditions, either in the root .htaccess or one underneath the files folder itself. For nginx you'd be doing basically the same thing, except the vhost's config file would be the place for the rewrite logic.

Then you'd need to implement a menu callback at the path files which dealt with all incoming requests for files. That callback would invoke a custom hook, which your module(s) would consume to make decisions about whether or not that particular file should be downloadable. If so, you'd invoke a file pass through, if not a 403.

Long story short, it's not a good idea - you'll put a large amount more strain on your server with all those extra bootstraps (every CSS file, every image, every everything). What you're describing is the private file system, it would be much more palatable to use that.

The public file system is designed to be just that - public.


Using user_access() on Custom Node Type How can I check if a user has access to create a new node of a custom node type?

In 'admin/people/permissions' I have an item named "Custom Type: Create new content" and it is enabled for authenticated users.

How can I use user_access() to verify against "Custom Type: Create new content"?

Perhaps I'm missing something, but noting that using exactly the text 'Custom Type: Create new content' does not work with user_access, at least not for me.

Instead, use the machine value of the permission. One way to get that is to look at the user permission page, and view the checkbox value for the permission.

For example, instead of this:

if (user_access('Basic page: Edit any content'))

use this

if (user_access('edit any page content'))

To find the definition of the machine name, look in the .module file of the module that defines the permission.


How to create a custom payment page attached to a user account's form I am on Drupal 7 and I am building an ads website in which people can buy credits via their account form. I am not using Commerce or Ubercart for very complex reasons that would be a bit long to explain.

So lets move forward.

Users will use the credit that they buy to make payable actions on their content, such as making a content sticky.

1. What I already did :

Now a user who is connected to his account can select the number of credits to add to his balance. And the balance will be added that amount of credits.

And all the payable action on the ads decrease the balance of the concerned user.

So to say that the system works fine.

2. What I need to do now :

I set up field to let the user choose the type of payment his wants : PayPal or Credit Card.

How can I create a payment page without programming ?
How can I make people really see a payment page ?
How can I make that payment page appear before the users saves the
account forms ?

These are the things that I really need to know.

Anybody know how to ?

I think that this site will tell you what to do:

Setting up payment methods

You shall download one of the modules to get a list of services.


How to postpone access check to theme hooks? I am trying to hide only a few fields for non-authenticated users, so I would like to bypass access check and check the permission in theme's template files and hide these fields accordingly. I am using Nodeaccess to control each node's permissions.
How could I bypass the permission check before theme_preprocess_node is called? I think after that I could use nodeaccess_node_access to check the permission manually.
update
I found it easy to bypass the permission check by implement the hook_node_access and return NODE_ACCESS_ALLOW for all, but I cannot use Nodeaccess to check permission later, module_invoke('nodeaccess', 'node_access', $node, $op, $account) returned nothing (NODE_ACCESS_IGNORE).

Take a look at the Field Permissions Module:

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

  Features

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

EDIT

Based on comments, either create a module using this or add this to a template.php file and adjust as necessary:

function THEME_OR_MODULE_NAME_node_view_alter(&$build)
{
    global $user;
    if($user->uid == 0)
    {
        if($build['#node']->nid == 1) // add node id's you want hidden here
        {
            if(isset($build['field_image']))
            {
                unset($build['field_image']);
            }
        }
    }
}

This example will hide the field_image field on the node id = 1 only for anonymous users. Use the machine names for the fields found on the manage fields tab of the content type.

If you prefer a UI ready option, you can look at the Content Access Module

  This module allows you to manage permissions for content types by role
  and author. It allows you to specifiy custom view, edit and delete
  permissions for each content type. Optionally you can enable per
  content access settings, so you can customize the access for each
  content node.


Search Form block not displaying in Home Page I am using drupal 7.9 with the Bartik theme.
I have configured 'Search Form' block in header area.

It is displayed on all pages, but not in the home page.

Then I customized the page.tpl.php file with the following snippet:

if($page['header']['search_form']):
  print render($page['header']['search_form']);
endif;

But this doesn't solve my problem.
Does anybody know how to solve this?

have you looked at the block settings to see if it has something like "display on these pages" or "don't display on these pages" checked and if so it's saying to not show it on ?


Display multiple timezone values from a single date/time entry In Drupal 7 Views Date/Time field, is there a way to generate multiple timezone values from a single event date, with start and end values?
For example, if an event is entered into the start/end Time fields with 4:00pm to 5:30pm (using PHP date format "g:ia"), is there any way to decrease or increase the rendered values to reflect different time zones, as in "4:00pm to 5:30pm EST / 1:00pm to 2:30pm PST"?

I guess that could be done using jQuery (or a separate module that does the same) but to me, the easiest way would be jQuery.
So you load your date/time field a second time in your view, "Rewrite the output of this field" so you can give it a different HTML structure and different classes name e.g.

GMT +10:00

Here's a link on how you could do that: getTimezoneOffset via javascript
The great thing with "getTimezoneOffset" is that it accounts for daylight savings time as well.
Example of your Views Field:


How to build and embed the output of a Message entity created by the Message module? I need to, given the mid (= Message ID), generate the Message content for a specific view mode. How can I do this?

It seems to be complicated by the fact that a Message is an entity (created by the Message module), and there are multiple Message types, each of which have their own fields and rely heavily on tokens.

I'm hoping for something simple like:

$message = message_load($mid, $view_mode);
$output = drupal_render(entity_view($message));

... but everything I've found that loads Messages seems to rely on weird wrappers and stuff and I haven't been able to find a working solution no matter how much I tinker with it.

Got it.

$message = message_load($mid);
$build = $message->view();
$build += array(
  '#theme' => 'message',
  '#entity' => $message,
  '#view_mode' => 'full',
);
$output = drupal_render($build);


Why are my custom fees disappearing from my orders? I've set up my shop so that I am able to create an entire order programmatically. Line items register fine. However, I can't get fees to stick through the ordering process. I'm using the following code:

$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$fee = 'machine_name_of_fee';
commerce_fees_apply($order_wrapper, $fee, 500, 'USD');
commerce_order_save($order);

I then push the order through to checkout so that I can manage it on the backend:

commerce_order_status_update($order, 'checkout_checkout');

I get no errors, but when I check the order in the admin backend, there are no fees that show up. I've double checked that the machine name is correct, and have even confirmed that the commerce fees module returns as 'empty' if the machine name doesn't exist. This leads me to believe that the fees are indeed being added, but that they are being removed at some point after a checkout stage. Is there a specific stage where fees have to be added in order to stick to and affect the order total? Am I implementing commerce_fees_apply() incorrectly?

You need to apply commerce fees after "checkout_checkout" status and also move order to next status i assume "checkout_review".

commerce_fees_apply() is a rule callback and you are calling it directly from your code.This function first removes all fee type line item and then adds add the same and expects values from rules config.

I tried this and it worked.

module_load_include('inc','commerce_fees','commerce_fees.rules');
$order = commerce_order_load(3);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$fee = 'test';
commerce_fees_apply($order_wrapper, $fee, 500, 'USD');
commerce_order_save($order);
commerce_order_status_update($order, 'checkout_review');

But curious to know why you are writing code for this.You can easily achieve this using rules.


How do I provide a field storage definition for hook_entity_bundle_field_info? The documentation says:

  Bundle fields either have to override an existing base field, or need to provide a field storage definition via hook_entity_field_storage_info() unless they are computed.

How can I do that?

I tried something like this:

/**
 * Implements hook_entity_field_storage_info().
 */
function km_mod_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
  if ($entity_type->id() == 'node') {
    $definitions['field_metatags'] = \Drupal\Core\Field\BaseFieldDefinition::create('metatag')
      ->setName('field_metatags')
      ->setLabel(t('Metatags'))
      ->setTranslatable(TRUE)
      ->setCardinality(1)
      ->setTargetEntityTypeId($entity_type->id());
    return $definitions;
  }
}

/**
 * Implements hook_entity_bundle_field_info().
 */
function km_mod_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {

  if ($entity_type->id() === 'node') {
    $fields = [];

    $fields['field_metatags'] = BaseFieldDefinition::create('metatag')
      ->setLabel(t('Metatags'))
      ->setDisplayOptions('view', array(
        'label' => 'hidden',
        'type' => 'hidden',
        'weight' => 0,
      ))
      ->setDisplayOptions('form', array(
        'type' => 'metatag',
        'weight' => 50,
      ));

    return $fields;
  }
}

It does not work as intended though. The field does not appear during Form display, and when trying to save:

Drupal\Core\Entity\EntityStorageException: Table mapping contains invalid field field_metatags. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()

I've checked the field storage config yaml (by creating the field manually) and it doesn't really look any difference to how I try to configure it:

uuid: 4c6ecbd5-49b3-4305-8f47-518f76a917f7
langcode: sv
status: true
dependencies:
  module:
    - metatag
    - node
id: node.field_yaay
field_name: field_yaay
entity_type: node
type: metatag
settings: {  }
module: metatag
locked: false
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false

I have run drush entity-updates as well, with no luck.

So what am I doing wrong?

I ran into the same issue. It looks like there might be a problem with Core.

This patch attached to the issue "Hook entity_field_storage_info is broken" fixed things for me.


Searching for nodes from another site in a multisite installation I am trying to have the search function of a www.site.com return also nodes from site.com/somethingelse. Is there any way I can achieve this?

I prefer not to use Solr.

You could do that easy enough with Google Custom Search, e.g:

http://www.google.com/cse
http://drupal.org/project/google_cse

Basically can search a range of selected sites from one interface, using the power of Google search.


Should I use both caches pane and panels? this is my first post here on SE after years and years of just using the platform for researching, I hope I do it right!

On a D7 site I use several cache systems/layers, mainly filecache, views cache, panels cache and boost.

I have good results with caching the panels only, but I recently read an article (link not at hand unfortunately) that recommended to use both caches, the one for the panel and the cache for each pane at the same time.

Does this bring me any performance gain?

Or should I either use the pane or the panels cache?

If you panel already in cache, it doesn't matter that you panes are in cache, because cache of panel are alredy include panes.

But if you panel cache have lifetime around 1 hour and some panes have lifetime around 1 day (but not all) it can be usefull and take more performance to you.

So, cache of panels and panes for the same time doesn't take more effect then cache for panels only.


How to add multi nodes on a single page without using an iFrame? I came up with the Multi Node Add module to add multiple nodes to single page. But the nodes are shown on iframe.

Is there another way with which we can add multiple node on single page without iframe?

Consider using the Rules module, to insert a message with a clickable link in the Drupal Message area, whereas that link points to "/node/add" each time a node is saved.
Here is a summary of the rule to implement this:
Events: After saving new content
Actions: Show a message on the site, whereas the "value" of the message to be displayed should be something like so: Click to add another node.
This assumes you want to do this for all possible content types. If you'd want to limit it to specific types only, you'd have to add appropriate
Conditions (for the desired content types) also.


save base64 images alogside entity creation I need to save and edit entities via services like {user, nodes, products ...etc}

the problem comes with images posted form mobile apps encoded base64.

I saved the file and stored the object in session to be used in hook_services_request_postprocess_alter to be added to the entity saved by loading it again and  assign the value to the field

// in preprocess
$_SESSION['file'] = file_save_data(base64_decode($args[0]['image']),'public://test.png');

// in postprocess
$product = entity_load('commerce_product', array($result->product_id));
$wrapper = entity_metadata_wrapper('commerce_product', $product);

//$wrapper->field_field_user_avatar->file->set($_SESSION['file']);
//$wrapper->field_field_user_avatar['und'][0]['value']=(array)$_SESSION['file'];
//$wrapper->save();
entity_save('commerce_product', $product);

what missing here I have tried many answers either adding the file object to the field when creating the field nor entity saving

It works after getting file mime type here is the code sample

$data = base64_decode($args[1]['avatar']);
$finfo = finfo_open();
        $mime_type = finfo_buffer($finfo, $data, FILEINFO_MIME_TYPE);
        finfo_close($finfo);
        // get file type png. jpg
        $ext = $mime_type ? str_replace('image/', '', $mime_type) : 'png';
        $file_name = str_replace(' ', '-', $args[1]['name']);

then you we save the file using

$file = file_save_data($data, 'public://users/'.$file_name.'.'.$ext, FILE_EXISTS_REPLACE);

    $args[1]['field_field_user_picture'] = array(
        'fid' => $file->fid,
        'width' => 100,
        'height' => 100,
        'alt' => $args[1]['name'],
        'title' => $args[1]['name']
    );


New Content type formatting I have a person who wants to have feature jobs on his site.

I've already got the descrption allow full html and got WYSIWYG going so he can add pictures and descriptions beside the pictures etc. but he wants it even simpler.  He wants to have images and then a description that goes beside each image, then be able to add more images with descriptions as necessary.  He wants them to look as follows:

*image1 *description1

*image2 *description2

With description one being a bunch of text most likely bullet points.

He's wanting the image/descriptions to be tied to one another.  I'm pretty new so not sure how to do that.  I am comfortable being able to use CSS to format the content if I can create a type that ties the image/description together like this.

If you dont mind installing a new module you should check the double field module.

  Double field is a small module written to provide extensions to Drupal's core Fields. By this module you can divide your fields into two seporate parts.

By using this module you can actually tie two fields together, and by clicking on add more you will have an image and its description tied together


Drupal Isn't Finding My CSS My stylesheet is mentioned in my .info file, but it's not adding it to the page source and using it. The only style I have in Styles.css is body {background:#444}. I've tried clearing the site's cache as well as my browser's. CSS compression is off. Any ideas?

It's a theme I made from scratch.

info file:

name = PBmedia 14
description = The Site Theme
core = 7.x
engine = phptemplate

; Regions
; --------------------------------
regions[header] = Header
regions[content] = Content
regions[footer] = Footer

; Stylesheets
; --------------------------------
stylesheets[all] [] = html5reset-1.6.1.css
stylesheets[all] [] = styles.css

html.tpl.php

<!DOCTYPE html />

<head profile="<?php print $grddl_profile; ?>">
  <?php print $head; ?>
  <title><?php print $head_title; ?></title>
  <?php print $styles; ?>
  <?php print $scripts; ?>

<body class="<?php print $classes; ?>" <?php print $attributes;?>>

    <?php print t('Skip to main content'); ?>

  <?php print $page_top; ?>
  <?php print $page; ?>
  <?php print $page_bottom; ?>

page.tpl.php

  <?php if ($main_menu): ?>

    <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t(''))); ?>

  <?php endif; ?>

  <?php print render($page['header']); ?>

<?php print $messages; ?>

    <?php print render($title_prefix); ?>
    <?php if ($title): ?>
<?php print $title; ?>
<?php endif; ?>
    <?php print render($title_suffix); ?>
    <?php if ($tabs): ?>
<?php print render($tabs); ?>
<?php endif; ?>
    <?php print render($page['help']); ?>
    <?php if ($action_links): ?>
<?php print render($action_links); ?>
<?php endif; ?>
    <?php print render($page['content']); ?>
    <?php print $feed_icons; ?>

  <?php print render($page['footer']); ?>

There should not be a space after "[all]" ...
Change:
stylesheets[all] [] = styles.css
to:
stylesheets[all][] = styles.css


Memory efficient way to load large entity set for data export I'm working on an Excel exporting feature in a Drupal 8 site.

Obviously, I can load all entites of certain type like this:

$user = \Drupal::currentUser();

$entity_query = \Drupal::service('entity.query')->get('some_type');
$entity_query->sort('created', 'DESC');

$ids = $entity_query->execute();
$entites = $this->storage->loadMultiple($ids);

foreach ($entities as $entity) {
    // build some Excel row with the entity information
    // ...
}

But if you're doing this on a large entity set, you'll be running out of memory very soon. I think the reason why Drupal would run out of memory is the extensive caching involves in the entity query and loading process.

Is there a more memory-efficient way to load an indefinite size of entity set without running out of memory?

(Note: Let's pretend the Excel library is very clever and do not take up memory. That's another issue for another day.)

Batches allow heavy processing to be spread out over several page
  requests, ensuring that the processing does not get interrupted
  because of a PHP timeout, while allowing the user to receive feedback
  on the progress of the ongoing operations. It also can reduce out of
  memory situations.

  Source: Example: Batch API

You need to use the Batch API. There is no official docs for D8, but you can look at the batch_example module and the CSV Import module.

Good conceptual read, Drupal 8 Batch Processing but a bad code example.


How to use Rules to fetch domain Whois Data, parse the data and save it to fields? For a domain management website I would like to import all Whois data to entity fields.
A domain is an (ECK) entity, with the fields corresponding with the Whois data.

There are public Whois api's available, such as http://bulkwhoisapi.com/ but I'm not sure which one would best serve the import method I want to use.

How can this be accomplished?

Note: My preference is to use Rules and not create a custom module.

When you want to use Rules, you still need to have a connection between Rules and the API. The Rules module by default cannot make API requests (though some contrib module might provide it).

As an alternative I'd like to present to you, the Feeds module.

  Import or aggregate data as nodes, users, taxonomy terms or simple
  database records.

  One-off imports and periodic aggregation of content
  Import or aggregate RSS/Atom feeds
  Import or aggregate CSV files
  Import or aggregate OPML files
  PubSubHubbub support
  Create nodes, users, taxonomy terms or simple database records from import
  Extensible to import any other kind of content
  Granular mapping of input elements to Drupal content elements
  Exportable configurations
  Batched import for large files

This module is designed to perform (periodic) requests to external API's and store the data locally. Plus there are a lot of video tutorials out there to help you with this.

The downside is that feeds by default cannot save to an ECK entity (it can save into a node). The Feeds ECK Processor is currently under review and not yet ready for production. The Feeds Entity Processor might work (suggested on the Feeds ECK Processor application page), but this is unconfirmed. Or you can use Feed Rules to obtain the data with Feeds and then send it to Rules where you can attach it to your entity.

So far this seems possible. The only problem is that feeds does not accept input parameters, so you'd have to create a new feeds importer for every domain...

It is probably not the answer you were hoping for, but perhaps someone else knows how to resolve this last missing piece.


How do I show the contact form in panels? I have installed panels and Panelizer modules and used the core contact form.

There is no feature available for adding contact form in the panels.

How do I add the contact form in Panels without using the form Block module or other moudle?

Please use contact_block, because ctools use blocks please see module ctools_block in module ctools.


What if a rule doesnt fire or is interrupted because of server down etc? I have several rules that need to be fired after certain events.

When an event occurs and the rule starts execution, and something happens to the server, it may not finish.

Is there a way to make sure a rule will always execute?

I am asking for a method like a transaction occurs in MySQL. I need to be sure that a rule is executed to ensure data integrity.

To my knowledge there is no such thing as "make sure a rule will always execute?" (as in your question). However, by using the Message module, you can create your own custom "Events logging" (to register things that happened in a site).

A great sample of this you can find in Commerce Kickstart, which uses the Commerce Message module, to create such "Events logging". In this case in the format of an Order History, as shown in this screenprint (from this module's project page).

So in your case, if you'd create an appropriate events logging of all sorts of Rules related Events that you're interested in (= are critical enough?), then at least you'd have appropriate data you can use to investigate if anything went wrong.

To actually do so, for any of your Rules, you could add these Rules Actions to them:

create a "Start Rules Action"-message (as the very first action).
create a "Stop Rules Action"-message (as the very last action).

With that, for any set of Rules Actions that started executing, you can check if you have 2 corresponding messages.

Here is a variation that might work also: instead of creating such "Stop Rules Action" message, you could also use the Flag module to flag the corresponding "Start Rules Action" (the Message module creates messages as entities, so you can flag them for sure). Such flagging would indicate that the set of Rules Actions completed without problems. And to list all the groups of Rules Actions that were interrupted, you'd just have to use the Views module to report about all  "Start Rules Action" messages that were NOT flagged ... Piece of cake, no?

Attention: this covers the part related to Rules Actions, not (yet) something like "what are all Rules Events that were triggered but for which not even 1 Rules Action (= create the start-message) had started (because of some kind of interruption).


Drupal 7 - Call the default/base template implementation I am overriding node.tpl.php for a specific node (node--news.tpl.php) to display it differently in the front page. Instead of copying node.tpl.php code into node-news.tpl.php to display the node with the default rendering when we are not on the front page, I would rather prefer calling the base template implementation (node.tpl.php).

if ($is_front)
  // ...
else
  base_template(/* ... */);

Is that possible ?

Thanks,

Solution :

function template_preprocess_node(&$variables)
{
  if (drupal_is_front_page() && $variables['node']->type == 'news')
    $variables['theme_hook_suggestions'][] = 'node__news__front';
}

Then, simply edit the template file node--news--front.tpl.php

I have never tried this, but I suspect you can implement template_preprocess_node in your theme, use drupal_is_front_page, and if FALSE, remove the specific template from the $variables["theme_hook_suggestions"] array.


How to download directly to ~/.drush folder? I've created a project that is basically a drush command with a starterkit folder. I noticed the make_local project will but I haven't figured out how it does that.

I've tried the approach recommended in the answers and added a .info file and tried to hide the .profile extension by renaming it to .profile.starterkit.  Drush still thinks I'm downloading a theme.

There are three requirements:

Your project must have a .info file
Your project must have a project.drush.inc file
Your project must not have a project.module file or any sort of .profile file

If all three of these are true, then Drush will store the project in ~/.drush. If there is a module file or a .profile, then Drush will treat the project like a module or installation profile (usually storing it in sites/all/modules).

Your project was missing a .info file, but unfortunately, the existence of the profile file caused Drush to decide that your project was an installation profile, and Drush thinks that those do not belong in ~/.drush.

The user will have to specify --destination=$HOME/.drush, or move your project to the correct folder manually.


What to return from form AJAX Callback I used the examples found here as my AJAX guide.

I have a custom form field

$form['elements']['refunded']

which is entirely defined in a single line as an array.  My AJAX DIV's and callbacks work perfectly.  In the attributes field, I call a custom function that sets a CSS property.  No problems at all.

I need to duplicate this same functionality with another field on the same form.  The field is 'status' - but it is defined elsewhere and I don't know where or have access to the code where it is defined directly.

Thus in my code, I append to the array for the form field such as :

$form['elements']['status']['#prefix'] = '
';
$form['elements']['status']['#suffix'] = '
';
$form['elements']['status']['#disabled'] = myfn_disable_attendance($form_state);

When I update the attendance select field, it should update the ability of a user to change the status (i.e. is marked as attended, the student can no longer withdraw from the class).

Disabled should display the status, but not allow the user to modify the field.

The last piece is the callback that runs when the attendance select is changed, that is a single-line return:

  return $form['elements']['status'];

Which is the same as I use in the working example, however for that it is ['elements']['refunded'] which if you see above, is defined on a single line.

When I modify the attendance field, the status field disappears and displays what appears to be the return code from my function that should be setting the display option to true/false.

It appears it is not re-building the entire form field.  My call to return $form['elements']['status'] and Im thinking it may be due to it being defined on multiple lines in multiple php files.

Can anyone provide any pointers as to how to accomplish what I'm trying to do or help me identify what the code is actually returning from my callback function so I can better get a grasp on what I need to do here?

return $form['elements']['status'] is correct.

you need to create your form elements in

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

$fields = $form_state->getValues();
if (!isset($fields['status']){
   $form['elements']['status']['#prefix'] = '
';
   $form['elements']['status']['#suffix'] = '
';
   $form['elements']['status']['#disabled'] = myfn_disable_attendance($form_state);
}


Drupal Views argument menu - sending %! to end of URL Im building this project managment site that uses organic groups to sort and name projects.

So I have example.com/project/6. Where 6 is the organic groups views argument of %1.

What I am struggling to do is be able to create links that send for example 'gallery' to the end of the URL so example.com/project/6/gallery would show the gallery for project 6.

I am trying to create a global menu where all items would work for any organic group you may be within. So if you were within project 5 (http://example.com/project/5) the same menu item of 'Gallery' could be used to display example.com/project/5/gallery.

I have tried with all normal drupal menu methods but %1 is never accepted. The main thing is to be able to send for example '/gallery' to the end of the URL, or use any other method to achieve this.

Hope I have explained myself correctly.

Many thanks in advance.

Each segment of the URL is it's own argument. So to get project/6/gallery you would have two arguments.

The first argument %1 (which you already have) is the organic group, the second argument %2 would be (I assume) a content type argument.


How to allow a role to add user without adding user name, password, roles, etc I created a role. I would like the users of the role be able to add some people without entering user name, password, roles, active, etc. These people that the role will add are actually customers. When we get new customers, specific role users will login to the system and add the customers to the system and these people/customers do not need to access the system.

I did search google and i found this site link but I could not follow it.

Do you know how I can do it?

I thought about it. Here is the problem. After I add the customers, I need to be able to link each customer to another module content(e.e. xxx.com/module/add). The module that I am using it has a field which allows to select a user only exists in the system. If I create a content type 'customer' like you said, module field does not see these customers when i go to xxx.com/module/add. Module field only sees these customers if they are users of the system. Not sure how to proceed?

Other module name is simple reservation which has a field 'This reservation is for'. This field is only takes users names from the system.

sr_week.tpl.php has the below code to get the users ( i guess)

<div id="srFor">
          <?php if (($reservation["for_uid"] > 0) && ($reservation["uid"] != $reservation["for_uid"])) {
              print(" (". t("for") ." ". l($for->name, 'user/'. $for->uid)) . ")";}
              else print("&nbsp;");?>
        </div>

It sounds like these people you're adding should not be added as users to the system.  You should only add users if they are going to be actually logging into Drupal.

If you're just trying to keep a record of clients then you should store them as nodes.  Configure a new content type called something like "customer" and add and configure the appropriate fields that you wish to store about these customers.


Drupal override search form: how to debug hook failure? In the past I've always been able to override the theme form using the method mentioned http://drupal.org/node/154137.

function YOURTHEME_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'search_block_form') {
        $form['search_block_form']['#title'] = t('Search');
    }
}

However, this doesn't appear to be recognised in the template.php of my latest theme. It hasn't been an issue in the past - what is the best way to debug why the hook doesn't appear to be activated?

Clear cache.
Place some debugging code to see if the hook and then if statement is called.
Inspect the form variable, does it look correct?


How to log actual SMTP Authentication module communication with server? We are using SMTP Authentication  module. Our SMTP provider claims we are whitelisted. Configuration works. When Drupal is supposed to send email, proper entry appears in Watchdog, claiming succesful sending.

Sadly, these days only 2 kinds of email ever arrive to our users: "Account disabled" and "Account deleted" notifications, and SMTP Authentication module test email. Password restore mails, email confirmation ones, user awaiting moderator's approval etc does not.

How can we log actual communication with SMTP server and have it stored for future reference? Now we don't know if we have to look for a bug in Drupal, or is it SMTP server's fault. With real data, we could tell for sure, and fix / have fixed the part that really needs it.

Enabling "debug" in SMTP Authentication is not practical - it debugs to screen, so it breaks AJAX calls and most of these emails are password recovery or new user ones, so they are triggered by anonymous - who obviously will not see debug data.

I guess a simple answer would be to change the SMTP module's debugging output to use the watchdog, in addition to/instead of to the screen.

Unless the module offers a hook to do that you'll probably need to patch it temporarily, but if you need to debug on the live server you don't really have another option (not an easier one that I can think of, anyway).

The usual advice would be "get it reproduced on dev, then relax devel permissions temporarily for anon users to test", but of course with emails, getting problems reproduced is often hit and miss between different servers.


How to limit the number of nodes created using the Feeds module? I want to limit the number of node created by the Feeds module, it hsould be limited to 5 each time.

I've added $conf['feeds_process_limit'] = 5; to the bottom of sites/default/settings.php

I've also changed FEEDS_PROCESS_LIMIT value in plugins/FeedsProcessor.inc to be 5

But still Feeds trying to import more than 5.

Looks like I've missed something. Anybody any hints about it?

You'll also need to clear your caches after setting $conf['feeds_process_limit'] = 50;.

Alternatively, if you are just looking for a quick limiter (during development of a custom importer, for example) this trick worked for me:
Limit number of feed items to import ($conf['feeds_process_limit'] not working) (an active issue in the Feeds issue queue).


Filtered HTML does not work in field I have a field and set its input format to Filtered HTML. Its content some text within the <strong> and </strong>, which are allowed by the input format I chose.

However, when displaying the a node of that content type, the text is still displayed as plain text and the <strong> tag seems to be ignored.

What can be the reason for that?

Go to config >> content >> formats >> filtered_html

In bottom have Filter setting choose Limit allowed HTML tags add in it allowed HTML tags


Saving File Space with Drupal 8 I have a hosting account which has a maximum of 250 MB total space. I have installed Drupal 8 and I'm using the bootstrap theme and already my host has warned me that I am nearing my limit for file space. This is only going to be a small site, so it really shouldn't need that much space. Is there any way I can clear up space by deleting unused files in the Drupal 8 system?

For instance, is it possible for me to disable themes and then delete those folders? And also to uninstall core modules that I'm not using and delete those folders as well? Or are there any other ways I can clear up space?

If it is not possible then I will probably switch to using Drupal 7, which would be my 2nd option.

While you could uninstall and delete core modules, I wouldn't recommend it.  They will be restored during updates and you'll have to constantly be vigilant to not go over your space limit.

Over time, the size of the site will probably grow slightly due to additional updates, and you may add files of your own (images, etc.) that also increase the site's size.

Drupal 8 requires significantly more space than Drupal 7 and is a very tight squeeze if you only have 250 MB.  Hosting recommendations are off topic for this site, but there are many hosts that offer more file space (say, 1 GB) at a reasonable rate.  If Drupal 8 otherwise fits your needs, I would pay more to increase the disk space, but if that's not an option, go with Drupal 7 since it's smaller, even with a fair number of contrib modules.


Module Error for some content types but not for others The Error

  warning: array_keys() [function.array-keys]: The first argument should be an array in /home/vermontbiz/webapps/vermontbiz/modules/int_meta/int_meta_cck.module on line 39.
  warning: Invalid argument supplied for foreach() in /home/vermontbiz/webapps/vermontbiz/modules/int_meta/int_meta_cck.module on line 39.

The Code

function function int_meta_cck_int_meta($op, &$arg) {
  switch ($op) {
    case 'load': {
      if (!empty($arg->int_meta)) {
        $supported = int_meta_cck_supported($arg->type);
        foreach ($arg->int_meta as $key => $tag) {
          if (in_array($tag->field, $supported)) {
            $parts = explode('.', $tag->field);
            if (isset($arg->{$parts[0]})) {
             foreach ($arg->{$parts[0]} as $tmp) {
               $arg->int_meta[$key]->values[] = $tmp[$parts[1]];
              }
            }
          }
        }
      }
    }
    break;

    case 'fields': {
      return int_meta_cck_supported($arg);
    }
    break;
  }
}

function int_meta_cck_supported($arg) {
  $fields = array();
  if (!empty($arg)) {
    $type = content_types($arg);
    if (!empty($type)) {
      foreach ($type['fields'] as $name => $info) {

      //**Error below takes place in the line below but doesn't effect all content**

        foreach (array_keys($info['widget']['default_value'][0]) as $col) {
          $fields[] = $name . '.' . $col;
        }
      }
    }
  }
return $fields; }

My question is why does the line give an error to some content types but not others?

The two content types.

You're making an assumption and that is that

$info['widget']['default_value'][0]

Will always be an array. My guess is that for some fields (depending on configuration) that $info['widget']['default_value'][0] will be either NULL, FALSE or a scalar value.


How do I disable a module when Drush or the GUI doesnt work? My site just gives a WSOD and throws this error:

  Error: Unsupported operand types in sites/all/modules/rules/includes/rules.state.inc, line 620

Since I can't even get to my site now without a WSOD, and when I do a rush cc all or drush pm-disable rules I get that error via the command line, how can I disable the Rules module?

If you have access to your database, you can do it through there.

You can see all the modules enabled with:

SELECT name,status FROM system WHERE type='module' AND status='1';

You can disable a module by setting it's status to 0.

UPDATE system SET status='0' WHERE name='module_name';

For more on uninstalling stuff via drupal's db.


How to get the Commerce Product type from the order object. D7 I am unable to find the product type when looking at the order object. I have tried

commerce_order_load($order_id);

This does not give the product type and neither does

commerce_line_item_load();

I have also looked for a function to achieve this here but can't see anything to achieve this.

I am able to get the line item type it seems but not the product type, seems odd

I ended up just querying the database, here is what worked for me

$product_type = db_select('commerce_product', 'cp')
    ->fields('cp', array('type', 'product_id'))
    ->condition('cp.product_id', $product_id, '=')
    ->execute()
    ->fetchAll();


Drupal search - 2 search pages using their own settings I would like to have 2 pages:
- http://domain.com/search-1
- http://domain.com/search-2

Where search-1 is limited to results of contenttype blog and search-2 is limited to results of contenttype news.

I've been looking for contrib modules but cannot find anything.
Please help me out, thanks.

Cheers,
Wietse

First, I would consider to use Views along with exposed filters to create your special "search" pages. E.g. create a view which only lists blog entries and then add a filter for body text to it.

My next approach would be the Search API module along with the Search API Page module.

Last but not least, you always can write a module for that. ;) I would take a look at different search modules which already implement additional search pages.