Where can I tell if my Drupal 7 database is using InnoDB?

To find out which tables are InnoDB and MyISAM
COUNTS
SELECT ENGINE,COUNT(1) TableCount FROM information_schema.tables
WHERE table_schema NOT IN ('information_schema','mysql','performance_schema')
GROUP BY engine;

Since MyISAM is a non-transactional storage engine, it has no foreign key referential integrity to enforce. You could change all MyISAM tables to InnoDB, but with one exception: Before MySQL 5.6, FULLTEXT indexes are only available for MyISAM tables.
Here is how to find all tables using FULLTEXT indexes.
SELECT tbl.table_schema,tbl.table_name FROM
(
    SELECT table_schema,table_name
    FROM information_schema.tables
    WHERE engine='MyISAM' AND table_schema NOT IN
    ('information_schema','mysql','performance_schema')
) tbl
INNER JOIN
(
    SELECT table_schema,table_name
    FROM information_schema.statistics
    WHERE index_type='FULLTEXT'
) ndx
USING (table_schema,table_name);

If this comes back with no rows, you can convert all MyISAM tables to InnoDB without worry. If you have any tables with FULLTEXT indexes and you do not use them, you could drop the FULLTEXT indexes then convert the tables to InnoDB.
CONVERSION SCRIPTS
Here is a script to convert all MyISAM tables that do not have FULLTEXT indexes to InnoDB:
SQLSTMT="SELECT CONCAT('ALTER TABLE ',tbl.table_schema,'.',tbl.table_name,' ENGINE=InnoDB;')"
SQLSTMT="${SQLSTMT} FROM (SELECT table_schema,table_name FROM information_schema.tables"
SQLSTMT="${SQLSTMT} WHERE engine='MyISAM' AND table_schema NOT IN"
SQLSTMT="${SQLSTMT} ('information_schema','mysql','performance_schema')) tbl"
SQLSTMT="${SQLSTMT} INNER JOIN"
SQLSTMT="${SQLSTMT} (SELECT table_schema,table_name FROM information_schema.statistics"
SQLSTMT="${SQLSTMT} WHERE index_type='FULLTEXT') ndx USING (table_schema,table_name)"
mysql -uroot -p -ANe"${SQLSTMT}" > ConvertMyISAMToInnoDB.sql
mysql -uroot -p -A < ConvertMyISAMToInnoDB.sql

If you know for a certainty that there are no FULLTEXT indexes in use, you can do this:
MYSQL_CONN="-uroot -prootpassword"
SQLSTMT="SELECT CONCAT('ALTER TABLE ',table_schema,'.',"
SQLSTMT="${SQLSTMT} table_name,' ENGINE=InnoDB;') InnoDBConversionSQL"
SQLSTMT="${SQLSTMT} FROM information_schema.tables WHERE engine='MyISAM' AND"
SQLSTMT="${SQLSTMT} table_schema NOT IN ('information_schema','mysql','performance_schema')"
SQLSTMT="${SQLSTMT} ORDER BY (data_length+index_length)"
MYSQL_OPTIONS="-AN"
mysql ${MYSQL_CONN} ${MYSQL_OPTIONS} -e"${SQLSTMT}" > ConvertMyISAMToInnoDB.sql
mysql ${MYSQL_CONN} ${MYSQL_OPTIONS} < ConvertMyISAMToInnoDB.sql

I have suggested this in the past : How do I convert a database from MyISAM to InnoDB?
CAVEAT
Changing all tables to InnoDB will change the needs for MySQL's memory usage. Why?

MyISAM only caches indexes (via MyISAM .MYI files) into the key buffer. Data is never cached, but always reread from disk (via the .MYD of a MyISAM table) or OS caches
InnoDB caches data and index pages in the InnoDB Buffer Pool
You will have to compute and resize both the MyISAM key buffer and InnoDB Buffer Pool


How do I pass a specific argument from a rules event to a condition?

In a case like this, you'd going to have to use what Rules calls a data selector. If you were building this Rule through the UI, you would click the "Switch to data selection" and enter some token that corresponds to the type of parameter required.  In this case, the commerce_cart_product_add event provides the arguments commerce_order, commerce_product, quantity, commerce_line_item, and commerce_line_item_unchanged.  (See all this in the event's definition in commerce_cart.rules.inc.)  So when trying to select the product passed to the event through the UI, you'd use commerce-product as the value for your condition's product parameter.

When building this Rule in code, you specify a data selector by appending :select after your condition's parameter's name.  So, if the name of the product parameter for your condition (as defined in hook_rules_condition_info()) is commerce_product, your "something" would be commerce_product:select.  The "something_value" would be the same token you'd enter through the UI, commerce-product (as that's the name of the product argument passed to the Rule).

And touching on one more aspect, the event info defines the variables that must be passed to Rules when an event is invoked.  Your condition can use any, none, or all of these - it doesn't really matter. A condition or action's definition simply states what kind of parameters it needs, and the Rule configuration is responsible for passing the parameters to the condition from the pool of available variables (or from variables you load as part of the configuration).


Holistic Design Critique for a Volunteer Matching Service

This type of question is very difficult to respond to. It is very broad and potential responders do not know enough about the details to make sense of the best strategies to use in structuring it.  I suggest that you continue expanding the story you have begun here including flow diagrams for how the user would enter, organize and use the information. Since Drupal is basically a big database management system, think about the database structure  that would make sense to hold the information.

You will contain most information in content types with associated fields to categorize the content.  Fields are often associated with taxonomies which add the benefit of creating organizational hierarchies.  They provide a simple way for users to enter and categorize their information effectively and uniformly. You can also organize taxonomies into hierarchical menus (Taxonomy Menus) so they can quickly access information they require.

Views is basically a UI for SQL queries, so you will use that to retrieve and organize information to meet the users needs. For instance Views can be set to respond to taxonomy menus to arrange complex collections of content.

The easiest and most flexible way to arrange your information on a page is to use Panels and Page Manager(Ctools).  They allow you to intercept any URL request and arrange the content in multiple ways depending upon the context at the time it is called.  For instance, you can alter the content on a page and rearrange how it is displayed based upon the permission level of a user.  By adding Panels Everywhere, I have managed to practically totally bypass the theming system and the complex styling spaghetti it can produce and simplify my style sheets and gain better control of what is displayed.

Features is a great module for exporting parts of a site to other sites.  It is complicated and not perfect, so I would recommend getting one site solved first and deal with features later if you can.

I have had some problems with Profile2 and do not believe it is ready for prime time yet (it is a fairly new module).  Most basic profile information can be easily handled by adding fields to the users entity.

Pathauto will allow you to create aliases for the URL which is very nice for creating user friendly URL descriptions, but bear in mind that views contextual filters do not work with aliases well and cause cause you grief.

You will continue to learn about and pick up on other modules that meet certain needs, but I recommend you start conservative and master the few I have bolded in this answer first. Each of these modules is complex and will require study to master. As you encounter specific questions as \k them and you will probably get more useful answers.

Good Luck.


What's the best way to add an alert box to a link in D7

no there is no js related function in drupal 7 that provides a functionality like that. just make sure that custom setup you have there is in your template.php


How to add noindex / nofollow robot metatags to Views subpages

Altering robots.txt could be an option. For example this would stop google from accessing your pager.

    # Disallow all URL variables except for page
    Disallow: /*?page=*&*
    Disallow: /*?page=0*

More examples on Views and SEO can be found here.


View mode tabs no longer visible in Drupal 8

The block showing the secondary tab menu was disabled. In order to activate it, I had to pay /admin/structure/block/list/seven a visit and manually re-add the Tabs block to the Pre-content region.


What to name field collection theme file?

Theme hook suggestions typically work off of content type (or in this case bundle type), field name, or other variables. URL is not one of the defaults.

However you can create a custom template suggestion and use the URL to create that suggestion. If you want to theme the edit page you'll want to make sure you're putting the template and template suggestion in the administration theme.

Here's a good page on theming suggestions:
https://drupal.org/node/1089656


How to solve the error while uploading image to nodes?

Try the Upload QC module. Some details about it (from its project page):

This module offers checks and validations for the process of uploading files. It extends the Drupal 7 core and helps avoid errors during file upload. You can now say good bye to PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 2: INSERT INTO {file_managed}.
WHO SHOULD USE
This module is for you if:

you run into errors like this one PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 2: INSERT INTO {file_managed} OR PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ... for key 'uri': INSERT INTO {file_managed}.

you would like to add additional file upload validations that check for (a) file name length, (b) file name containing certain words/characters, (c) file name not containing certain words/characters.

Drupal and/or PHP upload size limit is not working for you and you would like to set it yourself in your admin section.

Looks like item "1." is pretty close to your issue, no?


How to add custom Views filters (for example, date between X & Y, but specified by myself)

Date ranges in solr views still being worked on - see http://drupal.org/node/642430 for latest patch from July 11 2011


How to generate absolute URL for breadcrumbs?

You can alter the breadcrumbs of other bread crumb builders (core or contrib) in a hook_system_breadcrumb_alter():

/**
 * Implements hook_system_breadcrumb_alter().
 */
function mymodule_system_breadcrumb_alter(\Drupal\Core\Breadcrumb\Breadcrumb &$breadcrumb, \Drupal\Core\Routing\RouteMatchInterface $route_match, array $context) {
  $links = $breadcrumb->getLinks();
  foreach ($links as $link) {
    $url = $link->getUrl();
    $url->setAbsolute();
  }
}


Feed aggregator does not update RSS feeds when cron job is run (Drupal 7)

Yup, trying to solve my own question (again):

Similar problem here:
http://drupal.org/node/1115978

and the possible solution here:
http://drupal.org/node/1023190

Update

The above solution was about a database fix to do with feeds that have more than one category.

When I applied to patch I was informed that this was already in the version of aggregator.

So in summary the solution I gave above had already been applied.

However, another avenue to explore is cron job time out. In my situation I have a lot of feeds so it could be taking the job invoked by the cron a long time to update all of them.

Here is another possible solution to extend the time alloted to running a job triggered by cron, a cron job:

http://teqsnacks.com/2007/07/07/drupal-when-cron-jobs-do-not-complete-and-cron-jobs-tips/

To quote:

  Go to your settings.php file (under sites/default or wherever it
  is). At the bottom of it you will see a list of ini_set commands. Add
  the following to the list:

ini_set("max_execution_time", 60);

  The number at the end is the number of seconds a program can run
  before timing out. Setting it to 0 means "never timeout" which you
  should use very carefully, like on a development site where you have
  control over the server.

Update 2 - and likely solution and root cause

The cause of the problem likely stems from a corrupt database causing errors when the cron job is run. Details and remedy here:

http://drupal.org/node/1596220

Update 3

After following the above instructions you may still see the feeds not updating. Further things to consider:

Clear all caches
Check your site logs for cron job running successfully and new feed items being imported from the aggregator
If you are using a View (of type aggregator) to process the feed then you would probably need to sort the feed by descending so that the latest feed items appear first. To do this you will need to define your own date format (check the PHP option) for the Aggregator Feed Item Timestamp in the View sort criteria, so that the date is big endian i.e. YYYY-MM-DD hh:mm:ss. The current date formats offered aren't purely big endian and the sort won't work properly e.g. because day comes before month.


Failing to create thumbnail, medium and large images

Right, the answer is in fact a little more subtle than I realised. Turns out that D7's imagecache replacement needs some attention in your nginx vhost. Without the 404s being sent to Drupal for the missing files, the images are not created - something I didn't realise initially, as I'd assumed they were created on upload.

location @rewrite {
    rewrite ^/(.*)$ /index.php?q=$1;
}

location ~ ^/sites/.*/files/styles/ {
    try_files $uri @rewrite;
}

It needs to be added to your server definition, and you should be ready to roll. Clearly, the path may need altering for your setup, but for mine it was.


Send Email to user after click submit button

You are looking for Workbench email module.

  Provides a way for administrators to define email transitions and
  configurable email subject / messages between those transitions. Email
  transitions can be defined as when content moves from state to state.
  Based on those email transitions, configurable emails can be created /
  updated / deleted as the site admin see's fit.


The error:

  EntityMalformedException: Missing bundle property on entity of type node.

happens, because your bundle property is malformed either on load or save, so Drupal can't find what type of bundle is it.

The logic of that Exception is:

// Explicitly fail for malformed entities missing the bundle property.
if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
  // var_dump(debug_backtrace()); exit; // You may want this line to debug.
  throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
}

So basically value of $info['entity keys']['bundle'] (for node it's: type) can't be found in $entity object ($node->type for the node), therefore Drupal doesn't know with what kind of entity it's dealing with. So most likely your entity is invalid (e.g. you're loading something else instead) or it is just empty ($entity is NULL).

If you haven't modified any Drupal code, this potentially can be caused by variety of things (most likely by specific Drupal module bug), such as:

saving invalid entity such as:

missing type from the node object (e.g. wrongly generated by Devel Generate?);

orphaned nodes in node table;
invalid rows in field_data_field_xxx table;
having orphaned nodes, caused by:

search view having indexed nodes which aren't in the system;
other modules (like Feeds) removing nodes from Drupal improperly;

nodes having invalid/non-existing references; for term data this can be checked by:

drush sqlq "SELECT nid, title from node WHERE nid IN (select entity_id from  field_data_field_some_ref WHERE field_some_ref_tid not IN (select tid from taxonomy_term_data));"

Where field_data_field_some_ref is data field of field_some_ref which is type of 'Term reference'.

See: DB records not deleted for Term Reference Fields after Term is Deleted
having orphaned taxonomy terms (so you may use Taxonomy Orphanage);
entity caching issue;
when using Rules Link module;
invalid custom code (human error) such as:

badly implemented Entity API,
badly implemented CTools/Form API,
!empty() test on the entity variable before calling field_get_items(),
rendering field by invalid calls,
triggering functions which shouldn't be triggered on certain pages (e.g. field_view_field()),

Here is the responsible code which is thrown by Drupal core (file: common.inc):

 if (!empty($info['entity keys']['bundle'])) {
    // Explicitly fail for malformed entities missing the bundle property.
    if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
      throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
    }
    $bundle = $entity->{$info['entity keys']['bundle']};
  }

Debugging

If you don't recognise anything above, the easiest thing to debug that kind of error is by placing var_dump(debug_backtrace()); or dd(debug_backtrace()); (when Devel is on) before the actual throw new EntityMalformedException on the affected line in common.inc.

Note: Using dd() function from Devel will generate the debugging info to the file in your Drupal temp folder (temporary://drupal_debug.txt) with backtrace dump, otherwise could be too big and difficult to read when dumping on the screen. When using var_dump(), it's easier to call die(); after the call and check the dump in the view-source mode of the page.

If this is happening on node save, check this EntityMalformedException post at SO for more detailed instructions.

See also the following Drupal issue: #1778572 for more ideas.


Db Query in Ajax callback. I would suggest to change type of Ajax-Button from submit to button.
In callback return instead of print. You should also use ->fetchAll() for instance after ->execute()


Is there way to use existing content type field to custom form in drupal?

In Drupal 7 you can use field_attach_form

function hook_form($form, &$form_state) {
  $form['fname'] = array(
    '#type' => 'textfield',
    '#title' => t('first name'),
  );
  $form['lname'] = array(
    '#type' => 'textfield',
    '#title' => t('last name'),
  );
  //attaching existing content type fields
  $node = new stdClass();
  $node->type = 'article'; //content type
  field_attach_form('node', $node, $form, $form_state); //it will attach all the fields
  unset($form['body']); //unset other fields like this.
  //..
  return $form;
}


You can also try the Opengraph Filter which sorts of acts like Facebook's link preview. I haven't tried on link fields but it does work on a text body. Pretty neat actually :)


How to send an email to all members of a group after the group is flagged?

Looking at the rule you included, it seems that your Rules Event is fine. But obviously your Rules Action (to send an eMail) is to only send it to 1 (hardcoded) eMail ID. Read on for more details about how you can get this to work ...

Step 1:

Create a flag (similar to yours) to flag a group. In my case I named it (surprise ...) "Flag a group", and with machine name "flag_a_group" (just replace in what follows this machine name of that flag with your own flag's machine name).

Step 2:

Create a Rules Component "Send eMail to all members of a Group", which you can do like so:

The type of this component is an "Action Set" (no need for any conditions).
Action 1 is to build a list of all the members of the flagged group. It uses "Fetch entity by property", with these additional specs:

Entity type value = Group Membership.
Property value = Group.
Value of the data selector = Group.
limit result count = blank (we do not want to limit the nr of results).
Provided variables = "Group members" (variable label) and "group_members" (variable name).

Action 2 is to iterate (= loop) over each of the members of the flagged group. It uses "Add a (rules) loop", with these additional specs:

The list to loop over = group-members
Current list item = "Member of group" (variable label) and "member_of_group" (variable name).
Sub-action (i) of this Action 2 is to just "Show a message on the site" (while QA-testing this Rules Component), with message type = Status and with a message something like "Group member named "[member-of-group:user:name]" and eMail "[member-of-group:user:mail]" will receive an eMail because of flagging this "[group:group-type]" group titled "[group:title]" and id "[group:gid]" (note the various tokens which might be interesting).
Sub-action (ii) of this Action 2 is to actually send an eMail to the "member_of_group" being processed in the loop, using various tokens similar to those in Sub-action (i).

Here is how the Rules Component looks like (in Rules export format):

{ "rules_send_email_to_all_members_of_a_group" : {
    "LABEL" : "Send eMail to all members of a Group",
    "PLUGIN" : "action set",
    "OWNER" : "rules",
    "TAGS" : [ "group" ],
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "group" : { "label" : "Group", "type" : "group" } },
    "ACTION SET" : [
      { "entity_query" : {
          "USING" : {
            "type" : "group_membership",
            "property" : "group",
            "value" : [ "group" ]
          },
          "PROVIDE" : { "entity_fetched" : { "group_members" : "Group members" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "group-members" ] },
          "ITEM" : { "member_of_group" : "Member of group" },
          "DO" : [
            { "drupal_message" : { "message" : "Group member named \u0022[member-of-group:user:name]\u0022 and eMail \u0022[member-of-group:user:mail]\u0022 will receive an eMail because of flagging this \u0022[group:group-type]\u0022 group titled \u0022[group:title]\u0022 and id \u0022[group:gid]\u0022" } },
            { "mail" : {
                "to" : "[member-of-group:user:mail]",
                "subject" : "eMail notification to group [group:title]",
                "message" : "Hello [member-of-group:user:name],\r\n\r\nyou are a member of the group [group:title] (which is of type [group:group-type]).\r\n\r\nYou are receiving this eMail since user [site:current-user] just flagged this group.\r\n\r\nGreetings,\r\n\r\nPS: contact the site admin by eMail (via [site:mail]) for more details if needed",
                "language" : [ "" ]
              }
            }
          ]
        }
      }
    ]
  }
}

If you have the Rules UI enabled you can simply import the above rule in your own site, no need to tweak anything in it, though you may want to tune the Subject and Message content of the actual eMail as you want (just remember the various tokens you may want to use).

Step 3:

Create a rule "Send a group notification by flagging a group", which you can do like so:

Rules Event: When a group is flagged with the flag from Step 1.
Rules Conditions: none (no need for it).
Rules Action: perform the Rules Component from Step 2.

Here is how the rule looks like (in Rules export format, disabled as shown here):

{ "rules_send_a_group_notification_by_flagging_a_group" : {
    "LABEL" : "Send a group notification by flagging a group",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "flag" ],
    "ON" : { "flag_flagged_flag_a_group" : [] },
    "DO" : [
      { "component_rules_send_email_to_all_members_of_a_group" : { "group" : [ "flagged-group" ] } }
    ]
  }
}

If you have the Rules UI enabled you can simply import the above rule in your own site, after you adapt the flag's machine name to fit yours. Don't forget to enable the rule also.

Step 4:

Add any additional parameters to the Rules Component to pass any relevant extra data from the rule (from Step 3) to the Rules Component (from Step 2). E.g. that date field you added to the flag to be included in the email also (as in your question, like "Elle commencera [flagging:field-flag-date:value] et se terminera [flagging:field-flag-date:value2].".

For more details about this, refer to the answer to "How to pass a Flag field's value to a Rules Component triggered by the flag?". Some more details about how to use that answer in the context of this question also:

looking at the message of the eMail in your rule here, I see 2 tokens that look like dates: [flagging:field-flag-date:value] and [flagging:field-flag-date:value2]. But your screenprints do not show how this "field-flag-date" is defined.
My best guess is that you have 1 field with 2 values, no?. If so, you only need 1 Rules Condition to check "Entity has field", which I think will be "flagging:field_flag_date". And in the Rules Action you should then be able to specify (drill down) to both [flagging:field-flag-date:value] and [flagging:field-flag-date:value2].

Voilà

So here you go: only 3 (robust) modules (Flag, Rules and Group) is what's needed to be able to trigger an eMail of all members of a Group that is flagged by an authorized user (with zero custom code).

True, the actual eMail is hardcoded in the Rules Component (would be nice to transform that into something with 2 extra Flag "fields", to specify during the flagging what the actual Subject and message content of the eMail should be).

VBO alternative

Another solution could be to use a combination of Rules and VBO. That would have the advantage that you get all the power of Views available to filter which group members you want to be eMailed ...


Extending EntityFieldQuery's method finishQuery doesn't work as supposed

I think it's because you're not returning anything from the function.

The code for the base finishQuery() function returns at the very least an empty array; at the moment your function isn't doing that.

The fix might be as simple as changing the last line to:

return parent::finishQuery($select_query, $id_key);


Image styles: Does not work with large images

I installed Imagemagick and now everything works as expected.


Adding Values to Header Drupal 7 + .htaccess

There is something you can try with Drupal itself.

hook_url_inbound_alter

  Alters inbound URL requests.

The idea is to drupal_lookup_path and if nothing found you can do whatever with $path variable in  hook_url_inbound_alter


How can I tell if a node has more than one parent taxonomy term assigned to it

There's no need to store this information when it can be calculated on the fly.

The taxonomy module contains a function called taxonomy_get_parents() that can retrieve the parents for a given term. Using this, you can iterate over the node field values to look for any root ("parent") level  terms (i.e. they have no parent) and count the number of terms accordingly.

// Given a node object & taxonomy field machine name, return count of root terms
function mymodule_node_root_term_count($node, $field_name) {
  $count = 0;

  // $node->{$field_name}[LANGUAGE_NONE] will vary with multi-lingual enviroment
  foreach($node->{$field_name}[LANGUAGE_NONE] as $term) {
    $parents = taxonomy_get_parents($term['tid']);
    // A root term will return an empty array.
    $count += empty($parents) ? 1 : 0;
  }

  return $count;
}

Once you've built your logic for determining the type of node, you can utilize it in a theme preprocess function to add CSS classes accordingly.


You need to specify them like this and set #tree to TRUE. Like this.

$form['MyArray']['#tree'] = TRUE;
$form["MyArray"][1] = _d7_taxonomy_term_select($node_type->name, 2, $default_value);
$form["MyArray"][2] = _d7_taxonomy_term_select($node_type->name, 2, $default_value);
$form["MyArray"][3] = _d7_taxonomy_term_select($node_type->name, 2, $default_value);


Can we make template for contextual filter?

There is no such template, but to override contextual filters you can follow the following approach:

In a custom module

you can use hook__views_pre_view to change contextual filter,
add children terms till depth to the contextual filter,
function taxonomy_get_children_all() defined below, will fetch all child terms till depth:
In view, don't forget to allow multiple value contextual filter for contextual filter.

function taxonomy_get_children_all($tid, $vid = 0, $key = 'tid'){
  $c = taxonomy_get_children($tid, $vid, $key);
  $result = array();
  foreach ($c as $t => $d){
    $result[$t] = $d;
    $below = taxonomy_get_children_all($t, $vid, $key);
    if (!empty($below)) {
       foreach ($below as $nt => $nd){
         $result[$nt] = $nd;
       }
    }
 }
 return $result;
 }

 function formalter_views_pre_view(&$view, &$display_id, &$args){
 if($view->name == "category_view") { // && $display_id == "page") {
   $vid = <Your vocabulary id>;

   $t = $args[0];

   $tt = taxonomy_get_children_all($t,$vid);
   foreach($tt as $k => $v) {
     $a = (string)$k;
     $args[0] = $args[0] . "+" . $a;
   }
 }
}


User Avatars on My Relationships: friends Block

Copy /user_relationships/user_relationship_blocks/templates/user_relationships-block.tpl.php to your custom theme's directory and you can make any modifications you want from there.

Make sure NOT to edit that in place. You don't want to end up in a situation where your modifications are scattered all over different module folders.


Drupal 7: Adding a save button to save content to user profile page

For something really simple, you can use the Favorites module where users can add nodes to a "favorites" list. This is based off of the URL though, so a gallery of images rotating on one page wouldn't really work.

For a more robust system, you can configure a bunch of Flags, which can do many different things like bookmarks, favorites, etc.


Deleting all terms from a vocabulary after timeout

Can you run sql queries directly against the database? What makes you think the terms are still there? The vocabulary table contains data about the vocabulary, and you could do a left outer join with term_data to see if there are any "orpaned" terms. So something like (assuming you haven't used a prefix on your drupal database):

SELECT *
FROM term_data t
LEFT OUTER JOIN vocabulary v
ON t.vid = v.vid
WHERE v.vid IS NULL;

You can do a delete on a join if you need to but I suspect you won't find any orphans.

EDIT:

You should also probably check term_node as well that links terms to nodes. If you're going to run these deletes please back up your database first! Also as these queries are written, the term_node needs to run first.

-- Run this first
DELETE n
FROM term_node n
JOIN term_data t
ON n.tid = t.tid
LEFT OUTER JOIN vocabulary v
ON t.vid = v.vid
WHERE v.vid IS NULL;

-- Then run this query
DELETE t
FROM term_data t
LEFT OUTER JOIN vocabulary v
ON t.vid = v.vid
WHERE v.vid IS NULL;

Remember to back up your database first!


Most of Drupal contributed modules have their translation under Drupal Translations

If you visit the site and search for Date, you will notice list of countries and languages.

I notice Portuguese translations for Date module.

Portuguese, Brazil
Portuguese, International
Portuguese, Portugal

Download the correct language translation file by selecting the version of Date module your using.

Go to http://[your_site]/admin/config/regional/translate/import . To import the downloaded file.

For more information about Translation and how to build multi language site please refer to my answer in https://drupal.stackexchange.com/a/184623/24038


Does Commerce Physical Convert Imperial to Metric?

Commerce Physical invokes physical_dimensions_convert which is part of the Physical module. This provides a means to converting data between Metric and Imperial.

physical_dimensions_convert is on line 771 of Physical module - http://drupalcode.org/project/physical.git/blob/refs/heads/7.x-1.x:/physical.module#l771


How does Drupal display the correct time for a specific time zone?

I've never seen the code itself,  but it likely uses this: http://ca3.php.net/manual/en/datetime.settimezone.php


I see two problems:

1) Your hook_theme() implementation is named incorrectly, meaning it will never be called. This:

_telisim_element_theme()

Should be this:

telisim_theme()

2) You haven't implemented theme_telisim_inline_form_element(), so there is no HTML for the form element to render.

You need to create this function, and output the relevant HTML for your form element inside the function.


Context reaction : Exclude specific block?

It might not be overkill to duplicate the context if it works ;)

Context is often used with Delta to provide layout and theme adjustments for internal pages. After setting up a few Delta layouts you will be able to specify a Context/Delta reaction and switch the applied Delta template for your Shop-product page.

Take a look at this decent Delta+Context tutorial. Good luck!

EDIT: If you're not already committed to a theme, the Omega theme has some incredible integration with Context/Delta - intro tutorial here.


What will be the post parameter when specifying vocabulary term?

node[taxonomy][vocabulary term id][tid]=vocabulary term id

in place of vocabulary term id give the term id of the vocabulary term

How to get the term id? I made a custom drupal view of type term where I fetch only the fields term id and term

I then sent the view contents to my iphone app. When I choose a particular term I also have the term id.


How to insert content type fields directly into Views

You should use webform module for it. You can display the form to users which the users can fill and submit. You can review the form submissions by going to content/webforms link.
You can display the webform as a block. You cannot display a content type to be filled in by the user, as only admins can create contents by default.
You can download webform from this Link


management menu invisible for the second administrator

The page under admin require the access administration pages permission, or the administer themes one. (See system_menu(), the 'access arguments' lines.)

  $items['admin'] = array(
    'title' => 'Administration',
    'access arguments' => array('access administration pages'),
    'page callback' => 'system_admin_menu_block_page',
    'weight' => 9,
    'menu_name' => 'management',
    'file' => 'system.admin.inc',
  );
  $items['admin/compact'] = array(
    'title' => 'Compact mode',
    'page callback' => 'system_admin_compact_page',
    'access arguments' => array('access administration pages'),
    'type' => MENU_CALLBACK,
    'file' => 'system.admin.inc',
  );
  $items['admin/tasks'] = array(
    'title' => 'Tasks',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -20,
  );
  $items['admin/index'] = array(
    'title' => 'Index',
    'page callback' => 'system_admin_index',
    'access arguments' => array('access administration pages'),
    'type' => MENU_LOCAL_TASK,
    'weight' => -18,
    'file' => 'system.admin.inc',
  );

  // Menu items that are basically just menu blocks.
  $items['admin/structure'] = array(
    'title' => 'Structure',
    'description' => 'Administer blocks, content types, menus, etc.',
    'position' => 'right',
    'weight' => -8,
    'page callback' => 'system_admin_menu_block_page',
    'access arguments' => array('access administration pages'),
    'file' => 'system.admin.inc',
  );
  // Appearance.
  $items['admin/appearance'] = array(
    'title' => 'Appearance',
    'description' => 'Select and configure your themes.',
    'page callback' => 'system_themes_page',
    'access arguments' => array('administer themes'),
    'position' => 'left',
    'weight' => -6,
    'file' => 'system.admin.inc',
  );

The user you create must have a role with the right permission. Go to admin/people/permissions and assign to the role of that use the necessary permissions, listed under System.

Keep in mind that the user #1 has every permission, independently from the roles it has. If you are wondering why there is a difference between the user you created and the user you normally use, even if they have the same role, that is the reason. Drupal check the currently logged-in user is the user #1, as visible in the code for user_access().

  // User #1 has all privileges:
  if ($account->uid == 1) {
    return TRUE;
  }

User #1 could not have any extra role, and simply be an authenticated user, and still it would have all the permissions, contrary to the normal authenticated users, who have just the permissions you assign to the authenticated user role.


Most likely that your theme renders them menu either in theme_preprocess_page() in its template.php and passing it page.tpl.php. That's how Garland does it:

https://api.drupal.org/api/drupal/themes%21garland%21template.php/function/garland_preprocess_page/7

https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_links/7

Given your question, you're most likely going to end up with a custom theme, which is normal for most sites. The best way to tackle this is to change the logic in preprocess_page to set it up how you like.

That's more sustainable and specific than altering or overriding theme_links() globally in module-space.


Views Block displaying above node content

Try out the below images step by step, i believe you are the evolving this step before you do with other blocks and pages

And see if that

Show block on specific pages are in

All pages except those listed or

Only the listed pages..

Make that to All pages except those listed and check that out..


In your instance the hook should be (based on what you said your theme name is):

function FWMurphy_preprocess_page(&$vars) {
  if (isset($vars['node']->type)) {
    $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
  }
}

After you implement that, clear the drupal cache. For drupal to pickup your page--{node type}.tpl.php , you need to make sure your theme also contains a default page.tpl.php


Can I make Text Field accept filtered_html?

You shouldn't need to use hook_form_alter to allow the user to specify an input format for a textfield. On the content type page, you can edit a fields settings and there is an option titled "Text Processing" that you will want to use instead.

Then when I look at my node form I see the following:


This was accomplished using Operator "CONTAINS" vs default "IS EQUAL TO"

I set a custom group and inputted values manually and had the operator set to contains, so for example if I select "Option A" in my filter and piece of content with either field a or field b with "option a" selected would show up.


how to make a filter on a view be on the result of a select query

I'm pretty sure Drupal 8 does this out of the box when you expose the field as a view filter. The drupal 8 documentation for Views and it's Filters is clear on how to set this up and I believe a Select list is possible with if your field is an integer or a date limited to a Year component.

https://www.drupal.org/docs/8/core/modules/views/expose-a-filter-to-site-visitors


InvalidArgumentException: Invalid translation language (fr) specified

Should check on lang_code the variable you already passed from preprocess, not language.getId() try something like that:

{% if lang_code == 'fr' and tab_label.entity.hastranslation(lang_code) %}

{{ tab_label.entity.translation(lang_code).field_tab_title.entity.label }}

{% else %}

{{ tab_label.entity.field_tab_title.entity.label }}

{% endif %}


Tags not rendering in the correct location

I had the same issue before, try rearranging the fields then save. after that rearrange again to the original order of fields, save then clear all caches.


In search result page, pagination is not showing up

i don't think that this will help you but do it like this:

// template.php
function MYTHEME_preprocess_page(&$variables){
  $search_box = drupal_render(drupal_get_form('search_form'));
  $variables['search_box'] = $search_box;
}

page.tpl.php:

<?php print $search_box; ?>

according to this discussion. You should not put your logic into tpl.


Making a view with a node reference argument

you are almost there. Create a view with display type block for content type articles. Then add a contextual filter (called arguments in Drupal 6) and select the node reference field that links articles and contributors.
Select "Provide default value" and "node ID from URL". You can also validate it to make sure it's of the type "contributor".

Give the block a name and then go to "structure/blocks" and assign that block to a region and have it show up for all content type "article".


Getting other fields during a Drupal Services GET

Use Views Datasource or Views data export and create a page view that contains your fields in JSON, or XML, or whatever you want to use. Then simply do a GET to your view's URL.


Saving a particular field of a related entities with Entity Reference

I think the content is saved correctly but displayed wrong. Try to change your View which displays the results (the table). On the field for the entity reference, you should have an option to change the Formatter of the displayed entity. I think you have currently "Rendered entity" selected. Try to change to Label to only show the title of the referenced entity.

You could also display a different View mode for the rendered entity to show more/different fields. Check the Display Suite Module for this.


How do I use user_save() to add a new category?

The category concept has been removed. So the answer is, you don't.

Not sure what you are trying to do, if you need a better answer, you will need to provide more details.

User is an entity with fields. There's nothing special about it, you change and save data in the same way like any other entity.


How to concatenate a string in a WHERE clause of an SQL query?

There is a small changes in code. I think it will help you.

$query = db_select('node', 'n')->extend('PagerDefault');
        $query->join('url_alias', 'ua', "ua.source = CONCAT('node/', n.nid)" );
        $nids = $query
            ->fields('n', array('nid', 'sticky', 'created'))
            ->condition('type', 'news')
            ->condition('status', 1)
            ->orderBy('sticky', 'DESC')
            ->orderBy('created', 'DESC')
            ->limit(3)
            ->addTag('node_access')
            ->execute()
            ->fetchCol();

For more info check


The config variable might be hard-coded in your codebase.

You could look for the string:

$conf[ or $conf['user_register'] = 0

For example, in settings.php or elsewhere.

The exact string may vary depending on your codebase, e.g quotes, spaces etc..

That would override the variable configuration setting in the UI.


When to use BaseFieldDefinition instead of hook_schema

The question that you are really asking is if you should be using the entity system or not. You only have one option depend on the answer to that.

Yes, there is considerable overhead especially when using content entities. But things like nodes and comments are entities too, and you can have hundreds of thousands of those. It doesn't really depend on how many are stored but how many are accessed and processed on typical requests. If it's common to load a large amount of them (not just calculate aggregates like how many votes but actuall load the whole thing), then entities might not be such a good match.

Drupal Core only has two primary types of entities, content and config entities. You could also define your own lightweight entity type that is completely custom, but then you again need your own storage class, table creation and so on.

But as you said yourself, being a (content) entity gives you a lot functionality, like CRUD, views integration, REST and many more that you possibly don't need for your use case.


Flag module integration with Message module

Actually, I tried "Set a data value" action, but was setting wrong variables in it. Using it right way and adding "Save entity" action (I think without this also it may work fine now) worked for me.

Following is the rules' export format in case someone need it in future:

{ "rules_user_likes_a_node" : {
    "LABEL" : "User likes a node",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "flag" ],
    "ON" : { "flag_flagged_group_flag" : [] },
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "node", "value" : [ "flagged-node" ] },
          "PROVIDE" : { "variable_added" : { "node" : "Added variable" } }
        }
      },
  { "mail" : {
      "to" : [ "flagged-node:author:mail" ],
      "subject" : "[flagged-node:content-type] [flagged-node:title] est aim\u00e9",
      "message" : "Hello [flagged-node:author:name],\r\n\r\n\r\n[flagging-user:name] loved[flagged-node:content-type] [flagged-node:title]",
      "language" : [ "" ]
    }
  },
      { "entity_create" : {
          "USING" : {
            "type" : "message",
            "param_type" : "commons_activity_streams_user_likes_a_node",
            "param_user" : [ "site:current-user" ]
          },
          "PROVIDE" : { "entity_created" : { "message" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "message:field-target-nodes:0" ],
          "value" : [ "flagged-node" ]
        }
      },
      { "entity_save" : { "data" : [ "message" ] } }
    ]
  }
}


how to import term by name in csv file in drupal 7?

Try Views data export

This module is designed to provide a way to export large amounts of
data from views. It provides a display plugin that can rendered
progressively in a batch. Style plugins are included that support
exporting in the following types:
CSV
Microsoft XLS
Microsoft DOC
Basic TXT
XML.

Requirements
The batched export functionality of this module requires a MySQL database.
This module also requires version 2.7 or higher of views.


Sounds like the perfect job for an EntityFieldQuery:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'commerce_coupon')
  ->fieldCondition('commerce_discount_reference', 'target_id', 4);

$results = $query->execute();
if (!empty($results['commerce_coupon'])) {
  $coupons = commerce_coupon_load_multiple(array_keys($results['commerce_coupon']));
}


Pass exposed filters values from one view to another view

Option 1: Views Global Filter. I've never used it but it sounds like a good but very heavy solution.

Option 2: Create the url for the second view dynamically with jQuery every time the exposed filters are changed. If you disable Ajax in the second view, you can see the url change and then use that as basis. The url will still work if you switch on Ajax again.

Option 3: Tokenise the exposed filters and create the link like option 2 in the header or footer.  There seems to be a couple of modules / sandboxes that could help.

I'd probably pick option 2 but of course, there are probably other solutions like your session variable and some views hook.


How to make a content type field unique per user

I don't know the Unique Field module, but I have a suggestion instead.

Create a little utility module which alters the node form of that node type and adds a custom validation. That validation could check for anything on the form, date inclusive.

In the Drupal 6 days it worked like this. I hope this is enough for a starting point. [Also, reading the book Pro Drupal 7 Development can help you a lot if you haven't written a module yet.]


How to upload video to Drupal using Video module?

To start uploading a video you have to create a new content type, and add a new field and use a field type of video. You can also choose a widget type of video upload.

Upon adding the field, on the next step you can add the extensions of the kind of video files you will like to upload


How can I delete a poorly named vocabulary?

Where are you calling that code? Is the $vid really right? You say it has spaces in it? Did you try to delete them from the UI?
Under /admin/structure/taxonomies where you have all vocabularies listed, open the operations dropdown and click "Edit vocabulary".

On the next page click "Delete".


It worked after I added file to the $batch array.

function mymdoule_node_batch()
{
    $batch = array(
        'title'         => t("Migrating"),
        'operations'    => array(
            array('mycallback_001'),
            array('mycallback_002'),
        ),
        'finished'      => 'mycallback_finished',
        'init_message'  => t('Initializing...'),
        'error_message' => t('An error occurred.'),
        'file'          => 'mypatch.ops.inc',
    );

    batch_set($batch);
    drupal_set_message("step: 0");
}


jQuery UI filter, Full HTML and hook_block_view_VIEW_NAME_alter

I was able to make it work with the modules installed ( jQuery plugins , jQuery UI filter and jQuery UI filter accordion). The trick was to include the following Javascript in the template yourtheme_preprocess_page() and in the HTML use the div with id="accordion" of the official example ( https://jqueryui.com/accordion/ ).

drupal_add_js(' jQuery(function() {
var icons = {
  header: "ui-icon-circle-arrow-e",
  activeHeader: "ui-icon-circle-arrow-s"
};
jQuery( "#accordion" ).accordion({
  icons: icons
});
jQuery( "#toggle" ).button().click(function() {
  if ( jQuery( "#accordion" ).accordion( "option", "icons" ) ) {
    jQuery( "#accordion" ).accordion( "option", "icons", null );
  } else {
    jQuery( "#accordion" ).accordion( "option", "icons", icons );
  }
});
  });', array('type' => 'inline'));


Uploading file, parsing and displaying data

I would create a new url where files can be uploaded. This is done with a implementation of hook_menu.

If you want to use Feeds you first need to upload the file and have it converted to rss/csv/opml etc and then use Feeds to map against a node. I would go with a custom module instead so that you can create nodes straight away instead of a "two step operation".

You can find out how to create a form that handles file uploads here. In the submit function for your form you would need to programatically create nodes from the file upload. This can be done in several ways but one is by using Entity metadata wrappers, which I find easy to work with. You can find out more about that here.

This all might sound like a lot of work and I didn't suggest a contributed module but I think in your case it would be more work to first convert the data to something readable by Feeds for example.


How do I set a visibility rule for the individual menu block items?

Step 1

Create 3 blocks:

Block 1 containing links pointing to all items like Item-1, Item-2, Item-3, Item-4, ... etc.
Block 2 containing links pointing to all items Item-1, Item-2 and Item-3.
Block 3 containing links pointing to all items Item-4, Item-5 and Item-6.

Step 2

Enable the Rules block visibility module. Here is a quote from its project page:

  The Rules block visibility module allows Rules components to be used to control block visibility. This provides Drupal administrators and developers extreme flexibility in controlling when blocks should be displayed on their websites, in addition to the default visibility options provided by Drupal.

  The general idea is that if you can do it with Rules, you can use it to control block visibility, so the possibilities are limitless:

  Need to show a block only for users registered more than a month ago?
  Perhaps you have a block that must be shown only between 8am-5pm on weekdays?
  What about displaying or hiding a block based on current weather conditions?

  All of this can be done by using Rules block visibility.

For an illustration of how to use this module, refer to my answer to "How to stop a Views block from displaying to admins, such as user/1?".

Step 3

As per the "if you can do it with Rules, you can use it to control block visibility" above, you've reduced your question to making Rules "check the path of the current page" (so that the block is only shown for the listed pages).

So create 3 Rules Components, each with a Rules Condition that performs a Text comparison with Parameter: Text: [site:current-page:path] and an appropriate Matching Text for the URLs like:

(NOT node/string-1 AND  node/string-2), to show Block 1.
node/string-1, to show Block 2.
node/string-2, to show Block 3.


Should I source control contribed modules in my project?

In my team, we have moved to only sourcing what is specific to our current project. If we are using Views for example, we add the appropriate entry to our drush make-file, and version that, but not the module itself.

This leaves us with a very small repository, consisting of any custom modules specific to the current site, the current theme, and features exports.

Unless you absolutely can't use drush and drush make, I don't see why one should version control code that is well versioned somewhere else. And if you intend to hack on one of modules, then you should add that as a submodule, again, not versioning the code in your own repo. (I believe this is called a vendor branch in SVN).

Edit: For more details and a more advanced setup, you can take a look at this repository: git@github.com:letharion/Drupal-build-scripts.git The scripts are written in bash to support my teams workflow which includes a building a base-install profile (NodeStream), then our site-specific profile on top of that, a make file for each profile, hooks for applying patches or making other changes on individual build steps etc. I hope I will find the time to re-write it as a drush extension in the near future.


How do I limit the access basing on the user role?

user_access function takes permission name as an argument you can not pass user role name to it.

Here is how you can achieve this:

function MYMODULE_menu() {
  $items = array();

  $items['programme_reg'] = array(
    'title' => 'Approved Programmes Registration',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('MYMODULE_form_test_form'),
    'access callback' => '_MYMODULE_check_user_role',
  );

  return $items;
}

function _MYMODULE_check_user_role() {
  $account = $GLOBALS['user'];

  // Assuming that RID 4 is Teacher.
  // You can also check for role name in $account->roles array.
  return (isset($account->roles[4]) ? TRUE : FALSE);
}

Assuming that user role Teacher has Role ID as 4, you can check and return TRUE/FALSE in your own custom access callback. You can also check using Role Name instead of Role ID, see here for more details.


Well you know that all these requests are made using hook_menu.

Yes, you should use hook_menu_alter Create new module and add hook_menu_alter

function my_module_menu_alter(&$items) {
    // Unset core path
    unset($items['The_actual_menu_request']);
    $items['your_new_menu_request'] = array(
        'title' => 'OG subscribe',
        ...
      );
}

Just pass the same page callback and arguments as the menu request for og subscribe

EDIT

Well try this snippet and see if it works, for OG subscribe menu request

Create a custom module. If you do not know how to create a custom module read This

then in your .module file add this code. It should work, I do not know if the 'file' argument needs an absolute path to the file, but if it does not work you just have to change it for the real path in og '../og/og_ui/og_ui.pages.inc'

function my_module_menu_alter(&$items){
  //unset core path
  unset($items['group/%/%/subscribe']);
  //as an example (taking the example url you provided) I will call the new menu request community/node/63/sign-in
  $items['community/%/%/sign-in'] = array(
    'type' => MENU_CALLBACK,
    'file' => 'og_ui.pages.inc',
    'page callback' => 'og_ui_subscribe',
    'page arguments' => array(1, 2),
    'access callback' => 'user_is_logged_in',
    'title' => 'Join group'
  );
}

Greetings hope it helps you, do not forget to mark the answer.


So I've installed FirebugForDrupal (updated)

It seems the extension is not compatible with Firefox 14. The issue report has been opened on July 19, 2012, and it still is open.

The last comments from one of the co-maintainers of the module say:

  unfourtunatly no, currently the new (from the ground up) plugin registers itself with firebug and firefox; it displays the drupal tabs and subtabs. But it doesn't gather the data from the drupalforfirebug drupal module yet.

  Once it is ready I will package it as an xpi and allow it to be downloaded from bitbucket while mozilla reviews the update. I should be done sometime this week.

  So now the code on bitbucket is functional. I wouldn't call it testable -- still hanging around pre-alpha.

  Before I we call it testable I need to do two things.

  Further abstract the connection between the Drupal Module and the Firefox Module. Right now the presentation layer calls the connector that returns the content directly. However, once I abstract that connection to an API call layer then changes to the API will be less problematic for Firefox plugin to deal with.
  Remove the dependency on jQuery for the plugin. Currently the plugin loads jQuery to deal with a couple of UI niceties.<-- this is what is blocking the release.

  By all means though, If you know how to install from code a firefox plugin then please do so. It works just like the old one for the time being.


How to configure annotator and annotation modules in Drupal 7?

I stumbled across the same problem today. Proper way to install everything:

Download the annotator libraries in /sites/all/libraries/annotator
Download jquery_update and set jquery v.1.8 to be used
Download and enable the annotator module and its dependencies (e.g. libraries)
Download and enable the annotation module
Do not change any configuration options

For a minimal installation, I have just used the markup and store plugins. Some things that might get in the way of the annotations being saved:

You need to have Clean URLs installed
If Drupal is not installed in the root of your domain (for example if it's in http://example.com/subsite instead of http://example.com) you may have to change the configuration of the store plugin to point at /subsite/annotation/api instead of /annotation/api

You can manage the permissions to create, edit, view or delete annotations through the permission system of the annotation module.

Also, keep in mind, that if you create the annotation while you are browsing node/3 through the URL: http://test.drupal/node/3#overlay-context=node/6, the annotation WILL NOT appear if you visit: http://test.drupal/node/3. That caused me a lot of headaches. You can check whether your annotations have been saved in the admin/content/annotation path.

NOTICE:
When downloading the annotator library from github make sure that you download the annotator-full.1.2.9.zip not annotator.1.2.9.zip.


Ubercart shipping API, get the package object with php to send the tracking number to the client as email

Are you managing to save the tracking number to the order? With a bit of preprocess magic you could probably get the number as a variable to the invoice template that already gets sent out.

EDIT:

Something like the below would work, that I did to get extra data displayed in an invoice. I did this in my theme, so replace that with your own theme name (and the other capitalised bits).

    function [THEMENAME]_preprocess_uc_order(&$variables) {
        $variables['tracking_number'] =
           db_fetch_object(db_query("QUERY TO GET TRACKING NUMBER"))->COLUMNNAME;
    }

Then if you put uc_order.tpl.php (needed as a dummy file so your theme can override other templates) and your own custom template into your theme directory then you are able to reference it in the template with a simple call like print $tracking_number;


Exporting nodes using Views Bonus Pack strips all formatting

Yes and no - this restriction is by design in the Views Bonus Pack module because of the difficulties in exporting HTML tags in a CSV format but there is a patch available in this d.o thread.


Locally you can disable the error by adding this to your curl options:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

This forces curl to not verify your local cert.


How to display current user name in webform field?

You can alter the webform and put some and achieve this.

<?php
    function module_name_form_alter(&$form, &$form_state, $form_id) {
   // module_name = your custom module name.
       if($form_id =='webform_name')
        // webform_name = your webform id
           //check condition for non login user
           if(!user_is_logged_in()){
            {
             $form['submitted']['field_name']['#default_value']= 'anynomous';
             // field_name = Field name
            }
         }
    }

    ?>

You also need to debug using dpm. Which helps you solve you problem easily.

I believe that you can also do this using Rules module. You also need to try for this.


There is the data attribute on entities, which you cannot access through Entity Metadata Wrappers (per previous answer.)

Do you need the full form state or just values? Also, you do not need to serialize the data, as the entity controller will do this for you.

I would do something like:

form_state_values_clean($form_state);
$order->data['myform_values'] = $form_state['values'];

form_state_values_clean() will remove build IDs and such.


CSS defined in library is not included, but theme works

Finally it seems to have been fixed. I re-created the same template again under a new name. Checked the diff of theme.info.yml and theme.libraries.yml files - only difference is the name. The new template has all the same functionality the previous had and is 1-to-1 copy except for the name. So only thing I can think of is that while playing with the template something has broken and left some residue in the database that prevented the theme from functioning properly ever again.

Thanks everyone who tried to help!


How do I find out which base fields are available for an entity type?

How to get the base fields for an entity type id:

$base_fields = \Drupal::entityManager()->getBaseFieldDefinitions($entity_type_id);

You get an array. The keys are the field names. Example how to loop through this array:

foreach ( $base_fields as $field_name => $definition ) {
  echo "$field_name: ", $definition->getDescription(), "\n";
}

Edit:

The method has moved to the service EntityFieldManager:

$base_fields = \Drupal::service('entity_field.manager')
  ->getBaseFieldDefinitions($entity_type_id);


Most effective way to create a landing page for content types?

If you want your code to live outside your module's .module file, hook_menu has a way to tell Drupal where to look for your page callback. A common name for include files containing page callbacks is MODULENAME.pages.inc. Place this file in the same folder as your .module file. Just add one line to your menu item definition:

function facility_menu() {
  $items['facilities'] = array(
    'title' => 'Facilities',
    'page callback' => 'facility_landing',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'facility.pages.inc',
  );
  return $items;
}

Now Drupal will load the facility.pages.inc file when example.com/facilities is requested. In facility.pages.inc you place the facility_landing() function. Inside facility_landing() you call other functions to generate the page and finally you return the markup (Drupal 6) or render array (Drupal 7) for your landing page.


adding image field to "Taxonomy term view"

when you click on term you see teasers of nodes. few solutions for you:

You can change teaser of node in node display settings.
You can enable taxonomy/term/% view and customize it as you want
Also here is some article


Inline EntityForm is for placing an entity's form within an Edit page of an existing  Node, eg (/node/edit/123). It's not for showing a form on a Nodes' page with a view_mode set to like full.

You want to use either:

webform entity
entityform

And then either use Display Suite or alter the Node Template for your theme to include form for reservations when people view your Node.

Alternatively you can just use 2 content types: 1 for product and 1 for reservations. and use the Prepopulate module to build a link to create a Reservation -- which you can place on the product node. Clicking this link would send the user to create a reservation, you could always send them back to the product node using $form['#redirect'] on your reservation type.

And if you were crazy you could try to make a url using Prepopulate that loads an Ajax popup node reservation form on the product page.

Hopefully one of these ideas sets you on your path.


How to setup a Multilingual site using A LOT of taxonomy terms and CCK content taxonomy?

Check this for taxonomy translation:
http://drupal.org/node/335205

The approach for menu translation depends on your menu and site structure. It is a bit painful but I would recommend using the menu translation interface. Managing multiple menus may work fine if you are planning 2-3 languages max but as you add more languages it will get out of control.


Email notifications for disqus comments on a node

This feature is not supported out of the box. There are a few solutions:

Use http://drupal.org/node/1117622 to fire a callback to Drupal to notify the author.
Sync disqus with the Drupal comment system. The module supports it, but I haven't tested.


Pull all articles from my Drupal Site as JSON

Judging by its description Views Datasource might be the way to go, but it seems to be still not ready for production. There is no even beta version as far as I can tell. But your task can be easily achieved by creating your own custom module.

Create your own module (you can read more about this process here).

And in your module do the following:

//Your implementation of hook_menu, create url endpoints here
function YOURMODULENAME_menu() {
    $items = array();
    $items['path/where/i/want/your/json/to/be'] = array(
        'title' => t('list of articles'), // can actually be arbitrary text here
        'type' => MENU_NORMAL_ITEM,
        'page callback' => 'your_function_name',
        'access callback' => TRUE,
    );
    return $items;
}

//Page callback function that renders the json endpoint
function your_function_name() {
    $query = "SELECT * FROM {node} n WHERE n.type = :type";
    $result = db_query($query, array(':type' => 'article'));
    $json_data = array();
    foreach ($result as $record) {
        $node = node_load($record->nid);
        $json_data[] = array('nid' => $node->nid, 'title' => $node->title, 'body' -> $node->body['und'][0]['value']);
    }
    print drupal_json_encode($json_data);
    exit;
}

I didn't test this code and you might have more fields in article datatype, but I think you should get the idea how this can be done. Just query the database for the list of nodes of specific type, compose an array of data and output json.


Views with contextual filter ignores sort order and number of nodes per page

I tried your example (with Drupal 7.39 and Views 7.x.3.11) and was not able to reproduce the issue. In short, I followed the following steps:

Created a taxonomy vocabulary, called "Tutorial Vocabulary"
Created a content type, called "Tutorial Type" containing two additional fields:

"Tutorial term" (Entity Reference to Taxonomy Terms of type "Tutorial Vocabulary") and
"Weight" (Integer).

Created some content.
Created a View for "Content" type "Tutorial type", added the "sorted by Weight" criterium, removed the default "sorted by creation date" criterium, and configured the default pager to display only "1 item"
Created a contextual filter for the "Tutorial term" field, specifying "Show page not found" when the filter value is not in the URL, and leaving everything by default.

The contextual filter seems to work as expected when I pass the tid of the taxonomy terms: Only the nodes associated to a term are displayed, they are sorted by weight, and only one node per page.

Maybe you are following different steps from the ones I am listing above. If so, please edit your post to specify them, it might be useful in order to find a solution to your question.


How to add an argument to a view programmatically?

You can use hook_views_pre_view and set arguments you want. For example

function hook_views_pre_view(&$view, &$display_id, &$args) {
  if ($view->name == 'your_view_name') {
     $view->set_arguments(array('arg1', 'arg2'));
  }
}


You wont be able to find any easy solution to downgrade from 7 to 6. The best option is to either find an alternative to the module that is not available for D7 or check the issue queue of that module you might find the dev release of the module. OR If only users are important to you then just export the users from D7 and import them on D6.


Drupal Views : Cumulative filtering from an exposed tag cloud

You could use views with exposed filters. You can set filter criteria to "exposed" so the user can choose which filter he would like to have. With the module "Better exposed filters" you have the possibility to format for example a select list as links.


How do I create and synchronize product fields with entity fields on another site

I'll start with saying, you should throw your "no custom coding" requirement out. That's not to say it's not possible, but it's going to require you stitching a patchwork of solutions that might drive you to conflicting or cumbersome processes. Every data migration problem, save for the most basic (e.g. migrating content title & body nodes), will have key details and rarely has pre-made default path in Drupal.

You don't want a patchwork solution to a detailed problem like this; it will be difficult to manage if you find  your future requirements or key module assumptions change in the future. Rather, you should rely on a few key tools to handle some big needs, and fill in the rest with custom code that leverages either Drupal's or contrib module's APIs.

You have 2 broad requirements. I'll list an outline of one approach.

An ETL solution between a new custom asset entities on Site A and commerce product on Site B.

You should, from the start, utilize a shared UUID on your asset entity & Commerce product; the alternative here is having some sort of shared PK mapping between sites that could have all sorts of problems.
The go-to-solution for Drupal data ETL is the Migration framework that allows you specify how to map fields, transform them if needed, and place them into your migrated destination. The duplicate insert problem is solved with UUIDs. Commerce Migrate provides extensions specific to the Commerce project.
You'll need to determine when/how such a migration sync will occur. A solution will need to be driven by your own workflow. As such, there's probably no one-size-fits-all solution here (e.g. if assets are periodically added on scheduled date a simple cron job to migrate products in might suffice a real-time requirement might require some RPC solution).

Data Field syncing.

You should rely on Serivces (as you have mentioned) and Services Entity API to provide CRUD transport. This will allow reliable data push/pull when you need it. Additionally, it could be the framework for providing a RPC service endpoint in the event you want to trigger an asset-to-commerce migration on site B from site A.
Just like with asset-to-product ETL, your sites' workflow is probably going to determine the best course of action. It could work with Rules (with a module provide custom conditions & actions to determine when to sync up via REST) or perhaps a simple custom module running a cron job.

In short, don't rely on a patchwork of module projects to somehow solve the problem for you through trial-and-error. Pick key tools that solve one single problem well (e.g. ETL, HTTP data transport, unique identification) and use your custom code to supply the logic that's unique to your use case.


Change the default "Create new account" title on the User registration page

You can add the following two hooks to your theme's *.theme file or your module's *.module file. The first to alter the title that's displayed in the page title block. The second to alter the meta title.

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHEME/MYMODULE_preprocess_page_title(&$variables) {

  if (\Drupal::routeMatch()->getRouteName() == 'user.register') {

    $variables['title'] = t('New Title');
  }
}

/**
 * Implements hook_preprocess_HOOK().
 */
function MYTHEME/MYMODULE_preprocess_html(&$variables) {

  if (\Drupal::routeMatch()->getRouteName() == 'user.register') {

    $variables['head_title']['title'] = t('New Title');
  }
}


How can I invalidate a cache on a specific View?

If you know the name of the view that you want to clear, then you can clear the caches specific to that view by calling a function like the following:

/**
 * Function to invalidate selected views caches to enable the action forms to work
 */
function mymodule_invalidate_views_cache($view_name) {
  cache_clear_all('ctools_export:views_view:' . $view_name, 'cache_views', TRUE);
  cache_clear_all($view_name, 'cache_views_data', TRUE);
}

I needed this to allow VBO actions with configuration forms to be able to work while views caching was enabled (I am using content caching).  I called this twice, once in the function mymodule_myaction_form() and again in the function mymodule_myaction_submit().


Is ist possible to get the page variables in node templates?

In node.tpl.php you can render the particular field like this:

echo render($content['field_header']);
hide($content['field_header']); // This line isn't necessary as the field has already been rendered, but I've left it here to show how to hide part of a render array in general.

If you need to do this in page.tpl.php then you want to implement a preprocess function in your template file to get the variable you need:

function mymodule_preproces_page(&$vars) {
  if ($node = menu_get_object() && $node->type == 'page') {
    $view = node_view($node);
    $vars['my_header'] = render($view['field_header']);
  }
}


Active menu trail for multiple menu item with the same path

You can use the module menu-position for this. When you add a new rule, just choose the option Mark the rule's parent menu item as being "active" on the settings page. You probably have to create a css rule for your theme, too.


For that function to be available from outside Drupal, you need to first bootstrap Drupal. This means that, with Drupal 7, the first lines of enquiry.php needs to be the following ones.

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

I assume the enquiry.php file is in the same directory containing the index.php file that comes with Drupal.

I would rather suggest you to read the following questions, though:

Are there cases where a third-party module would need to use its own file similar to xmlrp.php, cron.php, or authenticate.php?
How should I implement hook_menu()?


How to prevent Drupal export XML formatter adding paragraphs?

I don't think there is a need to make a "special module". Instead you could install the Forena module (with quite a few official D7 releases ...), as an alternative to what you're trying to do with the Views Data Export module (or the Views Datasource module as suggested in one of the comments to the question here).

You could use the Forena module to create an appropriate report. As per your comment like "Full nodes, no. Only some choosen fields, but all of a single content type." such report should be straight forward to create. And then create an XML file from the report data (= query results). Similar solution for somebody who rather wants/needs a JSON format. Refer to my answer to "How to add a link to the CSV download to my module page, for a report created with Forena?" for more details about all sorts of export formats, and some online demo samples.

Using this alternative, you probably don't need your (not ideal) work-around anymore which is to disable changing new lines to HTML new lines.


How can I print the translated entity title in a template?

If you configure the reference field to display the entity title it should be translated automatically, as @leymannx commented. But if you get the title from the entity directly you have to make sure the entity is in the correct language. If you don't want to use PHP you can do this with the help of Twig Tweak:
{{ item.entity|translation.title.value }}

See https://git.drupalcode.org/project/twig_tweak/-/blob/3.x/docs/cheat-sheet.md#entity-translation


How to open a node form in popup after click on edit from front end?

If you want to go through custom module you need to follow instructions given here. If you are looking for contrib module colorbox or modal forms to edit your content on modal popup(using Ctool).


Here you go:

(function($) {
  Drupal.behaviors.yourCustomName = {
    attach: function (context, settings) {

      $(document, context).scroll(function () {
        var y = $(this).scrollTop();
        if (y > 100) {
          $('.bottomMenu').fadeIn();
        } else {
          $('.bottomMenu').fadeOut();
        }
      });

    }
  };
})(jQuery);

Be sure to read the docs.


Get views contextual filter's argument value in thousand

/**
 * Implements hook_views_data_query_alter().
 *
 * @param $view
 *   Information about Views' tables and fields.
 *
 * @param $query
 *   Information about query used in this views.
 */
function my_module_views_query_alter(&$view, &$query) {
  // Only edit your view whose contextual filter need to be edited.
  if ($view->name == 'your_view_name'){

    // Get your contextual filter field and use your code to strip comma.
    // str_replace(',', '', $row->contact_id);
  }
}


How would you migrate a large list of (taxonomy) vocabulary list?

I have never used it quite for this purpose, but the Feeds module will import from CSV files and can create taxonomy terms.  The Drupal 7 version still says it is alpha status, but I have been using it for a while now without any real problems with CSV files.

Just make sure your CSV is UTF-8 clean, otherwise you may get some obscure SQL errors if your data has characters with diacriticals, etc.


How do I make node_gallery image thumbnails retain original proportions?

Never used this module, but try checking /admin/config/media/image-styles perhaps the module has an image style. If so, all you have to do is edit it and change it to your liking.

Side Note: You can also get there by clicking configuration, then under media click on Image Styles.

As you wrote in a comment:

  Editing the node_gallery_thumbnail style to replace the "Scale and crop" effect with a "Scale" with the same numbers for width and height did the trick.


In Behat How to Stage Link References in Table Nodes

This article from nuvole.org helped me resolve the same issue you describe.  From the article:

  A Link field in Drupal offers quite a wide range of options, such as
  an optional link title or internal/external URLs. We can use the
  following notation to work with links in our test scenarios:

When I am viewing a "post" content:
| title       | Post title                                              |
| field_link1 | http://nuvole.org                                       |
| field_link2 | Link 1 - http://nuvole.org                              |
| field_link3 | Link 1 - http://nuvole.org, Link 2 - http://example.com |

  As you can see we use always the same pattern: a
  dash - to separate parts of the same field value and a comma , to
  separate multiple field values.

The one note that I would add to the article is how to handle a link that has a URL, but not a title.  To handle that scenario, I used the following format:

When I am viewing a "post" content:
| link_with_text    | My link text - http://url.com |
| link_without_text | '' - https://google.com    |


How to redirect custom ajax form to external url

You can't return a redirect response, because the ajax script in the browser expects a json array with jquery commands, so you need to return a RedirectCommand from the ajax callback:

  public function ajaxCallback(array &$form, FormStateInterface $form_state) {
    $response = new AjaxResponse();

    $command = new RedirectCommand('https://example.com');

    return $response->addCommand($command);
  }

which then assigns window.location to redirect client-side.


How to change "Read more" and "Add new comment" link to an image in teaser view?

You can display both links enabled the "links" field in "manage display" page. The "display suite" module redirect to default content types manager.

Path to this page; Administration » Structure » Content types » Your_content_type » Manage display. Don't forget to select the view mode "teaser" in the upper side of the page to display all the fields associated with this view mode.

If you want to change the output, you will have to code the changes. We have different alternatives to reach to the same place:

Implement in your theme template or in your_module.module the hook hook_preprocess_node .  We examinate this function:

/* Tip 1 => You have to change 'yourmodule' for the real name of your module.
* For example, when you create a file like apple.module where you will write your code,
* 'apple' will be the machine name to implement hooks. Following the example,
* the name of this hook in apple.module should be apple_preprocces_node()
*/

function yourmodule_preprocess_node(&$variables){

  // Change *your_content_type* for the machine name of your content type
  // In your database, node_type table, you can see the machine name of your content types
  // By default, Drupal comes with 2 content types called Article and Basic Page,
  // but i assumed that you created a new type.
  // The reason of applying a conditional statement is we only want to apply these changes to a specific type,
  // because it's probably that you will use them to build theme like articles to build a blog.
  if ($variables['type'] == 'your_content_type' ){

  // Change the link node read-more
  // I am changing the title of the link. The text stay in the code,
  // but it's invisible.
  // Default text received in array => 'Read more about ...'

    $variables['content']['links']['node']['#links']['node-readmore']['title'] = 'Read more about ...';

  // We only have hidden the text with the span tag.
  // With css you can display the image you want

     $variables['content']['links']['node']['#links']['submitted']['title'] = $variables['submitted'];
     $variables['content']['links']['node']['#links']['submitted']['html'] = TRUE;
     $variables['display_submitted'] = FALSE;

  // -----------------------------------

  // We apply tha same strategy

  // Change the link node add-comment
  // Default text received in array => 'Add new comment'

    $variables['content']['links']['comment']['#links']['comment-add']['title'] = 'Add new comment';
    $variables['content']['links']['comment']['#links']['comment-add']['html'] = TRUE;

  // With css, the link looks better.

  } // end if

}

You could build your own functions that build the output that you want. This possibility will give you a great power of customization. For example:

 function theme_link_YourContentType_readMore($variables){

   // Build your code and return it

 }

 function theme_link_YourContentType_addComment($variables){

   // Build your code and return it

 }

 // Finally, you need to tell to the system that apply the theme functions that have been built previously

 function yourmodule_preprocess_node(&$variables){

   $variables['content']['links']['node']['#theme'] = 'link_YourContentType_readMore';
   $variables['content']['links']['comment']['#theme'] = 'link_YourContentType_addComment';

 }


Restrict access to text formats for certain role

Alternatively, you can use the Better Formats module, it gives a lot of possibilities to you to control text format selection.


If I understand the question, I think you want the Workflow module.  You probably also need the Revisioning module, and potentially the Module Grants and Rules modules.

I don't recall testing this particular workflow, though.  It is also worth noting that workflows can be a pain to set up, and adding workflow to an existing site can be problematic because existing nodes will not have a workflow yet (some scripts to fix this are available if you poke around).

This question is tagged for Drupal 7, which presents a problem with this solution.  Workflow and Module Grants don't have D7 versions yet.  There are discussions about ports in the issues, but nothing has been released yet.


Warning: Cannot modify header information - headers already sent by

There is an output in your settings.php file. Maybe a whitespace before <?php, maybe you closed PHP tag at the end of your file, can't know without seeing it. Inspect your file carefully.

Be sure to transfer your files in binary mode, and disable all automated conversions your FTP software may offer. Save files as utf8 without BOM, Linux line endings. That's the safest way. If your editor can't do that, use another.

As Daniel Tome correctly pointed out, it may be case of warning turned off on your localhost, not a transfer issue. But the things you need to check are the same either way.


How can I import fields into Drupal 8.4 user profile from a csv file that has identical values in the key row?

The solution will be to create a custom Migration Source Plugin and do some magic in the fetchNextRow() method. Depending on the source of your data, you might also use some other approach.


Set username to the field firstname untill the field first name is filled

use form alter for alter profile2 fields name, then put pass uid load user using userload function get username put this value as default value for the first name field in your profile 2 form ..


Pass variable to field template from theme_preprocess_field()

Ok, I figured this out. My preprocess function was for a field, but I was trying to access the variable in the wrong template. What I ended up doing was creating individual preprocess functions for each paragraphs-item, and preprocessing the variables in there.

First, I created a function that would allow me to create preprocess functions for entity types:

function merge_preprocess_entity(&$vars, $hook) {
  $function = 'merge_preprocess_' . $vars['entity_type'];
  if (function_exists($function)) {
    $function($vars, $hook);
  }
}

This allowed me to create a preprocess function for paragraphs items. Then I used this same idea to create preprocess functions for individual paragraphs items:

function merge_preprocess_paragraphs_item(&$vars, $hook) {
  $elements = $vars['elements'];

  $function = 'merge_preprocess_paragraphs_item__' . $elements['#bundle'];
  if (function_exists($function)) {
    $function($vars, $hook);
  }
}

Now I can set variables that are available in the paragraphs items templates, like so:

function merge_preprocess_paragraphs_item__smaller_full_width_text(&$vars, $hook) {

  if ($vars['content']['field_cta']) {

    $field_cta = !empty($vars['content']['field_cta'])? $vars['content']['field_cta'][0]['entity']['field_collection_item']: '';

    foreach ($field_cta as $field_cta) {

        // Make the CTA url available to the rest of the block
        $vars['content']['cta_url'] = $field_cta['field_link'][0]['#markup'];

        // Set character limit for CTA Text
        $vars['content']['cta_text'] = truncate_utf8($field_cta['field_link_text'][0]['#markup'], 24, TRUE, FALSE);

    }
  }
}


You can get the ID of a menu by looking at the URL when you edit it in the menu configuration admin interface and converting dashes to underscores.

For example, on admin/structure/menu if I hover 'User Menu' I see admin/structure/menu/manage/user-menu/edit which means that the menu machine name is 'user_menu'.

The $element contains the menu's id: $element['#original_link']['menu_name'].

So you can put that in your if() and get

if($element['#original_link']['menu_name'] == 'user_menu') {
  ...
}

where you replace 'user_menu' with the name of the menu you want.


Multiple forms on one page - gather values

You can nest form elements, so there is effectively only one form. That case you'll only need one validation and submit handler. In the end all results will be in $form_state['values'].

function form_a($form, &$form_states) {
  ..
  return $form;
}

function form_b($form, &$form_states) {
  ..
  return $form;
}

function my_form($form, &$form_states) {
  if ($need_a) {
    $form += form_a($form, &$form_states);
  }
  if ($need_b) {
    $form += form_a($form, &$form_states);
  }

  // Add the buttons.
  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 5,
  );

  return $form;
}

function my_form_submit($form, &$form_states) {
  drupal_set_message(print_r($form_state['values'], TRUE));
}


What does the checkbox "link to content" do?

It seems you are in display settings of a content type and these are the fields it has. Link to content in this context means that when this field is displayed it will link back to the parent node.   It will be displayed as link similar to this
SurnameThis surname

where the /node/2 would be the url of the node you are actually viewing
NOTE: if you enable this on the default content type view mode it will not make much sense as it will link on the page you are currently on (node/2).  This makes sense for example when the node is displayed as part of a view and in that case if clicking on the link will take you to the full node.


How to show a link if the user is member of a specific OG group?

Create a block that includes that "Link to node/add/team_1_content with 'Text' = create node" as in your question.

Then use the Rules block visibility module. Here is a quote from its project page:

  The Rules block visibility module allows Rules components to be used to control block visibility. This provides Drupal administrators and developers extreme flexibility in controlling when blocks should be displayed on their websites, in addition to the default visibility options provided by Drupal.

  The general idea is that if you can do it with Rules, you can use it to control block visibility, so the possibilities are limitless:

  Need to show a block only for users registered more than a month ago?
  Perhaps you have a block that must be shown only between 8am-5pm on weekdays?
  What about displaying or hiding a block based on current weather conditions?

  All of this can be done by using Rules block visibility.

With that, and as per the "if you can do it with Rules, you can use it to control block visibility" above, you've reduced your question to making Rules "check if the logged in user is a member of the Organic group team1".

For an illustration of how to use this module, refer to my answer to "How to stop a Views block from displaying to admins, such as user/1?".


Automatically open linked pdf (bypassing download box)

You are just linking to files, and the default action for the browser to take is to ask to download the file.
Files will sometimes automatically open if the browser is set up to do so.
If you want to make sure the pdf is always displayed, you will have to look into pdf viewer modules. Here is a site that compares a few.
https://drupal.org/node/1781960


How to compare 2 row fields in a view and don't display them if some conditions are verified?

Views Conditional

  Views Conditional is a simple module that allows you to define
  conditionals (if xxx then yyy) with fields in views. Conditions
  include:

  Equal To
  Not Equal To
  Greater Than
  Less Than
  Empty
  Not Empty

  Views conditional allows you to output text based on the result of the
  condition.


Display discount ad when people visit the page

You are looking for Splash Offer module. It will show the popup on page load.

  Allows the management of one or more "splash offers", which are modal
  popups with an accept or reject form. If a user accepts the offer then
  a new page will open with a provided accept url. If they reject the
  offer, the modal will close. (If they select Do not Show Again, then a
  cookie is set so as to avoid further display.) You may define the who,
  when and where of the splash offers with precision controls. Factors
  such as: user role, site url, device, and whether the offer has been
  previously viewed (cookies), cookie duration, etc. are configurable
  for each splash offer created.

also take a look at this modules - Splashify, Splash and TinyBox (Simple Splash).


How do I check if the current password that the user gives in the password reset form matches with the hashed password?

The hash is different every time, that's by design, because it is salted.

If you want to change the password of a user, you don't have to hash it yourself. Just load the user, set the password and save.

$user = User::load(1);
$user->setPassword('secret');
$user->save();

For the fatal error that you mentioned before, @mradcliffe already had the answer in a comment of this (now deleted) answer:

  I think MigratePassword is overriding the default password service. You can try changing the constructor argument to be PasswordInterface instead of PhpassHashedPassword if the Drupal instance is using MigratePassword. Or disable migrate module.

Always type hint on the interface if an interface is available. Services might be switched out, like migrate is doing that for example.

To check the password, you just have to use the other method of that interface, \Drupal\Core\Password\PasswordInterface::check(). Those two methods are a direct match for user_hash_password() and user_check_password()


Alter a view to show the first N results

You need to alter the pager, see ViewExecutable:initPager(), so right now only this code works (seems confusing ..):

function mycustommodule_views_query_alter(\Drupal\views\ViewExecutable $view, \Drupal\views\Plugin\views\query\QueryPluginBase $query){
    if($view->id() == 'mycustomview'){
        $view->setOffset(5);
        $view->getPager()->setItemsPerPage(7);
    }
}

  Is that code touched only the first time ? (After running drush cr)

If so - move the method in a file called mycustommodule.views_execution.inc. It won't work on every request inside mycustommodule.module file. see here!

  Also make sure Disable SQL rewriting is not set in the view used !

For more information see the issue I addressed regarding this on d.o.


How to use a sub-domain for a specific content type?

In hook_ENTITY_TYPE_view_alter you can check for your content type and redirect here.
Lets give a try , maybe it will help


How to build Taxonomy Menu with Parents and terms based on node?

Here's what I ended up having to do:

create a new view of Taxonomy Terms, unsorted.
Add Term: Name, & Vocab: Name as fields.
Set format as HTML list, grouped by Vocab: Name.
Add Taxonomy Term: Content with term relationship
Add Content: Nid contextual filter

I then added a filter to exclude certain vocabularies, and finally, added a weight sorting for both term & vocab names.


Render node author profile image in node template

If you like to do this in ui with one line of code:

1) add a view mode for user and name it "nodeview":

  /admin/structure/display-modes/view/add/user

2) activate the new view mode "nodeview" at the bottom of this page in "Custom Display Settings", then you get a new tab for the view mode "nodeview". Configure which fields are displayed and how they are formatted:

  /admin/config/people/accounts/display

3) Use the new view mode to render the author of the node in node preprocess:

$variables['author'] = \Drupal::entityTypeManager()->getViewBuilder('user')->view($variables['node']->getOwner(), 'nodeview');

4) Put the variable in twig

{{ author }}

This method allows full customization in ui and it is fast, because the rendered author gets cached and will be reused in every node referenced.


'Show block on specific pages' wraps url in paragraph tags

We have CK Editor enabled on our site. In order to fix this, I had to go under CK Editor and change the profile for my role. Under Visibility Settings, there was a place to specify paths of textareas not to affect. I put in the path and I'm good to go!


How can I output a Drush report in table format?

You are better off sticking with your initial implementation; if you use Drush output formatters, then the end-user will be able to convert your data to csv or yaml or other formats as needed. If it takes a long time to collect your data, then use drush_log or perhaps a progress bar to let the user know something is going on.


You can do this in hook_preprocess_html():

function theme_preprocess_html(&$var) {
  $script = [
    '#tag' => 'script',
    '#attributes' => [
      'type' => 'module',
      'src' => 'path/to/script.js',
    ],
    '#value' => '',
  ];
  drupal_add_html_head($script, 'script');
}


If you have to use two taxonomy vocabulary instead one, you can do the following.

On the "color" vocabulary add entity reference to the "containers" vocabulary and for each color term set avaiable containers for it.
Using Drupal.settings you give information about relations between terms (as an assocated array, for example) to browser so that it would use information in JavaScript.
Add JQuery script, which intercepts a selection of a color term and delete redundant terms in the select box for containers. That is, for example, you have selected a color Green and JQuery script has immediately removed all elements from the select box for contaners, except "B" and "C".

You can add the JQuery script and send data to Drupal.setting using hook_form_alter for the node insert/edit form.

Of course, I'm not guarantee that this way is the rightest one, but if I were you I would try so at the beginning.


While canceling user account choose either Disable the user account and keep its content or content belong to anonymous user

To bulk Update author for node you could use Views Bulk Operation

Create a view listing the content that you want to edit.
Add a bulk operation in fields

Select change the author of the content

Go to your view to select the nodes for which you want to change the author

Select the author who should be made the new other for all these content.


Cannot update: "No available releases found"

Solution 1: SQL Query

While checking updates Drupal creates some rows inside the key_value table which should be deleted after checking is complete but looks like they doesn't for some reason. So deleting the related rows manually solved my problem:

DELETE FROM key_value WHERE collection = 'update_fetch_task';

Solution 2: hook_update_N()

If it is not possible to execute SQL queries via MySQL CLI on your server, then you might want to create a hook_update_N() in a custom module:

$database = \Drupal::database();
$database
  ->delete('key_value')
  ->condition('collection', 'update_fetch_task')
  ->execute();