How to print preprocess_html variables in page.tpl

Yet another, perhaps simpler, to add variables to multiple templates, is too use an earlier hook_preprocess

  Preprocess theme variables for templates.
  This preprocess function is the first in the sequence of preprocessing and processing functions that is called when preparing variables for a template.

e.g:

/**
 * Implements hook_preprocess
 * @param $variables
 *   The variables array by reference.
 * @param $hook
 *   The name of the theme hook.
 */
function THEMENAME_preprocess(&$variables, $hook) {
  switch($hook){
    case 'html':
    case 'page':
      $variables['foo'] = 'my special variable';
    break;
  }
}

See also: template_preprocess


Drupal Commons update is having troubles using drush

Drush just wasn't cut out to automatically update profiles.  pm-updatecode does not do the right thing, and as you noted, even pm-download picks the wrong location by default.

To download a new version of a module that is in a profile, use --destination to tell Drush exactly where to put the module.
If you get into a situation where Drupal no longer has the right location for your modules, run the registry rebuild tool to fix things up.


Custom module update with project status url

The project status URL you provided in the .info file is wrong: It should be http://domain.com, in the same way for Drupal.org that URL is http://updates.drupal.org/. A Drupal site will then access (in your case) http://domain.com/{project_name}/{drupal_version} to verify the module needs to be updated.
http://domain.com/{project_name}/{drupal_version} needs to return XML data listing all the versions available for that project and that Drupal version.

To make an example with a project hosted on Drupal.org, the list of all the versions available for Drupal 7.x of the Views module is returned from http://updates.drupal.org/release-history/views/7.x, which returns the following.

<?xml version="1.0" encoding="utf-8"?>
<project xmlns:dc="http://purl.org/dc/elements/1.1/">
<title>Views</title>
<short_name>views</short_name>
<dc:creator>merlinofchaos</dc:creator>
<type>project_module</type>
<api_version>7.x</api_version>
<recommended_major>3</recommended_major>
<supported_majors>3</supported_majors>
<default_major>3</default_major>
<project_status>published</project_status>
<link>https://www.drupal.org/project/views</link>
<terms><term><name>Projects</name><value>Modules</value></term><term><name>Maintenance status</name><value>Seeking co-maintainer(s)</value></term><term><name>Development status</name><value>Under active development</value></term></terms>
<releases>
<release><name>views 7.x-3.16</name><version>7.x-3.16</version><tag>7.x-3.16</tag><version_major>3</version_major><version_patch>16</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.16</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.16.tar.gz</download_link><date>1491158584</date><mdhash>d840cb148809da844b93d73b16b453f9</mdhash><filesize>1643030</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.16.tar.gz</url><archive_type>tar.gz</archive_type><md5>d840cb148809da844b93d73b16b453f9</md5><size>1643030</size><filedate>1491158584</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.16.zip</url><archive_type>zip</archive_type><md5>58da4a76b03278e613f8298e69f761c6</md5><size>1913513</size><filedate>1491158584</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.16-rc1</name><version>7.x-3.16-rc1</version><tag>7.x-3.16-rc1</tag><version_major>3</version_major><version_patch>16</version_patch><version_extra>rc1</version_extra><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.16-rc1</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.16-rc1.tar.gz</download_link><date>1489763584</date><mdhash>cba59381dbf64ac9d9d76fa549b4c7c1</mdhash><filesize>1642814</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.16-rc1.tar.gz</url><archive_type>tar.gz</archive_type><md5>cba59381dbf64ac9d9d76fa549b4c7c1</md5><size>1642814</size><filedate>1489763584</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.16-rc1.zip</url><archive_type>zip</archive_type><md5>460ed4581a0a7680fad79e1c124cedc3</md5><size>1913275</size><filedate>1489763584</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security>RC releases are not covered by Drupal security advisories.</security></release><release><name>views 7.x-3.15</name><version>7.x-3.15</version><tag>7.x-3.15</tag><version_major>3</version_major><version_patch>15</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.15</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.15.tar.gz</download_link><date>1487784184</date><mdhash>473cb5384456d55af988feabc1af12ed</mdhash><filesize>1642425</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.15.tar.gz</url><archive_type>tar.gz</archive_type><md5>473cb5384456d55af988feabc1af12ed</md5><size>1642425</size><filedate>1487784184</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.15.zip</url><archive_type>zip</archive_type><md5>d22aa50667d4905a6b954c58d7c29832</md5><size>1913348</size><filedate>1487784184</filedate></file></files><terms><term><name>Release type</name><value>Security update</value></term><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.14</name><version>7.x-3.14</version><tag>7.x-3.14</tag><version_major>3</version_major><version_patch>14</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.14</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.14.tar.gz</download_link><date>1466019539</date><mdhash>168bb684c8f34297be94b03c797841e5</mdhash><filesize>1656594</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.14.tar.gz</url><archive_type>tar.gz</archive_type><md5>168bb684c8f34297be94b03c797841e5</md5><size>1656594</size><filedate>1466019539</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.14.zip</url><archive_type>zip</archive_type><md5>b8ee0f4278b2f67e4d10997dc2a05ec4</md5><size>1913123</size><filedate>1466019539</filedate></file></files><terms><term><name>Release type</name><value>Security update</value></term><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.13</name><version>7.x-3.13</version><tag>7.x-3.13</tag><version_major>3</version_major><version_patch>13</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.13</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.13.tar.gz</download_link><date>1446804839</date><mdhash>50d3b231f689f8c4ff15d79ea3c261d9</mdhash><filesize>1650157</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.13.tar.gz</url><archive_type>tar.gz</archive_type><md5>50d3b231f689f8c4ff15d79ea3c261d9</md5><size>1650157</size><filedate>1446804839</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.13.zip</url><archive_type>zip</archive_type><md5>d30756ba6b3489fd919ddd359f5decad</md5><size>1900939</size><filedate>1446804839</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.12</name><version>7.x-3.12</version><tag>7.x-3.12</tag><version_major>3</version_major><version_patch>12</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.12</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.12.tar.gz</download_link><date>1446653339</date><mdhash>a50033bb090730176d9263ddae7f32b2</mdhash><filesize>1650130</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.12.tar.gz</url><archive_type>tar.gz</archive_type><md5>a50033bb090730176d9263ddae7f32b2</md5><size>1650130</size><filedate>1446653339</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.12.zip</url><archive_type>zip</archive_type><md5>56beb9d18dcc252ca77834f52b9050d1</md5><size>1900868</size><filedate>1446653339</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.11</name><version>7.x-3.11</version><tag>7.x-3.11</tag><version_major>3</version_major><version_patch>11</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.11</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.11.tar.gz</download_link><date>1430320981</date><mdhash>00d722e1d8ed57e912c8bd586cf2edbe</mdhash><filesize>1649389</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.11.tar.gz</url><archive_type>tar.gz</archive_type><md5>00d722e1d8ed57e912c8bd586cf2edbe</md5><size>1649389</size><filedate>1430320981</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.11.zip</url><archive_type>zip</archive_type><md5>448b10631be9423948f4bad59d269593</md5><size>1899261</size><filedate>1430320981</filedate></file></files><terms><term><name>Release type</name><value>Security update</value></term><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.10</name><version>7.x-3.10</version><tag>7.x-3.10</tag><version_major>3</version_major><version_patch>10</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.10</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.10.tar.gz</download_link><date>1423648081</date><mdhash>c9806ffd69448bc505a67e790f97da58</mdhash><filesize>1648314</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.10.tar.gz</url><archive_type>tar.gz</archive_type><md5>c9806ffd69448bc505a67e790f97da58</md5><size>1648314</size><filedate>1423648081</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.10.zip</url><archive_type>zip</archive_type><md5>45246351588a7f9f74a7d8ba1e0554f4</md5><size>1897924</size><filedate>1423648081</filedate></file></files><terms><term><name>Release type</name><value>Security update</value></term><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.8</name><version>7.x-3.8</version><tag>7.x-3.8</tag><version_major>3</version_major><version_patch>8</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.8</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.8.tar.gz</download_link><date>1400618927</date><mdhash>0fbe71c455f5d34c7193797563b63b3f</mdhash><filesize>1646817</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.8.tar.gz</url><archive_type>tar.gz</archive_type><md5>0fbe71c455f5d34c7193797563b63b3f</md5><size>1646817</size><filedate>1400618927</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.8.zip</url><archive_type>zip</archive_type><md5>c1a997653b21943a86bcd42f5c803403</md5><size>1886165</size><filedate>1400618927</filedate></file></files><terms><term><name>Release type</name><value>Security update</value></term><term><name>Release type</name><value>Bug fixes</value></term><term><name>Release type</name><value>New features</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.7</name><version>7.x-3.7</version><tag>7.x-3.7</tag><version_major>3</version_major><version_patch>7</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.7</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.7.tar.gz</download_link><date>1365499237</date><mdhash>3f36f0d13f3b724d719f6729cbc110ba</mdhash><filesize>1639539</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.7.tar.gz</url><archive_type>tar.gz</archive_type><md5>3f36f0d13f3b724d719f6729cbc110ba</md5><size>1639539</size><filedate>1365499237</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.7.zip</url><archive_type>zip</archive_type><md5>c764bcc139e3698b24f4bfcc531542e4</md5><size>1878608</size><filedate>1365499237</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.6</name><version>7.x-3.6</version><tag>7.x-3.6</tag><version_major>3</version_major><version_patch>6</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.6</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.6.tar.gz</download_link><date>1363810217</date><mdhash>1531a1ece3970332db1559b854f5dcc9</mdhash><filesize>1639219</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.6.tar.gz</url><archive_type>tar.gz</archive_type><md5>1531a1ece3970332db1559b854f5dcc9</md5><size>1639219</size><filedate>1363810217</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.6.zip</url><archive_type>zip</archive_type><md5>0d7c7de301caa52670869060e22d1ef3</md5><size>1878465</size><filedate>1363810217</filedate></file></files><terms><term><name>Release type</name><value>Security update</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.5</name><version>7.x-3.5</version><tag>7.x-3.5</tag><version_major>3</version_major><version_patch>5</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.5</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.5.tar.gz</download_link><date>1345829395</date><mdhash>fba70998d4ebcca5116ef5ee90117738</mdhash><filesize>1632919</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.5.tar.gz</url><archive_type>tar.gz</archive_type><md5>fba70998d4ebcca5116ef5ee90117738</md5><size>1632919</size><filedate>1345829395</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.5.zip</url><archive_type>zip</archive_type><md5>8b1102f6cd54949eee147c63c4fd352b</md5><size>1866348</size><filedate>1345829395</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.4</name><version>7.x-3.4</version><tag>7.x-3.4</tag><version_major>3</version_major><version_patch>4</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.4</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.4.tar.gz</download_link><date>1345559303</date><mdhash>72bd0f35ac467aed74e533c10a76c93f</mdhash><filesize>1632803</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.4.tar.gz</url><archive_type>tar.gz</archive_type><md5>72bd0f35ac467aed74e533c10a76c93f</md5><size>1632803</size><filedate>1345559303</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.4.zip</url><archive_type>zip</archive_type><md5>0e92dc862bea87904d507af72e710af7</md5><size>1866193</size><filedate>1345559303</filedate></file></files><terms><term><name>Release type</name><value>New features</value></term><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.3</name><version>7.x-3.3</version><tag>7.x-3.3</tag><version_major>3</version_major><version_patch>3</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.3</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.3.tar.gz</download_link><date>1329946249</date><mdhash>70f24086dc7acfa7fc23c6148c7f8e00</mdhash><filesize>1583249</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.3.tar.gz</url><archive_type>tar.gz</archive_type><md5>70f24086dc7acfa7fc23c6148c7f8e00</md5><size>1583249</size><filedate>1329946249</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.3.zip</url><archive_type>zip</archive_type><md5>e8b5f8d4de7526d2919993bb3a34c0bf</md5><size>1803054</size><filedate>1329946249</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.2</name><version>7.x-3.2</version><tag>7.x-3.2</tag><version_major>3</version_major><version_patch>2</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.2</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.2.tar.gz</download_link><date>1329778551</date><mdhash>c350603991445ca69b30eddf3befe887</mdhash><filesize>1582617</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.2.tar.gz</url><archive_type>tar.gz</archive_type><md5>c350603991445ca69b30eddf3befe887</md5><size>1582617</size><filedate>1329778551</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.2.zip</url><archive_type>zip</archive_type><md5>641a7c36bc39d5c17b997ff5babf6d47</md5><size>1801836</size><filedate>1329778552</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.1</name><version>7.x-3.1</version><tag>7.x-3.1</tag><version_major>3</version_major><version_patch>1</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.1</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.1.tar.gz</download_link><date>1326750948</date><mdhash>e158435dc66d1d89a0df587c39ef1a23</mdhash><filesize>1575585</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.1.tar.gz</url><archive_type>tar.gz</archive_type><md5>e158435dc66d1d89a0df587c39ef1a23</md5><size>1575585</size><filedate>1326750948</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.1.zip</url><archive_type>zip</archive_type><md5>43999fc1888c1aa88f1d20288aace84c</md5><size>1792932</size><filedate>1326750949</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.0</name><version>7.x-3.0</version><tag>7.x-3.0</tag><version_major>3</version_major><version_patch>0</version_patch><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.0</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.0.tar.gz</download_link><date>1324170451</date><mdhash>1be8cbd6fd3f37bfd1493693dfa95d8d</mdhash><filesize>1461460</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0.tar.gz</url><archive_type>tar.gz</archive_type><md5>1be8cbd6fd3f37bfd1493693dfa95d8d</md5><size>1461460</size><filedate>1324170451</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0.zip</url><archive_type>zip</archive_type><md5>99769e8808519ae36171fa619cf00997</md5><size>1672723</size><filedate>1324170451</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security covered="1"/></release><release><name>views 7.x-3.0-rc3</name><version>7.x-3.0-rc3</version><tag>7.x-3.0-rc3</tag><version_major>3</version_major><version_patch>0</version_patch><version_extra>rc3</version_extra><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.0-rc3</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.0-rc3.tar.gz</download_link><date>1321467945</date><mdhash>b3e58f4195308e37621155d3c843e53f</mdhash><filesize>1456218</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-rc3.tar.gz</url><archive_type>tar.gz</archive_type><md5>b3e58f4195308e37621155d3c843e53f</md5><size>1456218</size><filedate>1321467945</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-rc3.zip</url><archive_type>zip</archive_type><md5>502f84cfadb4bf4744b6c452fc01f2d6</md5><size>1665759</size><filedate>1321467946</filedate></file></files><terms><term><name>Release type</name><value>Security update</value></term><term><name>Release type</name><value>Bug fixes</value></term></terms><security>RC releases are not covered by Drupal security advisories.</security></release><release><name>views 7.x-3.0-rc1</name><version>7.x-3.0-rc1</version><tag>7.x-3.0-rc1</tag><version_major>3</version_major><version_patch>0</version_patch><version_extra>rc1</version_extra><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.0-rc1</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.0-rc1.tar.gz</download_link><date>1308341221</date><mdhash>e158db78ae2f8cc615edb910a09384b0</mdhash><filesize>1481151</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-rc1.tar.gz</url><archive_type>tar.gz</archive_type><md5>e158db78ae2f8cc615edb910a09384b0</md5><size>1481151</size><filedate>1308341221</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-rc1.zip</url><archive_type>zip</archive_type><md5>941111b41371084230bc82374ebcae19</md5><size>1682522</size><filedate>1308341221</filedate></file></files><terms><term><name>Release type</name><value>New features</value></term><term><name>Release type</name><value>Bug fixes</value></term></terms><security>RC releases are not covered by Drupal security advisories.</security></release><release><name>views 7.x-3.0-beta3</name><version>7.x-3.0-beta3</version><tag>7.x-3.0-beta3</tag><version_major>3</version_major><version_patch>0</version_patch><version_extra>beta3</version_extra><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.0-beta3</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.0-beta3.tar.gz</download_link><date>1301301971</date><mdhash>114c76f201523ef3e50b9a1d431b0364</mdhash><filesize>1469580</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-beta3.tar.gz</url><archive_type>tar.gz</archive_type><md5>114c76f201523ef3e50b9a1d431b0364</md5><size>1469580</size><filedate>1301301971</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-beta3.zip</url><archive_type>zip</archive_type><md5>d69e051c8b4fa2066575c28e3ae197ba</md5><size>1671930</size><filedate>1301301971</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security>Beta releases are not covered by Drupal security advisories.</security></release><release><name>views 7.x-3.0-beta2</name><version>7.x-3.0-beta2</version><tag>7.x-3.0-beta2</tag><version_major>3</version_major><version_patch>0</version_patch><version_extra>beta2</version_extra><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.0-beta2</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.0-beta2.tar.gz</download_link><date>1301158871</date><mdhash>c39fab1e76e55b15291fecf2c10386c2</mdhash><filesize>1469243</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-beta2.tar.gz</url><archive_type>tar.gz</archive_type><md5>c39fab1e76e55b15291fecf2c10386c2</md5><size>1469243</size><filedate>1301158871</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-beta2.zip</url><archive_type>zip</archive_type><md5>cd30442906e8d9e9bffc7ea8b28f3702</md5><size>1671405</size><filedate>1301158871</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security>Beta releases are not covered by Drupal security advisories.</security></release><release><name>views 7.x-3.0-beta1</name><version>7.x-3.0-beta1</version><tag>7.x-3.0-beta1</tag><version_major>3</version_major><version_patch>0</version_patch><version_extra>beta1</version_extra><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.0-beta1</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.0-beta1.tar.gz</download_link><date>1301099796</date><mdhash>6ee4495cbdf0a8d19bd214f57bef0bf4</mdhash><filesize>1468892</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-beta1.tar.gz</url><archive_type>tar.gz</archive_type><md5>6ee4495cbdf0a8d19bd214f57bef0bf4</md5><size>1468892</size><filedate>1301099796</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-beta1.zip</url><archive_type>zip</archive_type><md5>36acc8675052e2dcb0c933e1ac8eab1d</md5><size>1670997</size><filedate>1301099796</filedate></file></files><terms><term><name>Release type</name><value>New features</value></term><term><name>Release type</name><value>Bug fixes</value></term></terms><security>Beta releases are not covered by Drupal security advisories.</security></release><release><name>views 7.x-3.0-alpha1</name><version>7.x-3.0-alpha1</version><tag>7.x-3.0-alpha1</tag><version_major>3</version_major><version_patch>0</version_patch><version_extra>alpha1</version_extra><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.0-alpha1</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.0-alpha1.tar.gz</download_link><date>1294276882</date><mdhash>8635e5b0c03fed4516abae25489a5a5c</mdhash><filesize>1561161</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-alpha1.tar.gz</url><archive_type>tar.gz</archive_type><md5>8635e5b0c03fed4516abae25489a5a5c</md5><size>1561161</size><filedate>1294276882</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.0-alpha1.zip</url><archive_type>zip</archive_type><md5>f5ffc235849f2a3a5f66b66f84a73aac</md5><size>1772425</size><filedate>1294276882</filedate></file></files><terms><term><name>Release type</name><value>Bug fixes</value></term></terms><security>Alpha releases are not covered by Drupal security advisories.</security></release><release><name>views 7.x-3.x-dev</name><version>7.x-3.x-dev</version><tag>7.x-3.x</tag><version_major>3</version_major><version_extra>dev</version_extra><status>published</status><release_link>https://www.drupal.org/project/views/releases/7.x-3.x-dev</release_link><download_link>https://ftp.drupal.org/files/projects/views-7.x-3.x-dev.tar.gz</download_link><date>1491154383</date><mdhash>b8b158ae6a7c9f4e84540fbfcfa83ee3</mdhash><filesize>1643061</filesize><files><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.x-dev.tar.gz</url><archive_type>tar.gz</archive_type><md5>b8b158ae6a7c9f4e84540fbfcfa83ee3</md5><size>1643061</size><filedate>1491154383</filedate></file><file><url>https://ftp.drupal.org/files/projects/views-7.x-3.x-dev.zip</url><archive_type>zip</archive_type><md5>db78a5499cda151d5a352a908adf7e6b</md5><size>1913538</size><filedate>1491154383</filedate></file></files><security>Dev releases are not covered by Drupal security advisories.</security></release></releases>
</project>

To make it short:

You need to change the project update URL reported in the .info file of the module (e.g. http://domain.com)
The server, on http://domain.com/release-history/{project_name}/{drupal_version}, needs to return XML data that describe all the project versions available and compatible with the Drupal version reported as last part of the URL (e.g. 7.x for Drupal 7, 8.x for Drupal 8)


Ari,

Let me start off by saying that media files (images, videos, etc..) attached to nodes, Meaning they are acctually uploaded when entering in a node content, those files are stored in the default file folder (usually 'sites/default/files' ), unless that field in the content type specifies otherwise.

Example:
If i create a content type called 'blog entry', I would add a field to that content type called media.  When you get to the screen where you can edit the field information, you can select accepted file extentions, where the files would be stored in relative path to the default file location in your sites file location settings (again, usually: sites/default/files)

I would make this file location 'blog-entry/media' for this new field in my new content type. So my files would upload to: sites/default/files/blog-entry/media  when i uploaded them during the addition of content.

The thumbnail settings are somewhat default and can be adjusted under the display settings for the content type. THere are default thumbnail parameters you can select from, or you can add/remove thumnail options in the site settings as well under image settings

Once you get a hang of this flow you will see how easy it really is to manage media.

Another module worth looking into (after you have done the above, so that you may understand what the core of Drupal is doing with your media files), is the Media Module. It makes uploading and managing a little easier than core.

Also to note: stay away from Media Gallery right now.. its a mess as of this week.. most bugs should be resolved sometime next month.


Search API Solr Configured, Content Indexed, No Search Results

Few observations that might help you.

Term "solenoid" is only listed in 2 fields "tm_body_1" and "spell". Are you sure your solr instance is searching on these fields ?
Can you try creating a view and see if you get some response / results ?
Not sure, but did you copied over the Solr config files that are part of the module(search_api_solr), in your solr instance ?
Which version of Solr you are using, as module version 8.x-2.7 supports 6.x and 7.x version - https://git.drupalcode.org/project/search_api_solr/tree/8.x-2.7/solr-conf.

Hope that helps !!


In computing, "bootstrapping" refers to software getting to a state to where it can perform the task being requested.

In the context of Drupal, it means the code starts and does everything up to the point where it generates the page.  It more-or-less includes

connecting to the database
reading configuration
loading modules

The bootstrap process is pretty much the same for everything request; what happens when a page gets rendered and sent to the browser differs page-to-page.

So, when "Drupal fails to bootstrap", it means that it wasn't able to get to a point to figure out what to do, and is considered a Fatal Error.  In my experience nine times out of ten when it happens in a production environment, it is because there was a problem connecting to the database.


Like you said disabling the render cache site wide is not a good idea. If you need this for one content type you can do this in a view alter hook.

If you want to disable caching for authenticated and anonymous users you have to set cache max-age = 0 and trigger the kill switch for the internal page cache:

function MYMODULE_node_view_alter(array &$build, Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display) {
  if ($entity->bundle() == 'article') {
    $build['#cache']['max-age'] = 0;
    \Drupal::service('page_cache_kill_switch')->trigger();
  }
}

The same can be implemented in a theme in a preprocess hook.


How to give the image path in the check box field option for a content type

Your image path needs a / before sites. Should be "/sites/default/files/test-image1.jpg"

If you don't have a / at the start, then it appends your url code to whatever page you're on. Example: node/1/sites/default/files/test-image1.jpg which is not what you want (broken image since it doesn't exist)


Is it feasible to migrate by only migrating content?

TL;DR: use Migrate and associated modules to do the heavy lifting, adding in your own code as needed.
Yes, you absolutely can build your configuration first and then migrate content. I'd suggest the following outline approach (you'll still need to read the documentation for Migrate and these modules carefully):

Install the Migrate Tools and Migrate Upgrade modules.
Use migrate upgrade to generate prototype migration configuration, eg. drush migrate-upgrade --legacy-db-url=mysql://user:pass@12.34.56.78/d6db --legacy-root=http://myd6site.com --configure-only
Export the configuration and weed out any migrations that you don't need, such as content type and field definitions. Remove references to these from other migrations.
Edit the remaining configurations to your needs. This can be laborious and for some cases it may be easier to use custom hooks to manipulate data rather than configuring process plugins. However, the process plugins provided by core, supplemented by those from Migrate Plus, are very powerful once you understand them.

These modules will do much of the hard work for you so you can concentrate on the tougher problems you may face, such as dealing with embedded media tags that may require modules that are not ported to D8.
(If you are thinking of moving field collections to paragraphs, the D8 Paragraphs module has everything you need already in place).


Conditionally change the image field style and wrapping it in a div

You can set wrapper for it with simple way
instead

print render($content);

just use

print '
'.render($content['field_image']).'
;

and for second limitation if you have not $node just need load it with node_load  ( if you have nid)

So before your code

  $node= node_load($nid);


Creating an entity with an unlimited number of bundles

You have to register entities using hook_entity_info() so the system knows about them.

If you look at those docs it tells you about the different entity properties.

The one you are interested in at the moment is the bundle entity key and the bundles array.

You can see from the docs that you have to specify a list of bundles, otherwise it will be assumed you only have a single bundle with the same name as the entity type.

The example I would probably look at is node, because it is in Drupal core, so check out node_entity_info().

You can see it works similar to the profile2 one in that it gets its node bundle information from the database from where users have defined content types via the content type UI (and also from hook_node_info() for modules defining content types).

So you need a table for the bundle information, similar to the node_type table.

You also need your table to store entity data, similar to the node table.

If you want to support revisions you also need a revision table, similar to the node_revision table.

I can't see how it is possible with a single table unless you are storing 2 completely different types of data in a single database table, which would be bad.

Another thing to consider is that the system needs to know about bundles to provide UI screens for managing fields.
You have to manage the fields before the user creates any content so at the time you need those UI pages there is nothing in the node table so it couldn't pull bundle data from there at that point.
If you pulled bundle data from the main node table you wouldn't be able to administer the fields until a node was created of that bundle type.

I'm also not sure why you are apprehensive about having 2 tables.


Drupal7 user reset password link not working

Not sure exactly what is wrong with your code (I will check it out in a min), but if the purpose is just to add some text to the password reset form, I would do it in one of these ways:

Add a custom block with the text you want to add and assign it to the user register page.
Add a custom module and use hook_form_alter to add custom markup. Like so:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function MYMODULE_form_user_pass_alter(&$form, &$form_state) {
  $form['intro_text'] = array(
    '#markup' => '
' . t('This is my super awesome reg form') . '
',
    '#weight' => -10,
  );
}


Image Cache only clears when clearing my browser cache

Drupal some times uses cache in Images for better user performance.

if you want to view the image after the update or change you can use this code

<?php
 //get the image fiels
 if (isset($data->field_field_profile_pic) && !empty($data->field_field_profile_pic[0]['rendered']['#item']['uri'])) {
        $Logo = file_create_url($data->field_field_profile_pic[0]['rendered']['#item']['uri']);
 }

?>
//print the image tag
<img  src='<?php print $Logo.'?'.time();?>' alt=''>

Here the main code here is appending time stamp after your image as query string so time() will append the image tag with latest timestamp which will get the latest image from your server.

will reduce your burden from clearing your cache every time.

this is a quick fix we used in our project.


Under Menus > Primary Links > (select items to enable by checking the menu items)
Check to ensure primary links are specified in the blocks by visiting 'Blocks' configuration.

Is this what you're looking for?


Change entity reference field widget based on condition?

For D7, you use hook_field_widget_properties_ENTITY_TYPE_alter but the problem is that in D8 this hook no longer exists.
Took a while to figure out an answer for D8, but here it is.
Since D8 allows you to create Form Display Modes:
1) Add a form mode

2) Select the entity type, User in this case

3) Add name to it

4) In Manage Form Display, click on Custom Display Settings and checkmark it

5) Click on the alternate view mode and change widget

Then in custom module you change the view mode if it has a certain role
/**
 * Implements hook_entity_form_display_alter()
 */
function mymodule_entity_form_display_alter(\Drupal\Core\Entity\Display\EntityFormDisplayInterface &$form_display, array $context) {
  if ($context['entity_type'] == 'user' && $context['bundle'] == 'user') {
    $current_user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
    if ($current_user->hasRole('administrator')) {
      // change the display mode
      $id = $context['entity_type'] . '.' . $context['bundle'] . '.alternate';
      $storage = \Drupal::entityTypeManager()
        ->getStorage('entity_form_display');
      $alt_display = $storage->load($id);
      $form_display = $alt_display;
    }
  }
}


How to change the way a Content Type is displayed depending on user?

Have a look at Display Modes, View Modes, and Form Modes, especially what is written about View modes within "View modes and view displays", which is like so:

View modes as a concept predate Drupal 8. They were present in Drupal 7. Drupal 6 had the concept of “build modes.” View modes exist to allow Drupal site building tools like Entity Reference fields to request a given entity be rendered in a certain way. For instance, if ‘song’ and ‘artist’ are each node types and song contains a reference field to artist. The full display of the song may need to render the ‘teaser’ for the artist. In this example ‘teaser’ is a view mode used by the artist node and ‘full’ is the view mode used by the song.

Then continue towards that present in Drupal 7 link, which further explains View modes, and includes this:

Contributed modules can be leveraged to add View modes to entities via the UI without writing code.

Display Suite

The Display Suite module makes it possible to add more view modes to your entities.

Entity View Modes

The Drupal 7 successor to Build modes which will allow administrators to define custom view modes for entities.

Then head over to the Entity View Modes project page ... Guess what: that module is now included in D8 core ...


What you can do is to define the path as a non-routed path:

<?
$url = Url::fromUri('base://knowledge-base');

(The base:// stuff is a bit weird IMHO, don't ask me why it's named like that. @dawehner might know ;))

This has a few limitations, some methods will then not work (like getRouteName()), and the url will not be checked for access.

The only other way I can think of is to define two displays in your view, one without an argument and the other one that requires it.


Passing a contextual filter value to a view via a link with entityreference prepopulate?

One solution would be to add a custom panel to a panel page overriding the node edit form.

To do so you'll want to go into Panels Page Manager (/admin/structure/pages) and enable node_edit adding a variant that uses context to evaluate Node: type where Node being viewed is type "Your Content Type"

Then go into the panel page content section and choose "New Custom Content" from the panel selection dialog.

In the dialog that opens, makes sure to choose and input format that allows hyperlinks.

Make sure "Use context keywords" is checked and in the substitution choices you'll see %node:nid

You can use this to build the url:

Reply


Notification when a shopping cart is abandoned

I'd start by trying the existing Commerce Abandoned Cart Notification module. This module was specifically designed to send abandoned cart notifications.

This module allows you to notify your customers by email about their abandoned their cart.
Abandoned Shopping Cart mailings generate more than 55% more conversion compared to regular email campaigns. –SeeWhy research (2011)
Features

List your customers abandoned carts
100% integration with Commerce VBO
Edit the notification email directly from the Rule component


If you want the entire files directory of uploaded files, you can do this with Drush:

drush rsync @source.target:%files/ @destination.target:%files

See: https://drushcommands.com/drush-8x/core/core-rsync/

This relies on having %files defined in your path-alias part of your alias definitions for drush.

Alternatively, you could ssh into the server, and tar/gzip the files directory, then scp it down to your machine (or sftp/ftp, I suppose).

Either of these methods will bring the entire files directory with it, which will have all uploaded files, any image derivatives (generated image style files) as well as cached css/js files. If you use the drush command with arguments, you can exclude directories you don't want.


Install module from URL to site directory instead of /all

The update manager will only install modules to sites/all/modules unfortunately (see this page), so it looks like you'll have to FTP/SCP/whatever them to your server.

There are some advanced installation methods here, but installing modules into specific directories is not something the update manager can do.

Alternatively, you should definately try Drush if you're not using it already.  There's a pretty good tutorial on how to set up Drush for a multisite here.

Drush homepage

Drush project page

Drush DO page

Drush cheatsheet

Drush guide


Userplus has an action which changes a users password, I was able to use the below:

/**
 * Implementation of hook_action_info().
 */
function userplus_actions_action_info() {
  $actions = array(
    'userplus_change_password_action' => array(
      'type' => 'user',
      'description' => t('Change user\'s password'),
      'configurable' => TRUE,
      'hooks' => array(),
    ),
  );
  return $actions;
}

/**
 * Action to change a user's password
 */
function userplus_change_password_action_form($context) {
  _user_password_dynamic_validation();
  $form['pass'] = array(
    '#title' => t('New password'),
    '#type' => 'password_confirm',
    '#description' => t('Provide a password for the selected users in both fields.'),
    '#required' => TRUE,
    '#size' => 25,
  );

  return $form;
}

function userplus_change_password_action_submit($form, $form_state) {
  return array('pass' => $form_state['values']['pass']);
}

function userplus_change_password_action(&$user, $context) {
  user_save($user, array('pass' => $context['pass']));
}


How to create a different second level block for every menu link?

Different colour second level menu items

I would not use a block for each menu item even if you could.

The menu items should have classes with their mlid (menu link id), which is unique to the menu item.

You can add different colours with css based on those classes.

Different colour second level menus based on active path

Now that I understand your question you want the whole second level menu block to be coloured based on the currently active top level menu item.

In this scenario I think it is more acceptable to have a second level menu block for each parent menu item, so that is one solution, in which case you can easily style the blocks differently as they have different block IDs.

An alternative solution, is to add a single second level menu block for your main menu, and then add this code to your theme's template.php file:

/**
 * Override or insert variables into the menu block wrapper template.
 */
function THEME_NAME_preprocess_menu_block_wrapper(&$variables) {
  $active_trail = menu_get_active_trail();
  foreach ($active_trail as $item) {
    if ((!(bool) ($item['type'] & MENU_IS_LOCAL_TASK)) && !empty($item['mlid'])) {
      $variables['classes_array'][] = 'active-top-level-mlid-' . $item['mlid'];
      break;
    }
  }
}

That code will add a class to the block like active-top-level-mlid-405 - where 405 is the mlid of the active top level menu item.

You can then theme the block using this class.


How to display multiple nodes of a content type on a page displaying a parent node?

Just use a Views Attachment to attach another view After your first view.

Another similar option is the Entity Views Attachment module:

  "Eva" is short for "Entity Views Attachment;" it provides a Views display plugin that allows the output of a View to be attached to the content of any Drupal entity. The body of a node or comment, the profile of a user account, or the listing page for a Taxonomy term are all examples of entity content.

  The placement of the view in the entity's content can be reordered on the "Field Display" administration page for that entity, like other fields added using the Field UI module.

So the nice thing about the EVA module is that it allows you to easily place and manage the View from the Field UI of your content type. Thus, making the administration of this tacked on view a little bit easier for site administrators.


Upgrade error: Attempt to create a field body that does not exist on entity type node

The solution is to manually create a "body" field in my landing_page content type.  Once I created the body field, the error no longer show up.

This can be apply to any other fields is show up in the error.


How can I override apache solr's default search result sorting?

This requires a custom modules where you implement a hook provided by apachesolr. There are several options but hook_apachesolr_modify_query(&$query, &$params, $caller) works as well as any.

You can modify the $query:

$query->set_solrsort($field_name, $direction);

Or you can modify the $params:

$params['sort'] = "$field_name $direction";


CSS styles not working while included in .info.yml file

Working for me creating drupal8 theme using bartik theme as base theme. Successfully call the css file present in my custom theme. Hopes this will helps you.

name: Smart
type: theme
description: 'Smart business templates'
core: '8.x'
package: Custom
base theme: bartik
project: 'drupal'
stylesheets-remove:
 - colors.css
stylesheets-override:
 - css/colors.css
regions:
 header: Header
 primary_menu: 'Primary menu'
 help: Help
 featured: Featured
 content: Content
 sidebar_first: 'First sidebar'
 sidebar_second: 'Second sidebar'
 triptych_first: 'Triptych first'
 triptych_middle: 'Triptych middle'
 triptych_last: 'Triptych last'
 footer_firstcolumn: 'Footer first column'
 footer_secondcolumn: 'Footer second column'
 footer_thirdcolumn: 'Footer third column'
 footer_fourthcolumn: 'Footer fourth column'
 footer: Footer

settings:
 shortcut_module_link: false

Also take reference from https://www.drupal.org/node/1876600


trailing slash added unwillingly and page not found

There was a folder in drupal installation folder with the exact same name as the path, which added the slash at the end


How to schedule the execution of a Rules Action based on a webform submission date field?

I'm not really familiar with Rules but this might be a step in the right direction.

If node:created worked you could give http://drupal.org/project/webform_tokens a try, it should define tokens for your form components, however I'm not sure if the date will be in the correct format.

If it's not in the correct format you could alter it for the compontent in a presave hook.

function hook_webform_submission_presave($node, $submission) {
  // Use dpm() to find out how the date is formatted, and make it into a timestamp.
  $date = strtotime($submission->data['COMPONENT_ID']['value'][0]);
  $submision->data['COMPONENT_ID']['value'][0] = $date;
}

Now you have altered the data for the submisison, converting a date into a timestamp which should then be used through webform_tokens just like node:created.


Products are stored without title and product variations. Can't display them

I'm not working on Kickstart as I prefer to have a custom install of Drupal Commerce.

Commerce concept is that each product you create is a variation and you can use those variations in a display (content type)

If you can't see and delete products in the products list, you can create a view (page) displaying commerce products in admin mode (page url : admin/my-view).
Then add fields like : product id, sku, title and commerce product delete link.

But it's really strange to have products without title in yourdatabase... because you can't create product without title.


By default terms not add in drupal,Properly you  are using active tag module,install autocomplete_deluxe module and use it as that field widget.


Hook menu url giving access denied for post method but working for get method

your code works for me:

Try to move watchdog before return if there is any exception, will log into your report log.
Change your function to like this:

function mymodule_api_return_aid_program() {
  try {
    // Fetching the primary parameters
    //product code
    $product = $_POST['product'];
    //country code
    $country = $_POST['country'];
    // language code
    $language = $_POST['language'];
    // age
    //citizenship
    // veteran_status
    $values = _find_product_specific_to_country($product, $country);
    return array('message' => array('nodes' => $values));
  } catch (Exception $e) {
    watchdog('mymodule', 'Aid API ERROR ' . $e->getMessage(), array(), WATCHDOG_NOTICE, NULL);
    return array('status' => FALSE, 'message' => $e->getMessage());
  }
}

Update: debug
Getting access denied maybe another module add/alter your menu and add another access arguments then access content so in your callback function print you menu object and see something like :

  $menu_item = menu_get_item('api/json/select/programs');
  // print the menu array
  print_r($menu_item);
  // Print access arguments
  print_r($menu_item['access_arguments']);
  // Print access callback
  print_r($menu_item['access_callback']);


Use the Internationalizations Views module, which extends the i18n module with multilingual support for views.

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

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

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


What is the best way to upload a PDF attachment, that can be attached to multiple nodes?

Two approaches spring to mind. Either you keep using a filefield and use something like FileField Sources to select already uploaded files; or you use a file-as-node idea, and create a content type for PDFs, use nodereferences to attach them to nodes, and use something like Nodereference Explorer for browsing.


how can add external php function or class to theme file?

A .theme file is processed as PHP - anything you can do in a PHP file, you can do in your theme's .theme file.

So if you want a service:

$some_service = \Drupal::service('foo');

Or a function from a module file:

module_load_include('inc', 'foo_module');

And so on.


Create a RSS feed of file attachments to a particular node

You can use Views RSS module for creating complex feeds with Drupal Fields. The module provides a lot of RSS settings:

RSS format plugin “RSS Feed - Fields” with settings
Support for core fields.
Enclosure elements

The result can look like this:


How to create an unsortable Field with multiple values?

I think you'll need to create your own module for this. Instead of using hook_form_alter(), I'd suggest doing things the "cck way". CCK provides hooks which allow modules to provide custom widgets for CCK fields. You can create a module to provide a new Widget option for multi-value fields that doesn't use an HTML table, and doesn't allow for reordering. There's a great article on Lullabot about this. It also talks about creating your own fields and formatters, but you can skip down to the widget part at the end. The sample code is very well documented and should help you understand what's happening. At the very least this will be a great starting point. If something in the article doesn't make sense, feel free to ask for clarifications and I'll add what I can.


Debugging Migrate: how to print what data's mapped to a field

Answer from Mike Ryan: I usually run migrations in drush and, when not stepping through in a
debugger, use drush_print_r(). The key points you want to instrument are
prepareRow() (dump $row to make sure the source data is being pulled
correctly in the first place) and prepare() (dump $node to make sure the
source values are getting properly mapped into the node object that's about
to be saved).


"Unable to generate the derived image located at public://styles/uc_category/public/tg.jpg"

If you are sure this is not a permission issue, also make sure you have a graphical library installed on your server.

In D7, the configuration page for this is: /admin/config/media/image-toolkit


Change the display name of a default field in Contact Form

AFAICT each contact category has its own form ID, which means you can change it with hook_form_alter() in your theme or a custom module. Here's a tutorial about  how to implement it, although there are other resources you can find: Learn how to change an existing Drupal form.

If you wanted to do it without coding then creating a new field and adjusting form and display for each contact category is the way to go.

As Hudri mentioned in a comment you could use Webform for a lot more control, including saving the responses in the database. If you don't need to keep record of the correspondence than Webform is probably an overkill.


Views archive page showing year and months of article content type

you can use calendar module, from module page:

  This module will display any Views date field in calendar formats, including CCK date fields, node created or updated dates, etc. Switch between year, month, and day views. Back and next navigation is provided for all views. Lots of the Calendar functionality comes from the Date module, so any time you update the Calendar module you should be sure you also update to the latest version of the Date module at the same time.

this video is for D7, for D8 is very similar, you can change display format in any view, for example a table and add a special field that you can find ir in views UI under "global" named "views reasult counter"


Go to admin/structure/types/manage//fields
Add new field:

Select field type -> Term reference
Select a widget -> Autocomplete term widget (tagging)

You should now be able to add new terms in node add/edit form via the autocomplete field. You don't need any custom modules. Drupal's core taxonomy module offers this functionality.


How to embed user photo upload form in a page of Drupal 7 site

You can do it like this:

Open node--37.tpl.php
locate the container(div) where should be placed a form and use drupal_get_form() function.

example:

<div class="some-class">
<?php print render(drupal_get_form('MY_FORM_ID')); ?>
</div>


Create a custom view, and add a custom sortable column

You can make a column sortable by clicking on your type of view "fields" and check the "make sortable" checkbox.


Turns out I was going about this the wrong way. I didn't need the "Field Collection Views" module. In views I chose relationships and added "content: the_name_of_my_collection_field" then I could just add the fields to the view like normal.


Filter data using exposed filter using country in drupal 7?

Entities are opened for views to show results. Fields are attached to entities, and with views you can either show the fields or can filter your results with the fields. So, assuming you are trying to make a view of any entity (node,user etc.), you can use the Address field or the Countries module and add the field provided by any of the module to entity you are listing though views.

After adding the field to the entity, the same field will be available in views to be showed or used as exposed filters.


how to add to cart button in drupal 8 commerce?

Wait until alpha3 is released, recreate your site, and use the core Add to Cart functionality on your product pages. Note: as we've been saying for some time, there is no alpha to alpha upgrade path, so you'll have to rebuild the site from scratch each time until we hit beta in late March.


How to best handle "sudo: no tty present and no askpass program specified"?

This may not be solution for everyone, but it worked in my situation because i could change settings at the remote instance. I followed the following instruction and turned on NOPASSWORD, which is adding the following line into sudoers file:

# Members of the admin group may gain root privileges
%admin  ALL=(ALL) ALL

Afterwards, my custom drush commands with sudo works on the remote instance


Create a view which shows related staff members based on taxonomy

I have now got this to work! While I don't fully understand what is going on I thought I'd share it here in case it helps somebody else.

I created a content type 'staff profile' to work with rather than using users. The staff profile content type has the field 'selected job roles' added to it.

In views I made a new view with a display of block. I added a new contextual filter for 'Content: Nid' and set 'when filter is not available' to 'provide default value' and selected the 'content ID from URL' for the type.

Then I added three relationships.

The first was 'Content: Taxonomy terms on node', selecting my vocabulary 'Selected Job Roles' and ticked the 'require this relationship' checkbox.

The second relationship I added was '(term) Taxonomy term: Content using Selected Job Roles' and ticked the 'require this relationship' checkbox.

The third and final relationship I added was the field itself '(field_selected_job_roles) Field: Selected Job Roles'.

I then added a filter criteria 'Content: Type (=Staff Member Profile)' so that only staff member profiles would be displayed.

Now, having done all of this i clicked on the contextual filter for 'Content: Nid' that I set up earlier. I think that because of the relationships that were added there is now an extra option here that was not there before. This new option is a Relationship drop down. I changed this from 'do not use a relationship' to 'field_selected_job_roles'.

The 'auto preview' at the bottom of the page did not return any results when I added an appropriate contextual filter. However going to my test page everything was working correctly!

I would appreciate it if anyone can provide an explanation on why this works. However in the mean time I am just happy to have resolved the issue.


You can do this through theming.

For that you can create a new views-view-field--VIEW_NAME--FIELD_NAME.tpl.php file and write the HTML output for the field.

Dont't forget to clear your cache after adding the file or you can do 'Rescan template files' inside your view.


How to keep  or  tags from getting in WYSIWYG editor with ckeditor?

Use a text filter (format) that allows all tags you want and doesn't allow font and style tags. I also recommend removing toolbar buttons that add these tags, such as font, font color, font size etc. You could add custom styles that add CSS selectors rather than inline style tags.


In your contextual filter settings select "provide default value" -> "user id from url" and it will work.


Drupal 8 Webform URL alias with parameters

You would need to write some custom code to support custom URL parameters. (see How to (truly) alter a URL in Drupal 8)

You could easily pass the 'id' as a query string parameter, which is supported as long as you enable 'Allow elements to be populated using query string parameters.' under a Webform's > Settings > Form Behaviors.


How do I expose display routes from a specific view as REST API?

I actually found a solution which is working for me myself.
$view = Views::getView('categories');

$displays = $view->storage->get('display');

$ret = array();

foreach( $displays as $display){
  array_push($ret, array(
    'title'   => $display['display_title'],
    'path'    => $display['display_options']['path']
  ));
}

return new JsonResponse( $ret );


Problem with storing values in multiple textboxes

When a field is set to Unlimited values, Drupal Services does not yet properly support them. There is an open issue here, and a patch in progress that I've used multiple times to get around this limitation. Grab the latest development version of Drupal Services 7.x-3.x and apply the patch mentioned above, and that should fix it.


How to add a condition based on a line-item's product type in a rules tax component?

I found out how to use product type as a condition - it actually does work the same for rules and rules components.

When I tested this, I was adding the condition "Entity has field": field_product, but in order for the commerce-line-item:commerce-product:type data selector to appear under the Data comparison condition, you have to use the field commerce_product, which is the product reference field used on the line-item entity.


Change jQuery version with hook_form_alter

What you would like to achieve is loading another version of jQery in your form page. You need to understand the way hook system works. hook_js_alter() is defined as:

  "Perform necessary alterations to the JavaScript before it is
  presented on the page."

You can use the above hook to change jQuery version. hook_form_alter() is defined as:

  Perform alterations before a form is rendered.

So, first action is hook_js_alter() and second action is hook_form_alter(). You cannot change jQuery version with the second hook, but you can use the following code.

function mymodule_js_alter(&$javascript) {
  if ($_GET['q'] == "node/add/page") {
     // Swap out jQuery to use an updated version of the library.
  $javascript['misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';
  }
}

For more information on using newer versions of jQuery you can refer the Drupal.org article which explains how to add Newer versions selectively using various methods.


Custom validation for views exposed form using form alter

To form alter a specific view exposed filter form, you need 2 conditions to check: the form id & the form's '#id' element.

function MYMODULE_form_alter(&$form, $form_state, $form_id) {

  // @NOTE: $form['#id'] will vary based on your your view & display machine names.
  // Here the view machine name is 'view' & display machine name is 'display'.
  // Use Devel's dpm() to inspect or the Views administration UI
  // to find your own form's values.

  if ($form_id == 'views_exposed_form') {
    if ($form['#id'] == 'views-exposed-form-view-display') {
      // @TODO: Add form alter code.

    }
  }
}


file_unmanaged functions are allowed to fail on managed items, so when you create folder using '#type' => 'managed_file', they are not the way to go.

drupal_rmdir is only a wrapper around PHP rmdir, and it requires folder to be empty.

It means both solutions you have tried was not able to work.

Correct way is to use EntityFieldQuery to load all files in the folder you want to purge, then use file_delete on them, with $force set to TRUE to remove files that are in use (think twice if that's really what you want to do!). Only when the folder is empty, call drupal_rmdir on it.


Change the value in the user join date field

Old users:  update the users table in your database.  It will be far more efficient.

New users:  https://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_presave/7     I don't think the date/time are saved in that form, so what you could do is find the UID and update the table using a sql query after the save is done.


views query alter not working when view appears in sidebar

I think you problem is there that $nid not passed correctly,edit your views, instead of your filter, set filter by contextual filter then in your page passed it by contextual filter parameter with

$view= views_embed_view('single_job', $display_id = 'block_1', $category);
$view->set_arguments(array($node->nid));
$output = $view->preview();
print $output;

not longer  need query alter function

/*
function bpm_views_query_alter(&$view, &$query) {
  if ($view->name == 'single_job' && $view->display_handler->display->id =='block_1' ){
    $nid = _get_job_nid_from_url();
  $query->where[1]['conditions'][2]['value'] = $nid;
 }
}*/


It sounds like you want PDF to ImageField.

  The PDF To ImageField module provides automatic conversion of uploaded
  PDF files to images. It can be used either to create a snapshot of the
  front page to use as a preview thumbnail, or to generate a gallery of
  images from each page in the document.

  The module is implemented as an additional widget for File Field where
  PDFs are uploaded to. It places generated images into a Image Field on
  the same content type.

That will get you half way there. As for the 2nd requirement of image merging, you'll likely have to implement your own solution via Drupal's node API/hooks to manipulate the converted PDF image with your stamp.


Automatically add class to images added through CKEditor

Ok, I got the answer.

Forget about the simple image plugin. Let's use the default image plugin from CKeditor.

Go to sites/all/modules/ckeditor/ckeditor/plugins/image/dialogs

Open the image.js file in notepad.

Search for c.lang.common.cssClass beside it you should see a "default": "",

So just type your class in between the default quotes.

For Example: "default": "MyCustomClassName",


How to display list of nodes by number in views

You can use the filter operator for regular expressions and this regex:

1|5|9|12|455


This is what I ended up doing, and it works 100%:

    <?php if(array_key_exists('menu_devel', $page['devel'])):?>
        <?php foreach($page['devel']['menu_devel'] as $link):?>
            <?php if(is_array($link) && array_key_exists('#title', $link)):?>

<a href="<?php echo $link['#href'];?>"><?php echo $link['#title'];?>

            <?php endif;?>
        <?php endforeach;?>
    <?php endif;?>


How to redirect the user to a product page (node) after payment is made?

One option is to use hook_menu_alter in a custom module to override your current destination page with a redirect.

<?php

function mymodule_menu_alter(&$items) {

    $items['current/checkout/path'] = array(
        'page callback' => 'drupal_goto',
        'page arguments' => array('new/checkout/path'),
        'access callback' => TRUE,
      );

}

Update:

To use the above code, you'll have to create a module.

1) Create a directory to be used for this module, e.g. /sites/all/modules/MYMODULE

2) Create MYMODULE.info, e.g. /sites/all/modules/MYMODULE/MYMODULE.info. Paste the following into the file.

name = MYMODULE
description = "Module description."
package = Custom
core = 7.x

3) Create MYMODULE.module, e.g. /sites/all/modules/MYMODULE/MYMODULE.module. Paste the following into the file.

<?php

function MYMODULE_menu_alter(&$items) {

    $items['current/checkout/path'] = array(
        'page callback' => 'drupal_goto',
        'page arguments' => array('node/123'),
        'access callback' => TRUE,
      );

}

4) Replace all instances of MYMODULE with your desired module name. Replace current/checkout/path with the current path of the checkout. Replace node/123 with the new checkout path. Lastly, enable your new module.

This will tell Drupal to replace the current checkout page with a redirection to the new one.


Try the xautoload (http://drupal.org/project/xautoload) module to help with autoloading. It's faster and less fragile then the D7 core code registry.

XAutoload implements the PSR-0 standard, which is how Drupal 8 will handle namespaces, so it's the most future proof way.


hook_user_presave at user registration, how to get field_data_field (set to auto increment) to take a new and unique value

Here's what I did in the end...

First I added the field to the user registration form, as one thing Drupal is great at is processing information - I did notice errors being caught so I might have to check that out.

Then I used hook_user_presave() and (managing the unique id creation seperately) passed that, overriding any existing value or adding a value if none existed.

(full details are here: Editing user submission of user registration form with hook_user_insert() and $edit)

I will still have to manage away the users ability to insert an identifier by hiding it through CSS/JavaScript etc. but because hook_form_alter() wouldn't edit the user registration form after repeat attempts this seems the most expedient way of solving the problem.


how to create a view that filters on different fields depending on the content type

You can go to 'Filter Criteria' and hit the triangle next to 'Add'. Select 'and/or, rearange'  and you can change to OR instead of AND as well as add groups.


How to reference URL relative to current page in a block

Adding a relative path (without the starting "/") is WRT the current "directory", so when you're on a node page the "directory" is "node" and the NID is the "page". Your "images" is supposed to be another page within the same "directory". That's the simplified explanations about how relative paths work in general.

To solve your problem the easiest way is probably through a Token. Do you have Token Filter or a similar module installed and configured? If your Text format doesn't evaluate tokens you won't get the correct output.

Try some available tokens in your text and see what they output. Maybe there's a [current:path] or similar token, or [current:nid]. When you find one with the output you like you can contruct the link:

Images

or

Images

If you need more control over the Block Visibility you can try Block Exclude Pages.

Another way to create contextually aware links is through Views (Block display). You would have a Node ID as the contextual filter, and override the Link to content field to add "/images" at the end of it.


How to include desktop css file only on desktop & mobile css file only on mobile?

Yes, you can do this with media queries in your info file.

Change...

stylesheets[all][] = css/style.css

to...

stylesheets[all and (min-width: 960px)][] = css/style.css

That being said, you can repeat a lot of work doing it that way. It might be easier to declare all of your styles that you know will change in a responsive.css style sheet, and use

@media all and (min-width: 768px) { /* all of your styles here */ }

At the bottom to change the values for a mobile version.


How to load a node based on current language?

Try this code:

 $node_trad = node_load($variables["node"]->nid); // in your case, 10.
 $idi_trad = translation_node_get_translations($node_trad->tnid);

  $vars['recipe_side'] = render(node_view(node_load($idi_trad["fr"]->nid)));
  //$vars['recipe_side'] = render(node_view(node_load($idi_trad[$language->language]->nid)));
  // alternative, more dynamical

Essentialy you load the node in original language, use the translation function to get all available translations, and use that what you need.
Instead of "fr" you could use language->language instead to make it completely dynamical.


You can use domain_registration to allow or dissalow emails from certain domains to register.

Setup is very simple as seen from the instructions on the project page

  Install the module
  visit 'admin/config/system/domain_register'
  Choose if you want to only allow, or disallow the domains from registering
  Enter the domain names you wish to allow/deny (one per line) in the format of 'foo.com'. Wildcards are allowed.
  Enter the error message you wish to show to the end user if the email address
  doesn't validate


Avoid caching a JavaScript file when the page cache is on

drupal_page_is_cacheable(FALSE);

Is what you're looking for.


debugging an array while creating custom rule

You can only have a string (not an array) as the second argument to dpm().

Try:

dpm($array, "array: ");


How to set non Drupal 404 and 403 pages for Drupal?

If you want to catch errors not handled by Drupal, you can do this using .htaccess:

ErrorDocument 403 /error403.html
ErrorDocument 404 /error404.html
ErrorDocument 500 /error500.html

However, if you want to intercept the errors handled by Drupal, and redirect that to an standalone error page, you should be able to do this with Redirect 404.


What is the best module for student registration form

Webform module is pretty popular among Drupalers for registration forms. It is quite well supported and documented. It also has many cool in-built features and a few other 3rd party modules that bring in even more sizzle to the mix.

Good-luck to you friend & welcome to drupal.stackexchange.


How to obtain raw View result for Drupal 5?

I think the answer is in here somewhere but I have no way to test it out.

Check out Intro to Views 1 and especially Inserting Views where the views_build_view() function is discussed.  From the discussion there, you should be able to do something like this:

$view = views_get_view('your_view');
$results = views_build_view('items', $view);

with $results now being "An array of objects containing the results of the query."

Now how you theme this is up to you to decipher :)


Very simple but working drush extension?

This is valid for Drush >= 4

<?php
/**
 * @file EXAMPLE.drush.inc
 * Provides a simple drush extension example
 */

function EXAMPLE_drush_command() {
  return array('COMMANDNAME' =>
    array(
      'description' => 'My example command',
      'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
    ),
  );
}

function drush_COMMANDNAME_validate() {
  // Return
  // drush_set_error('MACHINE_NAME_OF_FAIL', dt('Command failed because [reason]'));
  // on error.
}

function drush_COMMANDNAME() {
  echo 'Extension working!';
}


Module's optional field config not imported on install

Optional config is only installed if it has an explicit dependency on a module that is being installed right now. Otherwise that configuration would be re-installed every time you install a module, even if it is something you chose to delete on a specific site.

The downside of that is that there are some grey areas of config that depends on config that depends on a module being installed that isn't found by this. Although that should also work but apparently does not in this case.

As a workaround, you can add an enforced dependency on the paragraphs module on those configurations that aren't being imported, then it should work. See https://www.drupal.org/node/2404447


CCK E-mail field, display e-mail form in js dialog

You can do this with a few lines of JavaScript.

All you need to do is to create a iframe that links the the clicked link and then open it in a dialog. jQuery UI has support for dialogs. There is modules for integrating jQuery UI and upgrading your jQuery version (if needed).

Once that is done, you can add the JavaScript to your theme to create the wanted effect.


Redirect language-specific URL to correct path prefix

Here's the solution that worked for me.

In the end I came to the conclusion that it was easiest to do this at the domain hosting company end.

So in the account where my Spanish-language domain (sitio-web-en-español.com) is managed, I set up a redirect that goes to:

website.com/es

... and it seems to work fine.


Link field to path (automatically pulling Node Id)

Make sure to have the Token module installed.

Then, to be able to use the [nid] token, you'll have to add a Node ID field and move it before the Node name one to be output as link. The nid field you can Exclude from display.

In the node name field then, set custom path to details/[nid].


Duplicate entry/Contraint violation 1062 in file_managed on browser crash

Check whether the file is being used by another part of the system with the file_usage_list()

$file = file_load($fid);
$usage = file_usage_list($file);


The operators "Is one of etc" not working with exposed filters

Expose the filter, then select the fruits that you need to show and then enable the "Limit list to selected items" option, so the dropdown list filter will only show the fruits that you want, not all of them.


How to list most viewed nodes using Statistics module?

I should have enabled this feature in admin panel before using the following code:

$number_of_hot = '10';
$hot_result = db_query_range("SELECT nid FROM {node_counter} ORDER BY totalcount DESC", array(), 0, $number_of_hot);
while ($hotid = db_result($hot_result)) {
$hot = node_load($hotid);
print $hot->title;
}


Styling two views using the same template file?

If your views are same or similar then manage both of views as one using multiple views displays. For each display settings and configuration can be overridden. Template can be shared among displays of a single view.

The other a little bit bad way, can be to create a single template file and then include that template to your views templates.


When creating a content type programmatically, is there a way to add tuples (e.g. pairs) of fields?

The profile2 might fit your bill:

  Profile2 allows for creating multiple profile types, which may be
  assigned to roles via permissions (e.g. a general profile + a customer
  profile)


It seems like you don't really understand what a patch is and how you can use them. You can read about the basics at https://drupal.org/node/620014. Basically, this is a general definition of a patch:

  A "patch file" is a specific kind of file that contains code that is
  used to modify one or more existing files for a Drupal module.

You can use a special program to apply a patch, but I prefer applying them manually. You can find some more detailed information at https://drupal.org/node/534548.

In the patch you refer to, you find for example

+++ simplenews_rules/simplenews_rules.info
@@ -0,0 +1,7 @@
+; $Id$
+name = Simplenews rules
+description = Provides integration with Rules module for Simplenews.
+dependencies[] = simplenews
+dependencies[] = rules
+package = Mail
+core = 6.x

That means you should add the code (without the "+" signs) after @@ -0,0 +1,7 @@ at the top (after the "0th" line) of the simplenews_rules/simplenews_rules.info file. If the file doesn't exist yet, simply create it with your favourite code editor at the mentioned directory. I'm using Notepad++, for example.


With Drupal 7 and Date module 2.2:

$query = new EntityFieldQuery;
$result = $query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'event')
->propertyCondition('status', 1) // Getting published nodes only.
->fieldCondition('field_dates', 'value2', date("Y-m-d"), '<') // end date before today
->execute();


Just like Clive mention....

injecting the module_handlerservice would be preferable to using \Drupal (assuming it's an option in current context)

Here is an example of checking if a module is enabled using a service (without injecting it).
$moduleHandler = \Drupal::service('module_handler');
if ($moduleHandler->moduleExists('devel')) {
  // Code Here
}


Drupal core doesn't support mail attachments/HTML mails.

You need to use an alternative mail implementation, like the Swift Mailer module.

Also, the reason the first implementation doesn't work is because you need to go through a hook_mail() implementation instead. See how core does it.


How to show all nodes and comments by a user in a single view?

This is an example of my setup, just switch out article or content type for your content type or forum posts.

node--article--teaser.html.twig:

    {# other fields #}

    {{ content.field_comments }}

or:

    {{ content }}

As long as the comment field is set to display in your teaser view mode, and printed via your template, the comments will show in the view results.

View Config:

The contextual filter is the important part.

This setup uses content format teaser, the alternative would be using fields. Both will work, with fields you may need a relationship to comments depending on what fields you need available in your view.


Update to Commerce shipping 2.x breaks site with WSOD

The 7.x-2 branch of Commerce Shipping is only in beta, it's not ready for production use yet (but you probably already know that).

The release notes for the branch warn you not to install this on a site that currently uses v1.x of the shipping module:

  Note: If you are currently using Shipping 1.x on a live site, do not attempt an update on your live site. See the roadmap below for more information.

(emphasis theirs, not mine!)

I would heed that warning if I were you :)


Can Pathauto fallback to another pattern if the first pattern yields an empty path?

You can now achieve this using hook_pathauto_pattern_alter().  Something like:

<?php
/**
 * Implements hook_pathauto_pattern_alter().
 */
function mymodule_pathauto_pattern_alter(&$pattern, array $context) {
  // Alter any node entity path patterns we need to
  if (isset($context['data']['node'])) {
    $node = $context['data']['node'];

    switch ($node->type) {
      case 'page':
        // Check condition, and change the pattern when appropriate
        $pattern = '[node:title]';
        break;

    }
  }
?>


How to hide 'Configuration' tab for specific user

This can be done easily without any coding or other modules. Just go to /admin/people/permissions and then uncheck the box titled "Use the administration pages and help" in the System section. The user's with that role will no longer see the configuration link.

Also note that you should make sure all your permissions are set accordingly. Just because you hide the link doesn't mean one who knows the right URLs can't still use the functionality.


Try this:

if ($entity_field_item['value'] != 0)
 {
 $display_output = $entity_field_item['value'] . 'pkt';
 }
 else($display_output = NULL);


How do I get an OG Group Menu block to appear in View?

Resolved my issue, more or less, here: https://www.drupal.org/node/2195889#comment-8493709

First, setting all group views to use this url format: group/%/(title)
Always set group context in hook_views_pre_view() when arg(0) == 'group' and arg(1) is numeric.
3 .Use hook_block_info() to create my own block.
Use hook_block_view() to make my block content equal that generated by og_menu_block_view().
Go into block settings, and set the block to only appear on views = group/%/(title).
Set the block to appear at the same weight (just above or below) as the OG Menu block.

And, voila!  When I click on view from  OG Menu, the OG group menu itself persists.


How to set default value for route parameter based on configured value?

You must implement a route alter. In the alter code, extract the setting and set the value on the route definition.


Path: Home » Administration » Configuration » Regional and language
Or
Path : admin/config/regional/settings

In the above path there will be tab called 'format' where you can create your own custom format where format string is F j, Y, g:i a e.
 Now you can change the date format of the field from the manage displays tab of the admin/structure/types path.
 In the respective field you will have settings options where you can set your custom date format


Rendering Content Multiple Times in a Node

The display of a label is handled by the Field and not the template. The HTML for the field is passed to the template layer from the field API and the label HTML is lumped in with the field information itself. So basically you cannot alter or move the printing of the label in the template layer of theming. Consider the field data and the field label as one item in templating (i.e. $content['field_name'] contains the field data and label as one. Altering the label display (display label or not, inline, etc.) is done in the field display settings for the content type. The only way to alter the label is to do so at the field display level and again it is passed to the template with the field data as a final product.

Rendering content more than once, yes it can be done.


When a link is clicked, a value is retrieved from the table and displayed on a Webform field

Rather do this:

Alter the button link to include a parameter:

Yes

In hook_form_alter, check for the parameter and set the default value(s):

function test_presave_form_alter(&$form, &$form_state, $form_id) {
    // dpm($form_id); // uncomment to get $form_id
    // dpm($form); // uncomment to get $form
    if ($form_id == 'webform_client_form_2') { // use dpm($form_id) to get your form id
        $param = drupal_get_query_parameters();
        if (isset($param['captured']) && $param['captured'] == "true")
        {
            $result = ...
            if ($result) {
                $form['submitted']['room']['#default_value'] = $result; // use dpm($form) to get your room field
            }
        }
    }
}


My advice is to use "MailQ" (For Drupal 7 you can use "Queue Mail" instead) and "Elysia Cron" modules together.

Configure MailQ module to send 50 mails per one batch.

Configure Elysia Cron module to run MailQ cron hook every 15 minutes.
(note you need configure you cron job to run every 5 minutes or even often, more details in Elysia Cron readme.txt)

In this case MailQ will send 50 emails each 15 minutes - and you will got no more than 200 emails per hour.


If there is no field permission module installed, all fields are always visible. So if you don't want to restrict any fields, then disable the content permissions module.

Once such a module is installed, it works as implemented by that module. And there is no way for such a module to guess the permissions you want (should it be visible to auth users only, or anon users too.. maybe only a specific role?), so it can only chose the safe way and does not grant anything automatically.

That is consistent with all other permissions, when you install a new module.


How to allow each company section to manage their own content on the Intranet?

The thing you are looking for is Organic groups. It does exactly what you need.
Further more you may be interested in some solutions already made on drupal. Like Open Atrium or Drupal Commons

Hope it helps.


I didn't test the code. But you can use this code.

$page = 1;
$view = views_get_view('payment_schedule_students');
$view->set_display('payment_schedule_students_select');
$view->set_current_page($page);
$view->execute();$view->result;

Where you can set the $page variable from the url.


Why does field_get_items() sometimes return "blank"

Reading the function's source code it seems that the only way to return 'blank' is when the field's value for the selected langcode is actually 'blank':

https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_get_items/7

I suggest you to use XDdebug to check the node_object value just before this function is called. You can also use a dirty-and-quick trick: edit the code function and add a dpm (but remember to revert it!). But with XDebug you really can see where that 'blank' value comes from.


Search api solr deleted terms showing up in facet

Filter by that facet and check the nodes that display, they probably still reference the deleted term (see issue: Database records not deleted for Term Reference Fields after Term is Deleted)

To get rid of it, edit the nodes and remove the term reference, either manually or programatically depending on the volume.  Then reindex your content.


Are all updates (revisions) to a user recorded in the logs?

Unfortunately not: Changes to a user are not logged (even though newly created users are), and the user entity does not support revisions in core (as of Drupal 8.4.2).

You could add an extra submission function with hook_form_user_form_alter() that creates a log message.


User registration form throws validation errors on already unset profiles´ fields

The Profile2 Registration Path module  solves the issue!

  This module enables administrators to set unique registration paths per Profile2 profile type.


How to rewrite paths delivered by solr search (to view instead of node)

If you're using Apache Solr Views, or Search API Solr Search with Views, you can re-write the field in the usual Views way. Otherwise, you may need to fiddle with the search result template in your theme, which I realize is ugly.

A better choice would be to override the node display entirely, for example using Panels and creating a Page at node/% that overrides all node display for the appropriate content types. You can then customize the presentation of your nodes using Views that take the current node ID as an argument. This sort of thing is also possible using Display Suite, although that's a more complex solution. If you really always want people to see your node as presented by a View, you may as well solve this directly instead of by tweaking the search results.


Add a composer.json file to your movies module & name it your custom module's name:

{
  "name": "drupal/movies",
  "type": "drupal-module",
  "license": "GPL-2.0+",
  "require": {
    "imdbphp/imdbphp": "*"
  }
}

Add a new line to the merge-plugin include array in the composer.json of your Drupal ROOT with your module's composer file path:

"extra": {
  "merge-plugin": {
    "include": [
        "core/composer.json",
        "modules/custom/movies/composer.json"
    ]
  }
}

Enable the movies module
Run composer update & composer dumpauto in Drupal ROOT. This will install & autoload the new dependencies in your vendor directory.
Now you can use the classes provided by this library. In your case for example:

$title = new \Imdb\Title(335266);


How do I prevent a menu item from appearing?

I deleted the menu item in question, and then I re-created it.

I could see the menu item when logged on as my self.  I could NOT see the menu item when logged on as the user in question.

Deleting the menu item and re-creating it caused my issue to go away.


Like the Commerce docs say, you need to install it like any other Drupal 8 site. So, it is easier to use the composer command.

composer create-project drupalcommerce/project-base MYNEWSITE --stability dev

Where MYNEWSITE is the new Drupal 8 w Commerce 2 directory. You can do this anywhere on the host machine (ex. I always have them in /Sites).

From here, you can add Drupal VM to the project and tailor the config.yml to your needs, then vagrant up - just like you did with the vanilla Drupal 8 site you already installed. You should see the Commerce install screen.

There is likely a way to automate this with DrupalVM, though I have not tried that approach.


D7: filter fields in content type based on selected taxonomy terms

You could make use of Conditional Fields module

  Conditional Fields allows you to manage sets of dependencies between
  fields. When a field is “dependent”, it will only be available for
  editing and displayed if the state of the “dependee” field matches the
  right condition.


As per the error message, no such index 'entity' exists in the array $value->field_field_screenshot[0]['rendered'] Do a dpm($value->field_field_screenshot[0]['rendered']) when both logged in and logged out and you will see the difference.

Is field_screenshot associated with a user account or profile? In which case, the anonymous user object has no such field, so you're trying to assign to $collect_field something that doesn't exist. You should assert whether the user is logged in or not before doing the assignment.


More information would be more helpful to answering this question. I have no idea what file/function you have put this code into, if you have in your module any of the other hooks necessary to display a block or what your actual end-goal is here (are you printing a form in a block created by another module?). However, this code doesn't seem to correlate to any of the hooks necessary for creating a block within a module in Drupal 6.

You should take a look at the Examples for Developers module and its examples of a module that creates a block and a module that creates a form. By following those examples, you should be able to easily build a module that will create a form and a custom block that outputs that form.


I use the patch method mentioned on https://www.drupal.org/docs/develop/using-composer/using-drupals-composer-scaffold#toc_4

e.g:

"name": "my/project",
...
"scripts": {
  "post-drupal-scaffold-cmd": [
    "cd docroot && patch -p1 <../patches/htaccess-ssl.patch"
  ]
}

Then if the core file changes it will either merge correctly or the patch will fail and you'll see that in your composer command and can make the relevant changes to your patch


Get all available permission after NodeType delete - Drupal 8

You are using the wrong hooks. I am not sure what your objective is, but you want hook_ENTITY_BUNDLE_delete I believe:

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_entity_bundle_delete/8.6.x

function mymodule_entity_bundle_delete($entity_type_id, $entity) : void
{
    if ($entity_type_id == 'node' && $bundle == 'node type to check') {
        $permissions = array_keys(\Drupal::service('user.permissions')->getPermissions());

        foreach ($permissions as $permission) {
        // somestuff -> updating database permission table
        }
     }
}

I don't know if you care to check $bundle or not, but if you delete any node type, this code should fire.


Cannot translate a content type "The configuration objects have different language codes so they cannot be translated"

Export the configuration:

drush cex

then change the langcode in sites/default/files/config_HASH/sync and import the configuration again:

drush cim

Look for all non english langcodes that are in the base sync folder (or non default langcode, if you have another default language).


How to set defined image weight in Drupal

If you've set the quality to 100% it's likely that that is why it's resulting in a larger file size. You may be setting it to a higher quality compression than the original photo had. You should try to find a balance between compression quality and image size that results in page load speeds you find preferable. However, if there aren't multiple images on this page, that might be an okay file size.


video-play-html5.tpl is primarily for the HTML5 player. Are you using JW Player with this template? I think you should use the JW Player module to use JW Player. Using preprocess functions you may be able to change the overlay path.


How to build Druapl 7 bilingual website?

The Internationalization (i18n) module is good, Here is an excellent tutorial.

It's fairly robust, so I imagine it supports LTR script.


How to translate contact message field labels

Standard fields of a contact form are predefined in code. Custom fields are in configuration and the translation works differently.

This should work:

Enable the module "Configuration translation"
/admin/structure/contact/manage/feedback/fields
Add field
Enter an english label
Configure the field type
Choose Tab "Translate contact message fields"
Add a translation in another language
Enter a translated label


Run hook_nodeapi("pre save") but only on inserts, not on updates

You can know if it an update or insert by looking the $node->nid value. If you've a number it's an update otherwise an insert.

You can see an example directly on the documentation.


Answering my own question. I was missing something.

Boost is a bit more fussy about the URL than the rest of drush when clearing the cache

drush --uri=http://my.site.name cc all

will work.


In Drupal 7 you can use hook_quicktabs_alter

    /**
     * Implementing hook_quicktabs_alter
     * @param type $quicktabs
     */
    function MODULE_NAME_quicktabs_alter(&$quicktabs) {
        global $user;
        foreach ($quicktabs->tabs as $key => $tab) {
            if ($tab['title'] == 'Tab1' && arg(0) == 'user' && is_numeric(arg(1)) && $user->uid == arg(1)) {//check condition as per your requirement
                unset($quicktabs->tabs[$key]);
            }
        }
    }


How can I have a new dropdown for each entity reference added?

I would look into the Chosen and/or Select 2 modules. They both work to improve UX for select fields.
I've used the Chosen module multiple times in the past, so that's where I'd lean here. The module improves the UX for users managing multiple selections on a select field. The chosen library alters the UI to allow users to easily select multiple options - it even provides autocomplete functionality to limit the results of the select field.


Replacing menu link text with image: overriding the right function?

Consider using hook_preprocess_link().

Here's a snippet:

/**
 * Implements hook_preprocess_link().
 */
function example_preprocess_link(&$variables) {
  if ($variables['path'] == 'path/of/link/to/change') {
    $variables['options']['attributes']['class'][] = 'class-use-image';
  }
}

Then in your CSS file, define the class that replaces the text with the image:

.class-use-image {
  width: 350px;
  height: 75px;
  background: url("images/<your-iamge>");
  text-indent: -9999px;
}

More techniques on replacing text with image here.