Updating a module field schema I'm currently working on a project created by someone else. I have a textfield called "city". Currently the maximum limit is 255 characters. I want to update the maximum character to be 100. Looking at the code, it looks like the field was created using the features module. When I try to update the field, I got the FieldUpdateForbiddenException. I understand this is because I have value in the database. Is there a way update the field even if there is value in there? If I can't modify the database, can I change textfield max length in the form to be 100?

Thanks!

The website doesn't have CCK, so I'm not sure how to modify these fields. I'm using Drupal 7.

What I did:
1. I upgraded registration_page.info to upgrade the version from 7.x-1.0 to 7.x-1.1
2. I changed the field max length to 100 in registration.features.field.info

When I tried to deploy, I got this error

  [sshexec] WD php: FieldUpdateForbiddenException: field_sql_storage cannot          [error]
  [sshexec] change the schema for an existing field with data. in
  [sshexec] field_sql_storage_field_update_forbid() (line 229 of
  [sshexec] /var/lib/www.mine.com/deploys/site_20140515_140323/modules/field/modules/field_sql_storage/field_sql_storage.module).
  [sshexec] Cannot modify header information - headers already sent by (output     [warning]
  [sshexec] started at
  [sshexec] /var/lib/www.mine.com/deploys/site_20140515_140323/sites/default/drushrc.php:2)
  [sshexec] bootstrap.inc:1212
  [sshexec] FieldUpdateForbiddenException: field_sql_storage cannot change the schema for an existing field with data. in field_sql_storage_field_update_forbid()

This is what the code look like in registration.features.field.info

 // Exported field: 'node-registration-page-field_city'.
  $fields['node-registration_page-field_city'] = array(
    'field_config' => array(
      'active' => '1',
      'cardinality' => '1',
      'deleted' => '0',
      'entity_types' => array(),
      'field_name' => 'field_city',
      'foreign keys' => array(
        'format' => array(
          'columns' => array(
            'format' => 'format',
          ),
          'table' => 'filter_format',
        ),
      ),
      'indexes' => array(
        'format' => array(
          0 => 'format',
        ),
      ),
      'locked' => '0',
      'module' => 'text',
      'settings' => array(
        'max_length' => '255',
      ),
      'translatable' => '0',
      'type' => 'text',
    ),
    'field_instance' => array(
      'bundle' => 'registration_page',
      'default_value' => NULL,
      'deleted' => '0',
      'description' => 'Please enter your city',
      'display' => array(
        'default' => array(
          'label' => 'above',
          'module' => 'text',
          'settings' => array(),
          'type' => 'text_default',
          'weight' => 31,
        ),
        'teaser' => array(
          'label' => 'above',
          'settings' => array(),
          'type' => 'hidden',
          'weight' => 0,
        ),
      ),
      'entity_type' => 'node',
      'field_name' => 'field_city',
      'label' => 'City',
      'required' => 0,
      'settings' => array(
        'text_processing' => '0',
        'user_register_form' => FALSE,
      ),
      'widget' => array(
        'active' => 1,
        'module' => 'text',
        'settings' => array(
          'size' => '60',
        ),
        'type' => 'text_textfield',
        'weight' => '26',
      ),
    ),
  );

As you mentioned, you already have textfield with 255 character length and also contains data. If you want reduce length of this field then you need to make sure that there is no data within this field having more than 100 character length. Because if this field contains any data more than 100 character length then you can't alter it in this way. My suggestion to you is first take backup of this table and empty this table. Then you would be able to change its length and then you can import this table data. If there is any data more than 100 character either it will stored in truncated way or give you any warnings for this. One thing you need to remember you need to do this offline, this question is specific to database and take care of every piece of data. There is possibility you might need to make some changes manually, so should take data base backup first.


How to export comment fields (or other settings) with Features? If I export a content type that has fields specified in the comment of the content type the fields of the comment are not exported.

How do I export those fields that I specified in the comment?

(In my case a have a Workflow status field specified in the comment)

I Managed to do this with the help of the Strongarm module.

In the variables table there are fields like:

comment_xxxx_xx_[content_type_name_here]

for example:
field_bundle_settings_comment__comment_node_my_content_type
comment_default_per_page_my_content_type
..etc

I just selected all of them. It would be better of course to work out what is stored where.

Also in Features in field instances I found fields like:
comment-comment_node_my_content_type-comment_body
..

In Features field_base I found something called comment_body

Exporting those seemed to be everything.
(Not too convenient to hunt fields and whatnot and maybe miss something..)


How to execute php script using drush? I am new to Drush. How can I execute this script to remove comments of a specific user?

$uid = xx // the spam users id;
$query = db_query("SELECT cid FROM {comments} WHERE uid = %d", $uid);
while($cid = db_result($query)) {
  comment_delete($cid);
}

Also, that would be great if you could tell me how to complete the script so that it takes username instead of $uid.

Thanks

You can convert the script in a Drush shell script.

  A drush shell script is any Unix shell script file that has its "execute" bit set (i.e., via chmod +x myscript.drush) and that begins with a specific line:

    #!/usr/bin/env drush

  or

    #!/full/path/to/drush

Drush scripts are better than Bash scripts for the following reasons:

They are written in PHP
Drush can bootstrap the site before running the script

The following is the example you can find on helloword.script.

#!/usr/bin/env drush

//
// This example demonstrates how to write a drush
// "shebang" script.  These scripts start with the
// line "#!/usr/bin/env drush" or "#!/full/path/to/drush".
//
// See `drush topic docs-scripts` for more information.
//
drush_print("Hello world!");
drush_print();
drush_print("The arguments to this command were:");

//
// If called with --everything, use drush_get_arguments
// to print the commandline arguments.  Note that this
// call will include 'php-script' (the drush command)
// and the path to this script.
//
if (drush_get_option('everything')) {
  drush_print("  " . implode("\n  ", drush_get_arguments()));
}
//
// If --everything is not included, then use
// drush_shift to pull off the arguments one at
// a time.  drush_shift only returns the user
// commandline arguments, and does not include
// the drush command or the path to this script.
//
else {
  while ($arg = drush_shift()) {
    drush_print('  ' . $arg);
  }
}

drush_print();

You can made the script executable, so you can  execute it with <script file> <parameters> where <script name> is the script name, and <parameters> are the parameters passed to the script; if the script is not executable, you call it with drush <script name> <parameters>.


Webform token in emails: need example I've got multiple web forms that email their submissions. I need to break it out into fields and keep it clean.

Say, on my webform, I've got a field named zip_code. How can I print that in a token, with no label?

Thank you.

EDIT: I want to use the built-it (but not documented) functionality

Under Webforms > E-mails > E-mail template choose Custom Template.

Remove the [submission:values] token. That's what lists all the fields and their values with labels. Customize the other text as you wish.

Note the "Browse available tokens." link below the text box. This pops up a window that shows you what placeholders you can put in to build your email. You can even click on the browse tokens popup to add them to the text field. Some of them can be used as-is. Some need additional info, like the field tokens.

Field values are under the Submission header.

For your zip_code field example, you can use:

For just field:
[submission:values:zip_code]

For just label:
[submission:values:zip_code:label]

For label and field:
[submission:values:zip_code:withlabel]

You'll see there's lots of other stuff you can use, too.

Hope this answers your questions.


Views Taxonomy Term Argument With Multiple Terms Hello I am having a torrid time creating a views block. Let me try to explain without rambling on about nothing as I usually do.

I have a content type (links) which uses the same vocab as my other content type (posts) When viewing a Post I was hoping to display any links that have the same terms.

Ive set it up with an Argument Taxonomy: Term ID. It all works as hoped when I have just ONE term on a post but when I have more than one term things start to get a bit strange.

Actually I should mention that I am using Load default argument from node page and just doing it on term id. I am not using Allow multiple terms per argument box. this returns no results (for nodes with multiple terms)

If I change the Argument type: to term id's seprated by ....+ etc I do get a return but it only shows links for one of the terms. Funny enough the term results are for the term that I dont want to use. I have changed the term weights and everything to try and change it to show the links for the term I was hoping for but I dont seem to be able to influence what terms results appear in the views box I have made.. Its got me tearing my hair out.

Can anyone understand my gibberish and offer any solutions?

I think I have sort of worked out a solution. It displays correctly in the Views preview but not on the node itself. Maybe this will help though.

View settings:

Create a Block. Configure Block to display on content of type Post. Configure settings of View:

Fields

Content: Title

Filter criteria

Content: Published (Yes)
Content: Type (= Links)

Contextual filters

(field_tags) Content: Title

Using relationship: Term

Relationships

Content: Taxonomy terms on node (term)
Taxonomy term: Content using Tags

Using relationship: term

In my preview, when I enter the title of a Post as the contextual filter, I get a list of all the links tagged with the same tags as the Post. For some reason, when I view the actual Post it doesn't work but that might just be a caching issue or something on my end?


How to remove any data "http_proxy" module added or changed? I have a serious problem with a broken XML-Feed, that occurred after I installed http_proxy module. I have uninstalled the module, cleared the cache several times and even truncated the cache tables of the database manually. (I have to admit i didn't made a database backup before the installation). The XML feed is flawless, actually it didn't change at all.

I have following error messages:

in the drupal log:

  Notice: Undefined offset: 1 in http_request_get() (Zeile 239 von
  /example.com/sites/all/modules/feeds/libraries/http_request.inc).

The error message above is 2 times in the log with the same timestamp.
Then more recent:

  Warning: simplexml_import_dom(): Invalid Nodetype to import in
  FeedsExXpathDomXpath->__construct() (Zeile 393 von
  /example.com/sites/all/modules/feeds_ex/src/FeedsExXml.inc).

followed by
from the feeds module log:

  Start tag expected, '<' not found on line 1. Error code: 4

So i guess this comes from the http_proxy module. How can i remove any trace of it? Does someone have another idea where to look?

Thanks!

Uninstalling the HTTP proxy module appears to not uninstall its configuration. So the proxy configuration is likely still in place in your case. I assume that the reason the HTTP proxy module does not remove the configuration is that it doesn't explicitly "owns" the configuration: it exposes hidden settings from Drupal core.

There is an issue about this reported in the http_proxy issue queue: https://www.drupal.org/node/2592461


How to send an email using Rules to everyone in an Organic Group based upon a date field? I have an OG content type with a date field. When the date in the field comes up, I want to use Rules to send an email to everyone in the group using the other fields (title/body/og name) in the node.

(Edit) My OG is "Teams" and the OG Content node type is "Events" with the date field.  So when field_date in Events is within 24 hours Rules will send out an email to all the OG Members of Teams.

I'm having a hard time wrapping my head around triggering the event based upon the date field and then send the node information to all the different users in the different groups.

To do what you're asking for, I would only use the Rules module, and the Rules Scheduler (a submodule of it), as further explained below.

Step 1 - Create a Rules Component

Create a Rules Component which looks like so (in Rules export format):

{ "rules_send_notification_to_og_members" : {
    "LABEL" : "Send notification to OG members",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "rules", "og" ],
    "USES VARIABLES" : { "current_node" : { "label" : "Current node", "type" : "node" } },
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "current-node" ],
          "type" : { "value" : { "book" : "book" } }
        }
      }
    ],
    "DO" : [
      { "og_get_members" : {
          "USING" : { "group_content" : [ "current-node" ] },
          "PROVIDE" : { "group_members" : { "group_members" : "List of group members" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "group-members" ] },
          "ITEM" : { "group_member" : "Current group member" },
          "DO" : [
            { "mail" : {
                "to" : [ "group-member:mail" ],
                "subject" : "Friendly reminder about some post in group",
                "message" : "Hello [group-member:name],\r\n\r\nThere is a reminder about a post with title [current-node:title] (located at [current-node:url]) which belongs to one of the groups you are subscribed to.\r\n\r\nSome more details about this node:\r\n\r\n- Price: [current-node:field-book-price]\r\n- Release Date: [current-node:field-book-release-date]",
                "language" : [ "" ]
              }
            }
          ]
        }
      }
    ]
  }
}

Some details about the above Rules Component:

Component Variables: only a "node" (of type "node"), of type "parameter", labeled "Current node", and machine name current_node.
Rules Condition: use whatever extra condition you need/want, but actually you may not need any at all. As a sample, I just used "Content is of type" (with actual type = book).
Rules Actions:

Get group members from group audience, for current_node, and store the result in a list with machine name group_members.
Perform a Rules Loop, for each item in the group_members list, whereas the item is named group_member. And for each iteration of this loop, send an eMail to the group member being processed, with all sorts of data about the node included in the eMail title and/or eMail body (use your own imagination to make it fit your needs).

Step 2 - Create a Rules which schedules the Rules Component

Create a Rule which looks like so (in Rules export format):

{ "rules_remind_og_members_about_node_content" : {
    "LABEL" : "Remind OG members about node content",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "og", "rules", "rules_scheduler" ],
    "ON" : [ "node_insert", "node_update" ],
    "IF" : [
      { "og_entity_is_group_content" : { "entity" : [ "node" ] } },
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_book_release_date" } }
    ],
    "DO" : [
      { "schedule_delete" : {
          "component" : "rules_send_notification_to_og_members",
          "task" : "Notify-OG-members-for-node-[node:nid]"
        }
      },
      { "schedule" : {
          "component" : "rules_send_notification_to_og_members",
          "date" : {
            "select" : "node:field-book-release-date",
            "date_offset" : { "value" : -259200 }
          },
          "identifier" : "Notify-OG-members-for-node-[node:nid]",
          "param_current_node" : [ "node" ]
        }
      }
    ]
  }
}

Some details about the above Rule:

Rules Events (either of both):

After saving new content.
After updating existing content.

Rules Conditions (all conditions must be true):

Entity group content, for entity = node.
Entity has field for field field_book_release_date, which is defined as a date field, and which you could consider as something like the release data of a book. Note: for nodes which don't have that field, or for which it is empty, this Rules Condition is false (so no Rules Actions will be performed).

Rules Actions:

Delete scheduled task, with Notify-OG-members-for-node-[node:nid] as the "Task identifier", whereas the task refers to the Rules Component created in Step 1.
Schedule component evaluation, with Notify-OG-members-for-node-[node:nid] as the "Task identifier", whereas the task refers to the Rules Component created in Step 1. And the actual date to schedule the execution of this Rules Component, is the date indicated in the node's field field_book_release_date, but with an offset of -3 days (pick whatever value for this offset the fits your needs), so 3 days before the date indicated in that field, the Rules Component is executed.

To be complete: the first Rules Action (to delete the previously scheduled task with the very same Task identifier), is to ensure that the Rules Component is only executed once. The typical scenario is that first the node gets created (and the Rules Component is  scheduled accordingly). But later on the node is updated. In that case, the request to execute the previously scheduled Rules Component is deleted, and a new request is scheduled again. And if the date itself was not updated, it will be scheduled for execution at the very same moment. But if the date was updated also, only the date of the most recent update will be taken into account. For this mechanism to work, it's important to use a unique Task Identifier, to be used in both Rules Actions. That's why I added the token [node:nid] to it (with a prefix like Notify-OG-members-for-node- so that it can be recognized by somebody looking at the currently scheduled Rules Components also).

Bonus tip - Resolving potential access issues

By using the Rules Scheduler, in the end the Rules Component will be executed when cron is running (the very first time after the date/time the Rules Component was asked to be scheduled). But cron jobs always run with user Anonymous.

So the question that remains is: "How will the eMail content look like if you're processing a node for which an anonymous user has no access?". If you run in any such access issues, the easiest workaround I can think of is that you improve the Rules Component by adding additional variables (used as "Parameter"), and so that these variables contain the values of the relevant node's fields that you want to be able to refer to in the eMail to be created. Since the user who triggers the Rule from Step 2 (due to a create or update of a node) should have (read) access, for sure these values will be passed to the Rules Component at the time of scheduling the Rules Component.

PS: I'm assuming this question is about D7.


How to use hook_views to add calculation to a field? In a custom module (assoc), I have a custom Content Entity (Person) with these fields:

$fields['lastname'] = BaseFieldDefinition::create('string')
$fields['firstname'] = BaseFieldDefinition::create('string')
$fields['email'] = BaseFieldDefinition::create('email')
$fields['cellphone'] = BaseFieldDefinition::create('telephone')
$fields['balance'] = BaseFieldDefinition::create('integer')

I use Views to display a table of the persons. Here is the corresponding Views preview:

Before displaying the output, I'd like to add some value to the field 'balance':
balance = balance (of content entity) + somecredit - somedebit
'somecredit' and 'somedebit' being calculated by a query to the database.
What is the hook_views I should use ?
And how do I do?

Finally, after some (!!) digging, I did it in assoc_views_post_execute

function assoc_views_post_execute(ViewExecutable $view)
{
  switch ($view->id()) {
    case 'assoc_persons':
      if ($view->current_display == 'page_1') {
        $database = \Drupal::database();
        foreach ($view->result as $key => $value) {
          $person = $value->_entity->get('id')->value;
          $solde = $value->_entity->get('balance')->value;

          some code to calculate credit with database query
          $credit = $result[0]->credit;

          some code to calculate debit with database query
          $debit = $result[0]->debit;

          $solde = $solde + $credit - $debit;
          $value->_entity->set('balance', $solde);
        }
      }
      break;
    default:

  }
}


Candidate page template filename for particular custom content type entry I'm working on a Drupal 7 website. I created custom content type for works. I have many fields, and some of them are related to page layout like particular page bg for each entry. So I need custom page.tpl for this particular content type.

So I activated and opened Theme Developer module, and clicked the body area to get candidate name for this particular content type page entry. and it gives me the screen below which doesn't mean anything to me :/ When I click the node area, it is fine, it gives node--work.tpl.php, but I need for page. I tried "page--work.tpl.php", it didnt work.

What am I missing?

function mytheme_process_page(&$variables) {
    $variables['theme_hook_suggestions'][] = 'page__'. $variables['node']->type;
}

Assuming your machine-readable content type name is "work", page--work.tpl.php will work.

Refer to this thread for more info.


How do I mass update entities? How do I perform mass updates for entities? Suppose I want to publish 50 nodes at once. How should I do that?

You can perform most of the mass updates in Admin > Content page.

If you require any advanced actions, sorting, filtering, I'd suggest you use Views and Views Bulk Operations modules.


Conditional change row colors Say I have a content type "task" with one field "status", which is output by views. Now I want when the status is "finished", the color of that row will be red, when the status is "failed", the color of that row will be yellow, when the status is "ongoing", the color of that row will be green.
Is there any way to realize this? BTW, I know very little about code.

There are 2 ways to do this, but you should do this the Drupal way.

You can use JavaScript to iterate through each
 adding a class to the
 if it finds finished in the last column.
You can do it the Drupal way in views. I assume you are using the table view to output your data since that's what you are showing us.

Under your edit view mode, you'll see "Format" and then "Format:Table | Settings".

Click on Settings. Under settings you should see an option that says "Row Class".

You want to set your row class equal to the value of the status field. To do this. Look under Fields to find the field that is displaying your status column and click to edit it. Once there, select "Rewrite results" and then click the "Override the output of this field with custom text" checkbox.

This will open a textbox with an option below it stating "Replacement Patterns." when you click this, you should see some options inside of {{ }}. There will likely be one that looks something like {{ status }} == Status.

The {{ status }} part is your replacement pattern. Copy it and paste it into the row class field under table settings.

What this will do is add a class to your
 in your view.

Example of what the view output will then look like:

  3/5/19>
  write article
  finished

After completing this step, you need to add a bit of CSS to your stylesheet in your theme.

Something like:

tr.finished td { color: red; }
tr.ongoing td { color: green; }
tr.failed td { color: yellow; }

So you end up changing the row class to be the replacement pattern of your status field and adding 3 lines of CSS code to your theme's style sheet.


Installing ckeditor youtube plugin Does anyone know how to extend the ckeditor to add the youtube plugin in Drupal-7?
I am talking about this plugin http://ckeditor.com/addon/youtube.
What is the drupal way of adding this?

https://www.drupal.org/project/wysiwyg_mediaembed
Might be what you're looking for and it has a useful issue board if you run into trouble...


Why some functionality of my drupal site is different on different PCs? I created a site but when I log in from another PC (exact same site), some things are different.
Like on my laptop, my ajax loader is working beautifully but it lags on my office computer.
There is a message on successful image update (from media module) on my PC but there is no message in my laptop (however that should be the case).

What's happening here? I'm lost.

UPDATE

I saw a JavaScript error on my PC which is very much different than the JS error on my laptop. They are the same file, same webroot and same website. Even after turning off my development environment, I am not going further.

UPDATE

Problem Solved, the origin of the issue was JQuery Conflict. After defining different reference variables, my problem is free. Although I still don't understand why this was not a problem in my machine. Is there a mechanism that I'm missing?

The origin of the issue was Jquery Conflict. After defining different reference variables, my problem is free.


Pre load entity reference fields into a node Say I have three content types: Team member, Team and Matchday.

The team content type is made up of entity reference fields, which reference team members.

The Matchday content type should load team members from the Team content type automatically each time a new piece of content is created. Then the content editor should be able to delete people on each Matchday who don't show up, and also add members from other teams who are filling in.

Anyone know how to do this in Drupal 8, even just a general idea to point me in the right direction?

Add an entity reference field to team members content type.
Using form alter:
Hide the above field in the add form.
Add an entity reference render element that points to the team content type.
In the submit callback load all the team members that in the selected team and add them to the entity member field.


Resize & Crop Image Style Lowers Resolution Whenever I try to implement a "resize & crop" image style on the display of a node in Drupal 7, the image also comes out with a lower resolution than the original file. Any idea why this might be happening or how I can get it to stop?

Thank you.

The jpeg quality is defined at 75%, this can be changed at /admin/config/media/image-toolkit


How to set only one save button for a page with Editable Fields by Views? Using Views, I created a page that has editable fields(by Editable Fields Module) for Profile2 fields. Those editable fields have few kinds of type/widget of field such as Text, SHS(Simple Hierarchical Select) for Term reference, and Radio Button for List (text).

Now, I have a problem that few save buttons for each type/widget of fields are displayed in the page. The one is placed below SHS field and seems for saving only it, another is placed below the Radio Button field, and the other is for the Text one.

I want only one save button for all of fields in a page. Do anybody know how to unify those save buttons into one?

You can use Editable views module. It uses one save button for all fields in a view.
Editable Views:

Editable Views lets you create Views where the fields can be edited. Fields show both the current value and a form to edit it. A 'Save' button allows saving of all the entities shown in the View.
Editable fields can be added on the base entity as well as on entities brought into the View by a relationship. Other, non-editable fields may be added to the View, in which case they function normally.
Currently, the following Views fields can be edited:

All FieldAPI fields
Node title


How do I display all terms of nodes created by user in a user view field I have a User view where I list user information with contextual filter UID. I want to display all the terms from the nodes that the user added. I added the Author relationship so that way I can display the terms field to the view.

The issue is that the field only displays the terms of the first node added by the user. The aim is to display all the terms of all the nodes added by the user. Preferably with no repetition.

So if user U added node A with term X and Y and also added node B with term X and Z, the views filed should display term X, Y and Z.

What am I doing wrong that only the user's first node's terms display?

It's not likely you have it working the way you describe it, even for one node.

You need to first connect the users to the nodes, before you can make further connection to terms on those nodes.

The easiest to create such views is through Taxonomy term type, not User type, since it's the terms you want to list in the end:

Create Taxonomy term Views with 0 Pager (to show all items)
Under Fields add Taxonomy term: Name if you don't have it already
add Relationship Content using field_[name], require it
Add another Relationship Content author, require it (it will automatically use the first Relationship)
Add a Contextual filter User ID, it will automatically use the author Relationship, and configure it:
When the filter value is NOT available
Provide default value
User ID from route context
When the filter value IS available or a default is provided
Specify validation criteria
User ID
Single ID
Hide view
Turn Aggregation on.

To test the views enter a user ID into the Preview field, it should show a list of terms associated with the user's node's field you added the Relationship for.

Aggregation takes care that there are no duplicates in the results.


Seeking a point/level module to encourage user activity I have a very new site. Users have occassionaly popped in to say "hi" and that's about it.

I suspect a chicken and egg situation - I won't get content until there is content.

I seem to recall that Drupal Commons (sadly my server seems too  slow for it) has a system which is fairly standard in forums, where users get points and gainlevels for activity.

Is there something like that which is simple to add for a new admin on D7?

Thanks in advance

p.s. That's at its simplest, from an old school forumer; maybe I need +/-or "like/dislike" or new-fangled facebooky stuff?

For various voting and similar systems you could check these modules (including some quotes from their project pages):

Voting API:

  ... helps developers who want to use a standardized API and schema for storing, retrieving, and tabulating votes for Drupal content.

Fivestar:

  ... adds a clean, attractive voting widget to nodes and comments and any entity.

User Points:

  ... provides an API for users to gain or lose points for performing certain actions on your site. In conjunction with other modules, such as the Userpoints Nodes and Comments users can accumulate points for actions such as posting nodes, commenting or moderation duties.

Flag:

  ... is a flexible flagging system that is completely customizable by the administrator. Using this module, the site administrator can provide any number of flags for nodes, comments, users, and any other type of entity. Some possibilities include bookmarks, marking important, friends, or flag as offensive. With extensive views integration, you can create custom lists of popular content or keep tabs on important content.


Downloading a feed's embedded images to server and rewriting paths in html automatically I'm scraping a some sites into a csv which is then used by feeds importer module to create Drupal content.

Some of the content are html chunks containing html+images in them which go into "body"/textarea kind of fields to be displayed.

How do I use feeds tamper or some other method to

Download these embedded images to server and
Rewrite the image paths in the HTML chunks to point to server paths

Possible solution:

Rewrite the paths in the html to internal paths registered via "hook_menu". When the path is called, if the image is not there, use "system_retrieve_file" to download the file and serve it .. Example hook_menu() implemented at image_menu. {Thanks Ciss @ drupal-support irc channel} Rewriting would be taken care of by feed_tamper that I have already.

To clarify - I know that if I use image urls with image fields, the images will be downloaded automatically. However I don't know how to download images that are within a HTML chunk.. thanks.

One possible solution is the feeds_imagegrabber module.

What is does is when the feed is importing it goes to the original web page of the feed item and scrapes the image from the page and imports it into drupal.

Depending on the specifics of your requirements this could be a good easy solution.


Is it possible to create a custom theme function? I want for example to create a mytheme_table function to override theme_table etc. (in template.php) but I do not want to use it everywhere in my project.

I need to replace the table with a div or to remove some hardcoded wrappers.

$output .= theme('table_custom', array('header' => $header, 'rows' =>
$rows, 'attributes' => array('id' => $table_id, 'class' =>
array('field-multiple-table'))));

you don't have to use hooks in your theme functions.   you could create your own function called theme_table_custom()  and use that in your template files.

if for some reason you must use the hook, you could include the original drupal code in the function and include a check for a table id or something, which would then fire your custom code.


How to get the list of fields available in the user entity I have created a custom field to allow users to set their privacy settings based on the fields attached into their account.

I would like to get the list of fields available in the user entity so that I can create a table select form where the users can select the permission per field based on account type.

How to do it in a custom field?

Here's my curreny code:

  namespace Drupal\privacy_settings\Plugin\Field\FieldType;

  /**
   * @FieldType(
   *   id = "privacy_settings",
   *   label = @Translation("Privacy Settings"),
   *   description = @Translation("Privacy Settings"),
   *   default_widget = "privacy_settings_widget",
   *   default_formatter = "privacy_settings_formatter_default"
   * )
   */
  class PrivacySettingsField extends FieldItemBase {

  /**
   * {@inheritdoc}
   */
  public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    $properties['value'] = DataDefinition::create('string')
      ->setLabel(new TranslatableMarkup('@operation access', ['@operation' => 'Privacy Settings']));
    return $properties;
  }

  /**
   * {@inheritdoc}
   */
  public static function schema(FieldStorageDefinitionInterface $field_definition) {
    return [
      'columns' => [
        'value' => [
          'type' => 'blob',
          'size' => 'big',
          'serialize' => TRUE,
          'not null' => TRUE,
        ],
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function setValue($values, $notify = TRUE) {
    if (isset($values['value']['table']['rows'])) {
      $values['value'] = serialize($values['value']['table']['rows']);
    }
    parent::setValue($values, $notify);
  }

  /**
   * {@inheritdoc}
   */
  public function isEmpty() {
    $value = $this->get('value')->getValue();
    return $value === NULL || $value === '';
  }

  /**
   * Return the list of operations available.
   *
   * @return array
   *   The list of operations.
   */
  public function getOperations() {
   return [
      t('Account Type 1'),
      t('Account Type 2'),
      t('Account Type 3')
    ];
  }

}

You can get user entity field definitions list by using the following code:

$user_field_definitions = \Drupal::service('entity_field.manager')
  ->getFieldDefinitions('user', 'user');
// List of user field definitions.
dump($user_field_definitions);


Feeds vs. Aggregator for rss Is it fair to say that aggregator is retained in d7 core for legacy support, and that Feeds is the likely successor?   Feeds covers more scenarios than aggregator, and appears to be better situated for adaptions, although the generalization makes it more difficult to understand how to go about implementing.    Are there projects that you can recommend that build on themes to implement particular use cases?

--- Looking through the Feeds documentation, we find the statement

  "Feed: aggregation importer. Aggregates RSS/Atom feeds to nodes.
  Provides a node type Feed and a node type Feed item. Create one or
  more "Feed" nodes to add RSS/Atom feeds to your site. On cron, these
  feeds will continuously produce "Feed item" nodes. Requires the
  Aggregator core module to be enabled.

So project/feeds depends on core aggregator, although it seems to overlap and extend functionality as well.

Even though the module's name is 'Feeds' , it can import CSV, XML and other types of data too. Also, you can attach them to a stand alone form or a node type form.

The basic difference between aggregator and Feeds module is, how it stores data.

Aggregator module stores categories, feed URLs and imported data in its own tables. You will have Views support but it cannot be extended like nodes or such entity.

Also, you will not be able to map data. It's almost a fixed structure, like title to title, body to body, etc.

But in case of Feeds, you can decide what you need.
You can build a standard feed importer that maps feed item's title to node title and contents to a body field. But you can also be radical by mapping to other fields.

You also can use different entities as the target.
It also has 'pubsubhubbub' support which Aggregator doesn't support.

Both modules uses cron to fetch data.

Use aggregator if you want to show contents from few RSS/atom feeds in a simple block.
For all other cases, I'd recommend Feeds module.


Organic Groups -- Load group from gid This seems like it should be a simple operation, but I must be completely blind because I can't find anything about it in the API docs at http://www.drupalcontrib.org/api/drupal/contributions!og!og.module/7.

I have a $gid. I need to check if it really is the gid of a valid group, and have access to the group information if it is.

I did find an old post somewhere saying to use og_load(), but that is out of date -- that function does not exist in the current API. Nor can I find a function with similar functionality.

There has to be a simple way to do this; it's hardly an outlier use-case. What am I missing?

You don't need to use group_load anymore! Use node_load instead. You gid is equivalent to nid.


How do I a custom entity operation with a webform submission? My lack of D8 experience is going to show by just how many unknowns I have here. I hope someone can link some of the pieces for me.

I created a custom action using hook_entity_operation_alter() on the admin/structure/webform/manage/dis_document_generator/results/submissions page as you can see below. I'm guessing this will show up on various other pages to which is fine.

Currently as you can see the url is set to the current page but this needs to change once I have a controller redirect to. Also, it would be nice to add this operation through a controller instead of a hook but that's not important at the moment.

    /**
     * Implements hook_entity_operation_alter()
     */
    function dis_doc_gen_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) {
      if ($entity->getEntityTypeId() === 'webform_submission' && $entity->bundle() === 'dis_document_generator') {

        static $operation;
        static $permission;

        if (is_null($operation)) {
          $user = \Drupal::currentUser();
          $permission = $user->hasPermission('utilize mq client');

          $url = \Drupal\Core\Url::fromRoute('<current>');

          $operation = [
            'title' => t('Send XML'),
            'weight' => 8,
            'url' => $url,
          ];
        }

        if ($permission) {
          $operations['send_xml'] = $operation;
        }
      }
    }

I was using WebformSubmissionNotesForm.php as a sample to create a controller because it looked relatively simple but I'm not sure if it's a best choice because I don't actually need a form. I'm just going to perform an action and then return however using it for now.

The router for it is this:

entity.webform_submission.notes_form:
  path: '/admin/structure/webform/manage/{webform}/submission/{webform_submission}/notes'
  defaults:
    _entity_form: 'webform_submission.notes'
    _title_callback: '\Drupal\webform\Controller\WebformSubmissionViewController::title'
  requirements:
    _entity_access: 'webform_submission.notes'

With my module being called dis_doc_gen I gather that my router details should look like this?:

dis_doc_gen.webform_submission.sendxml:
  path: '/admin/structure/webform/manage/{webform}/submission/{webform_submission}/sendxml'
  defaults:
    _entity_form: 'dis_doc_gen.sendxml'
    _title_callback: 'Send XML'
  requirements:
    _entity_access: 'dis_doc_gen.utilize_mq_client'

where my permission is called utilize mq client and so I believe it would be represented here as dis_doc_gen.utilize_mq_client.

Finally, WebformSubmissionNotesForm.php sits under webform/src. The one plugin I managed to do for my webform had to go under webform/src/Plugin/WebformHandler so I'm wondering since this is off a webform submission whether I need to place a controller at:

webform/src or
webform/src/Plugin/WebformHandler or
webform/src/Plugin/WebformSubmissionHandler.

Last, webform defines WebformSubmissionNotesForm in it's header like this:

<?php
/**
 * Defines the WebformSubmission entity.
 *
 * @ingroup webform
 *
 * @ContentEntityType(
 *   handlers = {
 *     "form" = {
 *       "notes" = "Drupal\webform\WebformSubmissionNotesForm",

Since I can't have that hardcoded like that for my new controller I gather that's fine because I can just attach my controller through the interface.

It seems the answer came from spending a day (and a bit) just studying the inner workings of D8 and realizing just how much is done for you that wasn't the case in D7.

Ultimately I want to send the action to a Controller, not a plugin and the primary source for getting enough grounding to figure it out came from the following:

https://www.drupal.org/docs/8/api/routing-system/structure-of-routes
https://www.drupal.org/docs/8/api/configuration-api/creating-a-configuration-entity-type-in-drupal-8
https://www.drupal.org/docs/8/api/entity-api/creating-a-content-entity-type-in-drupal-8


How do "Order Types" and "Order Item Types" work? I'm using the Commerce framework. I'm trying to understand exactly how "Order Types" and "Order Item Types" work. (I've consulted the docs; they don't really address this question.)
So far, I've deduced that:

The Checkout Flow that Drupal uses is determined by the Order Type that's in play.
Every Order has an Order Type.
Every Order Item has an Order Item Type.
Every Order Item Type belongs to an Order Type.

...but that's as far as I've gotten. I'm trying to understand:

What rules does Drupal use to decide which Order Type it's dealing with? (That is, how does it know which Order Type is in play?)
At what point in the is this decision made? (When the user first adds an item to their cart? When they begin the checkout process? At some other point?)

Thanks!

What rules does Drupal use to decide which Order Type it's dealing with?

That's determined by order type resolvers (implementing OrderTypeResolverInterface in this case). Such resolvers are given an order item, and must use that to determine the type of order.
Out of the box, the default resolver (DefaultOrderTypeResolver) uses the bundle of the given order item, which will be an order item type ID, to load that item type entity, and get the associated order type ID from it.

At what point in the is this decision made?

There are probably multiple places that decision is made (creating orders in the admin UI for example), but in terms of the cart, it happens when the cart is created, which in turn happens when an item is first added to it via the standard AddToCartForm submission.
So I think it's fair to say that the type of an order that originated from a cart will always be the type associated with the first item that was added to it.


How to edit views settings I created a views. I am not sure what I selected show and Type when I created the view.

After I created the view, I see it is retrieving data from multiple content types. I am trying to edit the view to select the specific content type but i cant find it under edit view page.

Content type that I created name is "xpress". View name is "GlobalSearch". How can I edit the view and select to display only the content type "xpress".

Thanks.
D

admin/structure/views/view/globalsearch/edit

Filter criteria > type maybe?


Migrate fields with content from drupal 6 from different DB Can't understand how migrate node fields from different DB (I mean migration to clear drupal 7 site). At first, I migrate fields by content migrate module but in this case db contain too much garbage. Tried to it by migrate module but didn't find how to do this.
Then I used migrate_d2d module, but it doesn't help at all.

Is there way to migrate fields and content without writing by hand each field migration?

If by "writing by hand" you mean writing PHP code, then the answer is no. The migration module is a migration framework; it provides the tools (API, PHP classes, etc) to migrate data but it doesn't do it for you. Migrate D2D (built off the Migration framework) provides some support with "out of the box" importing (e.g. User Roles, Pics, Taxonomy, etc.), but it doesn't do it all for you.

The key thing to understand is complexity of the problem; content in Drupal can be configured in a myriad of different ways. As such, one module that can handle all the different permutations of sources (e.g. CSV, WordPress site, various DB's, & an old Drupal install), field configurations (e.g. ints, floats, text, custom objects, custom fields, module create fields), & destinations (e.g. custom node types, module-create node types, custom entities, etc.) is a mammoth task for an open-source project.

Instead, the Migration & Migrate D2D maintainers have made the problem more tractable. They've provided some common tools that are likely to be used in any Drupal migration. Filling in the last bit of details (e.g. should a phone field be mapped to an address field or as a text field) is up to you because only you can possible know that information and how it's used.


Should I log the user out after calling an API using the Services module? I am using Services 3.X to make API calls in my Drupal installation.  In order to update a user I:

Make an API call to log in with an account which has rights to modify users (I'm using an admin account)
Using the session I received from step 2, I make another API call to modify a user.

That works.  My question is, should I have a step 3 and log out the account I used in step 1?  The logout, of course will be done via the Services API.  Would there be any bad side effects of not logging the account out?

Thanks.

If you log the user out, the session ID that you received and used to modify users will expire, so it's recommended to do so.

I can imagine the following scenario:

You leave the user logged in. Someone else who have access to the server that you used to do the aforementioned actions somehow figures out the recently used session ID. They can use it to log in to your Drupal site within the maximum session lifetime.


How can i give link in block for only listed paths based on user id? I have created block and i want to give the only listed paths

i.e user/user_id   ex: user/123

i have given user/*  but it displays all pages where users pages are there.

i tried below ways

and enabled PHPFILTER and tried this

Try "extended_block_visibility" module, install it and then on block setting page select last option "pages on which this php code will return true" and then you can write php code inside php tag like :

<?php
if(arg(0) == 'user' && is_numeric(arg(1))){
return TRUE;
}
return FALSE;
?>

But remember this code will save inside the DB and will break site if write wrong code. Alternatively you can define theme specific visibility using this module.


How to add month and year dropdown to calendar month view I want to add a month and a year dropdown to the month view of calendar so a user can jump to any month from the dropdown and can jump to the year, if selected. (Users can pick month OR year and will get results). I can add an exposed filter that doesn't update the calendar display when I click apply.

Any suggestions of what terms to search for or how to start this. I cannot seem to find tutorials or posts on this other than people saying yeah, I want that but I have no idea how to do it without building a custom calendar or using jquery datepicker.

The Date module has a subproject called Date Views. Once that
module is enabled, you can add exposed filters to your date fields. Setting the filter option Date selection form element to select will provide the dropdown selection widget for your date.

Finally, under the Advanced > Exposed form > Exposed form style > Settings link there's an Autosubmit option that will submit the filter form upon date change.


How to properly check the menu for emptiness in twig? I use Simplify Menu to display the necessary menu markup. How do I make sure that the menu is not empty (there are items there) and if there are menu items, they are enabled?
{% set items = simplify_menu('main') %}

    {% for menu_item in items.menu_tree %}

      {{ menu_item.text }}

{% endfor %}

In my work, I use the Twig tweak module, but I can't do a check with it either:
{% if drupal_menu('main') is empty %}
{% endif %}

This is tricky as you would expect {% if drupal_menu('main') is empty %} to work for checking if the menu exists or not. In reality, you'll want to use the render filter for twig. So that would become:
{% if drupal_menu('main') | render %}

I tested this code in my theme's page.html.twig file and it works. e.g.
{% if drupal_menu('main') | render %}
  {{ 'Main menu is not empty'|t }}
{% else %}
  {{ 'Main menu is empty'|t }}
{% endif %}

There is a very long winded issue here with regard to this:
[meta] Themes improperly check renderable arrays when determining visibility
There are also some related issues for this.

2447049: Add a render filter to twig
Checking for empty fields in Twig templates is complicated


Views slideshow countinuous rotation I have some contents (organisms : a content type) to slide continuously... I already installed views slideshow 7.x-3.0 for another slider which has normal behavior.

Is it possible that I get my organisms rotate continuously like HTML marquee effect ?

with views slideshow or other modules ?

IMHO, Views Slideshow doesn't really make things easier (unless maybe if you don't want to write a single line of code).

I prefer to create a normal view (displaying fields or a rendered entity, whatever you like) and use jQuery Cycle to turn the views rows into slides. You just need to:

download the jQuery Cycle plugin to your theme's javascript directory
add a 'Drupal behavior' to a custom javascript file which initiates the jQuery Cycle (see the example code on the jQuery Cycle site)
make sure both javascript files are loaded by adding them to your theme's .info file

jQuery Cycle can definitely rotate continuously, just look at the demo's on its homepage.


Having trouble understanding hook_theme() I'm going through the Drupalize.me tutorials on module development, but I've come across something that has me a little stumped. In the module, called "spy_glass", we created a basic theme hook like so:

function spy_glass_theme() {
  return array(
   'spy_glass_item' => array(
       'arguments' => array('title' => NULL, 'data' => NULL),
       'template' => 'spy-glass-item',
    ),
  );
}

Which is all well and good. It eventually gets called by spy_glass_page() which uses the theme hook to create to loop through an $information array, which is formed elsewhere and consists of 2 keys: title, and data.

function spy_glass_page($node) {
    $information = _spy_glass_serious_spying_business($node);

    $content = array();
    foreach ($information as $item) {
        $content[] = array(
            '#type' => 'markup',
            '#markup' => theme('spy_glass_item', $item),
        );
    }
    return $content;
 }

All good. Everything works as expected later when its passed to a spy_glass_preprocess_spy_glass_item() function and printed to a template. But here's what I don't understand. What the heck is this line of code doing in spy_glass_theme():

 'arguments' => array('title' => NULL, 'data' => NULL),

I've removed it and it literally changed nothing at all. Everything still works perfectly. What is the purpose of this?

I think this is a typo on your part or Drupalize.me.  You should supply a variables array that defines the default values of the variables passed to your theme function if the calling function does not supply them.  It's not necessary, but seems to be good practice to NULL at least title and data.

From the api:

  variables: (see above) Each array key is the name of the variable, and
  the value given is used as the default value if the function calling
  theme() does not supply it. Template implementations receive each
  array key as a variable in the template file (so they must be legal
  PHP variable names). Function implementations are passed the variables
  in a single $variables function argument.

function spy_glass_theme() {
  return array(
   'spy_glass_item' => array(
     'variables' => array('title' => NULL, 'data' => NULL),
     'template' => 'spy-glass-item',
    ),
  );
}

And then your theme function:

function theme_spy_glass_item($variables) {
  $title = $variables['title'];
  $data = $variables['data'];
}

Or, if you're using .tpl.php, you simply have access to the variables $title and $data.


Rewrite Links Array to include Nesting I'm attempting to modify the language switcher links in a block so that the items are properly nested per my site's menu structure.

Currently, it outputs:

English Link

Japanese Link

Spanish Link

I need:

English Link

Japanese Link

Spanish Link

The $build['content']['#links'] array contains:

array (size=4)
  'en' =>
    array (size=5)
      'url' =>
        object(Drupal\Core\Url)[14062]
        ...
    'ja' =>
        array (size=5)
          'url' =>
            object(Drupal\Core\Url)[14062]

How can I modify this array so that elements are nested in a ul under the first link?

In my experience, the structure you're looking for is created by the template layer. I would not recommend changing the link array directly. A good example template is core's stable theme's menu.html.twig. It uses a recursive twig macro to create nested lists.


Syntax highlighting for admin-side text areas (during node or block editing) I'm trying to find a module that will highlight HTML (and preferably CSS/JavaScript inside of style/script tags, but that's an added bonus) when I'm editing a node or block in the administrative side of Drupal.

While I've searched on drupal.org for syntax highlighting modules and come across options like GeSHi and Syntax Highlighter, both of those seem to be for the public-facing end content and not the administrative side. Am I wrong and would one be suitable for me? I've also seen a few projects that highlight PHP code blocks, but that's less important to me than HTML/CSS/JavaScript.

I never use a WYSIWYG editor for my own HTML but some highlighting would be very helpful in editing my content.

I use the BUEditor module, for which you can add syntax highlighting with some additional configuration.  You can specify to only allow administrators access to this interface via the module's options page.

Step-by-step instructions

Install the BUEditor module (I used 1.6).
Download bue.highlight.min.css and bue.highlight.min.js from this page.  I placed these files in a bueditor directory inside the directory for my custom theme.
Go to the BUEditor config page: /admin/config/content/bueditor.  Edit the settings for the relevant version(s) of BUEditor (probably default, but it depends on which you assign to each role-- if you want, you can configure different BUEditor options per role, but then you will need to set up syntax highlighting for each.)
On the Editor settings screen, click the Editor paths tab and then add the following Editor specific library files (My example assumes that you put the JS in your theme directory.):

  %THEME/bueditor/bue.highlight.min.css
  %THEME/bueditor/bue.highlight.min.js

Then, scroll down to the bottom of that page (under Buttons) and add tpl:syntax along with this code:

js:
BUE.postprocess._turnOnHlight = function(E, $) {
  setTimeout(function(){E.highlight('html')});
};

Then save the configuration and you should be good to go.


How to get the publishing and menu fields from the node edit form in the "Manage fields" tab? I am wondering what is the cleanest way to customize the core node edit form fields like the publishing and menu options fields?

They do not appear in the Manage fields tab, otherwise I would be able to organize them using modules like Display Suite, Field Groups, and either Conditional Fields or Field Conditional States as I do with other fields.

Here are a few example of things I would like to do (I achieved such things in the past with Drupal 6 by altering the form array, but I want to avoid this now since this was more complex, less maintainable and with not enough separation between the presentation and application logic):

Adding supplementary fields to existing tabs: My site has news articles which can be promoted on the front-page (using the standard Drupal checkbox) and/or appear on some other pages (using multiple Entity Reference fields). All these control should be grouped together since they all are publishing options from the end-user perspective.
Core fields availability dynamically depends on custom fields: A user can choose to link the node title and the node's menu link title so changing one will alter the other automatically. In such case the field asking to enter the menu link title must be hidden. However, it must show-up if for some reason the user choose to unlink them and set different values for both titles.
Core fields availability dynamically depends on other core fields: Some content can be created either with no menu item, in which case it can only be referenced by other nodes, or with a menu item, in which case the end-user can choose to publish or unpublish it. The Published option should therefore be available only when the user chose to create a menu item since it is not relevant otherwise for this content-type.

I tried with Display Suite extra's Extra fields feature, but it only adds the fields on the Manage display tab, and not the Manage fields as I need.

My current solution is to add standard custom fields to the node, hide the default ones and code the logic in hook_node_presave() for instance, but I do not know if there any cleaner solution?

Issue solved mainly thank to the Renderable elements module.

It adds the core node edit form's vertical tabs and their content to the usual Manage fields tab, allowing any kind of customization (adding, removing, reordering tabs and fields, the tabs properties can even be turned into horizontal tabs if one needs this, etc.).

There is a very good short video introducing this module's main features.

The only limitation is that the way this module alter the forms may cause incompatibilities with other modules. On my side I just noticed minor issues with no impact to the end-user:

The standard checkbox "Provide a menu link" does not hide automatically the other menu related options depending on its state, this is a non-issue for me since I precisely wanted to customize this behavior,
Modules like Conditional Fields do not detect yet the supplementary fields added by the Renderable Elements module. The few States API effects directly involving these fields might need to be coded specifically (Conditional Fields offers an option to manually define the jQuery selector to be used, I didn't tried yet if this could be a reliable workaround for this issue),
Other modules which were already programmatically altering the default vertical tabs may be confused and become unable to alter the tabs anymore. For instance, Fast Permissions Administration does not add anymore its "Manage Permissions" link in the Publishing options vertical tab.

The good news is that this module is fully compatible with Display Suite and Field Group. The vertical tabs and its components can be moved to any Display Suite's region, but more importantly the vertical tabs content can be organized in any kind of group you like (<DIV> markers, (collapsible) fieldsets, other tabs, etc.).


Import users from LDAP I want to import user accounts to my Drupal site via the LDAP server. How do I do that? I installed LDAP feeds, but I don't understand how it works. I have LDAP query installed and working.

As the comment noted this question would benefit from much more detail.

There are 2 very broad scenarios here;

Loading LDAP user attributes for use and reference within Drupal (probably user entities) users that exist.
Linking LDAP users to Drupal in an ongoing fashion including some form of authentication requirement.

In the first case you won't likely be dealing with LDAP user credentials (which is good) and greatly simplifies the implementation.  This is a good example; on Drupal.org using LDAP feeds.

In the second case LDAP feeds is probably not the best or only module you'll need.  This d.o article covers some ground but there are important gaps, but also some good linked resources in that section that could be of great help to you depending on your needs.

There are a plethora of variants on these cases.  One time vs ongoing, update bi-directional or with one resource overwriting the other as authoritative, updating non-user entities and keeping them in reference to users, and many more.  This split is designed to identify the most likely cases from the question you asked.

If this is one-time, an option (not ideal) may be to bring the users into an interim D7 instance and then migrate them to D8.  This could be done repeatedly but would require a standing D7 instance to maintain.  I'd only suggest this until the D8 LDAP feeds project is further along.  It could give you time to dig in and contribute as well. ;)

Giving this further thought and since the module isn't fully ported, this could be done with a server cron, a little scripting and a docker D7 instance.  A nightly docker spin up, pull from LDAP into D7 and migrate users to D8.  It's far from a good solution.  But it sounds like your need is immediate and this would work.  If time isn't a factor either porting the module yourself or paying someone to do it is the best path.

I'm happy to amend or expand this answer as needed based on additional information added in your question.


Views Link Display Settings Is Not Accepting External URL I want to add an external URL to the Views More Link Display Settings. It is also mentioned in the guide lines as well ("A Drupal path or external URL the more link will point to. Note that this will override the link display setting above."). But it is validating the URL using internal path component.

Error:- InvalidArgumentException: The internal path component 'https://www.google.com' is external. You are not allowed to specify an external URL together with internal:/. in Drupal\Core\Url::fromInternalUri() (line 410 of /var/www/drupal/web/core/lib/Drupal/Core/Url.php).

Please refer to this screenshot.

Please share if there is a way to alter the link display settings.
Thanks in advance!

You must be using an older version of Drupal because this has been fixed: Views throws InvalidArgumentException in More Link with external URLs.

I tried it on the latest Drupal 8.6.2 and it accepts external urls (your example) without any errors.

You should update to the latest version, even more so for security fixes.


how do I disable modules in commerce kickstart I thought I needed dashboard and block languages modules for blocks. I enabled them and now want to disable them again but the update button has been replaced with an install button on the site settings -> modules admin page. How do I disable them?

Scroll down to bottom of left column for save button.

A module worth mentioning is https://www.drupal.org/project/module_filter. It makes the module page a lot more user friendly.


how to display overlay width and height hi i'm using overlay paths module with overlay module.  i have 2 questions

how to set an overlay width , i tried as mynode/*|200px but it doesn't works.
is it possible to view a page in a overlay without header and footer .

You should set your path in admin/config/system/overlay_paths_ui whit pattern like this node/add|600px. (I test it by myself, it effect after I clear cache in admin/config/development/performance  ).
This module cant help you to set a height for overlay.(you can patch this module to provide your require   ).
Final and good solution for do your job is use css, set css in your css file

#overlay {
height :xxx px; !important
width :xxx px; !important
}


Restrict concurrent content edit I want to restrict concurrent edit by the users.

If user A is editing a content then  user B should not be able to edit the content at the same time. That content should be visible, just not editable.

I am unable to find any module that provides this feature for Drupal 7.

Is there any module, or how can I achieve this programmatically?

There is a module for that. Try the Conflict module

This module allows parallel editing of nodes with field-level conflict detection and a trick to prevent accidental overwriting of fields when they are changed by another session while a node is being edited.
This behavior is useful for things like issue queues where multiple people might be following up to an issue simultaneously.
It works by hashing the field data and comparing these hashes. This is done so we can generically do a 3 way comparison between the original node, the node as edited by us, and the node as edited by others.


How to autofill webform with node field data I have a content type, applicant with a name, and birthday field. I also have a entity reference to a webform, which has a name and birthday fields, as well as others. I want to allow users to create the applicant content type, then click the link to webform, and autofill the appropriate fields on the webform.

I've been trying to use the FormStateInterface::setValue method. Here' where I am so far:

function mymodule_webform_element_alter(array &$element, \Drupal\Core\Form\FormStateInterface $form_state, array $context) {
  kint($element); // this outputs '#webform_key' => string(4) "name"

  $form_state->setValue('name', 'bob'); // Here I'm just trying to statically set the field.
}

This method doesn't actually autofill, and it also doesn't actually set the value. This is a demo-project, so we don't have specs yet, so I'm actually fine with either auto-filling, or setting the value, probably both.

The main thing I'm trying to do here is to link one node entity to a webform submission.

Using hook_form_alter() or hook_form_FORM_ID_alter(), you can set the default value by php code

For Example

function HOOK_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
  if($form_id == 'YOUR_FROM_ID'){
    $form['submitted']['FIELDNAME']['#default_value'] = date("Y-m-d h:i a", time());
  }
}


Can I use Feature for development and CMI only for deployment? As a developer working in team I don't like using CMI to synch config from/into development server at all (cim/cex) in local development machine. Instead I'd like to use Feature. What I wanted to achieve is on below diagram.

Basically I want to use Features for development in first tier and use CMI only for deployment to PRD/IGR. Does it make sense? What do you think?

Some comments according to the limited experience i have on CMI myself.

I believe that what you ask is pretty much logical, due to the fact that local dev envs usually end up being different than the actual remote Dev instance. Testing modules, code, configuration e.t.c is pretty much the reason for that.
This makes default CMI functionality unusable as you dont want to move the whole configuration into your actual deployment process (DEV->IGR->PROD).

This problem is addressed quite well using Features, however it could also be tackled by some CMI related modules such as Config partial export or Configuration Split

One more argument in favour of Features might be that you are able to have totally different local dev envs than the remote Dev (Dest site UUID != Source site UUID) which i guess would make CMI unusable.


URL-dependent templates only evaluated once, incorrectly cached I have a twig template that controls the HTML of the page based off of some URL-specific information. However, this template seems to be evaluated once on the server and then gets cached, never to be evaluated again. The result is that the first page loaded displays the correct information inside this particular block, but every page after that displays the same information as the first page in the block, even though the URLs are obviously different.
To illustrate, page A should have data A loaded on the side in a block, page B should have data B loaded on the side, and so on. If you go to page B first, then you will see data B loaded correctly. However, after that, if you go to page A, you will still see data B loaded on the side, rather than data A. Note that this bug only pertains to the portion of the page that is controlled by the URL-specific logic; the rest of each page loads correctly.
If I go to Home >> Administration >> Configuration >> Development and clear the cache, the next page loads correctly, but then I'm just stuck with a new incorrectly cached chunk of data for all the other pages.
Why is Drupal caching this block whose display is dependent on the URL? More importantly, how can I get rid of this behavior without disabling caching completely?
Update 1: I have tried going to the view for the block (Home >> Administration >> Structure >> Views) and under Advanced Settings selecting None for Caching, but this has no effect.
Update 2: I don't have a custom block with code to modify, so not sure how to incorporate fixes from questions like this.

As stated you would need a cache context for the block, more specifically the "url.path" cache context. You could add it in a preprocess hook, but it requires some PHP knowledge.
You could try the Blocache module which lets you change the Cacheability metadata for any block. Once enabled, select "Contexts" and check "url.path". Disclaimer: I have not tried this module myself, but it looks like it would solve your problem.


Commerce - check if this very product in presented in user's previous orders I use drupal commerce trying to build a website which sells content (nodes with restricted access). The thing is that, if user have bought the product once, he shouldn't have a possibility to do it again.

Currently i'm using form_commerce_add_to_cart_form_alter to check if user has already added this product to cart and if yes - hide "Add to Cart" button to prevent doing it twice and set a text that this very product is already in the cart. It works totally fine.

What I want to do next are two things:

1) to check if this current user has this product under active (not canceled and not complete) order, and if yes - hide "Add to cart button" and set a text that this product is under order processing at now.

2) to check if this current user has purchased this very product ever before and if he has, do the same trick - hide "Add to cart button" and set a text that User already owns this product.

My problem is that I'm very new to commerce and unfortunately totally don't understand how can I get all orders for the current user and check for some product IDs there... Will be very appreciated for any advice or a tip. Thanks a lot!

If you have the Entity API module installed, you can do it using entity_metadata_wrappers and EntityFieldQuery like this:

$query = new EntityFieldQuery();

$query->entityCondition('entity_type', 'commerce_order')
  ->entityCondition('uid', $uid);
$result = $query->execute();

if (isset($result['commerce_order'])) {
  $user_order_ids = array_keys($result['commerce_order']);
}

// Array for storing user's products.
$products = array();

foreach($user_order_ids as $user_order_id) {

  $o = entity_metadata_wrapper('commerce_order', $user_order_id);

  $line_items = $o->commerce_line_items->value();

  foreach ($line_items as $line_item) {
    $l = entity_metadata_wrapper('commerce_line_item', $line_item->line_item_id);
    $products[$o->status->value()][] = $l->commerce_product->product_id->value();
  }
}

This should give you a 2 dimensional array of products like this:

... (Array, 1 element)
  cart(Array, 2 elements)
    0 (String, 3 characters ) 203
    1 (String, 3 characters ) 158
  other_state(Array, 2 elements)
    0 (String, 3 characters ) 187


How to get node url of selected language? I have a node with an array of multiple languages.

 [19] => Drupal\node\Entity\Node Object
        (
            [in_preview] =>
            [values:protected] => Array
                (
                    [vid] => Array
                        (
                            [x-default] => 19
                        )

                    [langcode] => Array
                        (
                            [x-default] => en
                            [ca] => ca
                        )

I'm getting its url as:

$options = array('absolute' => TRUE);
$link = \Drupal\Core\Url::fromRoute('entity.node.canonical', ['node' => $key], $options);

print($link) is giving me http://test-d8.local/en/node/19 where as I want url of "ca" language not "en" language. i.e. http://test-d8.local/ca/node/19

Is there any way that gives node translations of particular langcode?

This line $language = $entity->get('langcode')->value; is giving me the value of chosen language from select list.

You want to use toUrl() with the language option.

$node->toUrl('canonical', ['language' => $node->language()]);

Unfortunately, toUrl() currently doesn't automatically respect the active language.


Large, regular product import for Commerce I am in the process of developing a new site using Commerce Kickstart.

The site needs to import a fairly large amount of data from a CSV on a regular basis - perhaps 50,000 to 100,000 products at a time, at least every week. (And maybe more often than that.)

I have tried to use Feeds to do a test import of around 30,000 products. (So this creates 30,000 product variations and 30,000 display nodes.) This has proved to be far too slow for my purposes, taking around 18 hours.

So I see my options as follows:

Run some profiling to attempt to see why the import is slowing down
so much (It starts off at around 200 products / minute and slows
down to 10-20 by the end of the import run.)
Following the strategy here, import into a single table, and use entities to do what I need to do. With this approach, I am concerned about losing or having to re-implement the functionality I need to make the site work - namely faceted search / unknown regular commerce functionality. Each product - each line of the CSV - has numerous fields of data that would have to be stored, so I'm not even sure if this approach would work.

Does anyone have any advice on the best way to progress? Or any hints about the above? Or strategies to import the data that I might not have considered?

Thanks in advance.

EDIT:-
Looking at the Feeds log, it looks like the product variations imported in 1 hour 20 mins, whereas the product display nodes took 17 hours to create.

Hopefully this helps someone else.

I used XHProf in an attempt to figure out why the Feeds import was slowing down so much. It appears that the culprit is DrupalDefaultEntityController::cacheGet.

As the number of entries in DrupalDefaultEntityController's entityCache increases, performance drops off a cliff.

I resolved the issue by importing the nodes manually.


Is it possible autoload PHP classes in themes? Does the namespace, class name and naming convention work like it does for modules?

These links don't seem to mention it:

https://www.drupal.org/docs/develop/standards/psr-4-namespaces-and-autoloading-in-drupal-8
https://www.drupal.org/node/2349803

There's an interesting development going on regarding themes and OOP. Look at Allow themes to provide services.yml which finally got closed as Won't Fix. From Mark Carver's closing comment:

  I really don't think we should be opening up themes to services
  anymore.

  A lot has changed (for the better) in the 5 years I've been following
  this issue (closely).

  If this were to happen... there wouldn't be any real delineation
  between what a module is vs. what theme is, would there?

Instead as a result Allow themes to declare dependencies on modules is the route to go now. To move all the OOP stuff out of themes as the theme layer is for theming things, as JayPan said in the comments.

My answer to that problem is that I now always create a themename_companion module where I provide Drush 9 commands, helper functions, services etc. for my themes.


Views: Multiple AND/OR operators in contextual filters I have created a page view that displays customer nodes. The result is filtered by a contextual filter based on a taxonomy term id from url. To allow multiple filter values i'm using OR (+) and AND (,) operators in the url. However, combining those operators doesn't work.

  Url's like this work:

  /finder/220+300+121
  /finder/220,300,121

  This doesn't:

  /finder/220+300,121

So i'm looking for a view setting or a module that allows multiple OR/AND operators. Here is a screenshot of what i'm trying to build.

Show me all customer nodes that are in industry3 OR industry5 AND are from Product1. This would be this url: /finder/220+300,121

Any ideas? Thx...

So I think you should remove your contextual filters and instead add exposed filters. In there you can make your industry filter multi select so the user can pick more than 1. Then you can also choose to make the filters an either AND or OR giving you that flexibility too.

If the exposed filters or the better exposed filters don't look as you wanted you could even hide the views filter form and created your own custom form that replicates it by passing the parameters into the url that views requires

Hope that helps!


Is there any module for booking? A  module for Booking type system which allow me to add Different Hotels, Apartments etc. in Different countries. I want to show Availability calender also.

I tried uc_hotel and AG Reservation but both don't meet my requirements.

I need price calculation based on room selected. If a user select only two rooms of an apartment and the apartment has 4 rooms, then the price is based on the selected room; filters are based on availability.
I need search functionality based on location, bedroom, people capacity, accommodation type, offers; the price is based on the extra facility provided.

Then Drupal Rooms is the only option for you and it match your requirement for room calculation, it will update the pricing  depend upon the rooms selected . Rooms is a booking and room management solution for hotels, vacation rentals and B&Bs.

  It allows an accommodation owner to:

  Create rooms and assign availability (or on hold states) via a calendar.
  Manage pricing for rooms using calendars that allow to set pricing for entire seasons or just change it for specific dates.
  Define optional add-ons for rooms.
  Charge either per-night or per-person.
  Handle children discounts.
  Create bookings and keep customer records.
  Make rooms available for booking with a availability search functionality and/or calendar - handling both immediate bookings and bookings following owner confirmation.
  Search by Room Type.
  Full integration with Commerce to manage payments, a range of different payment gateways, and a host of other e-commerce features.
  Accept full or partial payments (deposits) using Commerce features.


put views block in a content type different than the one in views block I have 2 content types. One called "tributes" and another called "offers".
Both content types have a field reference to pages of a third content type called "county".

What i want is to display a view block with content from "offers" in the pages of content type "tribute" based on the value of the field county that appears in the node each time.

Is there a way to create a contextual filter on field county and use as default value the value of the field county appearing in the "tribute" node?? (through PHP perhaps?!)

Thanks in advance!

Getting a block view to get a parameter from the node view can be tricky.  Here's what you can do:

For "tribute nodes":

create a new view to display "offer" nodes
add a filter to that view to limit the content type to "offer"
add an argument to that view to your node reference
Under "Action to take if argument is not present" select "Provide default argument"
For default argument type, select PHP Code
We now need to write some php code to grab the node reference id from the node being viewed.  your case might be a bit different, but here's a starting point: (you dont need php tags)

<?php

if(arg(0) == "node" && is_numeric( arg(1) )) {
  $node = node_load(arg(1));
  if($node->type == 'tribute') {
    return $node->field_county[0]['nid'];
  }
}

replacing field_county with whatever your cck field is named.

Then you should be able to add that block to any tribute node page and it will pull in the associated offers, and just do the same thing again for the offers->tribute direction.


Module to display file from an SVN repo? Looking for a way to display text files that are stored in an SVN repo or local filesystem. Exactly like http://www.mediawiki.org/wiki/Extension:Include works for mediawiki.
Thanks a lot

Have a look at
Version Control API with Version Control API -- Subversion backend

I didn't use it but you can try

  This module provides an implementation of the Version Control API that
  makes it possible to use the Subversion revision control system.

P.S. Drupal 5 and 6 only


Filter a view on field on a user referenced entity Given:

A view with some field
A field with referenced entity on user entity, named: assigner
A filter on the field assigner

How i can filter by a list of user? if i apply the same filter on Authored by it works.

The only option view edit form shows me is a filter on text base input.

Before adding a filter on the user name you need a relationship for your field assigner. This in the advanced section of views. After you have set up the relationship:

User referenced from field_assigner

You can add a filter:

Name (autocomplete)

and choose the relationship:

field_assigner: User


Display menu items deeper as second level. (show as expanded doesn't actually expand menu items) I have a menu that needs to be 3 levels deep. The last level never shows up. All menu items are set to 'Show as expanded'. But if go look at the html of the li items that make up the menu, I see <li class="collapsed" >menuitemname </li>

This problem occurs in bartik as well as b2nature (the one that the site should go live with)

Keep in mind that I made really really sure that under the menu configuration, I set each and every menu item as 'Show as expanded'.

Update The problem even seems a little tougher than I would think. I made a script that changed all of the class values that said 'collapsed' into 'expanded'. After checking the HTML I can see that the script works, but even with all the classes set to 'expanded' still no level 3 to be seen.

Here's the script for what it's worth

window.onload = function(){

    var mainMenu = document.getElementById('block-menu-block-1');
    var menuItems = mainMenu.getElementsByTagName("li");

    for (var i=0; i < menuItems.length; i++ ){

        var attributes = menuItems[i].getAttribute('class');
        var arrayAttributes = attributes.split(' ');
        for (var j=0; j < arrayAttributes.length; j++ ){

            if (arrayAttributes[j] == 'collapsed'){
                arrayAttributes[j] = 'expanded';
                }
            }

        var newAttributes = arrayAttributes.join(' ');
            menuItems[i].removeAttribute('class');
            menuItems[i].setAttribute('class', newAttributes);
        }
}

Update: I can confirm that this problem must be due to a bug.

I reconstructed the same menu on another site(locally this time). When I would put the block of that menu in any region, the expanded menu items just show up because I checked the 'Show as expanded'-checkbox in the configuration after clicking '+ Add link'.
It didn't matter if the expanded menu items had actual nodes as path or  as path. All worked just fine.
Then I also reconstructed the same menu on my problem-site just starting from scratch but the problem persisted.

Update The 3rd level also isn't there in HTML. I also installed and configured the Menu Blocks module to see if this would be of any help but it isn't.

This is "by design" of drupal / the themes.

With the help of a module like Menu Block you can create blocks that have the functionality you are searching for and then place the Blocks where the menu was.


Php block messing with the page tittle I've added the privatemsg module send message form in a php block, it's working fine but the page tittle and the metatag tittle now shows "write a new message to(user uid)" instead of the node tittle.

this is the code in the php block:

`<?php
 module_load_include('pages.inc','privatemsg');
 $node = node_load(arg(1));
 $recipients = strip_tags($node->uid);
 $subject = 'custom subject';
 print '
';
 print drupal_render(drupal_get_form('privatemsg_new', recipients,
 $subject));
 print "
";`

I can't figure out why this could be happening, i'm new to Drupal.

Thank you.

UPDATE

I've created a custom module as @burnsjeremy suggested, it works but the same error is happening.
Check the comment line in the code.

<?php
module_load_include('pages.inc','privatemsg');
function seb_privatemsg_block_info(){
    $block['seb_msg'] = array(
       'info' => t('Seb Private Msg'),
       'cache' => DRUPAL_NO_CACHE
    );
    return $block;
}
/**
* Implements hook_block_view().
*/
function seb_privatemsg_block_view($delta = '') {
    $block = array();
    $block['subject'] = '';
    $block['content'] = seb_privatemsg_content();
    return $block;
}
function seb_privatemsg_content() {
    $node = node_load(arg(1));
    $recipient = strip_tags($node->uid);
    $subject = 'custom subject';
    $output = '';
    // if i comment the following line the title is correct
    $output .= drupal_render(drupal_get_form('privatemsg_new', $recipient, $subject));
    return $output;
}

Any help would be greatly appreciated.

So I found an issue about this in the privatemsg issue queue, basically they are overwriting the page title when the form is embedded like this. So you need to use the code below to save the title before the form call and then set the title back to the saved one afterwards.

// Save the title.
$stored_title = drupal_set_title();
// Call the form.
print drupal_render(drupal_get_form('privatemsg_new', $recipients, $subject));
// Set title back to the saved version.
drupal_set_title($stored_title);

Here is the link to the issue if you want to do more research: https://www.drupal.org/node/1621198


Make changes to  for homepage only I need to insert hreflang tags in the head tags, but I only need these on the homepage. At the moment I'm inserting the hreflang tags into the head via the html.tpl.php template, but this puts the code on all pages in the site. How can I edit the head for just one page? I'm using Drupal 7.

You can use:

<?php if ($is_front): ?>
 <!-- code here-->
<?php endif; ?>

In your html.tpl.php and it'll only affect the homepage.


How to build a webform with a slider field The Webform module itself doesn't (yet?) support the html5 <input type="range"> element, which isn't really cross-browser compatible yet anyway.  I suppose right now (2013) we're stuck using a Javascript solution, and the most popular solution in the Drupal world seems to be the JQuery UI slider component, via the sliderfield module. However, the module page and issue queue makes no mention of integration with Webform.

I'm wondering if there is a module I've somehow overlooked that does offer slider/range widgets for Drupal Webforms, and if not, what is the most recommendable way to implement one, that could be shared and or turned into a module.

You will actually need to create a custom module to create a new webform component. This link contains more information on how to get it done http://jamestombs.co.uk/2012-09-24/create-new-webform-element-drupal-7


How to work with .install files and hook_enable etc... when developing a module? I'm writing a module which utilises a .install file to create and configure things - specifically I'm creating a custom line item based on the commerce_example module. Turns out it's quite a bit of code and will take a bit of time to get right.

This is all good, but how can I go about testing this as I'm going? I'll inevitably want to add fields to the install function later on, but to do this I'll need to disable (and uninstall?) the module, deleting the existing line-items, and re-enable every time I need to test if it's working which seems so slow. Is there a better way of working when doing this?

Yes You can write in your hook_update_N() like this in your mymodule.install file:

function mymodule_update_7001() {
 db_add_field('table_name', 'field_name', array(
  'description' => 'The total amount to be paid for the order.',
  'type' => 'numeric',
  'precision' => 16,
  'scale' => 5,
  'not null' => TRUE,
  'default' => 0.0,
 ));
}

After writing this you can simply run your update.php file


When I change theme, I can't see my sidebars I am a total n00b, just trying to set up my first site.

I got something nice with the Bartik theme, then realized that I wanted drop-down menus on the main menu, so decided to try another theme.

I tried both Corolla and Martinelli, but when I set them as default theme I can't see my sidebars or footers.

The are still set up as they were for Bartik and if I switch back to that then I see them again.

Obviously, this is just some stupid n00b thing, like not knowing to rebuild the front page or something. Can anyone tell me what I am doing wrong? Thanks.

Because themes haven't the same region names, after changing your theme you must go to admin/structure/block and re-assign blocks to regions.


How to display inbox messages and sent messages order by date - private message module In private message module inbox and sent messages should be display by time wise.

Right now,

It is displaying where the unread messages list first and then the read messages list second.

But based on my requirement

All the messages should be displayed in date order weather it is read or unread

How can I do this?

Have a look at the following issue: http://drupal.org/node/850932


CCK form to edit single field or set of fields We have a fairly large CCK content type and would like to be able to edit a single field of the node at a time (or a set of fields).

For example, we will display our content on the page through a custom view, with a series of "edit" icons per row, allowing the user to edit an individual fields values.

Ideally we are aiming to have a popup with that fields form item(s), which the user can edit and click update.

Manipulating the form after build is not practical as its so much overhead just to render a form with a single field.

Is there a module that can render a form for one or a series of the fields for the given node?

Is it for D6, if so this module will solve your problem: jEditable inline content editing.


Is there a way to filter blocks by vocabulary instead of NID or CT? Each time I filter block visibility (that is: When the block will appear in it's region), I can do so only via Node ID or Content-Type...

You might have a ready-2-go way to do so with a vocabulary term ? Here is a pseudocode of my meaning:

if (isset >=1 vocabulary->term) {isset block}

Sorry if it's a bit wired, I am just starting to learn PHP and my meaning is "if at least one term of a given vocabulary is in the node, show the block in whatever region".

Have a look at my answer to "How to make "Page specific visibility settings" for blocks more flexible?". It explains how the Rules block visibility module can be used to answer that question.

Your question here seems to be a variation of it. You could use a similar approach, so that in the end you'd only have to write a Rules Component related to your criteria here, ie to intercept your condition about "if at least one term of a given vocabulary is in the node" (in which case the Rules block visibility module should take care of "showing the block in whatever region". Done!

Note: for this to work, do not have to enable the PHP Filter module (always a good thing if you can  avoid that).


Content is not displayed in front page I am using drupal 7. In theming i have created page--front.tpl.php

Every thing is working properly, but when i create a basic page and assign it to display on front page then page is not rendered.

I have also written this <?php print render($page['content']) ?> but content is not being rendered. It is showing error

  No front page content has been created yet. Add new content

That's the message you get for the standard front page (located at /node), so it looks like your attempt to update which page is the front page hasn't taken for some reason.

In case you've done it another way, the usual way to set this front page is to go to admin/config/system/site-information and set the "Default Front Page" to the path of the new node that you've created.

You'll also need to clear Drupal's caches once you've added the new template file in case you haven't done that already.


Facebook Oauth and sending messages to facebook users I have Facebook OAuth and Facebook Connect installed on a site. We need to be able to periodically send a message to one of our member's Facebook inbox who logged in with the Facebook Connect.  I've looked all over, and haven't had much luck.

Can anyone point me in the right direction?

When a user registers or connects with his/her Facebook account, your web application receives that person's Facebook username which you can then store in a field.

On Facebook, you can receive external messages at username@facebook.com.

Now all that's left to for you to do is set up Rules module (maybe Facebook Rules module can help) so that if a user has connected his account on your website with his Facebook account an email is sent to username@facebook.com.


Subscription OG Group I want that user can subscribe to content add in several OG GROUP.

How can achieve that ?

Cordially

Yes, By default og_group_ref field  (organic group field machine name by default  add to your content types) accept multi value, if  for you it's Number of values set 1 value, go to you content type manage fields and change it to unlimited value


Select nodes based on entity reference value I have a content type student, and it has an Entity Reference field named as field_offline_course_reference and a email field field_offline_course_student_ema

I need a list of all emails of students based on field_offline_course_reference value.

How can I change the following code to achieve what I want to do?

$courseinfo = $theCourseId;
$query = db_select('node', 'n');

$query->join("field_data_field_offline_course_reference", "t", "t.entity_id = n.nid");
$query->fields("n", array("nid"))
    ->condition('n.type', 'students')
    ->condition('t.entity_id', $courseinfo);

$result = $query->execute();
    foreach ($result as $record) {
       var_dump($result);
}

You need to JOIN on nid and vid (entity fields are stored per nid/vid), add a JOIN to your email field table, set the fields to select the email value, and set your WHERE clause to entity reference target.

$query = db_select('node', 'n');
$query->join("field_data_field_offline_course_reference", "t", "t.entity_id = n.nid AND t.revision_id = n.vid");
$query->join("field_data_field_offline_course_student_ema", "e", "e.entity_id = n.nid AND e.revision_id = n.vid");
$query->fields("e", array("field_offline_course_student_ema_value"))
    ->condition('n.type', 'students')
    ->condition('t.field_offline_course_reference_target_id', $courseinfo);


Drawing Tool in WebForm Drupal 6 website.

I need to embed a drawing tool into a webform to allow a visitor to sketch a diagram and have it sent as an attachment to the email from the WebForm.

Been looking around but have not found a solution for Drupal 6.

Any ideas?

Image Editor will do that,

Drupal 6 version allows to edit Imagefield items and save them back either by replacing the original image or adding new Imagefield item. but I'm not sure it will integrate with webform, You need to test it.

See the Demo Here

  Bring image editing (draw, text, crop, scale, etc.) functionality into
  your Drupal website! Edit/create any images online in the powerful and
  feature-rich image editors and save resulted images back to your site!