how to make product with attribute which select admin and only this attributes be visible for user So i for example:
i have a commerce_product, in this product there is attributes (select list or check-boxes)

attribute: [color white]

attribute: [color red]

attribute: [color pink]

attribute: [color black]

attribute: [color green]

attribute: [color orange]

when admin select only pink, green and red, these attributes must showing for user, without [black], [orange] and [white] attributes, in select list...

How it's can make? (without multiply commerce product)
price not change if user selects black or other attributes

Thanks for any help!

You should create a Vocabulary : Color . In the voacabulary list all terms with the list of colors: blue, red , green etc
. In your Product Display field add a Term Reference field and include vocabulary color to the product display.
For Red Shirt you should select the color Red  in term reference field autocomplete or checkbox.
Similarly for other colors you should do the same.


Track One Time Login In my Drupal 7 site, when a user registers they are emailed a one time login link that they can use to set their password using this token: [user:one-time-login-url]. Is there any hook that I can use to update a field in my database so that I can differentiate users who have activated their accounts, versus those who have not clicked on the link?

I never found a solution for that. I did it always the following way:

Install the rules module (if you did not work with Drupal's hooks yet - otherwise you could use these hooks for that)
Then give an user a role like "unconfirmed" as soon as a new user account is created by one rule
Then define another rule: triggering event is "user logged in", check, if the user has the role "unconfirmed" and if so -> action "Take role away" (do not know now what the action is called in English).


Library item field doesn't show up the remove button I am using paragraphs and paragraphs library module in my drupal project. The paragraph (Paragraph A) has a text field (unlimited). I don't see a remove button on the field. I only need one item for one page but it shows up more that one fields. Is there a way to remove it?

There is no dedicated delete button. Drupals default behavior (including paragraphs) is to automatically delete every empty field at the end of the list. The empty field you see is just a convinience for faster adding of a new item.

Side node: To delete e.g. the first item of the list, remove the content and drag it to the bottom.


Is it possible to inherit theme files? I have 'Theme A' and 'Theme B'. The only difference between them is colors.css.

If I want to add Theme B, I have to copy the entire theme folder, change the info file and correct the name of the theme hooks in my .tpl files.

Is there a way I can have my second theme inherit all the files from Theme A (or just make 'theme A' use a different colors.css when user wishes to do so)?

Point of this is to make theming more easy for the end user, so that they just have to upload theme_b.info and colors.css?

If I am not mistaken, base themes do exactly what you describe.

For Drupal 7: https://www.drupal.org/docs/7/theming/creating-a-sub-theme
For Drupal 8: https://www.drupal.org/docs/8/theming-drupal-8/creating-a-drupal-8-sub-theme-or-sub-theme-of-sub-theme

In your case, you can use 'Theme A' as the base theme, and specify that 'Theme B' uses 'Theme A' as the base in the .info file. You can then override the CSS and other theme features as you wish.


How to automatically add the permission "edit" on a node to a user who is not the author? I'm in D6

I have a node type "Person" and a node type "Company"

Each node "Person" has :

an unique field-node-reference to a node "Company"
an unique field-user-reference (to a user)

So, several persons can belong to the same company

Use case :

The person P1.1 (belongs to company C1) creates a node (article)

How to automaticly grant edit permission on this article to an other person (P1.2) who belongs to the same company (C1) ?

Thank you

Install Content Access and ACL, and then use Rules to add Person 1.2 as a person able to edit that content.

You may find this question helpful: Node access by role or user, what module(s) should I use?

The Content Access module gives you role permissions at the content type and (optionally) node level. By default, node level permissions are disabled but you can enable it on a type-by-type basis.
If you install ACL module, Content Access can give you per user permissions at the content type and node level.


using jquery updated version in user edit page With jquery update module  I can use newer JQUERY version in my pages and also in admin pages I use another version, 1.9 for pages and 1.5 for admin pages,my question is DRUPAL know user edit page ( user/uid/edit)  as admin page, how can I use  updated version of JQUERY in user edit page?

I did something like

function mymodule_js_alter(&$js) {
  //$javascript['misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';

  if(preg_match('/user\/\d*\/edit/', current_path())){
    //ym($js);
    //there is exist 1.9.1 jquery file
     $path = libraries_get_path('jquery').'/jquery-1.9.1.min.js';
  // Copy the current jQuery file settings and change
  $js[$path] = $js['misc/jquery.js'];

  // Update necessary settings
  $js[$path]['version'] = 1.9;
  $js[$path]['data'] = $path;
  // Finally remove the original jQuery
  unset($js['misc/jquery.js']);
  }
}

also

function mymodule_js_alter(&$js) {

  if(preg_match('/user\/\d*\/edit/', current_path())){
     $path = libraries_get_path('jquery').'/jquery-1.9.1.min.js';
  // Copy the current jQuery file settings and change
  $js['sites/all/modules/jquery_update/replace/jquery/1.5/jquery.min.js'] = $path;
  }
}

but not worked

I found a solution: First check the path, and then replace the JavaScript file.

function mymodule_js_alter(&$js) {
  if (preg_match('/user\/\d*\/edit/', current_path())) {
    $js['sites/all/modules/jquery_update/replace/jquery/1.5/jquery.min.js']['data'] = 'sites/all/modules/jquery_update/replace/jquery/1.7/jquery.min.js';
  }
}


EntityForm custom submit handler I've attached an entityform object to content type on my site, the content is an organic group with users and administrators.

I want to extend the current emailing functionality of entityform -which currently emails an administrator, and the user who submitted it- to include the administrators for the organic group which this instance of the entityform is attached to.

As far as I can tell, when an entityform is submitted, it doesn't track which node it is connected to, it simply throws all the results for that type of form into a big pool, so I was struggling to try to create a rule that would get all the users from that organic group.

My alternative solution was to simply use hook_form_FORM_ID_alter, and add an additional submit handler to the form, and then write the email script out from there, it was mostly a last resort but that's where I'm upto.

However, this is where I'm stuck, for whatever reason, it just does not respond to my submit callback.

function mymodule_form_review_entityform_edit_form_alter(&$form, &$form_state) {

  $form['#submit'] = array(
    'entityform_edit_form_submit',
    'mymodule_notifty_review',
  );

}

I would so hope that I'm just being an idiot and getting the syntax or the code wrong to define my own submit handler, but when I dpm out the $form, it does acknowledge that there are 2 callbacks in the array. Is this a correct way to amend the callbacks for the form submit?

(Before anyone suggests Webform, I've already been down that route, and in terms of things this form needed to have, Webform couldn't do everything EntityForm can)

I managed to figure out that this is how you have to put an additional callback into the entityform submit function, hopefully this will help someone out in the future

$form['actions']['submit']['#submit'] = array(
  'entityform_edit_form_submit',
  'mymodule_notifty_review',
);


Redirecting /sites/all/files I am using Drupal 7. Is it possible to to redirect the "/sites/all/files" directory to
just "/files". Also, would it be better to just create a new directory /files and copy the files over. But, I would have to change a lot of links in my content that access those files.

With Drupal 7, you do not need to do so!
Drupal file paths are stored using stream wrappers so you can simply change the folder path in Admin > Configuration > Media File System and move the existing files to new folder and you are ready to go!

You will see public://images/my.png like paths in files table and many other locations. These are the stream wrappers used in Drupal 7.

However if your content has links hardcoded, they will not change.
Try adding the following line right below the

RewriteEngine on
RewriteBase /

lines.

RewriteRule ^sites/default/files/(.*)$ http://www.example.com/files/$1 [R=301,L]


How do I get a field value? I am using the Business Hours module. It allows you to specify two time periods per day, for the 7 days of the week. So you could, for example, say: 9 t 1 Mondays to Fridays, and 2 - 5, Mondays to Fridays.

My problem is getting access to these values as I need to expose it in a custom module. With print_r($node), I can see the following.

[field_office_hours] => Array(
  [x-default] => Array(
    [0] => Array(
      [day] => 0
      [starthours] => 900
      [endhours] => 1700
    )
    [1] => Array(
      [day] => 1
      [starthours] => 900
      [endhours] => 1700
    )
    /* Omissis */
  )
)

I have no idea how to get this as array. I know that the module requires the "Date" module, so these are probably Date fields, but how do I actually get the values as array?

$node->field_office_hours->value doesn't work.

Nevermind, this worked for me:

$node->get('field_office_hours')->getValue();


Problem adding html to blocks I seem to have a problem when adding html to a block (i'm using ckk editor), if i toggle Source it loses them html id tag. If I save the Block without toggling, it works fine, but when I go back in to edit the block afterwards, it has lost the div id tag. I have attached a pic which shows the problem in 3 steps. I have it set to Full HTML throughout.

I thinks, you must twig ckeditor config file, and set config.allowedContent = true. Please, see docs http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules

This links below can help you.

https://stackoverflow.com/questions/15659390/ckeditor-automatically-strips-classes-from-div

CKEDitor removes class names, even with the exception in config


Birthdays migrate to Profile2 guys.

I've this issue, i did migrate a user list from csv file with Migrate module to Profile2. I'd use one only value for the import with the format dd/mm/Y.  All was fine, but at the end the birthdays fields are empty.

What is the right way to import (update) my user birthdays.

Thanks!

I might be wrong but I believe (most) dates in Drupal are simply stored as 11 digit integers. The format you refer to is only whats displayed on the page. Your migration probably just needs to be moving the integer date data by simply moving the data from your source csv column into your new profile2 Drupal Field:

$this->addFieldMapping('csv_birthday_column', 'new_profile2_birthday_field');

Then you just use a Profile2 Manage Display under the Field UI to setup how you want it to look on the page such as d/m/Y.

EDIT:

If your CSV has for example "04/15/2013" as a date for a piece of content you could use PHP strtotime() in a Migration class prepareRow() function to get an integer value to save in Drupal.


Auto-Fill from on content type to another I have a content type called Point-of-Contacts, basic info for a person. (~600 nodes)

I have another content type, like a form, that has a select list of all Points-of-Contacts.  When a user selects their desired Point-of-Contact, by name from the select list, I need the rest of the info of that Point-of-Contact to auto-fill text boxes on the form.

Any ideas?

NOTE: Using Drupal 7

In my example I've created two content types with two custom fields in addition to your node reference field:

Node type: Point-of-Contact (machine name points_of_contacts)

Text field: To field one (machine name field_to_field_one)
Text field: To field two (machine name field_to_field_two)

Node type: Example (machine name example)

Node reference: Point-of-Contact (machine name field_points_of_contacts)
Text field: Field one (machine name field_field_one)
Text field: Field two (machine name field_field_one)

Then You need to create a custom module to alter node reference dropdown field to ajax dropdown with callback function.

First create custom module by following this tutorial

Second alter node reference field by implement this hook hook_field_widget_form_alter

function MODULE_NAME_field_widget_form_alter(&$element, &$form_state, $context) {

  if(isset($element['#field_name']) && $element['#field_name'] == 'field_points_of_contacts') {
    $element['#ajax'] = array(
      'callback' => 'MODULE_NAME_auto_fill_callback',
    );
  }
}

Third implement ajax callback function

function MODULE_NAME_auto_fill_callback(&$form, &$form_state) {

  $commands = array();

  if(isset($form_state['values']['field_points_of_contacts'])) {
    // get selected item/node from dropdown list
    $nid = $form_state['values']['field_points_of_contacts']['und'][0]['nid'];

    // load node by nid
    $node = node_load($nid);

    if($node) {

      if(isset($node->field_to_field_one['und'])) {
        // fill text field
        // edit-field-field-one-und-0-value represent the generated html id of the text field
        $commands[] = ajax_command_invoke('#edit-field-field-one-und-0-value', 'val', array($node->field_to_field_one['und'][0]['value']));
      }

      if(isset($node->field_to_field_two['und'])) {
        // fill text field
        // edit-field-field-two-und-0-value represent the generated html id of the text field
        $commands[] = ajax_command_invoke('#edit-field-field-two-und-0-value', 'val', array($node->field_to_field_two['und'][0]['value']));
      }
    }
  }

  return array('#type' => 'ajax', '#commands' => $commands);
}

Note: change MODULE_NAME to your desirable module name.


Why is an empty field on translated taxonomy term showing default language value? I have a list of translated taxonomy terms (title, description, link, image). Only some of the translated terms have a value in the link field. Set up as Entity translation

My view pulls all fields and displays the default language link when no value is present on the translated term. I actually do not want to see the default link. I'd like that field to remain empty if it does not exist on the translated term.

I've deselected language fall back in the language config and set the view to hide the field if empty, but I am still showing the default language field value.

Any suggestions?

You may get it to work by using the Internationalizations Views module, which extends the i18n module with multilingual support for Views.

To make Views results correspond to the language switcher, add a filter for Content Translation: User's Current Language, which is the language that an authenticated user has set in the user settings (it is NOT the same as the current browser language or the site language).

If no option for the User's Current Language is available in the filter criteria form, then verify your configuration at Configuration -> Languages -> detection and selection: The order should be URL, Default, User and not something like Default, URL, User (as mentioned also in https://www.drupal.org/node/1701854#comment-6279474).

Note: True, the Internationalizations Views module only has a DEV / Alfa version for D7, but right now there are over 37K users using this version. Therefor I think "DEV" is not a valid release qualifier for that version anymore, because +37K users can't be wrong, right?


Excluding Book children from a Custom view We have a News site that displays all news articles on the homepage and subpages that display only those items tagged with a certain Taxonomy term.  So for example we have a World News term so going to www.example.net/worldnews will only show those articles with that term.  That works great.

Now we have a request to also filter on Book Content type, so that instead of showing just Article Content nodes we want Article and Book.  For the Homepage we'd use the same sort of filter that we did for Article, and that works well.  However on the subpages, Book parents AND children are showing up.  Is there a way to make sure no children ever show up on the subpages ( but of course would still be accessible the usual way from the parent and siblings )?  I've played around with Contextual Filters but can't quite get it right.

We do have some module code written that uses this View so it may be that I need to go that route and write some code, but would love to see if a View-only solution is possible.

This can be done with Normal filter in views.

Following is the configuration of the filter UI, You need to separate the both content type in the filter with OR and in the Content Type: Book page you need to Book: Depth = 1.

Now in the following image you can see the Article and Book page titles, First one without Book: Depth =1, Second one with Book: Depth =1.

Hence, You can see the views fetches the all articles and only parents books page.


Custom Fonts in Drupal I use an Omega subtheme in my Drupal 7 site, and I'd like to change the default font to a custom font. How can I do this?

This question is over 6 months old.  The best solution now for adding custom fonts is to use the @fontyourface module.


Form has a div within it. How can I add classes to this div? There's a div called .description in a form in the site I've inherited. I want to add a another class to the div.

The div's content is created within hook_form_FORM_ID_alter(), eg:

$form['#description'] = 'Please enter your full name';

I've tried adding a classed to it like:

$form['#description'] = [
    '#markup' => '
Please enter your full name
',
  ];

But this just results in "Array" being printed.

Would anyone know what I could do add a class to this element?

That's not what you want. What you want to do is add it to the form structure like this:

$form['#attributes']['class'][] = 'my-class';

Since you didn't list an element on the form, I can only assume you want the class on the form itself. If you want to wrap an element with a div with a class on it, you can do:

$form['element']['#prefix'] = '
';
$form['element']['#suffix'] = '
';

That will wrap the entire element.


altering css / asset weight after it's been added? I'm using context add assets to add a stylesheet.

It's currently being loaded correctly based on a context; but now it's loading before my global.css stylesheet. I would like blog to load after global.css.

Is it possible to alter the weight of the blog.css stylesheet via preprocessing? If so could you provide an example?

Take a look at hook_css_alter():

/**
 * Implements hook_css_alter().
 */
function MYMODULE_css_alter(&$css) {
  $css['sites/all/themes/FUZZYGREYEDOUT/css/blog.css']['weight'] = 10;
}


How do I generate-content of a particular type with drush 9.x+ root@0a581055a6ad:/opt/drupal# drush genc 10 --types=article

  The "--types" option does not exist.

devel-generate:content [--kill] [--bundles [BUNDLES]] [--authors [AUTHORS]] [--feedback [FEEDBACK]] [--languages [LANGUAGES]] [--translations [TRANSLATIONS]] [--add-type-label] [--skip-fields [SKIP-FIELDS]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--notify [NOTIFY]] [--xh-link XH-LINK] [--druplicon] [--] <command> [<num> [<max_comments>]]

root@0a581055a6ad:/opt/drupal# drush --version
Drush Commandline Tool 10.3.4

According to the documentation this was an option with drush 8.x, but I don't see any equivalent in drush 9.x and up. What is the intended way to invoke genc for a particular node type with this new version of drush?

Yeah, it's --bundles now. That's also what the error output is telling you already when echoing all possible options.
drush genc 10 --bundles article,page


Drupal taxonomy problem I had setup my new articles directory site in Drupal 6.2 2-3 months back. You can see the article directory taxonomy in the menu block in the left side bar.
There are 26 categories in total like "Financial services, Food & Bevereges" etc. And each category has sub categories.

The problem is that frequently some categories or sub categories get automatically unchecked in the article directory menu bar. So I need to regularly count them and check them on if unchecked.

For example today I found automatically unchecked as shown in the following image which is screen shot at the path: admin/build/menu-customize/menu-articledirectory:

I'm wondering why this could be happening. Any idea?

If you are using Taxonomy Menu then definitely there is a bug in it. And here is a the Link to define the reason.


Views: How to show titles of nodes but hide link based on role In views (D7) i made a list of nodetitles that link to content. Some nodes are not accessible for anonymous users, others are. I want the view to list accessible nodetitles with a link but non-accessible titles without a link. How can i do that?
I use content access for setting permissions on individual nodes.

What if i add two fields for Title, one with a link to content and one without. Both fields excluded from display. I can add a binary (or whatever works) field in my content type telling views if visitors should have access to an individual node. Nodes that allow access should (manually) be set open with content-access. That isn't the best way because it requires two edits for every node that should be accessible, but i don't mind.

Than i can make a Views-PHP field that tests on the binary field and either displays the first title-field or the second.

Anyone can help me with some rough coding example for this?

I found it. I added a boolean field with Yes as the value for access, No for no access. This requires some careful management, as the value of this field has to equal the given access control.
But in Views everything is very easy, using the extra boolean field.
I added both Titles (Title1 being the one without a link, Title2 with link) and the boolean field. Both titles excluded from display, the boolean included.
In its settings rewrite i input [Title2], and in the empty behaviour [Title1]. That's all.


Organize node file attachments into groups I have a content type with multiple file attachments to download. Is there a module to give authors the ability to divide all the attachments into groups, writing a title for every group, just like they can reorder and name them in edit mode?
The final node display should be something like this:

Group Title 1
. File n.1
Group Title 2
. File n.2
. File n.3

I've been searching for a while and found FileTree, but it's too complicated. Files shouldn't be managed physically, just displayed in groups.

Thanx in advance.

You can use Field group module. Create multi-value field group, with single-value Group title sub-field and multi-value File field inside. That's pretty much all.


How to alert users that they have a survey / webform to complete Using D7 with the latest version of webform.  We have created several surveys and all is working fine, but a question came up in a meeting, is there an easier/automated way of sending emails to the specific users that need to complete the survey.  What we do now, is create the survey, save, then go into our email client and send out a note that a survey is ready for you to complete at whatever url.

We would like to click a button "send survey url to:" and then add the email address of the user who needs to be alerted of the availability of the survey.  They would jsut click the link and be taken to the the survey.

You can achieve this goal using Views Send module.

Create a view and add at least one column containing e-mail    addresses.
[Optional] Expose Views filters to let the user easily build list of    recipients using UI.
Add the "Global: Send E-mail" field to your view. This field provides    the checkboxes that allow the user to select multiple
rows.
Create a "Page" (or "Block") display.
Save the view, load the page, use exposed filters to build the list,    select all or some rows and then click the "Send e-mail"
button.
Fill the message form to configure the e-mail. Use tokens to    personalize your e-mail. The module provide also row-based tokens,
taken from the current row of the view. For example, if the view has
a column with the key users_name (the user name) you can use this
replacement token [views-send-users_name].
Preview and send the mail.

For more information go through the module documentation.


Most performant way to check if a user is referenced in any node of a specified type? I need to get a list of all users that have a specific role. Those users can be referenced in a multivalue field of a specific content type; some users are referenced in multiple nodes of that content type, some in none. I want to filter out all users that are not referenced in any node of that content type. Here's my current (functional) code:

 $ids = \Drupal::entityQuery('user')
 ->condition('status', 1)
 ->condition('roles', 'dozent')
 ->sort('field_name', 'ASC')
 ->execute();

 foreach($ids as $k => $id){
   $references = \Drupal::entityQuery('node')
   ->condition('type', 'angebot')
   ->condition('field_dozenten', $id)
   ->count()
   ->execute();
   if(intval($references) === 0) unset($ids[$id]);
 }

This works as intended as far as I can tell, but performant-wise it seems quite inelegant due to the large amount of database queries. Is there a better way? Can I somehow include the condition that a user must be referenced in at least one node in the first entityQuery? If not, is there a more performant way to perform the second query (e.g. a way to only search for the first reference from a node to the user, since I don't need the exact count anyway)? I'm open to other suggestions as well.

I suggest you NOT to worry about performance until it's not a real issue. That doesn't mean of course you can write any silly things you want to.
The code snippet you posted is just fine. You are using the Drupal API, which is a good thing to do.

If you really want to speed up things, to make it for example with ONE query (instead of two) you can use:

\Drupal::database()->select("..."); // With a proper dependency injection

About how to write queries in Drupal connection class there is a lot of good tutorials. If you wouldn't find one, please let me know.

However, I only would use this, if it's a REALY performance issue. It's never a good thing "having a knowledge" in your production code about your table schemes. Always start with EntityTypeManager or entityQuery (as you did).


drop-down menu not working anymore The Drop-Down menu on a site I manage has stopped working. The link is here: http://www.lslib.com/ I suspect it might be a jQuery issue but I have installed the jQuery Update module but it still does not seem to work. Any hints on what I may be missing or what needs to be fixed?

Thank you!

I see something like this in my html:

<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
window.jQuery || document.write("<script src='/sites/all/modules/jquery_update/replace/jquery/1.10/jquery.min.js'>\x3C/script>")
//--><!]]>
</script>
<script type="text/javascript" src="http://www.lslib.com/misc/jquery.once.js?v=1.2"></script>

and I imagine a browser might take jquery 1.2 instead on 1.10. I could npt find which template <script type="text/javascript" src="http://www.lslib.com/misc/jquery.once.js?v=1.2"></script> is coming from. How can I remove this?

Looks like you are getting a javascript error in your superfish.js file.

Uncaught TypeError: Cannot read property 'msie' of undefined

The $.browser method has been removed as of jQuery 1.9.

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

As stated in the Upgrade Guide you can try using the jQuery Migrate plugin to restore this functionality and let jQuery Tools work or you can use an earlier version of jQuery for your site (1.8 for example)


Price not updating on custom theme template I have a theme with a custom product display template.  I created a product display with different product variations; when different variations are selected, the price doesn't seem to be updated to reflect the product variation chosen.

It seems to be a problem with the theme as it works with standard themes.

I tried different jQuery versions and doesn't seem to be any JavaScript error. I've read somewhere that it could be the the price not being wrapped with the appropriate classes.  If that's the case, how do I fix that?

What you've heard is correct: Drupal Commerce adds classes around product fields that allow the Add to Cart form to target those rendered fields for replacement when attributes are selected. This is why in their absence you won't see prices updated at all.

The simplest way to illustrate it will be to simply look at the HTML on a site with a working theme and your custom theme to see what those classes look like.

The classes exist in the render arrays for these fields, so you simply need to ensure your theme is properly including the HTML element attributes for these rendered fields. Again, for that I'd simply advise you to look at working theme code to see how it's done elsewhere.


Services module: what is the syntax of node.index parameters? I'm trying to get the list of certain type nodes using xmlrpc and POST method. I'm constructing xml like this:

<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>node.index</methodName>
<params>
   <param>
      <value>
         <string>0</string>
      </value>
   </param>
   <param>
      <value>
         <string>*</string>
      </value>
   </param>
   <param>
      <value>
         <string>type=forum</string>
      </value>
   </param>
</params>
</methodCall>

yet in return I get nodes of various types. I guess that type=forum is bad. What is correct syntax of this parameter?

I usually call node.index this way

$nodes = xmlrpc($this->server_endpoint, Array('node.index' => Array(0,'nid,uuid,vid', array('type' => $contentType), PHP_INT_MAX)), $this->headers);

the parameters being:

Page number (usually I set it to zero and set the number of nodes per page to PHP_INT_MAX. This because I found page support buggy in a previous version, I haven't retested it recently)
Array with fields to retrieve (only that you find in the node DB table are available. Careful with it, less fields means better request speed)
Array with content type(s) to retrieve
Number of nodes in the index list per page

I dont'know how exacly goes in XML, but I think that it should be easy enough to adapt to that syntax, if necessary.


List through fieldName: illegal value I have created content type with field as List(text).
If I select any of above option and try to save it, it through "fieldName: illegal value" error.But if I modified option in below format and then try to save it. It get saved successfully.

-option1

-option2

-option3

-option4

Does list doesnot support first format? Is there any other way to resolve this without changing its format ?

You can achieve that by using hook_form_alter function.

I've tested the following code on my instance. It's working fine.

Use the following code in your custom module.

function YOUR_MODULE_form_alter(&$form, &$form_state, $form_id) {
        if ($form['#form_id'] == 'YOUR-CONTENT-TYPE_node_form') {
         $form['YOUR-FILED-NAME']['und']['#options'] = array (
       'Group1' => array(
          1 => 'Option1',
          2 => 'Option2',

        ),
        'Group2' => array(
          3 => 'Option3',
          4 => 'Option4',
        ),
    );
    return $form;
        }
    }


Custom sort with search api I have created a ViewsSort plugin that works on a normal view (like taxonomy_term) but not on a view based on Search API : it is not present when I click on "Add sort" in BO.
This sort is used to create a custom order of content types, and I use hook_views_data_alter() to provide it to views :

/**
 * Implements hook_views_data_alter().
 */
function mymodule_views_data_alter(array &$data) {

  // works on classic view
  $data['node_field_data']['inspiration_first'] = array(
    'title' => t('Custom search sort in page tags with inspiration first'),
    'group' => t('Search'),
    'help' => t('Sort content types in this order : dossier_inspiration, dossier_conseil, produit.'),
    'sort' => array(
      'field' => 'type',
      'id' => 'inspiration_first',
    ),
  );

  // doesn't work on search api view
  $data['search_api_db_default_search_content_index_content_type']['inspiration_first'] = array(
    'title' => t('Place inspiration first for custom search'),
    'group' => t('Search'),
    'help' => t('Sort content types in this order : dossier_inspiration, dossier_conseil, produit.'),
    'sort' => array(
      'field' => 'value',
      'id' => 'inspiration_first',
    ),
  );

}

Any idea ? Some sorts like Random work also on search api and I've provided the good table, I think (search_api_db_default_search_content_index_content_type).

Go to

Home  -> Administration  -> Configuration ->  Search and metadata  -> Search API

& Edit your Index Search. Then your URL will be like below. In my case it's

Content Search

/admin/config/search/search-api/index/content_search/

So I'm using

$data['search_api_index_content_search']['inspiration_first']

I think in ur case it will be

$data['search_api_index_search_content_index']['inspiration_first']

Please share your URL if didn't worked.


Images show up once, then have to clear styles folder to see again? So I'm trying to get a site setup with a template (global news), which requires Drupal 7.x, so I'm using 7.41. Anyway, I have all the modules set up and the general layout as it should be. However, I'm having a problem with getting the images to render.

It seems as though if I delete the /default/files/styles folder, the images will generate and show up on the website, however if I refresh the page the images fail to load until I delete the folder again. If I don't delete the folder I get a 403-forbidden for each image I'm trying to load.

It's weird, and I've almost driven myself crazy trying to get this figured out.

Any advice?

The fact that derived images can be fetched when they are absent from the filesystem but not when they are present indicates this is a webserver configuration issue.

The webserver rules are normally be set up so that any non-existent paths are routed to Drupal. When image thumbnails are generated they get served by Drupal, but once on disk they should be served directly from the filesystem. Check your .htaccess files (if using Apache) and somewhere there is likely to be an rule denying access to that area of the filesystem.


Remove folder from basepath of urls? I have 2 sites locally (in MAMP) both in their own folders. I need both sites to be in the web root which I can change in the MAMP settings each time Im working on a different site.

However now I need to be able to look at both sites 'head to head'. Is there any way (im thinking with the htacess file) to make both sites work at the same time?

a bit confused as to what exactly you are asking but i'll answer anyway. also, this question does not seem drupal specific.

yes... you can have both sites in the web root so to speak. however, vhosts will allow you to run both sites from any directory you want. take a look at the apache documentation on vhosts..

if you are doing your development local, you can adjust your hosts file to have sites dev1 and dev2 (for example) point back to your local development box (localhost).

as for removing the folder from the basepath, vhosts will handle this for you.

your vhost config might look lke this in httpd.conf

<VirtualHost *:80>
 ServerAdmin aasdf@asdfl.net
 DocumentRoot /var/www/html/dev1
 ServerName dev1
 ErrorLog logs/dev1-error_log
 CustomLog logs/dev1-access_log common
</VirtualHost>
<VirtualHost *:80>
 ServerAdmin aasdf@asdfl.net
 DocumentRoot /var/www/html/dev2
 ServerName dev2
 ErrorLog logs/dev2-error_log
 CustomLog logs/dev2-access_log common
</VirtualHost>


How to display the translated value of a boolean field when viewing a translated page? I have this problem with translation of a custom checkbox (boolean) field. To be specific, I'm able to translate everything but the options (Yes / No) that are shown on node view page.

I have the modules locale, i18n_nodes, and i18n_fields enabled, and translation strings imported (with corresponding context and to appropriate textgroup), and default language set to English. The translation shows correctly everywhere but on node view where it's still untranslated.

The content type is custom and is created via hook_node_info() and it's fields via field_create_field, and field create_instance.

BTW: I don't need translation of the content (every node will always have just one language and should be accessible regardless of what language the user has selected) but only of the user interface (descriptions, titles, ...). So if there's a simpler way to translate my custom fields and content types, please let me know.

Screenshot proofs that I've done everything I could:

Settings:

Edit page:

View page (note the only string that is in English but should be in Czech and should be Aktivni)

Try what's mentioned in Comment #1 of issue # 1762488, i.e:

  ... visit 'Manage Display' and switch from "Default" to "Default translated".


Creating a View feed: Do not summarize, but show whole post I've created a feed in a view, and it seems to automatically summarize the info. I'd like the entire post to be available.

How do I go about doing that?

from the sounds of it your view will be set to display teasers.

on your view edit page, under format, you have show, if set to "content | teaser" it is only displaying the teaser to display the full node click on teaser and then set the view mode to full content.


How to set a specific date (fixed value) as default value on a date field? I have a commerce order on which I have added a date field. The options for the default value are Now or Relative. How can I add a fixed default value, f.x. 20 Aug 2016?

Since, it isn't clarify about if the datefield is asking you for a PHP code or not; you can just use this:

2016-08-20

In that way the field will change that date into what you want.


The "Remove" button is not working I'm using a "managed file" to upload an image, which works fine, but if you want to remove the image by clicking on the "Remove" button, nothing happens.

 $form['logo'] = array(
    '#type' => 'managed_file',
    '#title' => 'Logo',
    '#default_value' => variable_get('logo', ''),
    '#theme' => 'mymodule_thumb_upload',
    '#upload_location' => 'public://my-files/',
    '#upload_validators' => array(
      'file_validate_extensions' => array('gif png jpg jpeg'),
      'file_validate_size' => array(0.3*1024*1024),
      'file_validate_image_resolution'=>array('100x100'),
    ),
);

I'm using a custom theme, and I just realized when I switch back to 'Seven' the button works. But what could be the problem?

function name_module_form() {
  $form['logo'] = array(
    '#type' => 'managed_file',
    '#title' => 'Logo',
    '#default_value' => variable_get('logo', ''),
    '#description' => t('Upload File'),
    '#upload_validators' => array(
      'file_validate_extensions' => array('gif png jpg jpeg'),
      'file_validate_size' => array(100 * 1024 * 1024),
    ),
    '#theme' => 'abc_thumb_upload',
    '#upload_location' => 'public://abc/',
    '#attributes' => array(
    'multiple' => 'multiple'
  ));
}

function name_module_theme() {
  return array(
    'abc_thumb_upload' => array(
    'render element' => 'element',
    'file' => 'name_module.module',
  ));
}

function theme_abc_thumb_upload($variables) {
  $element = $variables['element'];
  if (isset($element['#file']->uri)) {
    $output = '

';
    $output .= 'uri) . '" />';
    $output .= '<input type="submit" id="edit-' . isset($element['remove_button']['#name ']) . '-remove-button" name="' . isset($element['remove_button']['#name ']) . '_remove_button" value="Remove" class="btn btn-default form-submit ajax-processed">';
    $output .= '<input type="hidden" name="' . isset($element['remove_button']['#name ']) . '[fid]" value="' . $element['#file']->fid . '">';

    return $output;
  }
}


creating a new content type with a series of blocks I have just started with Drupal and I have a question regarding how content types work in Drupal. What i would like to know is how a content type can have a set of blocks attached to it?

If it helps I am trying to make a content type in which the user just gives a topic and then this content type will populate these blocks with information such as the latest news on that topic etc. But I'm unsure the best way to achieve this.

I think that what you are looking for is Drupal's Taxonomy feature.  I would start with that.  This lets you categorize your content.

After that familiarize yourself with the views module.  Items created in nodes that are associated with taxonomy terms can be listed in a views block.  So if you have a concert site you can create a "show" type with dates.  Then you can create a view/block that lists upcoming concerts.

Then when you get those two things I would recommend learning how to use panels.

For a great example of it all put together look here


Search settings: Indexing status stuck on 0% When I click Re-index site, and confirm, I get a message that the index will be indexed but it never does.

Run cron. (example.com/cron.php or go to Admin >> Reports >> Status and click "run cron")


How to show only values matching filter in a view? I have created a view, in which I apply a filter on a taxonomy term field that can contain multiple values.  This field is also displayed in the view.  Is there any way to only display those values in the view that match the filter?

For example:

Field of one node contains both terms A and B.
Filter set to select all nodes containing term A.
The view should only display A (not B) for this node.

If I uncheck the "Display all values in the same row" option, the view splits the entries, but I can't seem to get rid of the extra values.  I have also tried enabling "distinct" values and the "reduce duplicates" options; neither option helps.

Am I missing something simple?

It's most important for you now to get how Views works. Views are nothing more than (really good and elaborate) query builder. Each time you set a filter, what you are really doing is adding another condition to query's WHERE line. It does not, in any way, affect anything before WHERE - especially not list of fields to obtain.

Now, you are not first one to need this. So there is Views Filter Field module, that simply allows you to display filter's value as a field. That way if you want nodes with A, don't show the terms attached to a node. Just show a filter's value of A, and you will get what you wanted: A, but not B even if node contains both A and B terms.


Integrating a local php script into drupal block I am trying to integrate a local PHP script (a guestbook script) into a block, but the links it outputs are not correct. They point to the index.php file used from Drupal, instead of point to its own index.php file.

Is there a way to make the links point to the right index file?

Sounds like your script is expecting to run index.php from the website root directory which is already used by Drupal.  You will need to re-write the script to use a different root url or set the root url for that script.


Is there a way to make node titles longer? I am importing data which has some very long title fields in academic journals. Is there a way to lengthen the title property? Perhaps to 1000 characters?

A simple "I'm feeling lucky" on a google search for "drupal node title length" gives:

Title Length

  This module increases maximum length of node titles to 8000
  characters.


How to prevent a rule to be triggered inside a rule? I'm using the Rules module and I have two rules:

A: When flagged, 'Post a journal entry to the ledger'
B: When unflagged, 'Remove journal entry from the ledger'

Rule A includes also two Rules components with conditions that check if the journal entry is balanced:

If the condition 'balanced' is true:
 - Post journal entry to the ledger.

If the condition 'unbalanced' is true:
 - Show a warning on the page and UNFLAG the journal entry.

The problem is that I don't want the Rule B to be triggered inside rule A, which currently happens.

Theoretically I could add a condition to Rule B like 'is balanced' but I don't want to modify other rules in order to prevent the execution of a rule inside a rule.

Is it possible to prevent nested Rules from firing?

This is a workaround solution.
You could add a boolean field to your journal entry content type. Side note, you could use the Field Permission module to hide the boolean field from the add/edit form.
Alternatively, if you're not using the sticky system, you could use that instead.
So now all you gotta do is add a condition to your Unflag Rule.

Boolean is false/unchecked OR content is unsticky.

Now in your Component Action add:

Set a data value and make your boolean True/checked OR Make content sticky
Unflag node
Set a data value and make your boolean false/unchecked OR Make content unsticky

Voilà!!! your component will not trigger your unflag rule.


Drupal 7 SmugMug API Has there been any work to get SmugMug to work on Drupal 7? I am about to move forward on developing a solution, but wanted to check before I went forward. I do know there was some to work with MediaWorks, but that is a bit of a limited solution and was developed for Drupal 6.

2016 and I'm looking into this as well, now with regard to Drupal 8. I'm wondering about hosting the backend of our media assets locally.
The lure of using an external system is to get a more light weight cms and an easier migration path.
Part of our online core is a photo sharing platform similar to facebook's.
So I need something robust. I can't use Google+ because Google does whatever Google wants to do. I can't use Flickr because I can't be sure that it will be around in 3 years. So Smugmug is a logical candidate.

Anyway, for drupal 7 i found a limited media integration to insert smugmug assets the normal way: https://www.drupal.org/project/media_smugmug .
Smugmug also has an extensive api to program against. https://api.smugmug.com/api/v2/doc


Add code to  for specific content type What would be the best way to add code inside the  tag of specific content type?

Display Suite is being used for layout and we are using a custom theme. Have created html.html.twig. If I add anything to the head tags of this file, of course, it shows on all the pages.

Can we create a separate template such as html--content-type.html.twig then add the code there?

If not what would be the Drupal way of adding this code to the head tags for only specific content type?

<script async
   src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
   <script>
     (adsbygoogle = window.adsbygoogle || []).push({
          google_ad_client: "ca-pub-3********",
          enable_page_level_ads: true
     });
</script>

The quick way

and maybe some will call it dirty way would be to add in your THEMENAME.theme file

function THEMENAME_preprocess_html(&$vars) {
  $node = \Drupal::routeMatch()->getParameter('node');
  if ($node instanceof \Drupal\node\NodeInterface) {
    // You can get nid and anything else you need from the node object.
    $vars["content_type"] = $node->bundle();
  }
}

and then in your html.html.twig

{% if content_type == "page" %}
  <script> ... </script>
{% endif %}

alternatively

you can just put it in a .js file and include like this

function my_module_preprocess_html(&$variables) {
  // To get around the issue of D8 core escaping inline js we cram our js
  // file into a twig variable for printing "raw" in "html.html.twig" like so:
  // {{ my_module_script|raw }}
  $variables['my_module_script'] = '<script type="text/javascript">' . file_get_contents(dirname(__FILE__) . '/js/script.js') . '</script>';
}

as described in this comment

proper way is probably to

Define a library and then to attach it following this guide


Wrap a single html tag around each block that's generated from a single view I'm sure this isn't difficult, but I can't seem to figure it out.  I have about 10 block displays generated from one view that needs a single html wrap (Setting the css property in the view itself is not what I'm looking for).  Devel themer module is suggesting block--views.tpl.php, however that obviously affects all blocks generated by views.  I assume a preprocess function would be best. The function below works, but I need to target a specific view.

Thanks in advance.

  function mytheme_preprocess_block(&$variables) {
    if ($variables['block']->module == 'views') {
      $variables['classes_array'][] = drupal_html_class('semester-container');
    }
  }

The answer suggested by madhurjya is correct, but I would point out that it is possible to create a template that is applied to all block displays of a certain view. E.g. for a view Blog with Unformatted type of output you can use views-view-unformatted--blog--block.tpl.php to alter all blocks only from that view.

Explore the Theme:Information in the Advanced settings of a view to see all your options.


How can I make changes to "people" page? Drupal have a list of users with following link - my_site/admin/people
I have some boolean field for every user and I want to show on this page users, who have true value of this field.
How can I manipulate the content of people page.

Easiest way to do this:
enable Administration Views, this would provide you with a view for "/people" page.

  Replaces administrative overview/listing pages with actual views for
  superior usability. Filter users by name, ban/blocked status, or user
  roles.

Use a filter setting boolean field to "true" or expose this filter to allow admins to filter people by "true" or "false"


From my child theme, how can I remove a library loaded by the parent theme? I have hit an issue which I think is quite unusual or peculiar when settingup a child theme.

A commercial parent theme I have bought loads the Slick library like this in its theme.libraries.yml:

slick:
  version: VERSION
  css:
    component:
      css/vendor/slick.css: {}
      css/vendor/slick-theme.css: {}
  js:
    js/vendor/slick.min.js: {}

But I don't want the Slick library to be loaded by the parent theme because I will be installing the Slick module, and will be using Slick Views. I found the Slick library loaded by my parent theme was (of course it was) conflicting with the same library loaded by the Slick module.

My idea is somehow in my child theme's childtheme.libraries.yml file override and tell Drupal to ignore the instruction by the parent theme to load the Slick library. If that is not possile, then may I do that in my childtheme.theme file?

The only workaround I could find so far was to hack the parent theme and comment out the lines where Slick library is loaded, but I know this is a bad practice in case I need to update the parent theme in the future for some reason.

What is the best approach for this problem? Thank you.

You can add overrides to your child theme's info.yml file, telling Drupal not to load the slick library from the parent theme.

Refer to the "Libraries-override" section of this well documented blog post explaining and demonstrating the many options available in terms of removing/replacing files called by other modules and themes with specific ones in your theme.

For your use case, you probably just want to remove (aka disable) both css and js files for slick.js from the parent theme.  So your "library override" will resemble either:

Case 1: slick is part of a library in the parent theme that includes multiple css and js files for the theme, not just slick

libraries-override:
  parent_theme/parent_theme_library_that_includes_slick:
    css:
      theme:
        path_to_parent_theme_or_vendor_slick_library_folder/slick.css: false
        path_to_parent_theme_or_vendor_slick_library_folder/slick-theme.css: false
    js:
        path_to_parent_theme_or_vendor_slick_library_folder/slick.min.js: false

Case 2: slick is part of a standalone library in the parent theme

libraries-override:
  parent_theme/slick_library_name: false

You won't need to declare a replacement in your libraries-override, since you're using the Slick module itself, and it will load relevant files needed.


Moving from subdomain to top level, link/image paths incorrect after manual edit TL;DR Filepaths contain old subdomain prefix after find replace database and site code, can't determine cause.

I have a hosted site on mywebsite.com/drupal, I want to move it to my computer localhost.

I have a LAMP stack and I compress and download the contents of mywebsite.com/drupal and export its mysql database, mydb.sql, using phpmyadmin.

I uncompress and place all the files from mywebsite.com/drupal in /var/www/html/, I create a new database, local.db, locally and import mydb.sql. I edit /var/www/html/sites/default/settings.php $databases array and connect it to local.db.

I ensure all files permissions are correct by running

chown user:user -R /var/www/html/
chmod -R 755 /var/www/html/

I can then access my site using a browser and going to localhost, however the images are missing none of the links work.

Initially I thought the cause was that there are many instances in the database and my site code still containing filepaths with the subdomain /drupal/ prefix, images for example:

src="/drupal/sites/default/files/inline-images..."

When I move the site to localhost, it should just be:

src="/sites/default/files/inline-images..."

To solve this, I did a find /drupal/ and replace / in my database, reimported it and then used grep -rl '/drupal/' ./ | xargs sed -i 's_/drupal/_/_g' on /var/www/html/.

I thought this would have resolved the problem, however when I access localhost, the problem persists, images and links still contain the /drupal/ prefix in their filepaths. I've read on a few migration guides that I should flush all caches on the drupal backend before moving  (which I did) and also potentially flush the mysql cache using phpmyadmin, however I get an error #1146 - Table 'mydb.cache' doesn't exist when I try to execute the truncate commands.

Other guides mention .htaccess, which I copied over from mysite.com/drupal, admittedly I don't understand everything inside it deeply, but I can't find any code which is prefixing filepaths with /drupal/.

As a sanity check, I created /var/www/html/drupal/ and copied my site and then everything works fine.

I don't understand, how can the filepaths remain the same when I have changed all instances in the database and site code? I think there is something easy I'm missing but I can't figure it out.

Is this Drupal 7 or 8? Not sure that it matters, but take a look at around line 102 of your .htaccess file, should look like this:

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal

The issue you describes sounds like the RewriteBase is incorrect. What does your .htaccess say?

Can you also tell me what your settings.php file has for the base URL value?

# $base_url = 'http://www.example.com';  // NO trailing slash!


Node filtering based on taxonomy terms I followed this post, I am able to filter nodes based on content type and other parameters

http://test/api/node?parameters[nid]=1&parameters[status]=1

but I am not able to filter based on taxonomy terms (tid), problem is with nested json, how do I pass the parameter on URL for nested json?

I don't want to use services_views.

Below is my json data,

{
    "vid": "142",
    "uid": "2",
    "title": "Tomato",
    "log": "",
    "status": "1",
    "comment": "1",
    "promote": "1",
    "sticky": "0",
    "nid": "142",

..
..

 "field_category": {
        "und": [
            {
                "tid": "2"
            }
        ]
    },
}

This is what I tried and it works perfectly,

http://test/api/node?parameters[nid]=1&parameters[field_category]=1


How to get current route in the midst of a Views AJAX request I need to conditionally pass contextual filter values to a view based on the current route and am attempting to do so in hook_views_pre_view. This is the result of using AJAX via views_infinite_scroll and losing the contextual filters that I initially pass in programmatically.
On the initial request, the following works great for getting the current route in hook_views_pre_view:
$current_route_match = \Drupal::getContainer()->get('current_route_match');
$current_route_match->getRouteName();

However, when I hit the 'Load more' button supplied by views_infinite_scroll, the route name of the current route match is 'views.ajax'. While I understand that this is technically the request's route, I need to know the original route, or from where the request was made.
After digging around, I noticed that $_SERVER['HTTP_REFERER'] had the right path, but the documentation says:

Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

use Symfony\Component\HttpFoundation\Request;

if (\Drupal::routeMatch()->getRouteName() == 'views.ajax') {
    $previousUrl = \Drupal::request()->server->get('HTTP_REFERER');
    $fake_request = Request::create($previousUrl);
    $url_object = \Drupal::service('path.validator')->getUrlIfValid($fake_request->getRequestUri());
    if ($url_object) {
      $route_name = $url_object->getRouteName();
      // Do something with $route_name;
    }
  }


How to add < to "allowed values list"? I'm trying to add:
1|small (<100)
2|etc ...

but it will only display "small (" as the first option.
I've tried < without success.
Any way to display the < ?

Both <, &lt; and also &#60; works with a checkbox/radio widget. <select> doesn't allow html code for options.

In consecuence Drupal strip tags if the <select> widget is configured. This is done in _options_prepare_options().

Short story: after some tests I've found that small (< 100) works (there's a whitespace between < and 100), so it is not considered a tag.

I've done my tests with:

drush php-eval 'print strip_tags("small (< 100)") ."\n"'


How to choose between all the Views hooks Reading the docs about Views hooks doesn't really help me to make the right choice between all the hooks. As per this comment, this is the Views hooks execution order:

hook_views_pre_view
hook_views_pre_build
hook_views_post_build
hook_views_pre_execute
hook_views_post_execute
hook_views_pre_render
hook_views_post_render

I'm currently trying to alter properly the output of a view field :

I tried with hook_views_post_execute(&$view) :

function MODULE_views_post_execute(&$view) {
  if ($view->name == 'foo' && $view->current_display == 'bar') {

    foreach ($view->result as $result) {

      if (isset($result->field_field_status)) {

        switch($result->field_field_status[0]['raw']['value'] ) {
          case 1:
            $text = 'ABC';
            break;
          case 2:
            $text = 'DEF';
            break;
          //and so on
        }
        $result->field_field_status[0]['rendered']['#markup'] = $text;
      }
    }
  }
}

This worked fine at first glance : returned string display nice,  but raw data were displayed again after a while. After clearing page cache the expected output turns back, but then disappeared again, and so on.

Then I tried with hook_views_pre_render(&$view) , with exactly the same code inside that other hook giving exactly the same result.

Question(s) :

What makes the hook be applied or not ? Wrong hook use maybe ?  Is there any logic to apply one or another of these hooks ? (After reading @Alexar comments : yes I'd explicitly like to know about views hooks, the example is just to illustrate my searches and misunderstandings.)

I really need to understand the logic behind all that for my "learning curve".

Edit :

Lastly, I used a views-view-field.tpl.php to change the output of my field, another possibility adding more confusion to my global understanding of the view construction background... Anybody for a bit of Drupal pedagogy ?

The documentation View Hooks is clear about the purpose of every hook. It says about hook_views_post_execute(&$view):

  This hook is called right after the execute process. The query has
  been executed, but the pre_render() phase has not yet happened for
  handlers.

And gives an example what you can do with this hook:

function hook_views_post_execute(&$view) {
  // If there are more than 100 results, show a message that encourages the user
  // to change the filter settings.
  // (This action could be performed later in the execution process, but not
  // earlier.)
  if ($view->total_rows > 100) {
    drupal_set_message(t('You have more than 100 hits. Use the filter settings to narrow down your list.'));
  }
}

At this point the database query was executed and you can do something with the result of the query, for example place this warning.

When you search in drupalcontrib, you find, that it is only used once:

drupal contrib search

Here it is used following the documentation. But no one in contrib used it for other things. You would be the first, with unpredictable results.

What you want to do is not specific to views, and because of that it is not in your list of view hooks. It is more connected to theming in drupal.

It is not advisable to put extensive code in the templates *.tpl.php, better put it into a preprocess function. Some examples for views:

hook_preprocess_views_view
hook_preprocess_views_view_field
hook_preprocess_views_view_fields
hook_preprocess_views_view_grid
hook_preprocess_views_view_table
hook_preprocess_views_view_unformatted
hook_preprocess_views_view_list

Use the preprocess hook, that correspondents with your views configuration.


Possibility to apply a patch to a target directory with Drush make? Is there any way to declare target directory for a patch in a Drush make file?

I need to apply a patch to a subfolder of a module. The reason is that CiviCRM's project is composed from multiple repositories (the patch is from the civicrm-drupal repository, which corresponds to civicrm/drupal in the packaged module).

There was a proposal along these lines in #745224, but ultimately only support for -p0 and -p1-type patches was committed.

(I'm now using a work-around by declaring a library in that location and applying a patch to it, but a cleaner way would be nice).

After clarifying that the goal of the original question was to be able to use patches generated by pull requests on GitHub directly, I'm suggesting an alternative answer.  My original answer is correct if the goal is to package this on Drupal.org.  Because a drupal-org.make requires patches to be found on Drupal.org, the path can be updated in the patch to to target directories within the CiviCRM project.  drupal-org.make also requires all external projects to be whitelisted.  Only the sk (starterkit) build of CiviCRM is whitelisted (https://www.drupal.org/node/1588192) because of the size and licensing limits.

When using drush make locally, you can use both patches and code from any source.

  IIRC it was a bit more complicated than just combining the repos?

It really isn't more complicated than just combining the repos.  There is some additional logic in https://github.com/civicrm/civicrm-core/blob/master/tools/scripts/releaser/releaser and https://github.com/civicrm/civicrm-core/blob/master/distmaker/distmaker.sh, but you can really focus on what happens in...

https://github.com/civicrm/civicrm-core/blob/master/distmaker/dists/drupal_php5.sh

dm_install_core "$SRC" "$TRG"
dm_install_packages "$SRC/packages" "$TRG/packages"
dm_install_drupal "$SRC/drupal" "$TRG/drupal"

That combines https://github.com/civicrm/civicrm-core with https://github.com/civicrm/civicrm-drupal and https://github.com/civicrm/civicrm-packages.

Other than the versioning, that's really all that happens when a new release of CiviCRM is packaged.  There isn't any code for a D7 release that doesn't come from those 3 repos.  By adding each of these projects directly, the relative path of the code will match what the patch expects allowing the patch to be applied in the .make.

So to get something like https://github.com/civicrm/civicrm-drupal/pull/144.patch to work before it is merged into a release, your .make would look something like...

libraries[civicrm][download][type] = get
libraries[civicrm][download][url] = "https://github.com/civicrm/civicrm-core/archive/4.4.10.zip"
libraries[civicrm][destination] = "modules/"
libraries[civicrm][directory_name] = civicrm

libraries[civicrm-drupal][download][type] = get
libraries[civicrm-drupal][download][url] = "https://github.com/civicrm/civicrm-drupal/archive/7.x-4.5.4.zip"
libraries[civicrm-drupal][destination] = "modules/civicrm/"
libraries[civicrm-drupal][directory_name] = drupal
libraries[civicrm-drupal][patch][144] = https://github.com/civicrm/civicrm-drupal/pull/144.patch

libraries[civicrm-drupal][download][type] = get
libraries[civicrm-drupal][download][url] = "https://github.com/civicrm/civicrm-packages/archive/4.5.3.zip"
libraries[civicrm-drupal][destination] = "modules/civicrm/"
libraries[civicrm-drupal][directory_name] = packages


How to add a Subscription box? I would like to add a style-able Subscription box which will consist of a Heading, text field and a styled button in form of an image. Upon pressing the submit button I would like the user to be presented with some options in form of checkboxes as well as the option if they would like html or plain text email format.

How would I go about adding this to my drupal 7 site?

There are basicly two alternatives:

Using the Ctoosl Modal module. This module, included on the ctools project, is the most popular way to popup modal forms on Drupal, with lots of addon modules (like modal_forms). Here is a nice tutorial.
Using a custom module. You may find the following modules helpful:

popup_message - which seems well supported.
popup_announcement - this is a new module which seems closer to what you search for, with full html support, but with only a few downloads.

With option 2, you should have to create the form and inject it into the popup using the forms API, so here is a form creation tutorial, and a stackexchange discussion about the best form creation method.


Different css of #main-content at differnt page url? I have set the css of the main content in theme css as,

#main-content {
    background:#CCC;
    box-shadow: 0 0 1px #0F4C6A;
}

So it gets apply to the every page/node/content whatever I create which is quite common. For some pages I do not want this css to apply to #main-content. Is there any way I can achieve this?

Option 1 - Pure CSS

For those specific pages you can use the classes found in the body tag to override your generic style like so:

#main-content { ... }

.page-node-123 #main-content {
  your override for this node
}
.node-type-article #main-content {
  your override again
}

Option 2 - CSS with Drupal coding

Use preprocess hooks like hook_node_view or template_preprocess_page or hook_preprocess_html in the template.php file in your theme and add additional classes based on your specific requirements/conditions

Then use CSS to target those classes or IDs.

Drupal helps us already by default on basic IDs and classes that we need to target things globally or specifically we just need to do an inspect element on the page and check for yourself.


Unknown engine type outputformat Hello I've just updated Drupal (to version 7.53) and now in Drush when I try launch the commands:
"drush @theflyingeye.org up" (to update my website)
or
"drush @theflyingeye.org cc" (to clean chache)
or
"drush @theflyingeye.org dl view" (to download a basic module, view for example)
I can just get this answer:
"Unknown engine type outputformat"

If I digit:

"drush status" (after "su aegir")
I can get:
"PHP configuration     :  /etc/php5/cli/php.ini
 Drush version         :  5.10.0
 Drush configuration   :  /var/aegir/.drush/drushrc.php
 Drush alias files     :  /var/aegir/.drush/server_master.alias.drushrc.php
                          /var/aegir/.drush/theflyingeye.org.alias.drushrc.php
                          /var/aegir/.drush/server_localhost.alias.drushrc.php

Do you have any advise please to fix this problem?

Start with upgrading to Drush 8 ... see http://drush.org/en/master/install


How to add HTML to page following user/register to track Google AdWords conversions? I want to track conversions for Google AdWords. Basically I want to track when people sign up via the user register page (i.e. when they click join).

Google provides code (which is basically a little image) which it says I have to add to the page I want to track. I figure I need to add this to the page which comes after the visitor clicks the join button at the bottom of the user/register page.

(1) Is there a module to do this (Drupal 7)? OR
(2) How can I add HTML to the page following the user/register page (perhaps using hook_page_alter)?

In case of GA or some of the social plugins, you can just add the code in a custom block with FULL HTML format, so you can try creating custom block (maybe in footer) with your code and set the pages where it will appear to user/register


How can I filter a view to show recent items but only one item per user? I am using the Message module to produce a user activity feed for my site.

I want to make a view for the front page that shows the latest user activity (the 10 most recent actions for which I have messages configured) like this:

Bill updated his profile.
Ted updated his profile.
Wayne added a picture.
Garth sent a message.

Making a view that shows this activity was fairly simple.  However, if one user is very active, the results will look like this:

Wayne updated his profile.
Wayne added a picture.
Wayne sent a message.

This doesn't look very good on the front page, and I have many hyperactive users, so what I would like to do is "show the 10 most recent activity messages for 10 unique users."  I experimented with the grouping feature of views, but I haven't figured out how to create a combination that allows me to achieve this.

A dull ax approach would be to create a View that returns 100 of the latest messages, and then using a views_pre_render() hook, go through and grab the messages uniquely per user, eg, something like this:

function YOURMODULE_views_pre_render(&$view) {

  if ($view->name=='THIS_VIEW') {

    $new_result=array();
    $unique_users=array();

    foreach ($view->result as $row) {
      if (!in_array($row->USER_FIELD_IN_VIEW, $unique_users)) {
        $new_result[]=$row
        $unique_users[]=$row->USER_FIELD_IN_VIEW;
        if (count($new_result)==10) {
          break;
        }
      }
    }

    $view->result=$new_result;

  }

  // any other pre_render()ings go here

}

where USER_FIELD_IN_VIEW is the field in your View corresponding to the uid of the owner of the message.  A print_r() of $row or $view->result should give you that information.  The other kicker is picking a small enough number of messages to give you those 10 users. I just pulled out 100 out as 10 users and 10 messages per "hyperactive" user to make sure you got at least 10 users without getting too many that you just throw away at the end.

EDIT/ADDITION: there were some variable name typos in my code that I've corrected :)


User may edit their webform submissions, but only while in draft I don't want users to be able to edit their webform submissions after they have been submitted (in this case it's an application form that needs to be reviewed).

The trouble is, they also need to be able to partially complete and return to it. If they've saved a draft, to continue, they have to access:

/webform/{webform}/submissions/{webform_submission}/edit

and with 'Update own webform submissions' disallowed (which you can do per webform, remember) that route is blocked.

I can't see anything obvious in the options for drafts (Settings > Submissions) yet I can't be the first person to have needed this…

Solution I've come up with so far:

enabling edit/update access for all users
adding a RouteSubscriber for entity.webform.user.submission.edit
loading the submission there, using ->isDraft() to check its status
denying access for false, depending on role/ownership

Any better ideas?

(NB: this doesn't involve anonymous users - they have to be registered and logged in.)

You don't need a custom route, you can hook into the entity access check for the existing entity routes:

mymodule.module:

use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\webform\WebformSubmissionInterface;

/**
 * Implements hook_ENTITY_TYPE_access().
 */
function mymodule_webform_submission_access(WebformSubmissionInterface $webform_submission, $op, AccountInterface $account) {
  if ($op == 'edit' && !$webform_submission->isDraft() && in_array('role', $account->getRoles())) {
    return AccessResult::forbidden()->cachePerPermissions();
  }
  return AccessResult::neutral()->cachePerPermissions();
}


Drupal Form Button + "Are you sure"-Button I am trying to add an own JS function to a Drupal Core Form - think Config, Development, Clean Cache. This function basically just asks if the user is sure. Here is what I have so far:

Drupal.behaviors.confirm_delete = {

    attach: function (context, settings) {

         jQuery("#field-module-subsections-values input[id$='-remove-button']", context).bind('mousedown', function (ev) {

            ev.stopImmediatePropagation();
            ev.preventDefault();

            var followLink = window.confirm(question);

            if (followLink) {
                jQuery(this).click();
            }

            return false;

        });
    }
}

The problem I have is, that the function gets called before the click-event (thanks to mousedown), but the Ajax action on the button still fires. Maybe someone has a hint as to why?

Using hook_form_alter you can implement simple popups like this using #attributes.

 $form['submit']['#attributes'] => array(
  'onclick' => 'if(!confirm("Are you sure?")){return false;}',
 );

or

$form['submit']['#attributes']['onclick'] = 'if(!confirm("Are you sure?")){return false;}';


SImplenews module. Where does the form come from? I would like to modify the content of the simplenews form, but where is it being generated from?

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

I would like to change the "E-mail" wording, for example.

To modify a form in Drupal you dont need to get where the form is built.

You can make use of hook_form_alter to modify the form

  Perform alterations before a form is rendered. One popular use of this
  hook is to add form elements to the node form.

hook_form_alter(&$form, &$form_state, $form_id);

  Parameters

  $form: Nested array of form elements that comprise the form.

  $form_state: A keyed array containing the current state of the form.
  The arguments that drupal_get_form() was originally called with are
  available in the array $form_state['build_info']['args'].

  $form_id: String representing the name of the form itself. Typically
  this is the name of the function that generated the form.

What is a Hook ?

Basically they provide a way for a module to extend the functionality of another module. They would go in a module and 'hook' would be replaced by the actual module name.

Please try

Examples for Developers

Drupal Hooks Explained


Trigger redirect after Webform Remote Post Handler posted successfully I've made a webform with a handler. This handler does a Remote Post towards an API. This API is actually a custom module within the Drupal install which (after some logic) passes all of the preprocessed data towards another API. When that is passed successfully I get a redirect URL back from them, but whatever I use (TrustedRedirectResponse or just normal RedirectResponse) it won't redirect. It just reloads the form.

How to solve this?

I've added the following to the handler:

/**
* {@inheritdoc}
*/
public function confirmForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
  if ($this->isDisabled()) {
    return;
  }

  $uri = new Url('entity.node.webform.user.submission', [
    'node' => $webform_submission->getSourceEntity()->id(),
    'webform_submission' => $webform_submission->id(),
  ]);
  $form_state->setResponse(new RedirectResponse($uri->toString()));
}

This seems to work.


Enabling Views module causing cron to fail Quite simply, I enable the super common "Views" module, and on Save nothing but a white page happens.
On a refresh (Where I agree to the form resubmission) the modules page comes back just fine.

Then I click the "Run cron" link, and that is also blank, and never shows anything else or redirects.

Visiting cron.php by itself, also blank.

I've seen some solutions, such as increasing php's memory_limit and mysql's max_allowed_packet, but neither have done anything.

Everything runs optimally again the moment I disable Views.

Some info:

Web server: nginx/1.4.6
PHP: 5.5.9
PHP memory limit: 256M
Drupal: 7.35

I've never had this problem before, especially with Views

Sounds like either:

You have two copies of the Views module enabled somehow.
You have a problem with your server configuration in relation to op-code caching.

Check your "system" table in the database with:

SELECT name, filename, status FROM system WHERE name = 'views';

Check the results are as expected for your install.

For the op-code cache issue, check this thread:

  Cannot redeclare class view, updating to PHP5.5

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

It may be a problem with using multiple op-code caching methods, or xcache conf issue.


How to unset node form select list element_validate? I added a built-in select list field to a content type but left the allowed values field setting empty, since I'ld like to get the possible options to choose from dynamically.

To be precise I'ld like to offer the editors a list of files inside a certain directory to choose from. This list can grow and I don't like to touch the content type and adjust the allowed values field setting every time a new file gets added to that directory. (Editing it afterwards may even not be possible since after having values for that field in the database when nodes got added you are not allowed to change field settings anymore.)

So here I am, having the list of files added to the form widget's options array, but now I'm unable to save the selected value as it's not in the list of allowed values.

  The value you selected is not a valid choice.

OK I thought, let's simply uncheck the element validation: unset($form['field_MYFIELD']['widget']['#element_validate']). As far as I can remember this worked in D7. Makes the problem even bigger.

  TypeError: Argument 1 passed to
  Drupal\Core\Field\WidgetBase::massageFormValues() must be of the type
  array, string given, called in
  /Users/Shared/www/Documents/MYREPO/web/core/lib/Drupal/Core/Field/WidgetBase.php
  on line 370 in Drupal\Core\Field\WidgetBase->massageFormValues() (line
  505 of core/lib/Drupal/Core/Field/WidgetBase.php).

Is there a simple way to unset this element validation here? Or should I introduce another custom select list field and save the chosen value into a hidden textfield, simply?

The solution is here:
https://chromatichq.com/blog/dynamic-default-and-allowed-values-list-fields-drupal-8

the discussion is here:
https://tutel.me/c/drupal/questions/242006/how+do+i+programmatically+update+the+allowed+values+of+a+list+field


CSS aggregration breaks site - how to troubleshoot? I have a number of D7 sites that "broke" recently when I applied 7.39 and a few other updates. By "broke" I mean the site's CSS styling completely disappeared. I can easily fix by disabling CSS aggregation, so I know that's the cause.

At first I thought it might be a Omega 3.x problem since all sites initially affected, but then a site based on Bootstrap had the same problem. (The CSS doesn't always break right away).

What steps can I take to troubleshoot to determine the root cause?

Edit - to add more detail based on Clive's questions below:

Page source does contain <link>'s to aggregated CSS files (5 total)
Aggregated CSS files do exist on server
Status codes are 304 (4) and 200 (1)
Folder permissions seem OK

Some initial things to check:

Clear the cache (if you're running advagg, clear its cache). You can end up with stale file references sometimes.
Find out what's happening to the missing CSS:

When the styles go missing, does the page source contain a <link> to an aggregated CSS file? If not, check for modules/themes implementing hook_html_head_alter(), hook_css_alter(), or hook_preprocess_html(), and see if they're doing anything strange.
If the source does contain the <link>, what status code is the browser returning for the request? 404? You might have a stale cache issue. Clear all caches including those on any reverse proxy you're running. It might easily be something else, would require more intimate debugging. 500? Check the server logs, that should give you clues as to where things are failing.
If it's 200, does the requested file actually contain the styles it's supposed to? If not, you might be looking at a cache issue again, or potentially an issue with build tools (Compass/Gulp/Grunt/etc).

Switch the theme to a core one. Does it have the same problem? If so, it's probably a module or server setting at fault. If not, it's likely to be a problem with the theme.
Make sure permissions for your files folder are at the right level - the web server must be able to write to that folder to store the aggregated files. This is less likely to be an issue if the files are being created successfully, but it's worth double-checking you don't have an intermittent file system issue (if it's over NFS for example)

Getting the answers to those questions will help to narrow down the source of the problem, but unfortunately it's difficult to give specific advice as to where you should look in the code, as there are a lot of points problems could occur, and a lot of different modules you could have installed, at varying versions.


How to show thumbnails gallery images in the footer first section? i have installed node gallery module as well media gallery but media gallery is not working for my drupal version now i am using node gallery but its show like below image

but i want like

To do that you can use a views block to list all the pictures you want. After that you can use an image style to crop them like you want.

For the theming, feel free to use Views Theme Suggestion and Views Preprocess(ex : here) to add features et style images and content wrappers.

I hope it helped you.


Custom user login in Facebook Auth modules I try to run Facebook Login on my Drupal 8 site. I run it by Social API module and with Simple FB Connect, but both module generate user name from first and last name on Facebook. My user will not be happy with using real name, but I don't want to give them options to change username whenever they want.

For code examples I use Simple FB Connect, but the same logic is in Social API modules.

User go to path user/simple-fb-connect and is redirected by Drupal\simple_fb_connect\Controller\SimpleFbConnectController->redirectToFb(), and when he is back, go to user/simple-fb-connect/return which is handle by Drupal\simple_fb_connect\Controller\SimpleFbConnectController->returnFromFb().

It checks permissions, get data from FB and then if email not exist in DB, registers user:

[...]
    // If there was no existing user, try to create a new user.
    $fbid = $fb_profile->getField('id');
    $fb_profile_pic = $this->fbManager->getFbProfilePic();
    if ($drupal_user = $this->userManager->createUser($fb_profile->getField('name'), $email, $fbid, $fb_profile_pic)) {
[...]

The main question is: How I can replace $fb_profile->getField('name') with custom, provided by user string ? I think about:

Replace simple link on login with form contains textfield and submit button, which send POST/GET data to user/simple-fb-connect. There store it Session, and use on returnFromFb() function to create user.

But I can't always show an additional field (eg. on homepage), and I don't know if user want to register or just login. It kills idea, just click, and get account.

After back from FB, show users one-time form, which they can't skip, and access page, before they fill it, like post-login registration in normal FB integrations, on which they can fill additional data, but only once per account.

But there I have no idea how to even start. Maybe I can replace function returnFromFb() code creating new user with register form, and after submit create user. Or leave module code in peace and base it on events from the module. But how I can lock page for user who don't fill this and secure it to be fill just one time (maybe boolean field on user entity?).

The simplest way, just leave it as it is, use display name and hide login, but I don't want to store user names and last names in database.

Thanks for help!

PS. I tried to ask the creators, but it looks like the modules work like they should work.

Provided that you're using v8.3 or higher of the module, a possible solution would be to create a form where the user decides which values are stored according to his/her needs and your requirements of course.
Then, using the provided events in the module, you can redirect the user to this form which will accept the $user object and apply the changes accordingly.
You should add an EventSubscriber service which listens to simple_fb_connect.user_created event as per the module documentation linked above. Thus you're only showing this form to the user once after the account has been created and not with every login.
Hope this helps.


Why is step 2 of file to media migrate giving me missing bundle error? I am following the instruction on this page : https://www.drupal.org/project/migrate_file_to_media/issues/3118471 , but with media of bundle document, not image.  I have my step 1 yml on this issue How can i debug why files are not being created when using migrate files to media module?
My nodes of type grants and step 1 files are being created as media correctly, however when i do step 2, using the yml below, I get this error :
Missing bundle for entity type node (/var/www/html/docroot/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:108)
id: migd8_grants_media_step2
label: grants Media Mapping
migration_group: cncs
source:
  key: migrate
  plugin: d7_node
  node_type: grants

destination:
  plugin: entity:node

process:
  nid: nid
  changed: changed

  field_files:
    plugin: file_id_lookup
    source: field_files
    migration: migd8_grants_media_step1
    no_stub: true

migration_dependencies:
  optional:
  - migd8_node_grants
  - migd8_grants_media_step1

I made some changes as an experiment and started getting duplicate grants being created, one with the correct media files attached, and one without , these are the changes i made which caused the duplicates with one having the correct file attached:
id: migd8_grants_media_step2
label: grants Media Mapping
migration_group: cncs
source:
  key: migrate
  plugin: d7_node
  node_type: grants

destination:
  plugin: entity:node

process:
  nid: nid
  changed: changed
  title: title
  type:
    plugin: default_value
    default_value: grants
  field_files:
    plugin: file_id_lookup
    source: field_files
    migration: migd8_grants_media_step1
    no_stub: true

migration_dependencies:
  optional:
  - migd8_node_grants
  - migd8_grants_media_step1

in step2 i had to change it to this
destination:
  plugin: entity:node
  default_bundle: grants


How do I add taxonomy terms and vocabularies to an exportable deployment plan? I'm in the process of developing an installation profile for a new site. We're using Features to export much of our functionality, and are very interested in using the Deploy module integration with UUID to handle the thorny issues stemming from exported content not having the same unique IDs on multiple deployments. Being able to export entities into a deployment plan and import them with Features would be an absolute godsend, and this is working with basic node content from what I've seen so far (I'm familiar with the concept of creating a fetch-only deployment plan and exporting it later).

However, I have a content type that references multiple taxonomies, each with a closed, pre-defined vocabulary. These vocabularies (and their terms) need to be exported, so that they can be referenced by the appropriate fields (for instance, a list of terms representing venues should be selectable from a drop-down). I haven't yet found a way to add these to a deployment plan, despite hearing on the soon-to-be-deprecated UUID Features issue queue that this should be possible. Is there something I've overlooked, or is there a better approach?

I seem to have stumbled my way through to a solution. Vocabularies don't need to be exported via UUID, as they already have their own machine name, but any terms within those vocabularies still need to be added to a deployment plan so they can be exported (inadvertently adding a vocabulary to the plan throws errors).

Using the latest development snapshots (as of March 14, 2012) of UUID, Deploy, Entity Dependency API, Views and Rules, it is possible to stitch together a UI for adding taxonomy terms to a plan. First, a managed fetch-only deployment plan must be created.

Next, a Rules component must be created using Rules, with a taxonomy term as a single parameter and a single action that adds the entity to the selected deployment plan. Note, however, that the current development snapshot of Deploy does not allow you to use Rules to add to a fetch-only managed deployment plan (I had to write a trivial patch that allows this behavior).

Next, one should create a view of all taxonomy terms, adding a Bulk Operations checkbox using Views Bulk Operations. If you have created your Rules component as above, VBO will allow you to select your component as a task to perform on all checked entities.

Now that your form is configured, all that's left to do is visit the view and add the necessary taxonomy terms, and select the relevant components to export via Features. Gotcha: There is no dependency checking in Features after adding the taxonomy terms via uuid_entities. You have to remember adding the vocabulary yourself, or tragedy and error messages will ensue.


How to disable H1 heading in CKeditor? I'd like to give some authors a better SEO experience. How can I disable Heading 1 in builtin CKeditor in Drupal 8?

1) Take a look at the editors you're using on your site at /admin/config/content/formats

2) For each editor, you'll need to update the allowed tags.  Let's edit the FULL HTML format for this example, so click on the "Configure" button for "Full HTML"  (/admin/config/content/formats/manage/full_html).

3) Under "Enabled Filters", click the checkbox labelled "Limit allowed HTML tags and correct faulty HTML".  A filter settings form will appear below.  Remove the h1 tag from the field labelled "Allowed HTML Tags".

4) Save

Test that it's removed from the drop down:


Maximum upload size for file is not working I have set file filed with 25MB Maximum upload size. But when i upload more then 25mb file it is uploading. How to stop this.Can we create any custom module for file size.

In Drupal 7 you can achieve by using .htaccess

In your .htaccess file:

php_value post_max_size 8M
php_value upload_max_filesize 8M

Check this link for more information


Adding taxonomies to node gallery and using views to display I think the most important piece of information I can give is I am doing a migration from Drupal 6 to Drupal 7 and I am resetting everything up. This gave birth to a few hiccups along the way. As a side note, all content was migrated using the drupal-to-drupal migration module.

I have a few taxonomies. Some of the vocabularies have terms. I am using Node Gallery to create and display galleries and I am also using views to display some views. Given this information, I have 2 problems:

The first is I do not know how to link node gallery to any of the terms. This would be the first thing I need to do. I need to link a gallery to a specific category or term.
The second problem might be a bit involved. I need to create a view, based on the taxonomy accessed. On the Drupal 6 website, the menu URL was say /category/vocabulary/term. When clicked it redirected to ex. /gallery-page/term where both terms are the same.

I know the Drupal 6 site used Taxonomy Views Integrator. Not sure if that was what created it. I haven't had any luck getting any of this to work.

I see the Drupal 6 version allows you to select a category when creating or editing the gallery, not sure if this is a custom module.

Any advice, module suggestions or anything like that would be greatly appreciated.

Update:

I think I have figured out how to set categories, was missing a field. Added it and can now select. Will edit again if fixed.

I have made a plan. I have ignored the redirection for now. What I did was set up a view for each gallery-page/term that there should be. Each view was linked to a specific term that each gallery item is associated with.

The term association was made by adding a field to the gallery content type using the field type term reference. This allowed me to set the terms required for each gallery.

After setting up each of the fields I wanted to display including the path and additional settings, I got it to work displaying only the galleries in a specific taxonomy.

The solution is actually pretty straight forward. I would have liked to have used arguments, however I couldn't get that working. At least the problems described above have been resolved.


Is it okay to ignore the error notices I get on a Drupal site? My Drupal 7 site has many error notices like

  Notice: unserialize() [function.unserialize]: Error at offset 225 of
  305 bytes in variable_initialize() (line 943 of
  /site/includes/bootstrap.inc).

or

  Call-time pass-by-reference has been deprecated in drupal_load() in bootstrap.inc

The site still works inspite of the errors. Is it okay to ignore these error notices?

Between the two errors, the first is more worrying.

As variable_set() passes the variables value it receives to serialize(), if unserialize() is not able to understand the saved data, it means the database content is probably corrupted. variable_initialize() calls unserialize() using the following code.

  // Proceed with variable rebuild.
  $variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed());
  cache_set('variables', $variables, 'cache_bootstrap');
  lock_release($name);

The second error says the code is using a feature that is deprecated, which means that in future PHP versions the code could not work anymore, but in the actual PHP version is still working.


How do I remove default comment validation in drupal 7? Drupal is showing error message for empty comments by default. how can i remove that error message.
Note:- (I have not written any custom validation. It's the default validation provided by drupal module.) My changes in comment.module

if (empty($comment->cid) && empty($comment->pid)) {
if(($form['#node']->type=='iks_videos_youtube_video') || ($form['#node']-               >type=='iks_videos_vimeo_video' || $form['#node']->type=='iks_videos_video')){
if(isset($form['#node']->type) && $form['#node']->type=='iks_videos_youtube_video')
{   $vtype='yt';}
else
{   $vtype='v'; }
$form['#action'] = url('video/' . $form['#node']->video_id[LANGUAGE_NONE][0]['value'] . '/'.$vtype.'/' . strtolower(str_replace(' ', '_', $form['#node']->title)));
  }else{
$form['#action'] = url('comment/reply/' . $comment->nid);}

}

my custom module code

function  iks_videos_form_comment_node_iks_videos_youtube_video_form_alter(&$form, $form_estate) {
if (isset($form['actions']['preview']))
unset($form['actions']['preview']);
$form['subject']['#access'] = FALSE;
unset($form['author']['mail']['#description']);
$form['#submit'][] = '_iks_videos_comment_form_submit';
    }

alter form

function _iks_videos_comment_form_submit($form, &$form_estate) {

if(($form['#node']->type) && $form['#node']->type=='iks_videos_youtube_video')
    $vtype='yt';
else
    $vtype='v';
$form_estate['redirect'][0] = 'video/' . $form['#node']->video_id[LANGUAGE_NONE][0]['value'] . '/'.$vtype.'/' . strtolower(str_replace(' ', '_', $form['#node']->title));

}

You can see error message because comment_body is required for comment entity.
You can delete #required parameter for comment_body:

function my_module_form_alter(&$form, &$form_state, $form_id) {
  if(strpos($form_id, 'comment_node_erpal_task_form') !== FALSE) {
    $form['comment_body'][LANGUAGE_NONE][0]['#required'] = FALSE;
  }
}

But just know that you'll have php notice then. Because posting comment without the body is not right:

  Notice: Undefined offset: 0 in comment_submit() (line 2197 of
  W:\home\erpal.local\www\modules\comment\comment.module).

Make sure yhat you added custom validation for body field.

You you can handle validation callbacks for the whole form in $form['#validate'] array. Also you can handle validation callbacks for each form element in #element_validate array. E.g. for comment_body:

$form['comment_body'][LANGUAGE_NONE]['#element_validate'][] = '_my_module_comment_body_validate';

Update

You musn't change any code in Drupal core modules, it's very bad hardcode. You can do all your logic that you added to comment.module in hook_form_alter.

function my_module_form_alter(&$form, &$form_state, $form_id) {
  if(strpos($form_id, 'comment_node_erpal_task_form') !== FALSE) {
    $form['comment_body'][LANGUAGE_NONE][0]['#required'] = FALSE;

    if(isset($form['#node']->type) && $form['#node']->type=='iks_videos_youtube_video') {
      $vtype='yt';
    }
    else {
      $vtype='v';
    }

    $url = url('video/' . $form['#node']->video_id[LANGUAGE_NONE][0]['value'] . '/'.$vtype.'/' . strtolower(str_replace(' ', '_', $form['#node']->title)));
    $form['#action'] =  $url;
  }
}