Creating programatically a node that has a programtically created image field that should stay empty

I think this is already been covered here some where but i'll answer this any way because creating fields manually is not something easy.

Let's start:
1. First thing - create the field through the UI
2. Export the fields with features. In the latest version of features, features devide the export to to diffrent things: file with all the fileds settings and a file with all the field instances. From the settings of the field that features create you need only the settings: cardinality, field name, module and settings. From the instance you will need the settings: label, required and the widget. You can save them to a function.

After you saved the settings you will need to use a couple of functions for next you will install your module or anything like this: field_info_field(), this function will let return you the settings of the field if he exists, if not you will need to create it with the function field_create_field() like this:

field_create_field($field_config);

The argument you'll need to give her is the settings of the field you saved later. For attaching the field to an entity you'll need to use the function field_create_instance that get the instance settings you save with three more keys:

field_name - the name of the field
bundle - node type, message type etc. etc,
entity_type - the entity type: node, comment, message etc. etc.

You can see here hot it's done:

// This is the instance settings you saved.
$instance;
$instance += array(
  'field_name' => $field_config['field_name'],
  'bundle' => 'article',
  'entity_type' => 'node',
);

field_create_instance($instance);

You can have a look in the module OG in the function og_create_field() and how he saved fields inside hook. This could very easy and other module you will wrote can be based on this if you have a very a lot of fields.


How to set available options for Comment Per Page select?

Comments per page options are taken from _comment_per_page function and as you can see, are hardcoded:

function _comment_per_page() {
  return drupal_map_assoc(array(10, 30, 50, 70, 90, 150, 200, 250, 300));
}

To substitute this with your own function, you need to implement hook_form_alter, and override changes made by comment_form_node_type_form_alter. Specifically, you need to change $form['comment']['comment_default_per_page']['#options'] and make sure $form['comment']['comment_default_per_page']['#default_value'] makes sense after that change.

To make sure your hook fires after the one by comment module, see Can I change the order in which hook implementation by different modules are called?


How to increase delta value of a multiple valued field +1?

It depends upon what you're planning to do with that delta. Here's a possible solution for you:

Use Aggregation on the view and use "max" for the delta.  Hide the field and then do a math operation to add +1 to the value of the delta.

If you could expound on the "why" it would help.


Create a node Automatically when a commerce order is completed

Yes, its time to create a module, and use these nice hooks Commerce API is offering to interfere to the regular execution of things in your Drupal site.

After getting the big picture, creating a node will be as easy as this first script.
So in a hook which is invoked whenever an order is complete, you would add the node creation code.


Access webform by checking predefined codes

You can create a custom module with a hook_webform_access() callback that looks for authorizations codes.

The below hook grants access to the default Contact form via /form/contact?code=secretcode. Make sure to go to /admin/structure/webform/manage/contact/access and remove 'Create submissions' access to the Contact form.

/**
 * Implements hook_webform_access().
 */
function CUSTOM_MODULE_webform_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) {
  // List of webform ids and authorization codes.
  $webform_authorization_codes = [
    'contact' => 'secretcode',
  ];

  // Get the current webform.
  /** @var \Drupal\webform\WebformRequestInterface $request_handler */
  $request_handler = \Drupal::service('webform.request');
  $webform = $request_handler->getCurrentWebform();
  if (!$webform) {
    return \Drupal\Core\Access\AccessResult::neutral();
  }

  // Get the webform id.
  $webform_id = $webform->id();
  if (!isset($webform_authorization_codes[$webform_id])) {
    return \Drupal\Core\Access\AccessResult::neutral();
  }

  // Get get the code.
  $code = \Drupal::request()->get('code');
  if (empty($code)) {
    return \Drupal\Core\Access\AccessResult::neutral();
  }

  // If 'submission_page' (aka create) and authorization code is correct,
  // then grant access.
  if ($operation === 'submission_page' && $code === $webform_authorization_codes[$webform_id]) {
    return \Drupal\Core\Access\AccessResult::allowed();
  }
  else {
    return \Drupal\Core\Access\AccessResult::neutral();
  }
}


How to display a field when a media is uploaded to the media library field?

I did with javascript because the field type media_library is not an actual input field.
I overrided the setMediaUploadFieldValue jQuery function of the media_library_form_element module.
(($, Drupal) => {
  Drupal.behaviors.VideoComponent = {
    attach: () => {
      $.fn.setMediaUploadFieldValue = (data, element) => {
        const mediaElement = document.querySelector(element);
        const currentValue = mediaElement.value;

        mediaElement.value = `${currentValue}${
          currentValue === "" ? "" : ","
        }${data}`;

        try {
          fetch(`${my_url}`)
            .then(response => response.json())
            .then(result => {
              if (result) {
                // Do something
              }
            });
        } catch (error) {
          return false;
        }
      };
    }
  };
})(jQuery, Drupal);


Display custom user profile field as name in articles

You can use the Realname module to override the display name with the values of one or more fields:

  The RealName module allows the administrator to choose fields from the
  user profile that will be used to add a "real name" element (method)
  to a user object. Hook_user is used to automatically add this to any
  user object that is loaded. It will also optionally set all nodes and
  comments to show this name.


Disable select drop-downs, display names only

As of date_popup 7.x-2.9, you can do this in your theme or custom module, implementing hook_element_info_alter(&$type).

function mytheme_element_info_alter(&$type) {
  $type['date_popup']['#datepicker_options'] += array(
    'changeMonth' => FALSE,
    'changeYear' => FALSE,
  );
}


How do I make a custom entity update or create automatically update the solr index?

Originally I thought I had to implement my own hooks but after seeing that apachesolr took care of deletes I wondered why it hadn't taken care of my updates and inserts.

There is actually a apachesolr_entity_update/insert() which calls apachesolr_entity_should_index(). That checks whether your entity info (returned by entity_get_info($entity_type)) has the following key set:

$info['bundles'][$bundle]['apachesolr']['index']

Where $bundle is the $entity bundle. This made it pretty easy for me to figure out that I just had to add some stuff to my hook_entity_info_alter():

function my_entity_entity_info_alter(&$entity_info) {
  foreach (my_entity_get_types() as $type => $info) {
    $entity_info['my_entity']['bundles'][$type] = array(
      'apachesolr' => array('index' => TRUE),
    );
  }
}

After adding that and clearing cache I no longer needed my entity update/insert hooks.

Note: Don't get this confused with hook_apachesolr_entity_info_alter like I did!

Original Answer

I found the function apachesolr_index_get_entities_to_index() which checks the indexer table for your entity_type for a changed timestamp that's greater than what it's last seen (I have yet to find out where it sets that). Essentially we just need to automate the updating of that table. This can be done with 2 hooks:

hook_entity_insert()
hook_entity_update()

/**
 * Implements hook_entity_insert().
 */
function my_entity_entity_insert($entity, $type) {
  // Update our indexer table
  if ($type != 'my_entity') {
    return;
  }
  $indexer_table = apachesolr_get_indexer_table($type);

 // Insert the new entity into a fictional table of all entities.
  $info = entity_get_info($type);
  list($id) = entity_extract_ids($type, $entity);
  db_insert($indexer_table)->fields(array(
    'entity_type' => $type,
    'bundle' => $entity->type,
    'entity_id' => $id,
    'changed' => REQUEST_TIME,
  ))->execute();
}

/**
 * Implements hook_entity_update().
 */
function my_entity_entity_update($entity, $type) {
  // Update our indexer table
  if ($type != 'my_entity') {
    return;
  }
  $indexer_table = apachesolr_get_indexer_table($type);

  db_update($indexer_table)
    ->fields(array(
      'changed' => REQUEST_TIME,
    ))
  ->condition('entity_id', $entity->entity_id)
  ->execute();
}

You may have to add this line into the insert statement in hook_entity_insert() if you have a status coming from $entity (mine is always 1 so the db table defaults it to that).

'status' => $entity->status,

Edit: You may be wondering "What about delete??", this seems to be taken care of by  apachesolr_entity_delete, I'm going to see why  apachesolr_entity_update and  apachesolr_entity_insert didn't take care of my entities. However this answer is still valid.


Ok. It's resolved. I cleared the browsers cache in Safari under: Preferences/Privacy/Manage Website Data and there I searched for my site name, selected it and hit "remove all". Therefore I presume it was my Safari browser's cache.


Unable to use rules to update field after the first update

The issue appeared to be that the 'last updated time' field was updating only in 15 minute increments. Though I'm still not sure why it is in 15 minutes increments or how to turn that off.


How can i enable automatic path creating for all nodes?

If you have Pathauto installed, it will generate path aliases for your nodes. It unchecks the box when there's already a path alias, letting you know that it won't change the alias if you change the content. You can change this behavior with the 'Update action' setting here: /admin/config/search/path/settings


Determine conditions for Rules when changing field value

You need to create the rule for Before saving content rather than After saving content.

Before saving content has both the original node values and the new updated values which allows you to compare the values.

After saving content only has the updated values, so you won't be able to see what the old values are.


Show child pages in parent node view details in a book

I managed to find a solution. I would like to post it here if somebody looking for similar solutions.

Make a view for the parent page with all needed configurations. In my case, I have the main chapter page as the parent, the content type is 'chapter'. And when I see the view in a page I want to see all subchapters coming under it. The further steps are followed:

Browse to /admin/structure/views and click on "Add view".
Enter a view  name, Select content type from view settings
Check the "Create a block" checkbox only. Then click on
"Save & edit".
On the right-hand side, click on "Advanced" so that the advanced
menu appears.
Click on "add" next to "Relationships" to add a relationship.
Select "1st parent" (the parent book node) and click on "Apply and
configure relationships".
Check the "Require this relationship" checkbox and click on "Apply".
Click on "add" next to "Contextual filters" to add a contextual
filter.
Select "ID" (The node ID) and click on "Add and configure contextual
filters". Choose relationship to "Book 1st Parent"
In the "when the filter value is not available" section, select
 "Provide default value" and in the "Type" drop-down menu, select
 "Content ID from URL"
click on "Apply" & Save the view
Place the just created block in the page by visiting structure >
 block layout


How to avoid "header already sent" warning when loading a pdf

So, this question is very specific. The problem of 'headers already sent' warning is common, and each situation is specific, but here...

I don't need to send header-content-pdf, it is redundant, because the stream method of dompdf object sent it. So I had to erase this line.

Secondly, the most important thing is that: My code is in a page callback function, which is executed by drupal at a moment of the page generation process. After a page callback function is executed, the http headers are not sent yet, it is the job of the delivery callback function which is by default drupal_deliver_html_page. We can override this default behavior by adding in the hook_menu item the delivery callback property:

  "delivery callback": The function to call to package the result of the page callback function and send it to the browser. Defaults to drupal_deliver_html_page() unless a value is inherited from a parent menu item. Note that this function is called even if the access checks fail, so any custom delivery callback function should take that into account. See drupal_deliver_html_page() for an example.

Implementing our custom delivery callback function should work... But I didn't try it... Because, in my research, i found this function: drupal_exit()

  Performs end-of-request tasks.
  In some cases page requests need to end without calling drupal_page_footer(). In these cases, call drupal_exit() instead. There should rarely be a reason to call exit instead of drupal_exit();

But here, for me there is a reason to end the request roughly: The stream method of the dompdf object render the page as i want, ie a pdf page. So to be clear, here is my new code:

function invoices_callback($var){
require_once('sites/all/libraries/dompdf/dompdf_config.inc.php');

$filename = 'Invoice n°' . $var . '.pdf';
$dompdf = new DOMPDF();
$dompdf->load_html('
Test n° : ' . $var . '
');
$dompdf->render();
$dompdf->stream($filename, array('Attachment'=>0));
drupal_exit();

}

The stream method sends the http header and renders the page, we don't need anything else, so we exit. It takes me a lot of time, i know how drupal generates a page now. Hope this helps.


CKeditor + Media: insert image tag rather than link to image

Insert Module will do that, it will place the image in body field. Support for all major WYSIWYG editors, including tinyMCE, CKeditor.

  Insert is a utility that makes inserting images and links to files
  into text areas or WYSIWYGs much easier. It adds a simple
  JavaScript-based button to FileField and ImageField widgets. When used
  with ImageField and ImageCache, images may be inserted into text areas
  with a specific ImageCache preset.


How do I create a site inside another one?

It's possible, but usually not really recommended solution - as we have subdomains/multisites in Drupal.

But basicly only thing that will probably need small adjustments is .htaccess,
make sure to edit RewriteBase variable. Check out these links:

Same/Similar topics here:

How to get Drupal 7 installed in a sub-folder / sub-directory properly?

https://stackoverflow.com/questions/4122488/a-drupal-site-inside-another-drupal-subdirectory

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

Configuring .htaccess to ignore specific subfolders: https://www.drupal.org/node/30334

https://stackoverflow.com/questions/2718406/how-to-exclude-a-folder-on-drupal-site-so-that-drupal-does-not-recognise-it-its

Also if You decide to go for multisite -> read this one: https://www.drupal.org/docs/7/multisite-drupal/multi-site-in-subdirectories

Hope this will help You :) Good luck!


As you mentioned in the comments you field is multivalue field so you should loop over it and render the item inside
 tag something like the following:

      <?php foreach ($content['field_link'] as $key => $link):?>
      <?php if (is_numeric($key)): ?>

 <?php print render($link) ?>

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


How do I print the node title from the object?

Are you in a twig template rendering a node? If so:

{{ label }} or {{ node.label }}

Via code in PHP:

$node->label(); via label() and/or also $node->getTitle(); via getTitle()


Try using User Points modules to manage the points, which has a very good API to integrate with custom modules.

Read this also User Points Contributed modules


Aegir no longer seems to be adding SSL info to apache config files for sites

Is there any particular reason why you're using the legacy option, and not Aegir HTTPS?

The legacy option is no longer supported so my recommendation would be to follow the documentation to switch.


How to stop the book module defaulting to IE7 standards mode?

I suspect you may have visited the book page in IE, and selected compatibility mode once, and it is now being remembered.  Another possibility is that you have an internet zone rule (probably an intranet rule) that is forcing compatibility mode on.  Your IT department may be forcing this via a policy, too.

I have had some problems with just using the meta in the header of a page, and have been using this:

/**
 * Implements hook_html_head_alter().
 */
function MYTHEME_head_alter(&$head_elements) {
  // disable IE compatability mode
  // see http://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx

  $head_elements['x_ua_compatible'] = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
      'name' => 'X-UA-Compatible',
      'content' => 'IE=Edge,chrome=1',
    ),
  );

  $head_elements['x_ua_compatible']['#attached']['drupal_add_http_header'][] =
    array('X-UA-Compatible', $head_elements['x_ua_compatible']['#attributes']['content']);
}

This adds the meta, so you can see it when you do a view source, and it also adds a proper HTTP header to disable it.

Just note that if this is being enforced via policy or IE settings, you may not be able to override it.


Creating a "tag blacklist" for users on a view

I guess using the ER field on user profiles is the easiest way, it all depends on your requirements.

If you need users to interactively "mark" tags on tags pages or through some other places you could use Flag modules and let them flag tags to blacklist them by simply clicking on the "Blacklist" flag link.

Either way you can build Views that show only content that hasn't been tagged with those.

Add the Contextual filter for the Blacklisted ER field (Default value...) then under More check the Exclude. This way your list will not show any content that has blacklisted tags.

Of course, your Contextual needs to be configured properly but there are many answers here you can find with all the options listed.

Flags views take some more steps to configure but the logic is the same.


The latest stable version of Search API module (7.x-1.20) has a known bug when showing the SQL query that is performed. You will have to apply the patch that appears on that issue or upgrade to the latest development version.

Take into account that even when patch is applied, the information that will appear on Views UI will not be the raw SQL query itself. Instead, you will have the properties of a SelectQueryInterface element:

Index: test_search_api_index_node_index
Keys: 'university'
Parsed keys: array (
    '#conjunction' => 'OR',
    0 => 'university',
)
Searched fields: field_test_1, ...
Filters:
status = '1'
Options: array (
    'parse mode' => 'single',
    'conjunction' => 'OR',
    'filter class' => 'SearchApiQueryFilter',
    'search id' => 'search_api_views:test_view_search:test_search_page',
)

In order to get the raw SQL query, you will have to implement a custom module that alters the Search API query and use a debug tool like Devel module.

/**
 * Implements hook_search_api_db_query_alter().
*/
function yourmodule_search_api_db_query_alter(SelectQueryInterface &$db_query, SearchApiQueryInterface $query) {
  dsm($db_query, 'The SelectQueryInterface element');
  dsm((string) $db_query,'The raw SQL query with tokens');
  // Below I am changing the way Search API performs this search.
  $conditions =& $db_query->conditions();
  if (isset($conditions[0]) && is_string($conditions[0]['field']) && $conditions[0]['field'] == 'word') {
    $conditions[0]['operator'] = 'LIKE';
    $conditions[0]['value'][0] = '%' . $conditions[0]['value'][0] . '%';
  }
}

When printed, you will see the query has some token strings. Those tokens are the same that Views UI has printed above:

The raw SQL query with tokens =>
SELECT t.item_id AS item_id, SUM(score) AS score
FROM {search_api_db_test_search_api_index_node_index_text} t
LEFT OUTER JOIN {search_api_db_test_search_api_index_node_index} t_2 ON t.item_id = t_2.item_id
WHERE  (word LIKE :db_condition_placeholder_0 ESCAPE '\\') AND (field_name IN  (:db_condition_placeholder_1, :db_condition_placeholder_2, ...)) AND(( (t_2.status = :db_condition_placeholder_12) ))
GROUP BY t.item_id

I hope this helps you.


Put the following code into a custom module.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'bid_offer_node_form') {
    $form['actions']['submit']['#value'] = t('Make Bid Offer');
  }
}

or

function mymodule_form_bid_offer_node_form_alter(&$form, &$form_state, $form_id) {
    $form['actions']['submit']['#value'] = t('Make Bid Offer');
}

To change the URL, you can just set a path alias and alias node/add/bid-offer to make-offer or whatever you fancy should you need to.

Just for reference:

hook_form_alter()

hook_form_FORM_ID_alter()

EDIT

Following on from your comment, please try the following code (I've used it recently so I know it works):

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'bid_offer_node_form') {
    drupal_set_title(t('Make Offer'));
    $form['actions']['submit']['#value'] = t('Make Bid Offer');
  }
}

or

function mymodule_form_bid_offer_node_form_alter(&$form, &$form_state, $form_id) {
    drupal_set_title(t('Make Offer'));
    $form['actions']['submit']['#value'] = t('Make Bid Offer');
}

Reference:

drupal_set_title()


The condition for the 2 fields sort criteria

The problem has been solved using the Better Exposed Filters module.

  The Better Exposed Filters module replaces the Views' default single- or multi-select boxes with radio buttons or checkboxes, respectively. Description fields and Select All/None links can be added to exposed filters to make for a better user experience.


Where do i enable caching for drupal 7 panels data for Logged in Authenticated users?

You can enable Panels caching on a per-panel-pane basis.

Edit the panel pane and set the "Cache" configuration there.

You can also create your own cache plugins via the ctools plugin API.


Should I use content-types or database abstraction layer?

Reasons you should go with content type.

Its is what you get out of box from drupal, content type are built on drupal entity concept,lot of api's are exposed to alter the default workflow in case needed,internally it does the same that you can do with custom tables,a lot of contributed modules are there to extend the functionality.
If you are planning to have custom tables then you have to write codes at each point of three layers -tables creation, data insertion/updation, data view,while using content type you can get it done by drupal core and by using some of contributed modules for example to show different data you can use views.

Following modules can be helpfull for the functionalities listed above.

views.
entityreference

Things you need to plan
Try to categorize the listed  (Estate, property, charge, owner, payment) into entities and their properties for example charge might not be a separate entity instead it might be a property(field) of property(content type). So roughly you can have Estate,property as content type. Once you install entityreference module, it will allow you to setup reference from property to estate using reference field(provided by entity reference module).So setting up reference you can establish relationship of what property nodes belong to what estate nodes.Charge can simply a field on property content type, so it will show charge/cost for a property node.Owner can be nodes or if you allow login to owner you can make theme drupal users as well.Again you can setup by relationship between property and owner using reference field in both ways keeping it as users or as node.

I hope this might be helpful in starting,Merry Christmas :)


How to remove JS from a page during preprocess D7

You can try hook_js_alter and remove it from there:

module_hook_js_alter(&$data) {
  dpm($data);
  unset($data['script']);
  dpm($data);
}


Cache sometimes is not being updated on saving operations

Try Expire module  instead you try to clear cache manually.

  This module provides configurable actions upon events that will expire
  URLs from caches like reverse proxy caches, internal page caches,
  etc.This module make more sense when Minimum Cache Lifetime setting is
  set to a value other than none.

  There is now integration with the following modules:

Boost - deletes expired pages (files) from the file system.
Varnish - integrates over an administrative socket.
Fastly - Varnish/CDN caching
Purge - expires urls by sending purge requests to Varnish, Squid and Nginx over HTTP.
Acquia Purge - allows Drupal sites hosted on Acquia Cloud to automatically purge pages from their Varnish powered load balancers..
Memcache Storage - allows to delete pages that were cached in a memcached instances.
Akamai - provides an integration with the Akamai Cache Control Utility (CCU) Web Service
Recacher - Page cache warmer.

and Memchache Storage mdoule

Features

This module is an alternative to Memcache API and Integration module focused on different set of features. Available features (D7):

    You can move all cache to the memory.
    You can move users' sessions to the memory.
    You can move lock system to the memory.
    Module can store cached pages for anonymous users as a plain text, so proxy servers (like Nginx with enabled ngx_http_memcached) can get such pages directly from memcached pool and avoid heavy requests to the backend.
    You can clear data from single cache bin, cache cluster or flush all cached data from Drupal UI (screenshot).
    You can find helpful nice debug output (screenshot).
    Integration with Drush
    Integration with Administration menu. Module provides link for flushing memcached data from navigation toolbar.
    Active development and support.


How to add dynamic fields with condition?

I would recommend you to use any one of following modules.

Hierarchical Select

  This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.

Simple hierarchical select

  Simple hierarchical select defines a new form widget for taxonomy fields to select a term by "browsing" through the vocabularies hierarchy.

Taxonomy Term Reference Tree Widget

  This module provides an expandable tree widget for the Taxonomy Term Reference field in Drupal 7. This widget is intended to serve as a replacement for Drupal's core Taxonomy Term Reference widget, which is a flat list of radio buttons or checkboxes and not necessarily fit for medium to large taxonomy trees.


Display Suite View Only Showing Default Display

It was caused by a conflict with View Role Per Node Module
Even though I did not have any node views assigned based on role, it still seemed to be interfering with the Display Suite behavior.


Better way to manually load a view of nodes other than with "views_get_view_result" > "node_load"?

Since you need to load all of the nodes on your front page, Not that much difference does it make how you implement it, whether using code or loading View in a page or block or ....

views_embed_view do the same thing and loads a View but it doesn't reduce the load size!

I recommend you to to use Ajax. The Views Load More module is exatcly what you need. This module

Provide ajax/no-ajax views load more
Works with views default ajax implementation, no hacks (check/uncheck ajax)
Supports the Waypoints module for loading on various points, Such as when the scroller is visable on the page.
Supports the Fade effect when loading new content.

Instead of loading all of your content, simply just load 100 or 200 of them then use Ajax to load more.

Views Show More module is another solution. This module

Works both views ajax and no-ajax mode (developed mainly for the ajax mode).
Option for result display method. Can choose Append or Replace method.
Option to override 1st page or initial item count than others page.
Basic and advance animation system for result impression for ajax mode.
Ability to define custom animation timing.
Advance settings for content area and pager area selector. If default html

In the aggregate, create a View of all of the content types that their nodes must be included in the front page, include that view in the front page and use one of the above modules to use load more.


You can use php filter, or install Token Filter module and then enable tokens in filter which you use (admin/config/content/formats). Token for front page is [site:url] so you should write your link like follow:

[title]


How to write custom Form API elements for Drupal 7?

Searching Google for "hook_element_info tutorial" brings up Create custom Form API elements with hook_element_info() in Drupal 7.

There is also the Examples for Developers project, which is included in the documentation at http://api.drupal.org. The Form API Example module implements hook_element_info() and contains a number of example elements in the form_example_elements.inc file.


I cannot specify sender's address when sending email through rules

Jeeeez, it was just the configuration of the mail server on my local development machine... Everything worked as it should on the drupal side.


Drupal private file system and possible sharing options

Private filesystem allows Drupal to run permission checks before serving the requested file.

If you are using public file system, direct links to your files will be accessible to anyone, no matter they are logged in users or anonymous.

Regarding your questions:

  If i want let only user that uploaded file have access to the file, which setting should i choose, and what are drawbacks?

You should choose private filesystem. Drawbacks are explained above.

  Moreover, could if i choose private system, could i control access by module (for exaple User relationships module, so the friends of user could download the file)

Check out hook_file_download() - you can use it in a custom module to perform custom access checks.

Also, see this thread.


Post/redirect form to url of node selected

You need to set the selected node's URL as the confirmation URLs token.

Here is an example webform that redirects to the select node when submitted.


How to determine if request will result in a successful HTTP request?

When I was developing the code for Nodewords, I used the following code, to verify if Drupal was serving an error page:

  $headers = drupal_get_headers();

  if (preg_match('@HTTP/1\.[01]\x20+403@', $headers)) {
    return array('type' => NODEWORDS_TYPE_ERRORPAGE, 'id' => 403);
  }

  if (preg_match('@HTTP/1\.[01]\x20+404@', $headers)) {
    return array('type' => NODEWORDS_TYPE_ERRORPAGE, 'id' => 404);
  }

The function containing that code is called from nodewords_preprocess_page(), the implementation of hook_preprocess_page().


How to edit a webform block (not the webform itself)

probably the easiest way is to create a separate form for that block (a copy of what you have now, but dedicated to that block), and disable Captcha for that form name


How to get cache metadata from nested render array when returning response?

Render the nodes in a render context, so that the metadata can bubble up:

  $storage = \Drupal::entityTypeManager()->getStorage('node');
  $builder = \Drupal::entityTypeManager()->getViewBuilder('node');
  $nodes = $storage->loadMultiple([1,2,3]);
  $build = $builder->viewMultiple($nodes, 'teaser');

  $render_context = new \Drupal\Core\Render\RenderContext();
  \Drupal::service('renderer')->executeInRenderContext($render_context, function() use (&$build) {
    \Drupal::service('renderer')->render($build, TRUE);
  });

  $response = new CacheableResponse();
  if (!$render_context->isEmpty()) {
    $response->addCacheableDependency($render_context->pop());
  }

The rendering is not lost. The rendered nodes are in $build['#markup'] and you can add the html to the response if that is what you want to do:

$response->setContent($build['#markup']);

Edit:

Just seen in the related question on the right a similar topic. While the above code is good for demonstration purpose, because it shows how to get cache metadata from a nested render array, the simpler code in the answer to How to handle cache metadata in an AJAX response? is actually working for this nested build array too, because the dependencies of the build array are added after rendering and at this point the metadata has bubbled up to the top level.


I figured it out. Posting this for documentation: I had to pass the cookie after the user had logged in to do a GET on the token (localhost/services/session/token) for the Services module. Once I had the token, I could pass the cookie and the token to do a POST of the resources. I also switched the gem from rest-client to Faraday because I could customize my headers better. Also, the logging functionality was more verbose in Faraday which was helpful in debugging.


how to get summary of content in following code

You'll need to look in $record in your foreach statement and find the content you want. (probably $record->body) Since you are polling the database manually (vs. using display_modes like teaser / full) you'll probably have to create the summary yourself.

I suggest using the truncate_utf8() function which "Truncates a UTF-8-encoded string safely to a number of characters.", it supports adding "...", word boundaries etc.

As for this "looking" into your $record var, I suggest using the Devel module, which ships with a function dpm() which can take basically any variable and output it in a pretty navigationable message on your page.


How can I sort the order of status messages?

$variables['display'], passed to the theme function is optional, and its purpose is only to limit the type of messages being shown; for example, if its value is "error," only the error messages should be shown. The list of messages is returned from drupal_get_messages(), which should be called as drupal_get_messages($variables['display']).

To answer to your comment, you can avoid duplicating all the code used by theme_status_messages() if you follow these steps:

obtain the array of messages from drupal_get_messages()
sort the obtained array of messages
use the array to set the content of $_SESSION['messages'], which is the session variable used to contain all the messages set from the modules
call theme_status_messages(), passing the same argument passed to your theme function (not the array obtained from drupal_get_messages())

This method seems half of a hack, to me. What happens if Drupal would change how the list of messages are saved? It could be that future Drupal versions will not use a session variable for this purpose.
It also take the assumption that other modules didn't override the theme function, but it would be easy in the implementation of hook_theme_registry_alter() to save the previously defined theme function, and call that function instead of assuming that function is theme_status_messages().


What does the "Empty srcset[]" breakpoint in Picture Module?

The empty srcset is to be used when there is a breakpoint where you don't want to display your image. An example might be where the image in question, or a parent div, is display:none in the css. The image would normally be downloaded anyway, but by having an empty srcset at that breakpoint, no images will be downloaded.


In Drupal 8 can a developer inject Full HTML Pages?

Usually you will not inject full HTML pages to Drupal, more likely you will inject your content as node-content. Then use a convenient theme for your needs.

Drupal has - like wordpress - themes. These are nested pieces of HTML code with TWIG syntax for dynamic content.

Unlike, wordpress, you can specify different themes for different URI paths (look for keyword theme_negotiator). I.e., you may configure to use an "article-theme" on path /articles.

But this is only the beginning of a very long story...


How can I set the value of a taxonomy term reference to multiple terms using PHP?

Assuming the field is set up to accept multiple records...

$user->field_yourfield_name[LANGUAGE_NONE][0]['tid'] = 27;
$user->field_yourfield_name[LANGUAGE_NONE][1]['tid'] = 28;
// etc

Or you can just keep appending to the array (without knowing the next available index) like this:

$user->field_yourfield_name[LANGUAGE_NONE][]['tid'] = 27;
$user->field_yourfield_name[LANGUAGE_NONE][]['tid'] = 28;


Custom submit handler: how to create node?

After some searches I post the solution to myself!

This is the right code to use:

$values = $form_state['values'];
$node = entity_create('node', $values);
$node = node_submit($node); // Prepare node for saving
node_save($node);


Possible to call a function after user sets their password for the first time after using their one-time login link?

You could try using hook_user_login() in a custom module or theme.

function my_module_user_login($account) {

  // Get the end part of the URL.
  $request_uri = \Drupal::request()->getRequestUri();

  // Check if the URL is a reset / one time login link.
  if (strpos($request_uri, 'user/reset') !== false) {
    _my_module_custom_function();
  }
}

function _my_module_custom_function() {
  // Do stuff.
}


Move fields from additional settings to field_group on node edit forms

Display Suite

-module which changes the manage display page to allow exactly for that and moving title, links, comments and way more useful features like changing/resetting field and views templates, linking between displays, dynamic & block fields, moving fields to a block just to name a few. It could replace views in those cases where you mainly use views to have more control over the output.
Thank You.


Question about template_preprocess functions

Yes definitely it will go to parent function too because this is concept of overriding. But final impact would be of your override function.

Say example:

// Parent Function: First go to this fucntion

function template_preprocess_field(&$variables, $hook) {
   print "Parent Function";
   $variables['test_variable'] = "Parent data";
   ....
}

// Child Function: Override values using child function

function mytheme_preprocess_field(&$variables, $hook) {
   print "Child Function";
   $variables['test_variable'] = "Child data"; // Override value here
   ....
}

Now this $test_variable contains "Child data" value not "Parent data" because it is overrided.

I hope it would help you to understand basic concept of overriding.


Where is the configuration file for my custom plugins?

For configuration to be found as a file (yml) you have to manually invoke/export it with any of the following methods

from the Drupal admin interface visiting the url admin/config/development/configuration/single/export. For this to work the core Configuration Manager module must be enabled.
drush with drush config-export and than finding the appropriate file manually
drupal console drupal config:export:single
contrib modules such as config_single_export or config_partial_export

All those methods above have also an import mechanism which you can use to import or see more details here

Also note you will not need the REST UI module to be enabled in production


PHP setting of datetime field in CCK through Rules, How to stop continuous updates?

Thanks to Clive's help, I determined the problem was with the field type. There were several similar seeming Date/Time field types available to use, I was using one called "datetime". I switched to another one called "datestamp" and the datestamp field retained its original value after refreshing. I guess the "datetime" field is designed to always return the current datetime value of now(). Thanks for helping me work through this friend!


Change image style during hook_node_view()

I hate to answer my own question, but this answer pointed me in the right direction. Here's the hook that worked in this case:

/**
 * Implements hook_preprocess_HOOK().
 */
function example_preprocess_image_style(&$variables) {
  if (example_ok()) {
    $variables['style_name'] = 'new_image_style';
  }
}

function example_ok() {
  global $user;
  // If the logged in user is bob, everything is ok.
  if ($user->uid && $user->name == 'bob') {
    return TRUE;
  }
  return FALSE;
}


View all nodes of a content type using a filter

In this case, if you are providing a contextual filter, the view will render the filtered out result. However, as I understand from your question, you need the entire nodes of that content type with the contextual filter values on the top.

For this you can try using hook_views_post_execute() where the pre_render() function is yet not called and sort manually. Or, you can use hook_views_pre_render() function to shuffle the result. At this point, you have all the nodes and you can sort them manually.
Hope this is helpful. Thanks


unable to add configure field to drupal view

Your view is not a Content view.  Create a "Content" relationship on the view, and all the content type fields configured on your site will become available to add to the view.


How to hide a block or text if user can edit node?

Seems it can be done via this PoC

if (node_access('edit', $node, $user)) {
  {'you can edit'}
}
else {
  {show flag}
}


You could implement custom tokens, and the coupled with the module http://drupal.org/project/token_filter - your content will be rendered as per usual.

In this way you could have a token:

[price-tier-1] = $9.99

and when the price changes you only have to change the token value (in one place, in code)


How to structure git repositories for project?

Drupal.org uses just one repository for module, and branches for each module version (for example, 7.x-1.x for module in version 1.x for Drupal 7, 6.x-1.x for module in version 1.x for Drupal 6, 7.x-2.x for module in version 2 for Durpal 7, and so on).

Also, if your server and client share code you may use just one Durpal module with submodules, so all code is in one repository. Users will just enable client or server (and the module that holds the common code).

So, your actual setup is fine if client and server do not share any code or very little and you want to keep them as separate modules. Just add branches for each Drupal version (6.x, 7.x, 8.x). Or join them into one repository and split code into three modules: common, server and client.

You can check the 'Maintaining a drupal.org project with Git' page.


I have created a view which will display all the entities in which current logged in user is referenced. Just Import this view and change it as per the content type you want.

Enjoy!!!!

$view = new view();
$view->name = 'users_referenced_entity';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Users Referenced Entity';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Entities in Which Logged in User is Referenced';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Content: Referenced users (field_referenced_users) */
$handler->display->display_options['arguments']['field_referenced_users_target_id']['id'] = 'field_referenced_users_target_id';
$handler->display->display_options['arguments']['field_referenced_users_target_id']['table'] = 'field_data_field_referenced_users';
$handler->display->display_options['arguments']['field_referenced_users_target_id']['field'] = 'field_referenced_users_target_id';
$handler->display->display_options['arguments']['field_referenced_users_target_id']['default_action'] = 'default';
$handler->display->display_options['arguments']['field_referenced_users_target_id']['default_argument_type'] = 'current_user';
$handler->display->display_options['arguments']['field_referenced_users_target_id']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['field_referenced_users_target_id']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['field_referenced_users_target_id']['summary_options']['items_per_page'] = '25';
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'article' => 'article',
  'page' => 'page',
);
$handler->display->display_options['filters']['type']['group'] = 1;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['path'] = 'users-referenced-entity';


You can also use Login Destination module to redirect without touching any code

  The Login Destination module allows you to customize the destination
  that a user is redirected to after logging in, registering to the site
  (7.x), using a one-time login link or logging out (7.x). The
  destination can be an internal page or an external URL. It is possible
  to specify certain conditions like referring pages or user roles and
  make the destination depend upon them. You may use PHP snippets to
  provide custom conditions and destinations. It is also possible to
  keep users on the currently visited page after logging in or out.


The version of CKEditor could not be detected

What you need to do after installing the module is go to http://ckeditor.com and download the latest version. Then uncompress the contents of the 'ckeditor' directory of the downloaded file to this folder 'libraries/ckeditor/ckeditor'.

Installation steps

Unzip the module files to the "sites/all/libraries" directory. It should now
  contain a "ckeditor" directory.
Download standalone CKEditor from http://ckeditor.com/download. Unzip the
  contents of the "ckeditor" directory from the installation package to the
  "sites/all/libraries/ckeditor/ckeditor" directory.
  Note: you can skip uploading the "_samples" and "_source" folders.
Enable the module in the "Administration panel > Modules > User Interface" section.
Grant permissions for using CKEditor in the
  "Administration panel > People > Permissions" section.
  Note: In order to enable the file browser, refer to the
        "Installing CKFinder" section.
Adjust CKEditor profiles in the
  "Administration panel > Configuration > Content Authoring > CKEditor" section.
  Profiles determine which options are available to users based on the input format system.


I am using https://github.com/drupal-composer/drupal-project . How to add more scripts after "create-project"?

when you use create-project you're creating a new composer project with a  composer.json based on the package type.

The composer.json file is highly customizable. You can set install paths for specific modules/libraries and/or set a list of default modules to install when the project is created. You can also apply patches and run post-install scripts if nessecary. Plenty more options as well. I suggest jumping into the composer docs.

to add a module to composer.json run:

composer require drupal/module_name 8.1.*@dev

Once you have a composer.json the way you like, you can take that composer.json file, place in a different empty project directory and you can simply run composer-install and it will install the drupal project, all the modules in the appropriate directories specified inside the composer.json file, post install commands ect, it will also write a composer.lock file if one doesn't exist. No need to create a brand new project everytime, just manage custom composer.json files thats the beautfy of composer.

https://www.lullabot.com/articles/goodbye-drush-make-hello-composer

https://getcomposer.org/doc/01-basic-usage.md

https://getcomposer.org/doc/


How do I override a fields output in a Views template?

I don't know if this is the answer you wanted, but I template the individual fields by templating the custom:global, and accessing the individual pieces through the $view object.


Try the Hierarchical Select  module. This module integrates with Taxonomy.

This module defines the "hierarchical_select" form element, which is a greatly enhanced way for letting the user select items in a hierarchy.
Hierarchical Select has the ability to save the entire lineage of a selection or only the "deepest" selection. You can configure it to force the user to make a selection as deep as possible in the tree, or allow the user to select an item anywhere in the tree. Levels can be labeled, you can configure limit the number of items that can be selected, configure a title for the dropbox, choose a site-wide animation delay, and so on. You can even create new items and levels through Hierarchical Select!


Display custom block to specific content type programmatically

This code should work for you

function my_module_block_info() {
  $blocks = array();
  $blocks['my_module_config'] = array(
    'info' => t('My Module'),
    'status' => TRUE,
    'region' => 'content',
  );
  return $blocks;
}

/**
 * Implements hook_block_view().
 */
 function my_module_block_view($delta = '') {
 $block = array();

 switch ($delta) {
   case 'my_module_config':
     $block['subject'] = '';
     $node = menu_get_object();
     if (isset($node->type) && $node->type == 'product') {
       $my_module_form = drupal_get_form('my_module_form');
       $my_module_form = drupal_render($my_module_form);
       $block['content'] = $my_module_form;
     }
     else {
       $block['content'] = '';
     }
     break;
  }
  return $block;
}


how to show message in popup when user register to site?

Use this module to show popup on the specific page.Use the latest dev version https://drupal.org/project/popup_message


Your site is installed in the /cars folder, but you're pointing to the root of the server by using the forward slash at the front of your HREF. You should use Drupal's l() function to generate a proper link:

<?php echo l(t('Homepage'), 'homepage'); ?>


Thank You Chris...the menu_load_links() was exactly what i was looking for. Here is my custom main menu array that i later parse in html teplates as needed:

$mainMenuArray = menu_load_links('main-menu');
$finalMainMenu = array();
foreach($mainMenuArray as $key=>$menuItem){
    $finalMainMenu[$key]['active'] = false;
    $linkPath = $menuItem['link_path'];
    $linkPathAlias = drupal_get_path_alias($linkPath);
    $currentId = $vars['node']->nid;
    if(drupal_get_path_alias("node/$currentId") == $linkPathAlias)$finalMainMenu[$key]['active'] = true;
    $finalMainMenu[$key]['url'] = $linkPathAlias;
    $finalMainMenu[$key]['title'] = $menuItem['link_title'];
}
$vars['mainMenu'] = $finalMainMenu;

I have this in template.php hook 'theme_preprocess_page' where the $vars['node'] is used to determine what is the current node loaded. I hope it useful for someone. Thank you Chris for answering my question.


limit custom html.tpl.php to exact page, not subpages, drupal 7

If it's just one page you can just use something like node--nid.tpl.php
 or page--node--nid.tpl.php right? (Assume that /something/anotherthing and /something/anotherthing/details are two difference nodes)


I know this was asked a while ago, but for the benefit of people still searching, here is a solution.

<?php foreach ($rows as $id => $row): ?>

<?php
$node = node_load($view->result[$id]->nid);
// do something with your node
?>

<?php endforeach; ?>


Image styles not generated during config import

I went through adding all the files one by one and finally found the problem:

image.settings.yml contained:

suppress_itok_output: true

Once it was changed to false the problem disappeared.


drush make: Specify subdir for make-files provided by contrib modules

You can specify a default subdir for all projects this way:

core = "7.x"
api = 2
defaults[projects][subdir] = contrib
projects[] = views
projects[] = ctools

it is a very recent addition to drush 5, only available in the dev release.


How to display the title at the end of the breadcrumb?

In template.php of your theme folder you can do this:

This is for changing the seperator or overriding the already available breadcrumb:

function mytheme_breadcrumb($variables) {
  $sep = ' &gt; ';
  if (count($variables['breadcrumb']) > 0) {
    return implode($sep, $variables['breadcrumb']) . $sep;
  }
  else {
    return t("Home");
  }
}

For adding title of page next to the breadcrumb you simply do this.

In page.tpl.php of your theme folder:

<?php print $breadcrumb . $title; ?>

[Alternative Answer]:

If you dont want to do with custom code then you can try this module(Menu Breadcrumb) which will have option for adding page title at the end of breadcrumb.

In the configuration of this module you need to check this option for getting page title use menu the page belongs to the breadcrumb

Module Name is Menu Breadcrumb


Adding a query string to a link in Views

If the link is a field of view, it could be possible to get the URL in the template file using the $row variable.


Using Panels and Views to override taxonomy listing - which argument to use?

In the Views UI, each Content Pane has "argument settings". In there you have, at least, two options.

The easiest to configure, is "From panel argument", and its option in this case, "Second argument". This works fine in your situation.
The most flexible, that I always use, require more understanding of the Ctools context.

The argument setting then is "From context" and in this case "Taxonomy Term" -> "Name".
Save the View, go into the Panels UI, add the View Pane, not just a View.
Assuming your Panel Page now has a taxonomy term, which is always the case on the /taxonomy/term page, you will get a dropdown, most of the time with just one option, that lists the available terms that you pass on to the View.

If you for example had a path like /color/red/blue, because you wanted two terms, the second version will allow the re-use of the same View on the same page, with different content.


Having problems with file_copy in Drupal 7

Use "public://$public_place/$file->filename" as $destination parameter for file_copy().


Display a View Block multiple times in a region with each view using a different filter

Based on what you have described, yes.  It is not only doable, it is quite easy.

You can add different pages, blocks or even attachments.  When you creating/editing a view, click on "Add" then select what you would like.

With an attachment, you can select before, after or both for each attachment.

The key to making this work is to only set criteria for that display only.  In the example below, I am in the "Add Fields" dialog.  If you want a separate filter for this particular page/block/attachment, make sure to select "This Page (Override)"

When you do this, anything in this view will be restricted to this display only.


Converting and save images as JPG in IMCE module during uploading?

It can be done in this way:

download ImageCache Actions module and enable Color Actions    module
create image style "Change file format Convert to: jpg"
download and install IMCE Image Style module
on the IMCE Image Style administration page select necessary style

And we need to add custom submit function

/**
 * Implements hook_form_FORM_ID_alter().
 */
 function mymodule_form_imce_upload_form_alter(&$form, &$form_state, $form_id) {
   array_unshift($form['fset_upload']['upload']['#submit'], "mymodule_upload_form_submit");
 }

/**
 * Change uploaded image extension.
 */
 function mymodule_upload_form_submit($form, &$form_state) {
   if ($_FILES['files']['type']['imce'] == 'image/png' &&    $form_state['values']['imce_image_style']['optimize_image'] != '0') {
      $_FILES['files']['name']['imce'] = str_replace('.png', '.jpg', $_FILES['files']['name']['imce']);
   }
 }


Twitter like notification when new posts are made

You can use nodeJS to push live updates to your website without refreshing it, thus you also can count the new items.

There is a module that integrates with nodeJS: https://www.drupal.org/project/nodejs

You will need SSH access to make this work I think.


Is there a "hook_user_login_failed" hook? Or something similar?

At least in Drupal 7, there is no hook for that.  The login form uses validators, one which authenticates, and another that follows and sets a form error if login failed.

One option would be to add a custom validator to the form using hook_form_FORM_ID_alter, and check the status of login there.  See user_login_final_validate in user.module for an example of how status is checked.


Content-type linked to specific users and user-groups

Often times when using Drupal there are recipes or a collection of modules that will help you achieve your goals for a website so that your workload is  not burdened with custom PHP business logic code or SQL. Drupal helps to take away these technical difficulties when creating websites.

It sounds like you want to a site with groups of content and users. There exists active module(s) to allow easier site development of sections and groups of users within a website. The defacto module for this is Organic Groups (typically referred to as the "OG" module) and its set of sub-modules and contributed add-on 3rd party modules.

  Overview

  Enable users to create and manage their own 'groups'. Each group can
  have subscribers, and maintains a group home page where subscribers
  communicate amongst themselves.

  They do so by posting the usual node types: blog, story, page, etc. A
  block is shown on the group home page which facilitates these posts.
  The block also provides summary information about the group.

  Groups may be selective or not. Selective groups require approval in
  order to become a member, or even invitation -only groups. There are
  lots of preferences to configure groups as you need.

OG is not a small or simple module in it's administrative configuration, or it's supported API. But, it's goal is to make your stated problem easier to implement in a standard fashion/codebase for site developers.


How to use FilterProcessResult::createPlaceholder (#lazy_builder) in an input filter?

After several months, I looked at the code again and found the issue. The createPlaceholder method calls addAttachments, but then I call setAttachments, which removes the previous attachment.

I should always use addAttachments as that will merge instead of overwrite.

foreach ($matches['code'] as $i => $code) {
  $args = [$code, $this->settings['render_mode']];
  $markup = $result->createPlaceholder('\Drupal\processing\Plugin\Filter\FilterProcessing::build', $args);
  $text = preg_replace('/\[processing\](?P<code>.*)\[\/processing\]/is', $markup, $text);
}
$result
  ->setProcessedText($text)
  ->addAttachments(['library' => ['processing/drupalprocessing']])
  ->setCacheTags(['processing']);


Entity field query pager only loads first page

Here are some pointers:

The query looks fine
Try adding the parameter ?page=1 to your request and you should see different items. Page 0 is the one you see by default.
You need to display the pager object while building your output, like:
$output['pager'] = array('#theme' => 'pager'); This will make the pager visible and allow users to click on back/next buttons to navigate through pages to see other items which are not on the current page.


How to restrict node access to nodes based on field value?

I think the Node Access User Reference module will do exactly what you want.  It allows you to restrict access to a node based upon a user reference field in that node. It even comes in Drupal 6 and 7 flavors.

From what I can tell though, you want to make sure you use only one node access module for your system, so you may want to look at the Node Access Module Overview to make sure this is the best bet.


Leaflet library not avaliable even though it's in sites/all/libraries

Looks to me like the library hasn't been installed correctly, the path should be sites/all/libraries/leaflet/leaflet.js you should be able to append this to your sites URL to load the file.

Have you looked through https://www.drupal.org/node/1954942 to see whether anything helps?


Can always install manually

# get drush latest 8 version from
# https://github.com/drush-ops/drush/releases
# or any version that you want
wget https://github.com/drush-ops/drush/releases/download/8.1.16/drush.phar

# make it executable
chmod +x drush.phar

# move it to home directory or any other directory
mv drush.phar ~/drush

# go to that directory
cd ~

# find out the path to the directory
pwd
# the output would look similar to this
# /home/your_user

# edit the following file
nano .bash_profile
# or in some systems
# nano .bashrc

# add this the end of the file
alias drush='/home/your_user/drush'

# use the alias you just setup
source ~/.bash_profile

NOTES:
Above example works in ubuntu but should be similar on other distros

According to the docs drush 8 works with D8, D7 and D6 so no reason to install drush 7

If you want to call it with drush8 use following alias drush8='/home/your_user/drush' in .bash_profile file


In settings of the User ID contextual filter, you can exclude this argument/contextual-filter. Expand the last field-set and you'll see it. isn't it what you need to do ?


I made a content type Newsletters, You could remove the Body field if you want form the Node. I then used Panelizer with nodes to make newsletter like layouts. The content for the node is actually ctools based custom data.

I also made use of a custom html--newsletters.tpl.php file to remove site themeing from the newsletter and apply generic newsletter themeing for the site.

If you got this much working:

custom content type (title, optional body)
Panelizer enabled, pick a layout (or layouts)

enable node_panelizer.

un-embed newsletter from site with custom html.tpl.php for the content type (optional)

Then I would make a hook_menu entry for your json service. Just do a node_load on the newsletter node and inspect $page['content'] for your nodes layout and "sections". Just build a json array out of how your page is setup in the page render arrays.


Is there a way to display webform submission based on element values?

You can achieve this with Webform Views Integration. This module allows you to build a view of webform submissions. You then can use Views' filtering on elements values.
Unclear is where you want to display them. But with Webform Views Integration you can of course build a view page with an URL or view block as you need.

Use Webform Views Integration module to expose Webform submissions to Views (Webform is a module for making forms and surveys in Drupal).


The best way to implement custom variables with Google Analytics

"Custom variables" are now Custom dimensions and metrics.

The Google Analytics module supports custom dimensions and metrics.

See the module's README.txt:

  One example for custom dimensions tracking is the "User roles" tracking.

  In the Google Analytics Management Interface you need to setup Dimension #1    with name e.g. "User roles". This step is required. Do
  not miss it, please.
  Enter the below configuration data into the custom dimensions settings form    under admin/config/system/googleanalytics. You can
  also choose another index,    but keep it always in sync with the
  index used in step #1.

  Index: 1    Value: [current-user:role-names]


How to show the edit form of a page just below the page itself in the frontend?

You can output edit form of current node with node_page_edit function. So you can create a block programmatically(show this block only on node pages of your content type - Services for example) and output edit form with node_page_edit.

  if(arg(0) == 'node' && is_numeric(arg(1)) {
    $nid = arg(1);
    //you need to include node.pages
    module_load_include('inc', 'node', 'node.pages');

    $output = node_page_edit(node_load($nid));
    return $output;
  }

Here you can find an example how create block.


Ctools Custom Content Type Plugin with Image Field

You should try to put this line:

form_load_include($form_state, 'inc', 'my_module','plugins/content_types/my_file');

at the top of your content_image_pane_edit_form function, replacing my_module and my_file with your module and plugin include file.

Ctools panes are generated in a separate modal from base Drupal forms and so when the AJAX reloads the form it cannot find the original form function. By forcing Drupal to include the full form code each time it is processed, the AJAX will be able to find the necessary function to rebuild the form.

Tested working with Drupal 7 & panes on a production site.


No, Drupal is not doing anything to handle this; the very fact you're asking might suggest you're not totally sure how this works, as Drupal has no power over the efficiency of the code you write.

GC runs every time a function finishes, so unless you've identified an actual problem in one specific function, clearing up every single variable after you've used it, even though you theoretically can, would surely be considered premature optimisation.

Bottom line: Drupal cannot help you to write efficient code, you need to apply what you know from PHP. Whether you want or need to free the memory for every single variable manually depends on your requirements and specific code.

I would personally say you're over-thinking this a bit, as in an ideal world your functions should be small and modularised enough for this not to be an issue anyway. React to real problems, not perceived or potential ones, when it comes to optimisation.


You can adjust some of the settings of a field on the 'manage fields' tab of the content type configuration.

To position or further manipulate the output of a particular field in the template, edit node.tpl.php and where you want your field to appear, add

if(!empty($content['field_term'])) {
  print render($content['field_term']);
}

(Or if your field isn't called 'field_term', whatever your field's name is.)


Create fieldable bundle types for an entity with Drupal Console

I eventually got it by comparing how NodeType/Node is defined:

http://cgit.drupalcode.org/user_alert/tree/src/Entity?h=8.x-1.x

Now I can have unlimited entity types and add fields to them for different content configurations of the entity.

I started out by generating a config and content entity with the Console, but found that in order to get a more intuitive user interface, I had to modify the routing.yml and some of the paths as well.

Just a note for those looking for the same functionality.


Commerce Kickstart is a profile of Drupal and so you just have to select commerce kickstart radio button during your installation of Drupal. After selecting this, Drupal will start installing default products and all.
Download Commerce Kickstart and install it same as you install Drupal.


WYSIWYG editor not actually able to make use of all its tools

Filtered HTML format restrict some HTML tags, inspect or check source code of your text and see what is new line converted to.

Few guidelines for WYSIWYG editor:

Try Full HTML format
Check with permission on HTML profiles, on this path: admin/config/content/formats
Check your jQuery version, use jQuery update module
Check is there any JS error on console


Modules ".module" file not being called when anonymous user

If your module file defines a block, but isn't being parsed, then the block wouldn't work at all; you'd get all sorts of fatal errors, not missing CSS.

You've probably got page and block caching turned for anonymous users...that'll be why your exit code doesn't run. Try clearing the caches, it should make a difference.


Here you can find the solution for restricting duplicated items to the cart.

Solution is

Create rule, name it; Event: before adding a product to the cart
You can add there conditions if you wish. I am chcecking here is product is digital or not.
In Actions add Loop through commerce-order:commerce-line-items
Create component, single rule, name it
Create following variables of the component and name them as you wish:

Commerce line item (line item of the order from the loop of the main rule)
Commerce product (product added to the cart)

Add condition to the component: Entity has field, Entity: [line-item-in-order], Field: commerce_product. this will bring us the product from actual line item in current order (shopping cart).
Add condition to the component: Data comparison. Data to compare: line-item-in-order:commerce-product with product-added-to-cart (variable brought from the main rule)
Add action to the component: Remove an item from a list. List: [order:commerce-line-items], Item to remove: [line-item-in-order]. This will completely remove duplicated product from the shopping cart and from the order as well.
Eventually add another actions. At least Display some message to the user to inform him/her that the item has been removed sounds sensible.
Come back to your main rule created in step 1. Add action to the loop and select the component you have just created in steps 4. - 9. and set the variables.
You are done. Chcek it, it should work


The exceptions aren't caused from the code shown in the question. The second exception is caused from the following code in ContentEntityBase::getTranslatedField().

// Populate $this->fields to speed-up further look-ups and to keep track of
// fields objects, possibly holding changes to field values.
if (!isset($this->fields[$name][$langcode])) {
  $definition = $this->getFieldDefinition($name);
  if (!$definition) {
    throw new \InvalidArgumentException("Field $name is unknown."); // Line 586.
  }

  // Omissis.

}

There is a module that is trying to access the type field, which doesn't exist for the User entity.

Your code is correct. Eventually, instead of setting the user fields using a setter method, you could use the array User::create() accepts as first parameter, which uses the following array keys (among others):

name
mail
pass
status
roles (an array)
langcode
preferred_langcode
preferred_admin_langcode

There isn't an equivalent value for enforceIsNew(), so you need to call that method on the created user object.


Addressfield entries not showing up when entityform sends an email

This was addressed in an issue on Drupal.org. Which version of Entity2Text are you using? The fix was added to 7.x-1.0-alpha2.


having multiple instances of blocks with different settings in D7

There's no hook_block in Drupal 7. However if you take a look at your README file inside your D7 version of multiblock module, you can find how to do it:

  Example implementation of hook_block_info:

function hook_block_info() {
  $blocks['powered-by'] = array(
    'info' => t('Powered by Drupal'),
    'weight' => '10',
    'cache' => DRUPAL_NO_CACHE,
    'mb_enabled' => TRUE,
  );
  return $blocks;
}


hook_field_formatter_view does not get called

Your code is correct, I just tested it and it works for me.
I created fresh Drupal instance, created profile_cal module with your code without any modifications then added 'Availability calendar' field to 'Basic page' content type, created a page and got "Called!" message on the screen.


ViewsJSON module not working with Google Store Locator

I have managed to get it working with version 7.x-1.0-alpha2 of module GeoJSON.

Please see my question and my own answer at Localize nearest store to a zip code in Drupal 7


entity_reference field widget as select instead of autocomplete

I was able to change the widget from the field config page. The key used by drupal was options_select, so I updated the type to:

'type' => 'options_select'


At advanced, the column at the right, in the view config you can set the filters to apear as a block. You could place this at any random page and when submitting you will be send to the viewpage desiplaying the results from the filter.


How do I change the field value of multiple nodes?

You could use the Flag module to get this to work, by configuring an appropriate (non-global) flag, which you should then use to (automagically) flag a user after such user was emailed for the first time. To actually flag such users, you should just improve the Rule you use to send those emails, by adding a rules action to flag that user with the flag you created.

Any time your existing rule is about to send another email, you can then verify if it is the very first time, or yet another time. For this verification, all you'd have to do is use a Rules Condition to check "has this user yes or no been flagged already (with the flag you created for this purpose)?".

If you're not familiar with the Flag module, checkout either of these:

The set of 8 video tutorials about the Flag module.
Flag's Community documentation.

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


Disable the toolbar module in install profile

From an install file perspective, you can use a combination of module_exists and module_disable, in an implementation of hook_enable.

Example:

function MYMODULE_enable() {
  if (module_exists('toolbar') {
    module_disable('toolbar');
  }
}

Module enabling/disabling isn't within the scope of a make file, so that won't work.

Lastly, as far as I'm aware, if a module is not declared as a dependency of a profile, the it won't be enabled.  If I'm mistaken, you can still use the code shown above to disable the module (although I can't 100% confirm where to put it, as I've never made an install profile).


How to change conditions of views filters programmatically?

You specifically ask for altering the View programmatically, and that certainly is possible. I will however suggest an easier way. With Views 3, you can group your filters. This way, you can achieve the effect you are asking for by adding two separate groups of filters.

Group 1: Node:type == [type]

OR

Group 2:  User:role == [role] AND Node:type == [other_type]


How do I change a field with hook_node_presave()?

A bit outdated but still a great resource:

http://wizzlern.nl/drupal/drupal-8-entity-cheat-sheet

Also the documentation on drupal.org: https://www.drupal.org/node/1795854

In short, fields are lists of objects that use property and array access magic methods to simplify reading and writing values to them:

// Set a value, the field class will decide what to do with it, usually write to the primary property...
$entity->field_fieldname = importantfunction();

// The default property is often called value, but for reference fields, it is target_id, text fields also have a format for example
$entity->field_fieldname->format = 'full_html';

// By default, you access delta 0, you can also set other deltas.
$entity->field_fieldname[1] = importantfunction();

// You can also append a new item, without hardcoding the delta.
$entity->field_fieldname->appendItem(importantfunction());

// Note that when accessing fields, you must always specify the property:
print $entity->field_fieldname->value;
print $entity->field_fieldname[1]->value;

// What basically happens internally for the above is:
$entity->get('field_fieldname')->get(0)->get('value')->getValue();


Views on Drupal 8 are slightly different, but you might consider this answer (given for Exposed filters with dropdown selections), which gives you a quick module way of creating a custom node-based exposed filter drop down for a Drupal 7 view. This is essentially what I would suggest for your use case.


If you really want to remove bootstrap.js you can do it this way:

function YOURTHEME_js_alter(&$js) {
  $bootstrap = drupal_get_path('theme', 'bootstrap') . '/js/bootstrap.js';
  unset($js[$bootstrap]);
}

It might fix your menu plugin but it'll remove every drupal specific bootstrap js code (tabs, popovers, tooltips and anchors stuff).


.info file having a name that is different from the name of the theme's folder

You cant give same name for theme and module.
I have found an article on drupal.org

  How to Resolve module-theme name collision

  When developing a site it can happen that a module and theme are being
  given the same name. This results in very weird behavior: overriding
  hooks can make your blocks disappear, print $content returns only
  'array', hence disappearing admin interfaces which force us to alter
  the database to get back on track.

  Now we have to find out how to remove the new theme and switch back to
  an old one. if your site is big, with lots of content, then
  reinstalling is not an option. I tested this with MySQL, so these
  hints are for MySQL only.

  Make a backup of your database first. We are going to edit the dumped
  records, and reinsert the database. I used this method because using
  my favorite editor is way easier and safer than using MySQL shell
  (anyway we shouldn't edit a live site database).

  The theme name is registered in the following tables in your database:
  system, variables and block. Clear the cache manually, meaning to
  remove all the INSERT INTO cache_ lines in order to see results.
  Change the 'default_theme' value in system. Note that 's' stands for
  string length, so be sure you put the string length after the 's:'.
  Also make sure you change the value to an existing theme (available
  themes are listed in system). And remove, or rename your troublesome
  theme.

  The change in block is imperative, otherwise the blocks will not
  appear. Drop your old database from the sql server and insert the
  edited one. Voila, we have recovered from a theme crash.

© drupal.org

And

Never give a module and a theme the same name

Here's the D7 Patch


Why in node.tpl.php $content is different from $node?

Sounds like their field display settings are hidden, which is one reason it would not be in the $content renderable array.

Check the display settings for the applicable view mode for this content type on the "Manage Display" tab.


Disabling auto-removal of 'rel' attributes in full HTML input format

I fixed this by changing the formatting library from TinyMCE to Yui as it does not remove the 'rel' tag.


Is there anyway create relationship for filter criteria which has vocabularies( state, city and location)?

The Relationship option in Views tracks entity references, so to use that option, you have to create Entity References among your terms.  In taxonomy terms, the parent and grandparent are entity references.
Generally speaking, Views can only use a data structure that already exists in the database, or can be built from other structures in the database; it can't create a structure "out of thin air."
One approach: Using parents and grandparents
To use parents and grandparents, you would have to delete your current terms and re-structure them like this:

Grandparent: Country
Parent: State
Child: City

You can do this by setting the parent when you create each term:

Countries have no parent
States have a country as parent
Cities have a state as parent

Since there are no rules that enforce this structure unless you code the rules yourself, you have to be careful to make sure you set things correctly.
If you take this approach, you can add relationships to get the parent / grandparent under Relationships in Views, but making the filters by country / state / city will be a pain.
Alternative approach that will make it easier to add the filters but that is harder to maintain
Keep the vocabularies independent.  Add an entity reference field (term reference) to the State term type called Country and let users select a country.
Add two more entity reference fields (term reference) to the City term type called State and Country.
Then you have to set the correct country for each state, and state and country for each city.
Then, in your View, you can simply show a list of cities, and the filters for Country, State, and City will work for cities as you expect.
Note, however, that if a country or state has no cities, no entries will appear.  This is because we set this View to only show the list of cities to make setting up the filters easier.


The best way should be implementing the search_api module , with this module you can index anything and set the importance of the indexed field .

Here is a screen cast that shows how to implement here

Note that the screencast must be updated because facet_api works now without apachesolr

Enjoy!


How to render the textfield from custom advanced theme setting?

In your template.php preprocess function, you need to pass the message back as a key/value in the variables array. (I set the variable key as "custom_msg" as "message" may be too generic and be accidentally confused with any system message variables"

function MYTHEME_preprocess_page(&$vars) {
    $message = theme_get_setting('message_value');
    $vars['custom_msg'] = $message;
}

Then, in your page.tpl.php, the variable would be accessible as $custom_msg (or whatever custom key you set in the preprocess function) and can be included in your page template as:

<?php if(!empty($custom_msg)) echo $custom_msg; ?>

More information about this can be found on this Drupal.org page: Setting up variables for use in a template (preprocess and process functions)


Project contains 5 modules. Neither of them is named exactly like the project. See the names you were given in first message.

You probably meant

drush en vud


Is it possible to have a custom filter for exposed criteria?

Here's the solution that works for me. I've been heavily inspired by this solution which is for Drupal 6, so I've adapted it for Drupal 7 and it works for me:

(Nota: I give two hints in the code : (1) how to make a query that asks for all nodes that have no parent (join on taxonomy_term_hierarchy where parent=0) and (2) how to search form terms using LIKE statement):

/**
 * Implements hook_form_alter().
 */
function bcg_form_alter(&$form, &$form_state, $form_id) {
    if ($form['#form_id']=='views_exposed_form') {
        // override the original completion path which was:
        // 'admin/views/ajax/autocomplete/taxonomy/2'
        $form['term_node_tid_depth']['#autocomplete_path'] = 'admin/bcg/ajax/autocomplete/user';
    }
}

function bcg_menu() {
    $items = array();
    $items['admin/bcg/ajax/autocomplete/user'] = array(
        'page callback' => 'bcg_ajax_autocomplete_user',
        'access callback' => 'user_access',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
    );
    return $items;
}

/**
 * bcg_ajax_autocomplete_user makes specific autocompletion
 */
function bcg_ajax_autocomplete_user($ajax_search = '') {
    $result = array();
    $vocabularies = taxonomy_get_vocabularies();
    foreach ($vocabularies as $obj) {
        if ($obj->name == 'MY_OWN_VOCABULARY') {
            $vid=$obj->vid;
            break;
        }
    }
    if (isset($vid)) {
        $results = db_query(
            'SELECT td.name ' .
            'FROM taxonomy_term_data td ' .
            'JOIN taxonomy_term_hierarchy th ' .
            'ON th.tid=td.tid ' .
            'AND th.parent=0 ' .
            'WHERE (' .
                ' td.name LIKE :name ' .
                'OR ' .
                ' td.description LIKE :name ) ' .
            'ORDER BY 1',
            array(
                ':name' => '%'.$string.'%'
            )
        )->fetchAll();
        foreach ($results as $obj) {
            $result[$obj->name] = $obj->name;
        }
    }
    drupal_json_output($result);
}


Show content only if user is an owner of this content (node)

If possible then create your own permission which should be visible under
**Variants » Basic » Selection rules ** section. For creating panel permission, check following steps:
1. Create folder structure like module -> plugins -> access -> filename.inc
2. Add following function and hooks under that file:

/**
 * @file
 * Plugin to provide access control based upon role membership.
 */

/**
 * Plugins are described by creating a $plugin array which will be used
 * by the system that includes this file.
 */
$plugin = array(
  'title' => t("Community: Access"),
  'description' => t('Control access by community.'),
  'callback' => 'dc_visibility_ctools_access_check',
  'default' => array('community' => array()),
  'settings form' => 'dc_visibility_ctools_access_settings',
  'settings form submit' => 'dc_visibility_ctools_access_settings_submit',
  'summary' => 'dc_visibility_ctools_access_summary',
  'all contexts' => TRUE,
);

/**
 * Settings form for the 'by role' access plugin
 */
function dc_visibility_ctools_access_settings($form, &$form_state, $conf) {

  return $form;
}

/**
 * Compress the community allowed to the minimum.
 */
function dc_visibility_ctools_access_settings_submit($form, &$form_state) {
  $form_state['values']['settings']['community'] = array_keys(array_filter($form_state['values']['settings']['community']));
}

/**
 * Check for access.
 */
function dc_visibility_ctools_access_check($conf, $context) {

}

function dc_visibility_ctools_access_summary($conf, $context){

}


Moving to an answer so I don't overload your question with comments.

Your second rules doesn't seem to ever load the node you want to unpublish/edit.

You need an action for "Fetch entity by property" (although I would be wary of fetching by title, I prefer the safety of node ID). For this action you can limit it to 1, so it only gets one node (there should only be 1 anyway).

Then that will fetch your node, and then you can do comparisons on that node or unpublish that node (or whatever else you may want).

The problem is though is that at this stage rules only knows it is an entity, it doesn't know what type or anything so you can't actually access its fields or do node actions like unpublish on it.

So (I think this is the only way) you have to install the http://drupal.org/project/rules_conditional module.

Then after your "Fetch entity by property" action you can add a loop and loop over entity-fetched (it will return an array even though you specified to return 1.

Then in this loop add a "Conditional".

Then in the conditional add an "If". For the if you can do entity has field, or entity is of type and content is of type. You can add multiple Ifs. If you want multiple nested ifs you have to add it like
    conditional
      if entity is of type node
        conditional
          if content is of type page
            action unpublish node

Once you have added the ifs rules will know that the fetched-entity is a node and what fields it has.

Then you can add an unpublish action and select entity-fetched (or list-item because of the loop)

So your rule might look like this:

Event: Before saving a user account
Action: Fetch entity by property(Parameter: Entity type: Node, Property: Title, Value: [account:field-business-profile], Limit result count: 1 Provides variables: Fetched entity (entity_fetched))
Action Loop: (Property: List: [entity-fetched], List item: Current list item (list_item))
  Conditional:
    If: Entity is of type (Parameter: Entity: [list-item], Entity type: Node)
      Conditional:
        If: Content is of type (Parameter: Content: [list-item], Content types: Basic page)
          Action: Unpublish content (Parameter: Content: [list-item])

Or it could look like this (without the loop, just working on the 1st entity-fetched):

Event: Before saving a user account
Action: Fetch entity by property(Parameter: Entity type: Node, Property: Title, Value: [account:field-business-profile], Limit result count: 1 Provides variables: Fetched entity (entity_fetched))
Conditional:
  If: Entity is of type (Parameter: Entity: [entity-fetched:0], Entity type: Node)
    Conditional:
      If: Content is of type (Parameter: Content: [entity-fetched:0], Content types: Basic page)
        Action: Unpublish content (Parameter: Content: [entity-fetched:0])


Figured this out.  Have to add the following 2 filters:

operator is "Is greater than or equal to" value is today

AND

operator is "Is less than" value is today +24 hours

Notes:

Must use "Is greater than or equal to" to include today at midnight and must use "Is less than" to filter out tomorrow at midnight.

It does not matter what value type you select, machine readable or offset.

The value "today" literally returns the time of midnight on today's date.  This means setting operator Is equal to "today" only returns results dated on exactly midnight of today, hence why zero results were returned.

SQL for "today" taken from Views query:

DATE_FORMAT(('2020-03-29T07:00:00' + INTERVAL -25200 SECOND), '%Y-%m-%d\T%H:%i:%s'))

"+ INTERVAL -25200 SECOND" is -7 hours correction for my time zone so time is T00:00:00 or midnight.


I'm not sure what do you mean by zoom!! Image zoom or text resize?

Anyways you need to install 3 modules

for image zoom use deepzoom
for text resize use textsize
for print and save use Printer, email and PDF versions


Strange log message and node not found for anonymous

Check your custom 404 configuration at admin/config/system/site-information.

Also check if this custom configuration is directing users to a Panels page (check Structure > Panels or Structure > Pages if you have Panels and Page Manager installed). They may be handling different custom 404 pages for different roles. Perhaps the Panel variant that handles the 404 page for anonymous is missing or redirecting to a non-existing page.


Rendering view output into a separate region

There are a lot of hook for views, you can use hook_views_pre_execute or another one it depends of what you need to do.

See here the list


How can I install CKEditor on a server without downloading the files locally?

Pantheon assumes that you are using git; although there is an on-server development feature, the primary workflow is designed to use git as a conduit between your local machine and Pantheon's servers.

Nearly all tutorials you encounter will also assume you are able to download files to your server/local machine.

Even if you don't install Drupal to your local machine, you can clone your Pantheon repository and download/edit/commit the files locally without running Apache, MySQL, etc.  (Documentation here)

I would not try loading modules via URL using Pantheon; you need to learn how to use Git or you will constantly be running into problems later when you try to sync your sites.

Alternately, if you just want a WSYIWYG editor and some other nice features, you could try spinning up the Panoply distribution of Drupal 7, which includes a bunch of modules pre-configured out of the box (though it still has a fair number of bugs).


How to append #rss to each RSS feed item's URL built with Views?

In the RSS view, look at the format section. If you're like me, you'll have the following

Format: RSS feed
Show: Content

Make sure to switch "Content" to "Fields", otherwise you won't ever see the "rewrite" options that the commentators keep mentioning above. Add all the necessary fields you'll need for the RSS feed.  You should get something like this (Ignore the field Hardcoded...)

Now, click on the "Content:Path" field (which you should've added), expand the "Rewrite Results" section, and tick the "Rewrite the output of this field" checkbox.
In the provided textbox, add your custom URL parameter. In my case, I wanted a hashtag, so I added the following:

[path]#rss

And, you're done! You may be asking, how did you know what to put in that textbox? Scroll down a bit and expand the "Replacement Patterns" section. You can add all types of stuff. I found this post useful. Of course, I discovered it after I had solved the problem. Still good to know.

Feels good solving my own problem, though special thanks to Remi who pointed me in the right direction.

It seems pretty obvious after the fact and maybe that's why no one wanted to actually write out an answer but for beginners like me, it's obscure. Anyway, I wrote this out in detail in the hopes you won't get stuck here. Hope it helps :)


Allowing simple footer customisation in settings?

In Drupal 6, the Site information settings page at /admin/settings/site-information has a "Footer Information" field that meets your description above.  If this field is not empty, and you do a major upgrade of your D6 site to D7, then your footer information will be moved into a block called "Footer message".  While it would be possible to re-implement the "Footer Information" field from D6 in D7 with a custom module, or in the settings for your theme (which would be even easier) I think it is clear that D7 designers felt that using a block for this purpose was the best and most general solution.


On what event does the cron begin its execution?

So, my question is why did the cron not run for these days? What is
  the exact event which triggers cron to start running?

Poormans cron is D7 default cronjob handler, which invokes cron hooks. But it depends on traffic, when a user visits a page it will check last time at which cron was run, and schedule it to run if needed according to interval set.

Summary : This is not reliable if cron has to be run daily. To do so open up crontab from terminal (crontab -l will list the jobs, crontab -e will let you edit jobs) Ex:

0 0 * * * wget -O - -q -t 1 http://<yoursite>/cron.php?cron_key=<yourkey>

Will schedule cron job @midnight daily.


Rate content and attribute points to author

You're looking for the User Points module. For node ratings you can use the User points Nodes and Comments or/and the Fivestar modules. There are also plenty of other modules that integrate with the User Points module, there's a nice list in the User Points Contributed modules page.


You can use Webform module and create multiple separate forms.

On submission of first (on front page), you can redirect users to another page (another webform) based on their selection using custom redirect in webform settings and tokens [submission:values:?] that use data from webform that has been submitted. You just have to set "key" on selects in your form properly.


One of the only ways I have been successful at making required multistep forms before having access to the website was using CTools to construct the form workflow, and submitting the data on submit callbacks into Drupal with node_save().

See Intro to Drupal 6 Multistep Form Domination Using Chaos Tools.


Pathauto has migrations for settings & patterns built into the D8 module. Linkit doesn't have built-in support migrations.


You can do this by implementing hook_file_presave($file)

  This hook is called when a file has been added to the database. The hook doesn't distinguish between files created as a result of a copy or those created by an upload.

In this hook, you need to:

Test if file is really an image. I suggest using mimetype for this task: $file->filemime
Recognize which image processing library your Drupal is using. See image_get_available_toolkits(), image_gd_check_settings() and ImageMagick.
Process that file. This part is general programming issue already well answered on Stack Overflow - I see no point in reposting it here, I think I covered Drupal part of the question now.


Can Commerce Kickstart be used to add Drupal Commerce to an existing site?

No, you can not install an installation profile after Drupal has already been installed. What you can do is make a separate installation with Kickstart Commerce and compare configuration when you're stuck.

How hard Commerce is to install depends on you previous Drupal experience. If this is your first time around with Drupal, it will be pretty hard. But if you're already familiar with entities, views and rules, you'll be fine.


How to prepend a Views query with another query?

Why do you think you need to alter the query itself? You literally said you needed to set a …session value.

You can issue any query prior to the views query on that page load to achieve the desired affect. Eg db_query('set mysql_max_group_concat=5;');

If you want to so it in the views lifecycle you could use any hook_views_* api call which states it runs prior to query execution. Look at the views api docs.

Or you could likely use hook_page_build  for all its worth. Or hook_init ... whatever suits your needs.


Yes, the invalidation is automatic. From the debugging you have done so far you only know that the tag is somewhere on the page, but you don't know where it is and obviously it is not where you want it to be. Look in the database table cache_render. Clear the cache, so that it is emptied. Now request the page with the block and check for all cached elements the column tags.

By the way, you don't need to set cache keys on a block, because blocks do this automatically and for the problem here it's confusing, because the taxonomy id you set in the keys is not invalidated.